SkPathMeasure.cpp 1.5 KB

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