@@ -142,23 +142,25 @@ ORBPath ORBPathMakeUnevenRoundedRect(CGRect rect, CGFloat topLeftRadius, CGFloat
142142 };
143143 return path;
144144}
145+ #endif /* ORB_TARGET_OS_DARWIN */
145146
146- CGPathRef ORBPathCopyCGPath (ORBPath path) {
147- // TODO: Return a retained copy of the CGPath
148- return nullptr ;
149- }
150-
151- bool ORBPathContainsPoint (ORBPath path, CGPoint point, bool eoFill) {
152- return ORBPathContainsPoints (path, 1 , &point, eoFill, nullptr );
153- }
154-
155- bool ORBPathContainsPoints (ORBPath path, uint64_t count, const CGPoint *points, bool eoFill, const CGAffineTransform *transform) {
156- // TODO: Implement point containment testing with winding rule
157- return false ;
147+ bool ORBPathIsEmpty (ORBPath path) {
148+ if (path.callbacks == &empty_path_callbacks) {
149+ return true ;
150+ } else {
151+ auto isEmptyCallback = path.callbacks ->isEmpty ;
152+ if (isEmptyCallback) {
153+ return isEmptyCallback (path.storage );
154+ } else {
155+ bool isEmpty = true ;
156+ return ORBPathApplyElements (path, &isEmpty, +[](void * info, ORBPathElement element, const CGFloat *points, const void * _Nullable userInfo) -> bool {
157+ *((bool *)info) = false ;
158+ return false ;
159+ });
160+ }
161+ }
158162}
159163
160- #endif /* ORB_TARGET_OS_DARWIN */
161-
162164bool ORBPathApplyElements (ORBPath path, void *info, ORBPathApplyCallback callback) {
163165 auto apply = path.callbacks ->apply ;
164166 bool flag = false ; // TODO: calllbacks's flag to indicate whether it supports extra features
@@ -174,3 +176,43 @@ bool ORBPathApplyElements(ORBPath path, void *info, ORBPathApplyCallback callbac
174176 return apply (path.storage , info, callback);
175177 }
176178}
179+
180+ bool ORBPathEqualToPath (ORBPath lhs, ORBPath rhs) {
181+ if (lhs.callbacks == rhs.callbacks ) {
182+ if (lhs.storage == rhs.storage ) {
183+ return true ;
184+ }
185+ // TODO
186+ return false ;
187+ } else {
188+ if (lhs.callbacks == &empty_path_callbacks) {
189+ if (lhs.storage == ORBPathNull.storage ) {
190+ return rhs.callbacks == &empty_path_callbacks && rhs.storage == ORBPathNull.storage ;
191+ } else {
192+ return ORBPathIsEmpty (rhs);
193+ }
194+ } else if (rhs.callbacks == &empty_path_callbacks) {
195+ if (rhs.storage == ORBPathNull.storage ) {
196+ return false ;
197+ } else {
198+ return ORBPathIsEmpty (lhs);
199+ }
200+ }
201+ }
202+ }
203+
204+ #if ORB_TARGET_OS_DARWIN
205+ CGPathRef ORBPathCopyCGPath (ORBPath path) {
206+ // TODO: Return a retained copy of the CGPath
207+ return nullptr ;
208+ }
209+
210+ bool ORBPathContainsPoint (ORBPath path, CGPoint point, bool eoFill) {
211+ return ORBPathContainsPoints (path, 1 , &point, eoFill, nullptr );
212+ }
213+
214+ bool ORBPathContainsPoints (ORBPath path, uint64_t count, const CGPoint *points, bool eoFill, const CGAffineTransform *transform) {
215+ // TODO: Implement point containment testing with winding rule
216+ return false ;
217+ }
218+ #endif /* ORB_TARGET_OS_DARWIN */
0 commit comments