Index: bench/RecordingBench.cpp |
diff --git a/bench/RecordingBench.cpp b/bench/RecordingBench.cpp |
index 833bb229cc7ea9a5effae9e30c31584e3c7ef0d6..030bcc8415a5838fab7f61610aa0ddcfcdfb3e8f 100644 |
--- a/bench/RecordingBench.cpp |
+++ b/bench/RecordingBench.cpp |
@@ -6,14 +6,21 @@ |
*/ |
#include "RecordingBench.h" |
- |
#include "SkBBHFactory.h" |
+#include "SkLiteDL.h" |
+#include "SkLiteRecorder.h" |
#include "SkPictureRecorder.h" |
-RecordingBench::RecordingBench(const char* name, const SkPicture* pic, bool useBBH) |
- : fSrc(SkRef(pic)) |
- , fName(name) |
- , fUseBBH(useBBH) {} |
+RecordingBench::RecordingBench(const char* name, const SkPicture* pic, bool useBBH, bool lite) |
+ : fName(name) |
+ , fUseBBH(useBBH) |
+ , fLite(lite) { |
+ // Flatten the source picture in case it's trivially nested (useless for timing). |
+ SkPictureRecorder rec; |
+ pic->playback(rec.beginRecording(pic->cullRect(), nullptr, |
+ SkPictureRecorder::kPlaybackDrawPicture_RecordFlag)); |
+ fSrc = rec.finishRecordingAsPicture(); |
+} |
const char* RecordingBench::onGetName() { |
return fName.c_str(); |
@@ -29,14 +36,21 @@ SkIPoint RecordingBench::onGetSize() { |
} |
void RecordingBench::onDraw(int loops, SkCanvas*) { |
- SkRTreeFactory factory; |
- const SkScalar w = fSrc->cullRect().width(), |
- h = fSrc->cullRect().height(); |
- |
- uint32_t flags = SkPictureRecorder::kPlaybackDrawPicture_RecordFlag; |
- for (int i = 0; i < loops; i++) { |
+ if (fLite) { |
+ SkLiteRecorder rec; |
+ while (loops --> 0) { |
+ sk_sp<SkLiteDL> dl = SkLiteDL::New(fSrc->cullRect()); |
+ rec.reset(dl.get()); |
+ fSrc->playback(&rec); |
+ dl->makeThreadsafe(); |
+ } |
+ |
+ } else { |
+ SkRTreeFactory factory; |
SkPictureRecorder recorder; |
- fSrc->playback(recorder.beginRecording(w, h, fUseBBH ? &factory : nullptr, flags)); |
- (void)recorder.finishRecordingAsPicture(); |
+ while (loops --> 0) { |
+ fSrc->playback(recorder.beginRecording(fSrc->cullRect(), fUseBBH ? &factory : nullptr)); |
+ (void)recorder.finishRecordingAsPicture(); |
+ } |
} |
} |