Do we still need this DOUBLE_LOOP feature?
If so, let's do it this way so it works for all source types and doesn't need
to be chosen at compile time.
BUG=skia:
Review URL: https://codereview.chromium.org/1129693003
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index 840936c..79b7919 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -288,19 +288,7 @@
stream.reset((SkStream*)NULL); // Might as well drop this when we're done with it.
canvas->clipRect(kSKPViewport);
- // Testing TextBlob batching requires that we see individual text blobs more than once
- // TODO remove this and add a flag to DM so we can run skps multiple times
-//#define DOUBLE_LOOP
-#ifdef DOUBLE_LOOP
- {
- SkAutoCanvasRestore acr(canvas, true);
-#endif
- canvas->drawPicture(pic);
-#ifdef DOUBLE_LOOP
- }
- canvas->clear(0);
canvas->drawPicture(pic);
-#endif
return "";
}
@@ -720,6 +708,23 @@
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+// Draw the Src twice. This can help exercise caching.
+Error ViaTwice::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkString* log) const {
+ return draw_to_canvas(fSink, bitmap, stream, log, src.size(), [&](SkCanvas* canvas) -> Error {
+ for (int i = 0; i < 2; i++) {
+ SkAutoCanvasRestore acr(canvas, true/*save now*/);
+ canvas->clear(SK_ColorTRANSPARENT);
+ Error err = src.draw(canvas);
+ if (err.isEmpty()) {
+ return err;
+ }
+ }
+ return "";
+ });
+}
+
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
// This is like SkRecords::Draw, in that it plays back SkRecords ops into a Canvas.
// Unlike SkRecords::Draw, it builds a single-op sub-picture out of each Draw-type op.
// This is an only-slightly-exaggerated simluation of Blink's Slimming Paint pictures.