Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
PatchBench Class Reference
Inheritance diagram for PatchBench:
Benchmark SkRefCnt SkRefCntBase LODDiffPatchBench LoopPatchBench SquarePatchBench

Public Types

enum  VertexMode { kNone_VertexMode , kColors_VertexMode , kTexCoords_VertexMode , kBoth_VertexMode }
 
- Public Types inherited from Benchmark
enum class  Backend {
  kNonRendering , kRaster , kGanesh , kGraphite ,
  kPDF , kHWUI
}
 

Public Member Functions

 PatchBench (SkPoint scale, VertexMode vertexMode)
 
virtual void appendName (SkString *name)
 
virtual void setCubics ()
 
virtual void setColors ()
 
virtual void setTexCoords ()
 
virtual sk_sp< SkShadercreateShader ()
 
- 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 *canvas) override
 
- Protected Member Functions inherited from Benchmark
void setUnits (int units)
 
virtual void setupPaint (SkPaint *paint)
 
virtual const char * onGetUniqueName ()
 
virtual void onPerCanvasPreDraw (SkCanvas *)
 
virtual void onPerCanvasPostDraw (SkCanvas *)
 
virtual void onPreDraw (SkCanvas *)
 
virtual void onPostDraw (SkCanvas *)
 
virtual SkISize onGetSize ()
 

Protected Attributes

SkPaint fPaint
 
SkString fName
 
SkVector fScale
 
SkPoint fCubics [12]
 
SkPoint fTexCoords [4]
 
SkColor fColors [4]
 
VertexMode fVertexMode
 

Detailed Description

This bench measures the rendering time of the call SkCanvas::drawPatch with different types of input patches (regular case, with loops, a square, with a big difference between "parallel" sides). This bench also tests the different combination of optional parameters for the function (passing texture coordinates and colors, only textures coordinates, only colors or none). Finally, it applies a scale to test if the size affects the rendering time.

Definition at line 24 of file PatchBench.cpp.

Member Typedef Documentation

◆ INHERITED

using PatchBench::INHERITED = Benchmark
protected

Definition at line 157 of file PatchBench.cpp.

Member Enumeration Documentation

◆ VertexMode

Enumerator
kNone_VertexMode 
kColors_VertexMode 
kTexCoords_VertexMode 
kBoth_VertexMode 

Definition at line 28 of file PatchBench.cpp.

Constructor & Destructor Documentation

◆ PatchBench()

PatchBench::PatchBench ( SkPoint  scale,
VertexMode  vertexMode 
)
inline

Definition at line 35 of file PatchBench.cpp.

36 : fScale(scale)
37 , fVertexMode(vertexMode) { }
VertexMode fVertexMode
SkVector fScale
const Scalar scale

Member Function Documentation

◆ appendName()

virtual void PatchBench::appendName ( SkString name)
inlinevirtual

Reimplemented in SquarePatchBench, LODDiffPatchBench, and LoopPatchBench.

Definition at line 40 of file PatchBench.cpp.

40 {
41 name->append("normal");
42 }
const char * name
Definition fuchsia.cc:50

◆ createShader()

virtual sk_sp< SkShader > PatchBench::createShader ( )
inlinevirtual

Definition at line 74 of file PatchBench.cpp.

