Flutter Engine
The Flutter Engine
Public Member Functions | Protected Member Functions | List of all members
AndroidCodecBench Class Reference

#include <AndroidCodecBench.h>

Inheritance diagram for AndroidCodecBench:
Benchmark SkRefCnt SkRefCntBase

Public Member Functions

 AndroidCodecBench (SkString basename, SkData *encoded, int sampleSize)
 
- Public Member Functions inherited from Benchmark
 Benchmark ()
 
const char * getName ()
 
const char * getUniqueName ()
 
SkISize getSize ()
 
virtual bool isSuitableFor (Backend backend)
 
virtual void modifyGrContextOptions (GrContextOptions *)
 
virtual bool shouldLoop () const
 
void delayedSetup ()
 
void perCanvasPreDraw (SkCanvas *)
 
void perCanvasPostDraw (SkCanvas *)
 
void preDraw (SkCanvas *)
 
void postDraw (SkCanvas *)
 
void draw (int loops, SkCanvas *)
 
virtual void getGpuStats (SkCanvas *, skia_private::TArray< SkString > *keys, skia_private::TArray< double > *values)
 
virtual bool getDMSAAStats (GrRecordingContext *)
 
int getUnits () const
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Protected Member Functions

const char * onGetName () override
 
bool isSuitableFor (Backend backend) override
 
void onDraw (int n, SkCanvas *canvas) override
 
void onDelayedSetup () override
 
- Protected Member Functions inherited from Benchmark
void setUnits (int units)
 
virtual void setupPaint (SkPaint *paint)
 
virtual const char * onGetName ()=0
 
virtual const char * onGetUniqueName ()
 
virtual void onDelayedSetup ()
 
virtual void onPerCanvasPreDraw (SkCanvas *)
 
virtual void onPerCanvasPostDraw (SkCanvas *)
 
virtual void onPreDraw (SkCanvas *)
 
virtual void onPostDraw (SkCanvas *)
 
virtual void onDraw (int loops, SkCanvas *)=0
 
virtual SkISize onGetSize ()
 

Additional Inherited Members

- Public Types inherited from Benchmark
enum class  Backend {
  kNonRendering , kRaster , kGanesh , kGraphite ,
  kPDF , kHWUI
}
 

Detailed Description

Time SkAndroidCodec.

Definition at line 21 of file AndroidCodecBench.h.

Constructor & Destructor Documentation

◆ AndroidCodecBench()

AndroidCodecBench::AndroidCodecBench ( SkString  basename,
SkData encoded,
int  sampleSize 
)

Definition at line 15 of file AndroidCodecBench.cpp.

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}
static T * SkRef(T *obj)
Definition: SkRefCnt.h:132
void printf(const char format[],...) SK_PRINTF_LIKE(2
Definition: SkString.cpp:534

Member Function Documentation

◆ isSuitableFor()

bool AndroidCodecBench::isSuitableFor ( Backend  backend)
overrideprotectedvirtual

Reimplemented from Benchmark.

Definition at line 27 of file AndroidCodecBench.cpp.

27 {
29}
const char * backend

◆ onDelayedSetup()

void AndroidCodecBench::onDelayedSetup ( )
overrideprotectedvirtual

Reimplemented from Benchmark.

Definition at line 31 of file AndroidCodecBench.cpp.

31 {
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}
kUnpremul_SkAlphaType
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition: SkAlphaType.h:29
static std::unique_ptr< SkAndroidCodec > MakeFromData(sk_sp< SkData >, SkPngChunkReader *=nullptr)
void * reset(size_t size=0, OnShrink shrink=kAlloc_OnShrink)
Definition: SkAutoMalloc.h:53
Definition: SkSize.h:16
SkImageInfo makeAlphaType(SkAlphaType newAlphaType) const
Definition: SkImageInfo.h:466
SkImageInfo makeDimensions(SkISize newSize) const
Definition: SkImageInfo.h:454
size_t computeMinByteSize() const
Definition: SkImageInfo.h:578
SkAlphaType alphaType() const
Definition: SkImageInfo.h:375
SkImageInfo makeColorType(SkColorType newColorType) const
Definition: SkImageInfo.h:475

◆ onDraw()

void AndroidCodecBench::onDraw ( int  n,
SkCanvas canvas 
)
overrideprotectedvirtual

Implements Benchmark.

Definition at line 43 of file AndroidCodecBench.cpp.

43 {
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
#define SkASSERT(cond)
Definition: SkAssert.h:116
void * get()
Definition: SkAutoMalloc.h:64
Result
Definition: SkCodec.h:76
@ kIncompleteInput
Definition: SkCodec.h:84
@ kSuccess
Definition: SkCodec.h:80
GAsyncResult * result
size_t minRowBytes() const
Definition: SkImageInfo.h:517

◆ onGetName()

const char * AndroidCodecBench::onGetName ( )
overrideprotectedvirtual

Implements Benchmark.

Definition at line 23 of file AndroidCodecBench.cpp.

23 {
24 return fName.c_str();
25}
const char * c_str() const
Definition: SkString.h:133

The documentation for this class was generated from the following files: