Flutter Engine
The Flutter Engine
Public Member Functions | Protected Member Functions | List of all members
PremulAndUnpremulAlphaOpsBench Class Reference
Inheritance diagram for PremulAndUnpremulAlphaOpsBench:
Benchmark SkRefCnt SkRefCntBase

Public Member Functions

 PremulAndUnpremulAlphaOpsBench (SkColorType ct)
 
- 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
 
void onDelayedSetup () override
 
void onDraw (int loops, SkCanvas *canvas) 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

Definition at line 14 of file PremulAndUnpremulAlphaOpsBench.cpp.

Constructor & Destructor Documentation

◆ PremulAndUnpremulAlphaOpsBench()

PremulAndUnpremulAlphaOpsBench::PremulAndUnpremulAlphaOpsBench ( SkColorType  ct)
inline

Definition at line 22 of file PremulAndUnpremulAlphaOpsBench.cpp.

22 {
23 fColorType = ct;
24 fName.printf("premul_and_unpremul_alpha_%s", ToolUtils::colortype_name(ct));
25 }
void printf(const char format[],...) SK_PRINTF_LIKE(2
Definition: SkString.cpp:534
const char * colortype_name(SkColorType ct)
Definition: ToolUtils.cpp:65

Member Function Documentation

◆ onDelayedSetup()

void PremulAndUnpremulAlphaOpsBench::onDelayedSetup ( )
inlineoverrideprotectedvirtual

Reimplemented from Benchmark.

Definition at line 32 of file PremulAndUnpremulAlphaOpsBench.cpp.

32 {
34 fBmp1.allocPixels(info); // used in writePixels
35
36 for (int h = 0; h < H; ++h) {
37 for (int w = 0; w < W; ++w) {
38 // SkColor places A in the right slot for either RGBA or BGRA
39 *fBmp1.getAddr32(w, h) = SkColorSetARGB(h & 0xFF, w & 0xFF, w & 0xFF, w & 0xFF);
40 }
41 }
42
43 fBmp2.allocPixels(info); // used in readPixels()
44 }
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
kUnpremul_SkAlphaType
static constexpr SkColor SkColorSetARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
Definition: SkColor.h:49
void allocPixels(const SkImageInfo &info, size_t rowBytes)
Definition: SkBitmap.cpp:258
uint32_t * getAddr32(int x, int y) const
Definition: SkBitmap.h:1260
SkScalar w
SkScalar h
Definition: SkMD5.cpp:130
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)

◆ onDraw()

void PremulAndUnpremulAlphaOpsBench::onDraw ( int  loops,
SkCanvas canvas 
)
inlineoverrideprotectedvirtual

Implements Benchmark.

Definition at line 46 of file PremulAndUnpremulAlphaOpsBench.cpp.

46 {
47 canvas->clear(SK_ColorBLACK);
48
49 for (int loop = 0; loop < loops; ++loop) {
50 // Unpremul -> Premul
51 canvas->writePixels(fBmp1.info(), fBmp1.getPixels(), fBmp1.rowBytes(), 0, 0);
52 // Premul -> Unpremul
53 canvas->readPixels(fBmp2.info(), fBmp2.getPixels(), fBmp2.rowBytes(), 0, 0);
54 }
55 }
constexpr SkColor SK_ColorBLACK
Definition: SkColor.h:103
size_t rowBytes() const
Definition: SkBitmap.h:238
void * getPixels() const
Definition: SkBitmap.h:283
const SkImageInfo & info() const
Definition: SkBitmap.h:139
bool writePixels(const SkImageInfo &info, const void *pixels, size_t rowBytes, int x, int y)
Definition: SkCanvas.cpp:399
void clear(SkColor color)
Definition: SkCanvas.h:1199
bool readPixels(const SkImageInfo &dstInfo, void *dstPixels, size_t dstRowBytes, int srcX, int srcY)
Definition: SkCanvas.cpp:382

◆ onGetName()

const char * PremulAndUnpremulAlphaOpsBench::onGetName ( )
inlineoverrideprotectedvirtual

Implements Benchmark.

Definition at line 28 of file PremulAndUnpremulAlphaOpsBench.cpp.

28 {
29 return fName.c_str();
30 }
const char * c_str() const
Definition: SkString.h:133

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