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=sledru
authorMatt Woodrow <mwoodrow@mozilla.com>
Fri, 28 Feb 2014 12:32:38 +1300
changeset 183130 d788af3a9b200e4095132cc1d87c41777356e763
parent 183129 ef5a3cd77982b5c5e4a7d40537bc353a245359c3
child 183131 fa6cb4c0421dd26a750d6a35a22483f332ddc2e6
push id3343
push userffxbld
push dateMon, 17 Mar 2014 21:55:32 +0000
treeherdermozilla-beta@2f7d3415f79f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnrc, sledru
bugs970294
milestone29.0a2
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=sledru
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),
                                                                    SurfaceFormat::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
     gfx3DMatrix effectiveTransform;
     gfx::To3DMatrix(aLayer->GetEffectiveTransform(), effectiveTransform);
     nsRefPtr<gfxASurface> result =
       Transform3D(untransformedDT->Snapshot(), aTarget, bounds,
--- 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());
 }
 
 /* static */ already_AddRefed<gfxContext>
 gfxContext::ContextForDrawTarget(DrawTarget* aTarget)
 {
   Matrix transform = aTarget->GetTransform();
   nsRefPtr<gfxContext> result = new gfxContext(aTarget);
--- a/gfx/thebes/gfxContext.h
+++ b/gfx/thebes/gfxContext.h
@@ -46,17 +46,18 @@ public:
      */
     gfxContext(gfxASurface *surface);
 
     /**
      * Initialize this context from a DrawTarget.
      * Strips any transform from aTarget.
      * aTarget will be flushed in the gfxContext's destructor.
      */
-    gfxContext(mozilla::gfx::DrawTarget *aTarget);
+    gfxContext(mozilla::gfx::DrawTarget *aTarget,
+               const mozilla::gfx::Point& aDeviceOffset = mozilla::gfx::Point());
 
     ~gfxContext();
 
     /**
      * Create a new gfxContext wrapping aTarget and preserving aTarget's
      * transform. Note that the transform is moved from aTarget to the resulting
      * gfxContext, aTarget will no longer have its transform.
      */