Flutter Engine
The Flutter Engine
BitmapRegionDecoderBench.cpp
Go to the documentation of this file.
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
9#ifdef SK_ENABLE_ANDROID_UTILS
13#include "src/core/SkOSFile.h"
14
15BitmapRegionDecoderBench::BitmapRegionDecoderBench(const char* baseName, SkData* encoded,
16 SkColorType colorType, uint32_t sampleSize, const SkIRect& subset)
17 : fBRD(nullptr)
18 , fData(SkRef(encoded))
20 , fSampleSize(sampleSize)
21 , fSubset(subset)
22{
23 // Choose a useful name for the color type
24 const char* colorName = color_type_to_str(colorType);
25
26 fName.printf("BRD_%s_%s", baseName, colorName);
27 if (1 != sampleSize) {
28 fName.appendf("_%.3f", 1.0f / (float) sampleSize);
29 }
30}
31
32const char* BitmapRegionDecoderBench::onGetName() {
33 return fName.c_str();
34}
35
36bool BitmapRegionDecoderBench::isSuitableFor(Backend backend) {
37 return Backend::kNonRendering == backend;
38}
39
40void BitmapRegionDecoderBench::onDelayedSetup() {
42}
43
44void BitmapRegionDecoderBench::onDraw(int n, SkCanvas* canvas) {
45 auto ct = fBRD->computeOutputColorType(fColorType);
46 auto cs = fBRD->computeOutputColorSpace(ct, nullptr);
47 for (int i = 0; i < n; i++) {
48 SkBitmap bm;
49 SkAssertResult(fBRD->decodeRegion(&bm, nullptr, fSubset, fSampleSize, ct, false, cs));
50 }
51}
52#endif // SK_ENABLE_ANDROID_UTILS
const char * color_type_to_str(SkColorType colorType)
const char * backend
const char * fName
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, std::size(glyphs))==count)
SkColorType fColorType
SkColorType
Definition: SkColorType.h:19
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
static T * SkRef(T *obj)
Definition: SkRefCnt.h:132
Definition: SkData.h:25
static std::unique_ptr< BitmapRegionDecoder > Make(sk_sp< SkData > data)
Definition: SkRect.h:32