Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Private Member Functions | List of all members
Dashing4GM Class Reference
Inheritance diagram for Dashing4GM:
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 315 of file dashing.cpp.

Member Function Documentation

◆ getISize()

SkISize Dashing4GM::getISize ( )
inlineoverrideprivatevirtual

Implements skiagm::GM.

Definition at line 318 of file dashing.cpp.

318{ return {640, 1100}; }

◆ getName()

SkString Dashing4GM::getName ( ) const
inlineoverrideprivatevirtual

Implements skiagm::GM.

Definition at line 316 of file dashing.cpp.

316{ return SkString("dashing4"); }

◆ onDraw()

void Dashing4GM::onDraw ( SkCanvas canvas)
inlineoverrideprivatevirtual

Reimplemented from skiagm::GM.

Definition at line 320 of file dashing.cpp.

320 {
321 struct Intervals {
322 int fOnInterval;
323 int fOffInterval;
324 };
325
327 paint.setStroke(true);
328
329 canvas->translate(SkIntToScalar(20), SkIntToScalar(20));
331
332 for (int width = 0; width <= 2; ++width) {
333 for (const Intervals& data : {Intervals{1, 1},
334 Intervals{4, 2},
335 Intervals{0, 4}}) { // test for zero length on interval.
336 // zero length intervals should draw
337 // a line of squares or circles
338 for (bool aa : {false, true}) {
339 for (auto cap : {SkPaint::kRound_Cap, SkPaint::kSquare_Cap}) {
340 int w = width * width * width;
341 paint.setAntiAlias(aa);
342 paint.setStrokeWidth(SkIntToScalar(w));
343 paint.setStrokeCap(cap);
344
345 int scale = w ? w : 1;
346
347 drawline(canvas, data.fOnInterval * scale, data.fOffInterval * scale,
348 paint);
349 canvas->translate(0, SkIntToScalar(20));
350 }
351 }
352 }
353 }
354
355 for (int aa = 0; aa <= 1; ++aa) {
356 paint.setAntiAlias(SkToBool(aa));
357 paint.setStrokeWidth(8.f);
358 paint.setStrokeCap(SkPaint::kSquare_Cap);
359 // Single dash element that is cut off at start and end
360 drawline(canvas, 32, 16, paint, 20.f, 0, 5.f);
361 canvas->translate(0, SkIntToScalar(20));
362
363 // Two dash elements where each one is cut off at beginning and end respectively
364 drawline(canvas, 32, 16, paint, 56.f, 0, 5.f);
365 canvas->translate(0, SkIntToScalar(20));
366
367 // Many dash elements where first and last are cut off at beginning and end respectively
368 drawline(canvas, 32, 16, paint, 584.f, 0, 5.f);
369 canvas->translate(0, SkIntToScalar(20));
370
371 // Diagonal dash line where src pnts are not axis aligned (as apposed to being diagonal from
372 // a canvas rotation)
373 drawline(canvas, 32, 16, paint, 600.f, 30.f);
374 canvas->translate(0, SkIntToScalar(20));
375
376 // Case where only the off interval exists on the line. Thus nothing should be drawn
377 drawline(canvas, 32, 16, paint, 8.f, 0.f, 40.f);
378 canvas->translate(0, SkIntToScalar(20));
379 }
380
381 // Test overlapping circles.
382 canvas->translate(SkIntToScalar(5), SkIntToScalar(20));
383 paint.setAntiAlias(true);
384 paint.setStrokeCap(SkPaint::kRound_Cap);
385 paint.setColor(0x44000000);
386 paint.setStrokeWidth(40);
387 drawline(canvas, 0, 30, paint);
388
389 canvas->translate(0, SkIntToScalar(50));
390 paint.setStrokeCap(SkPaint::kSquare_Cap);
391 drawline(canvas, 0, 30, paint);
392
393 // Test we draw the cap when the line length is zero.
394 canvas->translate(0, SkIntToScalar(50));
395 paint.setStrokeCap(SkPaint::kRound_Cap);
396 paint.setColor(0xFF000000);
397 paint.setStrokeWidth(11);
398 drawline(canvas, 0, 30, paint, 0);
399
400 canvas->translate(SkIntToScalar(100), 0);
401 drawline(canvas, 1, 30, paint, 0);
402 }
#define SK_ScalarHalf
Definition SkScalar.h:19
#define SkIntToScalar(x)
Definition SkScalar.h:57
static constexpr bool SkToBool(const T &x)
Definition SkTo.h:35
void translate(SkScalar dx, SkScalar dy)
@ kRound_Cap
adds circle
Definition SkPaint.h:335
@ kSquare_Cap
adds square
Definition SkPaint.h:336
SkScalar width()
Definition gm.h:159
const Paint & paint
static void drawline(SkCanvas *canvas, int on, int off, const SkPaint &paint, SkScalar finalX=SkIntToScalar(600), SkScalar finalY=SkIntToScalar(0), SkScalar phase=SkIntToScalar(0), SkScalar startX=SkIntToScalar(0), SkScalar startY=SkIntToScalar(0))
Definition dashing.cpp:30
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switches.h:41
SkScalar w
const Scalar scale

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