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 | * |
msarett | 7f69144 | 2015-09-22 11:56:16 -0700 | [diff] [blame] | 21 | * nanobench.cpp handles creating benchmarks for interesting scaled subsets. We strive to test |
| 22 | * on real use cases. |
| 23 | */ |
| 24 | class BitmapRegionDecoderBench : public Benchmark { |
| 25 | public: |
| 26 | // Calls encoded->ref() |
msarett | d1227a7 | 2016-05-18 06:23:57 -0700 | [diff] [blame] | 27 | BitmapRegionDecoderBench(const char* basename, SkData* encoded, SkColorType colorType, |
msarett | 7f69144 | 2015-09-22 11:56:16 -0700 | [diff] [blame] | 28 | uint32_t sampleSize, const SkIRect& subset); |
| 29 | |
| 30 | protected: |
| 31 | const char* onGetName() override; |
| 32 | bool isSuitableFor(Backend backend) override; |
mtklein | a1ebeb2 | 2015-10-01 09:43:39 -0700 | [diff] [blame] | 33 | void onDraw(int n, SkCanvas* canvas) override; |
joshualitt | 8a6697a | 2015-09-30 12:11:07 -0700 | [diff] [blame] | 34 | void onDelayedSetup() override; |
msarett | 7f69144 | 2015-09-22 11:56:16 -0700 | [diff] [blame] | 35 | |
| 36 | private: |
| 37 | SkString fName; |
Ben Wagner | 145dbcd | 2016-11-03 14:40:50 -0400 | [diff] [blame] | 38 | std::unique_ptr<SkBitmapRegionDecoder> fBRD; |
bungeman | ffae30d | 2016-08-03 13:32:32 -0700 | [diff] [blame] | 39 | sk_sp<SkData> fData; |
msarett | 7f69144 | 2015-09-22 11:56:16 -0700 | [diff] [blame] | 40 | const SkColorType fColorType; |
| 41 | const uint32_t fSampleSize; |
| 42 | const SkIRect fSubset; |
| 43 | typedef Benchmark INHERITED; |
| 44 | }; |
| 45 | #endif // BitmapRegionDecoderBench_DEFINED |