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

Public Member Functions

 OvalGM ()
 
- 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 makePaints ()
 
void makeMatrices ()
 
SkColor genColor (SkRandom *rand)
 
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 32 of file ovals.cpp.

Constructor & Destructor Documentation

◆ OvalGM()

skiagm::OvalGM::OvalGM ( )
inline

Definition at line 34 of file ovals.cpp.

34 {
35 this->setBGColor(0xFF000000);
36 this->makePaints();
37 this->makeMatrices();
38 }
void setBGColor(SkColor)
Definition: gm.cpp:159
void makePaints()
Definition: ovals.cpp:45
void makeMatrices()
Definition: ovals.cpp:86

Member Function Documentation

◆ genColor()

SkColor skiagm::OvalGM::genColor ( SkRandom rand)
inlineprotected

Definition at line 136 of file ovals.cpp.

136 {
137 SkScalar hsv[3];
138 hsv[0] = rand->nextRangeF(0.0f, 360.0f);
139 hsv[1] = rand->nextRangeF(0.75f, 1.0f);
140 hsv[2] = rand->nextRangeF(0.75f, 1.0f);
141
143 }
SK_API SkColor SkHSVToColor(U8CPU alpha, const SkScalar hsv[3])
Definition: SkColor.cpp:78
float nextRangeF(float min, float max)
Definition: SkRandom.h:64
float SkScalar
Definition: extension.cpp:12
SkColor color_to_565(SkColor color)
Definition: ToolUtils.cpp:139

◆ getISize()

SkISize skiagm::OvalGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 43 of file ovals.cpp.

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

◆ getName()

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

Implements skiagm::GM.

Definition at line 41 of file ovals.cpp.

41{ return SkString("ovals"); }

◆ makeMatrices()

void skiagm::OvalGM::makeMatrices ( )
inlineprotected

Definition at line 86 of file ovals.cpp.

86 {
87 {
88 SkMatrix m;
89 m.setIdentity();
90 fMatrices.push_back(m);
91 }
92
93 {
94 SkMatrix m;
95 m.setScale(SkIntToScalar(3), SkIntToScalar(2));
96 fMatrices.push_back(m);
97 }
98
99 {
100 SkMatrix m;
101 m.setScale(SkIntToScalar(2), SkIntToScalar(2));
102 fMatrices.push_back(m);
103 }
104
105 {
106 SkMatrix m;
107 m.setScale(SkIntToScalar(1), SkIntToScalar(2));
108 fMatrices.push_back(m);
109 }
110
111 {
112 SkMatrix m;
113 m.setScale(SkIntToScalar(4), SkIntToScalar(1));
114 fMatrices.push_back(m);
115 }
116
117 {
118 SkMatrix m;
119 m.setRotate(SkIntToScalar(90));
120 fMatrices.push_back(m);
121 }
122
123 {
124 SkMatrix m;
125 m.setSkew(SkIntToScalar(2), SkIntToScalar(3));
126 fMatrices.push_back(m);
127 }
128
129 {
130 SkMatrix m;
131 m.setRotate(SkIntToScalar(60));
132 fMatrices.push_back(m);
133 }
134 }
#define SkIntToScalar(x)
Definition: SkScalar.h:57

◆ makePaints()

void skiagm::OvalGM::makePaints ( )
inlineprotected

Definition at line 45 of file ovals.cpp.

45 {
46 {
47 // no AA
48 SkPaint p;
49 fPaints.push_back(p);
50 }
51
52 {
53 // AA
54 SkPaint p;
55 p.setAntiAlias(true);
56 fPaints.push_back(p);
57 }
58
59 {
60 // AA with stroke style
61 SkPaint p;
62 p.setAntiAlias(true);
63 p.setStyle(SkPaint::kStroke_Style);
64 p.setStrokeWidth(SkIntToScalar(5));
65 fPaints.push_back(p);
66 }
67
68 {
69 // AA with stroke style, width = 0
70 SkPaint p;
71 p.setAntiAlias(true);
72 p.setStyle(SkPaint::kStroke_Style);
73 fPaints.push_back(p);
74 }
75
76 {
77 // AA with stroke and fill style
78 SkPaint p;
79 p.setAntiAlias(true);
81 p.setStrokeWidth(SkIntToScalar(3));
82 fPaints.push_back(p);
83 }
84 }
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194
@ kStrokeAndFill_Style
sets to stroke and fill geometry
Definition: SkPaint.h:195

◆ onDraw()

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

Reimplemented from skiagm::GM.

Definition at line 145 of file ovals.cpp.

145 {
146 SkRandom rand(1);
147 canvas->translate(20 * SK_Scalar1, 20 * SK_Scalar1);
148 const SkRect kOval = SkRect::MakeLTRB(-20, -30, 20, 30);
149
150 const SkScalar kXStart = 60.0f;
151 const SkScalar kYStart = 80.0f;
152 const int kXStep = 150;
153 const int kYStep = 160;
154 int maxX = fMatrices.size();
155
156 SkPaint rectPaint;
157 rectPaint.setAntiAlias(true);
159 rectPaint.setStrokeWidth(SkIntToScalar(0));
160 rectPaint.setColor(SK_ColorLTGRAY);
161
162 int testCount = 0;
163 for (int i = 0; i < fPaints.size(); ++i) {
164 for (int j = 0; j < fMatrices.size(); ++j) {
165 canvas->save();
166 SkMatrix mat = fMatrices[j];
167 // position the oval, and make it at off-integer coords.
168 mat.postTranslate(kXStart + SK_Scalar1 * kXStep * (testCount % maxX) +
169 SK_Scalar1 / 4,
170 kYStart + SK_Scalar1 * kYStep * (testCount / maxX) +
171 3 * SK_Scalar1 / 4);
172 canvas->concat(mat);
173
174 SkColor color = genColor(&rand);
175 fPaints[i].setColor(color);
176
177 canvas->drawRect(kOval, rectPaint);
178 canvas->drawOval(kOval, fPaints[i]);
179
180 canvas->restore();
181
182 ++testCount;
183 }
184 }
185
186 // special cases
187
188 // non-scaled tall and skinny oval
189 for (int i = 0; i < fPaints.size(); ++i) {
190 SkRect oval = SkRect::MakeLTRB(-20, -60, 20, 60);
191 canvas->save();
192 // position the oval, and make it at off-integer coords.
193 canvas->translate(kXStart + SK_Scalar1 * kXStep * 2.55f + SK_Scalar1 / 4,
194 kYStart + SK_Scalar1 * kYStep * i + 3 * SK_Scalar1 / 4);
195
196 SkColor color = genColor(&rand);
197 fPaints[i].setColor(color);
198
199 canvas->drawRect(oval, rectPaint);
200 canvas->drawOval(oval, fPaints[i]);
201 canvas->restore();
202 }
203
204 // non-scaled wide and short oval
205 for (int i = 0; i < fPaints.size(); ++i) {
206 SkRect oval = SkRect::MakeLTRB(-80, -30, 80, 30);
207 canvas->save();
208 // position the oval, and make it at off-integer coords.
209 canvas->translate(kXStart + SK_Scalar1 * kXStep * 4 + SK_Scalar1 / 4,
210 kYStart + SK_Scalar1 * kYStep * i + 3 * SK_Scalar1 / 4 +
211 SK_ScalarHalf * kYStep);
212
213 SkColor color = genColor(&rand);
214 fPaints[i].setColor(color);
215
216 canvas->drawRect(oval, rectPaint);
217 canvas->drawOval(oval, fPaints[i]);
218 canvas->restore();
219 }
220
221 // super skinny oval
222 for (int i = 0; i < fPaints.size(); ++i) {
223 SkRect oval = SkRect::MakeLTRB(0, -60, 1, 60);
224 canvas->save();
225 // position the oval, and make it at off-integer coords.
226 canvas->translate(kXStart + SK_Scalar1 * kXStep * 3.25f + SK_Scalar1 / 4,
227 kYStart + SK_Scalar1 * kYStep * i + 3 * SK_Scalar1 / 4);
228
229 SkColor color = genColor(&rand);
230 fPaints[i].setColor(color);
231
232 canvas->drawOval(oval, fPaints[i]);
233 canvas->restore();
234 }
235
236 // super short oval
237 for (int i = 0; i < fPaints.size(); ++i) {
238 SkRect oval = SkRect::MakeLTRB(-80, -1, 80, 0);
239 canvas->save();
240 // position the oval, and make it at off-integer coords.
241 canvas->translate(kXStart + SK_Scalar1 * kXStep * 2.5f + SK_Scalar1 / 4,
242 kYStart + SK_Scalar1 * kYStep * i + 3 * SK_Scalar1 / 4 +
243 SK_ScalarHalf * kYStep);
244
245 SkColor color = genColor(&rand);
246 fPaints[i].setColor(color);
247
248 canvas->drawOval(oval, fPaints[i]);
249 canvas->restore();
250 }
251
252 // radial gradient
256 auto shader = SkGradientShader::MakeRadial(center, 20, colors, pos, std::size(colors),
258
259 for (int i = 0; i < fPaints.size(); ++i) {
260 canvas->save();
261 // position the path, and make it at off-integer coords.
262 canvas->translate(kXStart + SK_Scalar1 * kXStep * 0 + SK_Scalar1 / 4,
263 kYStart + SK_Scalar1 * kYStep * i + 3 * SK_Scalar1 / 4 +
264 SK_ScalarHalf * kYStep);
265
266 SkColor color = genColor(&rand);
267 fPaints[i].setColor(color);
268 fPaints[i].setShader(shader);
269
270 canvas->drawRect(kOval, rectPaint);
271 canvas->drawOval(kOval, fPaints[i]);
272
273 fPaints[i].setShader(nullptr);
274
275 canvas->restore();
276 }
277
278 // reflected oval
279 for (int i = 0; i < fPaints.size(); ++i) {
280 SkRect oval = SkRect::MakeLTRB(-30, -30, 30, 30);
281 canvas->save();
282 // position the oval, and make it at off-integer coords.
283 canvas->translate(kXStart + SK_Scalar1 * kXStep * 5 + SK_Scalar1 / 4,
284 kYStart + SK_Scalar1 * kYStep * i + 3 * SK_Scalar1 / 4 +
285 SK_ScalarHalf * kYStep);
286 canvas->rotate(90);
287 canvas->scale(1, -1);
288 canvas->scale(1, 0.66f);
289
290 SkColor color = genColor(&rand);
291 fPaints[i].setColor(color);
292
293 canvas->drawRect(oval, rectPaint);
294 canvas->drawOval(oval, fPaints[i]);
295 canvas->restore();
296 }
297 }
SkPoint pos
static const size_t testCount
constexpr SkColor SK_ColorLTGRAY
Definition: SkColor.h:118
uint32_t SkColor
Definition: SkColor.h:37
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
constexpr SkColor SK_ColorGREEN
Definition: SkColor.h:131
#define SK_Scalar1
Definition: SkScalar.h:18
#define SK_ScalarHalf
Definition: SkScalar.h:19
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void drawOval(const SkRect &oval, const SkPaint &paint)
Definition: SkCanvas.cpp:1698
void restore()
Definition: SkCanvas.cpp:461
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void rotate(SkScalar degrees)
Definition: SkCanvas.cpp:1300
int save()
Definition: SkCanvas.cpp:447
void scale(SkScalar sx, SkScalar sy)
Definition: SkCanvas.cpp:1289
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 & postTranslate(SkScalar dx, SkScalar dy)
Definition: SkMatrix.cpp:281
void setStyle(Style style)
Definition: SkPaint.cpp:105
void setColor(SkColor color)
Definition: SkPaint.cpp:119
void setAntiAlias(bool aa)
Definition: SkPaint.h:170
void setStrokeWidth(SkScalar width)
Definition: SkPaint.cpp:159
int size() const
Definition: SkTArray.h:421
SkColor genColor(SkRandom *rand)
Definition: ovals.cpp:136
DlColor color
SkRect oval
Definition: SkRecords.h:249
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 constexpr SkPoint Make(float x, float y)
Definition: SkPoint_impl.h:173
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
Definition: SkRect.h:646

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