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

Public Member Functions

 HardStopGradientBench_ScaleNumHardStops (int colorCount, int hardStopCount)
 
const char * onGetName () override
 
SkISize onGetSize () override
 
void onPreDraw (SkCanvas *canvas) override
 
void onDraw (int loops, SkCanvas *canvas) override
 
- 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
 

Additional Inherited Members

- Public Types inherited from Benchmark
enum class  Backend {
  kNonRendering , kRaster , kGanesh , kGraphite ,
  kPDF , kHWUI
}
 
- 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 20 of file HardStopGradientBench_ScaleNumHardStops.cpp.

Constructor & Destructor Documentation

◆ HardStopGradientBench_ScaleNumHardStops()

HardStopGradientBench_ScaleNumHardStops::HardStopGradientBench_ScaleNumHardStops ( int  colorCount,
int  hardStopCount 
)
inline

Definition at line 22 of file HardStopGradientBench_ScaleNumHardStops.cpp.

22 {
23 SkASSERT(hardStopCount <= colorCount/2);
24
25 fName.printf("hardstop_scale_num_hard_stops_%03d_colors_%03d_hard_stops",
26 colorCount, hardStopCount);
27
28 fColorCount = colorCount;
29 fHardStopCount = hardStopCount;
30 }
#define SkASSERT(cond)
Definition: SkAssert.h:116
void printf(const char format[],...) SK_PRINTF_LIKE(2
Definition: SkString.cpp:534

Member Function Documentation

◆ onDraw()

void HardStopGradientBench_ScaleNumHardStops::onDraw ( int  loops,
SkCanvas canvas 
)
inlineoverridevirtual

Implements Benchmark.

Definition at line 86 of file HardStopGradientBench_ScaleNumHardStops.cpp.

86 {
87 for (int i = 0; i < loops; i++) {
88 canvas->drawPaint(fPaint);
89 }
90 }
void drawPaint(const SkPaint &paint)
Definition: SkCanvas.cpp:1668

◆ onGetName()

const char * HardStopGradientBench_ScaleNumHardStops::onGetName ( )
inlineoverridevirtual

Implements Benchmark.

Definition at line 32 of file HardStopGradientBench_ScaleNumHardStops.cpp.

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

◆ onGetSize()

SkISize HardStopGradientBench_ScaleNumHardStops::onGetSize ( )
inlineoverridevirtual

Reimplemented from Benchmark.

Definition at line 36 of file HardStopGradientBench_ScaleNumHardStops.cpp.

36 {
37 return SkISize::Make(kSize, kSize);
38 }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ onPreDraw()

void HardStopGradientBench_ScaleNumHardStops::onPreDraw ( SkCanvas canvas)
inlineoverridevirtual

Reimplemented from Benchmark.

Definition at line 40 of file HardStopGradientBench_ScaleNumHardStops.cpp.

40 {
41 // Left to right
42 SkPoint points[2] = {
43 SkPoint::Make(0, kSize/2),
44 SkPoint::Make(kSize-1, kSize/2),
45 };
46
47 constexpr int kNumColorChoices = 4;
48 SkColor color_choices[kNumColorChoices] = {
53 };
54
55 // Alternate between different choices
56 AutoTArray<SkColor> colors(fColorCount);
57 for (int i = 0; i < fColorCount; i++) {
58 colors[i] = color_choices[i % kNumColorChoices];
59 }
60
61 // Create requisite number of hard stops, and evenly
62 // space positions after that
63 AutoTArray<SkScalar> positions(fColorCount);
64 int k = 0;
65 for (int i = 0; i < fHardStopCount; i++) {
66 float val = k/2.0f;
67 positions[k++] = val / fColorCount;
68 positions[k++] = val / fColorCount;
69 }
70 for (int i = k; i < fColorCount; i++) {
71 positions[i] = i / (fColorCount - 1.0f);
72 }
73
75 colors.get(),
76 positions.get(),
77 fColorCount,
79 0,
80 nullptr));
81 }
static const int points[]
constexpr SkColor SK_ColorYELLOW
Definition: SkColor.h:139
uint32_t SkColor
Definition: SkColor.h:37
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
constexpr SkColor SK_ColorGREEN
Definition: SkColor.h:131
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)
void setShader(sk_sp< SkShader > shader)
PODArray< SkColor > colors
Definition: SkRecords.h:276
static constexpr SkPoint Make(float x, float y)
Definition: SkPoint_impl.h:173

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