void SKPBench::onDraw(const int loops, SkCanvas* canvas) { SkIRect bounds; SkAssertResult(canvas->getClipDeviceBounds(&bounds)); SkAutoCanvasRestore overall(canvas, true/*save now*/); canvas->scale(fScale, fScale); for (int i = 0; i < loops; i++) { 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))); fPic->playback(canvas); } } canvas->flush(); } }
void SKPBench::onDraw(const int loops, SkCanvas* canvas) { if (fUseMultiPictureDraw) { for (int i = 0; i < loops; i++) { SkMultiPictureDraw mpd; for (int i = 0; i < fTileRects.count(); ++i) { SkMatrix trans; trans.setTranslate(-fTileRects[i].fLeft/fScale, -fTileRects[i].fTop/fScale); mpd.add(fSurfaces[i]->getCanvas(), fPic, &trans); } mpd.draw(); for (int i = 0; i < fTileRects.count(); ++i) { fSurfaces[i]->getCanvas()->flush(); } } } else { SkIRect bounds; SkAssertResult(canvas->getClipDeviceBounds(&bounds)); SkAutoCanvasRestore overall(canvas, true/*save now*/); canvas->scale(fScale, fScale); for (int i = 0; i < loops; i++) { 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::MakeXYWH(x/fScale, y/fScale, FLAGS_benchTile/fScale, FLAGS_benchTile/fScale)); fPic->playback(canvas); } } canvas->flush(); } } }