Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
flutter::CanvasPathMeasure Class Reference

#include <path_measure.h>

Inheritance diagram for flutter::CanvasPathMeasure:
flutter::RefCountedDartWrappable< CanvasPathMeasure > fml::RefCountedThreadSafe< T > tonic::DartWrappable fml::internal::RefCountedThreadSafeBase

Public Member Functions

 ~CanvasPathMeasure () override
 
void setPath (const CanvasPath *path, bool isClosed)
 
double getLength (int contour_index)
 
tonic::Float32List getPosTan (int contour_index, double distance)
 
void getSegment (Dart_Handle path_handle, int contour_index, double start_d, double stop_d, bool start_with_move_to)
 
bool isClosed (int contour_index)
 
bool nextContour ()
 
const SkContourMeasureIterpathMeasure () const
 
- Public Member Functions inherited from flutter::RefCountedDartWrappable< CanvasPathMeasure >
virtual void RetainDartWrappableReference () const override
 
virtual void ReleaseDartWrappableReference () const override
 
- Public Member Functions inherited from fml::RefCountedThreadSafe< T >
void Release () const
 
- Public Member Functions inherited from fml::internal::RefCountedThreadSafeBase
void AddRef () const
 
bool HasOneRef () const
 
void AssertHasOneRef () const
 
- Public Member Functions inherited from tonic::DartWrappable
 DartWrappable ()
 
virtual const DartWrapperInfoGetDartWrapperInfo () const =0
 
Dart_Handle CreateDartWrapper (DartState *dart_state)
 
void AssociateWithDartWrapper (Dart_Handle wrappable)
 
void ClearDartWrapper ()
 
Dart_WeakPersistentHandle dart_wrapper () const
 

Static Public Member Functions

static void Create (Dart_Handle wrapper, const CanvasPath *path, bool forceClosed)
 

Additional Inherited Members

- Public Types inherited from tonic::DartWrappable
enum  DartNativeFields { kPeerIndex , kNumberOfNativeFields }
 
- Protected Member Functions inherited from fml::RefCountedThreadSafe< T >
 RefCountedThreadSafe ()
 
 ~RefCountedThreadSafe ()
 
- Protected Member Functions inherited from fml::internal::RefCountedThreadSafeBase
 RefCountedThreadSafeBase ()
 
 ~RefCountedThreadSafeBase ()
 
bool Release () const
 
void Adopt ()
 
- Protected Member Functions inherited from tonic::DartWrappable
virtual ~DartWrappable ()
 
- Static Protected Member Functions inherited from tonic::DartWrappable
static Dart_PersistentHandle GetTypeForWrapper (tonic::DartState *dart_state, const tonic::DartWrapperInfo &wrapper_info)
 

Detailed Description

Definition at line 21 of file path_measure.h.

Constructor & Destructor Documentation

◆ ~CanvasPathMeasure()

flutter::CanvasPathMeasure::~CanvasPathMeasure ( )
override

Definition at line 42 of file path_measure.cc.

42{}

Member Function Documentation

◆ Create()

void flutter::CanvasPathMeasure::Create ( Dart_Handle  wrapper,
const CanvasPath path,
bool  forceClosed 
)
static

Definition at line 23 of file path_measure.cc.

25 {
28 fml::MakeRefCounted<CanvasPathMeasure>();
29 if (path) {
30 const SkPath& skPath = path->path();
31 SkScalar resScale = 1;
32 pathMeasure->path_measure_ =
33 std::make_unique<SkContourMeasureIter>(skPath, forceClosed, resScale);
34 } else {
35 pathMeasure->path_measure_ = std::make_unique<SkContourMeasureIter>();
36 }
37 pathMeasure->AssociateWithDartWrapper(wrapper);
38}
const SkContourMeasureIter & pathMeasure() const
static void ThrowIfUIOperationsProhibited()
float SkScalar
Definition extension.cpp:12
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition switches.h:57

◆ getLength()

