From d79f45dd542ec88953c76dd5f99846c5eac427d0 Mon Sep 17 00:00:00 2001 From: Kyle Date: Wed, 11 Mar 2026 00:57:19 +0800 Subject: [PATCH 1/6] Update ORBDisplayList API --- .../OpenRenderBox/Render/ORBDisplayList.swift | 300 +++++++++++++++++- .../Render/ORBDisplayListContents.swift | 16 + .../Render/ORBDisplayListInterpolator.swift | 56 ++++ .../OpenRenderBoxCxx/Render/ORBDisplayList.m | 19 ++ .../Render/ORBDisplayListInterpolator.m | 15 + .../OpenRenderBoxObjC/Render/ORBDisplayList.h | 98 +++++- .../Render/ORBDisplayListContents.h | 33 ++ .../Render/ORBDisplayListInterpolator.h | 41 +++ .../OpenRenderBoxObjC/Render/ORBLayer.h | 7 +- .../Render/Private/_ORBDisplayListContents.h | 34 ++ .../{ => Private}/_ORBDrawableDelegate.h | 4 +- Sources/OpenRenderBoxShims/ORBShims.swift | 2 + 12 files changed, 615 insertions(+), 10 deletions(-) create mode 100644 Sources/OpenRenderBox/Render/ORBDisplayListContents.swift create mode 100644 Sources/OpenRenderBox/Render/ORBDisplayListInterpolator.swift create mode 100644 Sources/OpenRenderBoxCxx/Render/ORBDisplayList.m create mode 100644 Sources/OpenRenderBoxCxx/Render/ORBDisplayListInterpolator.m create mode 100644 Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/ORBDisplayListContents.h create mode 100644 Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/ORBDisplayListInterpolator.h create mode 100644 Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/Private/_ORBDisplayListContents.h rename Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/{ => Private}/_ORBDrawableDelegate.h (88%) diff --git a/Sources/OpenRenderBox/Render/ORBDisplayList.swift b/Sources/OpenRenderBox/Render/ORBDisplayList.swift index 2088a41..d115534 100644 --- a/Sources/OpenRenderBox/Render/ORBDisplayList.swift +++ b/Sources/OpenRenderBox/Render/ORBDisplayList.swift @@ -6,7 +6,305 @@ // #if !canImport(ObjectiveC) -public final class ORBDisplayList { +public import Foundation +public final class ORBDisplayList: NSObject, ORBDisplayListContents { + // MARK: - Properties + + public var linearColors: Bool = false + public var profile: UInt32 = 0 + public var contentRect: CGRect = .zero + public var deviceScale: Double = 0 + public var defaultColorSpace: Int32 = 0 + + public private(set) var clipBoundingBox: CGRect = .zero + + public var CTM: CGAffineTransform { + get { _openRenderBoxUnimplementedFailure() } + set { _openRenderBoxUnimplementedFailure() } + } + + public private(set) var identifier: UInt32 = 0 + public private(set) var identifierNamespace: UUID? + + public var empty: Bool { isEmpty() } + + public var boundingRect: CGRect { + _openRenderBoxUnimplementedFailure() + } + + public var xmlDescription: String { + _openRenderBoxUnimplementedFailure() + } + + // MARK: - Init + + public override init() { + super.init() + } + + // MARK: - ORBDisplayListContents + + public func isEmpty() -> Bool { + _openRenderBoxUnimplementedFailure() + } + + public func render(in context: CGContext, options: Any?) { + _openRenderBoxUnimplementedFailure() + } + + // MARK: - Cache & State + + public func clearCaches() { + _openRenderBoxUnimplementedFailure() + } + + public func clear() { + _openRenderBoxUnimplementedFailure() + } + + public func value(forAttribute attribute: UInt32) -> Any? { + _openRenderBoxUnimplementedFailure() + } + + public func save() { + _openRenderBoxUnimplementedFailure() + } + + public func restore() { + _openRenderBoxUnimplementedFailure() + } + + public func setValue(_ value: Any?, forAttribute attribute: UInt32) { + _openRenderBoxUnimplementedFailure() + } + + // MARK: - Transform + + public func concat(_ transform: CGAffineTransform) { + _openRenderBoxUnimplementedFailure() + } + + public func translateBy(x: Double, y: Double) { + _openRenderBoxUnimplementedFailure() + } + + public func scaleBy(x: Double, y: Double) { + _openRenderBoxUnimplementedFailure() + } + + public func rotate(by angle: Double) { + _openRenderBoxUnimplementedFailure() + } + + // MARK: - CG Context + + public func beginCGContext(withAlpha alpha: Float) -> CGContext { + _openRenderBoxUnimplementedFailure() + } + + public func beginCGContext(withAlpha alpha: Float, flags: UInt32) -> CGContext { + _openRenderBoxUnimplementedFailure() + } + + public func endCGContext() { + _openRenderBoxUnimplementedFailure() + } + + // MARK: - Layer + + public func beginLayer() { + _openRenderBoxUnimplementedFailure() + } + + public func beginLayer(withFlags flags: UInt32) { + _openRenderBoxUnimplementedFailure() + } + + public func drawLayer(withAlpha alpha: Float, blendMode mode: Int32) { + _openRenderBoxUnimplementedFailure() + } + + public func clipLayer(withAlpha alpha: Float, mode: Int32) { + _openRenderBoxUnimplementedFailure() + } + + // MARK: - Clip & Draw + + public func clipShape(_ shape: Any, mode: Int32) { + _openRenderBoxUnimplementedFailure() + } + + public func clipShape(_ shape: Any, alpha: Float, mode: Int32) { + _openRenderBoxUnimplementedFailure() + } + + public func drawShape(_ shape: Any, fill: Any, alpha: Float, blendMode mode: Int32) { + _openRenderBoxUnimplementedFailure() + } + + public func drawDisplayList(_ list: any ORBDisplayListContents) { + _openRenderBoxUnimplementedFailure() + } + + public func drawDisplayList(_ list: any ORBDisplayListContents, alpha: Float) { + _openRenderBoxUnimplementedFailure() + } + + // MARK: - Contents + + public func moveContents() -> (any ORBDisplayListContents)? { + _openRenderBoxUnimplementedFailure() + } + + public func setIdentifier(_ identifier: UInt32, namespace ns: UUID?) { + _openRenderBoxUnimplementedFailure() + } + + public func beginRecordingXML() { + _openRenderBoxUnimplementedFailure() + } + + // MARK: - Styles + + public func addAffineTransformStyle(_ style: CGAffineTransform) { + _openRenderBoxUnimplementedFailure() + } + + public func addTranslationStyle(withOffset offset: CGSize) { + _openRenderBoxUnimplementedFailure() + } + + public func addScaleStyle(withScale scale: CGSize, anchor: CGPoint) { + _openRenderBoxUnimplementedFailure() + } + + public func addRotationStyle(withAngle angle: Double, anchor: CGPoint) { + _openRenderBoxUnimplementedFailure() + } + + public func addTransformStyle(_ style: Any) { + _openRenderBoxUnimplementedFailure() + } + + public func addPredicateStyle(_ style: Any) { + _openRenderBoxUnimplementedFailure() + } + + // MARK: - Filters + + public func addBlurFilter(withRadius radius: Double) { + _openRenderBoxUnimplementedFailure() + } + + public func addBlurFilter(withRadius radius: Double, opaque: Bool) { + _openRenderBoxUnimplementedFailure() + } + + public func addBlurFilter(withRadius radius: Double, flags: UInt32) { + _openRenderBoxUnimplementedFailure() + } + + public func addBlurFilter(withRadius radius: Double, bounds: CGRect, flags: UInt32) { + _openRenderBoxUnimplementedFailure() + } + + public func addBrightnessFilter(withAmount amount: Float) { + _openRenderBoxUnimplementedFailure() + } + + public func addBrightnessFilter(withAmount amount: Float, flags: UInt32) { + _openRenderBoxUnimplementedFailure() + } + + public func addContrastFilter(withAmount amount: Float) { + _openRenderBoxUnimplementedFailure() + } + + public func addContrastFilter(withAmount amount: Float, flags: UInt32) { + _openRenderBoxUnimplementedFailure() + } + + public func addGrayscaleFilter(withAmount amount: Float) { + _openRenderBoxUnimplementedFailure() + } + + public func addGrayscaleFilter(withAmount amount: Float, flags: UInt32) { + _openRenderBoxUnimplementedFailure() + } + + public func addHueRotationFilter(withAngle angle: Double) { + _openRenderBoxUnimplementedFailure() + } + + public func addHueRotationFilter(withAngle angle: Double, flags: UInt32) { + _openRenderBoxUnimplementedFailure() + } + + public func addSaturationFilter(withAmount amount: Float) { + _openRenderBoxUnimplementedFailure() + } + + public func addSaturationFilter(withAmount amount: Float, flags: UInt32) { + _openRenderBoxUnimplementedFailure() + } + + public func addColorInvertFilter() { + _openRenderBoxUnimplementedFailure() + } + + public func addColorInvertFilter(withAmount amount: Float, flags: UInt32) { + _openRenderBoxUnimplementedFailure() + } + + public func addColorMultiplyFilter(withColor color: ORBColor) { + _openRenderBoxUnimplementedFailure() + } + + public func addColorMultiplyFilter(withColor color: ORBColor, colorSpace space: Int32, flags: UInt32) { + _openRenderBoxUnimplementedFailure() + } + + public func addColorMonochromeFilter(withAmount amount: Float, color: ORBColor, bias: Float) { + _openRenderBoxUnimplementedFailure() + } + + public func addColorMonochromeFilter(withAmount amount: Float, color: ORBColor, colorSpace space: Int32, bias: Float, flags: UInt32) { + _openRenderBoxUnimplementedFailure() + } + + public func addAlphaMultiplyFilter(withColor color: ORBColor) { + _openRenderBoxUnimplementedFailure() + } + + public func addAlphaMultiplyFilter(withColor color: ORBColor, colorSpace space: Int32, flags: UInt32) { + _openRenderBoxUnimplementedFailure() + } + + public func addLuminanceToAlphaFilter() { + _openRenderBoxUnimplementedFailure() + } + + public func addLuminanceToAlphaFilter(withFlags flags: UInt32) { + _openRenderBoxUnimplementedFailure() + } + + public func addDistanceFilter(withMaxDistance distance: Double, scale: Double, flags: UInt32) { + _openRenderBoxUnimplementedFailure() + } + + // MARK: - Shadow + + public func addShadowStyle(withRadius radius: Double, offset: CGSize, color: ORBColor, mode: UInt32) { + _openRenderBoxUnimplementedFailure() + } + + public func addShadowStyle(withRadius radius: Double, offset: CGSize, color: ORBColor, colorSpace space: Int32, blendMode mode: Int32, flags: UInt32) { + _openRenderBoxUnimplementedFailure() + } + + public func addShadowStyle(withRadius radius: Double, midpoint: Float, offset: CGSize, color: ORBColor, colorSpace space: Int32, blendMode mode: Int32, flags: UInt32) { + _openRenderBoxUnimplementedFailure() + } } #endif diff --git a/Sources/OpenRenderBox/Render/ORBDisplayListContents.swift b/Sources/OpenRenderBox/Render/ORBDisplayListContents.swift new file mode 100644 index 0000000..dcd4262 --- /dev/null +++ b/Sources/OpenRenderBox/Render/ORBDisplayListContents.swift @@ -0,0 +1,16 @@ +// +// ORBDisplayListContents.swift +// OpenRenderBox +// + +#if !canImport(ObjectiveC) +public import Foundation + +public protocol ORBDisplayListContents: AnyObject { + var empty: Bool { get } + var boundingRect: CGRect { get } + var xmlDescription: String { get } + func isEmpty() -> Bool + func render(in context: CGContext, options: Any?) +} +#endif diff --git a/Sources/OpenRenderBox/Render/ORBDisplayListInterpolator.swift b/Sources/OpenRenderBox/Render/ORBDisplayListInterpolator.swift new file mode 100644 index 0000000..a7298ce --- /dev/null +++ b/Sources/OpenRenderBox/Render/ORBDisplayListInterpolator.swift @@ -0,0 +1,56 @@ +// +// ORBDisplayListInterpolator.swift +// OpenRenderBox +// + +#if !canImport(ObjectiveC) +public import Foundation + +public class ORBDisplayListInterpolator: NSObject { + // MARK: - Properties + + public var from: any ORBDisplayListContents { + get { _openRenderBoxUnimplementedFailure() } + set { _openRenderBoxUnimplementedFailure() } + } + + public private(set) var to: any ORBDisplayListContents { + get { _openRenderBoxUnimplementedFailure() } + set { } + } + + public private(set) var options: [AnyHashable: Any]? = nil + public private(set) var isIdentity: Bool = false + public private(set) var onlyFades: Bool = false + public private(set) var activeDuration: Double = 0 + + // MARK: - Init + + public convenience init(from: any ORBDisplayListContents, to: any ORBDisplayListContents, options: [AnyHashable: Any]?) { + self.init() + _openRenderBoxUnimplementedFailure() + } + + public static func interpolator(withFrom from: any ORBDisplayListContents, to: any ORBDisplayListContents, options: [AnyHashable: Any]?) -> ORBDisplayListInterpolator { + _openRenderBoxUnimplementedFailure() + } + + // MARK: - Methods + + public func boundingRect(withProgress progress: Float) -> CGRect { + _openRenderBoxUnimplementedFailure() + } + + public func contents(withProgress progress: Float) -> (any ORBDisplayListContents)? { + _openRenderBoxUnimplementedFailure() + } + + public func copyContents(withProgress progress: Float) -> (any ORBDisplayListContents)? { + _openRenderBoxUnimplementedFailure() + } + + public func maxAbsoluteVelocity(withProgress progress: Float) -> Double { + _openRenderBoxUnimplementedFailure() + } +} +#endif diff --git a/Sources/OpenRenderBoxCxx/Render/ORBDisplayList.m b/Sources/OpenRenderBoxCxx/Render/ORBDisplayList.m new file mode 100644 index 0000000..ebc7f40 --- /dev/null +++ b/Sources/OpenRenderBoxCxx/Render/ORBDisplayList.m @@ -0,0 +1,19 @@ +// +// ORBDisplayList.m +// OpenRenderBox + +#include +#include + +#if ORB_OBJC_FOUNDATION + +@interface ORBDisplayList () <_ORBDisplayListContents> +@end + +@implementation ORBDisplayList + +// TODO + +@end + +#endif /* ORB_OBJC_FOUNDATION */ diff --git a/Sources/OpenRenderBoxCxx/Render/ORBDisplayListInterpolator.m b/Sources/OpenRenderBoxCxx/Render/ORBDisplayListInterpolator.m new file mode 100644 index 0000000..c3a2e31 --- /dev/null +++ b/Sources/OpenRenderBoxCxx/Render/ORBDisplayListInterpolator.m @@ -0,0 +1,15 @@ +// +// ORBDisplayListInterpolator.m +// OpenRenderBox + +#include + +#if ORB_OBJC_FOUNDATION + +@implementation ORBDisplayListInterpolator + +// TODO + +@end + +#endif /* ORB_OBJC_FOUNDATION */ diff --git a/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/ORBDisplayList.h b/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/ORBDisplayList.h index a7f7c41..9405f66 100644 --- a/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/ORBDisplayList.h +++ b/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/ORBDisplayList.h @@ -8,15 +8,109 @@ #if ORB_OBJC_FOUNDATION +#include +#include #include +#include ORB_ASSUME_NONNULL_BEGIN // TODO -@interface ORBDisplayList : NSObject +@interface ORBDisplayList : NSObject + +@property (nonatomic) BOOL linearColors; +@property (nonatomic) unsigned int profile; +@property (nonatomic) CGRect contentRect; +@property (nonatomic) double deviceScale; +@property (readonly, nonatomic) CGRect clipBoundingBox; +@property (nonatomic) CGAffineTransform CTM; +@property (nonatomic) int defaultColorSpace; +@property (readonly, nonatomic) unsigned int identifier; +@property (readonly, copy, nonatomic, nullable) NSUUID *identifierNamespace; +@property (readonly, nonatomic) BOOL empty; +@property (readonly, nonatomic) CGRect boundingRect; +@property (readonly, copy, nonatomic) NSString *xmlDescription; +- (BOOL)isEmpty; +- (void)clearCaches; +- (void)clear; +- (nullable id)valueForAttribute:(unsigned int)attribute; +- (void)save; +- (void)restore; +- (void)setValue:(nullable id)value forAttribute:(unsigned int)attribute; +- (void)concat:(CGAffineTransform)transform; +- (void)translateByX:(double)x Y:(double)y; +- (void)scaleByX:(double)x Y:(double)y; +- (void)rotateBy:(double)angle; +- (CGContextRef)beginCGContextWithAlpha:(float)alpha; +- (CGContextRef)beginCGContextWithAlpha:(float)alpha flags:(unsigned int)flags; +- (void)endCGContext; +- (void)beginLayer; +- (void)beginLayerWithFlags:(unsigned int)flags; +- (void)drawLayerWithAlpha:(float)alpha blendMode:(int)mode; +- (void)clipLayerWithAlpha:(float)alpha mode:(int)mode; +- (void)clipShape:(id)shape mode:(int)mode; +- (void)clipShape:(id)shape alpha:(float)alpha mode:(int)mode; +- (void)drawShape:(id)shape fill:(id)fill alpha:(float)alpha blendMode:(int)mode; +- (void)drawDisplayList:(id)list; +- (void)drawDisplayList:(id)list alpha:(float)alpha; +- (void)drawInRect:(CGRect)rect alpha:(float)alpha blendMode:(int)mode flags:(unsigned int)flags operation:(id /* block */)operation; +- (void)renderInContext:(CGContextRef)context options:(nullable id)options; +- (nullable id)moveContents; +- (void)setIdentifier:(unsigned int)identifier namespace:(nullable NSUUID *)ns; +- (void)beginRecordingXML; +- (void)addAffineTransformStyle:(CGAffineTransform)style; +- (void)addTranslationStyleWithOffset:(CGSize)offset; +- (void)addScaleStyleWithScale:(CGSize)scale anchor:(CGPoint)anchor; +- (void)addRotationStyleWithAngle:(double)angle anchor:(CGPoint)anchor; +- (void)addProjectionStyleWithArray:(float[_Nonnull 9])array; +- (void)addTransformStyle:(id)style; +- (void)addPredicateStyle:(id)style; +- (void)addAnimationStyle:(id)style id:(NSUUID *)styleID; +- (void)addAnimationStyle:(id)style id:(NSUUID *)styleID flags:(unsigned int)flags; +- (void)addBlurFilterWithRadius:(double)radius; +- (void)addBlurFilterWithRadius:(double)radius opaque:(BOOL)opaque; +- (void)addBlurFilterWithRadius:(double)radius flags:(unsigned int)flags; +- (void)addBlurFilterWithRadius:(double)radius bounds:(CGRect)bounds flags:(unsigned int)flags; +- (void)addVariableBlurFilterWithRadius:(double)radius mask:(id)mask bounds:(CGRect)bounds flags:(unsigned int)flags; +- (void)addVariableBlurLayerWithAlpha:(float)alpha scale:(double)scale radius:(double)radius bounds:(CGRect)bounds flags:(unsigned int)flags; +- (void)addBrightnessFilterWithAmount:(float)amount; +- (void)addBrightnessFilterWithAmount:(float)amount flags:(unsigned int)flags; +- (void)addContrastFilterWithAmount:(float)amount; +- (void)addContrastFilterWithAmount:(float)amount flags:(unsigned int)flags; +- (void)addGrayscaleFilterWithAmount:(float)amount; +- (void)addGrayscaleFilterWithAmount:(float)amount flags:(unsigned int)flags; +- (void)addHueRotationFilterWithAngle:(double)angle; +- (void)addHueRotationFilterWithAngle:(double)angle flags:(unsigned int)flags; +- (void)addSaturationFilterWithAmount:(float)amount; +- (void)addSaturationFilterWithAmount:(float)amount flags:(unsigned int)flags; +- (void)addColorInvertFilter; +- (void)addColorInvertFilterWithAmount:(float)amount flags:(unsigned int)flags; +- (void)addColorMatrixFilterWithArray:(float[_Nonnull 20])array; +- (void)addColorMatrixFilterWithArray:(float[_Nonnull 20])array flags:(unsigned int)flags; +- (void)addColorMultiplyFilterWithColor:(ORBColor)color; +- (void)addColorMultiplyFilterWithColor:(ORBColor)color colorSpace:(int)space flags:(unsigned int)flags; +- (void)addColorMonochromeFilterWithAmount:(float)amount color:(ORBColor)color bias:(float)bias; +- (void)addColorMonochromeFilterWithAmount:(float)amount color:(ORBColor)color colorSpace:(int)space bias:(float)bias flags:(unsigned int)flags; +- (void)addAlphaMultiplyFilterWithColor:(ORBColor)color; +- (void)addAlphaMultiplyFilterWithColor:(ORBColor)color colorSpace:(int)space flags:(unsigned int)flags; +- (void)addAlphaThresholdFilterWithAlpha:(float)alpha color:(ORBColor)color colorSpace:(int)space; +- (void)addAlphaThresholdFilterWithMinAlpha:(float)minAlpha maxAlpha:(float)maxAlpha color:(ORBColor)color colorSpace:(int)space; +- (void)addAlphaGradientFilterWithStopCount:(long long)count colors:(const ORBColor *)colors colorSpace:(int)space locations:(const double *)locations flags:(unsigned int)flags; +- (void)addLuminanceToAlphaFilter; +- (void)addLuminanceToAlphaFilterWithFlags:(unsigned int)flags; +- (void)addLuminanceCurveFilterWithCurve:(float[_Nonnull 4])curve color:(ORBColor)color colorSpace:(int)space flags:(unsigned int)flags; +- (void)addRGBACurvesFilterWithCurves:(float[_Nonnull 16])curves flags:(unsigned int)flags; +- (void)addDistanceFilterWithMaxDistance:(double)distance scale:(double)scale flags:(unsigned int)flags; +- (void)addFilterWithShader:(id)shader border:(CGSize)border bounds:(const CGRect *_Nullable)bounds flags:(unsigned int)flags; +- (void)addFilterLayerWithShader:(id)shader border:(CGSize)border layerBorder:(CGSize)layerBorder bounds:(const CGRect *_Nullable)bounds flags:(unsigned int)flags; +- (void)addShadowStyleWithRadius:(double)radius offset:(CGSize)offset color:(ORBColor)color mode:(unsigned int)mode; +- (void)addShadowStyleWithRadius:(double)radius offset:(CGSize)offset color:(ORBColor)color colorSpace:(int)space blendMode:(int)mode flags:(unsigned int)flags; +- (void)addShadowStyleWithRadius:(double)radius midpoint:(float)midpoint offset:(CGSize)offset color:(ORBColor)color colorSpace:(int)space blendMode:(int)mode flags:(unsigned int)flags; +- (void)addRotation3DStyleWithAngle:(double)angle axis:(struct { float x; float y; float z; })axis anchor:(struct { float x; float y; float z; })anchor perspective:(double)perspective flipWidth:(double)width; +- (void)addPathProjectionStyleWithStartPoint:(CGPoint)startPoint endPoint:(CGPoint)endPoint path:(id)path transform:(CGAffineTransform)transform flags:(unsigned int)flags; @end ORB_ASSUME_NONNULL_END -#endif +#endif /* ORB_OBJC_FOUNDATION */ diff --git a/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/ORBDisplayListContents.h b/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/ORBDisplayListContents.h new file mode 100644 index 0000000..05defc8 --- /dev/null +++ b/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/ORBDisplayListContents.h @@ -0,0 +1,33 @@ +// +// ORBDisplayListContents.h +// OpenRenderBox + +#pragma once + +#include + +#if ORB_OBJC_FOUNDATION + +#include +#include + +ORB_ASSUME_NONNULL_BEGIN + +@protocol ORBDisplayListContents + +@required + +@property (readonly, nonatomic) BOOL empty; +@property (readonly, nonatomic) CGRect boundingRect; +@property (readonly, copy, nonatomic) NSString *xmlDescription; + +- (BOOL)isEmpty; +- (void)renderInContext:(CGContextRef)context options:(nullable id)options; + +@optional + +@end + +ORB_ASSUME_NONNULL_END + +#endif /* ORB_OBJC_FOUNDATION */ diff --git a/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/ORBDisplayListInterpolator.h b/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/ORBDisplayListInterpolator.h new file mode 100644 index 0000000..47bf8c6 --- /dev/null +++ b/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/ORBDisplayListInterpolator.h @@ -0,0 +1,41 @@ +// +// ORBDisplayListInterpolator.h +// OpenRenderBox + +#pragma once + +#include + +#if ORB_OBJC_FOUNDATION + +#include +#include +#include + +ORB_ASSUME_NONNULL_BEGIN + +// TODO +@interface ORBDisplayListInterpolator : NSObject + +@property (retain, nonatomic) id from; +@property (readonly, nonatomic) id to; +@property (readonly, copy, nonatomic, nullable) NSDictionary *options; +@property (readonly, nonatomic, getter=isIdentity) BOOL identity; +@property (readonly, nonatomic) BOOL onlyFades; +@property (readonly, nonatomic) double activeDuration; + ++ (instancetype)interpolatorWithFrom:(id)from to:(id)to options:(nullable NSDictionary *)options; + +- (instancetype)initWithFrom:(id)from to:(id)to options:(nullable NSDictionary *)options; +- (id)copyWithZone:(nullable NSZone *)zone; +- (void)drawInState:(void *)state by:(float)by; +- (CGRect)boundingRectWithProgress:(float)progress; +- (nullable id)contentsWithProgress:(float)progress; +- (nullable id)copyContentsWithProgress:(float)progress; +- (double)maxAbsoluteVelocityWithProgress:(float)progress; + +@end + +ORB_ASSUME_NONNULL_END + +#endif /* ORB_OBJC_FOUNDATION */ diff --git a/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/ORBLayer.h b/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/ORBLayer.h index 3f3fca5..a33ba69 100644 --- a/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/ORBLayer.h +++ b/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/ORBLayer.h @@ -13,7 +13,6 @@ #include #include #include -#include #include //#include "RBImageQueueLayer.h" @@ -27,7 +26,7 @@ ORB_ASSUME_NONNULL_BEGIN -@interface ORBLayer: CALayer <_ORBDrawableDelegate, /*_RBSharedSurfaceOwner,*/ ORBDrawableStatistics> +@interface ORBLayer: CALayer @property (retain, nonatomic, nullable) ORBDevice *device; @property (nonatomic) BOOL rendersAsynchronously; @@ -41,10 +40,6 @@ ORB_ASSUME_NONNULL_BEGIN @property (nonatomic) BOOL allowsBottomLeftOrigin; @property (readonly, nonatomic, getter=isDrawableAvailable) BOOL drawableAvailable; @property (nonatomic) BOOL needsSynchronousUpdate; -@property (readonly) NSUInteger hash; -@property (readonly) Class superclass; -@property (readonly, copy) NSString *description; -@property (readonly, copy, nullable) NSString *debugDescription; @property (readonly, copy, nonatomic, nullable) NSDictionary *statistics; @property (copy, nonatomic, nullable) id /* block */ statisticsHandler; diff --git a/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/Private/_ORBDisplayListContents.h b/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/Private/_ORBDisplayListContents.h new file mode 100644 index 0000000..211afa7 --- /dev/null +++ b/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/Private/_ORBDisplayListContents.h @@ -0,0 +1,34 @@ +// +// _ORBDisplayListContents.h +// OpenRenderBox +// +// Audited for 6.5.4 +// Status: Complete + +#pragma once + +#include + +#if ORB_OBJC_FOUNDATION + +#include +#include + +ORB_ASSUME_NONNULL_BEGIN + +@protocol _ORBDisplayListContents + +@required + +@property (readonly, nonatomic) const void *_rb_contents; +@property (readonly, nonatomic) const void *_rb_xml_document; + +- (void)_drawInState:(void *)state alpha:(float)alpha; + +@optional + +@end + +ORB_ASSUME_NONNULL_END + +#endif /* ORB_OBJC_FOUNDATION */ diff --git a/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/_ORBDrawableDelegate.h b/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/Private/_ORBDrawableDelegate.h similarity index 88% rename from Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/_ORBDrawableDelegate.h rename to Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/Private/_ORBDrawableDelegate.h index ce2ff10..41d2b38 100644 --- a/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/_ORBDrawableDelegate.h +++ b/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/Private/_ORBDrawableDelegate.h @@ -1,6 +1,9 @@ // // _ORBDrawableDelegate.h // OpenRenderBox +// +// Audited for 6.5.4 +// Status: Complete #pragma once @@ -25,4 +28,3 @@ ORB_ASSUME_NONNULL_BEGIN ORB_ASSUME_NONNULL_END #endif /* ORB_OBJC_FOUNDATION */ - diff --git a/Sources/OpenRenderBoxShims/ORBShims.swift b/Sources/OpenRenderBoxShims/ORBShims.swift index e443ca8..92937a6 100644 --- a/Sources/OpenRenderBoxShims/ORBShims.swift +++ b/Sources/OpenRenderBoxShims/ORBShims.swift @@ -28,6 +28,8 @@ public typealias ORBAnimation = RBAnimation public typealias ORBColor = RBColor public typealias ORBDevice = RBDevice public typealias ORBDisplayList = RBDisplayList +// TODO: ORBDisplayListContents = RBDisplayListContents +// TODO: ORBDisplayListInterpolator = RBDisplayListInterpolator public typealias ORBLayer = RBLayer public typealias ORBLayerDelegate = RBLayerDelegate public typealias ORBPath = RBPath From 41601bc91b9546ef471d3781d4868e50cdb5e0d5 Mon Sep 17 00:00:00 2001 From: Kyle Date: Wed, 11 Mar 2026 01:00:32 +0800 Subject: [PATCH 2/6] Use ORBColorSpace for defaultColorSpace property --- Sources/OpenRenderBox/Render/ORBDisplayList.swift | 12 ++++++------ .../OpenRenderBoxObjC/Render/ORBDisplayList.h | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Sources/OpenRenderBox/Render/ORBDisplayList.swift b/Sources/OpenRenderBox/Render/ORBDisplayList.swift index d115534..0e28e19 100644 --- a/Sources/OpenRenderBox/Render/ORBDisplayList.swift +++ b/Sources/OpenRenderBox/Render/ORBDisplayList.swift @@ -15,7 +15,7 @@ public final class ORBDisplayList: NSObject, ORBDisplayListContents { public var profile: UInt32 = 0 public var contentRect: CGRect = .zero public var deviceScale: Double = 0 - public var defaultColorSpace: Int32 = 0 + public var defaultColorSpace: ORBColor.ColorSpace = .default public private(set) var clipBoundingBox: CGRect = .zero @@ -261,7 +261,7 @@ public final class ORBDisplayList: NSObject, ORBDisplayListContents { _openRenderBoxUnimplementedFailure() } - public func addColorMultiplyFilter(withColor color: ORBColor, colorSpace space: Int32, flags: UInt32) { + public func addColorMultiplyFilter(withColor color: ORBColor, colorSpace space: ORBColor.ColorSpace, flags: UInt32) { _openRenderBoxUnimplementedFailure() } @@ -269,7 +269,7 @@ public final class ORBDisplayList: NSObject, ORBDisplayListContents { _openRenderBoxUnimplementedFailure() } - public func addColorMonochromeFilter(withAmount amount: Float, color: ORBColor, colorSpace space: Int32, bias: Float, flags: UInt32) { + public func addColorMonochromeFilter(withAmount amount: Float, color: ORBColor, colorSpace space: ORBColor.ColorSpace, bias: Float, flags: UInt32) { _openRenderBoxUnimplementedFailure() } @@ -277,7 +277,7 @@ public final class ORBDisplayList: NSObject, ORBDisplayListContents { _openRenderBoxUnimplementedFailure() } - public func addAlphaMultiplyFilter(withColor color: ORBColor, colorSpace space: Int32, flags: UInt32) { + public func addAlphaMultiplyFilter(withColor color: ORBColor, colorSpace space: ORBColor.ColorSpace, flags: UInt32) { _openRenderBoxUnimplementedFailure() } @@ -299,11 +299,11 @@ public final class ORBDisplayList: NSObject, ORBDisplayListContents { _openRenderBoxUnimplementedFailure() } - public func addShadowStyle(withRadius radius: Double, offset: CGSize, color: ORBColor, colorSpace space: Int32, blendMode mode: Int32, flags: UInt32) { + public func addShadowStyle(withRadius radius: Double, offset: CGSize, color: ORBColor, colorSpace space: ORBColor.ColorSpace, blendMode mode: Int32, flags: UInt32) { _openRenderBoxUnimplementedFailure() } - public func addShadowStyle(withRadius radius: Double, midpoint: Float, offset: CGSize, color: ORBColor, colorSpace space: Int32, blendMode mode: Int32, flags: UInt32) { + public func addShadowStyle(withRadius radius: Double, midpoint: Float, offset: CGSize, color: ORBColor, colorSpace space: ORBColor.ColorSpace, blendMode mode: Int32, flags: UInt32) { _openRenderBoxUnimplementedFailure() } } diff --git a/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/ORBDisplayList.h b/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/ORBDisplayList.h index 9405f66..cb7238b 100644 --- a/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/ORBDisplayList.h +++ b/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/ORBDisplayList.h @@ -10,6 +10,7 @@ #include #include +#include #include #include @@ -24,7 +25,7 @@ ORB_ASSUME_NONNULL_BEGIN @property (nonatomic) double deviceScale; @property (readonly, nonatomic) CGRect clipBoundingBox; @property (nonatomic) CGAffineTransform CTM; -@property (nonatomic) int defaultColorSpace; +@property (nonatomic) ORBColorSpace defaultColorSpace; @property (readonly, nonatomic) unsigned int identifier; @property (readonly, copy, nonatomic, nullable) NSUUID *identifierNamespace; @property (readonly, nonatomic) BOOL empty; From 59fa55fd3aeff3e0331e0abf469f2af473dbb5df Mon Sep 17 00:00:00 2001 From: Kyle Date: Wed, 11 Mar 2026 01:15:00 +0800 Subject: [PATCH 3/6] Add ORBEncodable, ORBDecodable, ORBEncoderDelegate, ORBDecoderDelegate, and ORBEncoderSet --- .../OpenRenderBoxCxx/Encoding/ORBEncoderSet.m | 15 +++++++ .../OpenRenderBoxObjC/Encoding/ORBDecodable.h | 31 ++++++++++++++ .../Encoding/ORBDecoderDelegate.h | 35 ++++++++++++++++ .../OpenRenderBoxObjC/Encoding/ORBEncodable.h | 31 ++++++++++++++ .../Encoding/ORBEncoderDelegate.h | 41 +++++++++++++++++++ .../Encoding/ORBEncoderSet.h | 28 +++++++++++++ .../Render/ORBDisplayListContents.h | 10 ++++- 7 files changed, 190 insertions(+), 1 deletion(-) create mode 100644 Sources/OpenRenderBoxCxx/Encoding/ORBEncoderSet.m create mode 100644 Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Encoding/ORBDecodable.h create mode 100644 Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Encoding/ORBDecoderDelegate.h create mode 100644 Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Encoding/ORBEncodable.h create mode 100644 Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Encoding/ORBEncoderDelegate.h create mode 100644 Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Encoding/ORBEncoderSet.h diff --git a/Sources/OpenRenderBoxCxx/Encoding/ORBEncoderSet.m b/Sources/OpenRenderBoxCxx/Encoding/ORBEncoderSet.m new file mode 100644 index 0000000..43ab5bb --- /dev/null +++ b/Sources/OpenRenderBoxCxx/Encoding/ORBEncoderSet.m @@ -0,0 +1,15 @@ +// +// ORBEncoderSet.m +// OpenRenderBox + +#include + +#if ORB_OBJC_FOUNDATION + +@implementation ORBEncoderSet + +// TODO + +@end + +#endif /* ORB_OBJC_FOUNDATION */ diff --git a/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Encoding/ORBDecodable.h b/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Encoding/ORBDecodable.h new file mode 100644 index 0000000..2b7f76d --- /dev/null +++ b/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Encoding/ORBDecodable.h @@ -0,0 +1,31 @@ +// +// ORBDecodable.h +// OpenRenderBox +// +// Audited for 6.5.4 +// Status: Complete + +#pragma once + +#include + +#if ORB_OBJC_FOUNDATION + +#include +#include + +ORB_ASSUME_NONNULL_BEGIN + +@protocol ORBDecodable + +@required + ++ (nullable id)decodedObjectWithData:(NSData *)data delegate:(nullable id)delegate error:(NSError *_Nullable *_Nullable)error; + +@optional + +@end + +ORB_ASSUME_NONNULL_END + +#endif /* ORB_OBJC_FOUNDATION */ diff --git a/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Encoding/ORBDecoderDelegate.h b/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Encoding/ORBDecoderDelegate.h new file mode 100644 index 0000000..95ca87d --- /dev/null +++ b/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Encoding/ORBDecoderDelegate.h @@ -0,0 +1,35 @@ +// +// ORBDecoderDelegate.h +// OpenRenderBox +// +// Audited for 6.5.4 +// Status: Complete + +#pragma once + +#include + +#if ORB_OBJC_FOUNDATION + +#include +#include + +ORB_ASSUME_NONNULL_BEGIN + +@protocol ORBDecoderDelegate + +@required + +@optional + +// TODO: data type +- (CGFontRef)decodedCGFontWithData:(nullable NSData *)data error:(NSError *_Nullable *_Nullable)error; +- (nullable void *)decodedImageContentsWithData:(nullable NSData *)data type:(int *_Nullable)type error:(NSError *_Nullable *_Nullable)error; +- (void)decodedMetadata:(nullable NSData *)metadata; +- (nullable id)decodedShaderLibraryWithData:(nullable NSData *)data error:(NSError *_Nullable *_Nullable)error; + +@end + +ORB_ASSUME_NONNULL_END + +#endif /* ORB_OBJC_FOUNDATION */ diff --git a/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Encoding/ORBEncodable.h b/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Encoding/ORBEncodable.h new file mode 100644 index 0000000..11d837a --- /dev/null +++ b/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Encoding/ORBEncodable.h @@ -0,0 +1,31 @@ +// +// ORBEncodable.h +// OpenRenderBox +// +// Audited for 6.5.4 +// Status: Complete + +#pragma once + +#include + +#if ORB_OBJC_FOUNDATION + +#include +#include + +ORB_ASSUME_NONNULL_BEGIN + +@protocol ORBEncodable + +@required + +- (nullable NSData *)encodedDataForDelegate:(nullable id)delegate error:(NSError *_Nullable *_Nullable)error; + +@optional + +@end + +ORB_ASSUME_NONNULL_END + +#endif /* ORB_OBJC_FOUNDATION */ diff --git a/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Encoding/ORBEncoderDelegate.h b/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Encoding/ORBEncoderDelegate.h new file mode 100644 index 0000000..39eef2c --- /dev/null +++ b/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Encoding/ORBEncoderDelegate.h @@ -0,0 +1,41 @@ +// +// ORBEncoderDelegate.h +// OpenRenderBox +// +// Audited for 6.5.4 +// Status: Complete + +#pragma once + +#include + +#if ORB_OBJC_FOUNDATION + +#include +#include +#include + +ORB_ASSUME_NONNULL_BEGIN + +@protocol ORBEncoderDelegate + +@required + +@optional + +@property (readonly, nonatomic) ORBEncoderSet *encoderSet; + +// TODO: data type +- (nullable NSData *)encodedShaderLibraryData:(nullable NSData *)data error:(NSError *_Nullable *_Nullable)error; +- (nullable NSData *)encodedMetadata; +- (nullable NSData *)encodedCGFontData:(CGFontRef)data error:(NSError *_Nullable *_Nullable)error; +- (nullable NSData *)encodedFontData:(nullable NSData *)data cgFont:(CGFontRef)font error:(NSError *_Nullable *_Nullable)error; +- (nullable NSData *)encodedFontSubsetData:(nullable NSData *)data cgFont:(CGFontRef)font error:(NSError *_Nullable *_Nullable)error; +- (nullable NSData *)encodedImageData:(const void *)data error:(NSError *_Nullable *_Nullable)error; +- (BOOL)shouldEncodeFontSubset:(CGFontRef)subset; + +@end + +ORB_ASSUME_NONNULL_END + +#endif /* ORB_OBJC_FOUNDATION */ diff --git a/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Encoding/ORBEncoderSet.h b/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Encoding/ORBEncoderSet.h new file mode 100644 index 0000000..59fac2e --- /dev/null +++ b/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Encoding/ORBEncoderSet.h @@ -0,0 +1,28 @@ +// +// ORBEncoderSet.h +// OpenRenderBox +// +// Audited for 6.5.4 +// Status: Complete + +#pragma once + +#include + +#if ORB_OBJC_FOUNDATION + +#include + +ORB_ASSUME_NONNULL_BEGIN + +@interface ORBEncoderSet : NSObject + +-(instancetype)init; +- (void)commit; +- (void)addDisplayList:(id)list; + +@end + +ORB_ASSUME_NONNULL_END + +#endif /* ORB_OBJC_FOUNDATION */ diff --git a/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/ORBDisplayListContents.h b/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/ORBDisplayListContents.h index 05defc8..1cc6a6d 100644 --- a/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/ORBDisplayListContents.h +++ b/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/ORBDisplayListContents.h @@ -1,6 +1,9 @@ // // ORBDisplayListContents.h // OpenRenderBox +// +// Audited for 6.5.4 +// Status: Complete #pragma once @@ -8,12 +11,16 @@ #if ORB_OBJC_FOUNDATION +#include +#include #include #include ORB_ASSUME_NONNULL_BEGIN -@protocol ORBDisplayListContents +struct _ORBDrawingState; + +@protocol ORBDisplayListContents @required @@ -22,6 +29,7 @@ ORB_ASSUME_NONNULL_BEGIN @property (readonly, copy, nonatomic) NSString *xmlDescription; - (BOOL)isEmpty; +- (void)drawInState:(struct _ORBDrawingState *)state; - (void)renderInContext:(CGContextRef)context options:(nullable id)options; @optional From db579341d475c707e41db5b888a54e1f6127c98e Mon Sep 17 00:00:00 2001 From: Kyle Date: Wed, 11 Mar 2026 01:31:15 +0800 Subject: [PATCH 4/6] Update test case and dependency for ORBDisplayList --- Package.resolved | 2 +- .../OpenRenderBoxObjC/Render/ORBDisplayList.h | 2 +- Sources/OpenRenderBoxShims/ORBShims.swift | 4 +- .../DisplayListTests.swift | 103 ++++++++++++++++++ .../ORBShims.swift | 2 + 5 files changed, 109 insertions(+), 4 deletions(-) create mode 100644 Tests/OpenRenderBoxCompatibilityTests/DisplayListTests.swift diff --git a/Package.resolved b/Package.resolved index a784678..9bcafd6 100644 --- a/Package.resolved +++ b/Package.resolved @@ -7,7 +7,7 @@ "location" : "https://github.com/OpenSwiftUIProject/DarwinPrivateFrameworks.git", "state" : { "branch" : "main", - "revision" : "ad86657d9bdd98f7c40c977b34ff0c3de3e2fcee" + "revision" : "4e452649633fb1dad46da3a558730d72176edc4a" } }, { diff --git a/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/ORBDisplayList.h b/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/ORBDisplayList.h index cb7238b..4b0efa3 100644 --- a/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/ORBDisplayList.h +++ b/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/ORBDisplayList.h @@ -107,7 +107,7 @@ ORB_ASSUME_NONNULL_BEGIN - (void)addShadowStyleWithRadius:(double)radius offset:(CGSize)offset color:(ORBColor)color mode:(unsigned int)mode; - (void)addShadowStyleWithRadius:(double)radius offset:(CGSize)offset color:(ORBColor)color colorSpace:(int)space blendMode:(int)mode flags:(unsigned int)flags; - (void)addShadowStyleWithRadius:(double)radius midpoint:(float)midpoint offset:(CGSize)offset color:(ORBColor)color colorSpace:(int)space blendMode:(int)mode flags:(unsigned int)flags; -- (void)addRotation3DStyleWithAngle:(double)angle axis:(struct { float x; float y; float z; })axis anchor:(struct { float x; float y; float z; })anchor perspective:(double)perspective flipWidth:(double)width; +// TODO: addRotation3DStyleWithAngle - requires named struct for axis/anchor parameters - (void)addPathProjectionStyleWithStartPoint:(CGPoint)startPoint endPoint:(CGPoint)endPoint path:(id)path transform:(CGAffineTransform)transform flags:(unsigned int)flags; @end diff --git a/Sources/OpenRenderBoxShims/ORBShims.swift b/Sources/OpenRenderBoxShims/ORBShims.swift index 92937a6..217f80f 100644 --- a/Sources/OpenRenderBoxShims/ORBShims.swift +++ b/Sources/OpenRenderBoxShims/ORBShims.swift @@ -28,8 +28,8 @@ public typealias ORBAnimation = RBAnimation public typealias ORBColor = RBColor public typealias ORBDevice = RBDevice public typealias ORBDisplayList = RBDisplayList -// TODO: ORBDisplayListContents = RBDisplayListContents -// TODO: ORBDisplayListInterpolator = RBDisplayListInterpolator +public typealias ORBDisplayListContents = RBDisplayListContents +public typealias ORBDisplayListInterpolator = RBDisplayListInterpolator public typealias ORBLayer = RBLayer public typealias ORBLayerDelegate = RBLayerDelegate public typealias ORBPath = RBPath diff --git a/Tests/OpenRenderBoxCompatibilityTests/DisplayListTests.swift b/Tests/OpenRenderBoxCompatibilityTests/DisplayListTests.swift new file mode 100644 index 0000000..7944053 --- /dev/null +++ b/Tests/OpenRenderBoxCompatibilityTests/DisplayListTests.swift @@ -0,0 +1,103 @@ +// +// DisplayListTests.swift +// OpenRenderBoxCompatibilityTests + +import Testing + +#if canImport(Darwin) +import CoreGraphics +#if canImport(AppKit) +import AppKit +#endif + +@Suite(.enabled(if: compatibilityTestEnabled)) +struct DisplayListTests { + @Test + func testDisplayListInit() { + let displayList = ORBDisplayList() + #expect(displayList.isEmpty()) + } + + @Test + func testDisplayListProperties() { + let displayList = ORBDisplayList() + + // defaultColorSpace + displayList.defaultColorSpace = .SRGB + #expect(displayList.defaultColorSpace == .SRGB) + displayList.defaultColorSpace = .default + #expect(displayList.defaultColorSpace == .default) + + // linearColors + displayList.linearColors = true + #expect(displayList.linearColors == true) + displayList.linearColors = false + #expect(displayList.linearColors == false) + + // deviceScale + displayList.deviceScale = 2.0 + #expect(displayList.deviceScale == 2.0) + + // contentRect + let rect = CGRect(x: 0, y: 0, width: 100, height: 100) + displayList.contentRect = rect + #expect(displayList.contentRect == rect) + } + + @Test + func testBeginEndCGContext() { + let displayList = ORBDisplayList() + let context = displayList.beginCGContext(withAlpha: 1.0).takeUnretainedValue() + context.setFillColor(CGColor(red: 1, green: 0, blue: 0, alpha: 1)) + context.fill([CGRect(x: 0, y: 0, width: 10, height: 10)]) + displayList.endCGContext() + #expect(!displayList.isEmpty()) + } + + @Test + func testMoveContents() { + let displayList = ORBDisplayList() + displayList.defaultColorSpace = .SRGB + let context = displayList.beginCGContext(withAlpha: 1.0).takeUnretainedValue() + context.setFillColor(CGColor(red: 1, green: 0, blue: 0, alpha: 1)) + context.fill([CGRect(x: 0, y: 0, width: 10, height: 10)]) + displayList.endCGContext() + + let contents = displayList.moveContents() + #expect(contents != nil) + #expect(displayList.isEmpty()) + } + + #if canImport(AppKit) + @Test + func testNSImageDisplayList() throws { + let size = CGSize(width: 16, height: 16) + let image = NSImage(size: size, flipped: false) { rect in + NSColor.red.setFill() + rect.fill() + return true + } + + let displayList = ORBDisplayList() + displayList.defaultColorSpace = .SRGB + var rect = CGRect(origin: .zero, size: size) + let scale: CGFloat = 2.0 + let cgImage = try #require( + image.cgImage( + forProposedRect: &rect, + context: nil, + hints: [.ctm: AffineTransform(scaleByX: scale, byY: scale)] + ) + ) + let context = displayList.beginCGContext(withAlpha: 1.0).takeUnretainedValue() + context.draw(cgImage, in: CGRect(origin: .zero, size: size)) + displayList.endCGContext() + + let contents = displayList.moveContents() + #expect(contents != nil) + #expect(contents!.isEmpty() == false) + } + #endif +} + +#endif diff --git a/Tests/OpenRenderBoxCompatibilityTests/ORBShims.swift b/Tests/OpenRenderBoxCompatibilityTests/ORBShims.swift index 43847f8..fcb8026 100644 --- a/Tests/OpenRenderBoxCompatibilityTests/ORBShims.swift +++ b/Tests/OpenRenderBoxCompatibilityTests/ORBShims.swift @@ -9,6 +9,8 @@ public typealias ORBAnimation = RBAnimation public typealias ORBColor = RBColor public typealias ORBDevice = RBDevice public typealias ORBDisplayList = RBDisplayList +public typealias ORBDisplayListContents = RBDisplayListContents +public typealias ORBDisplayListInterpolator = RBDisplayListInterpolator public typealias ORBLayer = RBLayer public typealias ORBLayerDelegate = RBLayerDelegate public typealias ORBPath = RBPath From 11ee0d0a7971a51d11341ab9459a485be4b67bda Mon Sep 17 00:00:00 2001 From: Kyle Date: Wed, 11 Mar 2026 01:47:15 +0800 Subject: [PATCH 5/6] Fix CGContext API --- Package.resolved | 2 +- .../include/OpenRenderBoxObjC/Render/ORBDisplayList.h | 4 ++-- .../OpenRenderBoxCompatibilityTests/DisplayListTests.swift | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Package.resolved b/Package.resolved index 9bcafd6..659e3fb 100644 --- a/Package.resolved +++ b/Package.resolved @@ -7,7 +7,7 @@ "location" : "https://github.com/OpenSwiftUIProject/DarwinPrivateFrameworks.git", "state" : { "branch" : "main", - "revision" : "4e452649633fb1dad46da3a558730d72176edc4a" + "revision" : "8e4b56ac649f58b7d2555cc1f8418dde8c5bc8cd" } }, { diff --git a/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/ORBDisplayList.h b/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/ORBDisplayList.h index 4b0efa3..934db07 100644 --- a/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/ORBDisplayList.h +++ b/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/ORBDisplayList.h @@ -42,8 +42,8 @@ ORB_ASSUME_NONNULL_BEGIN - (void)translateByX:(double)x Y:(double)y; - (void)scaleByX:(double)x Y:(double)y; - (void)rotateBy:(double)angle; -- (CGContextRef)beginCGContextWithAlpha:(float)alpha; -- (CGContextRef)beginCGContextWithAlpha:(float)alpha flags:(unsigned int)flags; +- (CGContextRef)beginCGContextWithAlpha:(float)alpha CF_RETURNS_NOT_RETAINED; +- (CGContextRef)beginCGContextWithAlpha:(float)alpha flags:(unsigned int)flags CF_RETURNS_NOT_RETAINED; - (void)endCGContext; - (void)beginLayer; - (void)beginLayerWithFlags:(unsigned int)flags; diff --git a/Tests/OpenRenderBoxCompatibilityTests/DisplayListTests.swift b/Tests/OpenRenderBoxCompatibilityTests/DisplayListTests.swift index 7944053..d2d15cf 100644 --- a/Tests/OpenRenderBoxCompatibilityTests/DisplayListTests.swift +++ b/Tests/OpenRenderBoxCompatibilityTests/DisplayListTests.swift @@ -47,7 +47,7 @@ struct DisplayListTests { @Test func testBeginEndCGContext() { let displayList = ORBDisplayList() - let context = displayList.beginCGContext(withAlpha: 1.0).takeUnretainedValue() + let context = displayList.beginCGContext(withAlpha: 1.0) context.setFillColor(CGColor(red: 1, green: 0, blue: 0, alpha: 1)) context.fill([CGRect(x: 0, y: 0, width: 10, height: 10)]) displayList.endCGContext() @@ -58,7 +58,7 @@ struct DisplayListTests { func testMoveContents() { let displayList = ORBDisplayList() displayList.defaultColorSpace = .SRGB - let context = displayList.beginCGContext(withAlpha: 1.0).takeUnretainedValue() + let context = displayList.beginCGContext(withAlpha: 1.0) context.setFillColor(CGColor(red: 1, green: 0, blue: 0, alpha: 1)) context.fill([CGRect(x: 0, y: 0, width: 10, height: 10)]) displayList.endCGContext() @@ -89,7 +89,7 @@ struct DisplayListTests { hints: [.ctm: AffineTransform(scaleByX: scale, byY: scale)] ) ) - let context = displayList.beginCGContext(withAlpha: 1.0).takeUnretainedValue() + let context = displayList.beginCGContext(withAlpha: 1.0) context.draw(cgImage, in: CGRect(origin: .zero, size: size)) displayList.endCGContext() From dacf2da9c3fd69a4d88a4763da5d737f2f7fe33a Mon Sep 17 00:00:00 2001 From: Kyle Date: Wed, 11 Mar 2026 01:51:37 +0800 Subject: [PATCH 6/6] Fix Linux build by importing OpenCoreGraphicsShims for CG types --- Sources/OpenRenderBox/Render/ORBDisplayList.swift | 1 + Sources/OpenRenderBox/Render/ORBDisplayListContents.swift | 1 + Sources/OpenRenderBox/Render/ORBDisplayListInterpolator.swift | 1 + 3 files changed, 3 insertions(+) diff --git a/Sources/OpenRenderBox/Render/ORBDisplayList.swift b/Sources/OpenRenderBox/Render/ORBDisplayList.swift index 0e28e19..3057232 100644 --- a/Sources/OpenRenderBox/Render/ORBDisplayList.swift +++ b/Sources/OpenRenderBox/Render/ORBDisplayList.swift @@ -7,6 +7,7 @@ #if !canImport(ObjectiveC) public import Foundation +public import OpenCoreGraphicsShims public final class ORBDisplayList: NSObject, ORBDisplayListContents { // MARK: - Properties diff --git a/Sources/OpenRenderBox/Render/ORBDisplayListContents.swift b/Sources/OpenRenderBox/Render/ORBDisplayListContents.swift index dcd4262..155caf5 100644 --- a/Sources/OpenRenderBox/Render/ORBDisplayListContents.swift +++ b/Sources/OpenRenderBox/Render/ORBDisplayListContents.swift @@ -5,6 +5,7 @@ #if !canImport(ObjectiveC) public import Foundation +public import OpenCoreGraphicsShims public protocol ORBDisplayListContents: AnyObject { var empty: Bool { get } diff --git a/Sources/OpenRenderBox/Render/ORBDisplayListInterpolator.swift b/Sources/OpenRenderBox/Render/ORBDisplayListInterpolator.swift index a7298ce..537863c 100644 --- a/Sources/OpenRenderBox/Render/ORBDisplayListInterpolator.swift +++ b/Sources/OpenRenderBox/Render/ORBDisplayListInterpolator.swift @@ -5,6 +5,7 @@ #if !canImport(ObjectiveC) public import Foundation +public import OpenCoreGraphicsShims public class ORBDisplayListInterpolator: NSObject { // MARK: - Properties