diff options
author | Mike Reed <reed@google.com> | 2017-10-25 10:37:30 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-10-25 16:56:08 +0000 |
commit | 7306bcd758fc35be2f4bf75063c4d50d0be8f853 (patch) | |
tree | 3b358d155c73f1d04cbcfeada5e441077a3867c6 /bench/ReadPixBench.cpp | |
parent | f8e353d5eb97119f4dd44e65331f70d4a57ce7d9 (diff) |
- add bench for pixmap orient
- reduce code size by using a draw instead of custom blits
Bug: skia:
Change-Id: I90f9fb2abf40496e771f1f725556c178d730b590
Reviewed-on: https://skia-review.googlesource.com/62860
Reviewed-by: Mike Klein <mtklein@chromium.org>
Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'bench/ReadPixBench.cpp')
-rw-r--r-- | bench/ReadPixBench.cpp | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/bench/ReadPixBench.cpp b/bench/ReadPixBench.cpp index 2a8e9c4df3..55078d96b6 100644 --- a/bench/ReadPixBench.cpp +++ b/bench/ReadPixBench.cpp @@ -62,7 +62,46 @@ private: typedef Benchmark INHERITED; }; +DEF_BENCH( return new ReadPixBench(); ) //////////////////////////////////////////////////////////////////////////////// +#include "SkBitmap.h" +#include "SkPixmapPriv.h" -DEF_BENCH( return new ReadPixBench(); ) +class PixmapOrientBench : public Benchmark { +public: + PixmapOrientBench() {} + +protected: + void onDelayedSetup() override { + const SkImageInfo info = SkImageInfo::MakeN32Premul(2048, 1024); + fSrc.allocPixels(info); + fSrc.eraseColor(SK_ColorBLACK); + fDst.allocPixels(info.makeWH(info.height(), info.width())); + } + + const char* onGetName() override { + return "orient_pixmap"; + } + + bool isSuitableFor(Backend backend) override { + return backend == kNonRendering_Backend; + } + + void onDraw(int loops, SkCanvas*) override { + const SkPixmapPriv::OrientFlags flags = SkPixmapPriv::kSwapXY; + + SkPixmap src, dst; + fSrc.peekPixels(&src); + fDst.peekPixels(&dst); + for (int i = 0; i < loops; ++i) { + SkPixmapPriv::Orient(dst, src, flags); + } + } + +private: + SkBitmap fSrc, fDst; + + typedef Benchmark INHERITED; +}; +DEF_BENCH( return new PixmapOrientBench(); ) |