Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions docs/website/generator-errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,35 @@ This usually indicates a bug in Xamarin.iOS/Xamarin.Mac; please [file a bug repo

### <a name='BI1070'/>BI1070: The type '{type}' is trying to inline the property '{property}' from the protocols '{protocol1}' and '{protocol2}', but the inlined properties are of different types ('{property1}' is int, while '{property2}' is int).

<!-- 1071 used in master -->

### <a name='BI1072'/>BI1072: Missing [CoreImageFilterProperty] attribute on {type} property {name}

This error happens when a binding type, decorated with `[CoreImageFilter]` attribute, has properties that are not decorated with a `[CoreImageFilterProperty]` attribute. E.g.

```csharp
[CoreImageFilter]
[BaseType (typeof (CIFilter))]
interface CICustomFilter {

CGAffineTransform Transform { get; }
}
```

To solve this error you need to tell the `CIFilter` key that you want to map to the property, e.g.

```csharp
[CoreImageFilter]
[BaseType (typeof (CIFilter))]
interface CICustomFilter {

[CoreImageFilterProperty ("inputTransform")]
CGAffineTransform Transform { get; }
}
```

If the property is inlined from a protocol then the `[Export]` value, prefixed with `input`, will be used by default. You can override this with by adding the `[CoreImageFilterProperty]` attribute (e.g. for `output*` keys).

# BI11xx: warnings

<!-- 11xx: warnings -->
Expand Down
10 changes: 10 additions & 0 deletions src/CoreImage/CIContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,16 @@ public bool? CacheIntermediates {
SetBooleanValue (CIContext.CacheIntermediates, value);
}
}

[iOS (13,0)][TV (13,0)][Mac (10,15)]
public bool? AllowLowPower {
get {
return GetBoolValue (CIContext.AllowLowPower);
}
set {
SetBooleanValue (CIContext.AllowLowPower, value);
}
}
}

public partial class CIContext {
Expand Down
99 changes: 53 additions & 46 deletions src/CoreImage/CIFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,42 +173,61 @@ internal void SetInt (string key, int value)
SetValueForKey (new NSNumber (value), nskey);
}

internal void SetNInt (string key, nint value)
{
using (var nskey = new NSString (key))
SetValueForKey (new NSNumber (value), nskey);
}

internal void SetBool (string key, bool value)
{
using (var nskey = new NSString (key))
SetValueForKey (new NSNumber (value ? 1 : 0), nskey);
}

