Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Sources/OpenSwiftUICore/View/Image/GraphicsImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

package import OpenCoreGraphicsShims
package import OpenRenderBoxShims
#if canImport(IOSurface)
package import IOSurface
#endif
#if canImport(CoreGraphics)
import CoreGraphics_Private
#endif
Expand All @@ -21,7 +24,11 @@ package import CoreUI
package struct GraphicsImage: Equatable, Sendable {
package enum Contents: Equatable, @unchecked Sendable {
case cgImage(CGImage)
#if canImport(IOSurface)
case ioSurface(IOSurface)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we need this?

#else
case ioSurface(IOSurfaceRef)
#endif
indirect case vectorGlyph(ResolvedVectorGlyph)
indirect case vectorLayer(VectorImageLayer)
indirect case color(Color.Resolved)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@
#if OPENSWIFTUI_TARGET_OS_OSX
id NSColorSpaceForCGColorSpace(CGColorSpaceRef cgColorSpace);
Class NSColorSpaceClass(void);

// This path can select UIColor dynamically on macOS. AppKit headers do not
// declare UIColor's initializer, so describe it without adding it to NSColor.
@protocol OpenSwiftUIUIKitRGBAColor
- (instancetype)initWithRed:(CGFloat)red green:(CGFloat)green
blue:(CGFloat)blue alpha:(CGFloat)alpha;
@end
#endif

BOOL OpenSwiftUICoreColorPlatformColorGetComponents(OpenSwiftUICoreSystem system, id color, CGFloat *red, CGFloat *green, CGFloat *blue, CGFloat *alpha) {
Expand Down Expand Up @@ -59,7 +66,8 @@ id OpenSwiftUICorePlatformColorForRGBA(OpenSwiftUICoreSystem system, CGFloat red
id colorSpace = NSColorSpaceForCGColorSpace(CGColorSpaceCreateWithName(kCGColorSpaceExtendedSRGB));
return [colorClass colorWithColorSpace:colorSpace components:(CGFloat[]){red, green, blue, alpha} count:4];
} else {
return [[colorClass alloc] initWithRed:red green:green blue:blue alpha:alpha];
return [(id<OpenSwiftUIUIKitRGBAColor>)[colorClass alloc]
initWithRed:red green:green blue:blue alpha:alpha];
}
#else
return [[colorClass alloc] initWithRed:red green:green blue:blue alpha:alpha];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#if OPENSWIFTUI_TARGET_OS_DARWIN

#import <CoreFoundation/CoreFoundation.h>
#import <CoreFoundation/CFStringTokenizer.h>
#import <os/lock.h>

@interface NSBundle (OpenSwiftUILocalizationPrivate)
Expand Down