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

Public Member Functions

 StrokeRectGM ()
 
- 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 58 of file strokerect.cpp.

Constructor & Destructor Documentation

◆ StrokeRectGM()

StrokeRectGM::StrokeRectGM ( )
inline

Definition at line 60 of file strokerect.cpp.

60{}

Member Function Documentation

◆ getISize()

SkISize StrokeRectGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 65 of file strokerect.cpp.

65{ return SkISize::Make(1400, 740); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition SkSize.h:20

◆ getName()

SkString StrokeRectGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 63 of file strokerect.cpp.

63{ return SkString("strokerect"); }

◆ onDraw()

void StrokeRectGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 67 of file strokerect.cpp.

67 {
68 canvas->drawColor(SK_ColorWHITE);
69 canvas->translate(STROKE_WIDTH*3/2, STROKE_WIDTH*3/2);
70
73 paint.setStrokeWidth(STROKE_WIDTH);
74
75 constexpr SkPaint::Join gJoins[] = {
77 };
78
79 constexpr SkScalar W = 80;
80 constexpr SkScalar H = 80;
81 constexpr SkRect gRects[] = {
82 { 0, 0, W, H },
83 { W, 0, 0, H },
84 { 0, H, W, 0 },
85 { 0, 0, STROKE_WIDTH, H },
86 { 0, 0, W, STROKE_WIDTH },
87 { 0, 0, STROKE_WIDTH/2, STROKE_WIDTH/2 },
88 { 0, 0, W, 0 },
89 { 0, 0, 0, H },
90 { 0, 0, 0, 0 },
91 { 0, 0, W, FLT_EPSILON },
92 { 0, 0, FLT_EPSILON, H },
93 { 0, 0, FLT_EPSILON, FLT_EPSILON },
94 };
95
96 for (int doFill = 0; doFill <= 1; ++doFill) {
97 for (size_t i = 0; i < std::size(gJoins); ++i) {
98 SkPaint::Join join = gJoins[i];
99 paint.setStrokeJoin(join);
100
101 SkAutoCanvasRestore acr(canvas, true);
102 for (size_t j = 0; j < std::size(gRects); ++j) {
103 const SkRect& r = gRects[j];
104
105 SkPath path, fillPath;
106 path.addRect(r);
107 skpathutils::FillPathWithPaint(path, paint, &fillPath);
108 draw_path(canvas, fillPath, r, join, doFill);
109
110 canvas->translate(W + 2 * STROKE_WIDTH, 0);
111 }
112 acr.restore();
113 canvas->translate(0, H + 2 * STROKE_WIDTH);
114 }
116 }
117 }
constexpr SkColor SK_ColorWHITE
Definition SkColor.h:122
#define W
Definition aaa.cpp:17
void translate(SkScalar dx, SkScalar dy)
void drawColor(SkColor color, SkBlendMode mode=SkBlendMode::kSrcOver)
Definition SkCanvas.h:1182
@ kStroke_Style
set to stroke geometry
Definition SkPaint.h:194
@ kStrokeAndFill_Style
sets to stroke and fill geometry
Definition SkPaint.h:195
@ kRound_Join
adds circle
Definition SkPaint.h:360
@ kMiter_Join
extends to miter limit
Definition SkPaint.h:359
@ kBevel_Join
connects outside edges
Definition SkPaint.h:361
const Paint & paint
float SkScalar
Definition extension.cpp:12
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
SK_API bool FillPathWithPaint(const SkPath &src, const SkPaint &paint, SkPath *dst, const SkRect *cullRect, SkScalar resScale=1)
SINT Vec< 2 *N, T > join(const Vec< N, T > &lo, const Vec< N, T > &hi)
Definition SkVx.h:242
#define STROKE_WIDTH
static void draw_path(SkCanvas *canvas, const SkPath &path, const SkRect &rect, SkPaint::Join join, int doFill)
Definition SkMD5.cpp:130

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