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

Public Member Functions

 StrokeCircleGM ()
 
- 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 115 of file addarc.cpp.

Constructor & Destructor Documentation

◆ StrokeCircleGM()

StrokeCircleGM::StrokeCircleGM ( )
inline

Definition at line 117 of file addarc.cpp.

117: fRotate(0) {}

Member Function Documentation

◆ getISize()

SkISize StrokeCircleGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 122 of file addarc.cpp.

122{ return SkISize::Make(520, 520); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

SkString StrokeCircleGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 120 of file addarc.cpp.

120{ return SkString("strokecircle"); }

◆ onAnimate()

bool StrokeCircleGM::onAnimate ( double  nanos)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 149 of file addarc.cpp.

149 {
150 fRotate = TimeUtils::Scaled(1e-9 * nanos, 60, 360);
151 return true;
152 }
static float Scaled(float time, float speed, float period=0)
Definition: TimeUtils.h:27

◆ onDraw()

void StrokeCircleGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 124 of file addarc.cpp.

124 {
125 canvas->scale(20, 20);
126 canvas->translate(13, 13);
127
129 paint.setAntiAlias(true);
130 paint.setStroke(true);
131 paint.setStrokeWidth(SK_Scalar1 / 2);
132
133 const SkScalar delta = paint.getStrokeWidth() * 3 / 2;
134 SkRect r = SkRect::MakeXYWH(-12, -12, 24, 24);
135 SkRandom rand;
136
137 SkScalar sign = 1;
138 while (r.width() > paint.getStrokeWidth() * 2) {
139 SkAutoCanvasRestore acr(canvas, true);
140 canvas->rotate(fRotate * sign);
141
142 paint.setColor(ToolUtils::color_to_565(rand.nextU() | (0xFF << 24)));
143 canvas->drawOval(r, paint);
144 r.inset(delta, delta);
145 sign = -sign;
146 }
147 }
static int sign(SkScalar x)
Definition: SkPath.cpp:2205
#define SK_Scalar1
Definition: SkScalar.h:18
void drawOval(const SkRect &oval, const SkPaint &paint)
Definition: SkCanvas.cpp:1698
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void rotate(SkScalar degrees)
Definition: SkCanvas.cpp:1300
void scale(SkScalar sx, SkScalar sy)
Definition: SkCanvas.cpp:1289
uint32_t nextU()
Definition: SkRandom.h:42
const Paint & paint
Definition: color_source.cc:38
float SkScalar
Definition: extension.cpp:12
SkColor color_to_565(SkColor color)
Definition: ToolUtils.cpp:139
void inset(float dx, float dy)
Definition: SkRect.h:1060
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659
constexpr float width() const
Definition: SkRect.h:762

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