Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Private Member Functions | List of all members
skiagm::DegenerateSegmentsGM Class Reference
Inheritance diagram for skiagm::DegenerateSegmentsGM:
skiagm::GM

Private Member Functions

SkString getName () const override
 
SkISize getISize () override
 
void onDraw (SkCanvas *canvas) override
 

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
 
- 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 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
 
- Static Public Attributes inherited from skiagm::GM
static constexpr char kErrorMsg_DrawSkippedGpuOnly []
 
- 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 bool onAnimate (double)
 
virtual bool onGetControls (SkMetaData *)
 
virtual void onSetControls (const SkMetaData &)
 
GraphiteTestContextgraphiteTestContext () const
 

Detailed Description

Definition at line 27 of file degeneratesegments.cpp.

Member Function Documentation

◆ getISize()

SkISize skiagm::DegenerateSegmentsGM::getISize ( )
inlineoverrideprivatevirtual

Implements skiagm::GM.

Definition at line 36 of file degeneratesegments.cpp.

36{ return {896, 930}; }

◆ getName()

SkString skiagm::DegenerateSegmentsGM::getName ( ) const
inlineoverrideprivatevirtual

Implements skiagm::GM.

Definition at line 34 of file degeneratesegments.cpp.

34{ return SkString("degeneratesegments"); }

◆ onDraw()

void skiagm::DegenerateSegmentsGM::onDraw ( SkCanvas canvas)
inlineoverrideprivatevirtual

Reimplemented from skiagm::GM.

Definition at line 216 of file degeneratesegments.cpp.

