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

Public Types

enum  { NX = 5 , NY = 5 , NUM_DRAWS = NX * NY }
 
- Public Types inherited from Benchmark
enum class  Backend {
  kNonRendering , kRaster , kGanesh , kGraphite ,
  kPDF , kHWUI
}
 

Public Member Functions

 AlternatingColorPatternBench (ColorPattern pattern1, ColorPattern pattern2, DrawType drawType)
 
- 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

sk_sp< SkShaderfBmShader
 
SkPath fPaths [NUM_DRAWS]
 
SkRect fRects [NUM_DRAWS]
 
SkColor fColors [NUM_DRAWS]
 
sk_sp< SkShaderfShaders [NUM_DRAWS]
 
SkString fName
 
ColorPatternData fPattern1
 
ColorPatternData fPattern2
 
DrawType fDrawType
 
SkBitmap fBmp
 

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 ()
 

Detailed Description

This bench draws a grid of either rects or filled paths, with two alternating color patterns. This color patterns are passed in as enums to the class. The options are: 1) solid white color 2) solid blue color 3) opaque bitmap 4) partial alpha bitmap The same color pattern can be set for both arguments to create a uniform pattern on all draws.

The bench is used to test a few things. First it can test any optimizations made for a specific color pattern (for example drawing an opaque bitmap versus one with partial alpha). Also it can be used to test the cost of program switching and/or GrDrawOp combining when alternating between different patterns when on the gpu.

Definition at line 77 of file AlternatingColorPatternBench.cpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Constructor & Destructor Documentation

◆ AlternatingColorPatternBench()

AlternatingColorPatternBench::AlternatingColorPatternBench ( ColorPattern  pattern1,
ColorPattern  pattern2,
DrawType  drawType 
)
inline

Definition at line 98 of file AlternatingColorPatternBench.cpp.

98 {
99 fPattern1 = gColorPatterns[pattern1];
100 fPattern2 = gColorPatterns[pattern2];
101 fName.printf("colorPattern_%s_%s_%s",
103 kRect_DrawType == drawType ? "rect" : "path");
104 fDrawType = drawType;
105 }
static const struct ColorPatternData gColorPatterns[]
void printf(const char format[],...) SK_PRINTF_LIKE(2
Definition: SkString.cpp:534

Member Function Documentation

◆ onDelayedSetup()

void AlternatingColorPatternBench::onDelayedSetup ( )
inlineoverrideprotectedvirtual

Reimplemented from Benchmark.

Definition at line 112 of file AlternatingColorPatternBench.cpp.

112 {
113 int w = 40;
114 int h = 40;
115 makebm(&fBmp, w, h);
118 int offset = 2;
119 int count = 0;
120 for (int j = 0; j < NY; ++j) {
121 for (int i = 0; i < NX; ++i) {
122 int x = (w + offset) * i;
123 int y = (h * offset) * j;
124 if (kRect_DrawType == fDrawType) {
127 } else {
132 }
133 if (0 == count % 2) {
136 } else {
139 }
140 ++count;
141 }
142 }
143 }
static void makebm(SkBitmap *bm, int w, int h)
int count
Definition: FontMgrTest.cpp:50
#define SkIntToScalar(x)
Definition: SkScalar.h:57
sk_sp< SkShader > fShaders[NUM_DRAWS]
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
Definition: SkBitmap.cpp:669
SkPath & moveTo(SkScalar x, SkScalar y)
Definition: SkPath.cpp:688
SkPath & rLineTo(SkScalar dx, SkScalar dy)
Definition: SkPath.cpp:739
double y
double x
SkSamplingOptions(SkFilterMode::kLinear))
SkScalar w
SkScalar h
SeparatedVector2 offset
void setXYWH(float x, float y, float width, float height)
Definition: SkRect.h:931

◆ onDraw()

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

Implements Benchmark.

Definition at line 145 of file AlternatingColorPatternBench.cpp.

145 {
147 paint.setAntiAlias(false);
148
149 for (int i = 0; i < loops; ++i) {
150 for (int j = 0; j < NUM_DRAWS; ++j) {
151 paint.setColor(fColors[j]);
152 paint.setShader(fShaders[j]);
153 if (kRect_DrawType == fDrawType) {
154 canvas->drawRect(fRects[j], paint);
155 } else {
156 canvas->drawPath(fPaths[j], paint);
157 }
158 }
159 }
160 }
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void drawPath(const SkPath &path, const SkPaint &paint)
Definition: SkCanvas.cpp:1747
const Paint & paint
Definition: color_source.cc:38

◆ onGetName()

const char * AlternatingColorPatternBench::onGetName ( )
inlineoverrideprotectedvirtual

Implements Benchmark.

Definition at line 108 of file AlternatingColorPatternBench.cpp.

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

Member Data Documentation

◆ fBmp

SkBitmap AlternatingColorPatternBench::fBmp

Definition at line 95 of file AlternatingColorPatternBench.cpp.

◆ fBmShader

sk_sp<SkShader> AlternatingColorPatternBench::fBmShader

Definition at line 84 of file AlternatingColorPatternBench.cpp.

◆ fColors

SkColor AlternatingColorPatternBench::fColors[NUM_DRAWS]

Definition at line 88 of file AlternatingColorPatternBench.cpp.

◆ fDrawType

DrawType AlternatingColorPatternBench::fDrawType

Definition at line 94 of file AlternatingColorPatternBench.cpp.

◆ fName

SkString AlternatingColorPatternBench::fName

Definition at line 91 of file AlternatingColorPatternBench.cpp.

◆ fPaths

SkPath AlternatingColorPatternBench::fPaths[NUM_DRAWS]

Definition at line 86 of file AlternatingColorPatternBench.cpp.

◆ fPattern1

ColorPatternData AlternatingColorPatternBench::fPattern1

Definition at line 92 of file AlternatingColorPatternBench.cpp.

◆ fPattern2

ColorPatternData AlternatingColorPatternBench::fPattern2

Definition at line 93 of file AlternatingColorPatternBench.cpp.

◆ fRects

SkRect AlternatingColorPatternBench::fRects[NUM_DRAWS]

Definition at line 87 of file AlternatingColorPatternBench.cpp.

◆ fShaders

sk_sp<SkShader> AlternatingColorPatternBench::fShaders[NUM_DRAWS]

Definition at line 89 of file AlternatingColorPatternBench.cpp.


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