Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CoreGraphics] Implement Xcode 16.0 beta 1-6 changes. #21033

Merged
merged 4 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Fix tests.
  • Loading branch information
rolfbjarne committed Aug 23, 2024
commit 55c5324146ba3b673b9941730115d7b67ce8dbc4
31 changes: 17 additions & 14 deletions tests/monotouch-test/CoreGraphics/CGImageTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});
}
}
}
2 changes: 1 addition & 1 deletion tests/monotouch-test/CoreGraphics/ContextTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down