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

Public Member Functions

SkString name () override
 
sk_sp< ShapeRenderertoHairline () override
 
void draw (SkCanvas *canvas, SkPaint *paint, SkScalar tx, SkScalar ty, SkScalar angle) override
 
- Public Member Functions inherited from skiagm::ShapeRenderer
void applyLocalTransform (SkCanvas *canvas, SkScalar tx, SkScalar ty, SkScalar angle)
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Static Public Member Functions

static sk_sp< ShapeRendererMakeLine (bool hairline=false)
 
static sk_sp< ShapeRendererMakeLines (SkScalar depth, bool hairline=false)
 
static sk_sp< ShapeRendererMakeCurve (SkScalar depth, bool hairline=false)
 

Additional Inherited Members

- Static Public Attributes inherited from skiagm::ShapeRenderer
static constexpr SkScalar kTileWidth = 20.f
 
static constexpr SkScalar kTileHeight = 20.f
 

Detailed Description

Definition at line 71 of file ThinAASlide.cpp.

Member Function Documentation

◆ draw()

void skiagm::PathRenderer::draw ( SkCanvas canvas,
SkPaint paint,
SkScalar  tx,
SkScalar  ty,
SkScalar  angle 
)
inlineoverridevirtual

Implements skiagm::ShapeRenderer.

Definition at line 107 of file ThinAASlide.cpp.

107 {
108 SkPath path;
109 path.moveTo(kTileWidth / 2.f, 2.f);
110
111 if (fDepth > 0.f) {
112 path.quadTo(kTileWidth / 2.f + fDepth, kTileHeight / 2.f,
113 kTileWidth / 2.f, kTileHeight - 2.f);
114 } else {
115 if (fDepth < 0.f) {
116 path.lineTo(kTileWidth / 2.f + fDepth, kTileHeight / 2.f);
117 }
118 path.lineTo(kTileWidth / 2.f, kTileHeight - 2.f);
119 }
120
121 if (fHairline) {
122 // Fake thinner hairlines by making it transparent, conflating coverage and alpha
123 SkColor4f color = paint->getColor4f();
124 SkScalar width = paint->getStrokeWidth();
125 if (width > 1.f) {
126 // Can't emulate width larger than a pixel
127 return;
128 }
129 paint->setColor4f({color.fR, color.fG, color.fB, width}, nullptr);
130 paint->setStrokeWidth(0.f);
131 }
132
133 // Adding round caps forces Ganesh to use the path renderer for lines instead of converting
134 // them to rectangles (which are already explicitly tested). However, when not curved, the
135 // GrStyledShape will still find a way to turn it into a rrect draw so it doesn't hit the
136 // path renderer in that condition.
137 paint->setStrokeCap(SkPaint::kRound_Cap);
138 paint->setStrokeJoin(SkPaint::kMiter_Join);
139 paint->setStyle(SkPaint::kStroke_Style);
140
141 this->applyLocalTransform(canvas, tx, ty, angle);
142 canvas->drawPath(path, *paint);
143 }
SkColor4f color
void drawPath(const SkPath &path, const SkPaint &paint)
@ kRound_Cap
adds circle
Definition SkPaint.h:335
@ kStroke_Style
set to stroke geometry
Definition SkPaint.h:194
@ kMiter_Join
extends to miter limit
Definition SkPaint.h:359
static constexpr SkScalar kTileHeight
static constexpr SkScalar kTileWidth
void applyLocalTransform(SkCanvas *canvas, SkScalar tx, SkScalar ty, SkScalar angle)
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
int32_t width

◆ MakeCurve()

static sk_sp< ShapeRenderer > skiagm::PathRenderer::MakeCurve ( SkScalar  depth,
bool  hairline = false 
)
inlinestatic

Definition at line 81 of file ThinAASlide.cpp.

81 {
82 return sk_sp<ShapeRenderer>(new PathRenderer(depth, hairline));
83 }

◆ MakeLine()

static sk_sp< ShapeRenderer > skiagm::PathRenderer::MakeLine ( bool  hairline = false)
inlinestatic

Definition at line 73 of file ThinAASlide.cpp.

73 {
74 return MakeCurve(0.f, hairline);
75 }
static sk_sp< ShapeRenderer > MakeCurve(SkScalar depth, bool hairline=false)

◆ MakeLines()

static sk_sp< ShapeRenderer > skiagm::PathRenderer::MakeLines ( SkScalar  depth,
bool  hairline = false 
)
inlinestatic

Definition at line 77 of file ThinAASlide.cpp.

77 {
78 return MakeCurve(-depth, hairline);
79 }

◆ name()

SkString skiagm::PathRenderer::name ( )
inlineoverridevirtual

Implements skiagm::ShapeRenderer.

Definition at line 85 of file ThinAASlide.cpp.

85 {
87 if (fHairline) {
88 name.append("hairline");
89 if (fDepth > 0.f) {
90 name.appendf("-curve-%.2f", fDepth);
91 }
92 } else if (fDepth > 0.f) {
93 name.appendf("curve-%.2f", fDepth);
94 } else if (fDepth < 0.f) {
95 name.appendf("line-%.2f", -fDepth);
96 } else {
97 name.append("line");
98 }
99
100 return name;
101 }
void append(const char text[])
Definition SkString.h:203
void void void appendf(const char format[],...) SK_PRINTF_LIKE(2
Definition SkString.cpp:550
SkString name() override

◆ toHairline()

sk_sp< ShapeRenderer > skiagm::PathRenderer::toHairline ( )
inlineoverridevirtual

Implements skiagm::ShapeRenderer.

Definition at line 103 of file ThinAASlide.cpp.

103 {
104 return sk_sp<ShapeRenderer>(new PathRenderer(fDepth, true));
105 }

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