Flutter Engine
 
Loading...
Searching...
No Matches
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 SkContourMeasureIter & pathMeasure () 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().GetSkPath();
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()
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 switch_defs.h:52

References flutter::path, pathMeasure(), and flutter::UIDartState::ThrowIfUIOperationsProhibited().

◆ getLength()

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

Definition at line 48 of file path_measure.cc.

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

◆ getPosTan()

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

Definition at line 56 of file path_measure.cc.

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

References flutter::SafeNarrow().

◆ 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 81 of file path_measure.cc.

85 {
86 if (static_cast<std::vector<sk_sp<SkContourMeasure>>::size_type>(
87 contour_index) >= measures_.size()) {
88 CanvasPath::Create(path_handle);
89 }
90 SkPath dst;
91 bool success = measures_[contour_index]->getSegment(
92 SafeNarrow(start_d), SafeNarrow(stop_d), &dst, start_with_move_to);
93 if (!success) {
94 CanvasPath::Create(path_handle);
95 } else {
96 CanvasPath::CreateFrom(path_handle, dst);
97 }
98}
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

References flutter::CanvasPath::Create(), flutter::CanvasPath::CreateFrom(), and flutter::SafeNarrow().

◆ isClosed()

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

Definition at line 100 of file path_measure.cc.

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

Referenced by setPath().

◆ nextContour()

bool flutter::CanvasPathMeasure::nextContour ( )

Definition at line 108 of file path_measure.cc.

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

◆ pathMeasure()

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

Definition at line 42 of file path_measure.h.

42{ return *path_measure_; }

Referenced by Create().

◆ setPath()

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

Definition at line 44 of file path_measure.cc.

44 {
45 path_measure_->reset(path->path().GetSkPath(), isClosed);
46}
bool isClosed(int contour_index)

References isClosed(), and flutter::path.


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