double flutter::CanvasPathMeasure::getLength ( int  contour_index)

Definition at line 49 of file path_measure.cc.

49 {
50 if (static_cast<std::vector<sk_sp<SkContourMeasure>>::size_type>(
51 contour_index) < measures_.size()) {
52 return measures_[contour_index]->length();
53 }
54 return -1;
55}

◆ getPosTan()

tonic::Float32List flutter::CanvasPathMeasure::getPosTan ( int  contour_index,
double  distance 
)

Definition at line 57 of file path_measure.cc.

58 {
59 tonic::Float32List posTan(Dart_NewTypedData(Dart_TypedData_kFloat32, 5));
60 posTan[0] = 0; // dart code will check for this for failure
61 if (static_cast<std::vector<sk_sp<SkContourMeasure>>::size_type>(
62 contour_index) >= measures_.size()) {
63 return posTan;
64 }
65
67 SkVector tan;
68 float fdistance = SafeNarrow(distance);
69 bool success = measures_[contour_index]->getPosTan(fdistance, &pos, &tan);
70
71 if (success) {
72 posTan[0] = 1; // dart code will check for this for success
73 posTan[1] = pos.x();
74 posTan[2] = pos.y();
75 posTan[3] = tan.x();
76 posTan[4] = tan.y();
77 }
78
79 return posTan;
80}
SkPoint pos
@ Dart_TypedData_kFloat32
Definition dart_api.h:2614
DART_EXPORT Dart_Handle Dart_NewTypedData(Dart_TypedData_Type type, intptr_t length)
static float SafeNarrow(double value)
constexpr float y() const
constexpr float x() const

◆ getSegment()

void flutter::CanvasPathMeasure::getSegment ( Dart_Handle  path_handle,
int  contour_index,
double  start_d,
double  stop_d,
bool  start_with_move_to 
)

Definition at line 82 of file path_measure.cc.

86 {
87 if (static_cast<std::vector<sk_sp<SkContourMeasure>>::size_type>(
88 contour_index) >= measures_.size()) {
89 CanvasPath::Create(path_handle);
90 }
91 SkPath dst;
92 bool success = measures_[contour_index]->getSegment(
93 SafeNarrow(start_d), SafeNarrow(stop_d), &dst, start_with_move_to);
94 if (!success) {
95 CanvasPath::Create(path_handle);
96 } else {
97 CanvasPath::CreateFrom(path_handle, dst);
98 }
99}
static void CreateFrom(Dart_Handle path_handle, const SkPath &src)
Definition path.h:25
static fml::RefPtr< CanvasPath > Create(Dart_Handle wrapper)
Definition path.h:31
dst
Definition cp.py:12

◆ isClosed()

bool flutter::CanvasPathMeasure::isClosed ( int  contour_index)

Definition at line 101 of file path_measure.cc.

101 {
102 if (static_cast<std::vector<sk_sp<SkContourMeasure>>::size_type>(
103 contour_index) < measures_.size()) {
104 return measures_[contour_index]->isClosed();
105 }
106 return false;
107}

◆ nextContour()

bool flutter::CanvasPathMeasure::nextContour ( )

Definition at line 109 of file path_measure.cc.

109 {
110 auto measure = path_measure_->next();
111 if (measure) {
112 measures_.push_back(std::move(measure));
113 return true;
114 }
115 return false;
116}

◆ pathMeasure()

const SkContourMeasureIter & flutter::CanvasPathMeasure::pathMeasure ( ) const
inline

Definition at line 42 of file path_measure.h.

42{ return *path_measure_; }

◆ setPath()

void flutter::CanvasPathMeasure::setPath ( const CanvasPath path,
bool  isClosed 
)

Definition at line 44 of file path_measure.cc.

44 {
45 const SkPath& skPath = path->path();
46 path_measure_->reset(skPath, isClosed);
47}
bool isClosed(int contour_index)

The documentation for this class was generated from the following files: