Bug 1229202 (part 7) - Pass a DrawTarget to gfxXlibNativeRenderer::DrawDirect(). r=mattwoodrow.
authorNicholas Nethercote <nnethercote@mozilla.com>
Wed, 02 Dec 2015 15:32:17 -0800
changeset 309492 3e1abfc084f08983da4c873d41f55429a0c00a2a
parent 309491 f07938cebd6f8a0c1bb6b21d6e1986d4dc2e432f
child 309493 19dce9ab4d97753da057403d47e4e0a40b884105
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1229202
milestone45.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1229202 (part 7) - Pass a DrawTarget to gfxXlibNativeRenderer::DrawDirect(). r=mattwoodrow.
gfx/thebes/gfxXlibNativeRenderer.cpp
gfx/thebes/gfxXlibNativeRenderer.h
--- a/gfx/thebes/gfxXlibNativeRenderer.cpp
+++ b/gfx/thebes/gfxXlibNativeRenderer.cpp
@@ -131,23 +131,23 @@ FINISH:
 
 #define MAX_STATIC_CLIP_RECTANGLES 50
 
 /**
  * Try the direct path.
  * @return True if we took the direct path
  */
 bool
-gfxXlibNativeRenderer::DrawDirect(gfxContext *ctx, IntSize size,
+gfxXlibNativeRenderer::DrawDirect(DrawTarget* aDT, IntSize size,
                                   uint32_t flags,
                                   Screen *screen, Visual *visual)
 {
     // We need to actually borrow the context because we want to read out the
     // clip rectangles.
-    BorrowedCairoContext borrowed(ctx->GetDrawTarget());
+    BorrowedCairoContext borrowed(aDT);
     if (!borrowed.mCairo) {
       return false;
     }
 
     bool direct = DrawCairo(borrowed.mCairo, size, flags, screen, visual);
     borrowed.Finish();
 
     return direct;
@@ -485,30 +485,33 @@ gfxXlibNativeRenderer::Draw(gfxContext* 
         // little larger than the drawingRect;
         affectedRect.Inflate(filterRadius);
 
         NATIVE_DRAWING_NOTE("FALLBACK: matrix not integer translation");
     } else if (!canDrawOverBackground) {
         NATIVE_DRAWING_NOTE("FALLBACK: unsupported operator");
     }
 
+    DrawTarget* drawTarget = ctx->GetDrawTarget();
+
     // Clipping to the region affected by drawing allows us to consider only
     // the portions of the clip region that will be affected by drawing.
     gfxRect clipExtents;
     {
         gfxContextAutoSaveRestore autoSR(ctx);
         ctx->Clip(affectedRect);
 
         clipExtents = ctx->GetClipExtents();
-        if (clipExtents.IsEmpty())
+        if (clipExtents.IsEmpty()) {
             return; // nothing to do
-
+        }
         if (canDrawOverBackground &&
-            DrawDirect(ctx, size, flags, screen, visual))
+            DrawDirect(drawTarget, size, flags, screen, visual)) {
           return;
+        }
     }
 
     IntRect drawingRect(IntPoint(0, 0), size);
     // Drawing need only be performed within the clip extents
     // (and padding for the filter).
     if (!matrixIsIntegerTranslation) {
         // The source surface may need to be a little larger than the clip
         // extents due to the filter footprint.
@@ -520,17 +523,16 @@ gfxXlibNativeRenderer::Draw(gfxContext* 
                          int32_t(clipExtents.Y()),
                          int32_t(clipExtents.Width()),
                          int32_t(clipExtents.Height()));
     drawingRect.IntersectRect(drawingRect, intExtents);
 
     gfxPoint offset(drawingRect.x, drawingRect.y);
 
     DrawingMethod method;
-    DrawTarget* drawTarget = ctx->GetDrawTarget();
     Matrix dtTransform = drawTarget->GetTransform();
     gfxPoint deviceTranslation = gfxPoint(dtTransform._31, dtTransform._32);
     cairo_surface_t* cairoTarget = static_cast<cairo_surface_t*>
             (drawTarget->GetNativeSurface(NativeSurfaceType::CAIRO_SURFACE));
 
     cairo_surface_t* tempXlibSurface =
         CreateTempXlibSurface(cairoTarget, drawTarget, size,
                               canDrawOverBackground, flags, screen, visual,
--- a/gfx/thebes/gfxXlibNativeRenderer.h
+++ b/gfx/thebes/gfxXlibNativeRenderer.h
@@ -81,17 +81,17 @@ public:
      * rendered image into a surface similar to the surface of ctx; if
      * successful, a pointer to the new gfxASurface is stored in *resultSurface,
      * otherwise *resultSurface is set to nullptr.
      */
     void Draw(gfxContext* ctx, mozilla::gfx::IntSize size,
               uint32_t flags, Screen *screen, Visual *visual);
 
 private:
-    bool DrawDirect(gfxContext *ctx, mozilla::gfx::IntSize bounds,
+    bool DrawDirect(mozilla::gfx::DrawTarget* aDT, mozilla::gfx::IntSize bounds,
                     uint32_t flags, Screen *screen, Visual *visual);
 
     bool DrawCairo(cairo_t* cr, mozilla::gfx::IntSize size,
                    uint32_t flags, Screen *screen, Visual *visual);
 
     void DrawFallback(mozilla::gfx::DrawTarget* dt, gfxContext* ctx,
                       gfxASurface* aSurface, mozilla::gfx::IntSize& size,
                       mozilla::gfx::IntRect& drawingRect, bool canDrawOverBackground,