aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--bench/RecordingBench.cpp40
-rw-r--r--bench/RecordingBench.h5
-rw-r--r--bench/nanobench.cpp3
3 files changed, 32 insertions, 16 deletions
diff --git a/bench/RecordingBench.cpp b/bench/RecordingBench.cpp
index 833bb229cc..030bcc8415 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();
+ }
}
}
diff --git a/bench/RecordingBench.h b/bench/RecordingBench.h
index 0a8befe2f1..a5793b3ac9 100644
--- a/bench/RecordingBench.h
+++ b/bench/RecordingBench.h
@@ -13,7 +13,7 @@
class RecordingBench : public Benchmark {
public:
- RecordingBench(const char* name, const SkPicture*, bool useBBH);
+ RecordingBench(const char* name, const SkPicture*, bool useBBH, bool lite);
protected:
const char* onGetName() override;
@@ -22,9 +22,10 @@ protected:
SkIPoint onGetSize() override;
private:
- SkAutoTUnref<const SkPicture> fSrc;
+ sk_sp<const SkPicture> fSrc;
SkString fName;
bool fUseBBH;
+ bool fLite;
typedef Benchmark INHERITED;
};
diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp
index 6ff2be4b1b..4ded061800 100644
--- a/bench/nanobench.cpp
+++ b/bench/nanobench.cpp
@@ -110,6 +110,7 @@ DEFINE_string(scales, "1.0", "Space-separated scales for SKPs.");
DEFINE_string(zoom, "1.0,0", "Comma-separated zoomMax,zoomPeriodMs factors for a periodic SKP zoom "
"function that ping-pongs between 1.0 and zoomMax.");
DEFINE_bool(bbh, true, "Build a BBH for SKPs?");
+DEFINE_bool(lite, false, "Use SkLiteRecorder in recording benchmarks?");
DEFINE_bool(mpd, true, "Use MultiPictureDraw for the SKPs?");
DEFINE_bool(loopSKP, true, "Loop SKPs like we do for micro benches?");
DEFINE_int32(flushEvery, 10, "Flush --outResultsFile every Nth run.");
@@ -691,7 +692,7 @@ public:
fBenchType = "recording";
fSKPBytes = static_cast<double>(SkPictureUtils::ApproximateBytesUsed(pic.get()));
fSKPOps = pic->approximateOpCount();
- return new RecordingBench(name.c_str(), pic.get(), FLAGS_bbh);
+ return new RecordingBench(name.c_str(), pic.get(), FLAGS_bbh, FLAGS_lite);
}
// Then once each for each scale as SKPBenches (playback).