216 {
217 constexpr AddSegmentFunc gSegmentFunctions[] = {
218 AddMove,
219 AddMoveClose,
220 AddDegenLine,
221 AddMoveDegenLine,
222 AddMoveDegenLineClose,
223 AddDegenQuad,
224 AddMoveDegenQuad,
225 AddMoveDegenQuadClose,
226 AddDegenCubic,
227 AddMoveDegenCubic,
228 AddMoveDegenCubicClose,
229 AddClose,
230 AddLine,
231 AddMoveLine,
232 AddMoveLineClose,
233 AddQuad,
234 AddMoveQuad,
235 AddMoveQuadClose,
236 AddCubic,
237 AddMoveCubic,
238 AddMoveCubicClose
239 };
240 const char* gSegmentNames[] = {
241 "Move",
242 "MoveClose",
243 "DegenLine",
244 "MoveDegenLine",
245 "MoveDegenLineClose",
246 "DegenQuad",
247 "MoveDegenQuad",
248 "MoveDegenQuadClose",
249 "DegenCubic",
250 "MoveDegenCubic",
251 "MoveDegenCubicClose",
252 "Close",
253 "Line",
254 "MoveLine",
255 "MoveLineClose",
256 "Quad",
257 "MoveQuad",
258 "MoveQuadClose",
259 "Cubic",
260 "MoveCubic",
261 "MoveCubicClose"
262 };
263
264 struct FillAndName {
265 SkPathFillType fFill;
266 const char* fName;
267 };
268 constexpr FillAndName gFills[] = {
269 {SkPathFillType::kWinding, "Winding"},
270 {SkPathFillType::kEvenOdd, "Even / Odd"},
271 {SkPathFillType::kInverseWinding, "Inverse Winding"},
272 {SkPathFillType::kInverseEvenOdd, "Inverse Even / Odd"}
273 };
274 struct StyleAndName {
276 const char* fName;
277 };
278 constexpr StyleAndName gStyles[] = {
279 {SkPaint::kFill_Style, "Fill"},
280 {SkPaint::kStroke_Style, "Stroke 10"},
281 {SkPaint::kStrokeAndFill_Style, "Stroke 10 And Fill"}
282 };
283 struct CapAndName {
284 SkPaint::Cap fCap;
286 const char* fName;
287 };
288 constexpr CapAndName gCaps[] = {
292 };
293
294 SkPaint titlePaint;
295 titlePaint.setColor(SK_ColorBLACK);
296 titlePaint.setAntiAlias(true);
298 const char title[] = "Random Paths Drawn Into Rectangle Clips With "
299 "Indicated Style, Fill and Linecaps, "
300 "with Stroke width 6";
301 canvas->drawString(title, 20, 20, font, titlePaint);
302
303 SkRandom rand;
305 canvas->save();
306 canvas->translate(2*SK_Scalar1, 30 * SK_Scalar1); // The title
307 canvas->save();
308 unsigned numSegments = std::size(gSegmentFunctions);
309 unsigned numCaps = std::size(gCaps);
310 unsigned numStyles = std::size(gStyles);
311 unsigned numFills = std::size(gFills);
312 for (size_t row = 0; row < 6; ++row) {
313 if (0 < row) {
314 canvas->translate(0, rect.height() + 100*SK_Scalar1);
315 }
316 canvas->save();
317 for (size_t column = 0; column < 4; ++column) {
318 if (0 < column) {
319 canvas->translate(rect.width() + 4*SK_Scalar1, 0);
320 }
321
323 StyleAndName style = gStyles[(rand.nextU() >> 16) % numStyles];
324 CapAndName cap = gCaps[(rand.nextU() >> 16) % numCaps];
325 FillAndName fill = gFills[(rand.nextU() >> 16) % numFills];
326 unsigned s1 = (rand.nextU() >> 16) % numSegments;
327 unsigned s2 = (rand.nextU() >> 16) % numSegments;
328 unsigned s3 = (rand.nextU() >> 16) % numSegments;
329 unsigned s4 = (rand.nextU() >> 16) % numSegments;
330 unsigned s5 = (rand.nextU() >> 16) % numSegments;
331 SkPoint pt = SkPoint::Make(10*SK_Scalar1, 0);
333 pt = gSegmentFunctions[s1](path, pt);
334 pt = gSegmentFunctions[s2](path, pt);
335 pt = gSegmentFunctions[s3](path, pt);
336 pt = gSegmentFunctions[s4](path, pt);
337 pt = gSegmentFunctions[s5](path, pt);
338
339 this->drawPath(path.detach(), canvas, color, rect,
340 cap.fCap, cap.fJoin, style.fStyle,
341 fill.fFill, SK_Scalar1*6);
342
343 SkPaint rectPaint;
344 rectPaint.setColor(SK_ColorBLACK);
346 rectPaint.setStrokeWidth(-1);
347 rectPaint.setAntiAlias(true);
348 canvas->drawRect(rect, rectPaint);
349
350 SkPaint labelPaint;
351 labelPaint.setColor(color);
352 labelPaint.setAntiAlias(true);
353 font.setSize(10);
354 canvas->drawString(style.fName, 0, rect.height() + 12, font, labelPaint);
355 canvas->drawString(fill.fName, 0, rect.height() + 24, font, labelPaint);
356 canvas->drawString(cap.fName, 0, rect.height() + 36, font, labelPaint);
357 canvas->drawString(gSegmentNames[s1], 0, rect.height() + 48, font, labelPaint);
358 canvas->drawString(gSegmentNames[s2], 0, rect.height() + 60, font, labelPaint);
359 canvas->drawString(gSegmentNames[s3], 0, rect.height() + 72, font, labelPaint);
360 canvas->drawString(gSegmentNames[s4], 0, rect.height() + 84, font, labelPaint);
361 canvas->drawString(gSegmentNames[s5], 0, rect.height() + 96, font, labelPaint);
362 }
363 canvas->restore();
364 }
365 canvas->restore();
366 canvas->restore();
367 }
SkPaint::Join fJoin
SkStrokeRec::Style fStyle
const char * fName
SkColor4f color
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)
void restore()
Definition SkCanvas.cpp:465
void translate(SkScalar dx, SkScalar dy)
int save()
Definition SkCanvas.cpp:451
void drawString(const char str[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
Definition SkCanvas.h:1803
@ 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
uint32_t nextU()
Definition SkRandom.h:42
sk_sp< SkBlender > blender SkRect rect
Definition SkRecords.h:350
sk_sp< SkTypeface > DefaultPortableTypeface()
SkColor color_to_565(SkColor 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
font
Font Metadata and Metrics.
static constexpr SkPoint Make(float x, float y)
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: