Bug 933567 - Clean up Mask implementation a bit. r=mattwoodrow
authorAndreas Gal <gal@uci.edu>
Mon, 25 Nov 2013 09:22:33 -0500
changeset 157396 f6a7521fd5183ecc0f77b411c98a85780d80da9d
parent 157395 7e31cf975f22f209c04c67c13a6065efef0cf10e
child 157397 91c18951d81a8c014acda36b66fb7433b8c1fdbf
push id25712
push userryanvm@gmail.com
push dateMon, 25 Nov 2013 19:23:16 +0000
treeherdermozilla-central@53d55d2d0a25 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs933567
milestone28.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 933567 - Clean up Mask implementation a bit. r=mattwoodrow
gfx/2d/DrawTargetSkia.cpp
gfx/2d/DrawTargetSkia.h
--- a/gfx/2d/DrawTargetSkia.cpp
+++ b/gfx/2d/DrawTargetSkia.cpp
@@ -601,29 +601,17 @@ DrawTargetSkia::Mask(const Pattern &aSou
 
   SkPaint maskPaint;
   SetPaintPattern(maskPaint, aMask);
   
   SkLayerRasterizer *raster = new SkLayerRasterizer();
   raster->addLayer(maskPaint);
   SkSafeUnref(paint.mPaint.setRasterizer(raster));
 
-  // Skia only uses the mask rasterizer when we are drawing a path/rect.
-  // Take our destination bounds and convert them into user space to use
-  // as the path to draw.
-  SkPath path;
-  path.addRect(SkRect::MakeWH(SkScalar(mSize.width), SkScalar(mSize.height)));
- 
-  Matrix temp = mTransform;
-  temp.Invert();
-  SkMatrix mat;
-  GfxMatrixToSkiaMatrix(temp, mat);
-  path.transform(mat);
-
-  mCanvas->drawPath(path, paint.mPaint);
+  mCanvas->drawRect(SkRectCoveringWholeSurface(), paint.mPaint);
 }
 
 void
 DrawTargetSkia::MaskSurface(const Pattern &aSource,
                             SourceSurface *aMask,
                             Point aOffset,
                             const DrawOptions &aOptions)
 {
@@ -889,16 +877,24 @@ void
 DrawTargetSkia::MarkChanged()
 {
   if (mSnapshot) {
     mSnapshot->DrawTargetWillChange();
     mSnapshot = nullptr;
   }
 }
 
+// Return a rect (in user space) that covers the entire surface by applying
+// the inverse of GetTransform() to (0, 0, mSize.width, mSize.height).
+SkRect
+DrawTargetSkia::SkRectCoveringWholeSurface() const
+{
+  return RectToSkRect(mTransform.TransformBounds(Rect(0, 0, mSize.width, mSize.height)));
+}
+
 void
 DrawTargetSkia::SnapshotDestroyed()
 {
   mSnapshot = nullptr;
 }
 
 }
 }
--- a/gfx/2d/DrawTargetSkia.h
+++ b/gfx/2d/DrawTargetSkia.h
@@ -120,16 +120,18 @@ public:
   }
 
 private:
   friend class SourceSurfaceSkia;
   void SnapshotDestroyed();
 
   void MarkChanged();
 
+  SkRect SkRectCoveringWholeSurface() const;
+
 #ifdef USE_SKIA_GPU
   /*
    * These members have inter-dependencies, but do not keep each other alive, so
    * destruction order is very important here: mGrContext uses mGrGLInterface, and
    * through it, uses mGLContext, so it is important that they be declared in the
    * present order.
    */
   RefPtr<GenericRefCountedBase> mGLContext;