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

Public Member Functions

 FillCircleGM ()
 
- 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 165 of file addarc.cpp.

Constructor & Destructor Documentation

◆ FillCircleGM()

FillCircleGM::FillCircleGM ( )
inline

Definition at line 167 of file addarc.cpp.

167: fRotate(0) {}

Member Function Documentation

◆ getISize()

SkISize FillCircleGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 172 of file addarc.cpp.

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

◆ getName()

SkString FillCircleGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 170 of file addarc.cpp.

170{ return SkString("fillcircle"); }

◆ onAnimate()

bool FillCircleGM::onAnimate ( double  nanos)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 202 of file addarc.cpp.

202 {
203 fRotate = TimeUtils::Scaled(1e-9 * nanos, 60, 360);
204 return true;
205 }
static float Scaled(float time, float speed, float period=0)
Definition: TimeUtils.h:27

◆ onDraw()

void FillCircleGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 174 of file addarc.cpp.

174 {
175 canvas->scale(20, 20);
176 canvas->translate(13, 13);
177
179 paint.setAntiAlias(true);
180 paint.setStroke(true);
181 paint.setStrokeWidth(SK_Scalar1 / 2);
182
183 const SkScalar strokeWidth = paint.getStrokeWidth();
184 const SkScalar delta = strokeWidth * 3 / 2;
185 SkRect r = SkRect::MakeXYWH(-12, -12, 24, 24);
186 SkRandom rand;
187
188 // Reset style to fill. We only need stroke stype for producing delta and strokeWidth
189 paint.setStroke(false);
190
191 SkScalar sign = 1;
192 while (r.width() > strokeWidth * 2) {
193 SkAutoCanvasRestore acr(canvas, true);
194 canvas->rotate(fRotate * sign);
195 paint.setColor(ToolUtils::color_to_565(rand.nextU() | (0xFF << 24)));
196 canvas->drawOval(r, paint);
197 r.inset(delta, delta);
198 sign = -sign;
199 }
200 }
static const int strokeWidth
Definition: BlurTest.cpp:60
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: