You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// The encoding quality to use when encoding the represented image.
25
+
///
26
+
/// If the image format used for encoding (specified by the ``contentType``
27
+
/// property) does not support variable-quality encoding, the value of this
28
+
/// property is ignored.
29
+
publicvarencodingQuality:Float
30
+
31
+
/// Storage for ``contentType``.
32
+
privatevar_contentType:(anySendable)?
33
+
34
+
/// The content type to use when encoding the image.
35
+
///
36
+
/// The testing library uses this property to determine which image format to
37
+
/// encode the associated image as when it is attached to a test.
38
+
///
39
+
/// If the value of this property does not conform to [`UTType.image`](https://developer.apple.com/documentation/uniformtypeidentifiers/uttype-swift.struct/image),
40
+
/// the result is undefined.
41
+
@available(_uttypesAPI,*)
42
+
varcontentType:UTType{
43
+
get{
44
+
iflet contentType = _contentType as?UTType{
45
+
return contentType
46
+
}else{
47
+
return encodingQuality <1.0?.jpeg :.png
48
+
}
49
+
}
50
+
set{
51
+
precondition(
52
+
newValue.conforms(to:.image),
53
+
"An image cannot be attached as an instance of type '\(newValue.identifier)'. Use a type that conforms to 'public.image' instead."
54
+
)
55
+
_contentType = newValue
56
+
}
57
+
}
58
+
59
+
/// The content type to use when encoding the image, substituting a concrete
60
+
/// type for `UTType.image`.
61
+
///
62
+
/// This property is not part of the public interface of the testing library.
Copy file name to clipboardExpand all lines: Sources/Overlays/_Testing_CoreGraphics/Attachments/_AttachableImageWrapper.swift
+7-71Lines changed: 7 additions & 71 deletions
Original file line number
Diff line number
Diff line change
@@ -24,10 +24,7 @@ import UniformTypeIdentifiers
24
24
/// event handler (primarily because `Event` is `Sendable`.) So we would have
25
25
/// to eagerly serialize them, which is unnecessarily expensive if we know
26
26
/// they're actually concurrency-safe.
27
-
/// 2. We would have no place to store metadata such as the encoding quality
28
-
/// (although in the future we may introduce a "metadata" associated type to
29
-
/// `Attachable` that could store that info.)
30
-
/// 3. `Attachable` has a requirement with `Self` in non-parameter, non-return
27
+
/// 2. `Attachable` has a requirement with `Self` in non-parameter, non-return
31
28
/// position. As far as Swift is concerned, a non-final class cannot satisfy
32
29
/// such a requirement, and all image types we care about are non-final
33
30
/// classes. Thus, the compiler will steadfastly refuse to allow non-final
@@ -57,71 +54,8 @@ public struct _AttachableImageWrapper<Image>: Sendable where Image: AttachableAs
57
54
/// instances of this type it creates hold "safe" `NSImage` instances.
58
55
nonisolated(unsafe)var image:Image
59
56
60
-
/// The encoding quality to use when encoding the represented image.
61
-
varencodingQuality:Float
62
-
63
-
/// Storage for ``contentType``.
64
-
privatevar_contentType:(anySendable)?
65
-
66
-
/// The content type to use when encoding the image.
67
-
///
68
-
/// The testing library uses this property to determine which image format to
69
-
/// encode the associated image as when it is attached to a test.
70
-
///
71
-
/// If the value of this property does not conform to [`UTType.image`](https://developer.apple.com/documentation/uniformtypeidentifiers/uttype-swift.struct/image),
72
-
/// the result is undefined.
73
-
@available(_uttypesAPI,*)
74
-
varcontentType:UTType{
75
-
get{
76
-
iflet contentType = _contentType as?UTType{
77
-
return contentType
78
-
}else{
79
-
return encodingQuality <1.0?.jpeg :.png
80
-
}
81
-
}
82
-
set{
83
-
precondition(
84
-
newValue.conforms(to:.image),
85
-
"An image cannot be attached as an instance of type '\(newValue.identifier)'. Use a type that conforms to 'public.image' instead."
86
-
)
87
-
_contentType = newValue
88
-
}
89
-
}
90
-
91
-
/// The content type to use when encoding the image, substituting a concrete
92
-
/// type for `UTType.image`.
93
-
///
94
-
/// This property is not part of the public interface of the testing library.
0 commit comments