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