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

#include <CodecBench.h>

Inheritance diagram for CodecBench:
Benchmark SkRefCnt SkRefCntBase

Public Member Functions

 CodecBench (SkString basename, SkData *encoded, SkColorType colorType, SkAlphaType alphaType)
 
- 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 SkCodec.

Definition at line 21 of file CodecBench.h.

Constructor & Destructor Documentation

◆ CodecBench()

CodecBench::CodecBench ( SkString  basename,
SkData encoded,
SkColorType  colorType,
SkAlphaType  alphaType 
)

Definition at line 19 of file CodecBench.cpp.

21 : fColorType(colorType)
22 , fAlphaType(alphaType)
23 , fData(SkRef(encoded))
24{
25 // Parse filename and the color type to give the benchmark a useful name
26 fName.printf("Codec_%s_%s%s", baseName.c_str(), color_type_to_str(colorType),
27 alpha_type_to_str(alphaType));
28 // Ensure that we can create an SkCodec from this data.
30}
const char * alpha_type_to_str(SkAlphaType alphaType)
const char * color_type_to_str(SkColorType colorType)
#define SkASSERT(cond)
Definition: SkAssert.h:116
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
static T * SkRef(T *obj)
Definition: SkRefCnt.h:132
static std::unique_ptr< SkCodec > MakeFromData(sk_sp< SkData >, SkSpan< const SkCodecs::Decoder > decoders, SkPngChunkReader *=nullptr)
Definition: SkCodec.cpp:241
void printf(const char format[],...) SK_PRINTF_LIKE(2
Definition: SkString.cpp:534

Member Function Documentation

◆ isSuitableFor()

bool CodecBench::isSuitableFor ( Backend  backend)
overrideprotectedvirtual

Reimplemented from Benchmark.

Definition at line 36 of file CodecBench.cpp.

36 {
38}
const char * backend

◆ onDelayedSetup()

void CodecBench::onDelayedSetup ( )
overrideprotectedvirtual

Reimplemented from Benchmark.

Definition at line 40 of file CodecBench.cpp.

40 {
41 std::unique_ptr<SkCodec> codec = SkCodec::MakeFromData(fData);
42
43 fInfo = codec->getInfo().makeColorType(fColorType)
44 .makeAlphaType(fAlphaType)
45 .makeColorSpace(nullptr);
46
47 fPixelStorage.reset(fInfo.computeMinByteSize());
48}
void * reset(size_t size=0, OnShrink shrink=kAlloc_OnShrink)
Definition: SkAutoMalloc.h:53
SkImageInfo makeAlphaType(SkAlphaType newAlphaType) const
Definition: SkImageInfo.h:466
SkImageInfo makeColorSpace(sk_sp< SkColorSpace > cs) const
size_t computeMinByteSize() const
Definition: SkImageInfo.h:578
SkImageInfo makeColorType(SkColorType newColorType) const
Definition: SkImageInfo.h:475

◆ onDraw()

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

Implements Benchmark.

Definition at line 50 of file CodecBench.cpp.

50 {
51 std::unique_ptr<SkCodec> codec;
53 if (FLAGS_zero_init) {
54 options.fZeroInitialized = SkCodec::kYes_ZeroInitialized;
55 }
56 for (int i = 0; i < n; i++) {
57 codec = SkCodec::MakeFromData(fData);
58#ifdef SK_DEBUG
60#endif
61 codec->getPixels(fInfo, fPixelStorage.get(), fInfo.minRowBytes(),
62 &options);
65 }
66}
const char * options
void * get()
Definition: SkAutoMalloc.h:64
@ kYes_ZeroInitialized
Definition: SkCodec.h:308
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 * CodecBench::onGetName ( )
overrideprotectedvirtual

Implements Benchmark.

Definition at line 32 of file CodecBench.cpp.

32 {
33 return fName.c_str();
34}
const char * c_str() const
Definition: SkString.h:133

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