Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Macros | Functions
aaa.cpp File Reference
#include "gm/gm.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColor.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPathBuilder.h"
#include "include/core/SkScalar.h"
#include "src/base/SkFloatBits.h"
#include "src/core/SkPathPriv.h"

Go to the source code of this file.

Macros

#define W   800
 
#define H   800
 

Functions

 DEF_SIMPLE_GM (analytic_antialias_convex, canvas, W, H)
 
 DEF_SIMPLE_GM (analytic_antialias_general, canvas, W, H)
 
 DEF_SIMPLE_GM (analytic_antialias_inverse, canvas, W, H)
 

Macro Definition Documentation

◆ H

#define H   800

Definition at line 18 of file aaa.cpp.

◆ W

#define W   800

Definition at line 17 of file aaa.cpp.

Function Documentation

◆ DEF_SIMPLE_GM() [1/3]

DEF_SIMPLE_GM ( analytic_antialias_convex  ,
canvas  ,
W  ,
H   
)

Definition at line 20 of file aaa.cpp.

20 {
21 SkPaint p;
22 p.setColor(SK_ColorRED);
23 p.setAntiAlias(true);
24
25 canvas->clear(0xFFFFFFFF);
26
27 canvas->save();
28
29 SkScalar y = 0;
30
31 canvas->translate(0, y);
32 canvas->rotate(1);
33 canvas->drawRect({ 20, 20, 200, 200 }, p);
34 canvas->restore();
35
36 y += 200;
37
38 canvas->save();
39 canvas->translate(0, y);
40 canvas->rotate(1);
41 canvas->drawRect({ 20, 20, 20.2f, 200 }, p);
42 canvas->drawRect({ 20, 200, 200, 200.1f }, p);
43 canvas->drawCircle(100, 100, 30, p);
44 canvas->restore();
45
46 // The following path is empty but it'll reveal bug chrome:662914
48 pb.moveTo(SkBits2Float(0x429b9d5c), SkBits2Float(0x4367a041)); // 77.8073f, 231.626f
49 // 77.8075f, 231.626f, 77.8074f, 231.625f, 77.8073f, 231.625f
50 pb.cubicTo(SkBits2Float(0x429b9d71), SkBits2Float(0x4367a022),
51 SkBits2Float(0x429b9d64), SkBits2Float(0x4367a009),
52 SkBits2Float(0x429b9d50), SkBits2Float(0x43679ff2));
53 pb.lineTo(SkBits2Float(0x429b9d5c), SkBits2Float(0x4367a041)); // 77.8073f, 231.626f
54 pb.close();
55 canvas->drawPath(pb.detach(), p);
56
57 // The following path reveals a subtle SkAnalyticQuadraticEdge::updateQuadratic bug:
58 // we should not use any snapped y for the intermediate values whose error may accumulate;
59 // snapping should only be allowed once before updateLine.
60 pb.moveTo(SkBits2Float(0x434ba71e), SkBits2Float(0x438a06d0)); // 203.653f, 276.053f
61 pb.lineTo(SkBits2Float(0x43492a74), SkBits2Float(0x4396d70d)); // 201.166f, 301.68f
62 // 200.921f, 304.207f, 196.939f, 303.82f, 0.707107f
63 pb.conicTo(SkBits2Float(0x4348ebaf), SkBits2Float(0x43981a75),
64 SkBits2Float(0x4344f079), SkBits2Float(0x4397e900), SkBits2Float(0x3f3504f3));
65 pb.close();
66 SkPath path = pb.detach();
67 // Manually setting convexity is required. Otherwise, this path will be considered concave.
69 canvas->drawPath(path, p);
70
71 // skbug.com/7573
72 y += 200;
73 canvas->save();
74 canvas->translate(0, y);
75 p.setAntiAlias(true);
76 pb.moveTo(1.98009784f, 9.0162744f);
77 pb.lineTo(47.843992f, 10.1922744f);
78 pb.lineTo(47.804008f, 11.7597256f);
79 pb.lineTo(1.93990216f, 10.5837256f);
80 canvas->drawPath(pb.detach(), p);
81 canvas->restore();
82
83 // skbug.com/7813
84 // t8888 splits the 800-high canvas into 3 pieces; the boundary is close to 266 and 534
85 pb.moveTo(700, 266);
86 pb.lineTo(710, 266);
87 pb.lineTo(710, 534);
88 pb.lineTo(700, 534);
89 canvas->drawPath(pb.detach(), p);
90}
constexpr SkColor SK_ColorRED
Definition SkColor.h:126
static float SkBits2Float(uint32_t bits)
Definition SkFloatBits.h:48
SkPathBuilder & conicTo(SkPoint pt1, SkPoint pt2, SkScalar w)
SkPathBuilder & close()
SkPathBuilder & lineTo(SkPoint pt)
SkPathBuilder & cubicTo(SkPoint pt1, SkPoint pt2, SkPoint pt3)
SkPathBuilder & moveTo(SkPoint pt)
static void SetConvexity(const SkPath &path, SkPathConvexity c)
Definition SkPathPriv.h:413
float SkScalar
Definition extension.cpp:12
double y
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 ( analytic_antialias_general  ,
canvas  ,
W  ,
H   
)

