From 5a34fd3f9876174aea8b22e1b585b4244e71b0b1 Mon Sep 17 00:00:00 2001 From: "reed@google.com" Date: Mon, 10 Dec 2012 16:05:09 +0000 Subject: add '--mode clone' option to bench_pictures git-svn-id: http://skia.googlecode.com/svn/trunk@6735 2bbb7eff-a529-9590-31e7-b0007b416f81 --- tools/PictureRenderer.cpp | 27 +++++++++++++++++++++++++-- tools/PictureRenderer.h | 1 + tools/bench_pictures_main.cpp | 2 ++ 3 files changed, 28 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/PictureRenderer.cpp b/tools/PictureRenderer.cpp index 3f96e90962..e3ac187f66 100644 --- a/tools/PictureRenderer.cpp +++ b/tools/PictureRenderer.cpp @@ -669,10 +669,10 @@ public: SkIntToScalar(fPicture->height())); SkData* data = SkPictureUtils::GatherPixelRefs(fPicture, bounds); SkSafeUnref(data); - + return NULL == path; // we don't have anything to write } - + private: virtual SkString getConfigNameInternal() SK_OVERRIDE { return SkString("gather_pixelrefs"); @@ -683,4 +683,27 @@ PictureRenderer* CreateGatherPixelRefsRenderer() { return SkNEW(GatherRenderer); } +/////////////////////////////////////////////////////////////////////////////// + +class PictureCloneRenderer : public PictureRenderer { +public: + virtual bool render(const SkString* path) SK_OVERRIDE { + for (int i = 0; i < 100; ++i) { + SkPicture* clone = fPicture->clone(); + SkSafeUnref(clone); + } + + return NULL == path; // we don't have anything to write + } + +private: + virtual SkString getConfigNameInternal() SK_OVERRIDE { + return SkString("picture_clone"); + } +}; + +PictureRenderer* CreatePictureCloneRenderer() { + return SkNEW(PictureCloneRenderer); +} + } // namespace sk_tools diff --git a/tools/PictureRenderer.h b/tools/PictureRenderer.h index 8bce978bf9..192569cece 100644 --- a/tools/PictureRenderer.h +++ b/tools/PictureRenderer.h @@ -368,6 +368,7 @@ private: }; extern PictureRenderer* CreateGatherPixelRefsRenderer(); +extern PictureRenderer* CreatePictureCloneRenderer(); } diff --git a/tools/bench_pictures_main.cpp b/tools/bench_pictures_main.cpp index c1d0e1c0b3..47844f9417 100644 --- a/tools/bench_pictures_main.cpp +++ b/tools/bench_pictures_main.cpp @@ -378,6 +378,8 @@ static void parse_commandline(int argc, char* const argv[], SkTArray* if (0 == strcmp(*argv, "record")) { renderer.reset(SkNEW(sk_tools::RecordPictureRenderer)); gridSupported = true; + } else if (0 == strcmp(*argv, "clone")) { + renderer.reset(sk_tools::CreatePictureCloneRenderer()); } else if (0 == strcmp(*argv, "simple")) { renderer.reset(SkNEW(sk_tools::SimplePictureRenderer)); } else if ((0 == strcmp(*argv, "tile")) || (0 == strcmp(*argv, "pow2tile")) -- cgit v1.2.3