Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Static Protected Member Functions | List of all members
skiagm::StrokeRectsGM Class Reference
Inheritance diagram for skiagm::StrokeRectsGM:
skiagm::GM

Public Member Functions

 StrokeRectsGM (bool rotated)
 
- 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 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 bool onAnimate (double)
 
virtual bool onGetControls (SkMetaData *)
 
virtual void onSetControls (const SkMetaData &)
 
GraphiteTestContextgraphiteTestContext () const
 

Static Protected Member Functions

static void rnd_rect (SkRect *r, 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 26 of file strokerects.cpp.

Constructor & Destructor Documentation

◆ StrokeRectsGM()

skiagm::StrokeRectsGM::StrokeRectsGM ( bool  rotated)
inline

Definition at line 28 of file strokerects.cpp.

28: fRotated(rotated) {}

Member Function Documentation

◆ getISize()

SkISize skiagm::StrokeRectsGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 39 of file strokerects.cpp.

39{ return SkISize::Make(W * 2, H * 2); }
#define W
Definition aaa.cpp:17
Definition SkMD5.cpp:130
static constexpr SkISize Make(int32_t w, int32_t h)
Definition SkSize.h:20

◆ getName()

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

Implements skiagm::GM.

Definition at line 31 of file strokerects.cpp.

31 {
32 if (fRotated) {
33 return SkString("strokerects_rotated");
34 } else {
35 return SkString("strokerects");
36 }
37 }

◆ onDraw()

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

Reimplemented from skiagm::GM.

Definition at line 53 of file strokerects.cpp.

53 {
54 if (fRotated) {
55 canvas->rotate(45.f, SW, SH);
56 }
57
60
61 for (int y = 0; y < 2; y++) {
62 paint.setAntiAlias(!!y);
63 for (int x = 0; x < 2; x++) {
64 paint.setStrokeWidth(x * SkIntToScalar(3));
65
66 SkAutoCanvasRestore acr(canvas, true);
67 canvas->translate(SW * x, SH * y);
70 , SW - SkIntToScalar(2), SH - SkIntToScalar(2)
71 ));
72
73 SkRandom rand;
74 for (int i = 0; i < N; i++) {
75 SkRect r;
76 rnd_rect(&r, rand);
77 canvas->drawRect(r, paint);
78 }
79 }
80 }
81 }
#define SkIntToScalar(x)
Definition SkScalar.h:57
#define N
Definition beziers.cpp:19
void drawRect(const SkRect &rect, const SkPaint &paint)
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
void translate(SkScalar dx, SkScalar dy)
void rotate(SkScalar degrees)
@ kStroke_Style
set to stroke geometry
Definition SkPaint.h:194
static void rnd_rect(SkRect *r, SkRandom &rand)
const Paint & paint
double y
double x
constexpr SkScalar SH
constexpr SkScalar SW
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
Definition SkRect.h:646

◆ rnd_rect()

static void skiagm::StrokeRectsGM::rnd_rect ( SkRect r,
SkRandom rand 
)
inlinestaticprotected

Definition at line 41 of file strokerects.cpp.

41 {
42 SkScalar x = rand.nextUScalar1() * W;
43 SkScalar y = rand.nextUScalar1() * H;
44 SkScalar w = rand.nextUScalar1() * (W >> 2);
45 SkScalar h = rand.nextUScalar1() * (H >> 2);
46 SkScalar hoffset = rand.nextSScalar1();
47 SkScalar woffset = rand.nextSScalar1();
48
49 r->setXYWH(x, y, w, h);
50 r->offset(-w/2 + woffset, -h/2 + hoffset);
51 }
SkScalar nextUScalar1()
Definition SkRandom.h:101
SkScalar nextSScalar1()
Definition SkRandom.h:113
#define H
float SkScalar
Definition extension.cpp:12
SkScalar w
SkScalar h
void setXYWH(float x, float y, float width, float height)
Definition SkRect.h:931
void offset(float dx, float dy)
Definition SkRect.h:1016

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