Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
AndroidCodecBench.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2016 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
12#include "src/core/SkOSFile.h"
14
15AndroidCodecBench::AndroidCodecBench(SkString baseName, SkData* encoded, int sampleSize)
16 : fData(SkRef(encoded))
17 , fSampleSize(sampleSize)
18{
19 // Parse filename and the color type to give the benchmark a useful name
20 fName.printf("AndroidCodec_%s_SampleSize%d", baseName.c_str(), sampleSize);
21}
22
24 return fName.c_str();
25}
26
30
32 std::unique_ptr<SkAndroidCodec> codec(SkAndroidCodec::MakeFromData(fData));
33 SkISize scaledSize = codec->getSampledDimensions(fSampleSize);
34
35 fInfo = codec->getInfo().makeDimensions(scaledSize).makeColorType(kN32_SkColorType);
36 if (kUnpremul_SkAlphaType == fInfo.alphaType()) {
38 }
39
40 fPixelStorage.reset(fInfo.computeMinByteSize());
41}
42
43void AndroidCodecBench::onDraw(int n, SkCanvas* canvas) {
44 std::unique_ptr<SkAndroidCodec> codec;
46 options.fSampleSize = fSampleSize;
47 for (int i = 0; i < n; i++) {
48 codec = SkAndroidCodec::MakeFromData(fData);
49#ifdef SK_DEBUG
51#endif
52 codec->getAndroidPixels(fInfo, fPixelStorage.get(), fInfo.minRowBytes(), &options);
54 }
55}
const char * options
const char * backend
kUnpremul_SkAlphaType
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition SkAlphaType.h:29
#define SkASSERT(cond)
Definition SkAssert.h:116
static T * SkRef(T *obj)
Definition SkRefCnt.h:132
void onDraw(int n, SkCanvas *canvas) override
void onDelayedSetup() override
bool isSuitableFor(Backend backend) override
const char * onGetName() override
AndroidCodecBench(SkString basename, SkData *encoded, int sampleSize)
static std::unique_ptr< SkAndroidCodec > MakeFromData(sk_sp< SkData >, SkPngChunkReader *=nullptr)
void * reset(size_t size=0, OnShrink shrink=kAlloc_OnShrink)
void * get()
@ kIncompleteInput
Definition SkCodec.h:84
@ kSuccess
Definition SkCodec.h:80
void printf(const char format[],...) SK_PRINTF_LIKE(2
Definition SkString.cpp:534
const char * c_str() const
Definition SkString.h:133
GAsyncResult * result
SkImageInfo makeAlphaType(SkAlphaType newAlphaType) const
size_t minRowBytes() const
SkImageInfo makeDimensions(SkISize newSize) const
size_t computeMinByteSize() const
SkAlphaType alphaType() const
SkImageInfo makeColorType(SkColorType newColorType) const