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

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
 

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
 
- 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
 
- Static Public Attributes inherited from skiagm::GM
static constexpr char kErrorMsg_DrawSkippedGpuOnly []
 

Detailed Description

Definition at line 106 of file strokes.cpp.

Member Function Documentation

◆ getISize()

SkISize ZeroLenStrokesGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 129 of file strokes.cpp.

129{ return SkISize::Make(W, H * 2); }
#define W
Definition: strokes.cpp:33
Definition: SkMD5.cpp:130
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

SkString ZeroLenStrokesGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 127 of file strokes.cpp.

127{ return SkString("zeroPath"); }

◆ onDraw()

void ZeroLenStrokesGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 131 of file strokes.cpp.

131 {
132 SkPaint fillPaint, strokePaint, dashPaint;
133 fillPaint.setAntiAlias(true);
134 strokePaint = fillPaint;
135 strokePaint.setStyle(SkPaint::kStroke_Style);
136 for (int i = 0; i < 2; ++i) {
137 fillPaint.setAlphaf(1.0f);
138 strokePaint.setAlphaf(1.0f);
139 strokePaint.setStrokeWidth(i ? 8.f : 10.f);
141 canvas->save();
142 canvas->translate(10 + i * 100.f, 10);
143 canvas->drawPath(fMoveHfPath, strokePaint);
144 canvas->translate(0, 20);
145 canvas->drawPath(fMoveZfPath, strokePaint);
146 dashPaint = strokePaint;
147 const SkScalar intervals[] = { 0, 10 };
148 dashPaint.setPathEffect(SkDashPathEffect::Make(intervals, 2, 0));
149 SkPath fillPath;
150 skpathutils::FillPathWithPaint(fDashedfPath, dashPaint, &fillPath);
151 canvas->translate(0, 20);
152 canvas->drawPath(fDashedfPath, dashPaint);
153 canvas->translate(0, 20);
154 canvas->drawPath(fRefPath[i * 2], fillPaint);
155 strokePaint.setStrokeWidth(20);
156 strokePaint.setAlphaf(0.5f);
157 canvas->translate(0, 50);
158 canvas->drawPath(fMoveHfPath, strokePaint);
159 canvas->translate(0, 30);
160 canvas->drawPath(fMoveZfPath, strokePaint);
161 canvas->translate(0, 30);
162 fillPaint.setAlphaf(0.5f);
163 canvas->drawPath(fRefPath[1 + i * 2], fillPaint);
164 canvas->translate(0, 30);
165 canvas->drawPath(fCubicPath, strokePaint);
166 canvas->translate(0, 30);
167 canvas->drawPath(fQuadPath, strokePaint);
168 canvas->translate(0, 30);
169 canvas->drawPath(fLinePath, strokePaint);
170 canvas->restore();
171 }
172 }
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
static sk_sp< SkPathEffect > Make(const SkScalar intervals[], int count, SkScalar phase)
@ kRound_Cap
adds circle
Definition: SkPaint.h:335
@ kSquare_Cap
adds square
Definition: SkPaint.h:336
void setStyle(Style style)
Definition: SkPaint.cpp:105
void setAntiAlias(bool aa)
Definition: SkPaint.h:170
void setStrokeCap(Cap cap)
Definition: SkPaint.cpp:179
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194
void setPathEffect(sk_sp< SkPathEffect > pathEffect)
void setStrokeWidth(SkScalar width)
Definition: SkPaint.cpp:159
void setAlphaf(float a)
Definition: SkPaint.cpp:130
Definition: SkPath.h:59
float SkScalar
Definition: extension.cpp:12
SK_API bool FillPathWithPaint(const SkPath &src, const SkPaint &paint, SkPath *dst, const SkRect *cullRect, SkScalar resScale=1)
Definition: SkPathUtils.cpp:23

◆ onOnceBeforeDraw()

void ZeroLenStrokesGM::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 110 of file strokes.cpp.

110 {
111
112 SkAssertResult(SkParsePath::FromSVGString("M0,0h0M10,0h0M20,0h0", &fMoveHfPath));
113 SkAssertResult(SkParsePath::FromSVGString("M0,0zM10,0zM20,0z", &fMoveZfPath));
114 SkAssertResult(SkParsePath::FromSVGString("M0,0h25", &fDashedfPath));
115 SkAssertResult(SkParsePath::FromSVGString("M 0 0 C 0 0 0 0 0 0", &fCubicPath));
116 SkAssertResult(SkParsePath::FromSVGString("M 0 0 Q 0 0 0 0", &fQuadPath));
117 SkAssertResult(SkParsePath::FromSVGString("M 0 0 L 0 0", &fLinePath));
118
119 for (int i = 0; i < 3; ++i) {
120 fRefPath[0].addCircle(i * 10.f, 0, 5);
121 fRefPath[1].addCircle(i * 10.f, 0, 10);
122 fRefPath[2].addRect(i * 10.f - 4, -2, i * 10.f + 4, 6);
123 fRefPath[3].addRect(i * 10.f - 10, -10, i * 10.f + 10, 10);
124 }
125 }
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, std::size(glyphs))==count)
static bool FromSVGString(const char str[], SkPath *)
SkPath & addCircle(SkScalar x, SkScalar y, SkScalar radius, SkPathDirection dir=SkPathDirection::kCW)
Definition: SkPath.cpp:1213
SkPath & addRect(const SkRect &rect, SkPathDirection dir, unsigned start)
Definition: SkPath.cpp:864

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