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

Public Member Functions

 AddArcGM ()
 
- 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 25 of file addarc.cpp.

Constructor & Destructor Documentation

◆ AddArcGM()

AddArcGM::AddArcGM ( )
inline

Definition at line 27 of file addarc.cpp.

27: fRotate(0) {}

Member Function Documentation

◆ getISize()

SkISize AddArcGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 32 of file addarc.cpp.

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

◆ getName()

SkString AddArcGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 30 of file addarc.cpp.

30{ return SkString("addarc"); }

◆ onAnimate()

bool AddArcGM::onAnimate ( double  nanos)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 65 of file addarc.cpp.

65 {
66 fRotate = TimeUtils::Scaled(1e-9 * nanos, 1, 360);
67 return true;
68 }
static float Scaled(float time, float speed, float period=0)
Definition: TimeUtils.h:27

◆ onDraw()

void AddArcGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 34 of file addarc.cpp.

34 {
35 canvas->translate(20, 20);
36
37 SkRect r = SkRect::MakeWH(1000, 1000);
38
40 paint.setAntiAlias(true);
41 paint.setStroke(true);
42 paint.setStrokeWidth(15);
43
44 const SkScalar inset = paint.getStrokeWidth() + 4;
45 const SkScalar sweepAngle = 345;
46 SkRandom rand;
47
48 SkScalar sign = 1;
49 while (r.width() > paint.getStrokeWidth() * 3) {
50 paint.setColor(ToolUtils::color_to_565(rand.nextU() | (0xFF << 24)));
51 SkScalar startAngle = rand.nextUScalar1() * 360;
52
53 SkScalar speed = SkScalarSqrt(16 / r.width()) * 0.5f;
54 startAngle += fRotate * 360 * speed * sign;
55
57 path.addArc(r, startAngle, sweepAngle);
58 canvas->drawPath(path.detach().setIsVolatile(true), paint);
59
60 r.inset(inset, inset);
61 sign = -sign;
62 }
63 }
static int sign(SkScalar x)
Definition: SkPath.cpp:2205
#define SkScalarSqrt(x)
Definition: SkScalar.h:42
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void drawPath(const SkPath &path, const SkPaint &paint)
Definition: SkCanvas.cpp:1747
uint32_t nextU()
Definition: SkRandom.h:42
SkScalar nextUScalar1()
Definition: SkRandom.h:101
const Paint & paint
Definition: color_source.cc:38
float SkScalar
Definition: extension.cpp:12
SkScalar startAngle
Definition: SkRecords.h:250
SkScalar sweepAngle
Definition: SkRecords.h:251
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
static SkRect inset(const SkRect &r)
void inset(float dx, float dy)
Definition: SkRect.h:1060
constexpr float width() const
Definition: SkRect.h:762
static constexpr SkRect MakeWH(float w, float h)
Definition: SkRect.h:609

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