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

Public Member Functions

 DashCircle2GM ()
 
- 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 onDraw (SkCanvas *canvas) override
 
bool onAnimate (double nanos) 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
 

Protected Attributes

SkScalar fPhaseDegrees = 12.f
 

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 122 of file dashcircle.cpp.

Constructor & Destructor Documentation

◆ DashCircle2GM()

DashCircle2GM::DashCircle2GM ( )
inline

Definition at line 124 of file dashcircle.cpp.

124{}

Member Function Documentation

◆ getISize()

SkISize DashCircle2GM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 129 of file dashcircle.cpp.

129{ return SkISize::Make(635, 900); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

SkString DashCircle2GM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 127 of file dashcircle.cpp.

127{ return SkString("dashcircle2"); }

◆ onAnimate()

bool DashCircle2GM::onAnimate ( double  nanos)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 228 of file dashcircle.cpp.

228 {
229 fPhaseDegrees = 1e-9 * nanos;
230 return true;
231 }
SkScalar fPhaseDegrees
Definition: dashcircle.cpp:234

◆ onDraw()

void DashCircle2GM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 131 of file dashcircle.cpp.

131 {
132 // These intervals are defined relative to tau.
133 static constexpr SkScalar kIntervals[][2]{
134 {0.333f, 0.333f},
135 {0.015f, 0.015f},
136 {0.01f , 0.09f },
137 {0.097f, 0.003f},
138 {0.02f , 0.04f },
139 {0.1f , 0.2f },
140 {0.25f , 0.25f },
141 {0.6f , 0.7f }, // adds to > 1
142 {1.2f , 0.8f }, // on is > 1
143 {0.1f , 1.1f }, // off is > 1*/
144 };
145
146 static constexpr int kN = std::size(kIntervals);
147 static constexpr SkScalar kRadius = 20.f;
148 static constexpr SkScalar kStrokeWidth = 15.f;
149 static constexpr SkScalar kPad = 5.f;
150 static constexpr SkRect kCircle = {-kRadius, -kRadius, kRadius, kRadius};
151
152 static constexpr SkScalar kThinRadius = kRadius * 1.5;
153 static constexpr SkRect kThinCircle = {-kThinRadius, -kThinRadius,
154 kThinRadius, kThinRadius};
155 static constexpr SkScalar kThinStrokeWidth = 0.4f;
156
157 sk_sp<SkPathEffect> deffects[std::size(kIntervals)];
158 sk_sp<SkPathEffect> thinDEffects[std::size(kIntervals)];
159 for (int i = 0; i < kN; ++i) {
160 static constexpr SkScalar kTau = 2 * SK_ScalarPI;
161 static constexpr SkScalar kCircumference = kRadius * kTau;
162 SkScalar scaledIntervals[2] = {kCircumference * kIntervals[i][0],
163 kCircumference * kIntervals[i][1]};
164 deffects[i] = SkDashPathEffect::Make(
165 scaledIntervals, 2, kCircumference * fPhaseDegrees * kTau / 360.f);
166 static constexpr SkScalar kThinCircumference = kThinRadius * kTau;
167 scaledIntervals[0] = kThinCircumference * kIntervals[i][0];
168 scaledIntervals[1] = kThinCircumference * kIntervals[i][1];
169 thinDEffects[i] = SkDashPathEffect::Make(
170 scaledIntervals, 2, kThinCircumference * fPhaseDegrees * kTau / 360.f);
171 }
172
174 rotate.setRotate(25.f);
175 const SkMatrix kMatrices[]{
176 SkMatrix::I(),
177 SkMatrix::Scale(1.2f, 1.2f),
178 SkMatrix::MakeAll(1, 0, 0, 0, -1, 0, 0, 0, 1), // y flipper
179 SkMatrix::MakeAll(-1, 0, 0, 0, 1, 0, 0, 0, 1), // x flipper
180 SkMatrix::Scale(0.7f, 0.7f),
181 rotate,
183 SkMatrix::Concat(SkMatrix::MakeAll(-1, 0, 0, 0, 1, 0, 0, 0, 1), rotate),
184 rotate)
185 };
186
188 paint.setAntiAlias(true);
189 paint.setStrokeWidth(kStrokeWidth);
190 paint.setStroke(true);
191
192 // Compute the union of bounds of all of our test cases.
194 const SkRect kBounds = kThinCircle.makeOutset(kThinStrokeWidth / 2.f,
195 kThinStrokeWidth / 2.f);
196 for (const auto& m : kMatrices) {
197 SkRect devBounds;
198 m.mapRect(&devBounds, kBounds);
199 bounds.join(devBounds);
200 }
201
202 canvas->save();
203 canvas->translate(-bounds.fLeft + kPad, -bounds.fTop + kPad);
204 for (size_t i = 0; i < std::size(deffects); ++i) {
205 canvas->save();
206 for (const auto& m : kMatrices) {
207 canvas->save();
208 canvas->concat(m);
209
210 paint.setPathEffect(deffects[i]);
211 paint.setStrokeWidth(kStrokeWidth);
212 canvas->drawOval(kCircle, paint);
213
214 paint.setPathEffect(thinDEffects[i]);
215 paint.setStrokeWidth(kThinStrokeWidth);
216 canvas->drawOval(kThinCircle, paint);
217
218 canvas->restore();
219 canvas->translate(bounds.width() + kPad, 0);
220 }
221 canvas->restore();
222 canvas->translate(0, bounds.height() + kPad);
223 }
224 canvas->restore();
225 }
static bool rotate(const SkDCubic &cubic, int zero, int index, SkDCubic &rotPath)
#define SK_ScalarPI
Definition: SkScalar.h:21
constexpr int kPad
void drawOval(const SkRect &oval, const SkPaint &paint)
Definition: SkCanvas.cpp:1698
void restore()
Definition: SkCanvas.cpp:461
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
int save()
Definition: SkCanvas.cpp:447
void concat(const SkMatrix &matrix)
Definition: SkCanvas.cpp:1318
static sk_sp< SkPathEffect > Make(const SkScalar intervals[], int count, SkScalar phase)
static SkMatrix Scale(SkScalar sx, SkScalar sy)
Definition: SkMatrix.h:75
static SkMatrix MakeAll(SkScalar scaleX, SkScalar skewX, SkScalar transX, SkScalar skewY, SkScalar scaleY, SkScalar transY, SkScalar pers0, SkScalar pers1, SkScalar pers2)
Definition: SkMatrix.h:179
static SkMatrix Concat(const SkMatrix &a, const SkMatrix &b)
Definition: SkMatrix.h:1775
static const SkMatrix & I()
Definition: SkMatrix.cpp:1544
const Paint & paint
Definition: color_source.cc:38
float SkScalar
Definition: extension.cpp:12
Optional< SkRect > bounds
Definition: SkRecords.h:189
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
constexpr int kRadius
static constexpr SkRect MakeEmpty()
Definition: SkRect.h:595
SkRect makeOutset(float dx, float dy) const
Definition: SkRect.h:1002

Member Data Documentation

◆ fPhaseDegrees

SkScalar DashCircle2GM::fPhaseDegrees = 12.f
protected

Definition at line 234 of file dashcircle.cpp.


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