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

Public Types

enum  SkGeomTypes { kRect_GeomType , kPath_GeomType , kAAClip_GeomType }
 
- 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

 SimpleClipGM (SkGeomTypes geomType)
 
- 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
 
void buildRgn (SkAAClip *clip, SkClipOp op)
 
void drawOrig (SkCanvas *canvas)
 
void drawRgnOped (SkCanvas *canvas, SkClipOp op, SkColor color)
 
void drawPathsOped (SkCanvas *canvas, SkClipOp op, SkColor color)
 
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
 

Additional Inherited Members

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

Detailed Description

Definition at line 58 of file simpleaaclip.cpp.

Member Enumeration Documentation

◆ SkGeomTypes

Enumerator
kRect_GeomType 
kPath_GeomType 
kAAClip_GeomType 

Definition at line 60 of file simpleaaclip.cpp.

Constructor & Destructor Documentation

◆ SimpleClipGM()

skiagm::SimpleClipGM::SimpleClipGM ( SkGeomTypes  geomType)
inline

Definition at line 66 of file simpleaaclip.cpp.

67 : fGeomType(geomType) {
68 }

Member Function Documentation

◆ buildRgn()

void skiagm::SimpleClipGM::buildRgn ( SkAAClip clip,
SkClipOp  op 
)
inlineprotected

Definition at line 86 of file simpleaaclip.cpp.

86 {
87 clip->setPath(fBasePath, fBasePath.getBounds().roundOut(), true);
88
89 SkAAClip clip2;
90 clip2.setPath(fRectPath, fRectPath.getBounds().roundOut(), true);
91 clip->op(clip2, op);
92 }
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition: SkPath.cpp:3892
bool setPath(const SkPath &, const SkIRect &bounds, bool doAA=true)
Definition: SkAAClip.cpp:1401
const SkRect & getBounds() const
Definition: SkPath.cpp:430
void roundOut(SkIRect *dst) const
Definition: SkRect.h:1241

◆ drawOrig()

void skiagm::SimpleClipGM::drawOrig ( SkCanvas canvas)
inlineprotected

Definition at line 94 of file simpleaaclip.cpp.

94 {
96
98 paint.setColor(SK_ColorBLACK);
99
100 canvas->drawRect(fBase, paint);
101 canvas->drawRect(fRect, paint);
102 }
constexpr SkColor SK_ColorBLACK
Definition: SkColor.h:103
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194
const Paint & paint
Definition: color_source.cc:38

◆ drawPathsOped()

void skiagm::SimpleClipGM::drawPathsOped ( SkCanvas canvas,
SkClipOp  op,
SkColor  color 
)
inlineprotected

Definition at line 116 of file simpleaaclip.cpp.

116 {
117
118 this->drawOrig(canvas);
119
120 canvas->save();
121
122 // create the clip mask with the supplied boolean op
123 if (kPath_GeomType == fGeomType) {
124 // path-based case
125 canvas->clipPath(fBasePath, true);
126 canvas->clipPath(fRectPath, op, true);
127 } else {
128 // rect-based case
129 canvas->clipRect(fBase, true);
130 canvas->clipRect(fRect, op, true);
131 }
132
133 // draw a rect that will entirely cover the clip mask area
135 paint.setColor(color);
136
138 SkIntToScalar(180), SkIntToScalar(180));
139
140 canvas->drawRect(r, paint);
141
142 canvas->restore();
143 }
#define SkIntToScalar(x)
Definition: SkScalar.h:57
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
Definition: SkCanvas.cpp:1361
void restore()
Definition: SkCanvas.cpp:461
void clipPath(const SkPath &path, SkClipOp op, bool doAntiAlias)
Definition: SkCanvas.cpp:1456
int save()
Definition: SkCanvas.cpp:447
void drawOrig(SkCanvas *canvas)
DlColor color
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
Definition: SkRect.h:646

◆ drawRgnOped()

void skiagm::SimpleClipGM::drawRgnOped ( SkCanvas canvas,
SkClipOp  op,
SkColor  color 
)
inlineprotected

