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"); ) |