| 1 | // Copyright 2013 The Flutter Authors. All rights reserved. |
|---|---|
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef FLUTTER_LIB_UI_PAINTING_PATH_MEASURE_H_ |
| 6 | #define FLUTTER_LIB_UI_PAINTING_PATH_MEASURE_H_ |
| 7 | |
| 8 | #include <vector> |
| 9 | |
| 10 | #include "flutter/lib/ui/dart_wrapper.h" |
| 11 | #include "flutter/lib/ui/painting/path.h" |
| 12 | #include "third_party/skia/include/core/SkContourMeasure.h" |
| 13 | #include "third_party/skia/include/core/SkPath.h" |
| 14 | #include "third_party/tonic/typed_data/typed_list.h" |
| 15 | |
| 16 | // Be sure that the client doesn't modify a path on us before Skia finishes |
| 17 | // See AOSP's reasoning in PathMeasure.cpp |
| 18 | |
| 19 | namespace flutter { |
| 20 | |
| 21 | class CanvasPathMeasure : public RefCountedDartWrappable<CanvasPathMeasure> { |
| 22 | DEFINE_WRAPPERTYPEINFO(); |
| 23 | FML_FRIEND_MAKE_REF_COUNTED(CanvasPathMeasure); |
| 24 | |
| 25 | public: |
| 26 | ~CanvasPathMeasure() override; |
| 27 | static void Create(Dart_Handle wrapper, |
| 28 | const CanvasPath* path, |
| 29 | bool forceClosed); |
| 30 | |
| 31 | void setPath(const CanvasPath* path, bool isClosed); |
| 32 | double getLength(int contour_index); |
| 33 | tonic::Float32List getPosTan(int contour_index, double distance); |
| 34 | void getSegment(Dart_Handle path_handle, |
| 35 | int contour_index, |
| 36 | double start_d, |
| 37 | double stop_d, |
| 38 | bool start_with_move_to); |
| 39 | bool isClosed(int contour_index); |
| 40 | bool nextContour(); |
| 41 | |
| 42 | const SkContourMeasureIter& pathMeasure() const { return *path_measure_; } |
| 43 | |
| 44 | private: |
| 45 | CanvasPathMeasure(); |
| 46 | |
| 47 | std::unique_ptr<SkContourMeasureIter> path_measure_; |
| 48 | std::vector<sk_sp<SkContourMeasure>> measures_; |
| 49 | }; |
| 50 | |
| 51 | } // namespace flutter |
| 52 | |
| 53 | #endif // FLUTTER_LIB_UI_PAINTING_PATH_MEASURE_H_ |
| 54 |
