@@ -26,32 +26,33 @@ public import WinSDK
26
26
///
27
27
/// - [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps)
28
28
/// - [`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)
30
31
///
31
32
/// You do not generally need to add your own conformances to this protocol. If
32
33
/// you have an image in another format that needs to be attached to a test,
33
34
/// first convert it to an instance of one of the types above.
34
35
@_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.
38
39
///
39
40
/// - Parameters:
40
41
/// - imageAddress: The address of the instance of this type.
41
42
/// - factory: A WIC imaging factory that can be used to create additional
42
43
/// WIC objects.
43
44
///
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.
46
47
///
47
48
/// - Throws: Any error that prevented the creation of the WIC bitmap.
48
49
///
49
50
/// This function is not part of the public interface of the testing library.
50
51
/// It may be removed in a future update.
51
- static func _copyAttachableIWICBitmap (
52
+ static func _copyAttachableIWICBitmapSource (
52
53
from imageAddress: UnsafeMutablePointer < Self > ,
53
54
using factory: UnsafeMutablePointer < IWICImagingFactory >
54
- ) throws -> UnsafeMutablePointer < IWICBitmap >
55
+ ) throws -> UnsafeMutablePointer < IWICBitmapSource >
55
56
56
57
/// Make a copy of the instance of this type at the given address.
57
58
///
@@ -84,7 +85,7 @@ public protocol _AttachableByAddressAsIWICBitmap {
84
85
/// does not call this function.
85
86
///
86
87
/// This function is not responsible for releasing the image returned from
87
- /// `_copyAttachableIWICBitmap (from:using:)`.
88
+ /// `_copyAttachableIWICBitmapSource (from:using:)`.
88
89
///
89
90
/// This function is not part of the public interface of the testing library.
90
91
/// It may be removed in a future update.
@@ -104,13 +105,14 @@ public protocol _AttachableByAddressAsIWICBitmap {
104
105
///
105
106
/// - [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps)
106
107
/// - [`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)
108
110
///
109
111
/// You do not generally need to add your own conformances to this protocol. If
110
112
/// you have an image in another format that needs to be attached to a test,
111
113
/// first convert it to an instance of one of the types above.
112
114
@_spi ( Experimental)
113
- public protocol AttachableAsIWICBitmap {
115
+ public protocol AttachableAsIWICBitmapSource {
114
116
/// Create a WIC bitmap representing an instance of this type.
115
117
///
116
118
/// - Parameters:
@@ -124,9 +126,9 @@ public protocol AttachableAsIWICBitmap {
124
126
///
125
127
/// This function is not part of the public interface of the testing library.
126
128
/// It may be removed in a future update.
127
- borrowing func _copyAttachableIWICBitmap (
129
+ borrowing func _copyAttachableIWICBitmapSource (
128
130
using factory: UnsafeMutablePointer < IWICImagingFactory >
129
- ) throws -> UnsafeMutablePointer < IWICBitmap >
131
+ ) throws -> UnsafeMutablePointer < IWICBitmapSource >
130
132
131
133
/// Make a copy of this instance.
132
134
///
@@ -152,7 +154,7 @@ public protocol AttachableAsIWICBitmap {
152
154
/// automatically invokes this function as needed.
153
155
///
154
156
/// This function is not responsible for releasing the image returned from
155
- /// `_copyAttachableIWICBitmap (using:)`.
157
+ /// `_copyAttachableIWICBitmapSource (using:)`.
156
158
///
157
159
/// The default implementation of this function when `Self` conforms to
158
160
/// `Sendable` does nothing.
@@ -162,42 +164,7 @@ public protocol AttachableAsIWICBitmap {
162
164
func _deinitializeAttachableValue( )
163
165
}
164
166
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 {
201
168
public func _copyAttachableValue( ) -> Self {
202
169
self
203
170
}
0 commit comments