Skip to content

Commit f6409a6

Browse files
authored
[CoreImage] Update to Xcode 26 beta 1-7. (#23702)
Fixes #23054.
1 parent 4daf26a commit f6409a6

File tree

20 files changed

+722
-475
lines changed

20 files changed

+722
-475
lines changed

src/CoreImage/CIContext.cs

Lines changed: 13 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2626
//
2727
using System;
28+
using System.ComponentModel;
2829

2930
using Foundation;
3031
using CoreGraphics;
@@ -39,166 +40,37 @@
3940

4041
namespace CoreImage {
4142
/// <summary>Use to configure the CIContext rendering pipeline.</summary>
42-
/// <remarks>You would use an instance of this class to configure the CIContext rendering operations.</remarks>
43+
/// <remarks>You would use an instance of this class to configure the CIContext rendering operations.</remarks>
4344
[SupportedOSPlatform ("ios")]
4445
[SupportedOSPlatform ("maccatalyst")]
4546
[SupportedOSPlatform ("macos")]
4647
[SupportedOSPlatform ("tvos")]
47-
public class CIContextOptions : DictionaryContainer {
48-
49-
/// <summary>Creates an empty set of options for CIContext rendering.</summary>
50-
/// <remarks>
51-
/// </remarks>
52-
public CIContextOptions ()
53-
{
54-
}
55-
56-
/// <param name="dictionary">To be added.</param>
57-
/// <summary>Constructs a new <see cref="CoreImage.CIContextOptions" /> object using the options specified in <paramref name="dictionary" />.</summary>
58-
/// <remarks>To be added.</remarks>
59-
public CIContextOptions (NSDictionary dictionary)
60-
: base (dictionary)
61-
{
62-
}
63-
64-
/// <summary>The desired CIColorSpace to be used for the CIContext rendering operation.</summary>
65-
/// <value>
66-
/// </value>
67-
/// <remarks>This color space is used before the image is rendered into the output.</remarks>
68-
public CGColorSpace? OutputColorSpace {
69-
get {
70-
return GetNativeValue<CGColorSpace> (CIContext.OutputColorSpace);
71-
}
72-
set {
73-
SetNativeValue (CIContext.OutputColorSpace, value);
74-
}
75-
}
76-
77-
/// <summary>The colorspace used by image processing operations, this is different than the colorspace used for the final rendering.</summary>
78-
/// <value>To be added.</value>
79-
/// <remarks>To be added.</remarks>
80-
public CGColorSpace? WorkingColorSpace {
81-
get {
82-
return GetNativeValue<CGColorSpace> (CIContext._WorkingColorSpace);
83-
}
84-
set {
85-
SetNativeValue (CIContext._WorkingColorSpace, value);
86-
}
87-
}
88-
89-
#if __MACOS__
90-
/// <include file="../../docs/api/CoreImage/CIContextOptions.xml" path="/Documentation/Docs[@DocId='macOS:P:CoreImage.CIContextOptions.UseSoftwareRenderer']/*" />
91-
#else
92-
/// <include file="../../docs/api/CoreImage/CIContextOptions.xml" path="/Documentation/Docs[@DocId='P:CoreImage.CIContextOptions.UseSoftwareRenderer']/*" />
93-
#endif
48+
public partial class CIContextOptions : DictionaryContainer {
49+
#if !XAMCORE_5_0
50+
[EditorBrowsable (EditorBrowsableState.Never)]
51+
[Obsolete ("Use 'NullableUseSoftwareRenderer' instead.")]
9452
public bool UseSoftwareRenderer {
9553
get {
96-
var b = GetBoolValue (CIContext.UseSoftwareRenderer);
54+
var b = GetBoolValue (CIContextOptionKeys.UseSoftwareRenderer);
9755
return b.HasValue ? b.Value : false;
9856
}
9957
set {
100-
SetBooleanValue (CIContext.UseSoftwareRenderer, value);
58+
SetBooleanValue (CIContextOptionKeys.UseSoftwareRenderer, value);
10159
}
10260
}
10361

10462
/// <summary>Gets or sets the image format to use for storing intermediate rendering results.</summary>
105-
/// <value>To be added.</value>
106-
/// <remarks>To be added.</remarks>
63+
[EditorBrowsable (EditorBrowsableState.Never)]
64+
[Obsolete ("Use 'WorkingFormatField' instead.")]
10765
public int? CIImageFormat {
10866
get {
109-
return GetInt32Value (CIContext.WorkingFormatField);
110-
}
111-
set {
112-
SetNumberValue (CIContext.WorkingFormatField, value);
113-
}
114-
}
115-
116-
/// <summary>Gets or sets whether to request low priority from the GPU.</summary>
117-
/// <value>To be added.</value>
118-
/// <remarks>To be added.</remarks>
119-
[SupportedOSPlatform ("macos")]
120-
[SupportedOSPlatform ("ios")]
121-
[SupportedOSPlatform ("maccatalyst")]
122-
[SupportedOSPlatform ("tvos")]
123-
public bool? PriorityRequestLow {
124-
get {
125-
return GetBoolValue (CIContext.PriorityRequestLow);
126-
}
127-
set {
128-
SetBooleanValue (CIContext.PriorityRequestLow, value);
129-
}
130-
}
131-
132-
/// <summary>
133-
/// <see langword="true" /> if downsampling should be higher quality at the expense of performance.</summary>
134-
/// <value>To be added.</value>
135-
/// <remarks>To be added.</remarks>
136-
public bool? HighQualityDownsample {
137-
get {
138-
return GetBoolValue (CIContext.HighQualityDownsample);
139-
}
140-
set {
141-
SetBooleanValue (CIContext.HighQualityDownsample, value);
142-
}
143-
}
144-
145-
/// <summary>If <see langword="true" />, the output should premultiply pixel values by their alpha values.</summary>
146-
/// <value>To be added.</value>
147-
/// <remarks>To be added.</remarks>
148-
[SupportedOSPlatform ("ios")]
149-
[SupportedOSPlatform ("maccatalyst")]
150-
[SupportedOSPlatform ("macos")]
151-
[SupportedOSPlatform ("tvos")]
152-
public bool? OutputPremultiplied {
153-
get {
154-
return GetBoolValue (CIContext.OutputPremultiplied);
155-
}
156-
set {
157-
SetBooleanValue (CIContext.OutputPremultiplied, value);
158-
}
159-
}
160-
161-
/// <summary>If not <see langword="null" />, <see langword="true" /> indicates that intermediate images should be cached.</summary>
162-
/// <value>To be added.</value>
163-
/// <remarks>To be added.</remarks>
164-
[SupportedOSPlatform ("ios")]
165-
[SupportedOSPlatform ("macos")]
166-
[SupportedOSPlatform ("maccatalyst")]
167-
[SupportedOSPlatform ("tvos")]
168-
public bool? CacheIntermediates {
169-
get {
170-
return GetBoolValue (CIContext.CacheIntermediates);
171-
}
172-
set {
173-
SetBooleanValue (CIContext.CacheIntermediates, value);
174-
}
175-
}
176-
177-
[SupportedOSPlatform ("ios13.0")]
178-
[SupportedOSPlatform ("tvos13.0")]
179-
[SupportedOSPlatform ("macos")]
180-
[SupportedOSPlatform ("maccatalyst")]
181-
public bool? AllowLowPower {
182-
get {
183-
return GetBoolValue (CIContext.AllowLowPower);
184-
}
185-
set {
186-
SetBooleanValue (CIContext.AllowLowPower, value);
187-
}
188-
}
189-
190-
[SupportedOSPlatform ("ios14.0")]
191-
[SupportedOSPlatform ("tvos14.0")]
192-
[SupportedOSPlatform ("macos")]
193-
[SupportedOSPlatform ("maccatalyst")]
194-
public string? Name {
195-
get {
196-
return GetStringValue (CIContext.Name);
67+
return GetInt32Value (CIContextOptionKeys.WorkingFormatField);
19768
}
19869
set {
199-
SetStringValue (CIContext.Name, value);
70+
SetNumberValue (CIContextOptionKeys.WorkingFormatField, value);
20071
}
20172
}
73+
#endif // !XAMCORE_5_0
20274
}
20375

20476
public partial class CIContext {

src/CoreImage/CISystemToneMap.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
namespace CoreImage;
5+
6+
partial class CISystemToneMap {
7+
[SupportedOSPlatform ("ios26.0")]
8+
[SupportedOSPlatform ("macos26.0")]
9+
[SupportedOSPlatform ("tvos26.0")]
10+
[SupportedOSPlatform ("maccatalyst26.0")]
11+
public CIDynamicRangeOption? PreferredDynamicRange {
12+
get {
13+
return ((ICISystemToneMapProtocol) this).PreferredDynamicRange;
14+
}
15+
set {
16+
((ICISystemToneMapProtocol) this).PreferredDynamicRange = value;
17+
}
18+
}
19+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
namespace CoreImage;
5+
6+
partial interface ICISystemToneMapProtocol {
7+
[SupportedOSPlatform ("ios26.0")]
8+
[SupportedOSPlatform ("macos26.0")]
9+
[SupportedOSPlatform ("tvos26.0")]
10+
[SupportedOSPlatform ("maccatalyst26.0")]
11+
public CIDynamicRangeOption? PreferredDynamicRange {
12+
get {
13+
var value = WeakPreferredDynamicRange;
14+
if (value is null)
15+
return null;
16+
return CIDynamicRangeOptionExtensions.GetValue (value);
17+
}
18+
set {
19+
WeakPreferredDynamicRange = value.HasValue ? value.Value.GetConstant () : null;
20+
}
21+
}
22+
}

src/Resources.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Resources.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@
626626
</data>
627627

628628
<data name="BI1121" xml:space="preserve">
629-
<value>The strong enum '{0}' is not a valid strong dictionary field for the property '{1}.{2}', because its backing type is '{3}'. Only enums with backing type 'NSString' or 'NSNumber' are supported in strong dictionaries.</value>
629+
<value>The strong enum '{0}' is not a valid strong dictionary field for the property '{1}.{2}', because its backing type is '{3}'. Only enums with backing type 'NSString', 'NSNumber' or 'System.Int32' are supported in strong dictionaries.</value>
630630
</data>
631631

632632
<data name="BI1122" xml:space="preserve">

src/bgen/Filters.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ void GenerateFilterGetter (string propertyType, string propertyName, PropertyInf
305305
break;
306306
case "AVCameraCalibrationData":
307307
case "MLModel":
308+
case "NSString":
308309
case "NSAttributedString":
309310
case "NSData":
310311
print ("return Runtime.GetNSObject <{0}> (GetHandle (\"{1}\"), false)!;", propertyType, propertyName);
@@ -390,6 +391,7 @@ void GenerateFilterSetter (string propertyType, string propertyName, PropertyInf
390391
case "CIVector":
391392
case "MLModel":
392393
case "NSAttributedString":
394+
case "NSString":
393395
case "NSData":
394396
// NSNumber should not be added - it should be bound as a int or a float
395397
print ("SetValue (\"{0}\", value);", propertyName);

src/bgen/Generator.cs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1865,8 +1865,10 @@ void ValidateStrongEnumBackingTypeInStrongDictionaryType (PropertyInfo property,
18651865
return;
18661866
if (enumBackingType == TypeCache.NSNumber)
18671867
return;
1868+
if (enumBackingType == TypeCache.System_Int32)
1869+
return;
18681870

1869-
exceptions.Add (ErrorHelper.CreateError (1121 /* The strong enum '{0}' is not a valid strong dictionary field for the property '{1}.{2}', because its backing type is '{3}'. Only enums with backing type 'NSString' or 'NSNumber' are supported in strong dictionaries. */, property.PropertyType.Name, property.DeclaringType.FullName, property.Name, enumBackingType.FullName));
1871+
exceptions.Add (ErrorHelper.CreateError (1121 /* The strong enum '{0}' is not a valid strong dictionary field for the property '{1}.{2}', because its backing type is '{3}'. Only enums with backing type 'NSString', 'NSNumber' or 'System.Int32' are supported in strong dictionaries. */, property.PropertyType.Name, property.DeclaringType.FullName, property.Name, enumBackingType.FullName));
18701872
}
18711873

18721874
//
@@ -1949,8 +1951,15 @@ void GenerateStrongDictionaryTypes ()
19491951
}
19501952
if (pi.PropertyType.IsValueType) {
19511953
if (enumBackingType is not null) {
1952-
getter = "TryGetNativeValue ({0}, out var handle) ? " + TypeManager.FormatType (null, pi.PropertyType) + "Extensions.GetNullableValue (handle) : null";
1953-
setter = "SetNativeValue ({0}, value.HasValue ? value.Value.GetConstant () : null)";
1954+
if (TryGetNSNumberStrongDictionaryMethods (enumBackingType, out var getNSNumber, out var setNSNumber)) {
1955+
getter = "(" + TypeManager.FormatType (null, pi.PropertyType) + "?) " + getNSNumber + " ({0})";
1956+
setter = setNSNumber + " ({0}, (" + TypeManager.FormatType (null, enumBackingType) + "?) value)";
1957+
} else if (enumBackingType == TypeCache.NSString || enumBackingType == TypeCache.NSNumber) {
1958+
getter = "TryGetNativeValue ({0}, out var handle) ? " + TypeManager.FormatType (null, pi.PropertyType) + "Extensions.GetNullableValue (handle) : null";
1959+
setter = "SetNativeValue ({0}, value.HasValue ? value.Value.GetConstant () : null)";
1960+
} else {
1961+
exceptions.Add (ErrorHelper.CreateError (99, $"Unexpected enum backing type: {enumBackingType}"));
1962+
}
19541963
} else if (isNativeEnum && fetchType == TypeCache.System_Int64) {
19551964
getter = "{1} (long?) GetNIntValue ({0})";
19561965
setter = "SetNumberValue ({0}, {1}value)";
@@ -2003,8 +2012,15 @@ void GenerateStrongDictionaryTypes ()
20032012
ValidateStrongEnumBackingTypeInStrongDictionaryType (pi, enumBackingType);
20042013

20052014
var enumTypeStr = TypeManager.FormatType (null, elementType);
2006-
getter = "{1} GetArray<" + enumTypeStr + "> ({0}, (ptr) => ptr == NativeHandle.Zero ? default (" + enumTypeStr + ") : " + enumTypeStr + "Extensions.GetValue (ptr))";
2007-
setter = "SetArrayValue<" + enumTypeStr + "> ({0}, value, (element) => Runtime.RetainAndAutoreleaseNSObject (element.GetConstant ()))";
2015+
if (TryGetNSNumberField (enumBackingType, out var fieldName)) {
2016+
getter = "{1} GetArray<" + enumTypeStr + "> ({0}, (ptr) => (" + enumTypeStr + "?) Runtime.GetNSObjectChecked<NSNumber> (ptr)?." + fieldName + " ?? default (" + enumTypeStr + "))";
2017+
setter = "SetArrayValue<" + enumTypeStr + "> ({0}, value, (element) => Runtime.RetainAndAutoreleaseNSObject (new NSNumber ((" + TypeManager.FormatType (null, enumBackingType) + ") element)))";
2018+
} else if (enumBackingType == TypeCache.NSString || enumBackingType == TypeCache.NSNumber) {
2019+
getter = "{1} GetArray<" + enumTypeStr + "> ({0}, (ptr) => ptr == NativeHandle.Zero ? default (" + enumTypeStr + ") : " + enumTypeStr + "Extensions.GetValue (ptr))";
2020+
setter = "SetArrayValue<" + enumTypeStr + "> ({0}, value, (element) => Runtime.RetainAndAutoreleaseNSObject (element.GetConstant ()))";
2021+
} else {
2022+
exceptions.Add (ErrorHelper.CreateError (99, $"Unexpected enum backing type: {enumBackingType}"));
2023+
}
20082024
} else if (elementType.IsEnum) {
20092025
var underlyingEnumType = elementType.GetEnumUnderlyingType ();
20102026
if (!TryGetNSNumberField (underlyingEnumType, out var fieldName))

0 commit comments

Comments
 (0)