xref: /third_party/skia/src/core/SkPathMeasure.cpp (revision cb93a386)
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
8#include "include/core/SkContourMeasure.h"
9#include "include/core/SkPathMeasure.h"
10
11SkPathMeasure::SkPathMeasure() {}
12
13SkPathMeasure::SkPathMeasure(const SkPath& path, bool forceClosed, SkScalar resScale)
14    : fIter(path, forceClosed, resScale)
15{
16    fContour = fIter.next();
17}
18
19SkPathMeasure::~SkPathMeasure() {}
20
21void SkPathMeasure::setPath(const SkPath* path, bool forceClosed) {
22    fIter.reset(path ? *path : SkPath(), forceClosed);
23    fContour = fIter.next();
24}
25
26SkScalar SkPathMeasure::getLength() {
27    return fContour ? fContour->length() : 0;
28}
29
30bool SkPathMeasure::getPosTan(SkScalar distance, SkPoint* position, SkVector* tangent) {
31    return fContour && fContour->getPosTan(distance, position, tangent);
32}
33
34bool SkPathMeasure::getMatrix(SkScalar distance, SkMatrix* matrix, MatrixFlags flags) {
35    return fContour && fContour->getMatrix(distance, matrix, (SkContourMeasure::MatrixFlags)flags);
36}
37
38bool SkPathMeasure::getSegment(SkScalar startD, SkScalar stopD, SkPath* dst, bool startWithMoveTo) {
39    return fContour && fContour->getSegment(startD, stopD, dst, startWithMoveTo);
40}
41
42bool SkPathMeasure::isClosed() {
43    return fContour && fContour->isClosed();
44}
45
46bool SkPathMeasure::nextContour() {
47    fContour = fIter.next();
48    return !!fContour;
49}
50
51#ifdef SK_DEBUG
52void SkPathMeasure::dump() {}
53#endif
54