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

Public Member Functions

 StrokedLinesGM (bool useDrawPath)
 
- 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

SkString getName () const override
 
SkISize getISize () override
 
void onOnceBeforeDraw () 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
 
- Static Public Attributes inherited from skiagm::GM
static constexpr char kErrorMsg_DrawSkippedGpuOnly []
 

Detailed Description

Definition at line 125 of file strokedlines.cpp.

Constructor & Destructor Documentation

◆ StrokedLinesGM()

skiagm::StrokedLinesGM::StrokedLinesGM ( bool  useDrawPath)
inline

Definition at line 127 of file strokedlines.cpp.

127 : fUseDrawPath(useDrawPath) {
128 this->setBGColor(ToolUtils::color_to_565(0xFF1A65D7));
129 }
void setBGColor(SkColor)
Definition: gm.cpp:159
SkColor color_to_565(SkColor color)
Definition: ToolUtils.cpp:139

Member Function Documentation

◆ getISize()

SkISize skiagm::StrokedLinesGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 141 of file strokedlines.cpp.

141 {
142 return SkISize::Make(kNumColumns * (2*kRadius+2*kPad), kNumRows * (2*kRadius+2*kPad));
143 }
constexpr int kPad
constexpr int kNumColumns
constexpr int kNumRows
constexpr int kRadius
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

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

Implements skiagm::GM.

Definition at line 132 of file strokedlines.cpp.

132 {
133 // To preserve history, useDrawPath==true has no suffix.
134 SkString name{"strokedlines"};
135 if (!fUseDrawPath) {
136 name.append("_drawPoints");
137 }
138 return name;
139 }
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32

◆ onDraw()

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

Reimplemented from skiagm::GM.

Definition at line 225 of file strokedlines.cpp.

225 {
226 canvas->translate(0, kRadius+kPad);
227
228 for (int i = 0; i < fPaints.size(); ++i) {
229 int saveCount = canvas->save();
230 draw_row(canvas, fPaints[i], SkMatrix::I(), fUseDrawPath);
231 canvas->restoreToCount(saveCount);
232
233 canvas->translate(0, 2*(kRadius+kPad));
234 }
235
236 for (int i = 0; i < fMatrices.size(); ++i) {
237 int saveCount = canvas->save();
238 draw_row(canvas, fPaints[0], fMatrices[i], fUseDrawPath);
239 canvas->restoreToCount(saveCount);
240
241 canvas->translate(0, 2*(kRadius+kPad));
242 }
243 }
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void restoreToCount(int saveCount)
Definition: SkCanvas.cpp:478
int save()
Definition: SkCanvas.cpp:447
static const SkMatrix & I()
Definition: SkMatrix.cpp:1544
int size() const
Definition: SkTArray.h:421
static void draw_row(SkCanvas *canvas, const SkPaint &paint, const SkMatrix &localMatrix, bool useDrawPath)

◆ onOnceBeforeDraw()

void skiagm::StrokedLinesGM::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 145 of file strokedlines.cpp.

145 {
146 // paints
147 {
148 // basic white
149 SkPaint p;
150 p.setColor(SK_ColorWHITE);
151 fPaints.push_back(p);
152 }
153 {
154 // gradient
156 SkPoint pts[] = { {-kRadius-kPad, -kRadius-kPad }, { kRadius+kPad, kRadius+kPad } };
157
158 SkPaint p;
159 p.setShader(SkGradientShader::MakeLinear(pts, colors, nullptr, 2, SkTileMode::kClamp));
160
161 fPaints.push_back(p);
162 }
163 {
164 // dashing
165 SkScalar intervals[] = { kStrokeWidth, kStrokeWidth };
166 int intervalCount = (int) std::size(intervals);
167 SkPaint p;
168 p.setColor(SK_ColorWHITE);
169 p.setPathEffect(SkDashPathEffect::Make(intervals, intervalCount, kStrokeWidth));
170
171 fPaints.push_back(p);
172 }
173 {
174 // Bitmap shader
175 SkBitmap bm;
176 bm.allocN32Pixels(2, 2);
177 *bm.getAddr32(0, 0) = *bm.getAddr32(1, 1) = 0xFFFFFFFF;
178 *bm.getAddr32(1, 0) = *bm.getAddr32(0, 1) = 0x0;
179
180 SkMatrix m;
181 m.setRotate(12.0f);
182 m.preScale(3.0f, 3.0f);
183
184 SkPaint p;
186 SkSamplingOptions(), m));
187 fPaints.push_back(p);
188 }
189 {
190 // blur
191 SkPaint p;
192 p.setColor(SK_ColorWHITE);
193 p.setMaskFilter(SkMaskFilter::MakeBlur(kOuter_SkBlurStyle, 3.0f));
194 fPaints.push_back(p);
195 }
196
197 // matrices
198 {
199 // rotation
200 SkMatrix m;
201 m.setRotate(12.0f);
202
203 fMatrices.push_back(m);
204 }
205 {
206 // skew
207 SkMatrix m;
208 m.setSkew(0.3f, 0.5f);
209
210 fMatrices.push_back(m);
211 }
212 {
213 // perspective
214 SkMatrix m;
215 m.reset();
216 m.setPerspX(-SK_Scalar1 / 300);
217 m.setPerspY(SK_Scalar1 / 300);
218
219 fMatrices.push_back(m);
220 }
221
222 SkASSERT(kNumRows == fPaints.size() + fMatrices.size());
223 }
#define SkASSERT(cond)
Definition: SkAssert.h:116
@ kOuter_SkBlurStyle
nothing inside, fuzzy outside
Definition: SkBlurTypes.h:14
uint32_t SkColor
Definition: SkColor.h:37
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
constexpr SkColor SK_ColorGREEN
Definition: SkColor.h:131
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
#define SK_Scalar1
Definition: SkScalar.h:18
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
Definition: SkBitmap.cpp:669
void allocN32Pixels(int width, int height, bool isOpaque=false)
Definition: SkBitmap.cpp:232
uint32_t * getAddr32(int x, int y) const
Definition: SkBitmap.h:1260
static sk_sp< SkPathEffect > Make(const SkScalar intervals[], int count, SkScalar phase)
static sk_sp< SkShader > MakeLinear(const SkPoint pts[2], const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, uint32_t flags=0, const SkMatrix *localMatrix=nullptr)
static sk_sp< SkMaskFilter > MakeBlur(SkBlurStyle style, SkScalar sigma, bool respectCTM=true)
float SkScalar
Definition: extension.cpp:12
PODArray< SkColor > colors
Definition: SkRecords.h:276
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
static constexpr float kStrokeWidth

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