Flutter Engine
The Flutter Engine
Public Member Functions | Protected Member Functions | List of all members
skiagm::FillTypePerspGM Class Reference
Inheritance diagram for skiagm::FillTypePerspGM:
skiagm::GM

Public Member Functions

 FillTypePerspGM ()
 
void makePath ()
 
- Public Member Functions inherited from skiagm::GM
 GM (SkColor backgroundColor=SK_ColorWHITE)
 
virtual ~GM ()
 
void setMode (Mode mode)
 
Mode getMode () const
 
DrawResult gpuSetup (SkCanvas *, SkString *errorMsg, GraphiteTestContext *=nullptr)
 
void gpuTeardown ()
 
void onceBeforeDraw ()
 
DrawResult draw (SkCanvas *canvas)
 
DrawResult draw (SkCanvas *, SkString *errorMsg)
 
void drawBackground (SkCanvas *)
 
DrawResult drawContent (SkCanvas *canvas)
 
DrawResult drawContent (SkCanvas *, SkString *errorMsg)
 
virtual SkISize getISize ()=0
 
virtual SkString getName () const =0
 
virtual bool runAsBench () const
 
SkScalar width ()
 
SkScalar height ()
 
SkColor getBGColor () const
 
void setBGColor (SkColor)
 
void drawSizeBounds (SkCanvas *, SkColor)
 
bool animate (double)
 
virtual bool onChar (SkUnichar)
 
bool getControls (SkMetaData *controls)
 
void setControls (const SkMetaData &controls)
 
virtual void modifyGrContextOptions (GrContextOptions *)
 
virtual void modifyGraphiteContextOptions (skgpu::graphite::ContextOptions *) const
 
virtual bool isBazelOnly () const
 
virtual std::map< std::string, std::string > getGoldKeys () const
 

Protected Member Functions

SkString getName () const override
 
SkISize getISize () override
 
void showPath (SkCanvas *canvas, int x, int y, SkPathFillType ft, SkScalar scale, const SkPaint &paint)
 
void showFour (SkCanvas *canvas, SkScalar scale, bool aa)
 
void onDraw (SkCanvas *canvas) override
 
- Protected Member Functions inherited from skiagm::GM
virtual DrawResult onGpuSetup (SkCanvas *, SkString *, GraphiteTestContext *)
 
virtual void onGpuTeardown ()
 
virtual void onOnceBeforeDraw ()
 
virtual DrawResult onDraw (SkCanvas *, SkString *errorMsg)
 
virtual void onDraw (SkCanvas *)
 
virtual bool onAnimate (double)
 
virtual bool onGetControls (SkMetaData *)
 
virtual void onSetControls (const SkMetaData &)
 
GraphiteTestContextgraphiteTestContext () const
 

Additional Inherited Members

- Public Types inherited from skiagm::GM
enum  Mode { kGM_Mode , kSample_Mode , kBench_Mode }
 
using DrawResult = skiagm::DrawResult
 
using GraphiteTestContext = skiatest::graphite::GraphiteTestContext
 
- Static Public Attributes inherited from skiagm::GM
static constexpr char kErrorMsg_DrawSkippedGpuOnly []
 

Detailed Description

Definition at line 26 of file filltypespersp.cpp.

Constructor & Destructor Documentation

◆ FillTypePerspGM()

skiagm::FillTypePerspGM::FillTypePerspGM ( )
inline

Definition at line 29 of file filltypespersp.cpp.

29{}

Member Function Documentation

◆ getISize()

SkISize skiagm::FillTypePerspGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 43 of file filltypespersp.cpp.

