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

Public Member Functions

 AAClipBench (bool doPath, bool doAA)
 
- 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 ()
 

Additional Inherited Members

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

Detailed Description

Definition at line 18 of file AAClipBench.cpp.

Constructor & Destructor Documentation

◆ AAClipBench()

AAClipBench::AAClipBench ( bool  doPath,
bool  doAA 
)
inline

Definition at line 27 of file AAClipBench.cpp.

28 : fDoPath(doPath)
29 , fDoAA(doAA) {
30
31 fName.printf("aaclip_%s_%s",
32 doPath ? "path" : "rect",
33 doAA ? "AA" : "BW");
34
35 fClipRect.setLTRB(10.5f, 10.5f, 50.5f, 50.5f);
36 fClipPath.addRoundRect(fClipRect, SkIntToScalar(10), SkIntToScalar(10));
37 fDrawRect.setWH(100, 100);
38
39 SkASSERT(fClipPath.isConvex());
40 }
#define SkASSERT(cond)
Definition: SkAssert.h:116
#define SkIntToScalar(x)
Definition: SkScalar.h:57
SkPath & addRoundRect(const SkRect &rect, SkScalar rx, SkScalar ry, SkPathDirection dir=SkPathDirection::kCW)
Definition: SkPath.cpp:1093
bool isConvex() const
Definition: SkPath.cpp:426
void printf(const char format[],...) SK_PRINTF_LIKE(2
Definition: SkString.cpp:534
void setWH(float width, float height)
Definition: SkRect.h:944
void setLTRB(float left, float top, float right, float bottom)
Definition: SkRect.h:865

Member Function Documentation

◆ onDraw()

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

Implements Benchmark.

Definition at line 44 of file AAClipBench.cpp.

44 {
45
47 this->setupPaint(&paint);
48
49 for (int i = 0; i < loops; ++i) {
50 // jostle the clip regions each time to prevent caching
51 fClipRect.offset((i % 2) == 0 ? SkIntToScalar(10) : SkIntToScalar(-10), 0);
52 fClipPath.reset();
53 fClipPath.addRoundRect(fClipRect,
55 SkASSERT(fClipPath.isConvex());
56
57 canvas->save();
58#if 1
59 if (fDoPath) {
60 canvas->clipPath(fClipPath, SkClipOp::kIntersect, fDoAA);
61 } else {
62 canvas->clipRect(fClipRect, SkClipOp::kIntersect, fDoAA);
63 }
64
65 canvas->drawRect(fDrawRect, paint);
66#else
67 // this path tests out directly draw the clip primitive
68 // use it to comparing just drawing the clip vs. drawing using
69 // the clip
70 if (fDoPath) {
71 canvas->drawPath(fClipPath, paint);
72 } else {
73 canvas->drawRect(fClipRect, paint);
74 }
75#endif
76 canvas->restore();
77 }
78 }
virtual void setupPaint(SkPaint *paint)
Definition: Benchmark.cpp:55
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 clipPath(const SkPath &path, SkClipOp op, bool doAntiAlias)
Definition: SkCanvas.cpp:1456
int save()
Definition: SkCanvas.cpp:447
void drawPath(const SkPath &path, const SkPaint &paint)
Definition: SkCanvas.cpp:1747
SkPath & reset()
Definition: SkPath.cpp:370
const Paint & paint
Definition: color_source.cc:38
void offset(float dx, float dy)
Definition: SkRect.h:1016

◆ onGetName()

const char * AAClipBench::onGetName ( )
inlineoverrideprotectedvirtual

Implements Benchmark.

Definition at line 43 of file AAClipBench.cpp.

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

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