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

Public Member Functions

 QuadPathGM ()
 
- 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 drawPath (SkPath &path, SkCanvas *canvas, SkColor color, const SkRect &clip, SkPaint::Cap cap, SkPaint::Join join, SkPaint::Style style, SkPathFillType fill, SkScalar strokeWidth)
 
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 quadpaths.cpp.

Constructor & Destructor Documentation

◆ QuadPathGM()

skiagm::QuadPathGM::QuadPathGM ( )
inline

Definition at line 28 of file quadpaths.cpp.

28{}

Member Function Documentation

◆ drawPath()

void skiagm::QuadPathGM::drawPath ( SkPath path,
SkCanvas canvas,
SkColor  color,
const SkRect clip,
SkPaint::Cap  cap,
SkPaint::Join  join,
SkPaint::Style  style,
SkPathFillType  fill,
SkScalar  strokeWidth 
)
inlineprotected

Definition at line 35 of file quadpaths.cpp.

38 {
39 path.setFillType(fill);
41 paint.setStrokeCap(cap);
42 paint.setStrokeWidth(strokeWidth);
43 paint.setStrokeJoin(join);
44 paint.setColor(color);
45 paint.setStyle(style);
46 canvas->save();
47 canvas->clipRect(clip);
48 canvas->drawPath(path, paint);
49 canvas->restore();
50 }
static const int strokeWidth
Definition: BlurTest.cpp:60
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition: SkPath.cpp:3892
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
Definition: SkCanvas.cpp:1361
void restore()
Definition: SkCanvas.cpp:461
int save()
Definition: SkCanvas.cpp:447
void drawPath(const SkPath &path, const SkPaint &paint)
Definition: SkCanvas.cpp:1747
const Paint & paint
Definition: color_source.cc:38
DlColor color
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57
static SkString join(const CommandLineFlags::StringArray &)
Definition: skpbench.cpp:741

◆ getISize()

SkISize skiagm::QuadPathGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 33 of file quadpaths.cpp.

33{ return SkISize::Make(1240, 390); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

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

Implements skiagm::GM.

Definition at line 31 of file quadpaths.cpp.

31{ return SkString("quadpath"); }

◆ onDraw()

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

Reimplemented from skiagm::GM.

Definition at line 52 of file quadpaths.cpp.

52 {
53 struct FillAndName {
54 SkPathFillType fFill;
55 const char* fName;
56 };
57 constexpr FillAndName gFills[] = {
58 {SkPathFillType::kWinding, "Winding"},
59 {SkPathFillType::kEvenOdd, "Even / Odd"},
60 {SkPathFillType::kInverseWinding, "Inverse Winding"},
61 {SkPathFillType::kInverseEvenOdd, "Inverse Even / Odd"},
62 };
63 struct StyleAndName {
65 const char* fName;
66 };
67 constexpr StyleAndName gStyles[] = {
68 {SkPaint::kFill_Style, "Fill"},
69 {SkPaint::kStroke_Style, "Stroke"},
70 {SkPaint::kStrokeAndFill_Style, "Stroke And Fill"},
71 };
72 struct CapAndName {
73 SkPaint::Cap fCap;
75 const char* fName;
76 };
77 constexpr CapAndName gCaps[] = {
81 };
82 struct PathAndName {
84 const char* fName;
85 };
86 PathAndName path;
87 path.fPath.moveTo(25*SK_Scalar1, 10*SK_Scalar1);
88 path.fPath.quadTo(50*SK_Scalar1, 20*SK_Scalar1,
89 75*SK_Scalar1, 10*SK_Scalar1);
90 path.fName = "moveTo-quad";
91
92 SkPaint titlePaint;
95
96 const char title[] = "Quad Drawn Into Rectangle Clips With "
97 "Indicated Style, Fill and Linecaps, with stroke width 10";
98 canvas->drawString(title, 20.0f, 20.0f, font, titlePaint);
99
100 SkRandom rand;
102 canvas->save();
103 canvas->translate(10 * SK_Scalar1, 30 * SK_Scalar1);
104 canvas->save();
105 for (size_t cap = 0; cap < std::size(gCaps); ++cap) {
106 if (0 < cap) {
107 canvas->translate((rect.width() + 40 * SK_Scalar1) * std::size(gStyles), 0);
108 }
109 canvas->save();
110 for (size_t fill = 0; fill < std::size(gFills); ++fill) {
111 if (0 < fill) {
112 canvas->translate(0, rect.height() + 40 * SK_Scalar1);
113 }
114 canvas->save();
115 for (size_t style = 0; style < std::size(gStyles); ++style) {
116 if (0 < style) {
117 canvas->translate(rect.width() + 40 * SK_Scalar1, 0);
118 }
119
121 this->drawPath(path.fPath, canvas, color, rect,
122 gCaps[cap].fCap, gCaps[cap].fJoin, gStyles[style].fStyle,
123 gFills[fill].fFill, SK_Scalar1*10);
124
125 SkPaint rectPaint;
126 rectPaint.setColor(SK_ColorBLACK);
128 rectPaint.setStrokeWidth(-1);
129 rectPaint.setAntiAlias(true);
130 canvas->drawRect(rect, rectPaint);
131
132 SkPaint labelPaint;
133 labelPaint.setColor(color);
134 canvas->drawString(gStyles[style].fName, 0, rect.height() + 12.0f,
135 labelFont, labelPaint);
136 canvas->drawString(gFills[fill].fName, 0, rect.height() + 24.0f,
137 labelFont, labelPaint);
138 canvas->drawString(gCaps[cap].fName, 0, rect.height() + 36.0f,
139 labelFont, labelPaint);
140 }
141 canvas->restore();
142 }
143 canvas->restore();
144 }
145 canvas->restore();
146 canvas->restore();
147 }
SkPath fPath
SkPaint::Join fJoin
SkStrokeRec::Style fStyle
uint32_t SkColor
Definition: SkColor.h:37
constexpr SkColor SK_ColorBLACK
Definition: SkColor.h:103
SkPathFillType
Definition: SkPathTypes.h:11
#define SK_Scalar1
Definition: SkScalar.h:18
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void drawString(const char str[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
Definition: SkCanvas.h:1803
Definition: SkFont.h:35
@ kRound_Cap
adds circle
Definition: SkPaint.h:335
@ kButt_Cap
no stroke extension
Definition: SkPaint.h:334
@ kSquare_Cap
adds square
Definition: SkPaint.h:336
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
@ kFill_Style
set to fill geometry
Definition: SkPaint.h:193
@ kStrokeAndFill_Style
sets to stroke and fill geometry
Definition: SkPaint.h:195
@ kRound_Join
adds circle
Definition: SkPaint.h:360
@ kBevel_Join
connects outside edges
Definition: SkPaint.h:361
void setStrokeWidth(SkScalar width)
Definition: SkPaint.cpp:159
Definition: SkPath.h:59
void drawPath(SkPath &path, SkCanvas *canvas, SkColor color, const SkRect &clip, SkPaint::Cap cap, SkPaint::Join join, SkPaint::Style style, SkPathFillType fill, SkScalar strokeWidth)
Definition: quadpaths.cpp:35
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
sk_sp< SkTypeface > DefaultPortableTypeface()
SkColor color_to_565(SkColor color)
Definition: ToolUtils.cpp:139
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.
const char * fName
static constexpr SkRect MakeWH(float w, float h)
Definition: SkRect.h:609
static constexpr SkFontStyle gStyles[]
Definition: typeface.cpp:89

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