• 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 "Benchmark.h"
12 #include "SkBitmapRegionDecoder.h"
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  *  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()
27     BitmapRegionDecoderBench(const char* basename, SkData* encoded, SkColorType colorType,
28             uint32_t sampleSize, const SkIRect& subset);
29 
30 protected:
31     const char* onGetName() override;
32     bool isSuitableFor(Backend backend) override;
33     void onDraw(int n, SkCanvas* canvas) override;
34     void onDelayedSetup() override;
35 
36 private:
37     SkString                                       fName;
38     std::unique_ptr<SkBitmapRegionDecoder>         fBRD;
39     sk_sp<SkData>                                  fData;
40     const SkColorType                              fColorType;
41     const uint32_t                                 fSampleSize;
42     const SkIRect                                  fSubset;
43     typedef Benchmark INHERITED;
44 };
45 #endif // BitmapRegionDecoderBench_DEFINED
46