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

Public Member Functions

 GrQuadBoundsBench (bool perspective)
 
bool isSuitableFor (Backend backend) 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
 

Protected Types

using INHERITED = Benchmark
 

Protected Member Functions

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

Protected Attributes

SkString fName
 
bool fPerspective
 
GrQuad fQuads [kQuadCount]
 
SkScalar fArea
 

Static Protected Attributes

static constexpr int kQuadCount = 1000
 

Additional Inherited Members

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

Detailed Description

Definition at line 13 of file GrQuadBench.cpp.

Member Typedef Documentation

◆ INHERITED

Definition at line 68 of file GrQuadBench.cpp.

Constructor & Destructor Documentation

◆ GrQuadBoundsBench()

GrQuadBoundsBench::GrQuadBoundsBench ( bool  perspective)
inline

Definition at line 15 of file GrQuadBench.cpp.

16 : fPerspective(perspective) {
17 fName.printf("grquad_bounds_%s", perspective ? "3d" : "2d");
18 }
void printf(const char format[],...) SK_PRINTF_LIKE(2
Definition: SkString.cpp:534

Member Function Documentation

◆ isSuitableFor()

bool GrQuadBoundsBench::isSuitableFor ( Backend  backend)
inlineoverridevirtual

Reimplemented from Benchmark.

Definition at line 20 of file GrQuadBench.cpp.

20 {
22 }
const char * backend

◆ onDelayedSetup()

void GrQuadBoundsBench::onDelayedSetup ( )
inlineoverrideprotectedvirtual

Reimplemented from Benchmark.

Definition at line 31 of file GrQuadBench.cpp.

31 {
32 SkRandom r;
33 for (int i = 0; i < kQuadCount; ++i) {
34 for (int j = 0; j < 4; ++j) {
35 fQuads[i].xs()[j] = r.nextRangeF(-100.f, 100.f);
36 fQuads[i].ys()[j] = r.nextRangeF(-100.f, 100.f);
37 if (fPerspective) {
38 // Biased towards in front of the viewpoint, but do include some that require
39 // the vertices to be clipped against w = 0.
40 fQuads[i].ws()[j] = r.nextRangeF(-1.f, 10.f);
41 } else {
42 fQuads[i].ws()[j] = 1.f;
43 }
44 }
47 }
48 }
static constexpr int kQuadCount
Definition: GrQuadBench.cpp:25
GrQuad fQuads[kQuadCount]
Definition: GrQuadBench.cpp:65
const float * xs() const
Definition: GrQuad.h:132
const float * ys() const
Definition: GrQuad.h:134
void setQuadType(Type newType)
Definition: GrQuad.h:140
const float * ws() const
Definition: GrQuad.h:136
float nextRangeF(float min, float max)
Definition: SkRandom.h:64

◆ onDraw()

void GrQuadBoundsBench::onDraw ( int  loops,
SkCanvas  
)
inlineoverrideprotectedvirtual

Implements Benchmark.

Definition at line 50 of file GrQuadBench.cpp.

50 {
51 SkScalar area = 0.f;
52 for (int i = 0; i < loops; ++i) {
53 for (int j = 0; j < kQuadCount; ++j) {
54 SkRect qb = fQuads[j].bounds();
55 area += qb.width() + qb.height();
56 }
57 }
58 // Must persist this calculation in order to prevent the compiler from optimizing the
59 // loops away.
60 fArea = area;
61 }
SkRect bounds() const
Definition: GrQuad.h:81
float SkScalar
Definition: extension.cpp:12
constexpr float height() const
Definition: SkRect.h:769
constexpr float width() const
Definition: SkRect.h:762

◆ onGetName()

const char * GrQuadBoundsBench::onGetName ( )
inlineoverrideprotectedvirtual

Implements Benchmark.

Definition at line 27 of file GrQuadBench.cpp.

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

Member Data Documentation

◆ fArea

SkScalar GrQuadBoundsBench::fArea
protected

Definition at line 66 of file GrQuadBench.cpp.

◆ fName

SkString GrQuadBoundsBench::fName
protected

Definition at line 63 of file GrQuadBench.cpp.

◆ fPerspective

bool GrQuadBoundsBench::fPerspective
protected

Definition at line 64 of file GrQuadBench.cpp.

◆ fQuads

GrQuad GrQuadBoundsBench::fQuads[kQuadCount]
protected

Definition at line 65 of file GrQuadBench.cpp.

◆ kQuadCount

constexpr int GrQuadBoundsBench::kQuadCount = 1000
inlinestaticconstexprprotected

Definition at line 25 of file GrQuadBench.cpp.


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