Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions | Variables
labyrinth.cpp File Reference
#include "gm/gm.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPathBuilder.h"

Go to the source code of this file.

Functions

static void draw_labyrinth (SkCanvas *canvas, SkPaint::Cap cap)
 
 DEF_SIMPLE_GM (labyrinth_square, canvas, kWidth, kHeight)
 
 DEF_SIMPLE_GM (labyrinth_round, canvas, kWidth, kHeight)
 
 DEF_SIMPLE_GM (labyrinth_butt, canvas, kWidth, kHeight)
 

Variables

static constexpr int kWidth = 500
 
static constexpr int kHeight = 420
 

Function Documentation

◆ DEF_SIMPLE_GM() [1/3]

DEF_SIMPLE_GM ( labyrinth_butt  ,
canvas  ,
kWidth  ,
kHeight   
)

Definition at line 96 of file labyrinth.cpp.

96 {
98}
@ kButt_Cap
no stroke extension
Definition SkPaint.h:334
static void draw_labyrinth(SkCanvas *canvas, SkPaint::Cap cap)
Definition labyrinth.cpp:24

◆ DEF_SIMPLE_GM() [2/3]

DEF_SIMPLE_GM ( labyrinth_round  ,
canvas  ,
kWidth  ,
kHeight   
)

Definition at line 92 of file labyrinth.cpp.

92 {
94}
@ kRound_Cap
adds circle
Definition SkPaint.h:335

◆ DEF_SIMPLE_GM() [3/3]

DEF_SIMPLE_GM ( labyrinth_square  ,
canvas  ,
kWidth  ,
kHeight   
)

Definition at line 88 of file labyrinth.cpp.

88 {
90}
@ kSquare_Cap
adds square
Definition SkPaint.h:336

◆ draw_labyrinth()

static void draw_labyrinth ( SkCanvas canvas,
SkPaint::Cap  cap 
)
static

Repro case for https://bugs.chromium.org/p/chromium/issues/detail?id=913223

The original bug was filed against square caps, but here we also draw the labyrinth using round and butt caps.

Square and round caps expose over-coverage on overlaps when using coverage counting.

Butt caps expose under-coverage on abutted strokes when using a 'max()' coverage function.

Definition at line 24 of file labyrinth.cpp.

24 {
25 constexpr static bool kRows[11][12] = {
26 {1,1,1,1,1,1,1,1,1,1,1,1},
27 {0,1,0,1,0,1,0,0,0,0,1,1},
28 {0,0,0,0,1,0,0,0,0,1,1,1},
29 {1,0,1,0,0,0,0,1,0,0,0,0},
30 {0,1,1,0,0,0,0,0,0,1,1,1},
31 {1,0,0,1,0,0,0,0,1,1,1,0},
32 {0,1,0,1,1,1,0,0,1,1,1,0},
33 {1,0,1,0,1,1,1,1,0,1,1,1},
34 {0,0,1,0,0,1,0,0,0,0,0,1},
35 {0,1,1,1,0,0,1,1,1,1,0,0},
36 {1,1,1,1,1,1,1,1,1,1,1,1},
37 };
38
39 constexpr static bool kCols[13][10] = {
40 {1,1,1,1,0,1,1,1,1,1},
41 {0,0,1,0,0,0,1,1,1,0},
42 {0,1,1,0,1,1,1,0,0,1},
43 {1,1,0,0,0,0,1,0,1,0},
44 {0,0,1,0,1,0,0,0,0,1},
45 {0,0,1,1,1,0,0,0,1,0},
46 {0,1,0,1,1,1,0,0,0,0},
47 {1,1,1,0,1,1,1,0,1,0},
48 {1,1,0,1,1,0,0,0,1,0},
49 {0,0,1,0,0,0,0,0,0,1},
50 {0,0,1,1,0,0,0,0,1,0},
51 {0,0,0,0,0,0,1,0,0,1},
52 {1,1,1,1,1,1,0,1,1,1},
53 };
54
55 SkPathBuilder maze;
56 for (size_t y = 0; y < std::size(kRows); ++y) {
57 for (size_t x = 0; x < std::size(kRows[0]); ++x) {
58 if (kRows[y][x]) {
59 maze.moveTo(x, y);
60 maze.lineTo(x+1, y);
61 }
62 }
63 }
64 for (size_t x = 0; x < std::size(kCols); ++x) {
65 for (size_t y = 0; y < std::size(kCols[0]); ++y) {
66 if (kCols[x][y]) {
67 maze.moveTo(x, y);
68 maze.lineTo(x, y+1);
69 }
70 }
71 }
72
75 paint.setStrokeWidth(.1f);
76 paint.setColor(0xff406060);
77 paint.setAntiAlias(true);
78 paint.setStrokeCap(cap);
79
80 canvas->translate(10.5, 10.5);
81 canvas->scale(40, 40);
82 canvas->drawPath(maze.detach(), paint);
83}
void translate(SkScalar dx, SkScalar dy)
void drawPath(const SkPath &path, const SkPaint &paint)
void scale(SkScalar sx, SkScalar sy)
@ kStroke_Style
set to stroke geometry
Definition SkPaint.h:194
SkPathBuilder & lineTo(SkPoint pt)
SkPathBuilder & moveTo(SkPoint pt)
const Paint & paint
double y
double x

Variable Documentation

◆ kHeight

constexpr int kHeight = 420
staticconstexpr

Definition at line 86 of file labyrinth.cpp.

◆ kWidth

constexpr int kWidth = 500
staticconstexpr

Definition at line 85 of file labyrinth.cpp.