Bug 1059033 - Part 1: Cull DrawTargetTiled operations where we can. r=Bas
authorMatt Woodrow <mwoodrow@mozilla.com>
Wed, 03 Sep 2014 09:20:10 +1200
changeset 244267 cbffc438afd755c4661174b6c7d6734a99e553e5
parent 244266 913c2178085a4905387f229967d40d71c103a112
child 244268 dae2525a189c25147e811da3fd932efa48922faf
push id30418
push userjmuizelaar@mozilla.com
push dateTue, 02 Sep 2014 23:57:30 +0000
treeherdertry@2983b61bb70f [default view] [failures only]
reviewersBas
bugs1059033
milestone35.0a1
Bug 1059033 - Part 1: Cull DrawTargetTiled operations where we can. r=Bas
gfx/2d/DrawTargetTiled.cpp
--- a/gfx/2d/DrawTargetTiled.cpp
+++ b/gfx/2d/DrawTargetTiled.cpp
@@ -144,27 +144,21 @@ DrawTargetTiled::Snapshot()
     for (size_t i = 0; i < mTiles.size(); i++) { \
     \
     \
     mTiles[i].mDrawTarget->command(arg1, arg2, arg3, arg4, arg5); \
     } \
   }
 
 TILED_COMMAND(Flush)
-TILED_COMMAND5(DrawSurface, SourceSurface*, const Rect&,
-                            const Rect&, const DrawSurfaceOptions&,
-                            const DrawOptions&)
 TILED_COMMAND4(DrawFilter, FilterNode*, const Rect&, const Point&, const DrawOptions&)
 TILED_COMMAND1(ClearRect, const Rect&)
 TILED_COMMAND4(MaskSurface, const Pattern&, SourceSurface*, Point, const DrawOptions&)
-TILED_COMMAND3(FillRect, const Rect&, const Pattern&, const DrawOptions&)
 TILED_COMMAND4(StrokeRect, const Rect&, const Pattern&, const StrokeOptions&, const DrawOptions&)
 TILED_COMMAND5(StrokeLine, const Point&, const Point&, const Pattern&, const StrokeOptions&, const DrawOptions&)
-TILED_COMMAND4(Stroke, const Path*, const Pattern&, const StrokeOptions&, const DrawOptions&)
-TILED_COMMAND3(Fill, const Path*, const Pattern&, const DrawOptions&)
 TILED_COMMAND5(FillGlyphs, ScaledFont*, const GlyphBuffer&, const Pattern&, const DrawOptions&, const GlyphRenderingOptions*)
 TILED_COMMAND3(Mask, const Pattern&, const Pattern&, const DrawOptions&)
 TILED_COMMAND1(PushClip, const Path*)
 TILED_COMMAND1(PushClipRect, const Rect&)
 TILED_COMMAND(PopClip)
 
 void
 DrawTargetTiled::CopySurface(SourceSurface *aSurface,
@@ -193,10 +187,66 @@ DrawTargetTiled::SetTransform(const Matr
   for (size_t i = 0; i < mTiles.size(); i++) {
     Matrix mat = aTransform;
     mat.PostTranslate(Float(-mTiles[i].mTileOrigin.x), Float(-mTiles[i].mTileOrigin.y));
     mTiles[i].mDrawTarget->SetTransform(mat);
   }
   DrawTarget::SetTransform(aTransform);
 }
 
+void
+DrawTargetTiled::DrawSurface(SourceSurface* aSurface, const Rect& aDest, const Rect& aSource, const DrawSurfaceOptions& aSurfaceOptions, const DrawOptions& aDrawOptions)
+{
+  Rect deviceRect = mTransform.TransformBounds(aDest);
+  for (size_t i = 0; i < mTiles.size(); i++) {
+    if (deviceRect.Intersects(Rect(mTiles[i].mTileOrigin.x,
+                                   mTiles[i].mTileOrigin.y,
+                                   mTiles[i].mDrawTarget->GetSize().width,
+                                   mTiles[i].mDrawTarget->GetSize().height))) {
+      mTiles[i].mDrawTarget->DrawSurface(aSurface, aDest, aSource, aSurfaceOptions, aDrawOptions);
+    }
+  }
+}
+
+void
+DrawTargetTiled::FillRect(const Rect& aRect, const Pattern& aPattern, const DrawOptions& aDrawOptions)
+{
+  Rect deviceRect = mTransform.TransformBounds(aRect);
+  for (size_t i = 0; i < mTiles.size(); i++) {
+    if (deviceRect.Intersects(Rect(mTiles[i].mTileOrigin.x,
+                                   mTiles[i].mTileOrigin.y,
+                                   mTiles[i].mDrawTarget->GetSize().width,
+                                   mTiles[i].mDrawTarget->GetSize().height))) {
+      mTiles[i].mDrawTarget->FillRect(aRect, aPattern, aDrawOptions);
+    }
+  }
+}
+
+void
+DrawTargetTiled::Stroke(const Path* aPath, const Pattern& aPattern, const StrokeOptions& aStrokeOptions, const DrawOptions& aDrawOptions)
+{
+  Rect deviceRect = aPath->GetStrokedBounds(aStrokeOptions, mTransform);
+  for (size_t i = 0; i < mTiles.size(); i++) {
+    if (deviceRect.Intersects(Rect(mTiles[i].mTileOrigin.x,
+                                   mTiles[i].mTileOrigin.y,
+                                   mTiles[i].mDrawTarget->GetSize().width,
+                                   mTiles[i].mDrawTarget->GetSize().height))) {
+      mTiles[i].mDrawTarget->Stroke(aPath, aPattern, aStrokeOptions, aDrawOptions);
+    }
+  }
+}
+
+void
+DrawTargetTiled::Fill(const Path* aPath, const Pattern& aPattern, const DrawOptions& aDrawOptions)
+{
+  Rect deviceRect = aPath->GetBounds(mTransform);
+  for (size_t i = 0; i < mTiles.size(); i++) {
+    if (deviceRect.Intersects(Rect(mTiles[i].mTileOrigin.x,
+                                   mTiles[i].mTileOrigin.y,
+                                   mTiles[i].mDrawTarget->GetSize().width,
+                                   mTiles[i].mDrawTarget->GetSize().height))) {
+      mTiles[i].mDrawTarget->Fill(aPath, aPattern, aDrawOptions);
+    }
+  }
+}
+
 }
 }