diff --git a/binding/Binding/Definitions.cs b/binding/Binding/Definitions.cs index ece05dfd9..7de80174d 100644 --- a/binding/Binding/Definitions.cs +++ b/binding/Binding/Definitions.cs @@ -2165,10 +2165,15 @@ namespace SkiaSharp Binary, } - public enum SKColorSpaceNamed { + public enum SKColorSpaceGamut { Srgb, AdobeRgb, - SrgbLinear, + Dcip3D65, + Rec2020, + } + + public enum SKColorSpaceFlags { + NonLinearBlending = 0x1, } public enum SKColorSpaceRenderTargetGamma { diff --git a/binding/Binding/SKColorSpace.cs b/binding/Binding/SKColorSpace.cs index ea3bd84e7..3b8caaf71 100644 --- a/binding/Binding/SKColorSpace.cs +++ b/binding/Binding/SKColorSpace.cs @@ -44,9 +44,14 @@ namespace SkiaSharp return SkiaApi.sk_colorspace_equals (left.Handle, right.Handle); } - public static SKColorSpace CreateNamed (SKColorSpaceNamed name) + public static SKColorSpace CreateSrgb () { - return GetObject (SkiaApi.sk_colorspace_new_named (name)); + return GetObject (SkiaApi.sk_colorspace_new_srgb ()); + } + + public static SKColorSpace CreateSrgbLinear () + { + return GetObject (SkiaApi.sk_colorspace_new_srgb_linear ()); } public static SKColorSpace CreateIcc (IntPtr input, long length) @@ -68,18 +73,45 @@ namespace SkiaSharp return GetObject (SkiaApi.sk_colorspace_new_icc (input, (IntPtr)input.Length)); } - public static SKColorSpace CreateRgb (SKColorSpaceRenderTargetGamma gamma, SKMatrix44 toXyzD50) + public static SKColorSpace CreateRgb (SKColorSpaceRenderTargetGamma gamma, SKMatrix44 toXyzD50, SKColorSpaceFlags flags = 0) { if (toXyzD50 == null) throw new ArgumentNullException (nameof (toXyzD50)); - return GetObject (SkiaApi.sk_colorspace_new_rgb_with_gamma (gamma, toXyzD50.Handle)); + return GetObject (SkiaApi.sk_colorspace_new_rgb_with_gamma (gamma, toXyzD50.Handle, flags)); } - public static SKColorSpace CreateRgb (SKColorSpaceTransferFn coeffs, SKMatrix44 toXyzD50) + public static SKColorSpace CreateRgb (SKColorSpaceRenderTargetGamma gamma, SKColorSpaceGamut gamut, SKColorSpaceFlags flags = 0) + { + return GetObject (SkiaApi.sk_colorspace_new_rgb_with_gamma_and_gamut (gamma, gamut, flags)); + } + + public static SKColorSpace CreateRgb (SKColorSpaceTransferFn coeffs, SKMatrix44 toXyzD50, SKColorSpaceFlags flags = 0) { if (toXyzD50 == null) throw new ArgumentNullException (nameof (toXyzD50)); - return GetObject (SkiaApi.sk_colorspace_new_rgb_with_coeffs (ref coeffs, toXyzD50.Handle)); + return GetObject (SkiaApi.sk_colorspace_new_rgb_with_coeffs (ref coeffs, toXyzD50.Handle, flags)); + } + + public static SKColorSpace CreateRgb (SKColorSpaceTransferFn coeffs, SKColorSpaceGamut gamut, SKColorSpaceFlags flags = 0) + { + return GetObject (SkiaApi.sk_colorspace_new_rgb_with_coeffs_and_gamut (ref coeffs, gamut, flags)); + } + + public bool ToXyzD50 (SKMatrix44 toXyzD50) + { + if (toXyzD50 == null) + throw new ArgumentNullException (nameof (toXyzD50)); + return SkiaApi.sk_colorspace_to_xyzd50 (Handle, toXyzD50.Handle); + } + + public SKMatrix44 ToXyzD50 () + { + var xyzD50 = new SKMatrix44 (); + if (!ToXyzD50 (xyzD50)) { + xyzD50.Dispose (); + xyzD50 = null; + } + return xyzD50; } public static bool ConvertPrimariesToXyzD50 (SKColorSpacePrimaries primaries, SKMatrix44 toXyzD50) diff --git a/binding/Binding/SkiaApi.cs b/binding/Binding/SkiaApi.cs index a72d067f8..58d9ff26d 100755 --- a/binding/Binding/SkiaApi.cs +++ b/binding/Binding/SkiaApi.cs @@ -95,15 +95,24 @@ namespace SkiaSharp [return: MarshalAs(UnmanagedType.I1)] public extern static bool sk_colorspace_equals(sk_colorspace_t src, sk_colorspace_t dst); [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] - public extern static sk_colorspace_t sk_colorspace_new_named(SKColorSpaceNamed named); + public extern static sk_colorspace_t sk_colorspace_new_srgb(); + [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] + public extern static sk_colorspace_t sk_colorspace_new_srgb_linear(); [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] public extern static sk_colorspace_t sk_colorspace_new_icc(IntPtr input, IntPtr len); [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] public extern static sk_colorspace_t sk_colorspace_new_icc(byte[] input, IntPtr len); [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] - public extern static sk_colorspace_t sk_colorspace_new_rgb_with_gamma(SKColorSpaceRenderTargetGamma gamma, sk_matrix44_t toXYZD50); + public extern static sk_colorspace_t sk_colorspace_new_rgb_with_gamma(SKColorSpaceRenderTargetGamma gamma, sk_matrix44_t toXYZD50, SKColorSpaceFlags flags); [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] - public extern static sk_colorspace_t sk_colorspace_new_rgb_with_coeffs(ref SKColorSpaceTransferFn coeffs, sk_matrix44_t toXYZD50); + public extern static sk_colorspace_t sk_colorspace_new_rgb_with_gamma_and_gamut(SKColorSpaceRenderTargetGamma gamma, SKColorSpaceGamut gamut, SKColorSpaceFlags flags); + [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] + public extern static sk_colorspace_t sk_colorspace_new_rgb_with_coeffs(ref SKColorSpaceTransferFn coeffs, sk_matrix44_t toXYZD50, SKColorSpaceFlags flags); + [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] + public extern static sk_colorspace_t sk_colorspace_new_rgb_with_coeffs_and_gamut(ref SKColorSpaceTransferFn coeffs, SKColorSpaceGamut gamut, SKColorSpaceFlags flags); + [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.I1)] + public extern static bool sk_colorspace_to_xyzd50(sk_colorspace_t cColorSpace, sk_matrix44_t toXYZD50); [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] [return: MarshalAs(UnmanagedType.I1)] public extern static bool sk_colorspaceprimaries_to_xyzd50(ref SKColorSpacePrimaries primaries, sk_matrix44_t toXYZD50); diff --git a/cake/BuildExternals.cake b/cake/BuildExternals.cake index 5778a2d85..15cc7cf58 100644 --- a/cake/BuildExternals.cake +++ b/cake/BuildExternals.cake @@ -573,7 +573,7 @@ Task ("externals-tvos") " is_official_build=true skia_enable_tools=false" + " target_os=\"tvos\" target_cpu=\"" + skiaArch + "\"" + " skia_use_icu=false skia_use_sfntly=false" + - " extra_cflags=[ \"-DSKIA_C_DLL\", \"-mtvos-version-min=9.0\" ]" + + " extra_cflags=[ \"-DSK_BUILD_FOR_TVOS\", \"-DSKIA_C_DLL\", \"-mtvos-version-min=9.0\" ]" + " extra_ldflags=[ \"-Wl,tvos_version_min=9.0\" ]" + "'", WorkingDirectory = SKIA_PATH.FullPath, diff --git a/externals/skia b/externals/skia index 801343076..e7d3654a6 160000 --- a/externals/skia +++ b/externals/skia @@ -1 +1 @@ -Subproject commit 801343076bc02c67ed64845ffc8b0cd9f96477ec +Subproject commit e7d3654a693aa9da1d574253adb87b1a6f8f0420 diff --git a/tests/Tests/SKColorSpaceTest.cs b/tests/Tests/SKColorSpaceTest.cs index c2a83310e..d4405edc6 100644 --- a/tests/Tests/SKColorSpaceTest.cs +++ b/tests/Tests/SKColorSpaceTest.cs @@ -10,7 +10,7 @@ namespace SkiaSharp.Tests [Test] public void CanCreateSrgb() { - var colorspace = SKColorSpace.CreateNamed(SKColorSpaceNamed.Srgb); + var colorspace = SKColorSpace.CreateSrgb(); Assert.IsNotNull(colorspace); Assert.IsTrue(SKColorSpace.Equal(colorspace, colorspace)); @@ -19,7 +19,7 @@ namespace SkiaSharp.Tests [Test] public void ImageInfoHasColorSpace() { - var colorspace = SKColorSpace.CreateNamed(SKColorSpaceNamed.Srgb); + var colorspace = SKColorSpace.CreateSrgb(); var info = new SKImageInfo(100, 100, SKImageInfo.PlatformColorType, SKAlphaType.Premul, colorspace); Assert.AreEqual(colorspace, info.ColorSpace); @@ -31,7 +31,7 @@ namespace SkiaSharp.Tests [Test] public void SrgbColorSpaceIsCloseToSrgb() { - var colorspace = SKColorSpace.CreateNamed(SKColorSpaceNamed.Srgb); + var colorspace = SKColorSpace.CreateSrgb(); Assert.IsTrue(colorspace.GammaIsCloseToSrgb); }