Flutter Engine
The Flutter Engine
strokerect_gm.cpp
Go to the documentation of this file.
1// Copyright 2020 Google LLC.
2// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
4#include <cfloat>
5
6REG_FIDDLE(strokerect_gm, 1400, 740, false, 0) {
7void draw(SkCanvas* canvas) {
8 constexpr SkScalar kStrokeWidth = 20;
11 constexpr SkScalar W = 80;
12 constexpr SkScalar H = 80;
13 constexpr SkRect gRects[] = {
14 {0, 0, W, H},
15 {W, 0, 0, H},
16 {0, H, W, 0},
17 {0, 0, kStrokeWidth, H},
18 {0, 0, W, kStrokeWidth},
19 {0, 0, kStrokeWidth / 2, kStrokeWidth / 2},
20 {0, 0, W, 0},
21 {0, 0, 0, H},
22 {0, 0, 0, 0},
23 {0, 0, W, FLT_EPSILON},
24 {0, 0, FLT_EPSILON, H},
25 {0, 0, FLT_EPSILON, FLT_EPSILON},
26 };
27 canvas->translate(kStrokeWidth * 3 / 2, kStrokeWidth * 3 / 2);
28 for (int doFill = 0; doFill <= 1; ++doFill) {
30 for (size_t i = 0; i < std::size(gJoins); ++i) {
31 SkPaint::Join join = gJoins[i];
32 for (size_t j = 0; j < std::size(gRects); ++j) {
33 SkAutoCanvasRestore acr(canvas, true);
34 canvas->translate(
35 j * (W + 2 * kStrokeWidth),
36 (i + doFill * std::size(gJoins)) * (H + 2 * kStrokeWidth));
37 const SkRect& rect = gRects[j];
38
39 SkPath path, fillPath;
40 path.addRect(rect);
42
43 paint.setStrokeWidth(kStrokeWidth);
44 paint.setStyle(style);
45 paint.setStrokeJoin(join);
47
48 paint.setAntiAlias(true);
49 paint.setColor(0xFF8C8A8C);
50 canvas->drawRect(rect, paint);
51
53 paint.setStrokeWidth(0);
54 paint.setColor(SK_ColorRED);
55 canvas->drawPath(fillPath, paint);
56
57 paint.setStrokeWidth(3);
58 paint.setStrokeJoin(SkPaint::kMiter_Join);
59 int n = fillPath.countPoints();
60 SkPoint* points = new SkPoint[n];
61 fillPath.getPoints(points, n);
63 delete[] points;
64 }
65 }
66 }
67}
68} // END FIDDLE
static const int points[]
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
#define W
Definition: aaa.cpp:17
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void drawPoints(PointMode mode, size_t count, const SkPoint pts[], const SkPaint &paint)
Definition: SkCanvas.cpp:1710
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void drawPath(const SkPath &path, const SkPaint &paint)
Definition: SkCanvas.cpp:1747
@ kPoints_PointMode
draw each point separately
Definition: SkCanvas.h:1241
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194
@ 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
int countPoints() const
Definition: SkPath.cpp:535
int getPoints(SkPoint points[], int max) const
Definition: SkPath.cpp:539
const Paint & paint
Definition: color_source.cc:38
#define H
float SkScalar
Definition: extension.cpp:12
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
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
SK_API bool FillPathWithPaint(const SkPath &src, const SkPaint &paint, SkPath *dst, const SkRect *cullRect, SkScalar resScale=1)
Definition: SkPathUtils.cpp:23
static SkString join(const CommandLineFlags::StringArray &)
Definition: skpbench.cpp:741
constexpr SkScalar kStrokeWidth
REG_FIDDLE(strokerect_gm, 1400, 740, false, 0)
Definition: SkMD5.cpp:130