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

Unified Diff: bench/BitmapScaleBench.cpp

Issue 1588113002: add explicit bench for raw bitmapscaler (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: mark as nonrendering Created 4 years, 11 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 | « no previous file | src/core/SkBitmapFilter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/BitmapScaleBench.cpp
diff --git a/bench/BitmapScaleBench.cpp b/bench/BitmapScaleBench.cpp
index 37ce7cf65a11bd0207cdb49307010618a87be40f..2e8f72e03c2097e725de5304df8b258a4308e41a 100644
--- a/bench/BitmapScaleBench.cpp
+++ b/bench/BitmapScaleBench.cpp
@@ -110,3 +110,51 @@ DEF_BENCH(return new BitmapFilterScaleBench(90, 30);)
DEF_BENCH(return new BitmapFilterScaleBench(90, 10);)
DEF_BENCH(return new BitmapFilterScaleBench(256, 64);)
DEF_BENCH(return new BitmapFilterScaleBench(64, 256);)
+
+///////////////////////////////////////////////////////////////////////////////////////////////
+
+#include "SkBitmapScaler.h"
+
+class PixmapScalerBench: public Benchmark {
+ SkBitmapScaler::ResizeMethod fMethod;
+ SkString fName;
+ SkBitmap fSrc, fDst;
+
+public:
+ PixmapScalerBench(SkBitmapScaler::ResizeMethod method, const char suffix[]) : fMethod(method) {
+ fName.printf("pixmapscaler_%s", suffix);
+ }
+
+protected:
+ const char* onGetName() override {
+ return fName.c_str();
+ }
+
+ SkIPoint onGetSize() override { return{ 100, 100 }; }
+
+ bool isSuitableFor(Backend backend) override {
+ return backend == kNonRendering_Backend;
+ }
+
+ void onDelayedSetup() override {
+ fSrc.allocN32Pixels(640, 480);
+ fDst.allocN32Pixels(300, 250);
+ }
+
+ void onDraw(int loops, SkCanvas*) override {
+ SkPixmap src, dst;
+ fSrc.peekPixels(&src);
+ fDst.peekPixels(&dst);
+ for (int i = 0; i < loops * 16; i++) {
+ SkBitmapScaler::Resize(dst, src, fMethod);
+ }
+ }
+
+private:
+ typedef Benchmark INHERITED;
+};
+DEF_BENCH( return new PixmapScalerBench(SkBitmapScaler::RESIZE_LANCZOS3, "lanczos"); )
+DEF_BENCH( return new PixmapScalerBench(SkBitmapScaler::RESIZE_MITCHELL, "mitchell"); )
+DEF_BENCH( return new PixmapScalerBench(SkBitmapScaler::RESIZE_HAMMING, "hamming"); )
+DEF_BENCH( return new PixmapScalerBench(SkBitmapScaler::RESIZE_TRIANGLE, "triangle"); )
+DEF_BENCH( return new PixmapScalerBench(SkBitmapScaler::RESIZE_BOX, "box"); )
« no previous file with comments | « no previous file | src/core/SkBitmapFilter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698