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

Public Types

enum  Clip { kRect_Clip , kRRect_Clip , kPath_Clip }
 
- Public Types inherited from skiagm::GM
enum  Mode { kGM_Mode , kSample_Mode , kBench_Mode }
 
using DrawResult = skiagm::DrawResult
 
using GraphiteTestContext = skiatest::graphite::GraphiteTestContext
 

Public Member Functions

 ComplexClip2GM (Clip clip, bool antiAlias)
 
- 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

void onOnceBeforeDraw () override
 
SkString getName () const override
 
SkISize getISize () override
 
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 const char * ClipStr (Clip clip)
 

Static Protected Attributes

static constexpr int kRows = 5
 
static constexpr int kCols = 5
 
static constexpr int kPadX = 20
 
static constexpr int kPadY = 20
 

Additional Inherited Members

- Static Public Attributes inherited from skiagm::GM
static constexpr char kErrorMsg_DrawSkippedGpuOnly []
 

Detailed Description

Definition at line 24 of file complexclip2.cpp.

Member Enumeration Documentation

◆ Clip

Enumerator
kRect_Clip 
kRRect_Clip 
kPath_Clip 

Definition at line 26 of file complexclip2.cpp.

Constructor & Destructor Documentation

◆ ComplexClip2GM()

skiagm::ComplexClip2GM::ComplexClip2GM ( Clip  clip,
bool  antiAlias 
)
inline

Definition at line 32 of file complexclip2.cpp.

33 : fClip(clip)
34 , fAntiAlias(antiAlias) {
35 SkScalar xA = 0.65f;
36 SkScalar xF = 50.65f;
37
38 SkScalar yA = 0.65f;
39 SkScalar yF = 50.65f;
40
41 fWidth = xF - xA;
42 fHeight = yF - yA;
43
44 fTotalWidth = kCols * fWidth + SK_Scalar1 * (kCols + 1) * kPadX;
45 fTotalHeight = kRows * fHeight + SK_Scalar1 * (kRows + 1) * kPadY;
46 }
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition: SkPath.cpp:3892
#define SK_Scalar1
Definition: SkScalar.h:18
static constexpr int kCols
static constexpr int kPadY
static constexpr int kRows
static constexpr int kPadX
float SkScalar
Definition: extension.cpp:12

Member Function Documentation

◆ ClipStr()

static const char * skiagm::ComplexClip2GM::ClipStr ( Clip  clip)
inlinestaticprotected

Definition at line 112 of file complexclip2.cpp.

112 {
113 switch (clip) {
114 case kRect_Clip:
115 return "rect";
116 case kRRect_Clip:
117 return "rrect";
118 case kPath_Clip:
119 return "path";
120 }
121 SkDEBUGFAIL("Unknown clip type.");
122 return "";
123 }
#define SkDEBUGFAIL(message)
Definition: SkAssert.h:118

◆ getISize()

SkISize skiagm::ComplexClip2GM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 137 of file complexclip2.cpp.

137 {
138 return SkISize::Make(SkScalarRoundToInt(fTotalWidth),
139 SkScalarRoundToInt(fTotalHeight));
140 }
#define SkScalarRoundToInt(x)
Definition: SkScalar.h:37
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

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

Implements skiagm::GM.

Definition at line 125 of file complexclip2.cpp.

