Bug 1220624: Make MaskSurface properly take into account the possibilities of partial uploads. r=jrmuizel
authorBas Schouten <bschouten@mozilla.com>
Thu, 05 Nov 2015 00:05:26 +0100
changeset 271171 ea7b16628b48ebfe1561798930c7a3ad793e2cbf
parent 271170 722e121f6ce6f08e4c875343c24cedc5ba095800
child 271172 980aebe436cf782cba8c65eeff46ec3dec4fc23f
push id67580
push userbschouten@mozilla.com
push dateWed, 04 Nov 2015 23:05:48 +0000
treeherdermozilla-inbound@ea7b16628b48 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1220624
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 1220624: Make MaskSurface properly take into account the possibilities of partial uploads. r=jrmuizel
gfx/2d/DrawTargetD2D1.cpp
--- a/gfx/2d/DrawTargetD2D1.cpp
+++ b/gfx/2d/DrawTargetD2D1.cpp
@@ -279,36 +279,43 @@ DrawTargetD2D1::MaskSurface(const Patter
                             SourceSurface *aMask,
                             Point aOffset,
                             const DrawOptions &aOptions)
 {
   MarkChanged();
 
   RefPtr<ID2D1Bitmap> bitmap;
 
-  RefPtr<ID2D1Image> image = GetImageForSurface(aMask, ExtendMode::CLAMP);
+  Matrix mat = Matrix::Translation(aOffset);
+  RefPtr<ID2D1Image> image = GetImageForSurface(aMask, mat, ExtendMode::CLAMP, nullptr);
+
+  MOZ_ASSERT(!mat.HasNonTranslation());
+  aOffset.x = mat._31;
+  aOffset.y = mat._32;
 
   if (!image) {
     gfxWarning() << "Failed to get image for surface.";
     return;
   }
 
   PrepareForDrawing(aOptions.mCompositionOp, aSource);
 
   // FillOpacityMask only works if the antialias mode is MODE_ALIASED
   mDC->SetAntialiasMode(D2D1_ANTIALIAS_MODE_ALIASED);
 
-  IntSize size = aMask->GetSize();
-  Rect maskRect = Rect(0.f, 0.f, Float(size.width), Float(size.height));
-  image->QueryInterface((ID2D1Bitmap**)&bitmap);
+  image->QueryInterface((ID2D1Bitmap**)getter_AddRefs(bitmap));
   if (!bitmap) {
     gfxWarning() << "FillOpacityMask only works with Bitmap source surfaces.";
     return;
   }
 
+  IntSize size = IntSize(bitmap->GetSize().width, bitmap->GetSize().height);
+
+  Rect maskRect = Rect(0.f, 0.f, Float(size.width), Float(size.height));
+
   Rect dest = Rect(aOffset.x, aOffset.y, Float(size.width), Float(size.height));
   RefPtr<ID2D1Brush> brush = CreateBrushForPattern(aSource, aOptions.mAlpha);
   mDC->FillOpacityMask(bitmap, brush, D2D1_OPACITY_MASK_CONTENT_GRAPHICS, D2DRect(dest), D2DRect(maskRect));
 
   mDC->SetAntialiasMode(D2D1_ANTIALIAS_MODE_PER_PRIMITIVE);
 
   FinalizeDrawing(aOptions.mCompositionOp, aSource);
 }