Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Unified Diff: bench/SKPBench.cpp

Issue 750583002: Revert of Add MultiPictureDraw to nanobench (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « bench/SKPBench.h ('k') | bench/nanobench.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/SKPBench.cpp
diff --git a/bench/SKPBench.cpp b/bench/SKPBench.cpp
index fd8df429c2ad7ccb088f48e7c570a05628118039..5844d8a588ab4597ab76661f684ace36865cc9c2 100644
--- a/bench/SKPBench.cpp
+++ b/bench/SKPBench.cpp
@@ -7,28 +7,15 @@
#include "SKPBench.h"
#include "SkCommandLineFlags.h"
-#include "SkMultiPictureDraw.h"
-#include "SkSurface.h"
DEFINE_int32(benchTile, 256, "Tile dimension used for SKP playback.");
-SKPBench::SKPBench(const char* name, const SkPicture* pic, const SkIRect& clip, SkScalar scale,
- bool useMultiPictureDraw)
+SKPBench::SKPBench(const char* name, const SkPicture* pic, const SkIRect& clip, SkScalar scale)
: fPic(SkRef(pic))
, fClip(clip)
, fScale(scale)
- , fName(name)
- , fUseMultiPictureDraw(useMultiPictureDraw) {
+ , fName(name) {
fUniqueName.printf("%s_%.2g", name, scale); // Scale makes this unqiue for skiaperf.com traces.
- if (useMultiPictureDraw) {
- fUniqueName.append("_mpd");
- }
-}
-
-SKPBench::~SKPBench() {
- for (int i = 0; i < fSurfaces.count(); ++i) {
- fSurfaces[i]->unref();
- }
}
const char* SKPBench::onGetName() {
@@ -37,49 +24,6 @@
const char* SKPBench::onGetUniqueName() {
return fUniqueName.c_str();
-}
-
-void SKPBench::onPerCanvasPreDraw(SkCanvas* canvas) {
- if (!fUseMultiPictureDraw) {
- return;
- }
-
- SkIRect bounds;
- SkAssertResult(canvas->getClipDeviceBounds(&bounds));
-
- int xTiles = SkScalarCeilToInt(bounds.width() / SkIntToScalar(FLAGS_benchTile));
- int yTiles = SkScalarCeilToInt(bounds.height() / SkIntToScalar(FLAGS_benchTile));
-
- fSurfaces.setReserve(xTiles * yTiles);
- fTileRects.setReserve(xTiles * yTiles);
-
- SkImageInfo ii = canvas->imageInfo().makeWH(FLAGS_benchTile, FLAGS_benchTile);
-
- 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);
- *fSurfaces.push() = canvas->newSurface(ii);
- fSurfaces.top()->getCanvas()->setMatrix(canvas->getTotalMatrix());
- fSurfaces.top()->getCanvas()->scale(fScale, fScale);
- }
- }
-}
-
-void SKPBench::onPerCanvasPostDraw(SkCanvas* canvas) {
- if (!fUseMultiPictureDraw) {
- return;
- }
-
- // Draw the last set of tiles into the master canvas in case we're
- // saving the images
- for (int i = 0; i < fTileRects.count(); ++i) {
- canvas->drawImage(fSurfaces[i]->newImageSnapshot(),
- SkIntToScalar(fTileRects[i].fLeft), SkIntToScalar(fTileRects[i].fTop));
- SkSafeSetNull(fSurfaces[i]);
- }
-
- fSurfaces.rewind();
- fTileRects.rewind();
}
bool SKPBench::isSuitableFor(Backend backend) {
@@ -91,41 +35,21 @@
}
void SKPBench::onDraw(const int loops, SkCanvas* canvas) {
- if (fUseMultiPictureDraw) {
- for (int i = 0; i < loops; i++) {
- SkMultiPictureDraw mpd;
+ SkIRect bounds;
+ SkAssertResult(canvas->getClipDeviceBounds(&bounds));
- 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);
- }
+ SkAutoCanvasRestore overall(canvas, true/*save now*/);
+ canvas->scale(fScale, fScale);
- mpd.draw();
-
- for (int i = 0; i < fTileRects.count(); ++i) {
- fSurfaces[i]->getCanvas()->flush();
+ 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);
}
}
- } 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::Make(
- SkIRect::MakeXYWH(x, y, FLAGS_benchTile, FLAGS_benchTile)));
- fPic->playback(canvas);
- }
- }
-
- canvas->flush();
- }
+ canvas->flush();
}
}
« no previous file with comments | « bench/SKPBench.h ('k') | bench/nanobench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698