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

Public Member Functions

 XfermodeBench (SkBlendMode mode, Type t)
 
- 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 onDelayedSetup () 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 33 of file BlendmodeBench.cpp.

Constructor & Destructor Documentation

◆ XfermodeBench()

XfermodeBench::XfermodeBench ( SkBlendMode  mode,
Type  t 
)
inline

Definition at line 35 of file BlendmodeBench.cpp.

35 : fBlendMode(mode) {
36 fType = t;
37 fName.printf("blendmicro_%s_%s", gTypeNames[t], SkBlendMode_Name(mode));
38 }
const char * gTypeNames[]
SK_API const char * SkBlendMode_Name(SkBlendMode blendMode)
void printf(const char format[],...) SK_PRINTF_LIKE(2
Definition: SkString.cpp:534
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 mode
Definition: switches.h:228

Member Function Documentation

◆ onDelayedSetup()

void XfermodeBench::onDelayedSetup ( )
inlineoverrideprotectedvirtual

Reimplemented from Benchmark.

Definition at line 43 of file BlendmodeBench.cpp.

43 {
44 if (fType == kSprite) {
45 fImage = ToolUtils::GetResourceAsImage("images/color_wheel.png");
46 }
47 }
sk_sp< SkImage > GetResourceAsImage(const char *resource)
Definition: DecodeUtils.h:25

◆ onDraw()

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

Implements Benchmark.

Definition at line 49 of file BlendmodeBench.cpp.

49 {
50 const char* text = "Hamburgefons";
51 size_t len = strlen(text);
52 SkISize size = canvas->getBaseLayerSize();
53 SkRandom random;
54 while (loops > 0) {
56 paint.setBlendMode(fBlendMode);
57 paint.setColor(random.nextU());
58 switch (fType) {
59 case kText: {
60 // Draw text to exercise AA code paths.
62 font.setSize(random.nextRangeScalar(12, 96));
63 SkScalar x = random.nextRangeScalar(0, (SkScalar)size.fWidth),
64 y = random.nextRangeScalar(0, (SkScalar)size.fHeight);
66 int iterations = std::min(1000, loops);
67 for (int j = 0; j < iterations; ++j) {
68 canvas->drawTextBlob(blob, x, y, paint);
69 }
70 loops -= iterations;
71 } break;
72 case kRect: {
73 // Draw rects to exercise non-AA code paths.
74 SkScalar w = random.nextRangeScalar(50, 100);
75 SkScalar h = random.nextRangeScalar(50, 100);
77 random.nextUScalar1() * (size.fWidth - w),
78 random.nextUScalar1() * (size.fHeight - h),
79 w,
80 h
81 );
82 int iterations = std::min(1000, loops);
83 for (int j = 0; j < iterations; ++j) {
84 canvas->drawRect(rect, paint);
85 }
86 loops -= iterations;
87 } break;
88 case kSprite:
89 paint.setAlphaf(1.0f);
90 for (int i = 0; i < 10; ++i) {
91 canvas->drawImage(fImage, 0, 0, SkSamplingOptions(), &paint);
92 }
93 loops -= 1;
94 break;
95 }
96 }
97 }
@ kUTF8
uses bytes to represent UTF-8 or ASCII
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
virtual SkISize getBaseLayerSize() const
Definition: SkCanvas.cpp:369
void drawTextBlob(const SkTextBlob *blob, SkScalar x, SkScalar y, const SkPaint &paint)
Definition: SkCanvas.cpp:2484
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
Definition: SkFont.h:35
uint32_t nextU()
Definition: SkRandom.h:42
SkScalar nextUScalar1()
Definition: SkRandom.h:101
SkScalar nextRangeScalar(SkScalar min, SkScalar max)
Definition: SkRandom.h:106
static sk_sp< SkTextBlob > MakeFromText(const void *text, size_t byteLength, const SkFont &font, SkTextEncoding encoding=SkTextEncoding::kUTF8)
Definition: SkTextBlob.cpp:788
const Paint & paint
Definition: color_source.cc:38
float SkScalar
Definition: extension.cpp:12
static float min(float r, float g, float b)
Definition: hsl.cpp:48
std::u16string text
double y
double x
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
SkFont DefaultFont()
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
font
Font Metadata and Metrics.
SkSamplingOptions(SkFilterMode::kLinear))
SkScalar w
SkScalar h
Definition: SkSize.h:16
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659

◆ onGetName()

const char * XfermodeBench::onGetName ( )
inlineoverrideprotectedvirtual

Implements Benchmark.

Definition at line 41 of file BlendmodeBench.cpp.

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

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