125 {
126 if (kRect_Clip == fClip && !fAntiAlias) {
127 return SkString("complexclip2");
128 }
129
130 SkString str;
131 str.printf("complexclip2_%s_%s",
132 ClipStr(fClip),
133 fAntiAlias ? "aa" : "bw");
134 return str;
135 }
void printf(const char format[],...) SK_PRINTF_LIKE(2
Definition: SkString.cpp:534
static const char * ClipStr(Clip clip)

◆ onDraw()

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

Reimplemented from skiagm::GM.

Definition at line 142 of file complexclip2.cpp.

142 {
143 SkPaint rectPaint;
145 rectPaint.setStrokeWidth(-1);
146
147 SkPaint fillPaint;
148 fillPaint.setColor(SkColorSetRGB(0xA0,0xDD,0xA0));
149
150 for (int i = 0; i < kRows; ++i) {
151 for (int j = 0; j < kCols; ++j) {
152 canvas->save();
153
154 canvas->translate(kPadX * SK_Scalar1 + (fWidth + kPadX * SK_Scalar1)*j,
155 kPadY * SK_Scalar1 + (fHeight + kPadY * SK_Scalar1)*i);
156
157 // draw the original shapes first so we can see the
158 // antialiasing on the clipped draw
159 for (int k = 0; k < 5; ++k) {
160 rectPaint.setColor(fRectColors[k]);
161 switch (fClip) {
162 case kRect_Clip:
163 canvas->drawRect(fRects[k], rectPaint);
164 break;
165 case kRRect_Clip:
166 canvas->drawRRect(fRRects[k], rectPaint);
167 break;
168 case kPath_Clip:
169 canvas->drawPath(fPaths[k], rectPaint);
170 break;
171 }
172 }
173
174 for (int k = 0; k < 5; ++k) {
175 switch (fClip) {
176 case kRect_Clip:
177 canvas->clipRect(fRects[k],
178 fOps[j*kRows+i][k],
179 fAntiAlias);
180 break;
181 case kRRect_Clip:
182 canvas->clipRRect(fRRects[k],
183 fOps[j*kRows+i][k],
184 fAntiAlias);
185 break;
186 case kPath_Clip:
187 canvas->clipPath(fPaths[k],
188 fOps[j*kRows+i][k],
189 fAntiAlias);
190 break;
191 }
192 }
193 canvas->drawRect(SkRect::MakeWH(fWidth, fHeight), fillPaint);
194 canvas->restore();
195 }
196 }
197 }
#define SkColorSetRGB(r, g, b)
Definition: SkColor.h:57
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
Definition: SkCanvas.cpp:1361
void restore()
Definition: SkCanvas.cpp:461
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void drawRRect(const SkRRect &rrect, const SkPaint &paint)
Definition: SkCanvas.cpp:1705
void clipPath(const SkPath &path, SkClipOp op, bool doAntiAlias)
Definition: SkCanvas.cpp:1456
int save()
Definition: SkCanvas.cpp:447
void drawPath(const SkPath &path, const SkPaint &paint)
Definition: SkCanvas.cpp:1747
void clipRRect(const SkRRect &rrect, SkClipOp op, bool doAntiAlias)
Definition: SkCanvas.cpp:1439
void setStyle(Style style)
Definition: SkPaint.cpp:105
void setColor(SkColor color)
Definition: SkPaint.cpp:119
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194
void setStrokeWidth(SkScalar width)
Definition: SkPaint.cpp:159
static constexpr SkRect MakeWH(float w, float h)
Definition: SkRect.h:609

◆ onOnceBeforeDraw()

void skiagm::ComplexClip2GM::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 49 of file complexclip2.cpp.

49 {
50 this->setBGColor(SkColorSetRGB(0xDD,0xA0,0xDD));
51
52 // offset the rects a bit so we get antialiasing even in the rect case
53 SkScalar xA = 0.65f;
54 SkScalar xB = 10.65f;
55 SkScalar xC = 20.65f;
56 SkScalar xD = 30.65f;
57 SkScalar xE = 40.65f;
58 SkScalar xF = 50.65f;
59
60 SkScalar yA = 0.65f;
61 SkScalar yB = 10.65f;
62 SkScalar yC = 20.65f;
63 SkScalar yD = 30.65f;
64 SkScalar yE = 40.65f;
65 SkScalar yF = 50.65f;
66
67 fRects[0].setLTRB(xB, yB, xE, yE);
68 fRRects[0].setRectXY(fRects[0], 7, 7);
69 fPaths[0] = SkPath::RRect(fRects[0], 5, 5);
70 fRectColors[0] = SK_ColorRED;
71
72 fRects[1].setLTRB(xA, yA, xD, yD);
73 fRRects[1].setRectXY(fRects[1], 7, 7);
74 fPaths[1] = SkPath::RRect(fRects[1], 5, 5);
75 fRectColors[1] = SK_ColorGREEN;
76
77 fRects[2].setLTRB(xC, yA, xF, yD);
78 fRRects[2].setRectXY(fRects[2], 7, 7);
79 fPaths[2] = SkPath::RRect(fRects[2], 5, 5);
80 fRectColors[2] = SK_ColorBLUE;
81
82 fRects[3].setLTRB(xA, yC, xD, yF);
83 fRRects[3].setRectXY(fRects[3], 7, 7);
84 fPaths[3] = SkPath::RRect(fRects[3], 5, 5);
85 fRectColors[3] = SK_ColorYELLOW;
86
87 fRects[4].setLTRB(xC, yC, xF, yF);
88 fRRects[4].setRectXY(fRects[4], 7, 7);
89 fPaths[4] = SkPath::RRect(fRects[4], 5, 5);
90 fRectColors[4] = SK_ColorCYAN;
91
92 const SkClipOp ops[] = {
95 };
96
97 SkRandom r;
98 for (int i = 0; i < kRows; ++i) {
99 for (int j = 0; j < kCols; ++j) {
100 for (int k = 0; k < 5; ++k) {
101 fOps[j*kRows+i][k] = ops[r.nextU() % std::size(ops)];
102 }
103 }
104 }
105 }
SkPathOp ops[]
SkClipOp
Definition: SkClipOp.h:13
constexpr SkColor SK_ColorYELLOW
Definition: SkColor.h:139
constexpr SkColor SK_ColorCYAN
Definition: SkColor.h:143
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
constexpr SkColor SK_ColorGREEN
Definition: SkColor.h:131
static SkPath RRect(const SkRRect &, SkPathDirection dir=SkPathDirection::kCW)
Definition: SkPath.cpp:3602
void setRectXY(const SkRect &rect, SkScalar xRad, SkScalar yRad)
Definition: SkRRect.cpp:52
uint32_t nextU()
Definition: SkRandom.h:42
void setBGColor(SkColor)
Definition: gm.cpp:159
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
void setLTRB(float left, float top, float right, float bottom)
Definition: SkRect.h:865

Member Data Documentation

◆ kCols

constexpr int skiagm::ComplexClip2GM::kCols = 5
inlinestaticconstexprprotected

Definition at line 108 of file complexclip2.cpp.

◆ kPadX

constexpr int skiagm::ComplexClip2GM::kPadX = 20
inlinestaticconstexprprotected

Definition at line 109 of file complexclip2.cpp.

◆ kPadY

constexpr int skiagm::ComplexClip2GM::kPadY = 20
inlinestaticconstexprprotected

Definition at line 110 of file complexclip2.cpp.

◆ kRows

constexpr int skiagm::ComplexClip2GM::kRows = 5
inlinestaticconstexprprotected

Definition at line 107 of file complexclip2.cpp.


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