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

Unified Diff: tools/bench_playback.cpp

Issue 333823007: Enable basic drawing with SkRecord-based pictures. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: ref accel data Created 6 years, 6 months 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 | « src/gpu/SkGpuDevice.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/bench_playback.cpp
diff --git a/tools/bench_playback.cpp b/tools/bench_playback.cpp
index 6ebe19d36f78e72da44b6510e96ab7bc7a08e103..5343191974036add6d849da5c71745871fff842c 100644
--- a/tools/bench_playback.cpp
+++ b/tools/bench_playback.cpp
@@ -5,6 +5,7 @@
* found in the LICENSE file.
*/
+#include "SkCanvas.h"
#include "SkCommandLineFlags.h"
#include "SkForceLinking.h"
#include "SkGraphics.h"
@@ -14,8 +15,6 @@
#include "SkStream.h"
#include "SkString.h"
-#include "../include/record/SkRecording.h"
-
#include "Stats.h"
#include "Timer.h"
@@ -37,7 +36,7 @@ static double timescale() {
return 1;
}
-static SkPicture* rerecord_with_tilegrid(SkPicture& src) {
+static SkPicture* rerecord(const SkPicture& src, bool skr) {
SkTileGridFactory::TileGridInfo info;
info.fTileInterval.set(FLAGS_tile, FLAGS_tile);
info.fMargin.setEmpty();
@@ -45,27 +44,13 @@ static SkPicture* rerecord_with_tilegrid(SkPicture& src) {
SkTileGridFactory factory(info);
SkPictureRecorder recorder;
- src.draw(recorder.beginRecording(src.width(), src.height(), &factory));
+ src.draw(skr ? recorder.EXPERIMENTAL_beginRecording(src.width(), src.height(), &factory)
+ : recorder. beginRecording(src.width(), src.height(), &factory));
return recorder.endRecording();
}
-static EXPERIMENTAL::SkPlayback* rerecord_with_skr(SkPicture& src) {
- EXPERIMENTAL::SkRecording recording(src.width(), src.height());
- src.draw(recording.canvas());
- return recording.releasePlayback();
-}
-
-static void draw(const EXPERIMENTAL::SkPlayback& skr, const SkPicture& skp, SkCanvas* canvas) {
- if (FLAGS_skr) {
- skr.draw(canvas);
- } else {
- skp.draw(canvas);
- }
-}
-
-static void bench(SkPMColor* scratch, SkPicture& src, const char* name) {
- SkAutoTUnref<SkPicture> picture(rerecord_with_tilegrid(src));
- SkAutoTDelete<EXPERIMENTAL::SkPlayback> record(rerecord_with_skr(src));
+static void bench(SkPMColor* scratch, const SkPicture& src, const char* name) {
+ SkAutoTUnref<const SkPicture> picture(rerecord(src, FLAGS_skr));
SkAutoTDelete<SkCanvas> canvas(SkCanvas::NewRasterDirectN32(src.width(),
src.height(),
@@ -74,7 +59,7 @@ static void bench(SkPMColor* scratch, SkPicture& src, const char* name) {
canvas->clipRect(SkRect::MakeWH(SkIntToScalar(FLAGS_tile), SkIntToScalar(FLAGS_tile)));
// Draw once to warm any caches. The first sample otherwise can be very noisy.
- draw(*record, *picture, canvas.get());
+ picture->draw(canvas.get());
WallTimer timer;
const double scale = timescale();
@@ -83,7 +68,7 @@ static void bench(SkPMColor* scratch, SkPicture& src, const char* name) {
// We assume timer overhead (typically, ~30ns) is insignificant
// compared to draw runtime (at least ~100us, usually several ms).
timer.start();
- draw(*record, *picture, canvas.get());
+ picture->draw(canvas.get());
timer.end();
samples[i] = timer.fWall * scale;
}
@@ -129,7 +114,7 @@ int tool_main(int argc, char** argv) {
failed = true;
continue;
}
- SkAutoTUnref<SkPicture> src(SkPicture::CreateFromStream(stream));
+ SkAutoTUnref<const SkPicture> src(SkPicture::CreateFromStream(stream));
if (!src) {
SkDebugf("Could not read %s as an SkPicture.\n", path.c_str());
failed = true;
« no previous file with comments | « src/gpu/SkGpuDevice.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698