Bug 895116: Fix masking with BasicCompositor r=mattwoodrow
authorDavid Zbarsky <dzbarsky@gmail.com>
Tue, 23 Jul 2013 16:38:46 -0700
changeset 152011 98d1f6e62fab8bdb54811fceb9e8455bc1650ab8
parent 152010 a9714e5897799814cf4c134cc710bbb797e44992
child 152012 d9dbb5dbb96a60b6c921ef80c955e48a97b2eaa5
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs895116
milestone25.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 895116: Fix masking with BasicCompositor r=mattwoodrow
gfx/layers/basic/BasicCompositor.cpp
--- a/gfx/layers/basic/BasicCompositor.cpp
+++ b/gfx/layers/basic/BasicCompositor.cpp
@@ -48,22 +48,20 @@ public:
   virtual const char *Name() { return "DeprecatedTextureHostBasic"; }
 
 protected:
   virtual void UpdateImpl(const SurfaceDescriptor& aImage,
                           nsIntRegion *aRegion,
                           nsIntPoint*) MOZ_OVERRIDE
   {
     AutoOpenSurface surf(OPEN_READ_ONLY, aImage);
-    mFormat =
-      (surf.ContentType() == gfxASurface::CONTENT_COLOR_ALPHA) ? FORMAT_B8G8R8A8 :
-                                                                 FORMAT_B8G8R8X8;
     mThebesSurface = ShadowLayerForwarder::OpenDescriptor(OPEN_READ_ONLY, aImage);
     mThebesImage = mThebesSurface->GetAsImageSurface();
     MOZ_ASSERT(mThebesImage);
+    mFormat = ImageFormatToSurfaceFormat(mThebesImage->Format());
     mSurface = nullptr;
     mSize = IntSize(mThebesImage->Width(), mThebesImage->Height());
   }
 
   virtual void EnsureSurface() { }
 
   virtual bool Lock() MOZ_OVERRIDE
   {
@@ -250,19 +248,23 @@ DrawSurfaceWithTextureCoords(DrawTarget 
   // Compute a transform that maps sourceRect to aDestRect.
   gfxMatrix transform =
     gfxUtils::TransformRectToRect(sourceRect,
                                   gfxPoint(aDestRect.x, aDestRect.y),
                                   gfxPoint(aDestRect.XMost(), aDestRect.y),
                                   gfxPoint(aDestRect.XMost(), aDestRect.YMost()));
   Matrix matrix = ToMatrix(transform);
   if (aMask) {
-    aDest->Mask(SurfacePattern(aSource, EXTEND_REPEAT, matrix),
-                SurfacePattern(aMask, EXTEND_CLAMP, aMaskTransform),
-                DrawOptions(aOpacity));
+    NS_ASSERTION(matrix._11 == 1.0f && matrix._12 == 0.0f &&
+                 matrix._21 == 0.0f && matrix._22 == 1.0f,
+                 "Can only handle translations for mask transform");
+    aDest->MaskSurface(SurfacePattern(aSource, EXTEND_CLAMP, matrix),
+                       aMask,
+                       Point(matrix._31, matrix._32),
+                       DrawOptions(aOpacity));
   } else {
     aDest->FillRect(aDestRect,
                     SurfacePattern(aSource, EXTEND_REPEAT, matrix),
                     DrawOptions(aOpacity));
   }
 }
 
 void