Flutter Engine
The Flutter Engine
Public Member Functions | Public Attributes | List of all members
skottie::internal::TextAdapter::PathInfo Struct Reference

Public Member Functions

void updateContourData ()
 
float pathLength () const
 
SkM44 getMatrix (float distance, SkTextUtils::Align alignment) const
 

Public Attributes

ShapeValue fPath
 
ScalarValue fPathFMargin = 0
 
ScalarValue fPathLMargin = 0
 
ScalarValue fPathPerpendicular = 0
 
ScalarValue fPathReverse = 0
 

Detailed Description

Definition at line 200 of file TextAdapter.cpp.

Member Function Documentation

◆ getMatrix()

SkM44 skottie::internal::TextAdapter::PathInfo::getMatrix ( float  distance,
SkTextUtils::Align  alignment 
) const
inline

Definition at line 237 of file TextAdapter.cpp.

237 {
238 SkASSERT(fPath == fCurrentPath);
239 SkASSERT((fPathReverse != 0) == fCurrentReversed);
240
241 if (!fCurrentMeasure) {
242 return SkM44();
243 }
244
245 const auto path_len = fCurrentMeasure->length();
246
247 // First/last margin adjustment also depends on alignment.
248 switch (alignment) {
250 case SkTextUtils::Align::kCenter_Align: distance += fPathFMargin +
251 fPathLMargin; break;
253 }
254
255 // For closed paths, extranormal distances wrap around the contour.
256 if (fCurrentClosed) {
257 distance = std::fmod(distance, path_len);
258 if (distance < 0) {
259 distance += path_len;
260 }
261 SkASSERT(0 <= distance && distance <= path_len);
262 }
263
264 SkPoint pos;
265 SkVector tan;
266 if (!fCurrentMeasure->getPosTan(distance, &pos, &tan)) {
267 return SkM44();
268 }
269
270 // For open paths, extranormal distances are extrapolated from extremes.
271 // Note:
272 // - getPosTan above clamps to the extremes
273 // - the extrapolation below only kicks in for extranormal values
274 const auto underflow = std::min(0.0f, distance),
275 overflow = std::max(0.0f, distance - path_len);
276 pos += tan*(underflow + overflow);
277
278 auto m = SkM44::Translate(pos.x(), pos.y());
279
280 // The "perpendicular" flag controls whether fragments are positioned and rotated,
281 // or just positioned.
282 if (fPathPerpendicular != 0) {
283 m = m * SkM44::Rotate({0,0,1}, std::atan2(tan.y(), tan.x()));
284 }
285
286 return m;
287 }
@ kRight_Align
@ kLeft_Align
SkPoint pos
#define SkASSERT(cond)
Definition: SkAssert.h:116
bool getPosTan(SkScalar distance, SkPoint *position, SkVector *tangent) const
SkScalar length() const
Definition: SkM44.h:150
static SkM44 Rotate(SkV3 axis, SkScalar radians)
Definition: SkM44.h:239
static SkM44 Translate(SkScalar x, SkScalar y, SkScalar z=0)
Definition: SkM44.h:225
static float max(float r, float g, float b)
Definition: hsl.cpp:49
static float min(float r, float g, float b)
Definition: hsl.cpp:48
constexpr float y() const
Definition: SkPoint_impl.h:187
constexpr float x() const
Definition: SkPoint_impl.h:181

◆ pathLength()

float skottie::internal::TextAdapter::PathInfo::pathLength ( ) const
inline

Definition at line 230 of file TextAdapter.cpp.

230 {
231 SkASSERT(fPath == fCurrentPath);
232 SkASSERT((fPathReverse != 0) == fCurrentReversed);
233
234 return fCurrentMeasure ? fCurrentMeasure->length() : 0;
235 }

◆ updateContourData()

void skottie::internal::TextAdapter::PathInfo::updateContourData ( )
inline

Definition at line 207 of file TextAdapter.cpp.

207 {
208 const auto reverse = fPathReverse != 0;
209
210 if (fPath != fCurrentPath || reverse != fCurrentReversed) {
211 // reinitialize cached contour data
212 auto path = static_cast<SkPath>(fPath);
213 if (reverse) {
214 SkPath reversed;
215 reversed.reverseAddPath(path);
216 path = reversed;
217 }
218
219 SkContourMeasureIter iter(path, /*forceClosed = */false);
220 fCurrentMeasure = iter.next();
221 fCurrentClosed = path.isLastContourClosed();
222 fCurrentReversed = reverse;
223 fCurrentPath = fPath;
224
225 // AE paths are always single-contour (no moves allowed).
226 SkASSERT(!iter.next());
227 }
228 }
Definition: SkPath.h:59
SkPath & reverseAddPath(const SkPath &src)
Definition: SkPath.cpp:1633
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

Member Data Documentation

◆ fPath

ShapeValue skottie::internal::TextAdapter::PathInfo::fPath

Definition at line 201 of file TextAdapter.cpp.

◆ fPathFMargin

ScalarValue skottie::internal::TextAdapter::PathInfo::fPathFMargin = 0

Definition at line 202 of file TextAdapter.cpp.

◆ fPathLMargin

ScalarValue skottie::internal::TextAdapter::PathInfo::fPathLMargin = 0

Definition at line 203 of file TextAdapter.cpp.

◆ fPathPerpendicular

ScalarValue skottie::internal::TextAdapter::PathInfo::fPathPerpendicular = 0

Definition at line 204 of file TextAdapter.cpp.

◆ fPathReverse

ScalarValue skottie::internal::TextAdapter::PathInfo::fPathReverse = 0

Definition at line 205 of file TextAdapter.cpp.


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