msarett | 7f69144 | 2015-09-22 11:56:16 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef BitmapRegionDecoderBench_DEFINED |
| 9 | #define BitmapRegionDecoderBench_DEFINED |
| 10 | |
| 11 | #include "Benchmark.h" |
msarett | 5cb4885 | 2015-11-06 08:56:32 -0800 | [diff] [blame] | 12 | #include "SkBitmapRegionDecoder.h" |
msarett | 7f69144 | 2015-09-22 11:56:16 -0700 | [diff] [blame] | 13 | #include "SkData.h" |
| 14 | #include "SkImageInfo.h" |
| 15 | #include "SkRefCnt.h" |
| 16 | #include "SkString.h" |
| 17 | |
| 18 | /** |
| 19 | * Benchmark Android's BitmapRegionDecoder for a particular colorType, sampleSize, and subset. |
| 20 | * |
| 21 | * fStrategy determines which of various implementations is to be used. |
| 22 | * |
| 23 | * nanobench.cpp handles creating benchmarks for interesting scaled subsets. We strive to test |
| 24 | * on real use cases. |
| 25 | */ |
| 26 | class BitmapRegionDecoderBench : public Benchmark { |
| 27 | public: |
| 28 | // Calls encoded->ref() |
| 29 | BitmapRegionDecoderBench(const char* basename, SkData* encoded, |
msarett | 5cb4885 | 2015-11-06 08:56:32 -0800 | [diff] [blame] | 30 | SkBitmapRegionDecoder::Strategy strategy, SkColorType colorType, |
msarett | 7f69144 | 2015-09-22 11:56:16 -0700 | [diff] [blame] | 31 | uint32_t sampleSize, const SkIRect& subset); |
| 32 | |
| 33 | protected: |
| 34 | const char* onGetName() override; |
| 35 | bool isSuitableFor(Backend backend) override; |
mtklein | a1ebeb2 | 2015-10-01 09:43:39 -0700 | [diff] [blame] | 36 | void onDraw(int n, SkCanvas* canvas) override; |
joshualitt | 8a6697a | 2015-09-30 12:11:07 -0700 | [diff] [blame] | 37 | void onDelayedSetup() override; |
msarett | 7f69144 | 2015-09-22 11:56:16 -0700 | [diff] [blame] | 38 | |
| 39 | private: |
| 40 | SkString fName; |
msarett | 5cb4885 | 2015-11-06 08:56:32 -0800 | [diff] [blame] | 41 | SkAutoTDelete<SkBitmapRegionDecoder> fBRD; |
msarett | 7f69144 | 2015-09-22 11:56:16 -0700 | [diff] [blame] | 42 | SkAutoTUnref<SkData> fData; |
msarett | 5cb4885 | 2015-11-06 08:56:32 -0800 | [diff] [blame] | 43 | const SkBitmapRegionDecoder::Strategy fStrategy; |
msarett | 7f69144 | 2015-09-22 11:56:16 -0700 | [diff] [blame] | 44 | const SkColorType fColorType; |
| 45 | const uint32_t fSampleSize; |
| 46 | const SkIRect fSubset; |
| 47 | typedef Benchmark INHERITED; |
| 48 | }; |
| 49 | #endif // BitmapRegionDecoderBench_DEFINED |