[CoreGraphics] Make P/Invokes in CGContext have blittable signatures. (#20207)

Contributes towards #15684.
This commit is contained in:
Rolf Bjarne Kvinge 2024-02-28 08:59:24 +01:00 коммит произвёл GitHub
Родитель 69bb4ac1fb
Коммит 90992e464b
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
4 изменённых файлов: 29 добавлений и 32 удалений

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

@ -340,12 +340,11 @@ namespace CoreGraphics {
[DllImport (Constants.CoreGraphicsLibrary)]
[return: MarshalAs (UnmanagedType.I1)]
extern static bool CGContextIsPathEmpty (/* CGContextRef */ IntPtr context);
extern static byte CGContextIsPathEmpty (/* CGContextRef */ IntPtr context);
public bool IsPathEmpty ()
{
return CGContextIsPathEmpty (Handle);
return CGContextIsPathEmpty (Handle) != 0;
}
[DllImport (Constants.CoreGraphicsLibrary)]
@ -365,12 +364,11 @@ namespace CoreGraphics {
}
[DllImport (Constants.CoreGraphicsLibrary)]
[return: MarshalAs (UnmanagedType.I1)]
extern static bool CGContextPathContainsPoint (/* CGContextRef */ IntPtr context, CGPoint point, CGPathDrawingMode mode);
extern static byte CGContextPathContainsPoint (/* CGContextRef */ IntPtr context, CGPoint point, CGPathDrawingMode mode);
public bool PathContainsPoint (CGPoint point, CGPathDrawingMode mode)
{
return CGContextPathContainsPoint (Handle, point, mode);
return CGContextPathContainsPoint (Handle, point, mode) != 0;
}
[DllImport (Constants.CoreGraphicsLibrary)]
@ -1244,26 +1242,26 @@ namespace CoreGraphics {
}
[DllImport (Constants.CoreGraphicsLibrary)]
extern static void CGContextSetShouldAntialias (/* CGContextRef */ IntPtr context, [MarshalAs (UnmanagedType.I1)] bool shouldAntialias);
extern static void CGContextSetShouldAntialias (/* CGContextRef */ IntPtr context, byte shouldAntialias);
public void SetShouldAntialias (bool shouldAntialias)
{
CGContextSetShouldAntialias (Handle, shouldAntialias);
CGContextSetShouldAntialias (Handle, shouldAntialias.AsByte ());
}
[DllImport (Constants.CoreGraphicsLibrary)]
extern static void CGContextSetAllowsAntialiasing (/* CGContextRef */ IntPtr context, [MarshalAs (UnmanagedType.I1)] bool allowsAntialiasing);
extern static void CGContextSetAllowsAntialiasing (/* CGContextRef */ IntPtr context, byte allowsAntialiasing);
public void SetAllowsAntialiasing (bool allowsAntialiasing)
{
CGContextSetAllowsAntialiasing (Handle, allowsAntialiasing);
CGContextSetAllowsAntialiasing (Handle, allowsAntialiasing.AsByte ());
}
[DllImport (Constants.CoreGraphicsLibrary)]
extern static void CGContextSetShouldSmoothFonts (/* CGContextRef */ IntPtr context, [MarshalAs (UnmanagedType.I1)] bool shouldSmoothFonts);
extern static void CGContextSetShouldSmoothFonts (/* CGContextRef */ IntPtr context, byte shouldSmoothFonts);
public void SetShouldSmoothFonts (bool shouldSmoothFonts)
{
CGContextSetShouldSmoothFonts (Handle, shouldSmoothFonts);
CGContextSetShouldSmoothFonts (Handle, shouldSmoothFonts.AsByte ());
}
[DllImport (Constants.CoreGraphicsLibrary)]
@ -1353,43 +1351,43 @@ namespace CoreGraphics {
}
[DllImport (Constants.CoreGraphicsLibrary)]
extern static void CGContextSetAllowsFontSmoothing (/* CGContextRef */ IntPtr context, [MarshalAs (UnmanagedType.I1)] bool shouldSubpixelPositionFonts);
extern static void CGContextSetAllowsFontSmoothing (/* CGContextRef */ IntPtr context, byte shouldSubpixelPositionFonts);
public void SetAllowsFontSmoothing (bool allows)
{
CGContextSetAllowsFontSmoothing (Handle, allows);
CGContextSetAllowsFontSmoothing (Handle, allows.AsByte ());
}
[DllImport (Constants.CoreGraphicsLibrary)]
extern static void CGContextSetAllowsFontSubpixelPositioning (/* CGContextRef */ IntPtr context, [MarshalAs (UnmanagedType.I1)] bool allowsFontSubpixelPositioning);
extern static void CGContextSetAllowsFontSubpixelPositioning (/* CGContextRef */ IntPtr context, byte allowsFontSubpixelPositioning);
public void SetAllowsSubpixelPositioning (bool allows)
{
CGContextSetAllowsFontSubpixelPositioning (Handle, allows);
CGContextSetAllowsFontSubpixelPositioning (Handle, allows.AsByte ());
}
[DllImport (Constants.CoreGraphicsLibrary)]
extern static void CGContextSetAllowsFontSubpixelQuantization (/* CGContextRef */ IntPtr context, [MarshalAs (UnmanagedType.I1)] bool shouldSubpixelQuantizeFonts);
extern static void CGContextSetAllowsFontSubpixelQuantization (/* CGContextRef */ IntPtr context, byte shouldSubpixelQuantizeFonts);
public void SetAllowsFontSubpixelQuantization (bool allows)
{
CGContextSetAllowsFontSubpixelQuantization (Handle, allows);
CGContextSetAllowsFontSubpixelQuantization (Handle, allows.AsByte ());
}
[DllImport (Constants.CoreGraphicsLibrary)]
extern static void CGContextSetShouldSubpixelPositionFonts (/* CGContextRef */ IntPtr context, [MarshalAs (UnmanagedType.I1)] bool shouldSubpixelPositionFonts);
extern static void CGContextSetShouldSubpixelPositionFonts (/* CGContextRef */ IntPtr context, byte shouldSubpixelPositionFonts);
public void SetShouldSubpixelPositionFonts (bool shouldSubpixelPositionFonts)
{
CGContextSetShouldSubpixelPositionFonts (Handle, shouldSubpixelPositionFonts);
CGContextSetShouldSubpixelPositionFonts (Handle, shouldSubpixelPositionFonts.AsByte ());
}
[DllImport (Constants.CoreGraphicsLibrary)]
extern static void CGContextSetShouldSubpixelQuantizeFonts (/* CGContextRef */ IntPtr context, [MarshalAs (UnmanagedType.I1)] bool shouldSubpixelQuantizeFonts);
extern static void CGContextSetShouldSubpixelQuantizeFonts (/* CGContextRef */ IntPtr context, byte shouldSubpixelQuantizeFonts);
public void ShouldSubpixelQuantizeFonts (bool shouldSubpixelQuantizeFonts)
{
CGContextSetShouldSubpixelQuantizeFonts (Handle, shouldSubpixelQuantizeFonts);
CGContextSetShouldSubpixelQuantizeFonts (Handle, shouldSubpixelQuantizeFonts.AsByte ());
}
[DllImport (Constants.CoreGraphicsLibrary)]

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

@ -0,0 +1,8 @@
namespace ObjCRuntime {
static class Extensions {
public static byte AsByte (this bool value)
{
return value ? (byte) 1 : (byte) 0;
}
}
}

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

@ -1932,6 +1932,7 @@ SHARED_CORE_SOURCES = \
ObjCRuntime/Constants.cs \
ObjCRuntime/DisposableObject.cs \
ObjCRuntime/ErrorConstants.cs \
ObjCRuntime/Extensions.cs \
ObjCRuntime/INativeObject.cs \
ObjCRuntime/LinkWithAttribute.cs \
ObjCRuntime/Messaging.cs \

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

@ -193,8 +193,6 @@ namespace Cecil.Tests {
"Security.SslStatus Security.SslContext::SSLSetSessionOption(System.IntPtr,Security.SslSessionOption,System.Boolean)",
"Security.SslStatus Security.SslContext::SSLWrite(System.IntPtr,System.Byte*,System.IntPtr,System.IntPtr&)",
"System.Boolean CoreGraphics.CGColor::CGColorEqualToColor(System.IntPtr,System.IntPtr)",
"System.Boolean CoreGraphics.CGContext::CGContextIsPathEmpty(System.IntPtr)",
"System.Boolean CoreGraphics.CGContext::CGContextPathContainsPoint(System.IntPtr,CoreGraphics.CGPoint,CoreGraphics.CGPathDrawingMode)",
"System.Boolean CoreGraphics.CGDisplay::CGDisplayIsCaptured(System.UInt32)",
"System.Boolean CoreGraphics.CGEvent::CGEventTapIsEnabled(System.IntPtr)",
"System.Boolean CoreGraphics.CGEvent::PreflightListenEventAccess()",
@ -449,14 +447,6 @@ namespace Cecil.Tests {
"System.IntPtr SystemConfiguration.NetworkReachability::SCNetworkReachabilityCreateWithAddressPair(System.IntPtr,System.IntPtr,SystemConfiguration.NetworkReachability/sockaddr_in&)",
"System.IntPtr SystemConfiguration.NetworkReachability::SCNetworkReachabilityCreateWithAddressPair(System.IntPtr,SystemConfiguration.NetworkReachability/sockaddr_in&,System.IntPtr)",
"System.IntPtr SystemConfiguration.NetworkReachability::SCNetworkReachabilityCreateWithAddressPair(System.IntPtr,SystemConfiguration.NetworkReachability/sockaddr_in&,SystemConfiguration.NetworkReachability/sockaddr_in&)",
"System.Void CoreGraphics.CGContext::CGContextSetAllowsAntialiasing(System.IntPtr,System.Boolean)",
"System.Void CoreGraphics.CGContext::CGContextSetAllowsFontSmoothing(System.IntPtr,System.Boolean)",
"System.Void CoreGraphics.CGContext::CGContextSetAllowsFontSubpixelPositioning(System.IntPtr,System.Boolean)",
"System.Void CoreGraphics.CGContext::CGContextSetAllowsFontSubpixelQuantization(System.IntPtr,System.Boolean)",
"System.Void CoreGraphics.CGContext::CGContextSetShouldAntialias(System.IntPtr,System.Boolean)",
"System.Void CoreGraphics.CGContext::CGContextSetShouldSmoothFonts(System.IntPtr,System.Boolean)",
"System.Void CoreGraphics.CGContext::CGContextSetShouldSubpixelPositionFonts(System.IntPtr,System.Boolean)",
"System.Void CoreGraphics.CGContext::CGContextSetShouldSubpixelQuantizeFonts(System.IntPtr,System.Boolean)",
"System.Void CoreGraphics.CGEvent::CGEventKeyboardGetUnicodeString(System.IntPtr,System.UIntPtr,System.UIntPtr&,System.Char*)",
"System.Void CoreGraphics.CGEvent::CGEventTapEnable(System.IntPtr,System.Boolean)",
"System.Void CoreGraphics.CGPath::CGPathAddArc(System.IntPtr,CoreGraphics.CGAffineTransform*,System.Runtime.InteropServices.NFloat,System.Runtime.InteropServices.NFloat,System.Runtime.InteropServices.NFloat,System.Runtime.InteropServices.NFloat,System.Runtime.InteropServices.NFloat,System.Boolean)",