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

Public Member Functions

 Gradient2Bench (bool hasAlpha)
 
- 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 311 of file GradientBench.cpp.

Constructor & Destructor Documentation

◆ Gradient2Bench()

Gradient2Bench::Gradient2Bench ( bool  hasAlpha)
inline

Definition at line 316 of file GradientBench.cpp.

316 {
317 fName.printf("gradient_create_%s", hasAlpha ? "alpha" : "opaque");
318 fHasAlpha = hasAlpha;
319 }
void printf(const char format[],...) SK_PRINTF_LIKE(2
Definition: SkString.cpp:534

Member Function Documentation

◆ onDraw()

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

Implements Benchmark.

Definition at line 326 of file GradientBench.cpp.

326 {
328 this->setupPaint(&paint);
329
330 const SkRect r = { 0, 0, SkIntToScalar(4), SkIntToScalar(4) };
331 const SkPoint pts[] = {
332 { 0, 0 },
333 { SkIntToScalar(100), SkIntToScalar(100) },
334 };
335
336 for (int i = 0; i < loops; i++) {
337 const int gray = i % 256;
338 const int alpha = fHasAlpha ? gray : 0xFF;
339 SkColor colors[] = {
341 SkColorSetARGB(alpha, gray, gray, gray),
343 paint.setShader(SkGradientShader::MakeLinear(pts, colors, nullptr,
346 canvas->drawRect(r, paint);
347 }
348 }
uint32_t SkColor
Definition: SkColor.h:37
static constexpr SkColor SkColorSetARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
Definition: SkColor.h:49
constexpr SkColor SK_ColorBLACK
Definition: SkColor.h:103
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
#define SkIntToScalar(x)
Definition: SkScalar.h:57
virtual void setupPaint(SkPaint *paint)
Definition: Benchmark.cpp:55
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
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)
const Paint & paint
Definition: color_source.cc:38
PODArray< SkColor > colors
Definition: SkRecords.h:276
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259

◆ onGetName()

const char * Gradient2Bench::onGetName ( )
inlineoverrideprotectedvirtual

Implements Benchmark.

Definition at line 322 of file GradientBench.cpp.

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

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