Skip to content

Commit 0c5e481

Browse files
committed
Promote Windows image attachments to API.
Remove `@_spi` and adjust documentation as needed. Pending approval of [ST-0015](https://forums.swift.org/t/st-0015-image-attachments-in-swift-testing-windows/82241).
1 parent 894fc62 commit 0c5e481

13 files changed

+28
-41
lines changed

Sources/Overlays/_Testing_CoreGraphics/Attachments/AttachableAsCGImage.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ private import ImageIO
2727
/// |-|-|
2828
/// | macOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) |
2929
/// | iOS, watchOS, tvOS, and visionOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) |
30-
/// @Comment {
3130
/// | Windows | [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps), [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons), [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) (including its subclasses declared by Windows Imaging Component) |
32-
/// }
3331
///
3432
/// You do not generally need to add your own conformances to this protocol. If
3533
/// you have an image in another format that needs to be attached to a test,

Sources/Overlays/_Testing_WinSDK/Attachments/AttachableAsIWICBitmapSource.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ public import WinSDK
3232
/// You do not generally need to add your own conformances to this protocol. If
3333
/// you have an image in another format that needs to be attached to a test,
3434
/// first convert it to an instance of one of the types above.
35-
@_spi(Experimental)
3635
public protocol _AttachableByAddressAsIWICBitmapSource {
3736
/// Create a WIC bitmap source representing an instance of this type at the
3837
/// given address.
@@ -112,14 +111,21 @@ public protocol _AttachableByAddressAsIWICBitmapSource {
112111
/// You do not generally need to add your own conformances to this protocol. If
113112
/// you have an image in another format that needs to be attached to a test,
114113
/// first convert it to an instance of one of the types above.
115-
@_spi(Experimental)
114+
///
115+
/// @Metadata {
116+
/// @Available(Swift, introduced: 6.3)
117+
/// }
116118
public protocol AttachableAsIWICBitmapSource: _AttachableAsImage, SendableMetatype {
117119
/// Create a WIC bitmap source representing an instance of this type.
118120
///
119121
/// - Returns: A pointer to a new WIC bitmap source representing this image.
120122
/// The caller is responsible for releasing this image when done with it.
121123
///
122124
/// - Throws: Any error that prevented the creation of the WIC bitmap source.
125+
///
126+
/// @Metadata {
127+
/// @Available(Swift, introduced: 6.3)
128+
/// }
123129
func copyAttachableIWICBitmapSource() throws -> UnsafeMutablePointer<IWICBitmapSource>
124130

125131
/// Create a WIC bitmap representing an instance of this type.

Sources/Overlays/_Testing_WinSDK/Attachments/AttachableImageFormat+CLSID.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99
//
1010

1111
#if os(Windows)
12-
@_spi(Experimental) public import Testing
12+
public import Testing
1313
public import WinSDK
1414

15-
@_spi(Experimental)
1615
extension AttachableImageFormat {
1716
private static let _encoderPathExtensionsByCLSID = Result<[UInt128: [String]], any Error> {
1817
var result = [UInt128: [String]]()
@@ -235,6 +234,10 @@ extension AttachableImageFormat {
235234
///
236235
/// For example, if this image format equals ``png``, the value of this
237236
/// property equals [`CLSID_WICPngEncoder`](https://learn.microsoft.com/en-us/windows/win32/wic/-wic-guids-clsids#wic-guids-and-clsids).
237+
///
238+
/// @Metadata {
239+
/// @Available(Swift, introduced: 6.3)
240+
/// }
238241
public var encoderCLSID: CLSID {
239242
switch kind {
240243
case .png:
@@ -263,6 +266,10 @@ extension AttachableImageFormat {
263266
/// result is undefined. For a list of image encoder classes supported by WIC,
264267
/// see the documentation for the [`IWICBitmapEncoder`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapencoder)
265268
/// class.
269+
///
270+
/// @Metadata {
271+
/// @Available(Swift, introduced: 6.3)
272+
/// }
266273
public init(encoderCLSID: CLSID, encodingQuality: Float = 1.0) {
267274
if encoderCLSID == CLSID_WICPngEncoder {
268275
self = .png

Sources/Overlays/_Testing_WinSDK/Attachments/HBITMAP+AttachableAsIWICBitmapSource.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
private import Testing
1313
public import WinSDK
1414

15-
@_spi(Experimental)
1615
extension HBITMAP__: _AttachableByAddressAsIWICBitmapSource {
1716
public static func _copyAttachableIWICBitmapSource(
1817
from imageAddress: UnsafeMutablePointer<Self>,

Sources/Overlays/_Testing_WinSDK/Attachments/HICON+AttachableAsIWICBitmapSource.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
private import Testing
1313
public import WinSDK
1414

15-
@_spi(Experimental)
1615
extension HICON__: _AttachableByAddressAsIWICBitmapSource {
1716
public static func _copyAttachableIWICBitmapSource(
1817
from imageAddress: UnsafeMutablePointer<Self>,

Sources/Overlays/_Testing_WinSDK/Attachments/IWICBitmapSource+AttachableAsIWICBitmapSource.swift

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,31 +34,14 @@ public import WinSDK
3434
/// allows us to reuse code across all subclasses of `IWICBitmapSource`.
3535
protocol IWICBitmapSourceProtocol: _AttachableByAddressAsIWICBitmapSource {}
3636

37-
@_spi(Experimental)
3837
extension IWICBitmapSource: _AttachableByAddressAsIWICBitmapSource, IWICBitmapSourceProtocol {}
39-
40-
@_spi(Experimental)
4138
extension IWICBitmap: _AttachableByAddressAsIWICBitmapSource, IWICBitmapSourceProtocol {}
42-
43-
@_spi(Experimental)
4439
extension IWICBitmapClipper: _AttachableByAddressAsIWICBitmapSource, IWICBitmapSourceProtocol {}
45-
46-
@_spi(Experimental)
4740
extension IWICBitmapFlipRotator: _AttachableByAddressAsIWICBitmapSource, IWICBitmapSourceProtocol {}
48-
49-
@_spi(Experimental)
5041
extension IWICBitmapFrameDecode: _AttachableByAddressAsIWICBitmapSource, IWICBitmapSourceProtocol {}
51-
52-
@_spi(Experimental)
5342
extension IWICBitmapScaler: _AttachableByAddressAsIWICBitmapSource, IWICBitmapSourceProtocol {}
54-
55-
@_spi(Experimental)
5643
extension IWICColorTransform: _AttachableByAddressAsIWICBitmapSource, IWICBitmapSourceProtocol {}
57-
58-
@_spi(Experimental)
5944
extension IWICFormatConverter: _AttachableByAddressAsIWICBitmapSource, IWICBitmapSourceProtocol {}
60-
61-
@_spi(Experimental)
6245
extension IWICPlanarFormatConverter: _AttachableByAddressAsIWICBitmapSource, IWICBitmapSourceProtocol {}
6346

6447
// MARK: - Upcasting conveniences
@@ -96,7 +79,6 @@ extension UnsafeMutablePointer where Pointee: IWICBitmapSourceProtocol {
9679

9780
// MARK: - _AttachableByAddressAsIWICBitmapSource implementation
9881

99-
@_spi(Experimental)
10082
extension IWICBitmapSourceProtocol {
10183
public static func _copyAttachableIWICBitmapSource(
10284
from imageAddress: UnsafeMutablePointer<Self>,
@@ -120,7 +102,6 @@ extension IWICBitmapSourceProtocol {
120102
}
121103

122104
extension IWICBitmapSource {
123-
@_spi(Experimental)
124105
public static func _copyAttachableIWICBitmapSource(
125106
from imageAddress: UnsafeMutablePointer<Self>,
126107
using factory: UnsafeMutablePointer<IWICImagingFactory>

Sources/Overlays/_Testing_WinSDK/Attachments/UnsafeMutablePointer+AttachableAsIWICBitmapSource.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,13 @@
1212
private import Testing
1313
public import WinSDK
1414

15-
@_spi(Experimental)
15+
/// @Metadata {
16+
/// @Available(Swift, introduced: 6.3)
17+
/// }
1618
extension UnsafeMutablePointer: _AttachableAsImage, AttachableAsIWICBitmapSource where Pointee: _AttachableByAddressAsIWICBitmapSource {
19+
/// @Metadata {
20+
/// @Available(Swift, introduced: 6.3)
21+
/// }
1722
public func copyAttachableIWICBitmapSource() throws -> UnsafeMutablePointer<IWICBitmapSource> {
1823
let factory = try IWICImagingFactory.create()
1924
defer {

Sources/Overlays/_Testing_WinSDK/Attachments/_AttachableImageWrapper+AttachableWrapper.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99
//
1010

1111
#if os(Windows)
12-
@_spi(Experimental) public import Testing
12+
public import Testing
1313
private import WinSDK
1414

15-
@_spi(Experimental)
1615
extension _AttachableImageWrapper: Attachable, AttachableWrapper where Image: AttachableAsIWICBitmapSource {
1716
public func withUnsafeBytes<R>(for attachment: borrowing Attachment<_AttachableImageWrapper>, _ body: (UnsafeRawBufferPointer) throws -> R) throws -> R {
1817
// Create an in-memory stream to write the image data to. Note that Windows

Sources/Overlays/_Testing_WinSDK/ReexportTesting.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors
99
//
1010

11-
@_exported @_spi(Experimental) @_spi(ForToolsIntegrationOnly) public import Testing
11+
@_exported public import Testing

Sources/Testing/Attachments/Images/AttachableImageFormat.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@
2323
/// - On Apple platforms, you can use [`CGImageDestinationCopyTypeIdentifiers()`](https://developer.apple.com/documentation/imageio/cgimagedestinationcopytypeidentifiers())
2424
/// from the [Image I/O framework](https://developer.apple.com/documentation/imageio)
2525
/// to determine which formats are supported.
26-
/// @Comment {
2726
/// - On Windows, you can use [`IWICImagingFactory.CreateComponentEnumerator()`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createcomponentenumerator)
2827
/// to enumerate the available image encoders.
29-
/// }
3028
///
3129
/// @Metadata {
3230
/// @Available(Swift, introduced: 6.3)

0 commit comments

Comments
 (0)