Fix SKPBench tiling so MPD and non-MPD match
authorrobertphillips <robertphillips@google.com>
Thu, 4 Dec 2014 16:31:02 +0000 (08:31 -0800)
committerCommit bot <commit-bot@chromium.org>
Thu, 4 Dec 2014 16:31:03 +0000 (08:31 -0800)
Two issues with the SKPBench tile computation were causing the MPD path to do more work:

The clip from the parent canvas wasn't being used to trim content off the edges of the MPD tiles

The non-MPD path was not taking the scale into account in its tile placement (resulting in it having fewer, larger active tiles when scaling).

Review URL: https://codereview.chromium.org/776273002

bench/SKPBench.cpp
src/gpu/SkGpuDevice.cpp

index 3e692171dbbb1bb46888bcb2838cde46fcb8063b..222a8789504a7cfbde88e2b0e97eeb4714bd4c36 100644 (file)
@@ -57,8 +57,16 @@ void SKPBench::onPerCanvasPreDraw(SkCanvas* canvas) {
 
     for (int y = bounds.fTop; y < bounds.fBottom; y += FLAGS_benchTile) {
         for (int x = bounds.fLeft; x < bounds.fRight; x += FLAGS_benchTile) {
-            *fTileRects.append() = SkIRect::MakeXYWH(x, y, FLAGS_benchTile, FLAGS_benchTile);
+            const SkIRect tileRect = SkIRect::MakeXYWH(x, y, FLAGS_benchTile, FLAGS_benchTile);
+            *fTileRects.append() = tileRect;
             *fSurfaces.push() = canvas->newSurface(ii);
+
+            // Never want the contents of a tile to include stuff the parent
+            // canvas clips out
+            SkRect clip = SkRect::Make(bounds);
+            clip.offset(-SkIntToScalar(tileRect.fLeft), -SkIntToScalar(tileRect.fTop));
+            fSurfaces.top()->getCanvas()->clipRect(clip);
+
             fSurfaces.top()->getCanvas()->setMatrix(canvas->getTotalMatrix());
             fSurfaces.top()->getCanvas()->scale(fScale, fScale);
         }
@@ -120,8 +128,9 @@ void SKPBench::onDraw(const int loops, SkCanvas* canvas) {
             for (int y = bounds.fTop; y < bounds.fBottom; y += FLAGS_benchTile) {
                 for (int x = bounds.fLeft; x < bounds.fRight; x += FLAGS_benchTile) {
                     SkAutoCanvasRestore perTile(canvas, true/*save now*/);
-                    canvas->clipRect(SkRect::Make(
-                                SkIRect::MakeXYWH(x, y, FLAGS_benchTile, FLAGS_benchTile)));
+                    canvas->clipRect(SkRect::MakeXYWH(x/fScale, y/fScale,
+                                                      FLAGS_benchTile/fScale,
+                                                      FLAGS_benchTile/fScale));
                     fPic->playback(canvas);
                 }
             }
index f09ebf291f57d061cbc34ef654677a5b13dcf0df..b4b24d9086f74eca31aa23b4c92173db5b40ff33 100644 (file)
@@ -1823,6 +1823,7 @@ SkSurface* SkGpuDevice::newSurface(const SkImageInfo& info, const SkSurfaceProps
 
 bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* mainCanvas, const SkPicture* mainPicture,
                                            const SkMatrix* matrix, const SkPaint* paint) {
+#ifndef SK_IGNORE_GPU_LAYER_HOISTING
     // todo: should handle this natively
     if (paint) {
         return false;
@@ -1874,6 +1875,9 @@ bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* mainCanvas, const SkPicture
     GrLayerHoister::UnlockLayers(fContext, atlasedRecycled);
 
     return true;
+#else
+    return false;
+#endif
 }
 
 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() {