blob: 30990557b2720e8c24c120df48db209c5c015353 [file] [log] [blame]
msarett7f691442015-09-22 11:56:16 -07001/*
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"
msarett5cb48852015-11-06 08:56:32 -080012#include "SkBitmapRegionDecoder.h"
msarett7f691442015-09-22 11:56:16 -070013#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 *
msarett7f691442015-09-22 11:56:16 -070021 * nanobench.cpp handles creating benchmarks for interesting scaled subsets. We strive to test
22 * on real use cases.
23 */
24class BitmapRegionDecoderBench : public Benchmark {
25public:
26 // Calls encoded->ref()
msarettd1227a72016-05-18 06:23:57 -070027 BitmapRegionDecoderBench(const char* basename, SkData* encoded, SkColorType colorType,
msarett7f691442015-09-22 11:56:16 -070028 uint32_t sampleSize, const SkIRect& subset);
29
30protected:
31 const char* onGetName() override;
32 bool isSuitableFor(Backend backend) override;
mtkleina1ebeb22015-10-01 09:43:39 -070033 void onDraw(int n, SkCanvas* canvas) override;
joshualitt8a6697a2015-09-30 12:11:07 -070034 void onDelayedSetup() override;
msarett7f691442015-09-22 11:56:16 -070035
36private:
37 SkString fName;
Ben Wagner145dbcd2016-11-03 14:40:50 -040038 std::unique_ptr<SkBitmapRegionDecoder> fBRD;
bungemanffae30d2016-08-03 13:32:32 -070039 sk_sp<SkData> fData;
msarett7f691442015-09-22 11:56:16 -070040 const SkColorType fColorType;
41 const uint32_t fSampleSize;
42 const SkIRect fSubset;
43 typedef Benchmark INHERITED;
44};
45#endif // BitmapRegionDecoderBench_DEFINED