Flutter Engine
The Flutter Engine
Functions
inversepaths.cpp File Reference
#include "gm/gm.h"
#include "include/core/SkBlurTypes.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkMaskFilter.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPath.h"
#include "include/core/SkPathEffect.h"
#include "include/core/SkRect.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkScalar.h"
#include "include/core/SkTypes.h"
#include "include/effects/SkDashPathEffect.h"
#include "include/effects/SkImageFilters.h"
#include <utility>

Go to the source code of this file.

Functions

static SkPath generate_square (SkScalar cx, SkScalar cy, SkScalar w)
 
static SkPath generate_rect_line (SkScalar cx, SkScalar cy, SkScalar l)
 
static SkPath generate_circle (SkScalar cx, SkScalar cy, SkScalar d)
 
static SkPath generate_line (SkScalar cx, SkScalar cy, SkScalar l)
 
 DEF_SIMPLE_GM (inverse_paths, canvas, 800, 1200)
 
 DEF_SIMPLE_GM (inverse_fill_filters, canvas, 384, 128)
 
 DEF_SIMPLE_GM (inverse_windingmode_filters, canvas, 256, 100)
 

Function Documentation

◆ DEF_SIMPLE_GM() [1/3]

DEF_SIMPLE_GM ( inverse_fill_filters  ,
canvas  ,
384  ,
128   
)

Definition at line 142 of file inversepaths.cpp.

142 {
143 auto draw = [canvas](const SkPaint& paint) {
144 SkPath path = SkPath::Circle(65.f, 65.f, 30.f);
146
147 canvas->save();
148 canvas->clipRect({0, 0, 128, 128});
149 canvas->drawPath(path, paint);
150 canvas->restore();
151
154 stroke.setColor(SK_ColorWHITE);
155 canvas->drawRect({0, 0, 128, 128}, stroke);
156 };
157
159 paint.setAntiAlias(true);
160
161 draw(paint);
162
163 canvas->translate(128, 0);
164 paint.setImageFilter(SkImageFilters::Blur(5.f, 5.f, nullptr));
165 draw(paint);
166
167 canvas->translate(128, 0);
168 paint.setImageFilter(nullptr);
170 draw(paint);
171}
@ kNormal_SkBlurStyle
fuzzy inside and outside
Definition: SkBlurTypes.h:12
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
static sk_sp< SkImageFilter > Blur(SkScalar sigmaX, SkScalar sigmaY, SkTileMode tileMode, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkMaskFilter > MakeBlur(SkBlurStyle style, SkScalar sigma, bool respectCTM=true)
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194
Definition: SkPath.h:59
static SkPath Circle(SkScalar center_x, SkScalar center_y, SkScalar radius, SkPathDirection dir=SkPathDirection::kCW)
Definition: SkPath.cpp:3598
const Paint & paint
Definition: color_source.cc:38
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

◆ DEF_SIMPLE_GM() [2/3]

DEF_SIMPLE_GM ( inverse_paths  ,
canvas  ,
800  ,
1200   
)

Definition at line 82 of file inversepaths.cpp.

82 {
83 SkScalar cx = slideWidth / 2 + slideBoundary;
84 SkScalar cy = slideHeight / 2 + slideBoundary;
85 SkScalar dx = slideWidth + 2 * slideBoundary;
86 SkScalar dy = slideHeight + 2 * slideBoundary;
87
88 SkRect clipRect = SkRect::MakeLTRB(slideBoundary, slideBoundary,
89 slideBoundary + slideWidth,
90 slideBoundary + slideHeight);
91 SkPaint clipPaint;
93 clipPaint.setStrokeWidth(SkIntToScalar(2));
94
95 SkPaint outlinePaint;
96 outlinePaint.setColor(0x40000000);
97 outlinePaint.setStyle(SkPaint::kStroke_Style);
98 outlinePaint.setStrokeWidth(SkIntToScalar(0));
99
100 for (size_t styleIndex = 0; styleIndex < std::size(styles);
101 styleIndex++) {
102 for (size_t sizeIndex = 0; sizeIndex < std::size(pathSizes);
103 sizeIndex++) {
104 SkScalar size = pathSizes[sizeIndex];
105
106 canvas->save();
107
108 for (size_t widthIndex = 0;
109 widthIndex < std::size(strokeWidths);
110 widthIndex++) {
112 paint.setColor(0xff007000);
113 paint.setStrokeWidth(strokeWidths[widthIndex]);
114 paint.setStyle(styles[styleIndex].fPaintStyle);
115 paint.setPathEffect(styles[styleIndex].fPathEffect);
116
117 for (size_t pathIndex = 0;
118 pathIndex < std::size(paths);
119 pathIndex++) {
120 canvas->drawRect(clipRect, clipPaint);
121
122 canvas->save();
123 canvas->clipRect(clipRect);
124
125 SkPath path = paths[pathIndex](cx, cy, size);
127 canvas->drawPath(path, paint);
128
129 path.setFillType(SkPathFillType::kWinding);
130 canvas->drawPath(path, outlinePaint);
131
132 canvas->restore();
133 canvas->translate(dx, 0);
134 }
135 }
136 canvas->restore();
137 canvas->translate(0, dy);
138 }
139 }
140}
#define SkIntToScalar(x)
Definition: SkScalar.h:57
void setStyle(Style style)
Definition: SkPaint.cpp:105
void setColor(SkColor color)
Definition: SkPaint.cpp:119
void setStrokeWidth(SkScalar width)
Definition: SkPaint.cpp:159
float SkScalar
Definition: extension.cpp:12
clipRect(r.rect, r.opAA.op(), r.opAA.aa())) template<> void Draw
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
Definition: SkRecords.h:208
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 SkRect MakeLTRB(float l, float t, float r, float b)
Definition: SkRect.h:646

