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

Public Member Functions

 StringArtGM ()
 
- 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
 

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 30 of file stringart.cpp.

Constructor & Destructor Documentation

◆ StringArtGM()

StringArtGM::StringArtGM ( )
inline

Definition at line 32 of file stringart.cpp.

32: fNumSteps(kMaxNumSteps) {}
constexpr int kMaxNumSteps
Definition: stringart.cpp:25

Member Function Documentation

◆ getISize()

SkISize StringArtGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 37 of file stringart.cpp.

37{ return SkISize::Make(kWidth, kHeight); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

SkString StringArtGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 35 of file stringart.cpp.

35{ return SkString("stringart"); }

◆ onAnimate()

bool StringArtGM::onAnimate ( double  nanos)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 65 of file stringart.cpp.

65 {
66 constexpr SkScalar kDesiredDurationSecs = 3.0f;
67
68 // Make the animation ping-pong back and forth but start in the fully drawn state
69 SkScalar fraction = 1.0f - TimeUtils::Scaled(1e-9 * nanos, 2.0f/kDesiredDurationSecs, 2.0f);
70 if (fraction <= 0.0f) {
71 fraction = -fraction;
72 }
73
74 SkASSERT(fraction >= 0.0f && fraction <= 1.0f);
75
76 fNumSteps = (int) (fraction * kMaxNumSteps);
77 return true;
78 }
#define SkASSERT(cond)
Definition: SkAssert.h:116
float SkScalar
Definition: extension.cpp:12
static float Scaled(float time, float speed, float period=0)
Definition: TimeUtils.h:27

◆ onDraw()

void StringArtGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 39 of file stringart.cpp.

39 {
43 SkScalar length = 5;
44 SkScalar step = angle;
45
47 path.moveTo(center);
48
49 for (int i = 0; i < fNumSteps && length < (SkScalarHalf(size) - 10.f); ++i) {
52 path.lineTo(rp);
54 step += angle;
55 }
56
58 paint.setAntiAlias(true);
60 paint.setColor(ToolUtils::color_to_565(0xFF007700));
61
62 canvas->drawPath(path, paint);
63 }
static int step(int x, SkScalar min, SkScalar max)
Definition: BlurTest.cpp:215
#define SkScalarSin(radians)
Definition: SkScalar.h:45
#define SkScalarHalf(a)
Definition: SkScalar.h:75
#define SkIntToScalar(x)
Definition: SkScalar.h:57
#define SkScalarCos(radians)
Definition: SkScalar.h:46
#define SK_ScalarPI
Definition: SkScalar.h:21
static SkScalar center(float pos0, float pos1)
void drawPath(const SkPath &path, const SkPaint &paint)
Definition: SkCanvas.cpp:1747
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194
Definition: SkPath.h:59
const Paint & paint
Definition: color_source.cc:38
static float min(float r, float g, float b)
Definition: hsl.cpp:48
size_t length
SkColor color_to_565(SkColor color)
Definition: ToolUtils.cpp:139
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57
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 SkScalar kAngle
Definition: stringart.cpp:24
static constexpr SkPoint Make(float x, float y)
Definition: SkPoint_impl.h:173

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