Definition at line 104 of file simpleaaclip.cpp.

104 {
105
107
108 this->buildRgn(&clip, op);
109 this->drawOrig(canvas);
110
112 paint.setColor(color);
113 paint_rgn(canvas, clip, paint);
114 }
void buildRgn(SkAAClip *clip, SkClipOp op)
static void paint_rgn(SkCanvas *canvas, const SkAAClip &clip, const SkPaint &paint)

◆ getISize()

SkISize skiagm::SimpleClipGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 154 of file simpleaaclip.cpp.

154{ return SkISize::Make(500, 240); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

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

Implements skiagm::GM.

Definition at line 145 of file simpleaaclip.cpp.

145 {
146 SkString str;
147 str.printf("simpleaaclip_%s",
148 kRect_GeomType == fGeomType ? "rect" :
149 (kPath_GeomType == fGeomType ? "path" :
150 "aaclip"));
151 return str;
152 }
void printf(const char format[],...) SK_PRINTF_LIKE(2
Definition: SkString.cpp:534

◆ onDraw()

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

Reimplemented from skiagm::GM.

Definition at line 156 of file simpleaaclip.cpp.

156 {
157
158 const struct {
159 SkColor fColor;
160 const char* fName;
161 SkClipOp fOp;
162 } gOps[] = {
163 {SK_ColorBLACK, "Difference", SkClipOp::kDifference},
164 {SK_ColorRED, "Intersect", SkClipOp::kIntersect},
165 };
166
167 SkPaint textPaint;
169 int xOff = 0;
170
171 for (size_t op = 0; op < std::size(gOps); op++) {
172 canvas->drawString(gOps[op].fName, 75.0f, 50.0f, font, textPaint);
173
174 if (kAAClip_GeomType == fGeomType) {
175 this->drawRgnOped(canvas, gOps[op].fOp, gOps[op].fColor);
176 } else {
177 this->drawPathsOped(canvas, gOps[op].fOp, gOps[op].fColor);
178 }
179
180 if (xOff >= 400) {
181 canvas->translate(SkIntToScalar(-400), SkIntToScalar(250));
182 xOff = 0;
183 } else {
184 canvas->translate(SkIntToScalar(200), 0);
185 xOff += 200;
186 }
187 }
188 }
SkClipOp
Definition: SkClipOp.h:13
uint32_t SkColor
Definition: SkColor.h:37
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void drawString(const char str[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
Definition: SkCanvas.h:1803
Definition: SkFont.h:35
void drawRgnOped(SkCanvas *canvas, SkClipOp op, SkColor color)
void drawPathsOped(SkCanvas *canvas, SkClipOp op, SkColor color)
sk_sp< SkTypeface > DefaultPortableTypeface()
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
font
Font Metadata and Metrics.
const char * fName

◆ onOnceBeforeDraw()

void skiagm::SimpleClipGM::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 71 of file simpleaaclip.cpp.

71 {
72 // offset the rects a bit so we get anti-aliasing in the rect case
73 fBase.setLTRB(100.65f,
74 100.65f,
75 150.65f,
76 150.65f);
77 fRect = fBase;
78 fRect.inset(5, 5);
79 fRect.offset(25, 25);
80
81 fBasePath.addRoundRect(fBase, SkIntToScalar(5), SkIntToScalar(5));
82 fRectPath.addRoundRect(fRect, SkIntToScalar(5), SkIntToScalar(5));
83 INHERITED::setBGColor(0xFFDDDDDD);
84 }
SkPath & addRoundRect(const SkRect &rect, SkScalar rx, SkScalar ry, SkPathDirection dir=SkPathDirection::kCW)
Definition: SkPath.cpp:1093
void setBGColor(SkColor)
Definition: gm.cpp:159
void inset(float dx, float dy)
Definition: SkRect.h:1060
void offset(float dx, float dy)
Definition: SkRect.h:1016
void setLTRB(float left, float top, float right, float bottom)
Definition: SkRect.h:865

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