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

Public Member Functions

 TiledPlaybackBench (BBH bbh, Mode mode)
 
const char * onGetName () override
 
SkISize onGetSize () override
 
void onDelayedSetup () 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 30 of file PicturePlaybackBench.cpp.

Constructor & Destructor Documentation

◆ TiledPlaybackBench()

TiledPlaybackBench::TiledPlaybackBench ( BBH  bbh,
Mode  mode 
)
inline

Definition at line 32 of file PicturePlaybackBench.cpp.

32 : fBBH(bbh), fMode(mode), fName("tiled_playback") {
33 switch (fBBH) {
34 case kNone: fName.append("_none" ); break;
35 case kRTree: fName.append("_rtree" ); break;
36 }
37 switch (fMode) {
38 case kTiled: fName.append("_tiled" ); break;
39 case kRandom: fName.append("_random"); break;
40 }
41 }
void append(const char text[])
Definition: SkString.h:203
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 TiledPlaybackBench::onDelayedSetup ( )
inlineoverridevirtual

Reimplemented from Benchmark.

Definition at line 46 of file PicturePlaybackBench.cpp.

46 {
47 std::unique_ptr<SkBBHFactory> factory;
48 switch (fBBH) {
49 case kNone: break;
50 case kRTree: factory = std::make_unique<SkRTreeFactory>(); break;
51 }
52
53 SkPictureRecorder recorder;
54 SkCanvas* canvas = recorder.beginRecording(1024, 1024, factory.get());
55 SkRandom rand;
56 for (int i = 0; i < 10000; i++) {
57 SkScalar x = rand.nextRangeScalar(0, 1024),
58 y = rand.nextRangeScalar(0, 1024),
59 w = rand.nextRangeScalar(0, 128),
60 h = rand.nextRangeScalar(0, 128);
62 paint.setColor(rand.nextU());
63 paint.setAlpha(0xFF);
64 canvas->drawRect(SkRect::MakeXYWH(x,y,w,h), paint);
65 }
66 fPic = recorder.finishRecordingAsPicture();
67 }
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
SkCanvas * beginRecording(const SkRect &bounds, sk_sp< SkBBoxHierarchy > bbh)
sk_sp< SkPicture > finishRecordingAsPicture()
uint32_t nextU()
Definition: SkRandom.h:42
SkScalar nextRangeScalar(SkScalar min, SkScalar max)
Definition: SkRandom.h:106
const Paint & paint
Definition: color_source.cc:38
float SkScalar
Definition: extension.cpp:12
double y
double x
SkScalar w
SkScalar h
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659

◆ onDraw()

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

Implements Benchmark.

Definition at line 69 of file PicturePlaybackBench.cpp.

69 {
70 for (int i = 0; i < loops; i++) {
71 // This inner loop guarantees we make the same choices for all bench variants.
72 SkRandom rand;
73 for (int j = 0; j < 10; j++) {
74 SkScalar x = 0, y = 0;
75 switch (fMode) {
76 case kTiled: x = SkScalar(256 * rand.nextULessThan(4));
77 y = SkScalar(256 * rand.nextULessThan(4));
78 break;
79 case kRandom: x = rand.nextRangeScalar(0, 768);
80 y = rand.nextRangeScalar(0, 768);
81 break;
82 }
83 SkAutoCanvasRestore ar(canvas, true/*save now*/);
84 canvas->clipRect(SkRect::MakeXYWH(x,y,256,256));
85 fPic->playback(canvas);
86 }
87 }
88 }
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
Definition: SkCanvas.cpp:1361
virtual void playback(SkCanvas *canvas, AbortCallback *callback=nullptr) const =0
uint32_t nextULessThan(uint32_t count)
Definition: SkRandom.h:93

◆ onGetName()

const char * TiledPlaybackBench::onGetName ( )
inlineoverridevirtual

Implements Benchmark.

Definition at line 43 of file PicturePlaybackBench.cpp.

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

◆ onGetSize()

SkISize TiledPlaybackBench::onGetSize ( )
inlineoverridevirtual

Reimplemented from Benchmark.

Definition at line 44 of file PicturePlaybackBench.cpp.

44{ return SkISize::Make(1024,1024); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

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