◆ DEF_SIMPLE_GM() [3/3]

DEF_SIMPLE_GM ( inverse_windingmode_filters  ,
canvas  ,
256  ,
100   
)

Definition at line 173 of file inversepaths.cpp.

173 {
174 SkPath path;
175 path.addRect({10, 10, 30, 30}, SkPathDirection::kCW);
176 path.addRect({20, 20, 40, 40}, SkPathDirection::kCW);
177 path.addRect({10, 60, 30, 80}, SkPathDirection::kCW);
178 path.addRect({20, 70, 40, 90}, SkPathDirection::kCCW);
179 SkPaint strokePaint;
180 strokePaint.setStyle(SkPaint::kStroke_Style);
181 SkRect clipRect = {0, 0, 51, 99};
182 canvas->drawPath(path, strokePaint);
183 SkPaint fillPaint;
185 for (auto fillType : { SkPathFillType::kWinding,
189 canvas->translate(51, 0);
190 canvas->save();
191 canvas->clipRect(clipRect);
192 path.setFillType(fillType);
193 canvas->drawPath(path, fillPaint);
194 canvas->restore();
195 SkPaint clipPaint;
196 clipPaint.setColor(SK_ColorRED);
198 clipPaint.setStrokeWidth(1.f);
199 canvas->drawRect(clipRect, clipPaint);
200 }
201}
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
void setMaskFilter(sk_sp< SkMaskFilter > maskFilter)

◆ generate_circle()

static SkPath generate_circle ( SkScalar  cx,
SkScalar  cy,
SkScalar  d 
)
static

Definition at line 32 of file inversepaths.cpp.

32 {
33 return SkPath::Circle(cx, cy, d/2, SkPathDirection::kCW);
34}
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
Definition: main.cc:19

◆ generate_line()

static SkPath generate_line ( SkScalar  cx,
SkScalar  cy,
SkScalar  l 
)
static

Definition at line 36 of file inversepaths.cpp.

36 {
37 return SkPath::Line({cx - l / 2, cy}, {cx + l / 2, cy});
38}
static SkPath Line(const SkPoint a, const SkPoint b)
Definition: SkPath.h:106

◆ generate_rect_line()

static SkPath generate_rect_line ( SkScalar  cx,
SkScalar  cy,
SkScalar  l 
)
static

Definition at line 28 of file inversepaths.cpp.

28 {
29 return SkPath::Rect(SkRect::MakeXYWH(cx - l / 2, cy, l, 0));
30}
static SkPath Rect(const SkRect &, SkPathDirection=SkPathDirection::kCW, unsigned startIndex=0)
Definition: SkPath.cpp:3586
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659

◆ generate_square()

static SkPath generate_square ( SkScalar  cx,
SkScalar  cy,
SkScalar  w 
)
static

Definition at line 24 of file inversepaths.cpp.

24 {
25 return SkPath::Rect(SkRect::MakeXYWH(cx - w / 2, cy - w / 2, w, w));
26}
SkScalar w