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

Public Types

enum  ClosureType { TotallyNonClosed , FakeCloseCorner , FakeCloseMiddle , kClosureTypeCount }
 
- Public Types inherited from skiagm::GM
enum  Mode { kGM_Mode , kSample_Mode , kBench_Mode }
 
using DrawResult = skiagm::DrawResult
 
using GraphiteTestContext = skiatest::graphite::GraphiteTestContext
 

Public Member Functions

 NonClosedPathsGM ()
 
- 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 SkPath MakePath (ClosureType type)
 
static void SetLocation (SkCanvas *canvas, int counter, int lineNum)
 

Additional Inherited Members

- Static Public Attributes inherited from skiagm::GM
static constexpr char kErrorMsg_DrawSkippedGpuOnly []
 

Detailed Description

Definition at line 22 of file nonclosedpaths.cpp.

Member Enumeration Documentation

◆ ClosureType

Enumerator
TotallyNonClosed 
FakeCloseCorner 
FakeCloseMiddle 
kClosureTypeCount 

Definition at line 26 of file nonclosedpaths.cpp.

26 {
27 TotallyNonClosed, // The last point doesn't coincide with the first one in the contour.
28 // The path looks not closed at all.
29
30 FakeCloseCorner, // The last point coincides with the first one at a corner.
31 // The path looks closed, but final rendering has 2 ends with cap.
32
33 FakeCloseMiddle, // The last point coincides with the first one in the middle of a line.
34 // The path looks closed, and the final rendering looks closed too.
35
37 };

Constructor & Destructor Documentation

◆ NonClosedPathsGM()

skiagm::NonClosedPathsGM::NonClosedPathsGM ( )
inline

Definition at line 24 of file nonclosedpaths.cpp.

24{}

Member Function Documentation

◆ getISize()

SkISize skiagm::NonClosedPathsGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 43 of file nonclosedpaths.cpp.

43{ return SkISize::Make(1220, 1920); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

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

Implements skiagm::GM.

Definition at line 40 of file nonclosedpaths.cpp.

40{ return SkString("nonclosedpaths"); }

◆ MakePath()

static SkPath skiagm::NonClosedPathsGM::MakePath ( ClosureType  type)
inlinestaticprotected

Definition at line 47 of file nonclosedpaths.cpp.

47 {
49 if (FakeCloseMiddle == type) {
50 path.moveTo(30, 50);
51 path.lineTo(30, 30);
52 } else {
53 path.moveTo(30, 30);
54 }
55 path.lineTo(70, 30);
56 path.lineTo(70, 70);
57 path.lineTo(30, 70);
58 path.lineTo(30, 50);
59 if (FakeCloseCorner == type) {
60 path.lineTo(30, 30);
61 }
62 return path.detach();
63 }
GLenum type
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

◆ onDraw()

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

Reimplemented from skiagm::GM.

Definition at line 72 of file nonclosedpaths.cpp.

72 {
73 // Stroke widths are:
74 // 0(may use hairline rendering), 10(common case for stroke-style)
75 // 40 and 50(>= geometry width/height, make the contour filled in fact)
76 constexpr int kStrokeWidth[] = {0, 10, 40, 50};
77 int numWidths = std::size(kStrokeWidth);
78
79 constexpr SkPaint::Style kStyle[] = {
81 };
82
83 constexpr SkPaint::Cap kCap[] = {
85 };
86
87 constexpr SkPaint::Join kJoin[] = {
89 };
90
91 constexpr ClosureType kType[] = {
93 };
94
95 int counter = 0;
97 paint.setAntiAlias(true);
98
99 // For stroke style painter and fill-and-stroke style painter
100 for (size_t type = 0; type < kClosureTypeCount; ++type) {
101 for (size_t style = 0; style < std::size(kStyle); ++style) {
102 for (size_t cap = 0; cap < std::size(kCap); ++cap) {
103 for (size_t join = 0; join < std::size(kJoin); ++join) {
104 for (int width = 0; width < numWidths; ++width) {
105 canvas->save();
106 SetLocation(canvas, counter, SkPaint::kJoinCount * numWidths);
107
108 SkPath path = MakePath(kType[type]);
109
110 paint.setStyle(kStyle[style]);
111 paint.setStrokeCap(kCap[cap]);
112 paint.setStrokeJoin(kJoin[join]);
113 paint.setStrokeWidth(SkIntToScalar(kStrokeWidth[width]));
114
115 canvas->drawPath(path, paint);
116 canvas->restore();
117 ++counter;
118 }
119 }
120 }
121 }
122 }
123
124 // For fill style painter
125 paint.setStyle(SkPaint::kFill_Style);
126 for (size_t type = 0; type < kClosureTypeCount; ++type) {
127 canvas->save();
128 SetLocation(canvas, counter, SkPaint::kJoinCount * numWidths);
129
130 SkPath path = MakePath(kType[type]);
131
132 canvas->drawPath(path, paint);
133 canvas->restore();
134 ++counter;
135 }
136 }
#define SkIntToScalar(x)
Definition: SkScalar.h:57
void restore()
Definition: SkCanvas.cpp:461
int save()
Definition: SkCanvas.cpp:447
void drawPath(const SkPath &path, const SkPaint &paint)
Definition: SkCanvas.cpp:1747
@ kRound_Cap
adds circle
Definition: SkPaint.h:335
@ kButt_Cap
no stroke extension
Definition: SkPaint.h:334
@ kSquare_Cap
adds square
Definition: SkPaint.h:336
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194
@ kFill_Style
set to fill geometry
Definition: SkPaint.h:193
@ kStrokeAndFill_Style
sets to stroke and fill geometry
Definition: SkPaint.h:195
static constexpr int kJoinCount
Definition: SkPaint.h:368
@ 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
Definition: SkPath.h:59
SkScalar width()
Definition: gm.h:159
static void SetLocation(SkCanvas *canvas, int counter, int lineNum)
static SkPath MakePath(ClosureType type)
const Paint & paint
Definition: color_source.cc:38
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
static constexpr float kStrokeWidth
static SkString join(const CommandLineFlags::StringArray &)
Definition: skpbench.cpp:741

◆ SetLocation()

static void skiagm::NonClosedPathsGM::SetLocation ( SkCanvas canvas,
int  counter,
int  lineNum 
)
inlinestaticprotected

Definition at line 66 of file nonclosedpaths.cpp.

66 {
67 SkScalar x = SK_Scalar1 * 100 * (counter % lineNum) + 10 + SK_Scalar1 / 4;
68 SkScalar y = SK_Scalar1 * 100 * (counter / lineNum) + 10 + 3 * SK_Scalar1 / 4;
69 canvas->translate(x, y);
70 }
#define SK_Scalar1
Definition: SkScalar.h:18
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
float SkScalar
Definition: extension.cpp:12
double y
double x

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