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

Public Member Functions

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

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 21 of file thinstrokedrects.cpp.

Constructor & Destructor Documentation

◆ ThinStrokedRectsGM()

skiagm::ThinStrokedRectsGM::ThinStrokedRectsGM ( )
inline

Definition at line 23 of file thinstrokedrects.cpp.

23 {
24 this->setBGColor(0xFF000000);
25 }
void setBGColor(SkColor)
Definition gm.cpp:159

Member Function Documentation

◆ getISize()

SkISize skiagm::ThinStrokedRectsGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 30 of file thinstrokedrects.cpp.

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

◆ getName()

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

Implements skiagm::GM.

Definition at line 28 of file thinstrokedrects.cpp.

28{ return SkString("thinstrokedrects"); }

◆ onDraw()

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

Reimplemented from skiagm::GM.

Definition at line 32 of file thinstrokedrects.cpp.

32 {
33
35 paint.setColor(SK_ColorWHITE);
37 paint.setAntiAlias(true);
38
39 constexpr SkRect rect = { 0, 0, 10, 10 };
40 constexpr SkRect rect2 = { 0, 0, 20, 20 };
41
42 constexpr SkScalar gStrokeWidths[] = {
43 4, 2, 1, 0.5f, 0.25f, 0.125f, 0
44 };
45
46 canvas->translate(5, 5);
47 for (int i = 0; i < 8; ++i) {
48 canvas->save();
49 canvas->translate(i*0.125f, i*30.0f);
50 for (size_t j = 0; j < std::size(gStrokeWidths); ++j) {
51 paint.setStrokeWidth(gStrokeWidths[j]);
52 canvas->drawRect(rect, paint);
53 canvas->translate(15, 0);
54 }
55 canvas->restore();
56 }
57
58 // Draw a second time in red with a scale
59 paint.setColor(SK_ColorRED);
60 canvas->translate(0, 15);
61 for (int i = 0; i < 8; ++i) {
62 canvas->save();
63 canvas->translate(i*0.125f, i*30.0f);
64 canvas->scale(0.5f, 0.5f);
65 for (size_t j = 0; j < std::size(gStrokeWidths); ++j) {
66 paint.setStrokeWidth(2.0f * gStrokeWidths[j]);
67 canvas->drawRect(rect2, paint);
68 canvas->translate(30, 0);
69 }
70 canvas->restore();
71 }
72 }
constexpr SkColor SK_ColorRED
Definition SkColor.h:126
constexpr SkColor SK_ColorWHITE
Definition SkColor.h:122
void drawRect(const SkRect &rect, const SkPaint &paint)
void restore()
Definition SkCanvas.cpp:465
void translate(SkScalar dx, SkScalar dy)
int save()
Definition SkCanvas.cpp:451
void scale(SkScalar sx, SkScalar sy)
@ kStroke_Style
set to stroke geometry
Definition SkPaint.h:194
const Paint & paint
float SkScalar
Definition extension.cpp:12
sk_sp< SkBlender > blender SkRect rect
Definition SkRecords.h:350

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