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

Public Member Functions

 PictureNesting (const char *name, int maxLevel, int maxPictureLevel)
 
- 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 doDraw (SkCanvas *canvas)
 
int sierpinsky (SkCanvas *canvas, int lvl, const SkPaint &paint)
 
- 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

int fMaxLevel
 
int fMaxPictureLevel
 

Additional Inherited Members

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

Detailed Description

Definition at line 17 of file PictureNestingBench.cpp.

Constructor & Destructor Documentation

◆ PictureNesting()

PictureNesting::PictureNesting ( const char *  name,
int  maxLevel,
int  maxPictureLevel 
)
inline

Definition at line 19 of file PictureNestingBench.cpp.

20 : fMaxLevel(maxLevel)
21 , fMaxPictureLevel(maxPictureLevel) {
22 fName.printf("picture_nesting_%s_%d", name, this->countPics());
23 fPaint.setColor(SK_ColorRED);
24 fPaint.setAntiAlias(true);
26 }
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
void setStyle(Style style)
Definition: SkPaint.cpp:105
void setColor(SkColor color)
Definition: SkPaint.cpp:119
void setAntiAlias(bool aa)
Definition: SkPaint.h:170
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194
void printf(const char format[],...) SK_PRINTF_LIKE(2
Definition: SkString.cpp:534
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32

Member Function Documentation

◆ doDraw()

void PictureNesting::doDraw ( SkCanvas canvas)
inlineprotected

Definition at line 33 of file PictureNestingBench.cpp.

33 {
34 SkISize canvasSize = onGetSize();
35 canvas->save();
36 canvas->scale(SkIntToScalar(canvasSize.width()), SkIntToScalar(canvasSize.height()));
37
38 SkDEBUGCODE(int pics = ) this->sierpinsky(canvas, 0, fPaint);
39 SkASSERT(pics == this->countPics());
40
41 canvas->restore();
42 }
#define SkASSERT(cond)
Definition: SkAssert.h:116
#define SkIntToScalar(x)
Definition: SkScalar.h:57
SkDEBUGCODE(SK_SPI) SkThreadID SkGetThreadID()
virtual SkISize onGetSize()
Definition: Benchmark.cpp:59
int sierpinsky(SkCanvas *canvas, int lvl, const SkPaint &paint)
int save()
Definition: SkCanvas.cpp:447
void scale(SkScalar sx, SkScalar sy)
Definition: SkCanvas.cpp:1289
Definition: SkSize.h:16
constexpr int32_t width() const
Definition: SkSize.h:36
constexpr int32_t height() const
Definition: SkSize.h:37

◆ onGetName()

const char * PictureNesting::onGetName ( )
inlineoverrideprotectedvirtual

Implements Benchmark.

Definition at line 29 of file PictureNestingBench.cpp.

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

◆ sierpinsky()

int PictureNesting::sierpinsky ( SkCanvas canvas,
int  lvl,
const SkPaint paint 
)
inlineprotected

Definition at line 44 of file PictureNestingBench.cpp.

44 {
45 if (++lvl > fMaxLevel) {
46 return 0;
47 }
48
49 int pics = 0;
50 bool recordPicture = lvl <= fMaxPictureLevel;
51 SkPictureRecorder recorder;
52 SkCanvas* c = canvas;
53
54 if (recordPicture) {
55 c = recorder.beginRecording(1, 1);
56 pics++;
57 }
58
59 c->drawLine(0.5, 0, 0, 1, paint);
60 c->drawLine(0.5, 0, 1, 1, paint);
61 c->drawLine(0, 1, 1, 1, paint);
62
63 c->save();
64 c->scale(0.5, 0.5);
65
66 c->translate(0, 1);
67 pics += this->sierpinsky(c, lvl, paint);
68
69 c->translate(1, 0);
70 pics += this->sierpinsky(c, lvl, paint);
71
72 c->translate(-0.5, -1);
73 pics += this->sierpinsky(c, lvl, paint);
74 c->restore();
75
76 if (recordPicture) {
77 canvas->drawPicture(recorder.finishRecordingAsPicture());
78 }
79
80 return pics;
81 }
void restore()
Definition: SkCanvas.cpp:461
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, const SkPaint &paint)
Definition: SkCanvas.cpp:2700
void drawPicture(const SkPicture *picture)
Definition: SkCanvas.h:1961
SkCanvas * beginRecording(const SkRect &bounds, sk_sp< SkBBoxHierarchy > bbh)
sk_sp< SkPicture > finishRecordingAsPicture()
const Paint & paint
Definition: color_source.cc:38

Member Data Documentation

◆ fMaxLevel

int PictureNesting::fMaxLevel
protected

Definition at line 83 of file PictureNestingBench.cpp.

◆ fMaxPictureLevel

int PictureNesting::fMaxPictureLevel
protected

Definition at line 84 of file PictureNestingBench.cpp.


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