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

Public Member Functions

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

Static Protected Member Functions

static void fill_pts (SkPoint pts[], size_t n, SkRandom *rand)
 

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 23 of file points.cpp.

Constructor & Destructor Documentation

◆ PointsGM()

skiagm::PointsGM::PointsGM ( )
inline

Definition at line 25 of file points.cpp.

25{}

Member Function Documentation

◆ fill_pts()

static void skiagm::PointsGM::fill_pts ( SkPoint  pts[],
size_t  n,
SkRandom rand 
)
inlinestaticprotected

Definition at line 32 of file points.cpp.

32 {
33 for (size_t i = 0; i < n; i++) {
34 // Compute these independently and store in variables, rather
35 // than in the parameter-passing expression, to get consistent
36 // evaluation order across compilers.
37 SkScalar y = rand->nextUScalar1() * 480;
38 SkScalar x = rand->nextUScalar1() * 640;
39 pts[i].set(x, y);
40 }
41 }
SkScalar nextUScalar1()
Definition: SkRandom.h:101
float SkScalar
Definition: extension.cpp:12
double y
double x
void set(float x, float y)
Definition: SkPoint_impl.h:200

◆ getISize()

SkISize skiagm::PointsGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 30 of file points.cpp.

30{ return SkISize::Make(640, 490); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

SkString skiagm::PointsGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 28 of file points.cpp.

28{ return SkString("points"); }

◆ onDraw()

void skiagm::PointsGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 43 of file points.cpp.

43 {
45
46 SkRandom rand;
47 SkPaint p0, p1, p2, p3;
48 const size_t n = 99;
49
54
58
59 SkPoint* pts = new SkPoint[n];
60 fill_pts(pts, n, &rand);
61
62 canvas->drawPoints(SkCanvas::kPolygon_PointMode, n, pts, p0);
63 canvas->drawPoints(SkCanvas::kLines_PointMode, n, pts, p1);
64 canvas->drawPoints(SkCanvas::kPoints_PointMode, n, pts, p2);
65 canvas->drawPoints(SkCanvas::kPoints_PointMode, n, pts, p3);
66
67 delete[] pts;
68 }
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
constexpr SkColor SK_ColorGREEN
Definition: SkColor.h:131
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
#define SK_Scalar1
Definition: SkScalar.h:18
#define SkIntToScalar(x)
Definition: SkScalar.h:57
void drawPoints(PointMode mode, size_t count, const SkPoint pts[], const SkPaint &paint)
Definition: SkCanvas.cpp:1710
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
@ kLines_PointMode
draw each pair of points as a line segment
Definition: SkCanvas.h:1242
@ kPolygon_PointMode
draw the array of points as a open polygon
Definition: SkCanvas.h:1243
@ kPoints_PointMode
draw each point separately
Definition: SkCanvas.h:1241
@ kRound_Cap
adds circle
Definition: SkPaint.h:335
void setColor(SkColor color)
Definition: SkPaint.cpp:119
void setStrokeCap(Cap cap)
Definition: SkPaint.cpp:179
void setStrokeWidth(SkScalar width)
Definition: SkPaint.cpp:159
static void fill_pts(SkPoint pts[], size_t n, SkRandom *rand)
Definition: points.cpp:32

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