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

Public Member Functions

 ConvexLineOnlyPathsGM (bool doStrokeAndFill)
 
- 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
 
bool runAsBench () const override
 
void drawPath (SkCanvas *canvas, int index, SkPoint *offset)
 
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
 

Static Protected Member Functions

static SkPath GetPath (int index, SkPathDirection dir)
 

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 170 of file convex_all_line_paths.cpp.

Constructor & Destructor Documentation

◆ ConvexLineOnlyPathsGM()

skiagm::ConvexLineOnlyPathsGM::ConvexLineOnlyPathsGM ( bool  doStrokeAndFill)
inline

Definition at line 172 of file convex_all_line_paths.cpp.

172 : fDoStrokeAndFill(doStrokeAndFill) {
173 this->setBGColor(0xFFFFFFFF);
174 }
void setBGColor(SkColor)
Definition: gm.cpp:159

Member Function Documentation

◆ drawPath()

void skiagm::ConvexLineOnlyPathsGM::drawPath ( SkCanvas canvas,
int  index,
SkPoint offset 
)
inlineprotected

Definition at line 272 of file convex_all_line_paths.cpp.

272 {
273
275 {
277 if (offset->fX+path.getBounds().width() > kGMWidth) {
278 offset->fX = 0;
279 offset->fY += kMaxPathHeight;
280 if (fDoStrokeAndFill) {
281 offset->fX += kStrokeWidth / 2.0f;
282 offset->fY += kStrokeWidth / 2.0f;
283 }
284 }
285 center = { offset->fX + SkScalarHalf(path.getBounds().width()), offset->fY};
286 offset->fX += path.getBounds().width();
287 if (fDoStrokeAndFill) {
288 offset->fX += kStrokeWidth;
289 }
290 }
291
294 const float scales[] = { 1.0f, 0.75f, 0.5f, 0.25f, 0.1f, 0.01f, 0.001f };
295 const SkPaint::Join joins[3] = { SkPaint::kRound_Join,
298
300 paint.setAntiAlias(true);
301
302 for (size_t i = 0; i < std::size(scales); ++i) {
303 SkPath path = GetPath(index, dirs[i%2]);
304 if (fDoStrokeAndFill) {
306 paint.setStrokeJoin(joins[i%3]);
307 paint.setStrokeWidth(SkIntToScalar(kStrokeWidth));
308 }
309
310 canvas->save();
311 canvas->translate(center.fX, center.fY);
312 canvas->scale(scales[i], scales[i]);
313 paint.setColor(colors[i%2]);
314 canvas->drawPath(path, paint);
315 canvas->restore();
316 }
317 }
uint32_t SkColor
Definition: SkColor.h:37
constexpr SkColor SK_ColorBLACK
Definition: SkColor.h:103
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
SkPathDirection
Definition: SkPathTypes.h:34
#define SkScalarHalf(a)
Definition: SkScalar.h:75
#define SkIntToScalar(x)
Definition: SkScalar.h:57
void restore()
Definition: SkCanvas.cpp:461
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
int save()
Definition: SkCanvas.cpp:447
void drawPath(const SkPath &path, const SkPaint &paint)
Definition: SkCanvas.cpp:1747
void scale(SkScalar sx, SkScalar sy)
Definition: SkCanvas.cpp:1289
@ kStrokeAndFill_Style
sets to stroke and fill geometry
Definition: SkPaint.h:195
@ kRound_Join
adds circle
Definition: SkPaint.h:360
@ kMiter_Join
extends to miter limit
Definition: SkPaint.h:359
@ kBevel_Join
connects outside edges
Definition: SkPaint.h:361
Definition: SkPath.h:59
static SkPath GetPath(int index, SkPathDirection dir)
const Paint & paint
Definition: color_source.cc:38
PODArray< SkColor > colors
Definition: SkRecords.h:276
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
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
SeparatedVector2 offset

◆ getISize()

SkISize skiagm::ConvexLineOnlyPathsGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 183 of file convex_all_line_paths.cpp.

183{ return SkISize::Make(kGMWidth, kGMHeight); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

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

Implements skiagm::GM.

Definition at line 177 of file convex_all_line_paths.cpp.

177 {
178 if (fDoStrokeAndFill) {
179 return SkString("convex-lineonly-paths-stroke-and-fill");
180 }
181 return SkString("convex-lineonly-paths");
182 }

◆ GetPath()

static SkPath skiagm::ConvexLineOnlyPathsGM::GetPath ( int  index,
SkPathDirection  dir 
)
inlinestaticprotected

Definition at line 186 of file convex_all_line_paths.cpp.

186 {
187 std::unique_ptr<SkPoint[]> data(nullptr);
188 const SkPoint* points;
189 int numPts;
190 if (index < (int) std::size(ConvexLineOnlyData::gPoints)) {
191 // manually specified
193 numPts = (int)ConvexLineOnlyData::gSizes[index];
194 } else {
195 // procedurally generated
196 SkScalar width = kMaxPathHeight/2;
197 SkScalar height = kMaxPathHeight/2;
198 switch (index-std::size(ConvexLineOnlyData::gPoints)) {
199 case 0:
200 numPts = 3;
201 break;
202 case 1:
203 numPts = 4;
204 break;
205 case 2:
206 numPts = 5;
207 break;
208 case 3: // squashed pentagon
209 numPts = 5;
210 width = kMaxPathHeight/5;
211 break;
212 case 4:
213 numPts = 6;
214 break;
215 case 5:
216 numPts = 8;
217 break;
218 case 6: // squashed octogon
219 numPts = 8;
220 width = kMaxPathHeight/5;
221 break;
222 case 7:
223 numPts = 20;
224 break;
225 case 8:
226 numPts = 100;
227 break;
228 default:
229 numPts = 3;
230 break;
231 }
232
233 data = std::make_unique<SkPoint[]>(numPts);
234
235 create_ngon(numPts, data.get(), width, height);
236 points = data.get();
237 }
238
240
241 if (SkPathDirection::kCW == dir) {
242 builder.moveTo(points[0]);
243 for (int i = 1; i < numPts; ++i) {
244 builder.lineTo(points[i]);
245 }
246 } else {
247 builder.moveTo(points[numPts-1]);
248 for (int i = numPts-2; i >= 0; --i) {
249 builder.lineTo(points[i]);
250 }
251 }
252
253 builder.close();
254 SkPath path = builder.detach();
255#ifdef SK_DEBUG
256 // Each path this method returns should be convex, only composed of
257 // lines, wound the right direction, and short enough to fit in one
258 // of the GMs rows.
259 SkASSERT(path.isConvex());
260 SkASSERT(SkPath::kLine_SegmentMask == path.getSegmentMasks());
263 SkRect bounds = path.getBounds();
264 SkASSERT(SkScalarNearlyEqual(bounds.centerX(), 0.0f));
265 SkASSERT(bounds.height() <= kMaxPathHeight);
266#endif
267 return path;
268 }
static const int points[]
#define SkASSERT(cond)
Definition: SkAssert.h:116
SkPathFirstDirection
Definition: SkPathEnums.h:19
static bool SkScalarNearlyEqual(SkScalar x, SkScalar y, SkScalar tolerance=SK_ScalarNearlyZero)
Definition: SkScalar.h:107
static SkPathFirstDirection AsFirstDirection(SkPathDirection dir)
Definition: SkPathPriv.h:43
static SkPathFirstDirection ComputeFirstDirection(const SkPath &)
Definition: SkPath.cpp:2627
@ kLine_SegmentMask
Definition: SkPath.h:1445
SkScalar width()
Definition: gm.h:159
SkScalar height()
Definition: gm.h:162
static void create_ngon(int n, SkPoint *pts, SkScalar width, SkScalar height)
float SkScalar
Definition: extension.cpp:12
Optional< SkRect > bounds
Definition: SkRecords.h:189
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 to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets dir
Definition: switches.h:145
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ onDraw()

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

Reimplemented from skiagm::GM.

Definition at line 319 of file convex_all_line_paths.cpp.

319 {
320 // the right edge of the last drawn path
321 SkPoint offset = { 0, SkScalarHalf(kMaxPathHeight) };
322 if (fDoStrokeAndFill) {
323 offset.fX += kStrokeWidth / 2.0f;
324 offset.fY += kStrokeWidth / 2.0f;
325 }
326
327 for (int i = 0; i < kNumPaths; ++i) {
328 this->drawPath(canvas, i, &offset);
329 }
330
331 {
332 // Repro for crbug.com/472723 (Missing AA on portions of graphic with GPU rasterization)
333
334 SkPaint p;
335 p.setAntiAlias(true);
336 if (fDoStrokeAndFill) {
338 p.setStrokeJoin(SkPaint::kMiter_Join);
339 p.setStrokeWidth(SkIntToScalar(kStrokeWidth));
340 }
341
343 {60.8522949f, 364.671021f},
344 {59.4380493f, 364.671021f},
345 {385.414276f, 690.647217f},
346 {386.121399f, 689.940125f},
347 }, false);
348 canvas->save();
349 canvas->translate(356.0f, 50.0f);
350 canvas->drawPath(p1, p);
351 canvas->restore();
352
353 // Repro for crbug.com/869172 (SVG path incorrectly simplified when using GPU
354 // Rasterization). This will only draw anything in the stroke-and-fill version.
356 {10.f, 0.f},
357 {38.f, 0.f},
358 {66.f, 0.f},
359 {94.f, 0.f},
360 {122.f, 0.f},
361 {150.f, 0.f},
362 {150.f, 0.f},
363 {122.f, 0.f},
364 {94.f, 0.f},
365 {66.f, 0.f},
366 {38.f, 0.f},
367 {10.f, 0.f},
368 }, true);
369 canvas->save();
370 canvas->translate(0.0f, 500.0f);
371 canvas->drawPath(p2, p);
372 canvas->restore();
373
374 // Repro for crbug.com/856137. This path previously caused GrAAConvexTessellator to turn
375 // inset rings into outsets when adjacent bisector angles converged outside the previous
376 // ring due to accumulated error.
378 {1184.96f, 982.557f},
379 {1183.71f, 982.865f},
380 {1180.99f, 982.734f},
381 {1178.5f, 981.541f},
382 {1176.35f, 979.367f},
383 {1178.94f, 938.854f},
384 {1181.35f, 936.038f},
385 {1183.96f, 934.117f},
386 {1186.67f, 933.195f},
387 {1189.36f, 933.342f},
388 {1191.58f, 934.38f},
389 }, true, SkPathFillType::kEvenOdd);
390 canvas->save();
391 SkMatrix m;
392 m.setAll(0.0893210843f, 0, 79.1197586f, 0, 0.0893210843f, 300, 0, 0, 1);
393 canvas->concat(m);
394 canvas->drawPath(p3, p);
395 canvas->restore();
396 }
397 }
void concat(const SkMatrix &matrix)
Definition: SkCanvas.cpp:1318
static SkPath Polygon(const SkPoint pts[], int count, bool isClosed, SkPathFillType=SkPathFillType::kWinding, bool isVolatile=false)
Definition: SkPath.cpp:3614
void drawPath(SkCanvas *canvas, int index, SkPoint *offset)

◆ runAsBench()

bool skiagm::ConvexLineOnlyPathsGM::runAsBench ( ) const
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 184 of file convex_all_line_paths.cpp.

184{ return true; }

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