From 954f2b1a82c19a942c3617bc6726aeaef87a112c Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Tue, 13 Aug 2024 20:19:45 +0200 Subject: [PATCH 1/2] [CoreGraphics] Implement Xcode 16.0 beta 1-5 changes. Note: there were no changes in beta 3 or beta 5. --- src/CoreGraphics/CGColorSpace.cs | 35 +++ src/CoreGraphics/CGContext.cs | 103 +++++++++ src/CoreGraphics/CGContextPDF.cs | 72 ++++++ src/CoreGraphics/CGEnums.cs | 2 + src/CoreGraphics/CGEventTypes.cs | 26 ++- src/CoreGraphics/CGImage.cs | 206 ++++++++++++++++++ src/coregraphics.cs | 68 ++++++ .../Documentation.KnownFailures.txt | 24 ++ .../CoreGraphics/CGImageTest.cs | 22 ++ .../CoreGraphics/ColorSpaceTest.cs | 10 + .../CoreGraphics/ContextTest.cs | 39 ++++ .../CoreGraphics/PDFContextTest.cs | 30 +++ .../MacCatalyst-CoreGraphics.ignore | 3 + .../MacCatalyst-CoreGraphics.todo | 29 --- .../iOS-CoreGraphics.todo | 23 -- .../macOS-CoreGraphics.todo | 29 --- .../tvOS-CoreGraphics.todo | 23 -- tests/xtro-sharpie/iOS-CoreGraphics.todo | 23 -- tests/xtro-sharpie/macOS-CoreGraphics.todo | 29 --- tests/xtro-sharpie/tvOS-CoreGraphics.todo | 23 -- tests/xtro-sharpie/watchOS-CoreGraphics.todo | 23 -- 21 files changed, 637 insertions(+), 205 deletions(-) delete mode 100644 tests/xtro-sharpie/api-annotations-dotnet/MacCatalyst-CoreGraphics.todo delete mode 100644 tests/xtro-sharpie/api-annotations-dotnet/iOS-CoreGraphics.todo delete mode 100644 tests/xtro-sharpie/api-annotations-dotnet/macOS-CoreGraphics.todo delete mode 100644 tests/xtro-sharpie/api-annotations-dotnet/tvOS-CoreGraphics.todo delete mode 100644 tests/xtro-sharpie/iOS-CoreGraphics.todo delete mode 100644 tests/xtro-sharpie/macOS-CoreGraphics.todo delete mode 100644 tests/xtro-sharpie/tvOS-CoreGraphics.todo delete mode 100644 tests/xtro-sharpie/watchOS-CoreGraphics.todo diff --git a/src/CoreGraphics/CGColorSpace.cs b/src/CoreGraphics/CGColorSpace.cs index 96ce4fa8b2ad..a24574b85095 100644 --- a/src/CoreGraphics/CGColorSpace.cs +++ b/src/CoreGraphics/CGColorSpace.cs @@ -1005,6 +1005,41 @@ public bool UsesExtendedRange { #endif public bool IsPQBased => CGColorSpaceIsPQBased (Handle) != 0; +#if NET + [SupportedOSPlatform ("macos15.0")] + [SupportedOSPlatform ("ios18.0")] + [SupportedOSPlatform ("tvos18.0")] + [SupportedOSPlatform ("maccatalyst18.0")] +#else + [Mac (15, 0)] + [iOS (18, 0)] + [TV (18, 0)] + [MacCatalyst (18, 0)] + [Watch (11, 0)] +#endif + [DllImport (Constants.CoreGraphicsLibrary)] + extern static /* CGColorSpaceRef */ IntPtr CGColorSpaceCopyBaseColorSpace (/* CGColorSpaceRef */ IntPtr space); + + /// Get the base color space, or a new color space without any image-specific metadata. + /// If the current color space is a pattern or an indexed color space, get the base color space. If the current color space contains image-specific metadata associated with the gain map, get a new color space without the metadata. Otherwise returns a null value. +#if NET + [SupportedOSPlatform ("macos15.0")] + [SupportedOSPlatform ("ios18.0")] + [SupportedOSPlatform ("tvos18.0")] + [SupportedOSPlatform ("maccatalyst18.0")] +#else + [Mac (15, 0)] + [iOS (18, 0)] + [TV (18, 0)] + [MacCatalyst (18, 0)] + [Watch (11, 0)] +#endif + public CGColorSpace? CopyBaseColorSpace () + { + var h = CGColorSpaceCopyBaseColorSpace (Handle); + return FromHandle (h, true); + } + #endif // !COREBUILD } diff --git a/src/CoreGraphics/CGContext.cs b/src/CoreGraphics/CGContext.cs index a9e647bb2d60..5d35a01e0cf0 100644 --- a/src/CoreGraphics/CGContext.cs +++ b/src/CoreGraphics/CGContext.cs @@ -1433,6 +1433,109 @@ public CGBitmapContext AsBitmapContext () public void DrawConicGradient (CGGradient? gradient, CGPoint point, nfloat angle) => CGContextDrawConicGradient (Handle, gradient.GetHandle (), point, angle); +#if NET + [SupportedOSPlatform ("ios18.0")] + [SupportedOSPlatform ("maccatalyst18.0")] + [SupportedOSPlatform ("macos15.0")] + [SupportedOSPlatform ("tvos18.0")] +#else + [Watch (11, 0), TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)] +#endif + [DllImport (Constants.CoreGraphicsLibrary)] + static extern byte CGContextSetEDRTargetHeadroom (/* CGContextRef __nonnull */ IntPtr context, /* float */ float headroom); + +#if NET + [SupportedOSPlatform ("ios18.0")] + [SupportedOSPlatform ("maccatalyst18.0")] + [SupportedOSPlatform ("macos15.0")] + [SupportedOSPlatform ("tvos18.0")] +#else + [Watch (11, 0), TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)] +#endif + [DllImport (Constants.CoreGraphicsLibrary)] + static extern float CGContextGetEDRTargetHeadroom (/* CGContextRef __nonnull */ IntPtr context); + + /// Get the EDR headroom that's used when rendering HDR content. + /// The EDR headroom. +#if NET + [SupportedOSPlatform ("ios18.0")] + [SupportedOSPlatform ("maccatalyst18.0")] + [SupportedOSPlatform ("macos15.0")] + [SupportedOSPlatform ("tvos18.0")] +#else + [Watch (11, 0), TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)] +#endif + public float GetEdrTargetHeadroom () + { + return CGContextGetEDRTargetHeadroom (Handle); + } + + /// Get the EDR headroom that's used when rendering HDR content. + /// The value to set. Must be greater than 1.0f. + /// Returns true if successful, false otherwise. +#if NET + [SupportedOSPlatform ("ios18.0")] + [SupportedOSPlatform ("maccatalyst18.0")] + [SupportedOSPlatform ("macos15.0")] + [SupportedOSPlatform ("tvos18.0")] +#else + [Watch (11, 0), TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)] +#endif + public bool SetEdrTargetHeadroom (float value) + { + return CGContextSetEDRTargetHeadroom (Handle, value) != 0; + } + +#if NET + [SupportedOSPlatform ("ios18.0")] + [SupportedOSPlatform ("maccatalyst18.0")] + [SupportedOSPlatform ("macos15.0")] + [SupportedOSPlatform ("tvos18.0")] +#else + [Watch (11, 0), TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)] +#endif + [DllImport (Constants.CoreGraphicsLibrary)] + static extern /* bool */ byte CGContextDrawImageApplyingToneMapping (/* CGContextRef __nonnull */ IntPtr context, CGRect r, /* CGImageRef */ IntPtr image, CGToneMapping method, /* CFDictionaryRef __nullable */ IntPtr options); + + /// Draw the specified image onto the CGContext, applying the tone mapping and any tone mapping options. + /// The rectangle where the image is rendered. + /// The image to render. + /// The tone mapping method to use. + /// The tone mapping options to use. + /// Returns true if successful, otherwise false. +#if NET + [SupportedOSPlatform ("ios18.0")] + [SupportedOSPlatform ("maccatalyst18.0")] + [SupportedOSPlatform ("macos15.0")] + [SupportedOSPlatform ("tvos18.0")] +#else + [Watch (11, 0), TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)] +#endif + public bool DrawImageApplyingToneMapping (CGRect rect, CGImage image, CGToneMapping method, NSDictionary? options) + { + var rv = CGContextDrawImageApplyingToneMapping (Handle, rect, image.Handle, method, options.GetHandle ()); + return rv != 0; + } + + /// Draw the specified image onto the CGContext, applying the tone mapping and any tone mapping options. + /// The rectangle where the image is rendered. + /// The image to render. + /// The tone mapping method to use. + /// The tone mapping options to use. + /// Returns true if successful, otherwise false. +#if NET + [SupportedOSPlatform ("ios18.0")] + [SupportedOSPlatform ("maccatalyst18.0")] + [SupportedOSPlatform ("macos15.0")] + [SupportedOSPlatform ("tvos18.0")] +#else + [Watch (11, 0), TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)] +#endif + public bool DrawImageApplyingToneMapping (CGRect rect, CGImage image, CGToneMapping method, CGToneMappingOptions? options) + { + var rv = CGContextDrawImageApplyingToneMapping (Handle, rect, image.Handle, method, options?.Dictionary?.GetHandle () ?? IntPtr.Zero); + return rv != 0; + } #endif // !COREBUILD } } diff --git a/src/CoreGraphics/CGContextPDF.cs b/src/CoreGraphics/CGContextPDF.cs index a4e21f80c096..1ed74f260c40 100644 --- a/src/CoreGraphics/CGContextPDF.cs +++ b/src/CoreGraphics/CGContextPDF.cs @@ -378,6 +378,78 @@ public void EndTag () CGPDFContextEndTag (Handle); } +#if NET + [SupportedOSPlatform ("ios18.0")] + [SupportedOSPlatform ("maccatalyst18.0")] + [SupportedOSPlatform ("macos15.0")] + [SupportedOSPlatform ("tvos18.0")] +#else + [Watch (11, 0), TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)] +#endif + [DllImport (Constants.CoreGraphicsLibrary)] + static extern void CGPDFContextSetParentTree (/* CGContextRef cg_nullable */ IntPtr context, /* CGPDFDictionaryRef */ IntPtr parentTreeDictionary); + +#if NET + [SupportedOSPlatform ("ios18.0")] + [SupportedOSPlatform ("maccatalyst18.0")] + [SupportedOSPlatform ("macos15.0")] + [SupportedOSPlatform ("tvos18.0")] +#else + [Watch (11, 0), TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)] +#endif + public void SetParentTree (CGPDFDictionary parentTreeDictionary) + { + CGPDFContextSetParentTree (GetCheckedHandle (), parentTreeDictionary.GetNonNullHandle (nameof (parentTreeDictionary))); + } + +#if NET + [SupportedOSPlatform ("ios18.0")] + [SupportedOSPlatform ("maccatalyst18.0")] + [SupportedOSPlatform ("macos15.0")] + [SupportedOSPlatform ("tvos18.0")] +#else + [Watch (11, 0), TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)] +#endif + [DllImport (Constants.CoreGraphicsLibrary)] + static extern void CGPDFContextSetIDTree (/* CGContextRef cg_nullable */ IntPtr context, /* CGPDFDictionaryRef */ IntPtr IDTreeDictionary); + +#if NET + [SupportedOSPlatform ("ios18.0")] + [SupportedOSPlatform ("maccatalyst18.0")] + [SupportedOSPlatform ("macos15.0")] + [SupportedOSPlatform ("tvos18.0")] +#else + [Watch (11, 0), TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)] +#endif + public void SetIdTree (CGPDFDictionary idTreeDictionary) + { + CGPDFContextSetIDTree (GetCheckedHandle (), idTreeDictionary.GetNonNullHandle (nameof (idTreeDictionary))); + } + +#if NET + [SupportedOSPlatform ("ios18.0")] + [SupportedOSPlatform ("maccatalyst18.0")] + [SupportedOSPlatform ("macos15.0")] + [SupportedOSPlatform ("tvos18.0")] +#else + [Watch (11, 0), TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)] +#endif + [DllImport (Constants.CoreGraphicsLibrary)] + static extern void CGPDFContextSetPageTagStructureTree (/* CGContextRef cg_nullable */ IntPtr context, /* CFDictionaryRef */ IntPtr pageTagStructureTreeDictionary); + +#if NET + [SupportedOSPlatform ("ios18.0")] + [SupportedOSPlatform ("maccatalyst18.0")] + [SupportedOSPlatform ("macos15.0")] + [SupportedOSPlatform ("tvos18.0")] +#else + [Watch (11, 0), TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)] +#endif + public void SetPageTagStructureTree (NSDictionary pageTagStructureTreeDictionary) + { + CGPDFContextSetPageTagStructureTree (GetCheckedHandle (), pageTagStructureTreeDictionary.GetNonNullHandle (nameof (pageTagStructureTreeDictionary))); + } + protected override void Dispose (bool disposing) { if (disposing) diff --git a/src/CoreGraphics/CGEnums.cs b/src/CoreGraphics/CGEnums.cs index d5fdeca99f3d..7a3768b19a1f 100644 --- a/src/CoreGraphics/CGEnums.cs +++ b/src/CoreGraphics/CGEnums.cs @@ -168,6 +168,8 @@ public enum CGPdfTagType /* int32_t */ { Figure = 700, Formula, Form, + [NoWatch, TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)] + Object = 800, } // untyped enum -> CGPDFObject.h diff --git a/src/CoreGraphics/CGEventTypes.cs b/src/CoreGraphics/CGEventTypes.cs index 0feaf9b63189..6b11c06a8997 100644 --- a/src/CoreGraphics/CGEventTypes.cs +++ b/src/CoreGraphics/CGEventTypes.cs @@ -358,15 +358,15 @@ public enum CGEventField : int { EventWindowUnderMousePointerThatCanHandleThisEvent = 92, // no documentation for this value in the header file. - /// A value that represnets the scroll wheel's scroll phase. + /// A value that represents the scroll wheel's scroll phase. ScrollWheelEventScrollPhase = 99, // no documentation for this value in the header file. - /// A value that represnets the scroll wheel's scroll count. + /// A value that represents the scroll wheel's scroll count. ScrollWheelEventScrollCount = 100, // no documentation for this value in the header file. - /// A value that represnets the scroll wheel's scroll momentum. + /// A value that represents the scroll wheel's scroll momentum. ScrollWheelEventMomentumPhase = 123, // the header file doesn't say whether this is an integer or a double @@ -376,6 +376,26 @@ public enum CGEventField : int { // the header file doesn't say whether this is an integer or a double /// The unaccelerated pointer movement for the Y axis. EventUnacceleratedPointerMovementY = 171, + + // no documentation for this value in the header file. + /// A value that represents the scroll wheel's scroll momentum. + ScrollWheelEventMomentumOptionPhase = 173, + + // no documentation for this value in the header file. + /// A value that represents the accelerated delta value for axis 1. + ScrollWheelEventAcceleratedDeltaAxis1 = 176, + + // no documentation for this value in the header file. + /// A value that represents the accelerated delta value for axis 2. + ScrollWheelEventAcceleratedDeltaAxis2 = 175, + + // no documentation for this value in the header file. + /// A value that represents the raw delta value for axis 1. + ScrollWheelEventRawDeltaAxis1 = 178, + + // no documentation for this value in the header file. + /// A value that represents the raw delta value for axis 2. + ScrollWheelEventRawDeltaAxis2 = 177 } // CGEventTypes.h:typedef uint32_t CGEventType; diff --git a/src/CoreGraphics/CGImage.cs b/src/CoreGraphics/CGImage.cs index 033b8c4e1915..b6642ab52890 100644 --- a/src/CoreGraphics/CGImage.cs +++ b/src/CoreGraphics/CGImage.cs @@ -253,19 +253,25 @@ public CGImage (int width, int height, int bitsPerComponent, int bitsPerPixel, i #if MONOMAC || __MACCATALYST__ #if NET [SupportedOSPlatform ("maccatalyst")] + [ObsoletedOSPlatform ("maccatalyst18.0", "Use ScreenCaptureKit instead.")] [UnsupportedOSPlatform ("ios")] [SupportedOSPlatform ("macos")] + [ObsoletedOSPlatform ("macos15.0", "Use ScreenCaptureKit instead.")] [UnsupportedOSPlatform ("tvos")] #else [MacCatalyst (13,1)] + [Deprecated (PlatformName.MacCatalyst, 17, 0, message: "Use ScreenCaptureKit instead.")] + [Deprecated (PlatformName.MacOSX, 14, 0, message: "Use ScreenCaptureKit instead.")] #endif [DllImport (Constants.CoreGraphicsLibrary)] static extern IntPtr CGWindowListCreateImage(CGRect screenBounds, CGWindowListOption windowOption, uint windowID, CGWindowImageOption imageOption); #if NET [SupportedOSPlatform ("maccatalyst")] + [ObsoletedOSPlatform ("maccatalyst18.0", "Use ScreenCaptureKit instead.")] [UnsupportedOSPlatform ("ios")] [SupportedOSPlatform ("macos")] + [ObsoletedOSPlatform ("macos15.0", "Use ScreenCaptureKit instead.")] [UnsupportedOSPlatform ("tvos")] #else [MacCatalyst (13,1)] @@ -277,11 +283,15 @@ public CGImage (int width, int height, int bitsPerComponent, int bitsPerPixel, i #if NET [SupportedOSPlatform ("maccatalyst")] + [ObsoletedOSPlatform ("maccatalyst18.0", "Use ScreenCaptureKit instead.")] [UnsupportedOSPlatform ("ios")] [SupportedOSPlatform ("macos")] + [ObsoletedOSPlatform ("macos15.0", "Use ScreenCaptureKit instead.")] [UnsupportedOSPlatform ("tvos")] #else [MacCatalyst (13,1)] + [Deprecated (PlatformName.MacCatalyst, 18, 0, message: "Use ScreenCaptureKit instead.")] + [Deprecated (PlatformName.MacOSX, 15, 0, message: "Use ScreenCaptureKit instead.")] #endif public static CGImage? ScreenImage (int windownumber, CGRect bounds, CGWindowListOption windowOption, CGWindowImageOption imageOption) @@ -596,6 +606,202 @@ public NSString? UTType { #endif public CGImageByteOrderInfo ByteOrderInfo => CGImageGetByteOrderInfo (Handle); +#if NET + [SupportedOSPlatform ("ios18.0")] + [SupportedOSPlatform ("maccatalyst18.0")] + [SupportedOSPlatform ("macos15.0")] + [SupportedOSPlatform ("tvos18.0")] +#else + [Watch (11, 0), TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)] +#endif + [DllImport (Constants.CoreGraphicsLibrary)] + unsafe static extern /* CGImageRef __nullable */ IntPtr CGImageCreateWithContentHeadroom ( + /* float */ float headroom, + /* size_t */ nint width, + /* size_t */ nint height, + /* size_t */ nint bitsPerComponent, + /* size_t */ nint bitsPerPixel, + /* size_t */ nint bytesPerRow, + /* CGColorSpaceRef cg_nullable */ IntPtr space, + /* CGBitmapInfo */ CGBitmapFlags bitmapInfo, + /* CGDataProviderRef cg_nullable */ IntPtr provider, + /* const CGFloat * __nullable */ nfloat* decode, + /* bool */ byte shouldInterpolate, + /* CGColorRenderingIntent */ CGColorRenderingIntent intent); + + /// Create a new CGImage instance with the specified content headroom. + /// The content headroom. Must be either 0.0f or greater than or equal to 1.0f. + /// The width of the new image. + /// The height of the new image. + /// Bits per component for the new image. + /// Bits per pixel for the new image. + /// Bytes per row for the new image. + /// The colorspace for the new image. + /// The bitmap flags for the new image. + /// The data provider for the new image. + /// The decode array for the new image. + /// Whether image is interpolated or not. + /// The rendering intent for the new image. + /// A new CGImage instance. +#if NET + [SupportedOSPlatform ("ios18.0")] + [SupportedOSPlatform ("maccatalyst18.0")] + [SupportedOSPlatform ("macos15.0")] + [SupportedOSPlatform ("tvos18.0")] +#else + [Watch (11, 0), TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)] +#endif + public CGImage (float headroom, int width, int height, int bitsPerComponent, int bitsPerPixel, int bytesPerRow, + CGColorSpace? colorSpace, CGBitmapFlags bitmapFlags, CGDataProvider? provider, + nfloat []? decode, bool shouldInterpolate, CGColorRenderingIntent intent) + : base (Create (headroom, width, height, bitsPerComponent, bitsPerPixel, bytesPerRow, colorSpace, bitmapFlags, provider, decode, shouldInterpolate, intent), true) + { + } + +#if NET + [SupportedOSPlatform ("ios18.0")] + [SupportedOSPlatform ("maccatalyst18.0")] + [SupportedOSPlatform ("macos15.0")] + [SupportedOSPlatform ("tvos18.0")] +#else + [Watch (11, 0), TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)] +#endif + static IntPtr Create (float headroom, int width, int height, int bitsPerComponent, int bitsPerPixel, int bytesPerRow, + CGColorSpace? colorSpace, CGBitmapFlags bitmapFlags, CGDataProvider? provider, + nfloat []? decode, bool shouldInterpolate, CGColorRenderingIntent intent) + { + if (headroom != 0.0f && headroom < 1.0f) + throw new ArgumentException (nameof (headroom)); + if (width < 0) + throw new ArgumentException (nameof (width)); + if (height < 0) + throw new ArgumentException (nameof (height)); + if (bitsPerPixel < 0) + throw new ArgumentException (nameof (bitsPerPixel)); + if (bitsPerComponent < 0) + throw new ArgumentException (nameof (bitsPerComponent)); + if (bytesPerRow < 0) + throw new ArgumentException (nameof (bytesPerRow)); + + unsafe { + fixed (nfloat* decodePtr = decode) { + return CGImageCreateWithContentHeadroom (headroom, width, height, bitsPerComponent, bitsPerPixel, bytesPerRow, + colorSpace.GetHandle (), bitmapFlags, provider.GetHandle (), + decodePtr, shouldInterpolate.AsByte (), intent); + } + } + } + +#if NET + [SupportedOSPlatform ("ios18.0")] + [SupportedOSPlatform ("maccatalyst18.0")] + [SupportedOSPlatform ("macos15.0")] + [SupportedOSPlatform ("tvos18.0")] +#else + [Watch (11, 0), TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)] +#endif + [DllImport (Constants.CoreGraphicsLibrary)] + unsafe static extern /* CGImageRef __nullable */ IntPtr CGImageCreateCopyWithContentHeadroom ( + /* float */ float headroom, + /* CGImageRef cg_nullable */ IntPtr image); + + /// Create a copy of the current image, adding or replacing the current image's headroom. + /// Must be either equal to 0 or greater or equal to 1.0. +#if NET + [SupportedOSPlatform ("ios18.0")] + [SupportedOSPlatform ("maccatalyst18.0")] + [SupportedOSPlatform ("macos15.0")] + [SupportedOSPlatform ("tvos18.0")] +#else + [Watch (11, 0), TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)] +#endif + public CGImage? Copy (float headroom) + { + if (headroom != 0.0f && headroom < 1.0f) + throw new ArgumentException (nameof (headroom)); + + var rv = CGImageCreateCopyWithContentHeadroom (headroom, GetCheckedHandle ()); + return Runtime.GetINativeObject (rv, owns: true); + } + + /// Get the default content headroom for HDR images. +#if NET + [SupportedOSPlatform ("ios18.0")] + [SupportedOSPlatform ("maccatalyst18.0")] + [SupportedOSPlatform ("macos15.0")] + [SupportedOSPlatform ("tvos18.0")] +#else + [Watch (11, 0), TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)] +#endif + public static float DefaultHdrImageContentHeadroom { + get => CoreGraphicsFields.DefaultHdrImageContentHeadroom; + } + +#if NET + [SupportedOSPlatform ("ios18.0")] + [SupportedOSPlatform ("maccatalyst18.0")] + [SupportedOSPlatform ("macos15.0")] + [SupportedOSPlatform ("tvos18.0")] +#else + [Watch (11, 0), TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)] +#endif + [DllImport (Constants.CoreGraphicsLibrary)] + static extern float CGImageGetContentHeadroom (/* __nullable CGImageRef */ IntPtr handle); + + /// Get the content headroom for this image. +#if NET + [SupportedOSPlatform ("ios18.0")] + [SupportedOSPlatform ("maccatalyst18.0")] + [SupportedOSPlatform ("macos15.0")] + [SupportedOSPlatform ("tvos18.0")] +#else + [Watch (11, 0), TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)] +#endif + public float ContentHeadroom => CGImageGetContentHeadroom (Handle); + +#if NET + [SupportedOSPlatform ("ios18.0")] + [SupportedOSPlatform ("maccatalyst18.0")] + [SupportedOSPlatform ("macos15.0")] + [SupportedOSPlatform ("tvos18.0")] +#else + [Watch (11, 0), TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)] +#endif + [DllImport (Constants.CoreGraphicsLibrary)] + static extern /* bool */ byte CGImageShouldToneMap (/* __nullable CGImageRef */ IntPtr handle); + + /// Get whether this image should be tone mapped when rendered. +#if NET + [SupportedOSPlatform ("ios18.0")] + [SupportedOSPlatform ("maccatalyst18.0")] + [SupportedOSPlatform ("macos15.0")] + [SupportedOSPlatform ("tvos18.0")] +#else + [Watch (11, 0), TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)] +#endif + public bool ShouldToneMap => CGImageShouldToneMap (Handle) != 0; + +#if NET + [SupportedOSPlatform ("ios18.0")] + [SupportedOSPlatform ("maccatalyst18.0")] + [SupportedOSPlatform ("macos15.0")] + [SupportedOSPlatform ("tvos18.0")] +#else + [Watch (11, 0), TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)] +#endif + [DllImport (Constants.CoreGraphicsLibrary)] + static extern /* bool */ byte CGImageContainsImageSpecificToneMappingMetadata (/* __nullable CGImageRef */ IntPtr handle); + + /// Get whether this image has image-specific tone mapping metadata. +#if NET + [SupportedOSPlatform ("ios18.0")] + [SupportedOSPlatform ("maccatalyst18.0")] + [SupportedOSPlatform ("macos15.0")] + [SupportedOSPlatform ("tvos18.0")] +#else + [Watch (11, 0), TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)] +#endif + public bool ContainsImageSpecificToneMappingMetadata => CGImageContainsImageSpecificToneMappingMetadata (Handle) != 0; #endif // !COREBUILD } } diff --git a/src/coregraphics.cs b/src/coregraphics.cs index 2c643830b8ad..035bf66d28ae 100644 --- a/src/coregraphics.cs +++ b/src/coregraphics.cs @@ -10,6 +10,16 @@ namespace CoreGraphics { + [Watch (11, 0), TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)] + enum CGToneMapping : uint { + Default = 0, + ImageSpecificLumaScaling, + ReferenceWhiteBased, + IturRecommended, + ExrGamma, + None, + } + /// Specifies various boxes for the method. [Partial] interface CGPDFPageInfo { @@ -358,6 +368,10 @@ interface CGColorSpaceNames { [Mac (12, 0), iOS (15, 0), TV (15, 0), Watch (8, 0), MacCatalyst (15, 0)] [Field ("kCGColorSpaceLinearITUR_2020")] NSString LinearItur_2020 { get; } + + [Mac (15, 0), iOS (18, 0), TV (18, 0), Watch (11, 0), MacCatalyst (18, 0)] + [Field ("kCGColorSpaceCoreMedia709")] + NSString CoreMedia709 { get; } } [Partial] @@ -464,6 +478,8 @@ enum CGConstantColor { // Adding suffix *Keys to avoid possible name clash [NoiOS, NoTV, NoWatch, MacCatalyst (13, 1)] [Static] + [Deprecated (PlatformName.MacOSX, 15, 0, message: "Use ScreenCaptureKit instead.")] + [Deprecated (PlatformName.MacCatalyst, 18, 0, message: "Use ScreenCaptureKit instead.")] interface CGDisplayStreamKeys { [Field ("kCGDisplayStreamColorSpace")] @@ -504,4 +520,56 @@ interface CGDisplayStreamYCbCrMatrixOptionKeys { [Field ("kCGDisplayStreamYCbCrMatrix_SMPTE_240M_1995")] NSString Smpte_240M_1995 { get; } } + + [Watch (11, 0), TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)] + [Partial] + partial interface CGToneMappingOptionKeys { + [Internal] + [Field ("kCGUse100nitsHLGOOTF")] + NSString Use100nitsHlgOotfKey { get; } + + [Internal] + [Field ("kCGUseBT1886ForCoreVideoGamma")] + NSString UseBT1886ForCoreVideoGammaKey { get; } + + [Internal] + [Field ("kCGSkipBoostToHDR")] + NSString SkipBoostToHdrKey { get; } + + [Internal] + [Field ("kCGEXRToneMappingGammaDefog")] + NSString ExrToneMappingGammaDefogKey { get; } + + [Internal] + [Field ("kCGEXRToneMappingGammaExposure")] + NSString ExrToneMappingGammaExposureKey { get; } + + [Internal] + [Field ("kCGEXRToneMappingGammaKneeLow")] + NSString ExrToneMappingGammaKneeLowKey { get; } + + [Internal] + [Field ("kCGEXRToneMappingGammaKneeHigh")] + NSString ExrToneMappingGammaKneeHighKey { get; } + } + + [Watch (11, 0), TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)] + [StrongDictionary ("CGToneMappingOptionKeys")] + interface CGToneMappingOptions { + bool Use100nitsHlgOotf { get; set; } + bool UseBT1886ForCoreVideoGamma { get; set; } + bool SkipBoostToHdr { get; set; } + float ExrToneMappingGammaDefog { get; set; } + float ExrToneMappingGammaExposure { get; set; } + float ExrToneMappingGammaKneeLow { get; set; } + float ExrToneMappingGammaKneeHigh { get; set; } + } + + [Watch (11, 0), TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)] + [Partial] + [Internal] + interface CoreGraphicsFields { + [Field ("kCGDefaultHDRImageContentHeadroom")] + float DefaultHdrImageContentHeadroom { get; } + } } diff --git a/tests/cecil-tests/Documentation.KnownFailures.txt b/tests/cecil-tests/Documentation.KnownFailures.txt index 154ff1611f76..440811cbb3a1 100644 --- a/tests/cecil-tests/Documentation.KnownFailures.txt +++ b/tests/cecil-tests/Documentation.KnownFailures.txt @@ -6895,6 +6895,7 @@ F:CoreGraphics.CGPdfTagType.ListBody F:CoreGraphics.CGPdfTagType.ListItem F:CoreGraphics.CGPdfTagType.NonStructure F:CoreGraphics.CGPdfTagType.Note +F:CoreGraphics.CGPdfTagType.Object F:CoreGraphics.CGPdfTagType.Paragraph F:CoreGraphics.CGPdfTagType.Part F:CoreGraphics.CGPdfTagType.Private @@ -6937,6 +6938,12 @@ F:CoreGraphics.CGTextDrawingMode.Stroke F:CoreGraphics.CGTextDrawingMode.StrokeClip F:CoreGraphics.CGTextEncoding.FontSpecific F:CoreGraphics.CGTextEncoding.MacRoman +F:CoreGraphics.CGToneMapping.Default +F:CoreGraphics.CGToneMapping.ExrGamma +F:CoreGraphics.CGToneMapping.ImageSpecificLumaScaling +F:CoreGraphics.CGToneMapping.IturRecommended +F:CoreGraphics.CGToneMapping.None +F:CoreGraphics.CGToneMapping.ReferenceWhiteBased F:CoreGraphics.CGVector.dx F:CoreGraphics.CGVector.dy F:CoreGraphics.CGWindowImageOption.BestResolution @@ -30003,6 +30010,9 @@ M:CoreGraphics.CGContextPDF.Dispose(System.Boolean) M:CoreGraphics.CGContextPDF.EndPage M:CoreGraphics.CGContextPDF.EndTag M:CoreGraphics.CGContextPDF.SetDestination(System.String,CoreGraphics.CGRect) +M:CoreGraphics.CGContextPDF.SetIdTree(CoreGraphics.CGPDFDictionary) +M:CoreGraphics.CGContextPDF.SetPageTagStructureTree(Foundation.NSDictionary) +M:CoreGraphics.CGContextPDF.SetParentTree(CoreGraphics.CGPDFDictionary) M:CoreGraphics.CGContextPDF.SetUrl(Foundation.NSUrl,CoreGraphics.CGRect) M:CoreGraphics.CGDataConsumer.#ctor(Foundation.NSMutableData) M:CoreGraphics.CGDataConsumer.#ctor(Foundation.NSUrl) @@ -30374,6 +30384,9 @@ M:CoreGraphics.CGSize.ToDictionary M:CoreGraphics.CGSize.ToRoundedCGSize M:CoreGraphics.CGSize.ToString M:CoreGraphics.CGSize.TryParse(Foundation.NSDictionary,CoreGraphics.CGSize@) +M:CoreGraphics.CGToneMappingOptionKeys.#ctor +M:CoreGraphics.CGToneMappingOptions.#ctor +M:CoreGraphics.CGToneMappingOptions.#ctor(Foundation.NSDictionary) M:CoreGraphics.CGVector.#ctor(System.Runtime.InteropServices.NFloat,System.Runtime.InteropServices.NFloat) M:CoreGraphics.CGVector.Equals(System.Object) M:CoreGraphics.CGVector.FromString(System.String) @@ -60135,6 +60148,7 @@ P:CoreGraphics.CGColorSpace.UsesExtendedRange P:CoreGraphics.CGColorSpace.UsesItur2100TF P:CoreGraphics.CGColorSpaceNames.AcesCGLinear P:CoreGraphics.CGColorSpaceNames.AdobeRgb1998 +P:CoreGraphics.CGColorSpaceNames.CoreMedia709 P:CoreGraphics.CGColorSpaceNames.Dcip3 P:CoreGraphics.CGColorSpaceNames.DisplayP3 P:CoreGraphics.CGColorSpaceNames.DisplayP3_Hlg @@ -60360,6 +60374,13 @@ P:CoreGraphics.CGRect.Y P:CoreGraphics.CGSize.Height P:CoreGraphics.CGSize.IsEmpty P:CoreGraphics.CGSize.Width +P:CoreGraphics.CGToneMappingOptions.ExrToneMappingGammaDefog +P:CoreGraphics.CGToneMappingOptions.ExrToneMappingGammaExposure +P:CoreGraphics.CGToneMappingOptions.ExrToneMappingGammaKneeHigh +P:CoreGraphics.CGToneMappingOptions.ExrToneMappingGammaKneeLow +P:CoreGraphics.CGToneMappingOptions.SkipBoostToHdr +P:CoreGraphics.CGToneMappingOptions.Use100nitsHlgOotf +P:CoreGraphics.CGToneMappingOptions.UseBT1886ForCoreVideoGamma P:CoreGraphics.NMatrix2.Determinant P:CoreGraphics.NMatrix2.Identity P:CoreGraphics.NMatrix3.Determinant @@ -78809,6 +78830,9 @@ T:CoreGraphics.CGRectExtensions T:CoreGraphics.CGScrollEventUnit T:CoreGraphics.CGShading T:CoreGraphics.CGSize +T:CoreGraphics.CGToneMapping +T:CoreGraphics.CGToneMappingOptionKeys +T:CoreGraphics.CGToneMappingOptions T:CoreGraphics.CGVector T:CoreGraphics.CGWindowImageOption T:CoreGraphics.CGWindowListOption diff --git a/tests/monotouch-test/CoreGraphics/CGImageTest.cs b/tests/monotouch-test/CoreGraphics/CGImageTest.cs index c52c3478669b..5cbf9b644d46 100644 --- a/tests/monotouch-test/CoreGraphics/CGImageTest.cs +++ b/tests/monotouch-test/CoreGraphics/CGImageTest.cs @@ -41,5 +41,27 @@ public void FromPNG () Assert.That (img.UTType.ToString (), Is.EqualTo ("public.png"), "UTType"); } } + + [Test] + public void Xcode16APIs () + { + TestRuntime.AssertXcodeVersion (16, 0); + + var file = Path.Combine (NSBundle.MainBundle.ResourcePath, "basn3p08.png"); + using var dp = new CGDataProvider (file); + using var img = new CGImage (2.0f, 20, 20, 8, 32, 80, null, CGBitmapFlags.None, dp, null, false, CGColorRenderingIntent.Default); + Assert.IsNotNull (img, "Image"); + Assert.AreEqual (0.0f, img.ContentHeadroom, "ContentHeadroom A"); + Assert.IsFalse (img.ShouldToneMap, "ShouldToneMap A"); + Assert.IsFalse (img.ContainsImageSpecificToneMappingMetadata, "ContainsImageSpecificToneMappingMetadata A"); + + using var copy = img.Copy (3.0f); + Assert.IsNotNull (copy, "Copy"); + Assert.AreEqual (3.0f, copy.ContentHeadroom, "ContentHeadroom B"); + Assert.IsFalse (copy.ShouldToneMap, "ShouldToneMap B"); + Assert.IsFalse (copy.ContainsImageSpecificToneMappingMetadata, "ContainsImageSpecificToneMappingMetadata B"); + + Assert.AreEqual (2.0f, CGImage.DefaultHdrImageContentHeadroom, "DefaultHdrImageContentHeadroom"); + } } } diff --git a/tests/monotouch-test/CoreGraphics/ColorSpaceTest.cs b/tests/monotouch-test/CoreGraphics/ColorSpaceTest.cs index 425bd9ab5b66..63019ca03b3e 100644 --- a/tests/monotouch-test/CoreGraphics/ColorSpaceTest.cs +++ b/tests/monotouch-test/CoreGraphics/ColorSpaceTest.cs @@ -506,6 +506,16 @@ public void IsPQBasedTest () }); } } + + [Test] + public void CopyBaseColorSpace () + { + TestRuntime.AssertXcodeVersion (16, 0); + using (var cs = CGColorSpace.CreateDeviceRGB ()) { + using var cbcs = cs.CopyBaseColorSpace (); + Assert.IsNull (cbcs, "CopyBaseColorSpace"); + } + } } } diff --git a/tests/monotouch-test/CoreGraphics/ContextTest.cs b/tests/monotouch-test/CoreGraphics/ContextTest.cs index c92586704623..cf1b25268603 100644 --- a/tests/monotouch-test/CoreGraphics/ContextTest.cs +++ b/tests/monotouch-test/CoreGraphics/ContextTest.cs @@ -8,6 +8,8 @@ // using System; +using System.IO; + using Foundation; using CoreGraphics; using ObjCRuntime; @@ -55,5 +57,42 @@ public void ResetClip () Assert.That (original, Is.EqualTo (c.GetClipBoundingBox ())); } } + + [Test] + public void EdrHeadroom () + { + TestRuntime.AssertXcodeVersion (16, 0); + + using var context = Create (); + Assert.AreEqual (0.0f, context.GetEdrTargetHeadroom (), "a"); + Assert.IsTrue (context.SetEdrTargetHeadroom (2.0f), "b"); + Assert.AreEqual (2.0f, context.GetEdrTargetHeadroom (), "c"); + Assert.IsFalse (context.SetEdrTargetHeadroom (0.0f), "d"); + Assert.AreEqual (2.0f, context.GetEdrTargetHeadroom (), "e"); + } + + [Test] + public void DrawImageApplyingToneMapping () + { + TestRuntime.AssertXcodeVersion (16, 0); + + var imageFile = Path.Combine (NSBundle.MainBundle.ResourcePath, "basn3p08.png"); + using var dp = new CGDataProvider (imageFile); + using var img = CGImage.FromPNG (dp, null, false, CGColorRenderingIntent.Default); + var mapping = new CGToneMappingOptions () { Use100nitsHlgOotf = true, ExrToneMappingGammaExposure = 3.14f }; + + using (var context = Create ()) { + Assert.IsFalse (context.DrawImageApplyingToneMapping (new CGRect (0, 0, 10, 10), img, CGToneMapping.IturRecommended, (NSDictionary?) null), "DrawImageApplyingToneMapping A"); + } + + using (var context = Create ()) { + Assert.IsFalse (context.DrawImageApplyingToneMapping (new CGRect (0, 0, 10, 10), img, CGToneMapping.IturRecommended, mapping), "DrawImageApplyingToneMapping B"); + } + + using (var context = Create ()) { + Assert.IsFalse (context.DrawImageApplyingToneMapping (new CGRect (0, 0, 10, 10), img, CGToneMapping.IturRecommended, mapping.Dictionary), "DrawImageApplyingToneMapping C"); + } + + } } } diff --git a/tests/monotouch-test/CoreGraphics/PDFContextTest.cs b/tests/monotouch-test/CoreGraphics/PDFContextTest.cs index 24b814052483..3cec0525f837 100644 --- a/tests/monotouch-test/CoreGraphics/PDFContextTest.cs +++ b/tests/monotouch-test/CoreGraphics/PDFContextTest.cs @@ -121,5 +121,35 @@ public void Context_Tag_Strong () ctx.EndPage (); } } + + [Test] + public void SetParentTree () + { + TestRuntime.AssertXcodeVersion (16, 0); + using var url = new NSUrl (filename); + using var ctx = new CGContextPDF (url); + using var doc = CGPDFDocument.FromFile (NSBundle.MainBundle.PathForResource ("Tamarin", "pdf")); + ctx.SetParentTree (doc.GetCatalog ()); + } + + [Test] + public void SetIdTree () + { + TestRuntime.AssertXcodeVersion (16, 0); + using var url = new NSUrl (filename); + using var ctx = new CGContextPDF (url); + using var doc = CGPDFDocument.FromFile (NSBundle.MainBundle.PathForResource ("Tamarin", "pdf")); + ctx.SetIdTree (doc.GetCatalog ()); + } + + [Test] + public void SetPageTagStructureTree () + { + TestRuntime.AssertXcodeVersion (16, 0); + using var url = new NSUrl (filename); + using var ctx = new CGContextPDF (url); + using var dict = new NSDictionary (); + ctx.SetPageTagStructureTree (dict); + } } } diff --git a/tests/xtro-sharpie/api-annotations-dotnet/MacCatalyst-CoreGraphics.ignore b/tests/xtro-sharpie/api-annotations-dotnet/MacCatalyst-CoreGraphics.ignore index e0198271018d..a6b3b5320e17 100644 --- a/tests/xtro-sharpie/api-annotations-dotnet/MacCatalyst-CoreGraphics.ignore +++ b/tests/xtro-sharpie/api-annotations-dotnet/MacCatalyst-CoreGraphics.ignore @@ -99,3 +99,6 @@ !missing-pinvoke! CGWindowListCreate is not bound !missing-pinvoke! CGWindowListCreateDescriptionFromArray is not bound !missing-pinvoke! CGWindowServerCreateServerPort is not bound + +# We're using CGEventCreateScrollWheelEvent2, which is identical, except not variadic. +!missing-pinvoke! CGEventCreateScrollWheelEvent is not bound diff --git a/tests/xtro-sharpie/api-annotations-dotnet/MacCatalyst-CoreGraphics.todo b/tests/xtro-sharpie/api-annotations-dotnet/MacCatalyst-CoreGraphics.todo deleted file mode 100644 index c192144baa47..000000000000 --- a/tests/xtro-sharpie/api-annotations-dotnet/MacCatalyst-CoreGraphics.todo +++ /dev/null @@ -1,29 +0,0 @@ -!missing-pinvoke! CGEventCreateScrollWheelEvent is not bound -!missing-enum! CGToneMapping not bound -!missing-enum-value! CGEventField native value kCGScrollWheelEventAcceleratedDeltaAxis1 = 176 not bound -!missing-enum-value! CGEventField native value kCGScrollWheelEventAcceleratedDeltaAxis2 = 175 not bound -!missing-enum-value! CGEventField native value kCGScrollWheelEventMomentumOptionPhase = 173 not bound -!missing-enum-value! CGEventField native value kCGScrollWheelEventRawDeltaAxis1 = 178 not bound -!missing-enum-value! CGEventField native value kCGScrollWheelEventRawDeltaAxis2 = 177 not bound -!missing-enum-value! CGPdfTagType native value CGPDFTagTypeObject = 800 not bound -!missing-field! kCGColorSpaceCoreMedia709 not bound -!missing-field! kCGDefaultHDRImageContentHeadroom not bound -!missing-field! kCGEXRToneMappingGammaDefog not bound -!missing-field! kCGEXRToneMappingGammaExposure not bound -!missing-field! kCGEXRToneMappingGammaKneeHigh not bound -!missing-field! kCGEXRToneMappingGammaKneeLow not bound -!missing-field! kCGSkipBoostToHDR not bound -!missing-field! kCGUse100nitsHLGOOTF not bound -!missing-field! kCGUseBT1886ForCoreVideoGamma not bound -!missing-pinvoke! CGContextDrawImageApplyingToneMapping is not bound -!missing-pinvoke! CGContextGetEDRTargetHeadroom is not bound -!missing-pinvoke! CGContextSetEDRTargetHeadroom is not bound -!missing-pinvoke! CGImageContainsImageSpecificToneMappingMetadata is not bound -!missing-pinvoke! CGImageCreateCopyWithContentHeadroom is not bound -!missing-pinvoke! CGImageCreateWithContentHeadroom is not bound -!missing-pinvoke! CGImageGetContentHeadroom is not bound -!missing-pinvoke! CGImageShouldToneMap is not bound -!missing-pinvoke! CGPDFContextSetIDTree is not bound -!missing-pinvoke! CGPDFContextSetPageTagStructureTree is not bound -!missing-pinvoke! CGPDFContextSetParentTree is not bound -!missing-pinvoke! CGColorSpaceCopyBaseColorSpace is not bound diff --git a/tests/xtro-sharpie/api-annotations-dotnet/iOS-CoreGraphics.todo b/tests/xtro-sharpie/api-annotations-dotnet/iOS-CoreGraphics.todo deleted file mode 100644 index da8d17d878c7..000000000000 --- a/tests/xtro-sharpie/api-annotations-dotnet/iOS-CoreGraphics.todo +++ /dev/null @@ -1,23 +0,0 @@ -!missing-enum! CGToneMapping not bound -!missing-field! kCGEXRToneMappingGammaDefog not bound -!missing-field! kCGEXRToneMappingGammaExposure not bound -!missing-field! kCGEXRToneMappingGammaKneeHigh not bound -!missing-field! kCGEXRToneMappingGammaKneeLow not bound -!missing-field! kCGSkipBoostToHDR not bound -!missing-field! kCGUse100nitsHLGOOTF not bound -!missing-field! kCGUseBT1886ForCoreVideoGamma not bound -!missing-pinvoke! CGContextDrawImageApplyingToneMapping is not bound -!missing-pinvoke! CGContextGetEDRTargetHeadroom is not bound -!missing-pinvoke! CGContextSetEDRTargetHeadroom is not bound -!missing-pinvoke! CGImageContainsImageSpecificToneMappingMetadata is not bound -!missing-pinvoke! CGImageGetContentHeadroom is not bound -!missing-pinvoke! CGImageShouldToneMap is not bound -!missing-enum-value! CGPdfTagType native value CGPDFTagTypeObject = 800 not bound -!missing-field! kCGColorSpaceCoreMedia709 not bound -!missing-field! kCGDefaultHDRImageContentHeadroom not bound -!missing-pinvoke! CGImageCreateCopyWithContentHeadroom is not bound -!missing-pinvoke! CGImageCreateWithContentHeadroom is not bound -!missing-pinvoke! CGPDFContextSetIDTree is not bound -!missing-pinvoke! CGPDFContextSetPageTagStructureTree is not bound -!missing-pinvoke! CGPDFContextSetParentTree is not bound -!missing-pinvoke! CGColorSpaceCopyBaseColorSpace is not bound diff --git a/tests/xtro-sharpie/api-annotations-dotnet/macOS-CoreGraphics.todo b/tests/xtro-sharpie/api-annotations-dotnet/macOS-CoreGraphics.todo deleted file mode 100644 index 27e2edc2c2c7..000000000000 --- a/tests/xtro-sharpie/api-annotations-dotnet/macOS-CoreGraphics.todo +++ /dev/null @@ -1,29 +0,0 @@ -!deprecated-attribute-missing! CGWindowListCreateImage missing a [Deprecated] attribute -!missing-enum! CGToneMapping not bound -!missing-enum-value! CGEventField native value kCGScrollWheelEventAcceleratedDeltaAxis1 = 176 not bound -!missing-enum-value! CGEventField native value kCGScrollWheelEventAcceleratedDeltaAxis2 = 175 not bound -!missing-enum-value! CGEventField native value kCGScrollWheelEventMomentumOptionPhase = 173 not bound -!missing-enum-value! CGEventField native value kCGScrollWheelEventRawDeltaAxis1 = 178 not bound -!missing-enum-value! CGEventField native value kCGScrollWheelEventRawDeltaAxis2 = 177 not bound -!missing-field! kCGEXRToneMappingGammaDefog not bound -!missing-field! kCGEXRToneMappingGammaExposure not bound -!missing-field! kCGEXRToneMappingGammaKneeHigh not bound -!missing-field! kCGEXRToneMappingGammaKneeLow not bound -!missing-field! kCGSkipBoostToHDR not bound -!missing-field! kCGUse100nitsHLGOOTF not bound -!missing-field! kCGUseBT1886ForCoreVideoGamma not bound -!missing-pinvoke! CGContextDrawImageApplyingToneMapping is not bound -!missing-pinvoke! CGContextGetEDRTargetHeadroom is not bound -!missing-pinvoke! CGContextSetEDRTargetHeadroom is not bound -!missing-pinvoke! CGImageContainsImageSpecificToneMappingMetadata is not bound -!missing-pinvoke! CGImageGetContentHeadroom is not bound -!missing-pinvoke! CGImageShouldToneMap is not bound -!missing-enum-value! CGPdfTagType native value CGPDFTagTypeObject = 800 not bound -!missing-field! kCGColorSpaceCoreMedia709 not bound -!missing-field! kCGDefaultHDRImageContentHeadroom not bound -!missing-pinvoke! CGImageCreateCopyWithContentHeadroom is not bound -!missing-pinvoke! CGImageCreateWithContentHeadroom is not bound -!missing-pinvoke! CGPDFContextSetIDTree is not bound -!missing-pinvoke! CGPDFContextSetPageTagStructureTree is not bound -!missing-pinvoke! CGPDFContextSetParentTree is not bound -!missing-pinvoke! CGColorSpaceCopyBaseColorSpace is not bound diff --git a/tests/xtro-sharpie/api-annotations-dotnet/tvOS-CoreGraphics.todo b/tests/xtro-sharpie/api-annotations-dotnet/tvOS-CoreGraphics.todo deleted file mode 100644 index da8d17d878c7..000000000000 --- a/tests/xtro-sharpie/api-annotations-dotnet/tvOS-CoreGraphics.todo +++ /dev/null @@ -1,23 +0,0 @@ -!missing-enum! CGToneMapping not bound -!missing-field! kCGEXRToneMappingGammaDefog not bound -!missing-field! kCGEXRToneMappingGammaExposure not bound -!missing-field! kCGEXRToneMappingGammaKneeHigh not bound -!missing-field! kCGEXRToneMappingGammaKneeLow not bound -!missing-field! kCGSkipBoostToHDR not bound -!missing-field! kCGUse100nitsHLGOOTF not bound -!missing-field! kCGUseBT1886ForCoreVideoGamma not bound -!missing-pinvoke! CGContextDrawImageApplyingToneMapping is not bound -!missing-pinvoke! CGContextGetEDRTargetHeadroom is not bound -!missing-pinvoke! CGContextSetEDRTargetHeadroom is not bound -!missing-pinvoke! CGImageContainsImageSpecificToneMappingMetadata is not bound -!missing-pinvoke! CGImageGetContentHeadroom is not bound -!missing-pinvoke! CGImageShouldToneMap is not bound -!missing-enum-value! CGPdfTagType native value CGPDFTagTypeObject = 800 not bound -!missing-field! kCGColorSpaceCoreMedia709 not bound -!missing-field! kCGDefaultHDRImageContentHeadroom not bound -!missing-pinvoke! CGImageCreateCopyWithContentHeadroom is not bound -!missing-pinvoke! CGImageCreateWithContentHeadroom is not bound -!missing-pinvoke! CGPDFContextSetIDTree is not bound -!missing-pinvoke! CGPDFContextSetPageTagStructureTree is not bound -!missing-pinvoke! CGPDFContextSetParentTree is not bound -!missing-pinvoke! CGColorSpaceCopyBaseColorSpace is not bound diff --git a/tests/xtro-sharpie/iOS-CoreGraphics.todo b/tests/xtro-sharpie/iOS-CoreGraphics.todo deleted file mode 100644 index da8d17d878c7..000000000000 --- a/tests/xtro-sharpie/iOS-CoreGraphics.todo +++ /dev/null @@ -1,23 +0,0 @@ -!missing-enum! CGToneMapping not bound -!missing-field! kCGEXRToneMappingGammaDefog not bound -!missing-field! kCGEXRToneMappingGammaExposure not bound -!missing-field! kCGEXRToneMappingGammaKneeHigh not bound -!missing-field! kCGEXRToneMappingGammaKneeLow not bound -!missing-field! kCGSkipBoostToHDR not bound -!missing-field! kCGUse100nitsHLGOOTF not bound -!missing-field! kCGUseBT1886ForCoreVideoGamma not bound -!missing-pinvoke! CGContextDrawImageApplyingToneMapping is not bound -!missing-pinvoke! CGContextGetEDRTargetHeadroom is not bound -!missing-pinvoke! CGContextSetEDRTargetHeadroom is not bound -!missing-pinvoke! CGImageContainsImageSpecificToneMappingMetadata is not bound -!missing-pinvoke! CGImageGetContentHeadroom is not bound -!missing-pinvoke! CGImageShouldToneMap is not bound -!missing-enum-value! CGPdfTagType native value CGPDFTagTypeObject = 800 not bound -!missing-field! kCGColorSpaceCoreMedia709 not bound -!missing-field! kCGDefaultHDRImageContentHeadroom not bound -!missing-pinvoke! CGImageCreateCopyWithContentHeadroom is not bound -!missing-pinvoke! CGImageCreateWithContentHeadroom is not bound -!missing-pinvoke! CGPDFContextSetIDTree is not bound -!missing-pinvoke! CGPDFContextSetPageTagStructureTree is not bound -!missing-pinvoke! CGPDFContextSetParentTree is not bound -!missing-pinvoke! CGColorSpaceCopyBaseColorSpace is not bound diff --git a/tests/xtro-sharpie/macOS-CoreGraphics.todo b/tests/xtro-sharpie/macOS-CoreGraphics.todo deleted file mode 100644 index 27e2edc2c2c7..000000000000 --- a/tests/xtro-sharpie/macOS-CoreGraphics.todo +++ /dev/null @@ -1,29 +0,0 @@ -!deprecated-attribute-missing! CGWindowListCreateImage missing a [Deprecated] attribute -!missing-enum! CGToneMapping not bound -!missing-enum-value! CGEventField native value kCGScrollWheelEventAcceleratedDeltaAxis1 = 176 not bound -!missing-enum-value! CGEventField native value kCGScrollWheelEventAcceleratedDeltaAxis2 = 175 not bound -!missing-enum-value! CGEventField native value kCGScrollWheelEventMomentumOptionPhase = 173 not bound -!missing-enum-value! CGEventField native value kCGScrollWheelEventRawDeltaAxis1 = 178 not bound -!missing-enum-value! CGEventField native value kCGScrollWheelEventRawDeltaAxis2 = 177 not bound -!missing-field! kCGEXRToneMappingGammaDefog not bound -!missing-field! kCGEXRToneMappingGammaExposure not bound -!missing-field! kCGEXRToneMappingGammaKneeHigh not bound -!missing-field! kCGEXRToneMappingGammaKneeLow not bound -!missing-field! kCGSkipBoostToHDR not bound -!missing-field! kCGUse100nitsHLGOOTF not bound -!missing-field! kCGUseBT1886ForCoreVideoGamma not bound -!missing-pinvoke! CGContextDrawImageApplyingToneMapping is not bound -!missing-pinvoke! CGContextGetEDRTargetHeadroom is not bound -!missing-pinvoke! CGContextSetEDRTargetHeadroom is not bound -!missing-pinvoke! CGImageContainsImageSpecificToneMappingMetadata is not bound -!missing-pinvoke! CGImageGetContentHeadroom is not bound -!missing-pinvoke! CGImageShouldToneMap is not bound -!missing-enum-value! CGPdfTagType native value CGPDFTagTypeObject = 800 not bound -!missing-field! kCGColorSpaceCoreMedia709 not bound -!missing-field! kCGDefaultHDRImageContentHeadroom not bound -!missing-pinvoke! CGImageCreateCopyWithContentHeadroom is not bound -!missing-pinvoke! CGImageCreateWithContentHeadroom is not bound -!missing-pinvoke! CGPDFContextSetIDTree is not bound -!missing-pinvoke! CGPDFContextSetPageTagStructureTree is not bound -!missing-pinvoke! CGPDFContextSetParentTree is not bound -!missing-pinvoke! CGColorSpaceCopyBaseColorSpace is not bound diff --git a/tests/xtro-sharpie/tvOS-CoreGraphics.todo b/tests/xtro-sharpie/tvOS-CoreGraphics.todo deleted file mode 100644 index da8d17d878c7..000000000000 --- a/tests/xtro-sharpie/tvOS-CoreGraphics.todo +++ /dev/null @@ -1,23 +0,0 @@ -!missing-enum! CGToneMapping not bound -!missing-field! kCGEXRToneMappingGammaDefog not bound -!missing-field! kCGEXRToneMappingGammaExposure not bound -!missing-field! kCGEXRToneMappingGammaKneeHigh not bound -!missing-field! kCGEXRToneMappingGammaKneeLow not bound -!missing-field! kCGSkipBoostToHDR not bound -!missing-field! kCGUse100nitsHLGOOTF not bound -!missing-field! kCGUseBT1886ForCoreVideoGamma not bound -!missing-pinvoke! CGContextDrawImageApplyingToneMapping is not bound -!missing-pinvoke! CGContextGetEDRTargetHeadroom is not bound -!missing-pinvoke! CGContextSetEDRTargetHeadroom is not bound -!missing-pinvoke! CGImageContainsImageSpecificToneMappingMetadata is not bound -!missing-pinvoke! CGImageGetContentHeadroom is not bound -!missing-pinvoke! CGImageShouldToneMap is not bound -!missing-enum-value! CGPdfTagType native value CGPDFTagTypeObject = 800 not bound -!missing-field! kCGColorSpaceCoreMedia709 not bound -!missing-field! kCGDefaultHDRImageContentHeadroom not bound -!missing-pinvoke! CGImageCreateCopyWithContentHeadroom is not bound -!missing-pinvoke! CGImageCreateWithContentHeadroom is not bound -!missing-pinvoke! CGPDFContextSetIDTree is not bound -!missing-pinvoke! CGPDFContextSetPageTagStructureTree is not bound -!missing-pinvoke! CGPDFContextSetParentTree is not bound -!missing-pinvoke! CGColorSpaceCopyBaseColorSpace is not bound diff --git a/tests/xtro-sharpie/watchOS-CoreGraphics.todo b/tests/xtro-sharpie/watchOS-CoreGraphics.todo deleted file mode 100644 index da8d17d878c7..000000000000 --- a/tests/xtro-sharpie/watchOS-CoreGraphics.todo +++ /dev/null @@ -1,23 +0,0 @@ -!missing-enum! CGToneMapping not bound -!missing-field! kCGEXRToneMappingGammaDefog not bound -!missing-field! kCGEXRToneMappingGammaExposure not bound -!missing-field! kCGEXRToneMappingGammaKneeHigh not bound -!missing-field! kCGEXRToneMappingGammaKneeLow not bound -!missing-field! kCGSkipBoostToHDR not bound -!missing-field! kCGUse100nitsHLGOOTF not bound -!missing-field! kCGUseBT1886ForCoreVideoGamma not bound -!missing-pinvoke! CGContextDrawImageApplyingToneMapping is not bound -!missing-pinvoke! CGContextGetEDRTargetHeadroom is not bound -!missing-pinvoke! CGContextSetEDRTargetHeadroom is not bound -!missing-pinvoke! CGImageContainsImageSpecificToneMappingMetadata is not bound -!missing-pinvoke! CGImageGetContentHeadroom is not bound -!missing-pinvoke! CGImageShouldToneMap is not bound -!missing-enum-value! CGPdfTagType native value CGPDFTagTypeObject = 800 not bound -!missing-field! kCGColorSpaceCoreMedia709 not bound -!missing-field! kCGDefaultHDRImageContentHeadroom not bound -!missing-pinvoke! CGImageCreateCopyWithContentHeadroom is not bound -!missing-pinvoke! CGImageCreateWithContentHeadroom is not bound -!missing-pinvoke! CGPDFContextSetIDTree is not bound -!missing-pinvoke! CGPDFContextSetPageTagStructureTree is not bound -!missing-pinvoke! CGPDFContextSetParentTree is not bound -!missing-pinvoke! CGColorSpaceCopyBaseColorSpace is not bound From 55c5324146ba3b673b9941730115d7b67ce8dbc4 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Fri, 23 Aug 2024 20:22:37 +0200 Subject: [PATCH 2/2] Fix tests. --- .../CoreGraphics/CGImageTest.cs | 31 ++++++++++--------- .../CoreGraphics/ContextTest.cs | 2 +- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/tests/monotouch-test/CoreGraphics/CGImageTest.cs b/tests/monotouch-test/CoreGraphics/CGImageTest.cs index 5cbf9b644d46..ba4b7d25dddb 100644 --- a/tests/monotouch-test/CoreGraphics/CGImageTest.cs +++ b/tests/monotouch-test/CoreGraphics/CGImageTest.cs @@ -43,25 +43,28 @@ public void FromPNG () } [Test] - public void Xcode16APIs () + public void ContentHeadroom () { TestRuntime.AssertXcodeVersion (16, 0); - var file = Path.Combine (NSBundle.MainBundle.ResourcePath, "basn3p08.png"); - using var dp = new CGDataProvider (file); - using var img = new CGImage (2.0f, 20, 20, 8, 32, 80, null, CGBitmapFlags.None, dp, null, false, CGColorRenderingIntent.Default); - Assert.IsNotNull (img, "Image"); - Assert.AreEqual (0.0f, img.ContentHeadroom, "ContentHeadroom A"); - Assert.IsFalse (img.ShouldToneMap, "ShouldToneMap A"); - Assert.IsFalse (img.ContainsImageSpecificToneMappingMetadata, "ContainsImageSpecificToneMappingMetadata A"); + Assert.Multiple (() => { + var frame = new CGSize (32, 32); + using var provider = new CGDataProvider (new byte [(int) frame.Width * (int) frame.Height * 4]); + using var colorSpace = CGColorSpace.CreateWithName (CGColorSpaceNames.Itur_2100_PQ); + using var img = new CGImage (0.0f, (int) frame.Width, (int) frame.Height, 8, 32, 4 * (int) frame.Width, colorSpace, CGBitmapFlags.ByteOrderDefault | CGBitmapFlags.Last, provider, null, false, CGColorRenderingIntent.Default); + Assert.IsNotNull (img, "Image"); + Assert.AreEqual (4.92610836f, img.ContentHeadroom, "ContentHeadroom A"); + Assert.IsTrue (img.ShouldToneMap, "ShouldToneMap A"); + Assert.IsFalse (img.ContainsImageSpecificToneMappingMetadata, "ContainsImageSpecificToneMappingMetadata A"); - using var copy = img.Copy (3.0f); - Assert.IsNotNull (copy, "Copy"); - Assert.AreEqual (3.0f, copy.ContentHeadroom, "ContentHeadroom B"); - Assert.IsFalse (copy.ShouldToneMap, "ShouldToneMap B"); - Assert.IsFalse (copy.ContainsImageSpecificToneMappingMetadata, "ContainsImageSpecificToneMappingMetadata B"); + using var copy = img.Copy (3.0f); + Assert.IsNotNull (copy, "Copy"); + Assert.AreEqual (3.0f, copy.ContentHeadroom, "ContentHeadroom B"); + Assert.IsTrue (copy.ShouldToneMap, "ShouldToneMap B"); + Assert.IsFalse (copy.ContainsImageSpecificToneMappingMetadata, "ContainsImageSpecificToneMappingMetadata B"); - Assert.AreEqual (2.0f, CGImage.DefaultHdrImageContentHeadroom, "DefaultHdrImageContentHeadroom"); + Assert.AreEqual (4.92610836f, CGImage.DefaultHdrImageContentHeadroom, "DefaultHdrImageContentHeadroom"); + }); } } } diff --git a/tests/monotouch-test/CoreGraphics/ContextTest.cs b/tests/monotouch-test/CoreGraphics/ContextTest.cs index cf1b25268603..f2e40b62fd32 100644 --- a/tests/monotouch-test/CoreGraphics/ContextTest.cs +++ b/tests/monotouch-test/CoreGraphics/ContextTest.cs @@ -67,7 +67,7 @@ public void EdrHeadroom () Assert.AreEqual (0.0f, context.GetEdrTargetHeadroom (), "a"); Assert.IsTrue (context.SetEdrTargetHeadroom (2.0f), "b"); Assert.AreEqual (2.0f, context.GetEdrTargetHeadroom (), "c"); - Assert.IsFalse (context.SetEdrTargetHeadroom (0.0f), "d"); + Assert.IsFalse (context.SetEdrTargetHeadroom (-2.0f), "d"); Assert.AreEqual (2.0f, context.GetEdrTargetHeadroom (), "e"); }