internal float GetFloat (string key)
internal void SetValue (string key, CGPoint value)
{
using (var nskey = new NSString (key)){
var v = ValueForKey (nskey);
if (v is NSNumber)
return (v as NSNumber).FloatValue;
return 0;
using (var nskey = new NSString (key))
using (var nsv = new CIVector (value.X, value.Y)) {
SetValueForKey (nsv, nskey);
}
}

internal int GetInt (string key)
internal void SetValue (string key, CGRect value)
{
using (var nskey = new NSString (key)){
var v = ValueForKey (nskey);
if (v is NSNumber)
return (v as NSNumber).Int32Value;
return 0;
using (var nskey = new NSString (key))
using (var nsv = new CIVector (value.X, value.Y, value.Width, value.Height)) {
SetValueForKey (nsv, nskey);
}
}

internal bool GetBool (string key)
internal T Get<T> (string key) where T : class
{
using (var nskey = new NSString (key)){
var v = ValueForKey (nskey);
if (v is NSNumber)
return (v as NSNumber).BoolValue;
return false;
using (var nskey = new NSString (key)) {
return ValueForKey (nskey) as T;
}
}

internal float GetFloat (string key)
{
return Get<NSNumber> (key)?.FloatValue ?? default (float);
}

internal int GetInt (string key)
{
return Get<NSNumber> (key)?.Int32Value ?? default (int);
}

internal nint GetNInt (string key)
{
return Get<NSNumber> (key)?.NIntValue ?? default (nint);
}

internal bool GetBool (string key)
{
return Get<NSNumber> (key)?.BoolValue ?? default (bool);
}

internal void SetHandle (string key, IntPtr handle)
{
var nsname = NSString.CreateNative (key);
Expand Down Expand Up @@ -237,31 +256,16 @@ internal IntPtr GetHandle (string key)
return ret;
}


internal CIVector GetVector (string key)
{
return ValueForKey (key) as CIVector;
}

internal CIColor GetColor (string key)
{
return ValueForKey (key) as CIColor;
}

internal CIImage GetInputImage ()
internal CGPoint GetPoint (string key)
{
return ValueForKey (CIFilterInputKey.Image) as CIImage;
var v = Get<CIVector> (key);
return v != null ? new CGPoint (v.X, v.Y) : default (CGPoint);
}

internal void SetInputImage (CIImage value)
internal CGRect GetRect (string key)
{
SetValueForKey (value, CIFilterInputKey.Image);
}

internal CIImage GetImage (string key)
{
using (var nsstr = new NSString (key))
return ValueForKey (nsstr) as CIImage;
var v = Get<CIVector> (key);
return v != null ? new CGRect (v.X, v.Y, v.Z, v.W) : default (CGRect);
}

#if MONOMAC
Expand Down Expand Up @@ -673,29 +677,32 @@ internal static CIFilter FromName (string filterName, IntPtr handle)
}
}

#if !XAMCORE_4_0
// not every CIFilter supports inputImage, i.e.
// NSUnknownKeyException [<CICheckerboardGenerator 0x1648cb20> valueForUndefinedKey:]: this class is not key value coding-compliant for the key inputImage.
// and those will crash (on devices) if the property is called - and that includes displaying it in the debugger
[Obsolete ("Use 'InputImage' instead. If not available then the filter does not support it.")]
public CIImage Image {
get {
return SupportsInputImage ? GetInputImage () : null;
return SupportsInputImage ? ValueForKey (CIFilterInputKey.Image) as CIImage : null;
}
set {
if (!SupportsInputImage)
throw new ArgumentException ("inputImage is not supported by this filter");
SetInputImage (value);
SetValueForKey (value, CIFilterInputKey.Image);
}
}

bool? supportsInputImage;

bool SupportsInputImage {
get {
foreach (var key in InputKeys) {
if (key == "inputImage")
return true;
}
return false;
if (!supportsInputImage.HasValue)
supportsInputImage = Array.IndexOf (InputKeys, "inputImage") >= 0;
return supportsInputImage.Value;
}
}
#endif
}

#if MONOMAC && !XAMCORE_3_0
Expand Down
11 changes: 8 additions & 3 deletions src/ImageIO/CGImageSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

namespace ImageIO {

#if !COREBUILD
// untyped enum -> CGImageSource.h
public enum CGImageSourceStatus {
Complete = 0,
Expand Down Expand Up @@ -109,9 +110,11 @@ internal override NSMutableDictionary ToDictionary ()
return dict;
}
}

#endif

public partial class CGImageSource : INativeObject, IDisposable
{
#if !COREBUILD
[DllImport (Constants.ImageIOLibrary, EntryPoint="CGImageSourceGetTypeID")]
public extern static nint GetTypeID ();

Expand All @@ -126,7 +129,7 @@ public static string [] TypeIdentifiers {
return array;
}
}
#endif
internal IntPtr handle;

// invoked by marshallers
Expand Down Expand Up @@ -165,7 +168,8 @@ protected virtual void Dispose (bool disposing)
handle = IntPtr.Zero;
}
}


#if !COREBUILD
[DllImport (Constants.ImageIOLibrary)]
extern static /* CGImageSourceRef __nullable */ IntPtr CGImageSourceCreateWithURL (
/* CFURLRef __nonnull */ IntPtr url, /* CFDictionaryRef __nullable */ IntPtr options);
Expand Down Expand Up @@ -403,5 +407,6 @@ public nuint GetPrimaryImageIndex ()
{
return CGImageSourceGetPrimaryImageIndex (handle);
}
#endif
}
}
Loading