Bug 759036. Fix a masking bug in Thebes-Azure. r=Bas,a=akeybl
authorNicholas Cameron <ncameron@mozilla.com>
Thu, 14 Jun 2012 10:40:43 +1200
changeset 100511 ce812b5b6ab1630b9b97f55437e0eb8d23b41580
parent 100510 10d1a127d9b8fecfbf2c7f15464b61b4b95b98a6
child 100512 42817f2f2c3e8cb1da3e79e26ac5f0c99e87a6d6
push id173
push userlsblakk@mozilla.com
push dateFri, 24 Aug 2012 15:39:16 +0000
treeherdermozilla-release@bcc45eb1fb41 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBas, akeybl
bugs759036
milestone15.0a2
Bug 759036. Fix a masking bug in Thebes-Azure. r=Bas,a=akeybl
gfx/thebes/gfxContext.cpp
gfx/thebes/gfxPattern.cpp
--- a/gfx/thebes/gfxContext.cpp
+++ b/gfx/thebes/gfxContext.cpp
@@ -41,20 +41,20 @@ public:
     gfxContext::AzureState &state = mContext->CurrentState();
 
     if (state.pattern) {
       return *state.pattern->GetPattern(mContext->mDT, state.patternTransformChanged ? &state.patternTransform : nsnull);
     } else if (state.sourceSurface) {
       Matrix transform = state.surfTransform;
 
       if (state.patternTransformChanged) {
-        Matrix mat = state.patternTransform;
+        Matrix mat = mContext->mDT->GetTransform();
         mat.Invert();
 
-        transform = mat * mContext->mDT->GetTransform() * transform;
+        transform = mat * state.patternTransform * transform;
       }
 
       mPattern = new (mSurfacePattern.addr())
         SurfacePattern(state.sourceSurface, EXTEND_CLAMP, transform);
       return *mPattern;
     } else {
       mPattern = new (mColorPattern.addr())
         ColorPattern(state.color);
@@ -1418,17 +1418,17 @@ gfxContext::Mask(gfxASurface *surface, c
     // Lifetime needs to be limited here as we may simply wrap surface's data.
     RefPtr<SourceSurface> sourceSurf =
       gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(mDT, surface);
 
     gfxPoint pt = surface->GetDeviceOffset();
     mDT->Mask(GeneralPattern(this), 
               SurfacePattern(sourceSurf, EXTEND_CLAMP,
                              Matrix(1.0f, 0, 0, 1.0f, Float(offset.x - pt.x), Float(offset.y - pt.y))),
-                             DrawOptions(1.0f, CurrentState().op, CurrentState().aaMode));
+              DrawOptions(1.0f, CurrentState().op, CurrentState().aaMode));
   }
 }
 
 void
 gfxContext::Paint(gfxFloat alpha)
 {
   SAMPLE_LABEL("gfxContext", "Paint");
   if (mCairo) {
--- a/gfx/thebes/gfxPattern.cpp
+++ b/gfx/thebes/gfxPattern.cpp
@@ -162,17 +162,16 @@ gfxPattern::GetPattern(DrawTarget *aTarg
           gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(aTarget, gfxSurf);
       }
 
       if (mSourceSurface) {
         Matrix newMat = ToMatrix(matrix);
 
         AdjustTransformForPattern(newMat, aTarget->GetTransform(), aPatternTransform);
 
-        newMat.Invert();
         double x, y;
         cairo_surface_get_device_offset(surf, &x, &y);
         newMat.Translate(-x, -y);
         mGfxPattern = new (mSurfacePattern.addr())
           SurfacePattern(mSourceSurface, ToExtendMode(extend), newMat, ToFilter(filter));
         return mGfxPattern;
       }
       break;
@@ -204,18 +203,16 @@ gfxPattern::GetPattern(DrawTarget *aTarg
         cairo_matrix_t mat;
         cairo_pattern_get_matrix(mPattern, &mat);
         gfxMatrix matrix(*reinterpret_cast<gfxMatrix*>(&mat));
 
         Matrix newMat = ToMatrix(matrix);
 
         AdjustTransformForPattern(newMat, aTarget->GetTransform(), aPatternTransform);
 
-        newMat.Invert();
-
         mGfxPattern = new (mLinearGradientPattern.addr())
           LinearGradientPattern(Point(x1, y1), Point(x2, y2), mStops, newMat);
 
         return mGfxPattern;
       }
       break;
     }
   case CAIRO_PATTERN_TYPE_RADIAL:
@@ -243,18 +240,16 @@ gfxPattern::GetPattern(DrawTarget *aTarg
         cairo_matrix_t mat;
         cairo_pattern_get_matrix(mPattern, &mat);
         gfxMatrix matrix(*reinterpret_cast<gfxMatrix*>(&mat));
 
         Matrix newMat = ToMatrix(matrix);
 
         AdjustTransformForPattern(newMat, aTarget->GetTransform(), aPatternTransform);
 
-        newMat.Invert();
-
         double x1, y1, x2, y2, r1, r2;
         cairo_pattern_get_radial_circles(mPattern, &x1, &y1, &r1, &x2, &y2, &r2);
         mGfxPattern = new (mRadialGradientPattern.addr())
           RadialGradientPattern(Point(x1, y1), Point(x2, y2), r1, r2, mStops, newMat);
 
         return mGfxPattern;
       }
       break;
@@ -412,17 +407,18 @@ gfxPattern::CairoStatus()
   }
 }
 
 void
 gfxPattern::AdjustTransformForPattern(Matrix &aPatternTransform,
                                       const Matrix &aCurrentTransform,
                                       const Matrix *aOriginalTransform)
 {
+  aPatternTransform.Invert();
   if (!aOriginalTransform) {
     return;
   }
 
-  Matrix mat = *aOriginalTransform;
+  Matrix mat = aCurrentTransform;
   mat.Invert();
 
-  aPatternTransform = mat * aCurrentTransform * aPatternTransform;
-}
\ No newline at end of file
+  aPatternTransform = aPatternTransform * *aOriginalTransform * mat;
+}