• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "bench/Benchmark.h"
12 #ifdef SK_ENABLE_ANDROID_UTILS
13 #include "include/core/SkData.h"
14 #include "include/core/SkImageInfo.h"
15 #include "include/core/SkRefCnt.h"
16 #include "include/core/SkString.h"
17 
18 namespace android {
19 namespace skia {
20 class BitmapRegionDecoder;
21 }  // namespace skia
22 }  // namespace android
23 
24 /**
25  *  Benchmark Android's BitmapRegionDecoder for a particular colorType, sampleSize, and subset.
26  *
27  *  nanobench.cpp handles creating benchmarks for interesting scaled subsets.  We strive to test
28  *  on real use cases.
29  */
30 class BitmapRegionDecoderBench : public Benchmark {
31 public:
32     // Calls encoded->ref()
33     BitmapRegionDecoderBench(const char* basename, SkData* encoded, SkColorType colorType,
34             uint32_t sampleSize, const SkIRect& subset);
35 
36 protected:
37     const char* onGetName() override;
38     bool isSuitableFor(Backend backend) override;
39     void onDraw(int n, SkCanvas* canvas) override;
40     void onDelayedSetup() override;
41 
42 private:
43     SkString                                            fName;
44     std::unique_ptr<android::skia::BitmapRegionDecoder> fBRD;
45     sk_sp<SkData>                                       fData;
46     const SkColorType                                   fColorType;
47     const uint32_t                                      fSampleSize;
48     const SkIRect                                       fSubset;
49     using INHERITED = Benchmark;
50 };
51 #endif // SK_ENABLE_ANDROID_UTILS
52 #endif // BitmapRegionDecoderBench_DEFINED
53