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

Public Types

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

Public Member Functions

 ClearBench (ClearType type)
 
- 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 Member Functions

const char * onGetName () 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

Definition at line 30 of file ClearBench.cpp.

Member Enumeration Documentation

◆ ClearType

Enumerator
kFull_ClearType 
kPartial_ClearType 
kComplex_ClearType 

Definition at line 32 of file ClearBench.cpp.

Constructor & Destructor Documentation

◆ ClearBench()

ClearBench::ClearBench ( ClearType  type)
inline

Definition at line 38 of file ClearBench.cpp.

38: fType(type) {}
GLenum type

Member Function Documentation

◆ onDraw()

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

Implements Benchmark.

Definition at line 54 of file ClearBench.cpp.

54 {
55 static const SkRect kPartialClip = SkRect::MakeLTRB(50, 50, 400, 400);
56 static const SkRRect kComplexClip = SkRRect::MakeRectXY(kPartialClip, 15, 15);
57 // Small to limit fill cost, but intersects the clips to confound batching
58 static const SkRect kInterruptRect = SkRect::MakeXYWH(200, 200, 3, 3);
59
60 // For the draw that sits between consecutive clears, use a shader that is simple but
61 // requires local coordinates so that Ganesh does not convert it into a solid color rect,
62 // which could then turn into a scissored-clear behind the scenes.
63 SkPaint interruptPaint;
64 interruptPaint.setShader(make_shader());
65
67 if (sdc) {
68 // Tell the skgpu::ganesh::SurfaceDrawContext to not reset its draw op list on a
69 // fullscreen clear.
70 // If we don't do this, fullscreen clear ops would be created and constantly discard the
71 // previous iteration's op so execution would only invoke one actual clear on the GPU
72 // (not what we want to measure).
73 sdc->testingOnly_SetPreserveOpsOnFullClear();
74 }
75
76 for (int i = 0; i < loops; i++) {
77 canvas->save();
78 switch(fType) {
80 canvas->clipRect(kPartialClip);
81 break;
83 canvas->clipRRect(kComplexClip);
84 break;
85 case kFull_ClearType:
86 // Don't add any extra clipping, since it defaults to the entire "device"
87 break;
88 }
89
90 // The clear we care about measuring
91 canvas->clear(SK_ColorBLUE);
92 canvas->restore();
93
94 // Perform as minimal a draw as possible that intersects with the clear region in
95 // order to prevent the clear ops from being batched together.
96 canvas->drawRect(kInterruptRect, interruptPaint);
97 }
98 }
static sk_sp< SkShader > make_shader()
Definition: ClearBench.cpp:24
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
Definition: SkCanvas.cpp:1361
void restore()
Definition: SkCanvas.cpp:461
void clear(SkColor color)
Definition: SkCanvas.h:1199
int save()
Definition: SkCanvas.cpp:447
void clipRRect(const SkRRect &rrect, SkClipOp op, bool doAntiAlias)
Definition: SkCanvas.cpp:1439
void setShader(sk_sp< SkShader > shader)
static SkRRect MakeRectXY(const SkRect &rect, SkScalar xRad, SkScalar yRad)
Definition: SkRRect.h:180
SurfaceDrawContext * TopDeviceSurfaceDrawContext(const SkCanvas *canvas)
Definition: GrCanvas.cpp:20
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
Definition: SkRect.h:646

◆ onGetName()

const char * ClearBench::onGetName ( )
inlineoverrideprotectedvirtual

Implements Benchmark.

Definition at line 41 of file ClearBench.cpp.

41 {
42 switch(fType) {
43 case kFull_ClearType:
44 return "Clear-Full";
46 return "Clear-Partial";
48 return "Clear-Complex";
49 }
50 SkASSERT(false);
51 return "Unreachable";
52 }
#define SkASSERT(cond)
Definition: SkAssert.h:116

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