[coreimage] Add new Image Dictionary Keys

- Fixes bug #59296: [coreimage] Some `kCI*`keys are not bound
  (https://bugzilla.xamarin.com/show_bug.cgi?id=59296)
- Generate a StrongDictionary for `CIImageInitializationOptions` to avoid manual code.
- Move `CGImageProperties Properties { get; set; }` to parent type `CIImageInitializationOptions` (avoid 2 strong dictionaries).
  Reason:
  Even though the headers give us an indication of which constructors should use some CIImage keys it's hard to apply that
  to all constructors consistently.
  We could have 1 strong dictionary per constructor (duplicate members) with just the exact members we know it supports (based on headers) however
  it's better to have a single strong dictionary and document the options because A might be available only in X today and Y next too next year.
- Fix `DictionaryContainer`'s `GetStrongDictionary` to return null
and not throw if target StrongDictionary is not yet set.

Basically:

```
var options = new CIImageInitializationOptionsWithMetadata ();
            Assert.That (options.Dictionary.Count, Is.EqualTo (0), "Count");
```

Would throw:

```
System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation.
  ----> System.ArgumentNullException : Value cannot be null.
```
This commit is contained in:
Vincent Dondain 2017-11-16 13:47:21 -05:00
Родитель fc7f6ce1be
Коммит f307f377a1
5 изменённых файлов: 63 добавлений и 41 удалений

Просмотреть файл

@ -144,7 +144,7 @@ namespace XamCore.CoreImage {
throw new ArgumentNullException ("colorSpace"); throw new ArgumentNullException ("colorSpace");
using (var arr = NSArray.FromIntPtrs (new IntPtr [] { colorSpace.Handle })){ using (var arr = NSArray.FromIntPtrs (new IntPtr [] { colorSpace.Handle })){
using (var keys = NSArray.FromIntPtrs (new IntPtr [] { CIImageColorSpaceKey.Handle } )){ using (var keys = NSArray.FromIntPtrs (new IntPtr [] { CIImageInitializationOptionsKeys.ColorSpaceKey.Handle } )){
using (var dict = NSDictionary.FromObjectsAndKeysInternal (arr, keys)){ using (var dict = NSDictionary.FromObjectsAndKeysInternal (arr, keys)){
return FromCGImage (image, dict); return FromCGImage (image, dict);
} }

Просмотреть файл

@ -34,30 +34,21 @@ using XamCore.CoreGraphics;
namespace XamCore.CoreImage { namespace XamCore.CoreImage {
public class CIImageInitializationOptions : DictionaryContainer public partial class CIImageInitializationOptions
{ {
#if !COREBUILD #if !COREBUILD
public CIImageInitializationOptions ()
: base (new NSMutableDictionary ())
{
}
public CIImageInitializationOptions (NSDictionary dictionary)
: base (dictionary)
{
}
public CGColorSpace ColorSpace { public CGColorSpace ColorSpace {
get { get {
return GetNativeValue<CGColorSpace> (CIImage.CIImageColorSpaceKey); return GetNativeValue<CGColorSpace> (CIImageInitializationOptionsKeys.ColorSpaceKey);
} }
set { set {
SetNativeValue (CIImage.CIImageColorSpaceKey, value == null ? null : value); SetNativeValue (CIImageInitializationOptionsKeys.ColorSpaceKey, value == null ? null : value);
} }
} }
#endif #endif
} }
// Keeping 'CIImageInitializationOptionsWithMetadata' to avoid breaking change
public class CIImageInitializationOptionsWithMetadata : CIImageInitializationOptions public class CIImageInitializationOptionsWithMetadata : CIImageInitializationOptions
{ {
#if !COREBUILD #if !COREBUILD
@ -69,18 +60,6 @@ namespace XamCore.CoreImage {
: base (dictionary) : base (dictionary)
{ {
} }
public CGImageProperties Properties {
get {
var dict = GetNativeValue<NSDictionary> (CIImage.CIImagePropertiesKey);
if (dict == null)
return null;
return new CGImageProperties (dict);
}
set {
SetNativeValue (CIImage.CIImagePropertiesKey, value == null ? null : value.Dictionary, false);
}
}
#endif #endif
} }
} }

Просмотреть файл

@ -237,6 +237,8 @@ namespace XamCore.Foundation {
throw new ArgumentNullException ("key"); throw new ArgumentNullException ("key");
var dict = GetNSDictionary (key); var dict = GetNSDictionary (key);
if (dict == null)
return null;
T value = (T)Activator.CreateInstance (typeof(T), T value = (T)Activator.CreateInstance (typeof(T),
new object[] { dict } new object[] { dict }
); );

Просмотреть файл

@ -942,6 +942,14 @@ namespace XamCore.CoreImage {
[Since (7,0)] [Since (7,0)]
[Field ("kCIInputExtentKey", "+CoreImage")] [Field ("kCIInputExtentKey", "+CoreImage")]
NSString Extent { get; } NSString Extent { get; }
[iOS (11,0), TV (11,0), Mac (10,13)]
[Field ("kCIInputDepthImageKey", "+CoreImage")]
NSString DepthImage { get; }
[iOS (11,0), TV (11,0), Mac (10,13)]
[Field ("kCIInputDisparityImageKey", "+CoreImage")]
NSString DisparityImage { get; }
} }
[Since (5,0)] [Since (5,0)]
@ -1262,6 +1270,54 @@ namespace XamCore.CoreImage {
[Export ("extent")] [Export ("extent")]
CGRect Extent { get; } CGRect Extent { get; }
} }
[StrongDictionary ("CIImageInitializationOptionsKeys")]
interface CIImageInitializationOptions {
// Bug #60726: [Generator] Support INativeObject in StrongDictionary
// (https://bugzilla.xamarin.com/show_bug.cgi?id=60726)
// CGColorSpace ColorSpace { get; set; }
CoreGraphics.CGImageProperties Properties { get; set; }
[iOS (11,0), TV (11,0), Mac (10,13)]
bool ApplyOrientationProperty { get; set; }
[iOS (11,0), TV (11,0), Mac (10,13)]
bool NearestSampling { get; set; }
[iOS (11,0), TV (11,0), Mac (10,13)]
bool AuxiliaryDepth { get; set; }
[iOS (11,0), TV (11,0), Mac (10,13)]
bool AuxiliaryDisparity { get; set; }
}
[Internal]
[Static]
interface CIImageInitializationOptionsKeys {
[Field ("kCIImageColorSpace")]
NSString ColorSpaceKey { get; }
[MountainLion]
[Field ("kCIImageProperties")]
NSString PropertiesKey { get; }
[iOS (11,0), TV (11,0), Mac (10,13)]
[Field ("kCIImageNearestSampling")]
NSString NearestSamplingKey { get; }
[iOS (11,0), TV (11,0), Mac (10,13)]
[Field ("kCIImageApplyOrientationProperty")]
NSString ApplyOrientationPropertyKey { get; }
[iOS (11,0), TV (11,0), Mac (10,13)]
[Field ("kCIImageAuxiliaryDepth")]
NSString AuxiliaryDepthKey { get; }
[iOS (11,0), TV (11,0), Mac (10,13)]
[Field ("kCIImageAuxiliaryDisparity")]
NSString AuxiliaryDisparityKey { get; }
}
[BaseType (typeof (NSObject))] [BaseType (typeof (NSObject))]
[Since (5,0)] [Since (5,0)]
@ -1692,13 +1748,6 @@ namespace XamCore.CoreImage {
[Export ("autoAdjustmentFiltersWithOptions:"), Internal] [Export ("autoAdjustmentFiltersWithOptions:"), Internal]
NSArray _GetAutoAdjustmentFilters ([NullAllowed] NSDictionary opts); NSArray _GetAutoAdjustmentFilters ([NullAllowed] NSDictionary opts);
[Field ("kCIImageColorSpace"), Internal]
NSString CIImageColorSpaceKey { get; }
[MountainLion]
[Field ("kCIImageProperties"), Internal]
NSString CIImagePropertiesKey { get; }
[Since (6,0)] // publicly documented in 7.0 but really available since 6.0 [Since (6,0)] // publicly documented in 7.0 but really available since 6.0
[Mac (10,12)] [Mac (10,12)]
[Export ("regionOfInterestForImage:inRect:")] [Export ("regionOfInterestForImage:inRect:")]

Просмотреть файл

@ -65,14 +65,6 @@
!missing-selector! CISampler::initWithImage:keysAndValues: not bound !missing-selector! CISampler::initWithImage:keysAndValues: not bound
!missing-selector! +CISampler::samplerWithImage:keysAndValues: not bound !missing-selector! +CISampler::samplerWithImage:keysAndValues: not bound
## https://bugzilla.xamarin.com/show_bug.cgi?id=59296
!missing-field! kCIImageApplyOrientationProperty not bound
!missing-field! kCIImageAuxiliaryDepth not bound
!missing-field! kCIImageAuxiliaryDisparity not bound
!missing-field! kCIImageNearestSampling not bound
!missing-field! kCIInputDepthImageKey not bound
!missing-field! kCIInputDisparityImageKey not bound
# Foundation # Foundation