@@ -26,32 +26,33 @@ public import WinSDK
2626///
2727/// - [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps)
2828/// - [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons)
29- /// - [`IWICBitmap`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmap)
29+ /// - [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource)
30+ /// (including its subclasses declared by Windows Imaging Component)
3031///
3132/// You do not generally need to add your own conformances to this protocol. If
3233/// you have an image in another format that needs to be attached to a test,
3334/// first convert it to an instance of one of the types above.
3435@_spi ( Experimental)
35- public protocol _AttachableByAddressAsIWICBitmap {
36- /// Create a WIC bitmap representing an instance of this type at the given
37- /// address.
36+ public protocol _AttachableByAddressAsIWICBitmapSource {
37+ /// Create a WIC bitmap source representing an instance of this type at the
38+ /// given address.
3839 ///
3940 /// - Parameters:
4041 /// - imageAddress: The address of the instance of this type.
4142 /// - factory: A WIC imaging factory that can be used to create additional
4243 /// WIC objects.
4344 ///
44- /// - Returns: A pointer to a new WIC bitmap representing this image. The
45- /// caller is responsible for releasing this image when done with it.
45+ /// - Returns: A pointer to a new WIC bitmap source representing this image.
46+ /// The caller is responsible for releasing this image when done with it.
4647 ///
4748 /// - Throws: Any error that prevented the creation of the WIC bitmap.
4849 ///
4950 /// This function is not part of the public interface of the testing library.
5051 /// It may be removed in a future update.
51- static func _copyAttachableIWICBitmap (
52+ static func _copyAttachableIWICBitmapSource (
5253 from imageAddress: UnsafeMutablePointer < Self > ,
5354 using factory: UnsafeMutablePointer < IWICImagingFactory >
54- ) throws -> UnsafeMutablePointer < IWICBitmap >
55+ ) throws -> UnsafeMutablePointer < IWICBitmapSource >
5556
5657 /// Make a copy of the instance of this type at the given address.
5758 ///
@@ -84,7 +85,7 @@ public protocol _AttachableByAddressAsIWICBitmap {
8485 /// does not call this function.
8586 ///
8687 /// This function is not responsible for releasing the image returned from
87- /// `_copyAttachableIWICBitmap (from:using:)`.
88+ /// `_copyAttachableIWICBitmapSource (from:using:)`.
8889 ///
8990 /// This function is not part of the public interface of the testing library.
9091 /// It may be removed in a future update.
@@ -104,13 +105,14 @@ public protocol _AttachableByAddressAsIWICBitmap {
104105///
105106/// - [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps)
106107/// - [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons)
107- /// - [`IWICBitmap`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmap)
108+ /// - [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource)
109+ /// (including its subclasses declared by Windows Imaging Component)
108110///
109111/// You do not generally need to add your own conformances to this protocol. If
110112/// you have an image in another format that needs to be attached to a test,
111113/// first convert it to an instance of one of the types above.
112114@_spi ( Experimental)
113- public protocol AttachableAsIWICBitmap {
115+ public protocol AttachableAsIWICBitmapSource {
114116 /// Create a WIC bitmap representing an instance of this type.
115117 ///
116118 /// - Parameters:
@@ -124,9 +126,9 @@ public protocol AttachableAsIWICBitmap {
124126 ///
125127 /// This function is not part of the public interface of the testing library.
126128 /// It may be removed in a future update.
127- borrowing func _copyAttachableIWICBitmap (
129+ borrowing func _copyAttachableIWICBitmapSource (
128130 using factory: UnsafeMutablePointer < IWICImagingFactory >
129- ) throws -> UnsafeMutablePointer < IWICBitmap >
131+ ) throws -> UnsafeMutablePointer < IWICBitmapSource >
130132
131133 /// Make a copy of this instance.
132134 ///
@@ -152,7 +154,7 @@ public protocol AttachableAsIWICBitmap {
152154 /// automatically invokes this function as needed.
153155 ///
154156 /// This function is not responsible for releasing the image returned from
155- /// `_copyAttachableIWICBitmap (using:)`.
157+ /// `_copyAttachableIWICBitmapSource (using:)`.
156158 ///
157159 /// The default implementation of this function when `Self` conforms to
158160 /// `Sendable` does nothing.
@@ -162,42 +164,7 @@ public protocol AttachableAsIWICBitmap {
162164 func _deinitializeAttachableValue( )
163165}
164166
165- extension AttachableAsIWICBitmap {
166- /// Create a WIC bitmap representing an instance of this type and return it as
167- /// an instance of `IWICBitmapSource`.
168- ///
169- /// - Parameters:
170- /// - factory: A WIC imaging factory that can be used to create additional
171- /// WIC objects.
172- ///
173- /// - Returns: A pointer to a new WIC bitmap representing this image. The
174- /// caller is responsible for releasing this image when done with it.
175- ///
176- /// - Throws: Any error that prevented the creation of the WIC bitmap.
177- ///
178- /// This function is a convenience over `_copyAttachableIWICBitmap(using:)`
179- /// that casts the result of that function to `IWICBitmapSource` (as needed
180- /// by WIC when it encodes the image.)
181- borrowing func copyAttachableIWICBitmapSource(
182- using factory: UnsafeMutablePointer < IWICImagingFactory >
183- ) throws -> UnsafeMutablePointer < IWICBitmapSource > {
184- let bitmap = try _copyAttachableIWICBitmap ( using: factory)
185- defer {
186- _ = bitmap. pointee. lpVtbl. pointee. Release ( bitmap)
187- }
188-
189- return try withUnsafePointer ( to: IID_IWICBitmapSource) { IID_IWICBitmapSource in
190- var bitmapSource : UnsafeMutableRawPointer ?
191- let rQuery = bitmap. pointee. lpVtbl. pointee. QueryInterface ( bitmap, IID_IWICBitmapSource, & bitmapSource)
192- guard rQuery == S_OK, let bitmapSource else {
193- throw ImageAttachmentError . queryInterfaceFailed ( IWICBitmapSource . self, rQuery)
194- }
195- return bitmapSource. assumingMemoryBound ( to: IWICBitmapSource . self)
196- }
197- }
198- }
199-
200- extension AttachableAsIWICBitmap where Self: Sendable {
167+ extension AttachableAsIWICBitmapSource where Self: Sendable {
201168 public func _copyAttachableValue( ) -> Self {
202169 self
203170 }
0 commit comments