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

Public Member Functions

 ShadowBench (bool transparent, bool forceGeometric)
 
- 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 Types

enum  {
  kWidth = 640 , kHeight = 480 , kRRSize = 50 , kRRRadius = 6 ,
  kRRSpace = 8 , kRRStep = kRRSize + kRRSpace , kElevation = 16 , kNumRRects = ((kWidth - kRRSpace) / kRRStep)*((kHeight - kRRSpace) / kRRStep)
}
 

Protected Member Functions

void computeName (const char root[])
 
void genRRects ()
 
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 15 of file ShadowBench.cpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
protected
Enumerator
kWidth 
kHeight 
kRRSize 
kRRRadius 
kRRSpace 
kRRStep 
kElevation 
kNumRRects 

Definition at line 27 of file ShadowBench.cpp.

27 {
28 kWidth = 640,
29 kHeight = 480,
30 kRRSize = 50,
31 kRRRadius = 6,
32 kRRSpace = 8,
34 kElevation = 16,
36 };

Constructor & Destructor Documentation

◆ ShadowBench()

ShadowBench::ShadowBench ( bool  transparent,
bool  forceGeometric 
)
inline

Definition at line 20 of file ShadowBench.cpp.

21 : fTransparent(transparent)
22 , fForceGeometric(forceGeometric) {
23 computeName("shadows");
24 }
void computeName(const char root[])
Definition: ShadowBench.cpp:38

Member Function Documentation

◆ computeName()

void ShadowBench::computeName ( const char  root[])
inlineprotected

Definition at line 38 of file ShadowBench.cpp.

38 {
39 static const char kTransChars[2] = {
40 'o', 't'
41 };
42 static const char kGeomChars[2] = {
43 'a', 'g'
44 };
45
46 fBaseName.printf("%s_%c_%c", root, kTransChars[fTransparent], kGeomChars[fForceGeometric]);
47 }
void printf(const char format[],...) SK_PRINTF_LIKE(2
Definition: SkString.cpp:534
string root
Definition: scale_cpu.py:20

◆ genRRects()

void ShadowBench::genRRects ( )
inlineprotected

Definition at line 49 of file ShadowBench.cpp.

49 {
50 int i = 0;
51 for (int x = kRRSpace; x < kWidth - kRRStep; x += kRRStep) {
52 for (int y = kRRSpace; y < kHeight - kRRStep; y += kRRStep) {
55 ++i;
56 }
57 }
59 }
#define SkASSERT(cond)
Definition: SkAssert.h:116
SkPath & addRRect(const SkRRect &rrect, SkPathDirection dir=SkPathDirection::kCW)
Definition: SkPath.cpp:1000
static SkRRect MakeRectXY(const SkRect &rect, SkScalar xRad, SkScalar yRad)
Definition: SkRRect.h:180
double y
double x
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659

◆ onDelayedSetup()

void ShadowBench::onDelayedSetup ( )
inlineoverrideprotectedvirtual

Reimplemented from Benchmark.

Definition at line 63 of file ShadowBench.cpp.

63 {
65 fRec.fLightPos = SkPoint3::Make(270, 0, 600);
66 fRec.fLightRadius = 800;
67 fRec.fAmbientColor = 0x19000000;
68 fRec.fSpotColor = 0x40000000;
69 fRec.fFlags = 0;
70 if (fTransparent) {
72 }
73 if (fForceGeometric) {
75 }
76
77 this->genRRects();
78 }
@ kGeometricOnly_ShadowFlag
Definition: SkShadowUtils.h:29
@ kTransparentOccluder_ShadowFlag
Definition: SkShadowUtils.h:27
void genRRects()
Definition: ShadowBench.cpp:49
SkPoint3 fZPlaneParams
static SkPoint3 Make(SkScalar x, SkScalar y, SkScalar z)
Definition: SkPoint3.h:18

◆ onDraw()

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

Implements Benchmark.

Definition at line 80 of file ShadowBench.cpp.

80 {
82 paint.setColor(SK_ColorWHITE);
83 this->setupPaint(&paint);
84
85 for (int i = 0; i < loops; ++i) {
86 // use the private canvas call so we don't include the time to stuff data in the Rec
87 canvas->private_draw_shadow_rec(fRRects[i % kNumRRects], fRec);
88 }
89 }
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
virtual void setupPaint(SkPaint *paint)
Definition: Benchmark.cpp:55
void private_draw_shadow_rec(const SkPath &, const SkDrawShadowRec &)
Definition: SkCanvas.cpp:1831
const Paint & paint
Definition: color_source.cc:38

◆ onGetName()

const char * ShadowBench::onGetName ( )
inlineoverrideprotectedvirtual

Implements Benchmark.

Definition at line 61 of file ShadowBench.cpp.

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

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