diff --git a/src/coreimage.cs b/src/coreimage.cs index fc1ac712ca..0e64daaffc 100644 --- a/src/coreimage.cs +++ b/src/coreimage.cs @@ -2719,11 +2719,8 @@ namespace CoreImage { [CoreImageFilter] [iOS (9,0)] - [BaseType (typeof (CIFilter))] + [BaseType (typeof (CIReductionFilter))] interface CIAreaAverage { - - [CoreImageFilterProperty ("inputExtent")] - CIVector Extent { get; set; } } [CoreImageFilter] @@ -5653,7 +5650,7 @@ namespace CoreImage { [iOS (13,0)] [TV (13,0)] [Mac (10,15, onlyOn64: true)] - [BaseType (typeof (CIFilter))] + [BaseType (typeof (CIReductionFilter))] interface CIKMeans { [CoreImageFilterProperty ("inputMeans")] @@ -5662,9 +5659,6 @@ namespace CoreImage { [CoreImageFilterProperty ("inputCount")] float Count { get; set; } - [CoreImageFilterProperty ("inputExtent")] - CIVector Extent { get; set; } - [CoreImageFilterProperty ("inputPasses")] int Passes { get; set; } @@ -5677,7 +5671,8 @@ namespace CoreImage { [TV (13,0)] [Mac (10,15, onlyOn64: true)] [BaseType (typeof (CIFilter))] - interface CIMorphologyRectangleMaximum { + [Abstract] + interface CIMorphologyRectangle { [CoreImageFilterProperty ("inputHeight")] int Height { get; set; } @@ -5690,14 +5685,16 @@ namespace CoreImage { [iOS (13,0)] [TV (13,0)] [Mac (10,15, onlyOn64: true)] - [BaseType (typeof (CIFilter))] + [BaseType (typeof (CIMorphologyRectangle))] + interface CIMorphologyRectangleMaximum { + } + + [CoreImageFilter] + [iOS (13,0)] + [TV (13,0)] + [Mac (10,15, onlyOn64: true)] + [BaseType (typeof (CIMorphologyRectangle))] interface CIMorphologyRectangleMinimum { - - [CoreImageFilterProperty ("inputHeight")] - int Height { get; set; } - - [CoreImageFilterProperty ("inputWidth")] - int Width { get; set; } } [CoreImageFilter] @@ -5727,4 +5724,80 @@ namespace CoreImage { [CoreImageFilterProperty ("inputPerceptual")] bool Perceptual { get; set; } } + + [CoreImageFilter] + [iOS (13,0)] + [TV (13,0)] + [Mac (10,15, onlyOn64: true)] + [BaseType (typeof (CIFilter))] + [Abstract] + interface CIKeystoneCorrection { + + [CoreImageFilterProperty ("inputFocalLength")] + float FocalLength { get; set; } + + [CoreImageFilterProperty ("inputTopRight")] + CIVector TopRight { get; set; } + + [CoreImageFilterProperty ("inputBottomRight")] + CIVector BottomRight { get; set; } + + [CoreImageFilterProperty ("inputTopLeft")] + CIVector TopLeft { get; set; } + + [CoreImageFilterProperty ("inputBottomLeft")] + CIVector BottomLeft { get; set; } + } + + [CoreImageFilter] + [iOS (13,0)] + [TV (13,0)] + [Mac (10,15, onlyOn64: true)] + [BaseType (typeof (CIKeystoneCorrection))] + interface CIKeystoneCorrectionCombined { + } + + [CoreImageFilter] + [iOS (13,0)] + [TV (13,0)] + [Mac (10,15, onlyOn64: true)] + [BaseType (typeof (CIKeystoneCorrection))] + interface CIKeystoneCorrectionHorizontal { + } + + [CoreImageFilter] + [iOS (13,0)] + [TV (13,0)] + [Mac (10,15, onlyOn64: true)] + [BaseType (typeof (CIKeystoneCorrection))] + interface CIKeystoneCorrectionVertical { + } + + [CoreImageFilter] + [iOS (13,0)] + [TV (13,0)] + [Mac (10,15, onlyOn64: true)] + [BaseType (typeof (CIFilter))] + interface CIPerspectiveRotate { + + [CoreImageFilterProperty ("inputFocalLength")] + float FocalLength { get; set; } + + [CoreImageFilterProperty ("inputRoll")] + float Roll { get; set; } + + [CoreImageFilterProperty ("inputPitch")] + float Pitch { get; set; } + + [CoreImageFilterProperty ("inputYaw")] + float Yaw { get; set; } + } + + [CoreImageFilter] + [iOS (13,0)] + [TV (13,0)] + [Mac (10,15, onlyOn64: true)] + [BaseType (typeof (CIFilter))] + interface CIGaborGradients { + } } diff --git a/tests/introspection/ApiCoreImageFiltersTest.cs b/tests/introspection/ApiCoreImageFiltersTest.cs index 33c54b39dd..8d31abf0fa 100644 --- a/tests/introspection/ApiCoreImageFiltersTest.cs +++ b/tests/introspection/ApiCoreImageFiltersTest.cs @@ -54,6 +54,12 @@ namespace Introspection { static Type CIFilterType = typeof (CIFilter); +#if false + static TextWriter BindingOutput; +#else + static TextWriter BindingOutput = Console.Out; +#endif + protected virtual bool Skip (Type type) { return Skip (type.Name) || SkipDueToAttribute (type); @@ -66,13 +72,6 @@ namespace Introspection { // NSUnknownKeyException [ valueForUndefinedKey:]: this class is not key value coding-compliant for the key inputPoint2. case "CIDepthOfField": return true; - // TODO: https://github.com/xamarin/xamarin-macios/issues/6340 - case "CIGaborGradients": - case "CIKeystoneCorrectionCombined": - case "CIKeystoneCorrectionHorizontal": - case "CIKeystoneCorrectionVertical": - case "CIPerspectiveRotate": - return true; // Apple does **not** document filters as API (like we do) // uncomment calls to `GenerateBinding` to use introspection code to generate the skeleton binding code and complete it // e.g. picking better types like `bool` instead of `NSNumber' @@ -95,8 +94,8 @@ namespace Introspection { string type_name = qname.Replace ("CIFilter", filter_name); if (Type.GetType (type_name, false, true) == null) { filters.Add (filter_name); - // uncomment to generate bindings for any new native filter -// GenerateBinding (CIFilter.FromName (filter_name), Console.Out); + if (BindingOutput != null) + GenerateBinding (CIFilter.FromName (filter_name), BindingOutput); } n++; } @@ -137,7 +136,7 @@ namespace Introspection { if (!superFilters.Contains (super)) { superFilters.Add (super); Console.WriteLine ("[GENERATED] {0}", super); - GenerateBinding (CIFilter.FromName (super), Console.Out); + GenerateBinding (CIFilter.FromName (super), BindingOutput); } } #endif @@ -201,22 +200,20 @@ namespace Introspection { writer.WriteLine (); var dict = attributes [k] as NSDictionary; var type = dict [(NSString) "CIAttributeClass"]; - writer.WriteLine ("\t[CoreImageFilterProperty (\"{0}\")]", key); + writer.WriteLine ($"\t[CoreImageFilterProperty (\"{key}\")]"); // by default we drop the "input" prefix, but keep the "output" prefix to avoid confusion if (key.StartsWith ("input", StringComparison.Ordinal)) key = Char.ToUpperInvariant (key [5]) + key.Substring (6); - - var ptype = type.ToString (); - // Too many things ends up in NSNumber but we do a better job in our bindings - if (ptype == "NSNumber") { - ptype = "float"; - writer.WriteLine ("\t// TODO: this was an NSNumber transformed to float, but maybe an int or bool is more appropriate"); - } - writer.WriteLine ("\t{0} {1} {{ get; set; }}", ptype, key); + + writer.WriteLine ("\t/* REMOVE-ME"); + writer.WriteLine (dict); + writer.WriteLine ("\t*/"); + writer.WriteLine ($"\t{type} {key} {{ get; set; }}"); } writer.WriteLine ("}"); writer.WriteLine (); + writer.Flush (); } } }