Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | List of all members
RectBench Class Reference
Inheritance diagram for RectBench:
Benchmark SkRefCnt SkRefCntBase BlitMaskBench LocalCoordsRectBench OvalBench PointsBench RRectBench SrcModeRectBench TransparentRectBench

Public Types

enum  { W = 640 , H = 480 , N = 300 }
 
- Public Types inherited from Benchmark
enum class  Backend {
  kNonRendering , kRaster , kGanesh , kGraphite ,
  kPDF , kHWUI
}
 

Public Member Functions

 RectBench (int shift, int stroke=0, bool aa=true, bool perspective=false)
 
const char * computeName (const char root[])
 
- 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
 

Public Attributes

int fShift
 
int fStroke
 
SkRect fRects [N]
 
SkColor fColors [N]
 
bool fAA
 
bool fPerspective
 

Protected Member Functions

virtual void drawThisRect (SkCanvas *c, const SkRect &r, const SkPaint &p)
 
const char * onGetName () override
 
void onDelayedSetup () override
 
void onDraw (int loops, SkCanvas *canvas) override
 
void setupPaint (SkPaint *paint) 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 ()
 

Detailed Description

Definition at line 20 of file RectBench.cpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator

Definition at line 23 of file RectBench.cpp.

23 {
24 W = 640,
25 H = 480,
26 N = 300,
27 };
Definition: SkMD5.cpp:130

Constructor & Destructor Documentation

◆ RectBench()

RectBench::RectBench ( int  shift,
int  stroke = 0,
bool  aa = true,
bool  perspective = false 
)
inline

Definition at line 33 of file RectBench.cpp.

34 : fShift(shift)
36 , fAA(aa)
37 , fPerspective(perspective) {}
int fShift
Definition: RectBench.cpp:22
int fStroke
Definition: RectBench.cpp:22
bool fPerspective
Definition: RectBench.cpp:31
bool fAA
Definition: RectBench.cpp:30

Member Function Documentation

◆ computeName()

const char * RectBench::computeName ( const char  root[])
inline

Definition at line 39 of file RectBench.cpp.

39 {
40 fBaseName.printf("%s_%d", root, fShift);
41 if (fStroke > 0) {
42 fBaseName.appendf("_stroke_%d", fStroke);
43 }
44 if (fAA) {
45 fBaseName.appendf("_aa");
46 } else {
47 fBaseName.appendf("_bw");
48 }
49 if (fPerspective) {
50 fBaseName.appendf("_persp");
51 }
52 return fBaseName.c_str();
53 }
void printf(const char format[],...) SK_PRINTF_LIKE(2
Definition: SkString.cpp:534
const char * c_str() const
Definition: SkString.h:133
void void void appendf(const char format[],...) SK_PRINTF_LIKE(2
Definition: SkString.cpp:550
string root
Definition: scale_cpu.py:20

◆ drawThisRect()

virtual void RectBench::drawThisRect ( SkCanvas c,
const SkRect r,
const SkPaint p 
)
inlineprotectedvirtual

Reimplemented in OvalBench, and RRectBench.

Definition at line 57 of file RectBench.cpp.

57 {
58 c->drawRect(r, p);
59 }
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673

◆ onDelayedSetup()

void RectBench::onDelayedSetup ( )
inlineoverrideprotectedvirtual

Reimplemented from Benchmark.

Reimplemented in LocalCoordsRectBench.

Definition at line 63 of file RectBench.cpp.

63 {
64 SkRandom rand;
65 const SkScalar offset = SK_Scalar1/3;
66 for (int i = 0; i < N; i++) {
67 int x = rand.nextU() % W;
68 int y = rand.nextU() % H;
69 int w = rand.nextU() % W;
70 int h = rand.nextU() % H;
71 w >>= fShift;
72 h >>= fShift;
73 x -= w/2;
74 y -= h/2;
78 fColors[i] = rand.nextU() | 0xFF808080;
79 }
80 }
#define SK_Scalar1
Definition: SkScalar.h:18
#define SkIntToScalar(x)
Definition: SkScalar.h:57
SkColor fColors[N]
Definition: RectBench.cpp:29
SkRect fRects[N]
Definition: RectBench.cpp:28
uint32_t nextU()
Definition: SkRandom.h:42
float SkScalar
Definition: extension.cpp:12
double y
double x
SkScalar w
SkScalar h
SeparatedVector2 offset
void setXYWH(float x, float y, float width, float height)
Definition: SkRect.h:931
void offset(float dx, float dy)
Definition: SkRect.h:1016

◆ onDraw()

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

Implements Benchmark.

Reimplemented in PointsBench, and BlitMaskBench.

Definition at line 82 of file RectBench.cpp.

82 {
84 if (fStroke > 0) {
86 paint.setStrokeWidth(SkIntToScalar(fStroke));
87 }
88 if (fPerspective) {
89 // Apply some fixed perspective to change how ops may draw the rects
90 SkMatrix perspective;
91 perspective.setIdentity();
92 perspective.setPerspX(1e-4f);
93 perspective.setPerspY(1e-3f);
94 perspective.setSkewX(0.1f);
95 canvas->concat(perspective);
96 }
97 for (int i = 0; i < loops; i++) {
98 paint.setColor(fColors[i % N]);
99 this->setupPaint(&paint);
100 this->drawThisRect(canvas, fRects[i % N], paint);
101 }
102 }
virtual void drawThisRect(SkCanvas *c, const SkRect &r, const SkPaint &p)
Definition: RectBench.cpp:57
void setupPaint(SkPaint *paint) override
Definition: RectBench.cpp:104
void concat(const SkMatrix &matrix)
Definition: SkCanvas.cpp:1318
SkMatrix & setSkewX(SkScalar v)
Definition: SkMatrix.h:518
SkMatrix & setPerspX(SkScalar v)
Definition: SkMatrix.h:537
SkMatrix & setPerspY(SkScalar v)
Definition: SkMatrix.h:544
SkMatrix & setIdentity()
Definition: SkMatrix.h:626
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194
const Paint & paint
Definition: color_source.cc:38

◆ onGetName()

const char * RectBench::onGetName ( )
inlineoverrideprotectedvirtual

Implements Benchmark.

Reimplemented in SrcModeRectBench, TransparentRectBench, LocalCoordsRectBench, OvalBench, RRectBench, PointsBench, and BlitMaskBench.

Definition at line 61 of file RectBench.cpp.

61{ return computeName("rects"); }
const char * computeName(const char root[])
Definition: RectBench.cpp:39

◆ setupPaint()

void RectBench::setupPaint ( SkPaint paint)
inlineoverrideprotectedvirtual

Reimplemented from Benchmark.

Reimplemented in SrcModeRectBench, TransparentRectBench, and LocalCoordsRectBench.

Definition at line 104 of file RectBench.cpp.

104 {
105 this->INHERITED::setupPaint(paint);
106 paint->setAntiAlias(fAA);
107 }
virtual void setupPaint(SkPaint *paint)
Definition: Benchmark.cpp:55

Member Data Documentation

◆ fAA

bool RectBench::fAA

Definition at line 30 of file RectBench.cpp.

◆ fColors

SkColor RectBench::fColors[N]

Definition at line 29 of file RectBench.cpp.

◆ fPerspective

bool RectBench::fPerspective

Definition at line 31 of file RectBench.cpp.

◆ fRects

SkRect RectBench::fRects[N]

Definition at line 28 of file RectBench.cpp.

◆ fShift

int RectBench::fShift

Definition at line 22 of file RectBench.cpp.

◆ fStroke

int RectBench::fStroke

Definition at line 22 of file RectBench.cpp.


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