diff --git a/Package.resolved b/Package.resolved index a784678..659e3fb 100644 --- a/Package.resolved +++ b/Package.resolved @@ -7,7 +7,7 @@ "location" : "https://github.com/OpenSwiftUIProject/DarwinPrivateFrameworks.git", "state" : { "branch" : "main", - "revision" : "ad86657d9bdd98f7c40c977b34ff0c3de3e2fcee" + "revision" : "8e4b56ac649f58b7d2555cc1f8418dde8c5bc8cd" } }, { diff --git a/Sources/OpenRenderBox/Render/ORBDisplayList.swift b/Sources/OpenRenderBox/Render/ORBDisplayList.swift index 2088a41..3057232 100644 --- a/Sources/OpenRenderBox/Render/ORBDisplayList.swift +++ b/Sources/OpenRenderBox/Render/ORBDisplayList.swift @@ -6,7 +6,306 @@ // #if !canImport(ObjectiveC) -public final class ORBDisplayList { +public import Foundation +public import OpenCoreGraphicsShims +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: ORBColor.ColorSpace = .default + + 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: ORBColor.ColorSpace, flags: UInt32) { + _openRenderBoxUnimplementedFailure() + } + + public func addColorMonochromeFilter(withAmount amount: Float, color: ORBColor, bias: Float) { + _openRenderBoxUnimplementedFailure() + } + + public func addColorMonochromeFilter(withAmount amount: Float, color: ORBColor, colorSpace space: ORBColor.ColorSpace, bias: Float, flags: UInt32) { + _openRenderBoxUnimplementedFailure() + } + + public func addAlphaMultiplyFilter(withColor color: ORBColor) { + _openRenderBoxUnimplementedFailure() + } + + public func addAlphaMultiplyFilter(withColor color: ORBColor, colorSpace space: ORBColor.ColorSpace, 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: ORBColor.ColorSpace, blendMode mode: Int32, flags: UInt32) { + _openRenderBoxUnimplementedFailure() + } + + public func addShadowStyle(withRadius radius: Double, midpoint: Float, offset: CGSize, color: ORBColor, colorSpace space: ORBColor.ColorSpace, 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..155caf5 --- /dev/null +++ b/Sources/OpenRenderBox/Render/ORBDisplayListContents.swift @@ -0,0 +1,17 @@ +// +// ORBDisplayListContents.swift +// OpenRenderBox +// + +#if !canImport(ObjectiveC) +public import Foundation +public import OpenCoreGraphicsShims + +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..537863c --- /dev/null +++ b/Sources/OpenRenderBox/Render/ORBDisplayListInterpolator.swift @@ -0,0 +1,57 @@ +// +// ORBDisplayListInterpolator.swift +// OpenRenderBox +// + +#if !canImport(ObjectiveC) +public import Foundation +public import OpenCoreGraphicsShims + +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/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/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/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/ORBDisplayList.h b/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/ORBDisplayList.h index a7f7c41..934db07 100644 --- a/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/ORBDisplayList.h +++ b/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/ORBDisplayList.h @@ -8,15 +8,110 @@ #if ORB_OBJC_FOUNDATION +#include +#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) ORBColorSpace 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 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; +- (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; +// 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 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..1cc6a6d --- /dev/null +++ b/Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/ORBDisplayListContents.h @@ -0,0 +1,41 @@ +// +// ORBDisplayListContents.h +// OpenRenderBox +// +// Audited for 6.5.4 +// Status: Complete + +#pragma once + +#include + +#if ORB_OBJC_FOUNDATION + +#include +#include +#include +#include + +ORB_ASSUME_NONNULL_BEGIN + +struct _ORBDrawingState; + +@protocol ORBDisplayListContents + +@required + +@property (readonly, nonatomic) BOOL empty; +@property (readonly, nonatomic) CGRect boundingRect; +@property (readonly, copy, nonatomic) NSString *xmlDescription; + +- (BOOL)isEmpty; +- (void)drawInState:(struct _ORBDrawingState *)state; +- (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..217f80f 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 +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..d2d15cf --- /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) + 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) + 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) + 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