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

Public Member Functions

 CirclesBench (Flags flags)
 
- 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 ()
 

Protected Attributes

SkString fName
 
Flags fFlags
 

Additional Inherited Members

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

Detailed Description

Definition at line 659 of file PathBench.cpp.

Constructor & Destructor Documentation

◆ CirclesBench()

CirclesBench::CirclesBench ( Flags  flags)
inline

Definition at line 665 of file PathBench.cpp.

665 : fFlags(flags) {
666 fName.printf("circles_%s", fFlags & kStroke_Flag ? "stroke" : "fill");
667 }
@ kStroke_Flag
Definition: PathBench.cpp:28
SkString fName
Definition: PathBench.cpp:661
void printf(const char format[],...) SK_PRINTF_LIKE(2
Definition: SkString.cpp:534
FlutterSemanticsFlag flags

Member Function Documentation

◆ onDraw()

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

Implements Benchmark.

Definition at line 674 of file PathBench.cpp.

674 {
676
677 paint.setColor(SK_ColorBLACK);
678 paint.setAntiAlias(true);
679 if (fFlags & kStroke_Flag) {
681 }
682
683 SkRandom rand;
684
685 SkRect r;
686
687 for (int i = 0; i < loops; ++i) {
688 SkScalar radius = rand.nextUScalar1() * 3;
689 r.fLeft = rand.nextUScalar1() * 300;
690 r.fTop = rand.nextUScalar1() * 300;
691 r.fRight = r.fLeft + 2 * radius;
692 r.fBottom = r.fTop + 2 * radius;
693
694 if (fFlags & kStroke_Flag) {
695 paint.setStrokeWidth(rand.nextUScalar1() * 5.0f);
696 }
697
698 SkPath temp;
699
700 // mimic how Chrome does circles
701 temp.arcTo(r, 0, 0, false);
703 temp.arcTo(r, 360, 0, true);
704 temp.close();
705
706 canvas->drawPath(temp, paint);
707 }
708 }
constexpr SkColor SK_ColorBLACK
Definition: SkColor.h:103
void drawPath(const SkPath &path, const SkPaint &paint)
Definition: SkCanvas.cpp:1747
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194
Definition: SkPath.h:59
SkPath & arcTo(const SkRect &oval, SkScalar startAngle, SkScalar sweepAngle, bool forceMoveTo)
Definition: SkPath.cpp:1220
SkPath & addOval(const SkRect &oval, SkPathDirection dir=SkPathDirection::kCW)
Definition: SkPath.cpp:1106
SkPath & close()
Definition: SkPath.cpp:823
SkScalar nextUScalar1()
Definition: SkRandom.h:101
const Paint & paint
Definition: color_source.cc:38
float SkScalar
Definition: extension.cpp:12
SkScalar fBottom
larger y-axis bounds
Definition: extension.cpp:17
SkScalar fLeft
smaller x-axis bounds
Definition: extension.cpp:14
SkScalar fRight
larger x-axis bounds
Definition: extension.cpp:16
SkScalar fTop
smaller y-axis bounds
Definition: extension.cpp:15

◆ onGetName()

const char * CirclesBench::onGetName ( )
inlineoverrideprotectedvirtual

Implements Benchmark.

Definition at line 670 of file PathBench.cpp.

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

Member Data Documentation

◆ fFlags

Flags CirclesBench::fFlags
protected

Definition at line 662 of file PathBench.cpp.

◆ fName

SkString CirclesBench::fName
protected

Definition at line 661 of file PathBench.cpp.


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