File tree Expand file tree Collapse file tree 8 files changed +78
-2
lines changed
_Testing_CoreGraphics/Attachments Expand file tree Collapse file tree 8 files changed +78
-2
lines changed Original file line number Diff line number Diff line change @@ -90,6 +90,7 @@ let package = Package(
90
90
targets: [
91
91
" _Testing_AppKit " ,
92
92
" _Testing_CoreGraphics " ,
93
+ " _Testing_CoreImage " ,
93
94
]
94
95
)
95
96
]
@@ -137,6 +138,7 @@ let package = Package(
137
138
" Testing " ,
138
139
" _Testing_AppKit " ,
139
140
" _Testing_CoreGraphics " ,
141
+ " _Testing_CoreImage " ,
140
142
" _Testing_Foundation " ,
141
143
" MemorySafeTestingTests " ,
142
144
] ,
@@ -218,6 +220,15 @@ let package = Package(
218
220
path: " Sources/Overlays/_Testing_CoreGraphics " ,
219
221
swiftSettings: . packageSettings + . enableLibraryEvolution( )
220
222
) ,
223
+ . target(
224
+ name: " _Testing_CoreImage " ,
225
+ dependencies: [
226
+ " Testing " ,
227
+ " _Testing_CoreGraphics " ,
228
+ ] ,
229
+ path: " Sources/Overlays/_Testing_CoreImage " ,
230
+ swiftSettings: . packageSettings + . enableLibraryEvolution( )
231
+ ) ,
221
232
. target(
222
233
name: " _Testing_Foundation " ,
223
234
dependencies: [
Original file line number Diff line number Diff line change 8
8
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors
9
9
//
10
10
11
- @_exported public import Testing
12
- @_exported public import _Testing_CoreGraphics
11
+ @_exported @ _spi ( Experimental ) @ _spi ( ForToolsIntegrationOnly ) public import Testing
12
+ @_exported @ _spi ( Experimental ) @ _spi ( ForToolsIntegrationOnly ) public import _Testing_CoreGraphics
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ private import ImageIO
24
24
/// be attached to a test:
25
25
///
26
26
/// - [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage)
27
+ /// - [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage)
27
28
/// - [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage)
28
29
/// (macOS)
29
30
///
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ extension Attachment {
31
31
/// ``AttachableAsCGImage`` protocol and can be attached to a test:
32
32
///
33
33
/// - [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage)
34
+ /// - [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage)
34
35
/// - [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage)
35
36
/// (macOS)
36
37
///
@@ -68,6 +69,7 @@ extension Attachment {
68
69
/// ``AttachableAsCGImage`` protocol and can be attached to a test:
69
70
///
70
71
/// - [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage)
72
+ /// - [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage)
71
73
/// - [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage)
72
74
/// (macOS)
73
75
///
Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ import UniformTypeIdentifiers
47
47
/// to the ``AttachableAsCGImage`` protocol and can be attached to a test:
48
48
///
49
49
/// - [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage)
50
+ /// - [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage)
50
51
/// - [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage)
51
52
/// (macOS)
52
53
@_spi ( Experimental)
Original file line number Diff line number Diff line change
1
+ //
2
+ // This source file is part of the Swift.org open source project
3
+ //
4
+ // Copyright (c) 2024 Apple Inc. and the Swift project authors
5
+ // Licensed under Apache License v2.0 with Runtime Library Exception
6
+ //
7
+ // See https://swift.org/LICENSE.txt for license information
8
+ // See https://swift.org/CONTRIBUTORS.txt for Swift project authors
9
+ //
10
+
11
+ #if SWT_TARGET_OS_APPLE && canImport(CoreImage)
12
+ public import CoreImage
13
+ @_spi ( Experimental) public import _Testing_CoreGraphics
14
+
15
+ @_spi ( Experimental)
16
+ extension CIImage : AttachableAsCGImage {
17
+ public var attachableCGImage : CGImage {
18
+ get throws {
19
+ guard let result = CIContext ( ) . createCGImage ( self , from: extent) else {
20
+ throw ImageAttachmentError . couldNotCreateCGImage
21
+ }
22
+ return result
23
+ }
24
+ }
25
+
26
+ public func _makeCopyForAttachment( ) -> Self {
27
+ // CIImage is documented as thread-safe, but does not conform to Sendable.
28
+ // It conforms to NSCopying but does not actually copy itself, so there's no
29
+ // point in calling copy().
30
+ self
31
+ }
32
+ }
33
+ #endif
Original file line number Diff line number Diff line change
1
+ //
2
+ // This source file is part of the Swift.org open source project
3
+ //
4
+ // Copyright (c) 2024 Apple Inc. and the Swift project authors
5
+ // Licensed under Apache License v2.0 with Runtime Library Exception
6
+ //
7
+ // See https://swift.org/LICENSE.txt for license information
8
+ // See https://swift.org/CONTRIBUTORS.txt for Swift project authors
9
+ //
10
+
11
+ @_exported @_spi ( Experimental) @_spi ( ForToolsIntegrationOnly) public import Testing
12
+ @_exported @_spi ( Experimental) @_spi ( ForToolsIntegrationOnly) public import _Testing_CoreGraphics
Original file line number Diff line number Diff line change @@ -22,6 +22,10 @@ import _Testing_Foundation
22
22
import CoreGraphics
23
23
@_spi ( Experimental) import _Testing_CoreGraphics
24
24
#endif
25
+ #if canImport(CoreImage)
26
+ import CoreImage
27
+ @_spi ( Experimental) import _Testing_CoreImage
28
+ #endif
25
29
#if canImport(UniformTypeIdentifiers)
26
30
import UniformTypeIdentifiers
27
31
#endif
@@ -598,6 +602,18 @@ extension AttachmentTests {
598
602
}
599
603
#endif
600
604
605
+ #if canImport(CoreImage)
606
+ @available ( _uttypesAPI, * )
607
+ @Test func attachCIImage( ) throws {
608
+ let image = CIImage ( cgImage: try Self . cgImage. get ( ) )
609
+ let attachment = Attachment ( image, named: " diamond.jpg " )
610
+ #expect( attachment. attachableValue === image)
611
+ try attachment. attachableValue. withUnsafeBytes ( for: attachment) { buffer in
612
+ #expect( buffer. count > 32 )
613
+ }
614
+ }
615
+ #endif
616
+
601
617
#if canImport(AppKit)
602
618
static var nsImage : NSImage {
603
619
get throws {
You can’t perform that action at this time.
0 commit comments