74 {
75 const SkColor colors[] = {
78 };
79 const SkPoint pts[] = { { 200.f / 4.f, 0.f }, { 3.f * 200.f / 4, 200.f } };
80
81 return SkGradientShader::MakeLinear(pts, colors, nullptr, std::size(colors),
83 }
constexpr SkColor SK_ColorYELLOW
Definition SkColor.h:139
constexpr SkColor SK_ColorMAGENTA
Definition SkColor.h:147
uint32_t SkColor
Definition SkColor.h:37
constexpr SkColor SK_ColorCYAN
Definition SkColor.h:143
constexpr SkColor SK_ColorBLUE
Definition SkColor.h:135
constexpr SkColor SK_ColorRED
Definition SkColor.h:126
constexpr SkColor SK_ColorGREEN
Definition SkColor.h:131
constexpr SkColor SK_ColorWHITE
Definition SkColor.h:122
static sk_sp< SkShader > MakeLinear(const SkPoint pts[2], const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, uint32_t flags=0, const SkMatrix *localMatrix=nullptr)
PODArray< SkColor > colors
Definition SkRecords.h:276

◆ onDelayedSetup()

void PatchBench::onDelayedSetup ( )
inlineoverrideprotectedvirtual

Reimplemented from Benchmark.

Definition at line 111 of file PatchBench.cpp.

111 {
112 this->setCubics();
113 this->setColors();
114 this->setTexCoords();
115 this->setupPaint(&fPaint);
116 switch (fVertexMode) {
118 case kBoth_VertexMode:
120 break;
121 default:
122 fPaint.setShader(nullptr);
123 break;
124 }
125 }
virtual void setupPaint(SkPaint *paint)
Definition Benchmark.cpp:55
virtual sk_sp< SkShader > createShader()
virtual void setColors()
virtual void setTexCoords()
virtual void setCubics()
SkPaint fPaint
void setShader(sk_sp< SkShader > shader)

◆ onDraw()

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

Implements Benchmark.

Definition at line 127 of file PatchBench.cpp.

127 {
128 canvas->scale(fScale.x(), fScale.y());
129 for (int i = 0; i < loops; i++) {
130 switch (fVertexMode) {
131 case kNone_VertexMode:
132 canvas->drawPatch(fCubics, nullptr, nullptr, SkBlendMode::kModulate, fPaint);
133 break;
136 break;
139 break;
140 case kBoth_VertexMode:
142 break;
143 default:
144 break;
145 }
146 }
147 }
@ kModulate
r = s*d
SkPoint fTexCoords[4]
SkColor fColors[4]
SkPoint fCubics[12]
void drawPatch(const SkPoint cubics[12], const SkColor colors[4], const SkPoint texCoords[4], SkBlendMode mode, const SkPaint &paint)
void scale(SkScalar sx, SkScalar sy)
constexpr float y() const
constexpr float x() const

◆ onGetName()

const char * PatchBench::onGetName ( )
inlineoverrideprotectedvirtual

Implements Benchmark.

Definition at line 86 of file PatchBench.cpp.

86 {
87 SkString vertexMode;
88 switch (fVertexMode) {
90 vertexMode.set("meshlines");
91 break;
93 vertexMode.set("colors");
94 break;
96 vertexMode.set("texs");
97 break;
99 vertexMode.set("colors_texs");
100 break;
101 default:
102 break;
103 }
105 this->appendName(&type);
106 fName.printf("patch_%s_%s_%fx%f", type.c_str(), vertexMode.c_str(),
107 fScale.x(), fScale.y());
108 return fName.c_str();
109 }
SkString fName
virtual void appendName(SkString *name)
void printf(const char format[],...) SK_PRINTF_LIKE(2
Definition SkString.cpp:534
void set(const SkString &src)
Definition SkString.h:186
const char * c_str() const
Definition SkString.h:133

◆ setColors()

virtual void PatchBench::setColors ( )
inlinevirtual

Definition at line 59 of file PatchBench.cpp.

◆ setCubics()

virtual void PatchBench::setCubics ( )
inlinevirtual

Reimplemented in SquarePatchBench, LODDiffPatchBench, and LoopPatchBench.

Definition at line 45 of file PatchBench.cpp.

45 {
47 //top points
48 {100,100},{150,50},{250,150}, {300,100},
49 //right points
50 {350, 150},{250,200},
51 //bottom points
52 {300,300},{250,250},{150,350},{100,300},
53 //left points
54 {50,250},{150,50}
55 };
57 }
static const int points[]

◆ setTexCoords()

virtual void PatchBench::setTexCoords ( )
inlinevirtual

Definition at line 66 of file PatchBench.cpp.

66 {
67 const SkPoint texCoords[SkPatchUtils::kNumCorners] = {
68 {0.0f, 0.0f}, {1.0f, 0.0f}, {1.0f,1.0f}, {0.0f, 1.0f}
69 };
70 memcpy(fTexCoords, texCoords, SkPatchUtils::kNumCorners * sizeof(SkPoint));
71 }

Member Data Documentation

◆ fColors

SkColor PatchBench::fColors[4]
protected

Definition at line 154 of file PatchBench.cpp.

◆ fCubics

SkPoint PatchBench::fCubics[12]
protected

Definition at line 152 of file PatchBench.cpp.

◆ fName

SkString PatchBench::fName
protected

Definition at line 150 of file PatchBench.cpp.

◆ fPaint

SkPaint PatchBench::fPaint
protected

Definition at line 149 of file PatchBench.cpp.

◆ fScale

SkVector PatchBench::fScale
protected

Definition at line 151 of file PatchBench.cpp.

◆ fTexCoords

SkPoint PatchBench::fTexCoords[4]
protected

Definition at line 153 of file PatchBench.cpp.

◆ fVertexMode

VertexMode PatchBench::fVertexMode
protected

Definition at line 155 of file PatchBench.cpp.


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