Bug 970294 - Set our surface offset as a gfxContext device offset instead of a transform so that other callers don't accidentally overwrite it. r=nrc, a=lsblakk
authorMatt Woodrow <mwoodrow@mozilla.com>
Fri, 28 Feb 2014 12:32:38 +1300
changeset 176442 eb47781c21ef6799c7358b67fcacfad29143de28
parent 176441 f7953ebceb6055db47e7e515f2302cfe3596c62f
child 176443 a99090d5a6f4203ae253e5de5b84a25e310b3072
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnrc, lsblakk
bugs970294
milestone28.0
Bug 970294 - Set our surface offset as a gfxContext device offset instead of a transform so that other callers don't accidentally overwrite it. r=nrc, a=lsblakk
gfx/layers/basic/BasicLayerManager.cpp
gfx/thebes/gfxContext.cpp
gfx/thebes/gfxContext.h
--- a/gfx/layers/basic/BasicLayerManager.cpp
+++ b/gfx/layers/basic/BasicLayerManager.cpp
@@ -954,35 +954,34 @@ BasicLayerManager::PaintLayer(gfxContext
     const nsIntRect& bounds = visibleRegion.GetBounds();
     RefPtr<DrawTarget> untransformedDT =
       gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(IntSize(bounds.width, bounds.height),
                                                                    FORMAT_B8G8R8A8);
     if (!untransformedDT) {
       return;
     }
 
-    nsRefPtr<gfxContext> groupTarget = new gfxContext(untransformedDT);
-    groupTarget->Translate(gfxPoint(-bounds.x, -bounds.y));
+    nsRefPtr<gfxContext> groupTarget = new gfxContext(untransformedDT,
+                                                      Point(bounds.x, bounds.y));
 
     PaintSelfOrChildren(paintLayerContext, groupTarget);
 
     // Temporary fast fix for bug 725886
     // Revert these changes when 725886 is ready
     NS_ABORT_IF_FALSE(untransformedDT,
                       "We should always allocate an untransformed surface with 3d transforms!");
     gfxRect destRect;
 #ifdef DEBUG
     if (aLayer->GetDebugColorIndex() != 0) {
       gfxRGBA  color((aLayer->GetDebugColorIndex() & 1) ? 1.0 : 0.0,
                      (aLayer->GetDebugColorIndex() & 2) ? 1.0 : 0.0,
                      (aLayer->GetDebugColorIndex() & 4) ? 1.0 : 0.0,
                      1.0);
 
-      nsRefPtr<gfxContext> temp = new gfxContext(untransformedDT);
-      temp->Translate(gfxPoint(-bounds.x, -bounds.y));
+      nsRefPtr<gfxContext> temp = new gfxContext(untransformedDT, Point(bounds.x, bounds.y));
       temp->SetColor(color);
       temp->Paint();
     }
 #endif
     const gfx3DMatrix& effectiveTransform = aLayer->GetEffectiveTransform();
     nsRefPtr<gfxASurface> result =
       Transform3D(untransformedDT->Snapshot(), aTarget, bounds,
                   effectiveTransform, destRect);
--- a/gfx/thebes/gfxContext.cpp
+++ b/gfx/thebes/gfxContext.cpp
@@ -93,30 +93,31 @@ gfxContext::gfxContext(gfxASurface *surf
     Translate(gfxPoint(0, size.width));
     gfxMatrix matrix(0, -1,
                       1,  0,
                       0,  0);
     Multiply(matrix);
   }
 }
 
-gfxContext::gfxContext(DrawTarget *aTarget)
+gfxContext::gfxContext(DrawTarget *aTarget, const Point& aDeviceOffset)
   : mPathIsRect(false)
   , mTransformChanged(false)
   , mCairo(nullptr)
   , mRefCairo(nullptr)
   , mSurface(nullptr)
   , mFlags(0)
   , mDT(aTarget)
   , mOriginalDT(aTarget)
 {
   MOZ_COUNT_CTOR(gfxContext);
 
   mStateStack.SetLength(1);
   CurrentState().drawTarget = mDT;
+  CurrentState().deviceOffset = aDeviceOffset;
   mDT->SetTransform(Matrix());
 }
 
 gfxContext::~gfxContext()
 {
   if (mCairo) {
     cairo_destroy(mCairo);
   }
--- a/gfx/thebes/gfxContext.h
+++ b/gfx/thebes/gfxContext.h
@@ -44,17 +44,18 @@ public:
     /**
      * Initialize this context from a surface.
      */
     gfxContext(gfxASurface *surface);
 
     /**
      * Initialize this context from a DrawTarget.
      */
-    gfxContext(mozilla::gfx::DrawTarget *aTarget);
+    gfxContext(mozilla::gfx::DrawTarget *aTarget,
+               const mozilla::gfx::Point& aDeviceOffset = mozilla::gfx::Point());
 
     ~gfxContext();
 
     /**
      * Return the surface that this gfxContext was created with
      */
     gfxASurface *OriginalSurface();