Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkPathMeasure.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2008 The Android Open Source Project
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
9
11#include "include/core/SkPath.h"
16
17#include <cstddef>
18
19class SkMatrix;
20
22
23SkPathMeasure::SkPathMeasure(const SkPath& path, bool forceClosed, SkScalar resScale)
24 : fIter(path, forceClosed, resScale)
25{
26 fContour = fIter.next();
27}
28
30
31void SkPathMeasure::setPath(const SkPath* path, bool forceClosed) {
32 fIter.reset(path ? *path : SkPath(), forceClosed);
33 fContour = fIter.next();
34}
35
37 return fContour ? fContour->length() : 0;
38}
39
40bool SkPathMeasure::getPosTan(SkScalar distance, SkPoint* position, SkVector* tangent) {
41 return fContour && fContour->getPosTan(distance, position, tangent);
42}
43
45 return fContour && fContour->getMatrix(distance, matrix, (SkContourMeasure::MatrixFlags)flags);
46}
47
48bool SkPathMeasure::getSegment(SkScalar startD, SkScalar stopD, SkPath* dst, bool startWithMoveTo) {
49 return fContour && fContour->getSegment(startD, stopD, dst, startWithMoveTo);
50}
51
53 return fContour && fContour->isClosed();
54}
55
57 fContour = fIter.next();
58 return !!fContour;
59}
60
61#ifdef SK_DEBUG
62void SkPathMeasure::dump() {}
63#endif
64
65/////
66
68 if (auto cntr = meas.currentMeasure()) {
69 return cntr->fSegments.size();
70 }
71 return 0;
72}
std::unique_ptr< SkLatticeIter > fIter
bool getMatrix(SkScalar distance, SkMatrix *matrix, MatrixFlags flags=kGetPosAndTan_MatrixFlag) const
bool getSegment(SkScalar startD, SkScalar stopD, SkPath *dst, bool startWithMoveTo) const
bool getPosTan(SkScalar distance, SkPoint *position, SkVector *tangent) const
SkScalar length() const
bool isClosed() const
static size_t CountSegments(const SkPathMeasure &)
bool getMatrix(SkScalar distance, SkMatrix *matrix, MatrixFlags flags=kGetPosAndTan_MatrixFlag)
SkScalar getLength()
void setPath(const SkPath *, bool forceClosed)
const SkContourMeasure * currentMeasure() const
bool getSegment(SkScalar startD, SkScalar stopD, SkPath *dst, bool startWithMoveTo)
bool getPosTan(SkScalar distance, SkPoint *position, SkVector *tangent)
void reset(T *ptr=nullptr)
Definition SkRefCnt.h:310
float SkScalar
Definition extension.cpp:12
FlutterSemanticsFlag flags