From ae105e017d121b68bbfdad48df323e90b32e8564 Mon Sep 17 00:00:00 2001 From: Kyle Date: Sat, 7 Nov 2026 18:58:14 +0800 Subject: [PATCH] feat(RB): expand path interfaces and correct callback ABI --- .../RenderBox.framework/Headers/RBPath.h | 176 +++++++++++++++++- .../Headers/RBPathCallbacks.h | 8 +- .../Headers/RBPathStorage.h | 6 +- .../RenderBox.framework/RenderBox.tbd | 1 + .../RenderBox.framework/Headers/RBPath.h | 176 +++++++++++++++++- .../Headers/RBPathCallbacks.h | 8 +- .../Headers/RBPathStorage.h | 6 +- .../RenderBox.framework/RenderBox.tbd | 1 + .../Versions/A/Headers/RBPath.h | 176 +++++++++++++++++- .../Versions/A/Headers/RBPathCallbacks.h | 8 +- .../Versions/A/Headers/RBPathStorage.h | 6 +- .../Versions/A/RenderBox.tbd | 1 + .../RenderBox.framework/Headers/RBPath.h | 176 +++++++++++++++++- .../Headers/RBPathCallbacks.h | 8 +- .../Headers/RBPathStorage.h | 6 +- .../RenderBox.framework/Headers/RBPath.h | 176 +++++++++++++++++- .../Headers/RBPathCallbacks.h | 8 +- .../Headers/RBPathStorage.h | 6 +- RB/2024/Sources/Headers/RBPath.h | 176 +++++++++++++++++- RB/2024/Sources/Headers/RBPathCallbacks.h | 8 +- RB/2024/Sources/Headers/RBPathStorage.h | 6 +- RB/2024/tbds/ios-arm64-arm64e/RenderBox.tbd | 1 + .../ios-arm64-x86_64-simulator/RenderBox.tbd | 1 + .../macos-arm64e-arm64-x86_64/RenderBox.tbd | 1 + 24 files changed, 1062 insertions(+), 84 deletions(-) diff --git a/RB/2024/RenderBox.xcframework/ios-arm64-arm64e/RenderBox.framework/Headers/RBPath.h b/RB/2024/RenderBox.xcframework/ios-arm64-arm64e/RenderBox.framework/Headers/RBPath.h index c2a3fd2..b53bf38 100644 --- a/RB/2024/RenderBox.xcframework/ios-arm64-arm64e/RenderBox.framework/Headers/RBPath.h +++ b/RB/2024/RenderBox.xcframework/ios-arm64-arm64e/RenderBox.framework/Headers/RBPath.h @@ -5,6 +5,7 @@ #pragma once #include +#include #include RB_ASSUME_NONNULL_BEGIN @@ -20,12 +21,31 @@ typedef RB_ENUM(int32_t, RBPathElement) { RBPathElementCloseSubpath = 4, RBPathElementRect = 5, RBPathElementRoundedRect = 6, + RBPathElementEllipse = 7, RBPathElementFixedRoundedRectCircular = 8, RBPathElementFixedRoundedRectContinuous = 9, + RBPathElementUnevenRoundedRectCircular = 10, + RBPathElementUnevenRoundedRectContinuous = 11, + RBPathElementRelativeArc = 12, + RBPathElementArc = 13, + RBPathElementArcCounterclockwise = 14, + RBPathElementArcTo = 15, + RBPathElementEnd = 16, + RBPathElementTransformed = 17, + RBPathElementTrimmed = 18, + RBPathElementStroked = 19, + RBPathElementBoolean = 20, + RBPathElementBooleanSeparator = 21, + RBPathElementDilateGlyph = 22, + RBPathElementOffset = 23, + RBPathElementClipStroke = 24, RBPathElementInvalid = 25, } RB_SWIFT_NAME(RBPath.Element); +RB_EXPORT +const uint8_t __RBPathElementArgumentCount[25]; + /// Defines the shape of a rounded rectangle's corners. typedef RB_ENUM(int32_t, RBPathRoundedCornerStyle) { /// Quarter-circle rounded rect corners. @@ -35,9 +55,21 @@ typedef RB_ENUM(int32_t, RBPathRoundedCornerStyle) { } RB_SWIFT_NAME(RBPath.RoundedCornerStyle); /// Callback type for path element enumeration -/// Returns true to stop enumeration, false to continue +/// Returns true to continue enumeration, false to stop typedef bool (*RBPathApplyCallback)(void * info, RBPathElement element, const CGFloat *points, const void * _Nullable userInfo); +/// Callback for mapped Core Graphics elements. Return false to stop callbacks. +typedef bool (*RBPathApplierCallback)(void *info, const CGPathElement *element); + +typedef RB_ENUM(int32_t, RBPathLineElement) { + RBPathLineElementMoveToPoint = 0, + RBPathLineElementAddLineToPoint = 1, + RBPathLineElementCloseSubpath = 2, +}; + +/// The point is unused for a close-subpath callback. +typedef bool (*RBPathLineApplyCallback)(void *info, RBPathLineElement element, const CGPoint *point); + typedef struct RBPathCallbacks RBPathCallbacks RB_SWIFT_NAME(RBPath.ApplyCallback); typedef struct RBPathStorage * RBPathStorageRef RB_SWIFT_STRUCT RB_SWIFT_NAME(RBPath.Storage); @@ -47,6 +79,93 @@ typedef struct RBPath { const RBPathCallbacks * callbacks; } RBPath; +/// A primitive shape recognized by ``RBPathApplyShape``. +typedef RB_ENUM(int32_t, RBPathShapeType) { + RBPathShapeTypeRect = 0, + RBPathShapeTypeEllipse = 1, + RBPathShapeTypeLine = 2, + RBPathShapeTypeFixedRoundedRect = 3, + RBPathShapeTypeUnevenRoundedRect = 4, + RBPathShapeTypeNested = 5, + RBPathShapeTypeStroked = 6, + RBPathShapeTypeTrimmed = 7, + RBPathShapeTypeOffset = 8, +}; + +typedef struct RBPathRectShape { + CGAffineTransform transform; + CGRect rect; +} RBPathRectShape; + +typedef struct RBPathFixedRoundedRectShape { + CGAffineTransform transform; + CGRect rect; + CGSize cornerSize; + RBPathRoundedCornerStyle style; +} RBPathFixedRoundedRectShape; + +typedef struct RBPathUnevenRoundedRectShape { + CGAffineTransform transform; + CGRect rect; + CGFloat topLeftRadius; + CGFloat topRightRadius; + CGFloat bottomRightRadius; + CGFloat bottomLeftRadius; + RBPathRoundedCornerStyle style; +} RBPathUnevenRoundedRectShape; + +typedef struct RBPathLineShape { + CGPoint start; + CGPoint end; +} RBPathLineShape; + +typedef struct RBPathStrokeStyle { + CGFloat lineWidth; + int32_t lineCap; + int32_t lineJoin; + CGFloat miterLimit; + CGFloat dashPhase; + uint64_t dashCount; + const CGFloat * _Nullable dash; +} RBPathStrokeStyle; + +typedef struct RBPathStrokedShape { + RBPath path; + RBPathStrokeStyle style; +} RBPathStrokedShape; + +typedef struct RBPathNestedShape { + RBPath path; + CGAffineTransform transform; +} RBPathNestedShape; + +typedef struct RBPathTrimmedShape { + RBPath path; + CGFloat from; + CGFloat to; +} RBPathTrimmedShape; + +typedef union RBPathShape { + RBPathRectShape rect; + RBPathRectShape ellipse; + RBPathLineShape line; + RBPathFixedRoundedRectShape fixedRoundedRect; + RBPathUnevenRoundedRectShape unevenRoundedRect; + RBPathStrokedShape stroked; + RBPathNestedShape nested; + RBPathTrimmedShape trimmed; +} RBPathShape; + +#if defined(__cplusplus) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) +static_assert(sizeof(RBPath) == 0x10); +static_assert(offsetof(RBPathUnevenRoundedRectShape, rect) == 0x30); +static_assert(offsetof(RBPathUnevenRoundedRectShape, topLeftRadius) == 0x50); +static_assert(offsetof(RBPathUnevenRoundedRectShape, style) == 0x70); +static_assert(sizeof(RBPathShape) == 0x78); +#endif + +typedef void (*RBPathApplyShapeCallback)(void * info, RBPathShapeType type, const RBPathShape *shape); + /// Global empty path (storage = null, callbacks = &RBPathEmptyCallbacks) RB_EXPORT const RBPath RBPathEmpty RB_SWIFT_NAME(RBPath.empty); @@ -56,7 +175,7 @@ RB_EXPORT const RBPath RBPathNull RB_SWIFT_NAME(RBPath.null); RB_EXPORT -void RBPathRetain(RBPath path) RB_SWIFT_NAME(RBPath.retain(self:)); +RBPath RBPathRetain(RBPath path) RB_SWIFT_NAME(RBPath.retain(self:)); RB_EXPORT void RBPathRelease(RBPath path) RB_SWIFT_NAME(RBPath.release(self:)); @@ -64,7 +183,7 @@ void RBPathRelease(RBPath path) RB_SWIFT_NAME(RBPath.release(self:)); // MARK: - Path Creation RB_EXPORT -RBPath RBPathMakeWithCGPath(CGPathRef cgPath) RB_SWIFT_NAME(RBPath.init(cgPath:)); +RBPath RBPathMakeWithCGPath(CGPathRef _Nullable cgPath) RB_SWIFT_NAME(RBPath.init(cgPath:)); RB_EXPORT RBPath RBPathMakeRect(CGRect rect, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.init(rect:transform:)); @@ -76,12 +195,19 @@ RB_EXPORT RBPath RBPathMakeRoundedRect(CGRect rect, CGFloat cornerWidth, CGFloat cornerHeight, RBPathRoundedCornerStyle style, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.init(roundedRect:cornerWidth:cornerHeight:style:transform:)); RB_EXPORT -RBPath RBPathMakeUnevenRoundedRect(CGRect rect, CGFloat topLeftRadius, CGFloat bottomLeftRadius, CGFloat bottomRightRadius, CGFloat topRightRadius, RBPathRoundedCornerStyle style, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.init(roundedRect:topLeftRadius:bottomLeftRadius:bottomRightRadius:topRightRadius:style:transform:)); +RBPath RBPathMakeUnevenRoundedRect(CGRect rect, CGFloat topLeftRadius, CGFloat topRightRadius, CGFloat bottomRightRadius, CGFloat bottomLeftRadius, RBPathRoundedCornerStyle style, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.init(roundedRect:topLeftRadius:topRightRadius:bottomRightRadius:bottomLeftRadius:style:transform:)); -// MARK: - Path Transformation +RB_EXPORT +RBPath RBPathCopyTransformedPath(RBPath path, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.copy(self:transform:)); + +RB_EXPORT +RBPath RBPathCopyStrokedPath(RBPath path, CGFloat lineWidth, int32_t lineCap, int32_t lineJoin, CGFloat miterLimit, CGFloat dashPhase, const CGFloat * _Nullable dash, size_t dashCount) RB_SWIFT_NAME(RBPath.stroked(self:lineWidth:lineCap:lineJoin:miterLimit:dashPhase:dash:dashCount:)); RB_EXPORT -RBPath RBPathCopyTransformedPath(RBPath path, const CGAffineTransform *transform) RB_SWIFT_NAME(RBPath.copy(self:transform:)); +RBPath RBPathCopyTrimmedPath(RBPath path, CGFloat from, CGFloat to) RB_SWIFT_NAME(RBPath.trimmed(self:from:to:)); + +// MARK: - Path Transformation + static RB_INLINE bool RBPathIsNull(RBPath path) RB_SWIFT_NAME(getter:RBPath.isNull(self:)) { return path.storage == RBPathNull.storage && path.callbacks == RBPathNull.callbacks; @@ -92,24 +218,60 @@ static RB_INLINE bool RBPathIsNull(RBPath path) RB_SWIFT_NAME(getter:RBPath.isNu RB_EXPORT bool RBPathIsEmpty(RBPath path) RB_SWIFT_NAME(getter:RBPath.isEmpty(self:)); +RB_EXPORT +bool RBPathIsSingleElement(RBPath path) RB_SWIFT_NAME(getter:RBPath.isSingleElement(self:)); + +RB_EXPORT +size_t RBPathGetBezierOrder(RBPath path) RB_SWIFT_NAME(getter:RBPath.bezierOrder(self:)); + RB_EXPORT bool RBPathApplyElements(RBPath path, void * info, _Nullable RBPathApplyCallback callback) RB_SWIFT_NAME(RBPath.apply(self:info:callback:)); +RB_EXPORT +bool RBPathApplyShape(RBPath path, bool allowLine, void * info, RBPathApplyShapeCallback callback) RB_SWIFT_NAME(RBPath.applyShape(self:allowLine:info:callback:)); + RB_EXPORT bool RBPathEqualToPath(RBPath lhs, RBPath rhs) RB_SWIFT_NAME(RBPath.isEqual(self:to:)); // MARK: - CGPath Interoperability +RB_EXPORT +bool RBPathApply(RBPath path, const CGAffineTransform * _Nullable transform, void *info, RBPathApplierCallback callback) RB_SWIFT_NAME(RBPath.applyCGPathElements(self:transform:info:callback:)); + +RB_EXPORT +bool RBPathApplyLines(RBPath path, double tolerance, void *info, RBPathLineApplyCallback callback) RB_SWIFT_NAME(RBPath.applyLines(self:tolerance:info:callback:)); + +RB_EXPORT +double RBPathGetLength(RBPath path, double tolerance, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.length(self:tolerance:transform:)); + +RB_EXPORT +bool RBPathCanInterpolate(RBPath path, RBPath other) RB_SWIFT_NAME(RBPath.canInterpolate(self:to:)); + +RB_EXPORT +RBPath RBPathCopyInterpolatedPath(RBPath path, RBPath other, float fraction) RB_SWIFT_NAME(RBPath.interpolated(self:to:fraction:)); + +RB_EXPORT +CFDataRef RBPathCopyData(RBPath path) RB_SWIFT_NAME(getter:RBPath.data(self:)); + +RB_EXPORT +RBPath RBPathMakeWithData(CFDataRef data) RB_SWIFT_NAME(RBPath.init(data:)); + +RB_EXPORT +CFStringRef RBPathCopyDebugDescription(RBPath path) RB_SWIFT_NAME(getter:RBPath.debugDescription(self:)); + RB_EXPORT CGPathRef RBPathCopyCGPath(RBPath path) RB_SWIFT_NAME(getter:RBPath.cgPath(self:)); +RB_EXPORT +CGRect RBPathGetBoundingRect(RBPath path) RB_SWIFT_NAME(getter:RBPath.boundingRect(self:)); + // MARK: - Point Containment RB_EXPORT bool RBPathContainsPoint(RBPath path, CGPoint point, bool eoFill) RB_SWIFT_NAME(RBPath.contains(self:point:eoFill:)); RB_EXPORT -bool RBPathContainsPoints(RBPath path, uint64_t count, const CGPoint *points, bool eoFill, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.containsPoints(self:count:points:eoFill:transform:)); +uint64_t RBPathContainsPoints(RBPath path, uint64_t count, const CGPoint *points, bool eoFill, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.containsPoints(self:count:points:eoFill:transform:)); RB_EXTERN_C_END diff --git a/RB/2024/RenderBox.xcframework/ios-arm64-arm64e/RenderBox.framework/Headers/RBPathCallbacks.h b/RB/2024/RenderBox.xcframework/ios-arm64-arm64e/RenderBox.framework/Headers/RBPathCallbacks.h index d94c07a..8456e28 100644 --- a/RB/2024/RenderBox.xcframework/ios-arm64-arm64e/RenderBox.framework/Headers/RBPathCallbacks.h +++ b/RB/2024/RenderBox.xcframework/ios-arm64-arm64e/RenderBox.framework/Headers/RBPathCallbacks.h @@ -33,10 +33,10 @@ typedef struct RB_SWIFT_NAME(RBPath.Callbacks) RBPathCallbacks { bool (* _Nullable isEqual)(const void *object, const void *otherObject); bool (* _Nullable isEmpty)(const void *object); bool (* _Nullable isSingleElement)(const void *object); - uint32_t (* _Nullable bezierOrder)(const void *object); + size_t (* _Nullable bezierOrder)(const void *object); CGRect (* _Nullable boundingRect)(const void *object); CGPathRef _Nullable (* _Nullable cgPath)(const void *object); - const struct RBPathCallbacks * _Nullable (* _Nullable next)(const void *object); + RBPath (* _Nullable next)(const void *object); } RBPathCallbacks; /// Extended callbacks structure with additional extended callbacks argument @@ -48,10 +48,10 @@ typedef struct RB_SWIFT_NAME(RBPath.CallbacksExtended) RBPathCallbacksExtended { bool (* _Nullable isEqual)(const void *object, const void *otherObject, const struct RBPathCallbacksExtended *extended); bool (* _Nullable isEmpty)(const void *object, const struct RBPathCallbacksExtended *extended); bool (* _Nullable isSingleElement)(const void *object, const struct RBPathCallbacksExtended *extended); - uint32_t (* _Nullable bezierOrder)(const void *object, const struct RBPathCallbacksExtended *extended); + size_t (* _Nullable bezierOrder)(const void *object, const struct RBPathCallbacksExtended *extended); CGRect (* _Nullable boundingRect)(const void *object, const struct RBPathCallbacksExtended *extended); CGPathRef _Nullable (* _Nullable cgPath)(const void *object, const struct RBPathCallbacksExtended *extended); - const struct RBPathCallbacksExtended * _Nullable (* _Nullable next)(const void *object, const struct RBPathCallbacksExtended *extended); + RBPath (* _Nullable next)(const void *object, const struct RBPathCallbacksExtended *extended); } RBPathCallbacksExtended; /// Global callbacks for CGPath-backed paths diff --git a/RB/2024/RenderBox.xcframework/ios-arm64-arm64e/RenderBox.framework/Headers/RBPathStorage.h b/RB/2024/RenderBox.xcframework/ios-arm64-arm64e/RenderBox.framework/Headers/RBPathStorage.h index 6d1ccea..01e793f 100644 --- a/RB/2024/RenderBox.xcframework/ios-arm64-arm64e/RenderBox.framework/Headers/RBPathStorage.h +++ b/RB/2024/RenderBox.xcframework/ios-arm64-arm64e/RenderBox.framework/Headers/RBPathStorage.h @@ -16,7 +16,7 @@ RB_ASSUME_NONNULL_BEGIN RB_EXTERN_C_BEGIN RB_EXPORT -void RBPathStorageInit(RBPathStorageRef dst, uint32_t capacity, RBPathStorageRef _Nullable source) RB_SWIFT_NAME(RBPathStorageRef.initialize(self:capacity:source:)); +void RBPathStorageInit(RBPathStorageRef dst, size_t capacity, RBPathStorageRef _Nullable source) RB_SWIFT_NAME(RBPathStorageRef.initialize(self:capacity:source:)); RB_EXPORT void RBPathStorageDestroy(RBPathStorageRef storage) RB_SWIFT_NAME(RBPathStorageRef.destroy(self:)); @@ -25,7 +25,7 @@ RB_EXPORT void RBPathStorageClear(RBPathStorageRef storage) RB_SWIFT_NAME(RBPathStorageRef.clear(self:)); RB_EXPORT -bool RBPathStorageAppendElement(RBPathStorageRef storage, RBPathElement element, CGFloat const * points, const void * _Nullable userInfo) RB_SWIFT_NAME(RBPathStorageRef.append(self:element:points:userInfo:)); +void RBPathStorageAppendElement(RBPathStorageRef storage, RBPathElement element, CGFloat const * points, const void * _Nullable userInfo) RB_SWIFT_NAME(RBPathStorageRef.append(self:element:points:userInfo:)); RB_EXPORT bool RBPathStorageAppendPath(RBPathStorageRef, RBPath) RB_SWIFT_NAME(RBPathStorageRef.append(self:path:)); @@ -43,7 +43,7 @@ RB_EXPORT bool RBPathStorageIsSingleElement(RBPathStorageRef storage) RB_SWIFT_NAME(getter:RBPathStorageRef.isSingleElement(self:)); RB_EXPORT -uint32_t RBPathStorageGetBezierOrder(RBPathStorageRef storage) RB_SWIFT_NAME(getter:RBPathStorageRef.bezierOrder(self:)); +size_t RBPathStorageGetBezierOrder(RBPathStorageRef storage) RB_SWIFT_NAME(getter:RBPathStorageRef.bezierOrder(self:)); RB_EXPORT CGRect RBPathStorageGetBoundingRect(RBPathStorageRef storage) RB_SWIFT_NAME(getter:RBPathStorageRef.boundingRect(self:)); diff --git a/RB/2024/RenderBox.xcframework/ios-arm64-arm64e/RenderBox.framework/RenderBox.tbd b/RB/2024/RenderBox.xcframework/ios-arm64-arm64e/RenderBox.framework/RenderBox.tbd index 2a4566a..03e6bd8 100644 --- a/RB/2024/RenderBox.xcframework/ios-arm64-arm64e/RenderBox.framework/RenderBox.tbd +++ b/RB/2024/RenderBox.xcframework/ios-arm64-arm64e/RenderBox.framework/RenderBox.tbd @@ -268,6 +268,7 @@ "_RBDrawingStateSetCTM", "_RBPathCopyInterpolatedPath", "_RBPathGetBoundingRect", + "_RBPathGetLength", "_RBDrawingStateClipLayer", "_RBDisplayListContentsXMLDictionary", "_RBColorMakeLinear", diff --git a/RB/2024/RenderBox.xcframework/ios-arm64-x86_64-simulator/RenderBox.framework/Headers/RBPath.h b/RB/2024/RenderBox.xcframework/ios-arm64-x86_64-simulator/RenderBox.framework/Headers/RBPath.h index c2a3fd2..b53bf38 100644 --- a/RB/2024/RenderBox.xcframework/ios-arm64-x86_64-simulator/RenderBox.framework/Headers/RBPath.h +++ b/RB/2024/RenderBox.xcframework/ios-arm64-x86_64-simulator/RenderBox.framework/Headers/RBPath.h @@ -5,6 +5,7 @@ #pragma once #include +#include #include RB_ASSUME_NONNULL_BEGIN @@ -20,12 +21,31 @@ typedef RB_ENUM(int32_t, RBPathElement) { RBPathElementCloseSubpath = 4, RBPathElementRect = 5, RBPathElementRoundedRect = 6, + RBPathElementEllipse = 7, RBPathElementFixedRoundedRectCircular = 8, RBPathElementFixedRoundedRectContinuous = 9, + RBPathElementUnevenRoundedRectCircular = 10, + RBPathElementUnevenRoundedRectContinuous = 11, + RBPathElementRelativeArc = 12, + RBPathElementArc = 13, + RBPathElementArcCounterclockwise = 14, + RBPathElementArcTo = 15, + RBPathElementEnd = 16, + RBPathElementTransformed = 17, + RBPathElementTrimmed = 18, + RBPathElementStroked = 19, + RBPathElementBoolean = 20, + RBPathElementBooleanSeparator = 21, + RBPathElementDilateGlyph = 22, + RBPathElementOffset = 23, + RBPathElementClipStroke = 24, RBPathElementInvalid = 25, } RB_SWIFT_NAME(RBPath.Element); +RB_EXPORT +const uint8_t __RBPathElementArgumentCount[25]; + /// Defines the shape of a rounded rectangle's corners. typedef RB_ENUM(int32_t, RBPathRoundedCornerStyle) { /// Quarter-circle rounded rect corners. @@ -35,9 +55,21 @@ typedef RB_ENUM(int32_t, RBPathRoundedCornerStyle) { } RB_SWIFT_NAME(RBPath.RoundedCornerStyle); /// Callback type for path element enumeration -/// Returns true to stop enumeration, false to continue +/// Returns true to continue enumeration, false to stop typedef bool (*RBPathApplyCallback)(void * info, RBPathElement element, const CGFloat *points, const void * _Nullable userInfo); +/// Callback for mapped Core Graphics elements. Return false to stop callbacks. +typedef bool (*RBPathApplierCallback)(void *info, const CGPathElement *element); + +typedef RB_ENUM(int32_t, RBPathLineElement) { + RBPathLineElementMoveToPoint = 0, + RBPathLineElementAddLineToPoint = 1, + RBPathLineElementCloseSubpath = 2, +}; + +/// The point is unused for a close-subpath callback. +typedef bool (*RBPathLineApplyCallback)(void *info, RBPathLineElement element, const CGPoint *point); + typedef struct RBPathCallbacks RBPathCallbacks RB_SWIFT_NAME(RBPath.ApplyCallback); typedef struct RBPathStorage * RBPathStorageRef RB_SWIFT_STRUCT RB_SWIFT_NAME(RBPath.Storage); @@ -47,6 +79,93 @@ typedef struct RBPath { const RBPathCallbacks * callbacks; } RBPath; +/// A primitive shape recognized by ``RBPathApplyShape``. +typedef RB_ENUM(int32_t, RBPathShapeType) { + RBPathShapeTypeRect = 0, + RBPathShapeTypeEllipse = 1, + RBPathShapeTypeLine = 2, + RBPathShapeTypeFixedRoundedRect = 3, + RBPathShapeTypeUnevenRoundedRect = 4, + RBPathShapeTypeNested = 5, + RBPathShapeTypeStroked = 6, + RBPathShapeTypeTrimmed = 7, + RBPathShapeTypeOffset = 8, +}; + +typedef struct RBPathRectShape { + CGAffineTransform transform; + CGRect rect; +} RBPathRectShape; + +typedef struct RBPathFixedRoundedRectShape { + CGAffineTransform transform; + CGRect rect; + CGSize cornerSize; + RBPathRoundedCornerStyle style; +} RBPathFixedRoundedRectShape; + +typedef struct RBPathUnevenRoundedRectShape { + CGAffineTransform transform; + CGRect rect; + CGFloat topLeftRadius; + CGFloat topRightRadius; + CGFloat bottomRightRadius; + CGFloat bottomLeftRadius; + RBPathRoundedCornerStyle style; +} RBPathUnevenRoundedRectShape; + +typedef struct RBPathLineShape { + CGPoint start; + CGPoint end; +} RBPathLineShape; + +typedef struct RBPathStrokeStyle { + CGFloat lineWidth; + int32_t lineCap; + int32_t lineJoin; + CGFloat miterLimit; + CGFloat dashPhase; + uint64_t dashCount; + const CGFloat * _Nullable dash; +} RBPathStrokeStyle; + +typedef struct RBPathStrokedShape { + RBPath path; + RBPathStrokeStyle style; +} RBPathStrokedShape; + +typedef struct RBPathNestedShape { + RBPath path; + CGAffineTransform transform; +} RBPathNestedShape; + +typedef struct RBPathTrimmedShape { + RBPath path; + CGFloat from; + CGFloat to; +} RBPathTrimmedShape; + +typedef union RBPathShape { + RBPathRectShape rect; + RBPathRectShape ellipse; + RBPathLineShape line; + RBPathFixedRoundedRectShape fixedRoundedRect; + RBPathUnevenRoundedRectShape unevenRoundedRect; + RBPathStrokedShape stroked; + RBPathNestedShape nested; + RBPathTrimmedShape trimmed; +} RBPathShape; + +#if defined(__cplusplus) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) +static_assert(sizeof(RBPath) == 0x10); +static_assert(offsetof(RBPathUnevenRoundedRectShape, rect) == 0x30); +static_assert(offsetof(RBPathUnevenRoundedRectShape, topLeftRadius) == 0x50); +static_assert(offsetof(RBPathUnevenRoundedRectShape, style) == 0x70); +static_assert(sizeof(RBPathShape) == 0x78); +#endif + +typedef void (*RBPathApplyShapeCallback)(void * info, RBPathShapeType type, const RBPathShape *shape); + /// Global empty path (storage = null, callbacks = &RBPathEmptyCallbacks) RB_EXPORT const RBPath RBPathEmpty RB_SWIFT_NAME(RBPath.empty); @@ -56,7 +175,7 @@ RB_EXPORT const RBPath RBPathNull RB_SWIFT_NAME(RBPath.null); RB_EXPORT -void RBPathRetain(RBPath path) RB_SWIFT_NAME(RBPath.retain(self:)); +RBPath RBPathRetain(RBPath path) RB_SWIFT_NAME(RBPath.retain(self:)); RB_EXPORT void RBPathRelease(RBPath path) RB_SWIFT_NAME(RBPath.release(self:)); @@ -64,7 +183,7 @@ void RBPathRelease(RBPath path) RB_SWIFT_NAME(RBPath.release(self:)); // MARK: - Path Creation RB_EXPORT -RBPath RBPathMakeWithCGPath(CGPathRef cgPath) RB_SWIFT_NAME(RBPath.init(cgPath:)); +RBPath RBPathMakeWithCGPath(CGPathRef _Nullable cgPath) RB_SWIFT_NAME(RBPath.init(cgPath:)); RB_EXPORT RBPath RBPathMakeRect(CGRect rect, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.init(rect:transform:)); @@ -76,12 +195,19 @@ RB_EXPORT RBPath RBPathMakeRoundedRect(CGRect rect, CGFloat cornerWidth, CGFloat cornerHeight, RBPathRoundedCornerStyle style, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.init(roundedRect:cornerWidth:cornerHeight:style:transform:)); RB_EXPORT -RBPath RBPathMakeUnevenRoundedRect(CGRect rect, CGFloat topLeftRadius, CGFloat bottomLeftRadius, CGFloat bottomRightRadius, CGFloat topRightRadius, RBPathRoundedCornerStyle style, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.init(roundedRect:topLeftRadius:bottomLeftRadius:bottomRightRadius:topRightRadius:style:transform:)); +RBPath RBPathMakeUnevenRoundedRect(CGRect rect, CGFloat topLeftRadius, CGFloat topRightRadius, CGFloat bottomRightRadius, CGFloat bottomLeftRadius, RBPathRoundedCornerStyle style, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.init(roundedRect:topLeftRadius:topRightRadius:bottomRightRadius:bottomLeftRadius:style:transform:)); -// MARK: - Path Transformation +RB_EXPORT +RBPath RBPathCopyTransformedPath(RBPath path, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.copy(self:transform:)); + +RB_EXPORT +RBPath RBPathCopyStrokedPath(RBPath path, CGFloat lineWidth, int32_t lineCap, int32_t lineJoin, CGFloat miterLimit, CGFloat dashPhase, const CGFloat * _Nullable dash, size_t dashCount) RB_SWIFT_NAME(RBPath.stroked(self:lineWidth:lineCap:lineJoin:miterLimit:dashPhase:dash:dashCount:)); RB_EXPORT -RBPath RBPathCopyTransformedPath(RBPath path, const CGAffineTransform *transform) RB_SWIFT_NAME(RBPath.copy(self:transform:)); +RBPath RBPathCopyTrimmedPath(RBPath path, CGFloat from, CGFloat to) RB_SWIFT_NAME(RBPath.trimmed(self:from:to:)); + +// MARK: - Path Transformation + static RB_INLINE bool RBPathIsNull(RBPath path) RB_SWIFT_NAME(getter:RBPath.isNull(self:)) { return path.storage == RBPathNull.storage && path.callbacks == RBPathNull.callbacks; @@ -92,24 +218,60 @@ static RB_INLINE bool RBPathIsNull(RBPath path) RB_SWIFT_NAME(getter:RBPath.isNu RB_EXPORT bool RBPathIsEmpty(RBPath path) RB_SWIFT_NAME(getter:RBPath.isEmpty(self:)); +RB_EXPORT +bool RBPathIsSingleElement(RBPath path) RB_SWIFT_NAME(getter:RBPath.isSingleElement(self:)); + +RB_EXPORT +size_t RBPathGetBezierOrder(RBPath path) RB_SWIFT_NAME(getter:RBPath.bezierOrder(self:)); + RB_EXPORT bool RBPathApplyElements(RBPath path, void * info, _Nullable RBPathApplyCallback callback) RB_SWIFT_NAME(RBPath.apply(self:info:callback:)); +RB_EXPORT +bool RBPathApplyShape(RBPath path, bool allowLine, void * info, RBPathApplyShapeCallback callback) RB_SWIFT_NAME(RBPath.applyShape(self:allowLine:info:callback:)); + RB_EXPORT bool RBPathEqualToPath(RBPath lhs, RBPath rhs) RB_SWIFT_NAME(RBPath.isEqual(self:to:)); // MARK: - CGPath Interoperability +RB_EXPORT +bool RBPathApply(RBPath path, const CGAffineTransform * _Nullable transform, void *info, RBPathApplierCallback callback) RB_SWIFT_NAME(RBPath.applyCGPathElements(self:transform:info:callback:)); + +RB_EXPORT +bool RBPathApplyLines(RBPath path, double tolerance, void *info, RBPathLineApplyCallback callback) RB_SWIFT_NAME(RBPath.applyLines(self:tolerance:info:callback:)); + +RB_EXPORT +double RBPathGetLength(RBPath path, double tolerance, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.length(self:tolerance:transform:)); + +RB_EXPORT +bool RBPathCanInterpolate(RBPath path, RBPath other) RB_SWIFT_NAME(RBPath.canInterpolate(self:to:)); + +RB_EXPORT +RBPath RBPathCopyInterpolatedPath(RBPath path, RBPath other, float fraction) RB_SWIFT_NAME(RBPath.interpolated(self:to:fraction:)); + +RB_EXPORT +CFDataRef RBPathCopyData(RBPath path) RB_SWIFT_NAME(getter:RBPath.data(self:)); + +RB_EXPORT +RBPath RBPathMakeWithData(CFDataRef data) RB_SWIFT_NAME(RBPath.init(data:)); + +RB_EXPORT +CFStringRef RBPathCopyDebugDescription(RBPath path) RB_SWIFT_NAME(getter:RBPath.debugDescription(self:)); + RB_EXPORT CGPathRef RBPathCopyCGPath(RBPath path) RB_SWIFT_NAME(getter:RBPath.cgPath(self:)); +RB_EXPORT +CGRect RBPathGetBoundingRect(RBPath path) RB_SWIFT_NAME(getter:RBPath.boundingRect(self:)); + // MARK: - Point Containment RB_EXPORT bool RBPathContainsPoint(RBPath path, CGPoint point, bool eoFill) RB_SWIFT_NAME(RBPath.contains(self:point:eoFill:)); RB_EXPORT -bool RBPathContainsPoints(RBPath path, uint64_t count, const CGPoint *points, bool eoFill, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.containsPoints(self:count:points:eoFill:transform:)); +uint64_t RBPathContainsPoints(RBPath path, uint64_t count, const CGPoint *points, bool eoFill, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.containsPoints(self:count:points:eoFill:transform:)); RB_EXTERN_C_END diff --git a/RB/2024/RenderBox.xcframework/ios-arm64-x86_64-simulator/RenderBox.framework/Headers/RBPathCallbacks.h b/RB/2024/RenderBox.xcframework/ios-arm64-x86_64-simulator/RenderBox.framework/Headers/RBPathCallbacks.h index d94c07a..8456e28 100644 --- a/RB/2024/RenderBox.xcframework/ios-arm64-x86_64-simulator/RenderBox.framework/Headers/RBPathCallbacks.h +++ b/RB/2024/RenderBox.xcframework/ios-arm64-x86_64-simulator/RenderBox.framework/Headers/RBPathCallbacks.h @@ -33,10 +33,10 @@ typedef struct RB_SWIFT_NAME(RBPath.Callbacks) RBPathCallbacks { bool (* _Nullable isEqual)(const void *object, const void *otherObject); bool (* _Nullable isEmpty)(const void *object); bool (* _Nullable isSingleElement)(const void *object); - uint32_t (* _Nullable bezierOrder)(const void *object); + size_t (* _Nullable bezierOrder)(const void *object); CGRect (* _Nullable boundingRect)(const void *object); CGPathRef _Nullable (* _Nullable cgPath)(const void *object); - const struct RBPathCallbacks * _Nullable (* _Nullable next)(const void *object); + RBPath (* _Nullable next)(const void *object); } RBPathCallbacks; /// Extended callbacks structure with additional extended callbacks argument @@ -48,10 +48,10 @@ typedef struct RB_SWIFT_NAME(RBPath.CallbacksExtended) RBPathCallbacksExtended { bool (* _Nullable isEqual)(const void *object, const void *otherObject, const struct RBPathCallbacksExtended *extended); bool (* _Nullable isEmpty)(const void *object, const struct RBPathCallbacksExtended *extended); bool (* _Nullable isSingleElement)(const void *object, const struct RBPathCallbacksExtended *extended); - uint32_t (* _Nullable bezierOrder)(const void *object, const struct RBPathCallbacksExtended *extended); + size_t (* _Nullable bezierOrder)(const void *object, const struct RBPathCallbacksExtended *extended); CGRect (* _Nullable boundingRect)(const void *object, const struct RBPathCallbacksExtended *extended); CGPathRef _Nullable (* _Nullable cgPath)(const void *object, const struct RBPathCallbacksExtended *extended); - const struct RBPathCallbacksExtended * _Nullable (* _Nullable next)(const void *object, const struct RBPathCallbacksExtended *extended); + RBPath (* _Nullable next)(const void *object, const struct RBPathCallbacksExtended *extended); } RBPathCallbacksExtended; /// Global callbacks for CGPath-backed paths diff --git a/RB/2024/RenderBox.xcframework/ios-arm64-x86_64-simulator/RenderBox.framework/Headers/RBPathStorage.h b/RB/2024/RenderBox.xcframework/ios-arm64-x86_64-simulator/RenderBox.framework/Headers/RBPathStorage.h index 6d1ccea..01e793f 100644 --- a/RB/2024/RenderBox.xcframework/ios-arm64-x86_64-simulator/RenderBox.framework/Headers/RBPathStorage.h +++ b/RB/2024/RenderBox.xcframework/ios-arm64-x86_64-simulator/RenderBox.framework/Headers/RBPathStorage.h @@ -16,7 +16,7 @@ RB_ASSUME_NONNULL_BEGIN RB_EXTERN_C_BEGIN RB_EXPORT -void RBPathStorageInit(RBPathStorageRef dst, uint32_t capacity, RBPathStorageRef _Nullable source) RB_SWIFT_NAME(RBPathStorageRef.initialize(self:capacity:source:)); +void RBPathStorageInit(RBPathStorageRef dst, size_t capacity, RBPathStorageRef _Nullable source) RB_SWIFT_NAME(RBPathStorageRef.initialize(self:capacity:source:)); RB_EXPORT void RBPathStorageDestroy(RBPathStorageRef storage) RB_SWIFT_NAME(RBPathStorageRef.destroy(self:)); @@ -25,7 +25,7 @@ RB_EXPORT void RBPathStorageClear(RBPathStorageRef storage) RB_SWIFT_NAME(RBPathStorageRef.clear(self:)); RB_EXPORT -bool RBPathStorageAppendElement(RBPathStorageRef storage, RBPathElement element, CGFloat const * points, const void * _Nullable userInfo) RB_SWIFT_NAME(RBPathStorageRef.append(self:element:points:userInfo:)); +void RBPathStorageAppendElement(RBPathStorageRef storage, RBPathElement element, CGFloat const * points, const void * _Nullable userInfo) RB_SWIFT_NAME(RBPathStorageRef.append(self:element:points:userInfo:)); RB_EXPORT bool RBPathStorageAppendPath(RBPathStorageRef, RBPath) RB_SWIFT_NAME(RBPathStorageRef.append(self:path:)); @@ -43,7 +43,7 @@ RB_EXPORT bool RBPathStorageIsSingleElement(RBPathStorageRef storage) RB_SWIFT_NAME(getter:RBPathStorageRef.isSingleElement(self:)); RB_EXPORT -uint32_t RBPathStorageGetBezierOrder(RBPathStorageRef storage) RB_SWIFT_NAME(getter:RBPathStorageRef.bezierOrder(self:)); +size_t RBPathStorageGetBezierOrder(RBPathStorageRef storage) RB_SWIFT_NAME(getter:RBPathStorageRef.bezierOrder(self:)); RB_EXPORT CGRect RBPathStorageGetBoundingRect(RBPathStorageRef storage) RB_SWIFT_NAME(getter:RBPathStorageRef.boundingRect(self:)); diff --git a/RB/2024/RenderBox.xcframework/ios-arm64-x86_64-simulator/RenderBox.framework/RenderBox.tbd b/RB/2024/RenderBox.xcframework/ios-arm64-x86_64-simulator/RenderBox.framework/RenderBox.tbd index 14b5c3f..edb776b 100644 --- a/RB/2024/RenderBox.xcframework/ios-arm64-x86_64-simulator/RenderBox.framework/RenderBox.tbd +++ b/RB/2024/RenderBox.xcframework/ios-arm64-x86_64-simulator/RenderBox.framework/RenderBox.tbd @@ -268,6 +268,7 @@ "_RBDrawingStateSetCTM", "_RBPathCopyInterpolatedPath", "_RBPathGetBoundingRect", + "_RBPathGetLength", "_RBDrawingStateClipLayer", "_RBDisplayListContentsXMLDictionary", "_RBColorMakeLinear", diff --git a/RB/2024/RenderBox.xcframework/macos-arm64e-arm64-x86_64/RenderBox.framework/Versions/A/Headers/RBPath.h b/RB/2024/RenderBox.xcframework/macos-arm64e-arm64-x86_64/RenderBox.framework/Versions/A/Headers/RBPath.h index c2a3fd2..b53bf38 100644 --- a/RB/2024/RenderBox.xcframework/macos-arm64e-arm64-x86_64/RenderBox.framework/Versions/A/Headers/RBPath.h +++ b/RB/2024/RenderBox.xcframework/macos-arm64e-arm64-x86_64/RenderBox.framework/Versions/A/Headers/RBPath.h @@ -5,6 +5,7 @@ #pragma once #include +#include #include RB_ASSUME_NONNULL_BEGIN @@ -20,12 +21,31 @@ typedef RB_ENUM(int32_t, RBPathElement) { RBPathElementCloseSubpath = 4, RBPathElementRect = 5, RBPathElementRoundedRect = 6, + RBPathElementEllipse = 7, RBPathElementFixedRoundedRectCircular = 8, RBPathElementFixedRoundedRectContinuous = 9, + RBPathElementUnevenRoundedRectCircular = 10, + RBPathElementUnevenRoundedRectContinuous = 11, + RBPathElementRelativeArc = 12, + RBPathElementArc = 13, + RBPathElementArcCounterclockwise = 14, + RBPathElementArcTo = 15, + RBPathElementEnd = 16, + RBPathElementTransformed = 17, + RBPathElementTrimmed = 18, + RBPathElementStroked = 19, + RBPathElementBoolean = 20, + RBPathElementBooleanSeparator = 21, + RBPathElementDilateGlyph = 22, + RBPathElementOffset = 23, + RBPathElementClipStroke = 24, RBPathElementInvalid = 25, } RB_SWIFT_NAME(RBPath.Element); +RB_EXPORT +const uint8_t __RBPathElementArgumentCount[25]; + /// Defines the shape of a rounded rectangle's corners. typedef RB_ENUM(int32_t, RBPathRoundedCornerStyle) { /// Quarter-circle rounded rect corners. @@ -35,9 +55,21 @@ typedef RB_ENUM(int32_t, RBPathRoundedCornerStyle) { } RB_SWIFT_NAME(RBPath.RoundedCornerStyle); /// Callback type for path element enumeration -/// Returns true to stop enumeration, false to continue +/// Returns true to continue enumeration, false to stop typedef bool (*RBPathApplyCallback)(void * info, RBPathElement element, const CGFloat *points, const void * _Nullable userInfo); +/// Callback for mapped Core Graphics elements. Return false to stop callbacks. +typedef bool (*RBPathApplierCallback)(void *info, const CGPathElement *element); + +typedef RB_ENUM(int32_t, RBPathLineElement) { + RBPathLineElementMoveToPoint = 0, + RBPathLineElementAddLineToPoint = 1, + RBPathLineElementCloseSubpath = 2, +}; + +/// The point is unused for a close-subpath callback. +typedef bool (*RBPathLineApplyCallback)(void *info, RBPathLineElement element, const CGPoint *point); + typedef struct RBPathCallbacks RBPathCallbacks RB_SWIFT_NAME(RBPath.ApplyCallback); typedef struct RBPathStorage * RBPathStorageRef RB_SWIFT_STRUCT RB_SWIFT_NAME(RBPath.Storage); @@ -47,6 +79,93 @@ typedef struct RBPath { const RBPathCallbacks * callbacks; } RBPath; +/// A primitive shape recognized by ``RBPathApplyShape``. +typedef RB_ENUM(int32_t, RBPathShapeType) { + RBPathShapeTypeRect = 0, + RBPathShapeTypeEllipse = 1, + RBPathShapeTypeLine = 2, + RBPathShapeTypeFixedRoundedRect = 3, + RBPathShapeTypeUnevenRoundedRect = 4, + RBPathShapeTypeNested = 5, + RBPathShapeTypeStroked = 6, + RBPathShapeTypeTrimmed = 7, + RBPathShapeTypeOffset = 8, +}; + +typedef struct RBPathRectShape { + CGAffineTransform transform; + CGRect rect; +} RBPathRectShape; + +typedef struct RBPathFixedRoundedRectShape { + CGAffineTransform transform; + CGRect rect; + CGSize cornerSize; + RBPathRoundedCornerStyle style; +} RBPathFixedRoundedRectShape; + +typedef struct RBPathUnevenRoundedRectShape { + CGAffineTransform transform; + CGRect rect; + CGFloat topLeftRadius; + CGFloat topRightRadius; + CGFloat bottomRightRadius; + CGFloat bottomLeftRadius; + RBPathRoundedCornerStyle style; +} RBPathUnevenRoundedRectShape; + +typedef struct RBPathLineShape { + CGPoint start; + CGPoint end; +} RBPathLineShape; + +typedef struct RBPathStrokeStyle { + CGFloat lineWidth; + int32_t lineCap; + int32_t lineJoin; + CGFloat miterLimit; + CGFloat dashPhase; + uint64_t dashCount; + const CGFloat * _Nullable dash; +} RBPathStrokeStyle; + +typedef struct RBPathStrokedShape { + RBPath path; + RBPathStrokeStyle style; +} RBPathStrokedShape; + +typedef struct RBPathNestedShape { + RBPath path; + CGAffineTransform transform; +} RBPathNestedShape; + +typedef struct RBPathTrimmedShape { + RBPath path; + CGFloat from; + CGFloat to; +} RBPathTrimmedShape; + +typedef union RBPathShape { + RBPathRectShape rect; + RBPathRectShape ellipse; + RBPathLineShape line; + RBPathFixedRoundedRectShape fixedRoundedRect; + RBPathUnevenRoundedRectShape unevenRoundedRect; + RBPathStrokedShape stroked; + RBPathNestedShape nested; + RBPathTrimmedShape trimmed; +} RBPathShape; + +#if defined(__cplusplus) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) +static_assert(sizeof(RBPath) == 0x10); +static_assert(offsetof(RBPathUnevenRoundedRectShape, rect) == 0x30); +static_assert(offsetof(RBPathUnevenRoundedRectShape, topLeftRadius) == 0x50); +static_assert(offsetof(RBPathUnevenRoundedRectShape, style) == 0x70); +static_assert(sizeof(RBPathShape) == 0x78); +#endif + +typedef void (*RBPathApplyShapeCallback)(void * info, RBPathShapeType type, const RBPathShape *shape); + /// Global empty path (storage = null, callbacks = &RBPathEmptyCallbacks) RB_EXPORT const RBPath RBPathEmpty RB_SWIFT_NAME(RBPath.empty); @@ -56,7 +175,7 @@ RB_EXPORT const RBPath RBPathNull RB_SWIFT_NAME(RBPath.null); RB_EXPORT -void RBPathRetain(RBPath path) RB_SWIFT_NAME(RBPath.retain(self:)); +RBPath RBPathRetain(RBPath path) RB_SWIFT_NAME(RBPath.retain(self:)); RB_EXPORT void RBPathRelease(RBPath path) RB_SWIFT_NAME(RBPath.release(self:)); @@ -64,7 +183,7 @@ void RBPathRelease(RBPath path) RB_SWIFT_NAME(RBPath.release(self:)); // MARK: - Path Creation RB_EXPORT -RBPath RBPathMakeWithCGPath(CGPathRef cgPath) RB_SWIFT_NAME(RBPath.init(cgPath:)); +RBPath RBPathMakeWithCGPath(CGPathRef _Nullable cgPath) RB_SWIFT_NAME(RBPath.init(cgPath:)); RB_EXPORT RBPath RBPathMakeRect(CGRect rect, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.init(rect:transform:)); @@ -76,12 +195,19 @@ RB_EXPORT RBPath RBPathMakeRoundedRect(CGRect rect, CGFloat cornerWidth, CGFloat cornerHeight, RBPathRoundedCornerStyle style, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.init(roundedRect:cornerWidth:cornerHeight:style:transform:)); RB_EXPORT -RBPath RBPathMakeUnevenRoundedRect(CGRect rect, CGFloat topLeftRadius, CGFloat bottomLeftRadius, CGFloat bottomRightRadius, CGFloat topRightRadius, RBPathRoundedCornerStyle style, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.init(roundedRect:topLeftRadius:bottomLeftRadius:bottomRightRadius:topRightRadius:style:transform:)); +RBPath RBPathMakeUnevenRoundedRect(CGRect rect, CGFloat topLeftRadius, CGFloat topRightRadius, CGFloat bottomRightRadius, CGFloat bottomLeftRadius, RBPathRoundedCornerStyle style, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.init(roundedRect:topLeftRadius:topRightRadius:bottomRightRadius:bottomLeftRadius:style:transform:)); -// MARK: - Path Transformation +RB_EXPORT +RBPath RBPathCopyTransformedPath(RBPath path, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.copy(self:transform:)); + +RB_EXPORT +RBPath RBPathCopyStrokedPath(RBPath path, CGFloat lineWidth, int32_t lineCap, int32_t lineJoin, CGFloat miterLimit, CGFloat dashPhase, const CGFloat * _Nullable dash, size_t dashCount) RB_SWIFT_NAME(RBPath.stroked(self:lineWidth:lineCap:lineJoin:miterLimit:dashPhase:dash:dashCount:)); RB_EXPORT -RBPath RBPathCopyTransformedPath(RBPath path, const CGAffineTransform *transform) RB_SWIFT_NAME(RBPath.copy(self:transform:)); +RBPath RBPathCopyTrimmedPath(RBPath path, CGFloat from, CGFloat to) RB_SWIFT_NAME(RBPath.trimmed(self:from:to:)); + +// MARK: - Path Transformation + static RB_INLINE bool RBPathIsNull(RBPath path) RB_SWIFT_NAME(getter:RBPath.isNull(self:)) { return path.storage == RBPathNull.storage && path.callbacks == RBPathNull.callbacks; @@ -92,24 +218,60 @@ static RB_INLINE bool RBPathIsNull(RBPath path) RB_SWIFT_NAME(getter:RBPath.isNu RB_EXPORT bool RBPathIsEmpty(RBPath path) RB_SWIFT_NAME(getter:RBPath.isEmpty(self:)); +RB_EXPORT +bool RBPathIsSingleElement(RBPath path) RB_SWIFT_NAME(getter:RBPath.isSingleElement(self:)); + +RB_EXPORT +size_t RBPathGetBezierOrder(RBPath path) RB_SWIFT_NAME(getter:RBPath.bezierOrder(self:)); + RB_EXPORT bool RBPathApplyElements(RBPath path, void * info, _Nullable RBPathApplyCallback callback) RB_SWIFT_NAME(RBPath.apply(self:info:callback:)); +RB_EXPORT +bool RBPathApplyShape(RBPath path, bool allowLine, void * info, RBPathApplyShapeCallback callback) RB_SWIFT_NAME(RBPath.applyShape(self:allowLine:info:callback:)); + RB_EXPORT bool RBPathEqualToPath(RBPath lhs, RBPath rhs) RB_SWIFT_NAME(RBPath.isEqual(self:to:)); // MARK: - CGPath Interoperability +RB_EXPORT +bool RBPathApply(RBPath path, const CGAffineTransform * _Nullable transform, void *info, RBPathApplierCallback callback) RB_SWIFT_NAME(RBPath.applyCGPathElements(self:transform:info:callback:)); + +RB_EXPORT +bool RBPathApplyLines(RBPath path, double tolerance, void *info, RBPathLineApplyCallback callback) RB_SWIFT_NAME(RBPath.applyLines(self:tolerance:info:callback:)); + +RB_EXPORT +double RBPathGetLength(RBPath path, double tolerance, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.length(self:tolerance:transform:)); + +RB_EXPORT +bool RBPathCanInterpolate(RBPath path, RBPath other) RB_SWIFT_NAME(RBPath.canInterpolate(self:to:)); + +RB_EXPORT +RBPath RBPathCopyInterpolatedPath(RBPath path, RBPath other, float fraction) RB_SWIFT_NAME(RBPath.interpolated(self:to:fraction:)); + +RB_EXPORT +CFDataRef RBPathCopyData(RBPath path) RB_SWIFT_NAME(getter:RBPath.data(self:)); + +RB_EXPORT +RBPath RBPathMakeWithData(CFDataRef data) RB_SWIFT_NAME(RBPath.init(data:)); + +RB_EXPORT +CFStringRef RBPathCopyDebugDescription(RBPath path) RB_SWIFT_NAME(getter:RBPath.debugDescription(self:)); + RB_EXPORT CGPathRef RBPathCopyCGPath(RBPath path) RB_SWIFT_NAME(getter:RBPath.cgPath(self:)); +RB_EXPORT +CGRect RBPathGetBoundingRect(RBPath path) RB_SWIFT_NAME(getter:RBPath.boundingRect(self:)); + // MARK: - Point Containment RB_EXPORT bool RBPathContainsPoint(RBPath path, CGPoint point, bool eoFill) RB_SWIFT_NAME(RBPath.contains(self:point:eoFill:)); RB_EXPORT -bool RBPathContainsPoints(RBPath path, uint64_t count, const CGPoint *points, bool eoFill, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.containsPoints(self:count:points:eoFill:transform:)); +uint64_t RBPathContainsPoints(RBPath path, uint64_t count, const CGPoint *points, bool eoFill, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.containsPoints(self:count:points:eoFill:transform:)); RB_EXTERN_C_END diff --git a/RB/2024/RenderBox.xcframework/macos-arm64e-arm64-x86_64/RenderBox.framework/Versions/A/Headers/RBPathCallbacks.h b/RB/2024/RenderBox.xcframework/macos-arm64e-arm64-x86_64/RenderBox.framework/Versions/A/Headers/RBPathCallbacks.h index d94c07a..8456e28 100644 --- a/RB/2024/RenderBox.xcframework/macos-arm64e-arm64-x86_64/RenderBox.framework/Versions/A/Headers/RBPathCallbacks.h +++ b/RB/2024/RenderBox.xcframework/macos-arm64e-arm64-x86_64/RenderBox.framework/Versions/A/Headers/RBPathCallbacks.h @@ -33,10 +33,10 @@ typedef struct RB_SWIFT_NAME(RBPath.Callbacks) RBPathCallbacks { bool (* _Nullable isEqual)(const void *object, const void *otherObject); bool (* _Nullable isEmpty)(const void *object); bool (* _Nullable isSingleElement)(const void *object); - uint32_t (* _Nullable bezierOrder)(const void *object); + size_t (* _Nullable bezierOrder)(const void *object); CGRect (* _Nullable boundingRect)(const void *object); CGPathRef _Nullable (* _Nullable cgPath)(const void *object); - const struct RBPathCallbacks * _Nullable (* _Nullable next)(const void *object); + RBPath (* _Nullable next)(const void *object); } RBPathCallbacks; /// Extended callbacks structure with additional extended callbacks argument @@ -48,10 +48,10 @@ typedef struct RB_SWIFT_NAME(RBPath.CallbacksExtended) RBPathCallbacksExtended { bool (* _Nullable isEqual)(const void *object, const void *otherObject, const struct RBPathCallbacksExtended *extended); bool (* _Nullable isEmpty)(const void *object, const struct RBPathCallbacksExtended *extended); bool (* _Nullable isSingleElement)(const void *object, const struct RBPathCallbacksExtended *extended); - uint32_t (* _Nullable bezierOrder)(const void *object, const struct RBPathCallbacksExtended *extended); + size_t (* _Nullable bezierOrder)(const void *object, const struct RBPathCallbacksExtended *extended); CGRect (* _Nullable boundingRect)(const void *object, const struct RBPathCallbacksExtended *extended); CGPathRef _Nullable (* _Nullable cgPath)(const void *object, const struct RBPathCallbacksExtended *extended); - const struct RBPathCallbacksExtended * _Nullable (* _Nullable next)(const void *object, const struct RBPathCallbacksExtended *extended); + RBPath (* _Nullable next)(const void *object, const struct RBPathCallbacksExtended *extended); } RBPathCallbacksExtended; /// Global callbacks for CGPath-backed paths diff --git a/RB/2024/RenderBox.xcframework/macos-arm64e-arm64-x86_64/RenderBox.framework/Versions/A/Headers/RBPathStorage.h b/RB/2024/RenderBox.xcframework/macos-arm64e-arm64-x86_64/RenderBox.framework/Versions/A/Headers/RBPathStorage.h index 6d1ccea..01e793f 100644 --- a/RB/2024/RenderBox.xcframework/macos-arm64e-arm64-x86_64/RenderBox.framework/Versions/A/Headers/RBPathStorage.h +++ b/RB/2024/RenderBox.xcframework/macos-arm64e-arm64-x86_64/RenderBox.framework/Versions/A/Headers/RBPathStorage.h @@ -16,7 +16,7 @@ RB_ASSUME_NONNULL_BEGIN RB_EXTERN_C_BEGIN RB_EXPORT -void RBPathStorageInit(RBPathStorageRef dst, uint32_t capacity, RBPathStorageRef _Nullable source) RB_SWIFT_NAME(RBPathStorageRef.initialize(self:capacity:source:)); +void RBPathStorageInit(RBPathStorageRef dst, size_t capacity, RBPathStorageRef _Nullable source) RB_SWIFT_NAME(RBPathStorageRef.initialize(self:capacity:source:)); RB_EXPORT void RBPathStorageDestroy(RBPathStorageRef storage) RB_SWIFT_NAME(RBPathStorageRef.destroy(self:)); @@ -25,7 +25,7 @@ RB_EXPORT void RBPathStorageClear(RBPathStorageRef storage) RB_SWIFT_NAME(RBPathStorageRef.clear(self:)); RB_EXPORT -bool RBPathStorageAppendElement(RBPathStorageRef storage, RBPathElement element, CGFloat const * points, const void * _Nullable userInfo) RB_SWIFT_NAME(RBPathStorageRef.append(self:element:points:userInfo:)); +void RBPathStorageAppendElement(RBPathStorageRef storage, RBPathElement element, CGFloat const * points, const void * _Nullable userInfo) RB_SWIFT_NAME(RBPathStorageRef.append(self:element:points:userInfo:)); RB_EXPORT bool RBPathStorageAppendPath(RBPathStorageRef, RBPath) RB_SWIFT_NAME(RBPathStorageRef.append(self:path:)); @@ -43,7 +43,7 @@ RB_EXPORT bool RBPathStorageIsSingleElement(RBPathStorageRef storage) RB_SWIFT_NAME(getter:RBPathStorageRef.isSingleElement(self:)); RB_EXPORT -uint32_t RBPathStorageGetBezierOrder(RBPathStorageRef storage) RB_SWIFT_NAME(getter:RBPathStorageRef.bezierOrder(self:)); +size_t RBPathStorageGetBezierOrder(RBPathStorageRef storage) RB_SWIFT_NAME(getter:RBPathStorageRef.bezierOrder(self:)); RB_EXPORT CGRect RBPathStorageGetBoundingRect(RBPathStorageRef storage) RB_SWIFT_NAME(getter:RBPathStorageRef.boundingRect(self:)); diff --git a/RB/2024/RenderBox.xcframework/macos-arm64e-arm64-x86_64/RenderBox.framework/Versions/A/RenderBox.tbd b/RB/2024/RenderBox.xcframework/macos-arm64e-arm64-x86_64/RenderBox.framework/Versions/A/RenderBox.tbd index 819f60d..c3c9f4a 100644 --- a/RB/2024/RenderBox.xcframework/macos-arm64e-arm64-x86_64/RenderBox.framework/Versions/A/RenderBox.tbd +++ b/RB/2024/RenderBox.xcframework/macos-arm64e-arm64-x86_64/RenderBox.framework/Versions/A/RenderBox.tbd @@ -231,6 +231,7 @@ "_RBDrawingStateSetCTM", "_RBPathCopyInterpolatedPath", "_RBPathGetBoundingRect", + "_RBPathGetLength", "_RBDrawingStateClipLayer", "_RBLayerCopyImageColorMode", "_RBDisplayListContentsXMLDictionary", diff --git a/RB/2024/RenderBox.xcframework/xros-arm64-arm64e/RenderBox.framework/Headers/RBPath.h b/RB/2024/RenderBox.xcframework/xros-arm64-arm64e/RenderBox.framework/Headers/RBPath.h index c2a3fd2..b53bf38 100644 --- a/RB/2024/RenderBox.xcframework/xros-arm64-arm64e/RenderBox.framework/Headers/RBPath.h +++ b/RB/2024/RenderBox.xcframework/xros-arm64-arm64e/RenderBox.framework/Headers/RBPath.h @@ -5,6 +5,7 @@ #pragma once #include +#include #include RB_ASSUME_NONNULL_BEGIN @@ -20,12 +21,31 @@ typedef RB_ENUM(int32_t, RBPathElement) { RBPathElementCloseSubpath = 4, RBPathElementRect = 5, RBPathElementRoundedRect = 6, + RBPathElementEllipse = 7, RBPathElementFixedRoundedRectCircular = 8, RBPathElementFixedRoundedRectContinuous = 9, + RBPathElementUnevenRoundedRectCircular = 10, + RBPathElementUnevenRoundedRectContinuous = 11, + RBPathElementRelativeArc = 12, + RBPathElementArc = 13, + RBPathElementArcCounterclockwise = 14, + RBPathElementArcTo = 15, + RBPathElementEnd = 16, + RBPathElementTransformed = 17, + RBPathElementTrimmed = 18, + RBPathElementStroked = 19, + RBPathElementBoolean = 20, + RBPathElementBooleanSeparator = 21, + RBPathElementDilateGlyph = 22, + RBPathElementOffset = 23, + RBPathElementClipStroke = 24, RBPathElementInvalid = 25, } RB_SWIFT_NAME(RBPath.Element); +RB_EXPORT +const uint8_t __RBPathElementArgumentCount[25]; + /// Defines the shape of a rounded rectangle's corners. typedef RB_ENUM(int32_t, RBPathRoundedCornerStyle) { /// Quarter-circle rounded rect corners. @@ -35,9 +55,21 @@ typedef RB_ENUM(int32_t, RBPathRoundedCornerStyle) { } RB_SWIFT_NAME(RBPath.RoundedCornerStyle); /// Callback type for path element enumeration -/// Returns true to stop enumeration, false to continue +/// Returns true to continue enumeration, false to stop typedef bool (*RBPathApplyCallback)(void * info, RBPathElement element, const CGFloat *points, const void * _Nullable userInfo); +/// Callback for mapped Core Graphics elements. Return false to stop callbacks. +typedef bool (*RBPathApplierCallback)(void *info, const CGPathElement *element); + +typedef RB_ENUM(int32_t, RBPathLineElement) { + RBPathLineElementMoveToPoint = 0, + RBPathLineElementAddLineToPoint = 1, + RBPathLineElementCloseSubpath = 2, +}; + +/// The point is unused for a close-subpath callback. +typedef bool (*RBPathLineApplyCallback)(void *info, RBPathLineElement element, const CGPoint *point); + typedef struct RBPathCallbacks RBPathCallbacks RB_SWIFT_NAME(RBPath.ApplyCallback); typedef struct RBPathStorage * RBPathStorageRef RB_SWIFT_STRUCT RB_SWIFT_NAME(RBPath.Storage); @@ -47,6 +79,93 @@ typedef struct RBPath { const RBPathCallbacks * callbacks; } RBPath; +/// A primitive shape recognized by ``RBPathApplyShape``. +typedef RB_ENUM(int32_t, RBPathShapeType) { + RBPathShapeTypeRect = 0, + RBPathShapeTypeEllipse = 1, + RBPathShapeTypeLine = 2, + RBPathShapeTypeFixedRoundedRect = 3, + RBPathShapeTypeUnevenRoundedRect = 4, + RBPathShapeTypeNested = 5, + RBPathShapeTypeStroked = 6, + RBPathShapeTypeTrimmed = 7, + RBPathShapeTypeOffset = 8, +}; + +typedef struct RBPathRectShape { + CGAffineTransform transform; + CGRect rect; +} RBPathRectShape; + +typedef struct RBPathFixedRoundedRectShape { + CGAffineTransform transform; + CGRect rect; + CGSize cornerSize; + RBPathRoundedCornerStyle style; +} RBPathFixedRoundedRectShape; + +typedef struct RBPathUnevenRoundedRectShape { + CGAffineTransform transform; + CGRect rect; + CGFloat topLeftRadius; + CGFloat topRightRadius; + CGFloat bottomRightRadius; + CGFloat bottomLeftRadius; + RBPathRoundedCornerStyle style; +} RBPathUnevenRoundedRectShape; + +typedef struct RBPathLineShape { + CGPoint start; + CGPoint end; +} RBPathLineShape; + +typedef struct RBPathStrokeStyle { + CGFloat lineWidth; + int32_t lineCap; + int32_t lineJoin; + CGFloat miterLimit; + CGFloat dashPhase; + uint64_t dashCount; + const CGFloat * _Nullable dash; +} RBPathStrokeStyle; + +typedef struct RBPathStrokedShape { + RBPath path; + RBPathStrokeStyle style; +} RBPathStrokedShape; + +typedef struct RBPathNestedShape { + RBPath path; + CGAffineTransform transform; +} RBPathNestedShape; + +typedef struct RBPathTrimmedShape { + RBPath path; + CGFloat from; + CGFloat to; +} RBPathTrimmedShape; + +typedef union RBPathShape { + RBPathRectShape rect; + RBPathRectShape ellipse; + RBPathLineShape line; + RBPathFixedRoundedRectShape fixedRoundedRect; + RBPathUnevenRoundedRectShape unevenRoundedRect; + RBPathStrokedShape stroked; + RBPathNestedShape nested; + RBPathTrimmedShape trimmed; +} RBPathShape; + +#if defined(__cplusplus) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) +static_assert(sizeof(RBPath) == 0x10); +static_assert(offsetof(RBPathUnevenRoundedRectShape, rect) == 0x30); +static_assert(offsetof(RBPathUnevenRoundedRectShape, topLeftRadius) == 0x50); +static_assert(offsetof(RBPathUnevenRoundedRectShape, style) == 0x70); +static_assert(sizeof(RBPathShape) == 0x78); +#endif + +typedef void (*RBPathApplyShapeCallback)(void * info, RBPathShapeType type, const RBPathShape *shape); + /// Global empty path (storage = null, callbacks = &RBPathEmptyCallbacks) RB_EXPORT const RBPath RBPathEmpty RB_SWIFT_NAME(RBPath.empty); @@ -56,7 +175,7 @@ RB_EXPORT const RBPath RBPathNull RB_SWIFT_NAME(RBPath.null); RB_EXPORT -void RBPathRetain(RBPath path) RB_SWIFT_NAME(RBPath.retain(self:)); +RBPath RBPathRetain(RBPath path) RB_SWIFT_NAME(RBPath.retain(self:)); RB_EXPORT void RBPathRelease(RBPath path) RB_SWIFT_NAME(RBPath.release(self:)); @@ -64,7 +183,7 @@ void RBPathRelease(RBPath path) RB_SWIFT_NAME(RBPath.release(self:)); // MARK: - Path Creation RB_EXPORT -RBPath RBPathMakeWithCGPath(CGPathRef cgPath) RB_SWIFT_NAME(RBPath.init(cgPath:)); +RBPath RBPathMakeWithCGPath(CGPathRef _Nullable cgPath) RB_SWIFT_NAME(RBPath.init(cgPath:)); RB_EXPORT RBPath RBPathMakeRect(CGRect rect, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.init(rect:transform:)); @@ -76,12 +195,19 @@ RB_EXPORT RBPath RBPathMakeRoundedRect(CGRect rect, CGFloat cornerWidth, CGFloat cornerHeight, RBPathRoundedCornerStyle style, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.init(roundedRect:cornerWidth:cornerHeight:style:transform:)); RB_EXPORT -RBPath RBPathMakeUnevenRoundedRect(CGRect rect, CGFloat topLeftRadius, CGFloat bottomLeftRadius, CGFloat bottomRightRadius, CGFloat topRightRadius, RBPathRoundedCornerStyle style, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.init(roundedRect:topLeftRadius:bottomLeftRadius:bottomRightRadius:topRightRadius:style:transform:)); +RBPath RBPathMakeUnevenRoundedRect(CGRect rect, CGFloat topLeftRadius, CGFloat topRightRadius, CGFloat bottomRightRadius, CGFloat bottomLeftRadius, RBPathRoundedCornerStyle style, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.init(roundedRect:topLeftRadius:topRightRadius:bottomRightRadius:bottomLeftRadius:style:transform:)); -// MARK: - Path Transformation +RB_EXPORT +RBPath RBPathCopyTransformedPath(RBPath path, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.copy(self:transform:)); + +RB_EXPORT +RBPath RBPathCopyStrokedPath(RBPath path, CGFloat lineWidth, int32_t lineCap, int32_t lineJoin, CGFloat miterLimit, CGFloat dashPhase, const CGFloat * _Nullable dash, size_t dashCount) RB_SWIFT_NAME(RBPath.stroked(self:lineWidth:lineCap:lineJoin:miterLimit:dashPhase:dash:dashCount:)); RB_EXPORT -RBPath RBPathCopyTransformedPath(RBPath path, const CGAffineTransform *transform) RB_SWIFT_NAME(RBPath.copy(self:transform:)); +RBPath RBPathCopyTrimmedPath(RBPath path, CGFloat from, CGFloat to) RB_SWIFT_NAME(RBPath.trimmed(self:from:to:)); + +// MARK: - Path Transformation + static RB_INLINE bool RBPathIsNull(RBPath path) RB_SWIFT_NAME(getter:RBPath.isNull(self:)) { return path.storage == RBPathNull.storage && path.callbacks == RBPathNull.callbacks; @@ -92,24 +218,60 @@ static RB_INLINE bool RBPathIsNull(RBPath path) RB_SWIFT_NAME(getter:RBPath.isNu RB_EXPORT bool RBPathIsEmpty(RBPath path) RB_SWIFT_NAME(getter:RBPath.isEmpty(self:)); +RB_EXPORT +bool RBPathIsSingleElement(RBPath path) RB_SWIFT_NAME(getter:RBPath.isSingleElement(self:)); + +RB_EXPORT +size_t RBPathGetBezierOrder(RBPath path) RB_SWIFT_NAME(getter:RBPath.bezierOrder(self:)); + RB_EXPORT bool RBPathApplyElements(RBPath path, void * info, _Nullable RBPathApplyCallback callback) RB_SWIFT_NAME(RBPath.apply(self:info:callback:)); +RB_EXPORT +bool RBPathApplyShape(RBPath path, bool allowLine, void * info, RBPathApplyShapeCallback callback) RB_SWIFT_NAME(RBPath.applyShape(self:allowLine:info:callback:)); + RB_EXPORT bool RBPathEqualToPath(RBPath lhs, RBPath rhs) RB_SWIFT_NAME(RBPath.isEqual(self:to:)); // MARK: - CGPath Interoperability +RB_EXPORT +bool RBPathApply(RBPath path, const CGAffineTransform * _Nullable transform, void *info, RBPathApplierCallback callback) RB_SWIFT_NAME(RBPath.applyCGPathElements(self:transform:info:callback:)); + +RB_EXPORT +bool RBPathApplyLines(RBPath path, double tolerance, void *info, RBPathLineApplyCallback callback) RB_SWIFT_NAME(RBPath.applyLines(self:tolerance:info:callback:)); + +RB_EXPORT +double RBPathGetLength(RBPath path, double tolerance, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.length(self:tolerance:transform:)); + +RB_EXPORT +bool RBPathCanInterpolate(RBPath path, RBPath other) RB_SWIFT_NAME(RBPath.canInterpolate(self:to:)); + +RB_EXPORT +RBPath RBPathCopyInterpolatedPath(RBPath path, RBPath other, float fraction) RB_SWIFT_NAME(RBPath.interpolated(self:to:fraction:)); + +RB_EXPORT +CFDataRef RBPathCopyData(RBPath path) RB_SWIFT_NAME(getter:RBPath.data(self:)); + +RB_EXPORT +RBPath RBPathMakeWithData(CFDataRef data) RB_SWIFT_NAME(RBPath.init(data:)); + +RB_EXPORT +CFStringRef RBPathCopyDebugDescription(RBPath path) RB_SWIFT_NAME(getter:RBPath.debugDescription(self:)); + RB_EXPORT CGPathRef RBPathCopyCGPath(RBPath path) RB_SWIFT_NAME(getter:RBPath.cgPath(self:)); +RB_EXPORT +CGRect RBPathGetBoundingRect(RBPath path) RB_SWIFT_NAME(getter:RBPath.boundingRect(self:)); + // MARK: - Point Containment RB_EXPORT bool RBPathContainsPoint(RBPath path, CGPoint point, bool eoFill) RB_SWIFT_NAME(RBPath.contains(self:point:eoFill:)); RB_EXPORT -bool RBPathContainsPoints(RBPath path, uint64_t count, const CGPoint *points, bool eoFill, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.containsPoints(self:count:points:eoFill:transform:)); +uint64_t RBPathContainsPoints(RBPath path, uint64_t count, const CGPoint *points, bool eoFill, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.containsPoints(self:count:points:eoFill:transform:)); RB_EXTERN_C_END diff --git a/RB/2024/RenderBox.xcframework/xros-arm64-arm64e/RenderBox.framework/Headers/RBPathCallbacks.h b/RB/2024/RenderBox.xcframework/xros-arm64-arm64e/RenderBox.framework/Headers/RBPathCallbacks.h index d94c07a..8456e28 100644 --- a/RB/2024/RenderBox.xcframework/xros-arm64-arm64e/RenderBox.framework/Headers/RBPathCallbacks.h +++ b/RB/2024/RenderBox.xcframework/xros-arm64-arm64e/RenderBox.framework/Headers/RBPathCallbacks.h @@ -33,10 +33,10 @@ typedef struct RB_SWIFT_NAME(RBPath.Callbacks) RBPathCallbacks { bool (* _Nullable isEqual)(const void *object, const void *otherObject); bool (* _Nullable isEmpty)(const void *object); bool (* _Nullable isSingleElement)(const void *object); - uint32_t (* _Nullable bezierOrder)(const void *object); + size_t (* _Nullable bezierOrder)(const void *object); CGRect (* _Nullable boundingRect)(const void *object); CGPathRef _Nullable (* _Nullable cgPath)(const void *object); - const struct RBPathCallbacks * _Nullable (* _Nullable next)(const void *object); + RBPath (* _Nullable next)(const void *object); } RBPathCallbacks; /// Extended callbacks structure with additional extended callbacks argument @@ -48,10 +48,10 @@ typedef struct RB_SWIFT_NAME(RBPath.CallbacksExtended) RBPathCallbacksExtended { bool (* _Nullable isEqual)(const void *object, const void *otherObject, const struct RBPathCallbacksExtended *extended); bool (* _Nullable isEmpty)(const void *object, const struct RBPathCallbacksExtended *extended); bool (* _Nullable isSingleElement)(const void *object, const struct RBPathCallbacksExtended *extended); - uint32_t (* _Nullable bezierOrder)(const void *object, const struct RBPathCallbacksExtended *extended); + size_t (* _Nullable bezierOrder)(const void *object, const struct RBPathCallbacksExtended *extended); CGRect (* _Nullable boundingRect)(const void *object, const struct RBPathCallbacksExtended *extended); CGPathRef _Nullable (* _Nullable cgPath)(const void *object, const struct RBPathCallbacksExtended *extended); - const struct RBPathCallbacksExtended * _Nullable (* _Nullable next)(const void *object, const struct RBPathCallbacksExtended *extended); + RBPath (* _Nullable next)(const void *object, const struct RBPathCallbacksExtended *extended); } RBPathCallbacksExtended; /// Global callbacks for CGPath-backed paths diff --git a/RB/2024/RenderBox.xcframework/xros-arm64-arm64e/RenderBox.framework/Headers/RBPathStorage.h b/RB/2024/RenderBox.xcframework/xros-arm64-arm64e/RenderBox.framework/Headers/RBPathStorage.h index 6d1ccea..01e793f 100644 --- a/RB/2024/RenderBox.xcframework/xros-arm64-arm64e/RenderBox.framework/Headers/RBPathStorage.h +++ b/RB/2024/RenderBox.xcframework/xros-arm64-arm64e/RenderBox.framework/Headers/RBPathStorage.h @@ -16,7 +16,7 @@ RB_ASSUME_NONNULL_BEGIN RB_EXTERN_C_BEGIN RB_EXPORT -void RBPathStorageInit(RBPathStorageRef dst, uint32_t capacity, RBPathStorageRef _Nullable source) RB_SWIFT_NAME(RBPathStorageRef.initialize(self:capacity:source:)); +void RBPathStorageInit(RBPathStorageRef dst, size_t capacity, RBPathStorageRef _Nullable source) RB_SWIFT_NAME(RBPathStorageRef.initialize(self:capacity:source:)); RB_EXPORT void RBPathStorageDestroy(RBPathStorageRef storage) RB_SWIFT_NAME(RBPathStorageRef.destroy(self:)); @@ -25,7 +25,7 @@ RB_EXPORT void RBPathStorageClear(RBPathStorageRef storage) RB_SWIFT_NAME(RBPathStorageRef.clear(self:)); RB_EXPORT -bool RBPathStorageAppendElement(RBPathStorageRef storage, RBPathElement element, CGFloat const * points, const void * _Nullable userInfo) RB_SWIFT_NAME(RBPathStorageRef.append(self:element:points:userInfo:)); +void RBPathStorageAppendElement(RBPathStorageRef storage, RBPathElement element, CGFloat const * points, const void * _Nullable userInfo) RB_SWIFT_NAME(RBPathStorageRef.append(self:element:points:userInfo:)); RB_EXPORT bool RBPathStorageAppendPath(RBPathStorageRef, RBPath) RB_SWIFT_NAME(RBPathStorageRef.append(self:path:)); @@ -43,7 +43,7 @@ RB_EXPORT bool RBPathStorageIsSingleElement(RBPathStorageRef storage) RB_SWIFT_NAME(getter:RBPathStorageRef.isSingleElement(self:)); RB_EXPORT -uint32_t RBPathStorageGetBezierOrder(RBPathStorageRef storage) RB_SWIFT_NAME(getter:RBPathStorageRef.bezierOrder(self:)); +size_t RBPathStorageGetBezierOrder(RBPathStorageRef storage) RB_SWIFT_NAME(getter:RBPathStorageRef.bezierOrder(self:)); RB_EXPORT CGRect RBPathStorageGetBoundingRect(RBPathStorageRef storage) RB_SWIFT_NAME(getter:RBPathStorageRef.boundingRect(self:)); diff --git a/RB/2024/RenderBox.xcframework/xros-arm64-x86_64-simulator/RenderBox.framework/Headers/RBPath.h b/RB/2024/RenderBox.xcframework/xros-arm64-x86_64-simulator/RenderBox.framework/Headers/RBPath.h index c2a3fd2..b53bf38 100644 --- a/RB/2024/RenderBox.xcframework/xros-arm64-x86_64-simulator/RenderBox.framework/Headers/RBPath.h +++ b/RB/2024/RenderBox.xcframework/xros-arm64-x86_64-simulator/RenderBox.framework/Headers/RBPath.h @@ -5,6 +5,7 @@ #pragma once #include +#include #include RB_ASSUME_NONNULL_BEGIN @@ -20,12 +21,31 @@ typedef RB_ENUM(int32_t, RBPathElement) { RBPathElementCloseSubpath = 4, RBPathElementRect = 5, RBPathElementRoundedRect = 6, + RBPathElementEllipse = 7, RBPathElementFixedRoundedRectCircular = 8, RBPathElementFixedRoundedRectContinuous = 9, + RBPathElementUnevenRoundedRectCircular = 10, + RBPathElementUnevenRoundedRectContinuous = 11, + RBPathElementRelativeArc = 12, + RBPathElementArc = 13, + RBPathElementArcCounterclockwise = 14, + RBPathElementArcTo = 15, + RBPathElementEnd = 16, + RBPathElementTransformed = 17, + RBPathElementTrimmed = 18, + RBPathElementStroked = 19, + RBPathElementBoolean = 20, + RBPathElementBooleanSeparator = 21, + RBPathElementDilateGlyph = 22, + RBPathElementOffset = 23, + RBPathElementClipStroke = 24, RBPathElementInvalid = 25, } RB_SWIFT_NAME(RBPath.Element); +RB_EXPORT +const uint8_t __RBPathElementArgumentCount[25]; + /// Defines the shape of a rounded rectangle's corners. typedef RB_ENUM(int32_t, RBPathRoundedCornerStyle) { /// Quarter-circle rounded rect corners. @@ -35,9 +55,21 @@ typedef RB_ENUM(int32_t, RBPathRoundedCornerStyle) { } RB_SWIFT_NAME(RBPath.RoundedCornerStyle); /// Callback type for path element enumeration -/// Returns true to stop enumeration, false to continue +/// Returns true to continue enumeration, false to stop typedef bool (*RBPathApplyCallback)(void * info, RBPathElement element, const CGFloat *points, const void * _Nullable userInfo); +/// Callback for mapped Core Graphics elements. Return false to stop callbacks. +typedef bool (*RBPathApplierCallback)(void *info, const CGPathElement *element); + +typedef RB_ENUM(int32_t, RBPathLineElement) { + RBPathLineElementMoveToPoint = 0, + RBPathLineElementAddLineToPoint = 1, + RBPathLineElementCloseSubpath = 2, +}; + +/// The point is unused for a close-subpath callback. +typedef bool (*RBPathLineApplyCallback)(void *info, RBPathLineElement element, const CGPoint *point); + typedef struct RBPathCallbacks RBPathCallbacks RB_SWIFT_NAME(RBPath.ApplyCallback); typedef struct RBPathStorage * RBPathStorageRef RB_SWIFT_STRUCT RB_SWIFT_NAME(RBPath.Storage); @@ -47,6 +79,93 @@ typedef struct RBPath { const RBPathCallbacks * callbacks; } RBPath; +/// A primitive shape recognized by ``RBPathApplyShape``. +typedef RB_ENUM(int32_t, RBPathShapeType) { + RBPathShapeTypeRect = 0, + RBPathShapeTypeEllipse = 1, + RBPathShapeTypeLine = 2, + RBPathShapeTypeFixedRoundedRect = 3, + RBPathShapeTypeUnevenRoundedRect = 4, + RBPathShapeTypeNested = 5, + RBPathShapeTypeStroked = 6, + RBPathShapeTypeTrimmed = 7, + RBPathShapeTypeOffset = 8, +}; + +typedef struct RBPathRectShape { + CGAffineTransform transform; + CGRect rect; +} RBPathRectShape; + +typedef struct RBPathFixedRoundedRectShape { + CGAffineTransform transform; + CGRect rect; + CGSize cornerSize; + RBPathRoundedCornerStyle style; +} RBPathFixedRoundedRectShape; + +typedef struct RBPathUnevenRoundedRectShape { + CGAffineTransform transform; + CGRect rect; + CGFloat topLeftRadius; + CGFloat topRightRadius; + CGFloat bottomRightRadius; + CGFloat bottomLeftRadius; + RBPathRoundedCornerStyle style; +} RBPathUnevenRoundedRectShape; + +typedef struct RBPathLineShape { + CGPoint start; + CGPoint end; +} RBPathLineShape; + +typedef struct RBPathStrokeStyle { + CGFloat lineWidth; + int32_t lineCap; + int32_t lineJoin; + CGFloat miterLimit; + CGFloat dashPhase; + uint64_t dashCount; + const CGFloat * _Nullable dash; +} RBPathStrokeStyle; + +typedef struct RBPathStrokedShape { + RBPath path; + RBPathStrokeStyle style; +} RBPathStrokedShape; + +typedef struct RBPathNestedShape { + RBPath path; + CGAffineTransform transform; +} RBPathNestedShape; + +typedef struct RBPathTrimmedShape { + RBPath path; + CGFloat from; + CGFloat to; +} RBPathTrimmedShape; + +typedef union RBPathShape { + RBPathRectShape rect; + RBPathRectShape ellipse; + RBPathLineShape line; + RBPathFixedRoundedRectShape fixedRoundedRect; + RBPathUnevenRoundedRectShape unevenRoundedRect; + RBPathStrokedShape stroked; + RBPathNestedShape nested; + RBPathTrimmedShape trimmed; +} RBPathShape; + +#if defined(__cplusplus) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) +static_assert(sizeof(RBPath) == 0x10); +static_assert(offsetof(RBPathUnevenRoundedRectShape, rect) == 0x30); +static_assert(offsetof(RBPathUnevenRoundedRectShape, topLeftRadius) == 0x50); +static_assert(offsetof(RBPathUnevenRoundedRectShape, style) == 0x70); +static_assert(sizeof(RBPathShape) == 0x78); +#endif + +typedef void (*RBPathApplyShapeCallback)(void * info, RBPathShapeType type, const RBPathShape *shape); + /// Global empty path (storage = null, callbacks = &RBPathEmptyCallbacks) RB_EXPORT const RBPath RBPathEmpty RB_SWIFT_NAME(RBPath.empty); @@ -56,7 +175,7 @@ RB_EXPORT const RBPath RBPathNull RB_SWIFT_NAME(RBPath.null); RB_EXPORT -void RBPathRetain(RBPath path) RB_SWIFT_NAME(RBPath.retain(self:)); +RBPath RBPathRetain(RBPath path) RB_SWIFT_NAME(RBPath.retain(self:)); RB_EXPORT void RBPathRelease(RBPath path) RB_SWIFT_NAME(RBPath.release(self:)); @@ -64,7 +183,7 @@ void RBPathRelease(RBPath path) RB_SWIFT_NAME(RBPath.release(self:)); // MARK: - Path Creation RB_EXPORT -RBPath RBPathMakeWithCGPath(CGPathRef cgPath) RB_SWIFT_NAME(RBPath.init(cgPath:)); +RBPath RBPathMakeWithCGPath(CGPathRef _Nullable cgPath) RB_SWIFT_NAME(RBPath.init(cgPath:)); RB_EXPORT RBPath RBPathMakeRect(CGRect rect, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.init(rect:transform:)); @@ -76,12 +195,19 @@ RB_EXPORT RBPath RBPathMakeRoundedRect(CGRect rect, CGFloat cornerWidth, CGFloat cornerHeight, RBPathRoundedCornerStyle style, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.init(roundedRect:cornerWidth:cornerHeight:style:transform:)); RB_EXPORT -RBPath RBPathMakeUnevenRoundedRect(CGRect rect, CGFloat topLeftRadius, CGFloat bottomLeftRadius, CGFloat bottomRightRadius, CGFloat topRightRadius, RBPathRoundedCornerStyle style, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.init(roundedRect:topLeftRadius:bottomLeftRadius:bottomRightRadius:topRightRadius:style:transform:)); +RBPath RBPathMakeUnevenRoundedRect(CGRect rect, CGFloat topLeftRadius, CGFloat topRightRadius, CGFloat bottomRightRadius, CGFloat bottomLeftRadius, RBPathRoundedCornerStyle style, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.init(roundedRect:topLeftRadius:topRightRadius:bottomRightRadius:bottomLeftRadius:style:transform:)); -// MARK: - Path Transformation +RB_EXPORT +RBPath RBPathCopyTransformedPath(RBPath path, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.copy(self:transform:)); + +RB_EXPORT +RBPath RBPathCopyStrokedPath(RBPath path, CGFloat lineWidth, int32_t lineCap, int32_t lineJoin, CGFloat miterLimit, CGFloat dashPhase, const CGFloat * _Nullable dash, size_t dashCount) RB_SWIFT_NAME(RBPath.stroked(self:lineWidth:lineCap:lineJoin:miterLimit:dashPhase:dash:dashCount:)); RB_EXPORT -RBPath RBPathCopyTransformedPath(RBPath path, const CGAffineTransform *transform) RB_SWIFT_NAME(RBPath.copy(self:transform:)); +RBPath RBPathCopyTrimmedPath(RBPath path, CGFloat from, CGFloat to) RB_SWIFT_NAME(RBPath.trimmed(self:from:to:)); + +// MARK: - Path Transformation + static RB_INLINE bool RBPathIsNull(RBPath path) RB_SWIFT_NAME(getter:RBPath.isNull(self:)) { return path.storage == RBPathNull.storage && path.callbacks == RBPathNull.callbacks; @@ -92,24 +218,60 @@ static RB_INLINE bool RBPathIsNull(RBPath path) RB_SWIFT_NAME(getter:RBPath.isNu RB_EXPORT bool RBPathIsEmpty(RBPath path) RB_SWIFT_NAME(getter:RBPath.isEmpty(self:)); +RB_EXPORT +bool RBPathIsSingleElement(RBPath path) RB_SWIFT_NAME(getter:RBPath.isSingleElement(self:)); + +RB_EXPORT +size_t RBPathGetBezierOrder(RBPath path) RB_SWIFT_NAME(getter:RBPath.bezierOrder(self:)); + RB_EXPORT bool RBPathApplyElements(RBPath path, void * info, _Nullable RBPathApplyCallback callback) RB_SWIFT_NAME(RBPath.apply(self:info:callback:)); +RB_EXPORT +bool RBPathApplyShape(RBPath path, bool allowLine, void * info, RBPathApplyShapeCallback callback) RB_SWIFT_NAME(RBPath.applyShape(self:allowLine:info:callback:)); + RB_EXPORT bool RBPathEqualToPath(RBPath lhs, RBPath rhs) RB_SWIFT_NAME(RBPath.isEqual(self:to:)); // MARK: - CGPath Interoperability +RB_EXPORT +bool RBPathApply(RBPath path, const CGAffineTransform * _Nullable transform, void *info, RBPathApplierCallback callback) RB_SWIFT_NAME(RBPath.applyCGPathElements(self:transform:info:callback:)); + +RB_EXPORT +bool RBPathApplyLines(RBPath path, double tolerance, void *info, RBPathLineApplyCallback callback) RB_SWIFT_NAME(RBPath.applyLines(self:tolerance:info:callback:)); + +RB_EXPORT +double RBPathGetLength(RBPath path, double tolerance, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.length(self:tolerance:transform:)); + +RB_EXPORT +bool RBPathCanInterpolate(RBPath path, RBPath other) RB_SWIFT_NAME(RBPath.canInterpolate(self:to:)); + +RB_EXPORT +RBPath RBPathCopyInterpolatedPath(RBPath path, RBPath other, float fraction) RB_SWIFT_NAME(RBPath.interpolated(self:to:fraction:)); + +RB_EXPORT +CFDataRef RBPathCopyData(RBPath path) RB_SWIFT_NAME(getter:RBPath.data(self:)); + +RB_EXPORT +RBPath RBPathMakeWithData(CFDataRef data) RB_SWIFT_NAME(RBPath.init(data:)); + +RB_EXPORT +CFStringRef RBPathCopyDebugDescription(RBPath path) RB_SWIFT_NAME(getter:RBPath.debugDescription(self:)); + RB_EXPORT CGPathRef RBPathCopyCGPath(RBPath path) RB_SWIFT_NAME(getter:RBPath.cgPath(self:)); +RB_EXPORT +CGRect RBPathGetBoundingRect(RBPath path) RB_SWIFT_NAME(getter:RBPath.boundingRect(self:)); + // MARK: - Point Containment RB_EXPORT bool RBPathContainsPoint(RBPath path, CGPoint point, bool eoFill) RB_SWIFT_NAME(RBPath.contains(self:point:eoFill:)); RB_EXPORT -bool RBPathContainsPoints(RBPath path, uint64_t count, const CGPoint *points, bool eoFill, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.containsPoints(self:count:points:eoFill:transform:)); +uint64_t RBPathContainsPoints(RBPath path, uint64_t count, const CGPoint *points, bool eoFill, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.containsPoints(self:count:points:eoFill:transform:)); RB_EXTERN_C_END diff --git a/RB/2024/RenderBox.xcframework/xros-arm64-x86_64-simulator/RenderBox.framework/Headers/RBPathCallbacks.h b/RB/2024/RenderBox.xcframework/xros-arm64-x86_64-simulator/RenderBox.framework/Headers/RBPathCallbacks.h index d94c07a..8456e28 100644 --- a/RB/2024/RenderBox.xcframework/xros-arm64-x86_64-simulator/RenderBox.framework/Headers/RBPathCallbacks.h +++ b/RB/2024/RenderBox.xcframework/xros-arm64-x86_64-simulator/RenderBox.framework/Headers/RBPathCallbacks.h @@ -33,10 +33,10 @@ typedef struct RB_SWIFT_NAME(RBPath.Callbacks) RBPathCallbacks { bool (* _Nullable isEqual)(const void *object, const void *otherObject); bool (* _Nullable isEmpty)(const void *object); bool (* _Nullable isSingleElement)(const void *object); - uint32_t (* _Nullable bezierOrder)(const void *object); + size_t (* _Nullable bezierOrder)(const void *object); CGRect (* _Nullable boundingRect)(const void *object); CGPathRef _Nullable (* _Nullable cgPath)(const void *object); - const struct RBPathCallbacks * _Nullable (* _Nullable next)(const void *object); + RBPath (* _Nullable next)(const void *object); } RBPathCallbacks; /// Extended callbacks structure with additional extended callbacks argument @@ -48,10 +48,10 @@ typedef struct RB_SWIFT_NAME(RBPath.CallbacksExtended) RBPathCallbacksExtended { bool (* _Nullable isEqual)(const void *object, const void *otherObject, const struct RBPathCallbacksExtended *extended); bool (* _Nullable isEmpty)(const void *object, const struct RBPathCallbacksExtended *extended); bool (* _Nullable isSingleElement)(const void *object, const struct RBPathCallbacksExtended *extended); - uint32_t (* _Nullable bezierOrder)(const void *object, const struct RBPathCallbacksExtended *extended); + size_t (* _Nullable bezierOrder)(const void *object, const struct RBPathCallbacksExtended *extended); CGRect (* _Nullable boundingRect)(const void *object, const struct RBPathCallbacksExtended *extended); CGPathRef _Nullable (* _Nullable cgPath)(const void *object, const struct RBPathCallbacksExtended *extended); - const struct RBPathCallbacksExtended * _Nullable (* _Nullable next)(const void *object, const struct RBPathCallbacksExtended *extended); + RBPath (* _Nullable next)(const void *object, const struct RBPathCallbacksExtended *extended); } RBPathCallbacksExtended; /// Global callbacks for CGPath-backed paths diff --git a/RB/2024/RenderBox.xcframework/xros-arm64-x86_64-simulator/RenderBox.framework/Headers/RBPathStorage.h b/RB/2024/RenderBox.xcframework/xros-arm64-x86_64-simulator/RenderBox.framework/Headers/RBPathStorage.h index 6d1ccea..01e793f 100644 --- a/RB/2024/RenderBox.xcframework/xros-arm64-x86_64-simulator/RenderBox.framework/Headers/RBPathStorage.h +++ b/RB/2024/RenderBox.xcframework/xros-arm64-x86_64-simulator/RenderBox.framework/Headers/RBPathStorage.h @@ -16,7 +16,7 @@ RB_ASSUME_NONNULL_BEGIN RB_EXTERN_C_BEGIN RB_EXPORT -void RBPathStorageInit(RBPathStorageRef dst, uint32_t capacity, RBPathStorageRef _Nullable source) RB_SWIFT_NAME(RBPathStorageRef.initialize(self:capacity:source:)); +void RBPathStorageInit(RBPathStorageRef dst, size_t capacity, RBPathStorageRef _Nullable source) RB_SWIFT_NAME(RBPathStorageRef.initialize(self:capacity:source:)); RB_EXPORT void RBPathStorageDestroy(RBPathStorageRef storage) RB_SWIFT_NAME(RBPathStorageRef.destroy(self:)); @@ -25,7 +25,7 @@ RB_EXPORT void RBPathStorageClear(RBPathStorageRef storage) RB_SWIFT_NAME(RBPathStorageRef.clear(self:)); RB_EXPORT -bool RBPathStorageAppendElement(RBPathStorageRef storage, RBPathElement element, CGFloat const * points, const void * _Nullable userInfo) RB_SWIFT_NAME(RBPathStorageRef.append(self:element:points:userInfo:)); +void RBPathStorageAppendElement(RBPathStorageRef storage, RBPathElement element, CGFloat const * points, const void * _Nullable userInfo) RB_SWIFT_NAME(RBPathStorageRef.append(self:element:points:userInfo:)); RB_EXPORT bool RBPathStorageAppendPath(RBPathStorageRef, RBPath) RB_SWIFT_NAME(RBPathStorageRef.append(self:path:)); @@ -43,7 +43,7 @@ RB_EXPORT bool RBPathStorageIsSingleElement(RBPathStorageRef storage) RB_SWIFT_NAME(getter:RBPathStorageRef.isSingleElement(self:)); RB_EXPORT -uint32_t RBPathStorageGetBezierOrder(RBPathStorageRef storage) RB_SWIFT_NAME(getter:RBPathStorageRef.bezierOrder(self:)); +size_t RBPathStorageGetBezierOrder(RBPathStorageRef storage) RB_SWIFT_NAME(getter:RBPathStorageRef.bezierOrder(self:)); RB_EXPORT CGRect RBPathStorageGetBoundingRect(RBPathStorageRef storage) RB_SWIFT_NAME(getter:RBPathStorageRef.boundingRect(self:)); diff --git a/RB/2024/Sources/Headers/RBPath.h b/RB/2024/Sources/Headers/RBPath.h index c2a3fd2..b53bf38 100644 --- a/RB/2024/Sources/Headers/RBPath.h +++ b/RB/2024/Sources/Headers/RBPath.h @@ -5,6 +5,7 @@ #pragma once #include +#include #include RB_ASSUME_NONNULL_BEGIN @@ -20,12 +21,31 @@ typedef RB_ENUM(int32_t, RBPathElement) { RBPathElementCloseSubpath = 4, RBPathElementRect = 5, RBPathElementRoundedRect = 6, + RBPathElementEllipse = 7, RBPathElementFixedRoundedRectCircular = 8, RBPathElementFixedRoundedRectContinuous = 9, + RBPathElementUnevenRoundedRectCircular = 10, + RBPathElementUnevenRoundedRectContinuous = 11, + RBPathElementRelativeArc = 12, + RBPathElementArc = 13, + RBPathElementArcCounterclockwise = 14, + RBPathElementArcTo = 15, + RBPathElementEnd = 16, + RBPathElementTransformed = 17, + RBPathElementTrimmed = 18, + RBPathElementStroked = 19, + RBPathElementBoolean = 20, + RBPathElementBooleanSeparator = 21, + RBPathElementDilateGlyph = 22, + RBPathElementOffset = 23, + RBPathElementClipStroke = 24, RBPathElementInvalid = 25, } RB_SWIFT_NAME(RBPath.Element); +RB_EXPORT +const uint8_t __RBPathElementArgumentCount[25]; + /// Defines the shape of a rounded rectangle's corners. typedef RB_ENUM(int32_t, RBPathRoundedCornerStyle) { /// Quarter-circle rounded rect corners. @@ -35,9 +55,21 @@ typedef RB_ENUM(int32_t, RBPathRoundedCornerStyle) { } RB_SWIFT_NAME(RBPath.RoundedCornerStyle); /// Callback type for path element enumeration -/// Returns true to stop enumeration, false to continue +/// Returns true to continue enumeration, false to stop typedef bool (*RBPathApplyCallback)(void * info, RBPathElement element, const CGFloat *points, const void * _Nullable userInfo); +/// Callback for mapped Core Graphics elements. Return false to stop callbacks. +typedef bool (*RBPathApplierCallback)(void *info, const CGPathElement *element); + +typedef RB_ENUM(int32_t, RBPathLineElement) { + RBPathLineElementMoveToPoint = 0, + RBPathLineElementAddLineToPoint = 1, + RBPathLineElementCloseSubpath = 2, +}; + +/// The point is unused for a close-subpath callback. +typedef bool (*RBPathLineApplyCallback)(void *info, RBPathLineElement element, const CGPoint *point); + typedef struct RBPathCallbacks RBPathCallbacks RB_SWIFT_NAME(RBPath.ApplyCallback); typedef struct RBPathStorage * RBPathStorageRef RB_SWIFT_STRUCT RB_SWIFT_NAME(RBPath.Storage); @@ -47,6 +79,93 @@ typedef struct RBPath { const RBPathCallbacks * callbacks; } RBPath; +/// A primitive shape recognized by ``RBPathApplyShape``. +typedef RB_ENUM(int32_t, RBPathShapeType) { + RBPathShapeTypeRect = 0, + RBPathShapeTypeEllipse = 1, + RBPathShapeTypeLine = 2, + RBPathShapeTypeFixedRoundedRect = 3, + RBPathShapeTypeUnevenRoundedRect = 4, + RBPathShapeTypeNested = 5, + RBPathShapeTypeStroked = 6, + RBPathShapeTypeTrimmed = 7, + RBPathShapeTypeOffset = 8, +}; + +typedef struct RBPathRectShape { + CGAffineTransform transform; + CGRect rect; +} RBPathRectShape; + +typedef struct RBPathFixedRoundedRectShape { + CGAffineTransform transform; + CGRect rect; + CGSize cornerSize; + RBPathRoundedCornerStyle style; +} RBPathFixedRoundedRectShape; + +typedef struct RBPathUnevenRoundedRectShape { + CGAffineTransform transform; + CGRect rect; + CGFloat topLeftRadius; + CGFloat topRightRadius; + CGFloat bottomRightRadius; + CGFloat bottomLeftRadius; + RBPathRoundedCornerStyle style; +} RBPathUnevenRoundedRectShape; + +typedef struct RBPathLineShape { + CGPoint start; + CGPoint end; +} RBPathLineShape; + +typedef struct RBPathStrokeStyle { + CGFloat lineWidth; + int32_t lineCap; + int32_t lineJoin; + CGFloat miterLimit; + CGFloat dashPhase; + uint64_t dashCount; + const CGFloat * _Nullable dash; +} RBPathStrokeStyle; + +typedef struct RBPathStrokedShape { + RBPath path; + RBPathStrokeStyle style; +} RBPathStrokedShape; + +typedef struct RBPathNestedShape { + RBPath path; + CGAffineTransform transform; +} RBPathNestedShape; + +typedef struct RBPathTrimmedShape { + RBPath path; + CGFloat from; + CGFloat to; +} RBPathTrimmedShape; + +typedef union RBPathShape { + RBPathRectShape rect; + RBPathRectShape ellipse; + RBPathLineShape line; + RBPathFixedRoundedRectShape fixedRoundedRect; + RBPathUnevenRoundedRectShape unevenRoundedRect; + RBPathStrokedShape stroked; + RBPathNestedShape nested; + RBPathTrimmedShape trimmed; +} RBPathShape; + +#if defined(__cplusplus) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) +static_assert(sizeof(RBPath) == 0x10); +static_assert(offsetof(RBPathUnevenRoundedRectShape, rect) == 0x30); +static_assert(offsetof(RBPathUnevenRoundedRectShape, topLeftRadius) == 0x50); +static_assert(offsetof(RBPathUnevenRoundedRectShape, style) == 0x70); +static_assert(sizeof(RBPathShape) == 0x78); +#endif + +typedef void (*RBPathApplyShapeCallback)(void * info, RBPathShapeType type, const RBPathShape *shape); + /// Global empty path (storage = null, callbacks = &RBPathEmptyCallbacks) RB_EXPORT const RBPath RBPathEmpty RB_SWIFT_NAME(RBPath.empty); @@ -56,7 +175,7 @@ RB_EXPORT const RBPath RBPathNull RB_SWIFT_NAME(RBPath.null); RB_EXPORT -void RBPathRetain(RBPath path) RB_SWIFT_NAME(RBPath.retain(self:)); +RBPath RBPathRetain(RBPath path) RB_SWIFT_NAME(RBPath.retain(self:)); RB_EXPORT void RBPathRelease(RBPath path) RB_SWIFT_NAME(RBPath.release(self:)); @@ -64,7 +183,7 @@ void RBPathRelease(RBPath path) RB_SWIFT_NAME(RBPath.release(self:)); // MARK: - Path Creation RB_EXPORT -RBPath RBPathMakeWithCGPath(CGPathRef cgPath) RB_SWIFT_NAME(RBPath.init(cgPath:)); +RBPath RBPathMakeWithCGPath(CGPathRef _Nullable cgPath) RB_SWIFT_NAME(RBPath.init(cgPath:)); RB_EXPORT RBPath RBPathMakeRect(CGRect rect, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.init(rect:transform:)); @@ -76,12 +195,19 @@ RB_EXPORT RBPath RBPathMakeRoundedRect(CGRect rect, CGFloat cornerWidth, CGFloat cornerHeight, RBPathRoundedCornerStyle style, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.init(roundedRect:cornerWidth:cornerHeight:style:transform:)); RB_EXPORT -RBPath RBPathMakeUnevenRoundedRect(CGRect rect, CGFloat topLeftRadius, CGFloat bottomLeftRadius, CGFloat bottomRightRadius, CGFloat topRightRadius, RBPathRoundedCornerStyle style, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.init(roundedRect:topLeftRadius:bottomLeftRadius:bottomRightRadius:topRightRadius:style:transform:)); +RBPath RBPathMakeUnevenRoundedRect(CGRect rect, CGFloat topLeftRadius, CGFloat topRightRadius, CGFloat bottomRightRadius, CGFloat bottomLeftRadius, RBPathRoundedCornerStyle style, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.init(roundedRect:topLeftRadius:topRightRadius:bottomRightRadius:bottomLeftRadius:style:transform:)); -// MARK: - Path Transformation +RB_EXPORT +RBPath RBPathCopyTransformedPath(RBPath path, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.copy(self:transform:)); + +RB_EXPORT +RBPath RBPathCopyStrokedPath(RBPath path, CGFloat lineWidth, int32_t lineCap, int32_t lineJoin, CGFloat miterLimit, CGFloat dashPhase, const CGFloat * _Nullable dash, size_t dashCount) RB_SWIFT_NAME(RBPath.stroked(self:lineWidth:lineCap:lineJoin:miterLimit:dashPhase:dash:dashCount:)); RB_EXPORT -RBPath RBPathCopyTransformedPath(RBPath path, const CGAffineTransform *transform) RB_SWIFT_NAME(RBPath.copy(self:transform:)); +RBPath RBPathCopyTrimmedPath(RBPath path, CGFloat from, CGFloat to) RB_SWIFT_NAME(RBPath.trimmed(self:from:to:)); + +// MARK: - Path Transformation + static RB_INLINE bool RBPathIsNull(RBPath path) RB_SWIFT_NAME(getter:RBPath.isNull(self:)) { return path.storage == RBPathNull.storage && path.callbacks == RBPathNull.callbacks; @@ -92,24 +218,60 @@ static RB_INLINE bool RBPathIsNull(RBPath path) RB_SWIFT_NAME(getter:RBPath.isNu RB_EXPORT bool RBPathIsEmpty(RBPath path) RB_SWIFT_NAME(getter:RBPath.isEmpty(self:)); +RB_EXPORT +bool RBPathIsSingleElement(RBPath path) RB_SWIFT_NAME(getter:RBPath.isSingleElement(self:)); + +RB_EXPORT +size_t RBPathGetBezierOrder(RBPath path) RB_SWIFT_NAME(getter:RBPath.bezierOrder(self:)); + RB_EXPORT bool RBPathApplyElements(RBPath path, void * info, _Nullable RBPathApplyCallback callback) RB_SWIFT_NAME(RBPath.apply(self:info:callback:)); +RB_EXPORT +bool RBPathApplyShape(RBPath path, bool allowLine, void * info, RBPathApplyShapeCallback callback) RB_SWIFT_NAME(RBPath.applyShape(self:allowLine:info:callback:)); + RB_EXPORT bool RBPathEqualToPath(RBPath lhs, RBPath rhs) RB_SWIFT_NAME(RBPath.isEqual(self:to:)); // MARK: - CGPath Interoperability +RB_EXPORT +bool RBPathApply(RBPath path, const CGAffineTransform * _Nullable transform, void *info, RBPathApplierCallback callback) RB_SWIFT_NAME(RBPath.applyCGPathElements(self:transform:info:callback:)); + +RB_EXPORT +bool RBPathApplyLines(RBPath path, double tolerance, void *info, RBPathLineApplyCallback callback) RB_SWIFT_NAME(RBPath.applyLines(self:tolerance:info:callback:)); + +RB_EXPORT +double RBPathGetLength(RBPath path, double tolerance, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.length(self:tolerance:transform:)); + +RB_EXPORT +bool RBPathCanInterpolate(RBPath path, RBPath other) RB_SWIFT_NAME(RBPath.canInterpolate(self:to:)); + +RB_EXPORT +RBPath RBPathCopyInterpolatedPath(RBPath path, RBPath other, float fraction) RB_SWIFT_NAME(RBPath.interpolated(self:to:fraction:)); + +RB_EXPORT +CFDataRef RBPathCopyData(RBPath path) RB_SWIFT_NAME(getter:RBPath.data(self:)); + +RB_EXPORT +RBPath RBPathMakeWithData(CFDataRef data) RB_SWIFT_NAME(RBPath.init(data:)); + +RB_EXPORT +CFStringRef RBPathCopyDebugDescription(RBPath path) RB_SWIFT_NAME(getter:RBPath.debugDescription(self:)); + RB_EXPORT CGPathRef RBPathCopyCGPath(RBPath path) RB_SWIFT_NAME(getter:RBPath.cgPath(self:)); +RB_EXPORT +CGRect RBPathGetBoundingRect(RBPath path) RB_SWIFT_NAME(getter:RBPath.boundingRect(self:)); + // MARK: - Point Containment RB_EXPORT bool RBPathContainsPoint(RBPath path, CGPoint point, bool eoFill) RB_SWIFT_NAME(RBPath.contains(self:point:eoFill:)); RB_EXPORT -bool RBPathContainsPoints(RBPath path, uint64_t count, const CGPoint *points, bool eoFill, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.containsPoints(self:count:points:eoFill:transform:)); +uint64_t RBPathContainsPoints(RBPath path, uint64_t count, const CGPoint *points, bool eoFill, const CGAffineTransform * _Nullable transform) RB_SWIFT_NAME(RBPath.containsPoints(self:count:points:eoFill:transform:)); RB_EXTERN_C_END diff --git a/RB/2024/Sources/Headers/RBPathCallbacks.h b/RB/2024/Sources/Headers/RBPathCallbacks.h index d94c07a..8456e28 100644 --- a/RB/2024/Sources/Headers/RBPathCallbacks.h +++ b/RB/2024/Sources/Headers/RBPathCallbacks.h @@ -33,10 +33,10 @@ typedef struct RB_SWIFT_NAME(RBPath.Callbacks) RBPathCallbacks { bool (* _Nullable isEqual)(const void *object, const void *otherObject); bool (* _Nullable isEmpty)(const void *object); bool (* _Nullable isSingleElement)(const void *object); - uint32_t (* _Nullable bezierOrder)(const void *object); + size_t (* _Nullable bezierOrder)(const void *object); CGRect (* _Nullable boundingRect)(const void *object); CGPathRef _Nullable (* _Nullable cgPath)(const void *object); - const struct RBPathCallbacks * _Nullable (* _Nullable next)(const void *object); + RBPath (* _Nullable next)(const void *object); } RBPathCallbacks; /// Extended callbacks structure with additional extended callbacks argument @@ -48,10 +48,10 @@ typedef struct RB_SWIFT_NAME(RBPath.CallbacksExtended) RBPathCallbacksExtended { bool (* _Nullable isEqual)(const void *object, const void *otherObject, const struct RBPathCallbacksExtended *extended); bool (* _Nullable isEmpty)(const void *object, const struct RBPathCallbacksExtended *extended); bool (* _Nullable isSingleElement)(const void *object, const struct RBPathCallbacksExtended *extended); - uint32_t (* _Nullable bezierOrder)(const void *object, const struct RBPathCallbacksExtended *extended); + size_t (* _Nullable bezierOrder)(const void *object, const struct RBPathCallbacksExtended *extended); CGRect (* _Nullable boundingRect)(const void *object, const struct RBPathCallbacksExtended *extended); CGPathRef _Nullable (* _Nullable cgPath)(const void *object, const struct RBPathCallbacksExtended *extended); - const struct RBPathCallbacksExtended * _Nullable (* _Nullable next)(const void *object, const struct RBPathCallbacksExtended *extended); + RBPath (* _Nullable next)(const void *object, const struct RBPathCallbacksExtended *extended); } RBPathCallbacksExtended; /// Global callbacks for CGPath-backed paths diff --git a/RB/2024/Sources/Headers/RBPathStorage.h b/RB/2024/Sources/Headers/RBPathStorage.h index 6d1ccea..01e793f 100644 --- a/RB/2024/Sources/Headers/RBPathStorage.h +++ b/RB/2024/Sources/Headers/RBPathStorage.h @@ -16,7 +16,7 @@ RB_ASSUME_NONNULL_BEGIN RB_EXTERN_C_BEGIN RB_EXPORT -void RBPathStorageInit(RBPathStorageRef dst, uint32_t capacity, RBPathStorageRef _Nullable source) RB_SWIFT_NAME(RBPathStorageRef.initialize(self:capacity:source:)); +void RBPathStorageInit(RBPathStorageRef dst, size_t capacity, RBPathStorageRef _Nullable source) RB_SWIFT_NAME(RBPathStorageRef.initialize(self:capacity:source:)); RB_EXPORT void RBPathStorageDestroy(RBPathStorageRef storage) RB_SWIFT_NAME(RBPathStorageRef.destroy(self:)); @@ -25,7 +25,7 @@ RB_EXPORT void RBPathStorageClear(RBPathStorageRef storage) RB_SWIFT_NAME(RBPathStorageRef.clear(self:)); RB_EXPORT -bool RBPathStorageAppendElement(RBPathStorageRef storage, RBPathElement element, CGFloat const * points, const void * _Nullable userInfo) RB_SWIFT_NAME(RBPathStorageRef.append(self:element:points:userInfo:)); +void RBPathStorageAppendElement(RBPathStorageRef storage, RBPathElement element, CGFloat const * points, const void * _Nullable userInfo) RB_SWIFT_NAME(RBPathStorageRef.append(self:element:points:userInfo:)); RB_EXPORT bool RBPathStorageAppendPath(RBPathStorageRef, RBPath) RB_SWIFT_NAME(RBPathStorageRef.append(self:path:)); @@ -43,7 +43,7 @@ RB_EXPORT bool RBPathStorageIsSingleElement(RBPathStorageRef storage) RB_SWIFT_NAME(getter:RBPathStorageRef.isSingleElement(self:)); RB_EXPORT -uint32_t RBPathStorageGetBezierOrder(RBPathStorageRef storage) RB_SWIFT_NAME(getter:RBPathStorageRef.bezierOrder(self:)); +size_t RBPathStorageGetBezierOrder(RBPathStorageRef storage) RB_SWIFT_NAME(getter:RBPathStorageRef.bezierOrder(self:)); RB_EXPORT CGRect RBPathStorageGetBoundingRect(RBPathStorageRef storage) RB_SWIFT_NAME(getter:RBPathStorageRef.boundingRect(self:)); diff --git a/RB/2024/tbds/ios-arm64-arm64e/RenderBox.tbd b/RB/2024/tbds/ios-arm64-arm64e/RenderBox.tbd index 2a4566a..03e6bd8 100644 --- a/RB/2024/tbds/ios-arm64-arm64e/RenderBox.tbd +++ b/RB/2024/tbds/ios-arm64-arm64e/RenderBox.tbd @@ -268,6 +268,7 @@ "_RBDrawingStateSetCTM", "_RBPathCopyInterpolatedPath", "_RBPathGetBoundingRect", + "_RBPathGetLength", "_RBDrawingStateClipLayer", "_RBDisplayListContentsXMLDictionary", "_RBColorMakeLinear", diff --git a/RB/2024/tbds/ios-arm64-x86_64-simulator/RenderBox.tbd b/RB/2024/tbds/ios-arm64-x86_64-simulator/RenderBox.tbd index 14b5c3f..edb776b 100644 --- a/RB/2024/tbds/ios-arm64-x86_64-simulator/RenderBox.tbd +++ b/RB/2024/tbds/ios-arm64-x86_64-simulator/RenderBox.tbd @@ -268,6 +268,7 @@ "_RBDrawingStateSetCTM", "_RBPathCopyInterpolatedPath", "_RBPathGetBoundingRect", + "_RBPathGetLength", "_RBDrawingStateClipLayer", "_RBDisplayListContentsXMLDictionary", "_RBColorMakeLinear", diff --git a/RB/2024/tbds/macos-arm64e-arm64-x86_64/RenderBox.tbd b/RB/2024/tbds/macos-arm64e-arm64-x86_64/RenderBox.tbd index 819f60d..c3c9f4a 100644 --- a/RB/2024/tbds/macos-arm64e-arm64-x86_64/RenderBox.tbd +++ b/RB/2024/tbds/macos-arm64e-arm64-x86_64/RenderBox.tbd @@ -231,6 +231,7 @@ "_RBDrawingStateSetCTM", "_RBPathCopyInterpolatedPath", "_RBPathGetBoundingRect", + "_RBPathGetLength", "_RBDrawingStateClipLayer", "_RBLayerCopyImageColorMode", "_RBDisplayListContentsXMLDictionary",