Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
FourByteInterpBench< kFast, kScale > Class Template Reference
Inheritance diagram for FourByteInterpBench< kFast, kScale >:
Benchmark SkRefCnt SkRefCntBase

Public Member Functions

 FourByteInterpBench ()
 
bool isSuitableFor (Backend backend) override
 
const char * onGetName () override
 
void onDelayedSetup () override
 
void onDraw (int loops, SkCanvas *) override
 
- 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
 

Additional Inherited Members

- Public Types inherited from Benchmark
enum class  Backend {
  kNonRendering , kRaster , kGanesh , kGraphite ,
  kPDF , kHWUI
}
 
- 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 ()
 

Detailed Description

template<bool kFast, bool kScale>
class FourByteInterpBench< kFast, kScale >

Definition at line 13 of file ColorPrivBench.cpp.

Constructor & Destructor Documentation

◆ FourByteInterpBench()

template<bool kFast, bool kScale>
FourByteInterpBench< kFast, kScale >::FourByteInterpBench ( )
inline

Definition at line 15 of file ColorPrivBench.cpp.

15 {
16 fName.set("four_byte_interp");
17 fName.append(kFast ? "_fast" : "_slow");
18 fName.append(kScale ? "_255" : "_256");
19 }
void set(const SkString &src)
Definition: SkString.h:186
void append(const char text[])
Definition: SkString.h:203

Member Function Documentation

◆ isSuitableFor()

template<bool kFast, bool kScale>
bool FourByteInterpBench< kFast, kScale >::isSuitableFor ( Backend  backend)
inlineoverridevirtual

Reimplemented from Benchmark.

Definition at line 21 of file ColorPrivBench.cpp.

21 {
23 }
const char * backend

◆ onDelayedSetup()

template<bool kFast, bool kScale>
void FourByteInterpBench< kFast, kScale >::onDelayedSetup ( )
inlineoverridevirtual

Reimplemented from Benchmark.

Definition at line 27 of file ColorPrivBench.cpp.

27 {
28 // A handful of random srcs and dsts.
29 SkRandom rand;
30 for (int i = 0; i < kInputs; i++) {
31 fSrcs[i] = SkPreMultiplyColor(rand.nextU());
32 fDsts[i] = SkPreMultiplyColor(rand.nextU());
33 }
34
35 // We'll exhaustively test all scales instead of using random numbers.
36 for (int i = 0; i <= 256; i++) {
37 fScales[i] = i;
38 }
39 if (kScale) fScales[256] = 255; // We'll just do 255 twice if we're limited to [0,255].
40 }
SK_API SkPMColor SkPreMultiplyColor(SkColor c)
Definition: SkColor.cpp:21
uint32_t nextU()
Definition: SkRandom.h:42

◆ onDraw()

template<bool kFast, bool kScale>
void FourByteInterpBench< kFast, kScale >::onDraw ( int  loops,
SkCanvas  
)
inlineoverridevirtual

Implements Benchmark.

Definition at line 42 of file ColorPrivBench.cpp.

42 {
43 // We xor results of FourByteInterp into junk to make sure the function runs.
44 [[maybe_unused]] volatile SkPMColor junk = 0;
45
46 for (int loop = 0; loop < loops; loop++) {
47 for (int i = 0; i < kInputs; i++) {
48 for (size_t j = 0; j <= 256; j++) {
49 // Note: we really want to load src and dst here and not outside in the i-loop.
50 // If we put the loads there, a clever compiler will do the not-insignificant
51 // work in the FourByteInterps that depends only on src and dst outside this
52 // loop, so we'd only be benchmarking the back half of those functions that also
53 // depends on scale. Even here, these must be volatile arrays to prevent that
54 // clever compiler from hoisting the loads out of the loop on its own.
55 const SkPMColor src = fSrcs[i];
56 const SkPMColor dst = fDsts[i];
57
58 const unsigned scale = fScales[j];
59
60 if (kFast && kScale) {
62 } else if (kFast) {
64 } else if (kScale) {
65 junk = SkFourByteInterp(src, dst, scale);
66 } else {
68 }
69 }
70 }
71 }
72 }
static SkPMColor SkFastFourByteInterp256(SkPMColor src, SkPMColor dst, unsigned scale)
Definition: SkColorData.h:247
static SkPMColor SkFastFourByteInterp(SkPMColor src, SkPMColor dst, U8CPU srcWeight)
Definition: SkColorData.h:260
static SkPMColor SkFourByteInterp(SkPMColor src, SkPMColor dst, U8CPU srcWeight)
Definition: SkColorData.h:177
static SkPMColor SkFourByteInterp256(SkPMColor src, SkPMColor dst, int scale)
Definition: SkColorData.h:162
uint32_t SkPMColor
Definition: SkColor.h:205
dst
Definition: cp.py:12
const Scalar scale

◆ onGetName()

template<bool kFast, bool kScale>
const char * FourByteInterpBench< kFast, kScale >::onGetName ( )
inlineoverridevirtual

Implements Benchmark.

Definition at line 25 of file ColorPrivBench.cpp.

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

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