43{ return SkISize::Make(835, 840); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

SkString skiagm::FillTypePerspGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 41 of file filltypespersp.cpp.

41{ return SkString("filltypespersp"); }

◆ makePath()

void skiagm::FillTypePerspGM::makePath ( )
inline

Definition at line 31 of file filltypespersp.cpp.

31 {
32 if (fPath.isEmpty()) {
33 const SkScalar radius = SkIntToScalar(45);
34 fPath = SkPathBuilder().addCircle(SkIntToScalar(50), SkIntToScalar(50), radius)
35 .addCircle(SkIntToScalar(100), SkIntToScalar(100), radius)
36 .detach();
37 }
38 }
#define SkIntToScalar(x)
Definition: SkScalar.h:57
SkPathBuilder & addCircle(SkScalar center_x, SkScalar center_y, SkScalar radius, SkPathDirection dir=SkPathDirection::kCW)
bool isEmpty() const
Definition: SkPath.cpp:416
float SkScalar
Definition: extension.cpp:12

◆ onDraw()

void skiagm::FillTypePerspGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 84 of file filltypespersp.cpp.

84 {
85 this->makePath();
86
87 // do perspective drawPaint as the background;
88 SkPaint bkgnrd;
90 SkIntToScalar(100));
93 SkScalar pos[] = {0, SK_ScalarHalf / 2,
94 3 * SK_ScalarHalf / 2, SK_Scalar1};
96 SkIntToScalar(1000),
97 colors,
98 pos,
101 canvas->save();
102 canvas->translate(SkIntToScalar(100), SkIntToScalar(100));
103 SkMatrix mat;
104 mat.reset();
105 mat.setPerspY(SK_Scalar1 / 1000);
106 canvas->concat(mat);
107 canvas->drawPaint(bkgnrd);
108 canvas->restore();
109
110 // draw the paths in perspective
111 SkMatrix persp;
112 persp.reset();
113 persp.setPerspX(-SK_Scalar1 / 1800);
114 persp.setPerspY(SK_Scalar1 / 500);
115 canvas->concat(persp);
116
117 canvas->translate(SkIntToScalar(20), SkIntToScalar(20));
118 const SkScalar scale = SkIntToScalar(5)/4;
119
120 showFour(canvas, SK_Scalar1, false);
121 canvas->translate(SkIntToScalar(450), 0);
122 showFour(canvas, scale, false);
123
124 canvas->translate(SkIntToScalar(-450), SkIntToScalar(450));
125 showFour(canvas, SK_Scalar1, true);
126 canvas->translate(SkIntToScalar(450), 0);
127 showFour(canvas, scale, true);
128 }
SkPoint pos
constexpr SkColor SK_ColorYELLOW
Definition: SkColor.h:139
uint32_t SkColor
Definition: SkColor.h:37
constexpr SkColor SK_ColorCYAN
Definition: SkColor.h:143
constexpr SkColor SK_ColorBLACK
Definition: SkColor.h:103
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
#define SK_Scalar1
Definition: SkScalar.h:18
#define SK_ScalarHalf
Definition: SkScalar.h:19
void restore()
Definition: SkCanvas.cpp:461
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void drawPaint(const SkPaint &paint)
Definition: SkCanvas.cpp:1668
int save()
Definition: SkCanvas.cpp:447
void concat(const SkMatrix &matrix)
Definition: SkCanvas.cpp:1318
static sk_sp< SkShader > MakeRadial(const SkPoint &center, SkScalar radius, const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, uint32_t flags=0, const SkMatrix *localMatrix=nullptr)
SkMatrix & setPerspX(SkScalar v)
Definition: SkMatrix.h:537
SkMatrix & setPerspY(SkScalar v)
Definition: SkMatrix.h:544
SkMatrix & reset()
Definition: SkMatrix.cpp:49
void setShader(sk_sp< SkShader > shader)
void showFour(SkCanvas *canvas, SkScalar scale, bool aa)
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
static SkPath scale(const SkPath &path, SkScalar scale)
Definition: patheffects.cpp:68
static constexpr SkPoint Make(float x, float y)
Definition: SkPoint_impl.h:173

◆ showFour()

void skiagm::FillTypePerspGM::showFour ( SkCanvas canvas,
SkScalar  scale,
bool  aa 
)
inlineprotected

Definition at line 61 of file filltypespersp.cpp.

61 {
66 paint.setShader(SkGradientShader::MakeRadial(center,
67 SkIntToScalar(100),
68 colors,
69 pos,
72 paint.setAntiAlias(aa);
73
75 scale, paint);
76 showPath(canvas, 200, 0, SkPathFillType::kEvenOdd,
77 scale, paint);
79 scale, paint);
81 scale, paint);
82 }
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
constexpr SkColor SK_ColorGREEN
Definition: SkColor.h:131
void showPath(SkCanvas *canvas, int x, int y, SkPathFillType ft, SkScalar scale, const SkPaint &paint)
const Paint & paint
Definition: color_source.cc:38

◆ showPath()

void skiagm::FillTypePerspGM::showPath ( SkCanvas canvas,
int  x,
int  y,
SkPathFillType  ft,
SkScalar  scale,
const SkPaint paint 
)
inlineprotected

Definition at line 45 of file filltypespersp.cpp.

46 {
47 const SkRect r = { 0, 0, SkIntToScalar(150), SkIntToScalar(150) };
48
49 canvas->save();
51 canvas->clipRect(r);
52 canvas->drawColor(SK_ColorWHITE);
53 fPath.setFillType(ft);
54 canvas->translate(r.centerX(), r.centerY());
55 canvas->scale(scale, scale);
56 canvas->translate(-r.centerX(), -r.centerY());
57 canvas->drawPath(fPath, paint);
58 canvas->restore();
59 }
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
Definition: SkCanvas.cpp:1361
void drawColor(SkColor color, SkBlendMode mode=SkBlendMode::kSrcOver)
Definition: SkCanvas.h:1182
void drawPath(const SkPath &path, const SkPaint &paint)
Definition: SkCanvas.cpp:1747
void scale(SkScalar sx, SkScalar sy)
Definition: SkCanvas.cpp:1289
void setFillType(SkPathFillType ft)
Definition: SkPath.h:235
double y
double x
constexpr float centerX() const
Definition: SkRect.h:776
constexpr float centerY() const
Definition: SkRect.h:785

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