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

Unified Diff: bench/SKPBench.cpp

Issue 1541983002: Add tileSKP option to nanobench (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years 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') | no next file » | 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 db55b45f435601bad64d2c371273549a4c6e7f9a..9b3ef84dc76d42d3993fd9950d7206a2c847dbc8 100644
--- a/bench/SKPBench.cpp
+++ b/bench/SKPBench.cpp
@@ -14,6 +14,10 @@
#include "GrContext.h"
#endif
+#include <stdlib.h>
+
+DEFINE_bool(tileSKP, true, "Tile skp benches?");
+
// These CPU tile sizes are not good per se, but they are similar to what Chrome uses.
DEFINE_int32(CPUbenchTileW, 256, "Tile width used for CPU SKP playback.");
DEFINE_int32(CPUbenchTileH, 256, "Tile height used for CPU SKP playback.");
@@ -31,6 +35,11 @@ SKPBench::SKPBench(const char* name, const SkPicture* pic, const SkIRect& clip,
, fDoLooping(doLooping) {
fUniqueName.printf("%s_%.2g", name, scale); // Scale makes this unqiue for perf.skia.org traces.
if (useMultiPictureDraw) {
+ if (!FLAGS_tileSKP) {
+ SkDebugf("Tried to use SkMultiPictureDraw with a non-tiled SKP. Aborting. "
+ "(Please use --mpd false.)");
+ exit(-1);
+ }
fUniqueName.append("_mpd");
}
}
@@ -50,6 +59,10 @@ const char* SKPBench::onGetUniqueName() {
}
void SKPBench::onPerCanvasPreDraw(SkCanvas* canvas) {
+ if (!FLAGS_tileSKP) {
+ return;
+ }
+
SkIRect bounds;
SkAssertResult(canvas->getClipDeviceBounds(&bounds));
@@ -87,6 +100,10 @@ void SKPBench::onPerCanvasPreDraw(SkCanvas* canvas) {
}
void SKPBench::onPerCanvasPostDraw(SkCanvas* canvas) {
+ if (!FLAGS_tileSKP) {
+ 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) {
@@ -110,21 +127,28 @@ SkIPoint SKPBench::onGetSize() {
void SKPBench::onDraw(int loops, SkCanvas* canvas) {
SkASSERT(fDoLooping || 1 == loops);
- if (fUseMultiPictureDraw) {
- for (int i = 0; i < loops; i++) {
+ while (1) {
+ if (!FLAGS_tileSKP) {
+ this->drawPicture(canvas);
+ } else if (fUseMultiPictureDraw) {
this->drawMPDPicture();
+ } else {
+ this->drawPictureTiled();
}
- } else {
- for (int i = 0; i < loops; i++) {
- this->drawPicture();
+ if (0 == --loops) {
+ break;
}
- }
#if SK_SUPPORT_GPU
- // Ensure the GrContext doesn't batch across draw loops.
- if (GrContext* context = canvas->getGrContext()) {
- context->flush();
- }
+ // Ensure the GrContext doesn't batch across draw loops.
bsalomon 2015/12/22 17:04:25 It seems like now we will not flush after the last
Chris Dalton 2015/12/22 18:47:05 Oops :-\ the previous code was wrong.
+ if (GrContext* context = canvas->getGrContext()) {
+ context->flush();
+ }
#endif
+ }
+}
+
+void SKPBench::drawPicture(SkCanvas* canvas) {
+ canvas->drawPicture(fPic);
}
void SKPBench::drawMPDPicture() {
@@ -144,7 +168,7 @@ void SKPBench::drawMPDPicture() {
}
}
-void SKPBench::drawPicture() {
+void SKPBench::drawPictureTiled() {
for (int j = 0; j < fTileRects.count(); ++j) {
const SkMatrix trans = SkMatrix::MakeTrans(-fTileRects[j].fLeft / fScale,
-fTileRects[j].fTop / fScale);
« no previous file with comments | « bench/SKPBench.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698