Definition at line 92 of file aaa.cpp.

92 {
93 SkPaint p;
94 p.setColor(SK_ColorRED);
95 p.setAntiAlias(true);
96
97 canvas->clear(0xFFFFFFFF);
98
99 canvas->save();
100 canvas->rotate(1);
101 const SkScalar R = 115.2f, C = 128.0f;
103 builder.moveTo(C + R, C);
104 for (int i = 1; i < 8; ++i) {
105 SkScalar a = 2.6927937f * i;
106 builder.lineTo(C + R * SkScalarCos(a), C + R * SkScalarSin(a));
107 }
108 SkPath path = builder.detach();
109 canvas->drawPath(path, p);
110 canvas->restore();
111
112 canvas->save();
113 canvas->translate(200, 0);
114 canvas->rotate(1);
115 p.setStyle(SkPaint::kStroke_Style);
116 p.setStrokeWidth(5);
117 canvas->drawPath(path, p);
118 canvas->restore();
119
120
121 // The following two paths test if we correctly cumulates the alpha on the middle pixel
122 // column where the left rect and the right rect abut.
123 p.setStyle(SkPaint::kFill_Style);
124 canvas->translate(0, 300);
125 canvas->drawPath(SkPathBuilder().addRect({20, 20, 100.4999f, 100})
126 .addRect({100.5001f, 20, 200, 100})
127 .detach(), p);
128
129 canvas->translate(300, 0);
130 canvas->drawPath(SkPathBuilder().addRect({20, 20, 100.1f, 100})
131 .addRect({100.9f, 20, 200, 100})
132 .detach(), p);
133}
#define SkScalarSin(radians)
Definition SkScalar.h:45
#define SkScalarCos(radians)
Definition SkScalar.h:46
@ kStroke_Style
set to stroke geometry
Definition SkPaint.h:194
@ kFill_Style
set to fill geometry
Definition SkPaint.h:193
struct MyStruct a[10]
#define R(r)

◆ DEF_SIMPLE_GM() [3/3]

DEF_SIMPLE_GM ( analytic_antialias_inverse  ,
canvas  ,
W  ,
H   
)

Definition at line 135 of file aaa.cpp.

135 {
136 SkPaint p;
137 p.setColor(SK_ColorRED);
138 p.setAntiAlias(true);
139
140 canvas->save();
141
142 SkPath path = SkPath::Circle(100, 100, 30);
144 canvas->drawPath(path, p);
145 canvas->restore();
146}
static SkPath Circle(SkScalar center_x, SkScalar center_y, SkScalar radius, SkPathDirection dir=SkPathDirection::kCW)
Definition SkPath.cpp:3530