blob: 5e87ea8b153f37f8d8d220ba116c85cb00561cc1 [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
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "bench/Benchmark.h"
Leon Scroggins III87caae62020-05-04 10:02:45 -040012#ifdef SK_ENABLE_ANDROID_UTILS
Mike Kleinc0bd9f92019-04-23 12:05:21 -050013#include "include/core/SkData.h"
14#include "include/core/SkImageInfo.h"
15#include "include/core/SkRefCnt.h"
16#include "include/core/SkString.h"
msarett7f691442015-09-22 11:56:16 -070017
Leon Scroggins III87caae62020-05-04 10:02:45 -040018namespace android {
19namespace skia {
20class BitmapRegionDecoder;
21}
22}
23
msarett7f691442015-09-22 11:56:16 -070024/**
25 * Benchmark Android's BitmapRegionDecoder for a particular colorType, sampleSize, and subset.
26 *
msarett7f691442015-09-22 11:56:16 -070027 * nanobench.cpp handles creating benchmarks for interesting scaled subsets. We strive to test
28 * on real use cases.
29 */
30class BitmapRegionDecoderBench : public Benchmark {
31public:
32 // Calls encoded->ref()
msarettd1227a72016-05-18 06:23:57 -070033 BitmapRegionDecoderBench(const char* basename, SkData* encoded, SkColorType colorType,
msarett7f691442015-09-22 11:56:16 -070034 uint32_t sampleSize, const SkIRect& subset);
35
36protected:
37 const char* onGetName() override;
38 bool isSuitableFor(Backend backend) override;
mtkleina1ebeb22015-10-01 09:43:39 -070039 void onDraw(int n, SkCanvas* canvas) override;
joshualitt8a6697a2015-09-30 12:11:07 -070040 void onDelayedSetup() override;
msarett7f691442015-09-22 11:56:16 -070041
42private:
Leon Scroggins III87caae62020-05-04 10:02:45 -040043 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;
msarett7f691442015-09-22 11:56:16 -070049 typedef Benchmark INHERITED;
50};
Leon Scroggins III87caae62020-05-04 10:02:45 -040051#endif // SK_ENABLE_ANDROID_UTILS
msarett7f691442015-09-22 11:56:16 -070052#endif // BitmapRegionDecoderBench_DEFINED