Skip to content

Commit

Permalink
Revert "Revert "Merge branch 'develop' into main""
Browse files Browse the repository at this point in the history
This reverts commit 8be3cd9.
  • Loading branch information
mattleibow committed Mar 13, 2021
1 parent 8be3cd9 commit 87fbd9c
Show file tree
Hide file tree
Showing 40 changed files with 2,001 additions and 664 deletions.
46 changes: 23 additions & 23 deletions VERSIONS.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# dependencies
mdoc release 5.7.4.10
harfbuzz release 2.6.1
skia release m80
skia release m88
xunit release 2.4.1
xunit.runner.console release 2.4.1
Xamarin.Forms release 4.5.0.725
Expand Down Expand Up @@ -30,39 +30,39 @@ Xamarin.Forms reference 4.4.0.991757
# this is related to the API versions, not the library versions
# - milestone: the skia milestone determined by Google/Chromium
# - increment: the C API version increment caused by new APIs
libSkiaSharp milestone 80
libSkiaSharp increment 3
libSkiaSharp milestone 88
libSkiaSharp increment 0

# native sonames
libSkiaSharp soname 80.3.0
libSkiaSharp soname 88.0.0
HarfBuzz soname 0.20601.0

# SkiaSharp.dll
SkiaSharp assembly 2.80.0.0
SkiaSharp file 2.80.3.0
SkiaSharp assembly 2.88.0.0
SkiaSharp file 2.88.0.0

# HarfBuzzSharp.dll
HarfBuzzSharp assembly 1.0.0.0
HarfBuzzSharp file 2.6.1.7

# nuget versions
SkiaSharp nuget 2.80.3
SkiaSharp.NativeAssets.Linux nuget 2.80.3
SkiaSharp.NativeAssets.Linux.NoDependencies nuget 2.80.3
SkiaSharp.NativeAssets.NanoServer nuget 2.80.3
SkiaSharp.NativeAssets.WebAssembly nuget 2.80.3
SkiaSharp.Views nuget 2.80.3
SkiaSharp.Views.Desktop.Common nuget 2.80.3
SkiaSharp.Views.Gtk2 nuget 2.80.3
SkiaSharp.Views.Gtk3 nuget 2.80.3
SkiaSharp.Views.WindowsForms nuget 2.80.3
SkiaSharp.Views.WPF nuget 2.80.3
SkiaSharp.Views.Forms nuget 2.80.3
SkiaSharp.Views.Forms.WPF nuget 2.80.3
SkiaSharp.Views.Forms.GTK nuget 2.80.3
SkiaSharp.Views.Uno nuget 2.80.3
SkiaSharp.HarfBuzz nuget 2.80.3
SkiaSharp.Vulkan.SharpVk nuget 2.80.3
SkiaSharp nuget 2.88.0
SkiaSharp.NativeAssets.Linux nuget 2.88.0
SkiaSharp.NativeAssets.Linux.NoDependencies nuget 2.88.0
SkiaSharp.NativeAssets.NanoServer nuget 2.88.0
SkiaSharp.NativeAssets.WebAssembly nuget 2.88.0
SkiaSharp.Views nuget 2.88.0
SkiaSharp.Views.Desktop.Common nuget 2.88.0
SkiaSharp.Views.Gtk2 nuget 2.88.0
SkiaSharp.Views.Gtk3 nuget 2.88.0
SkiaSharp.Views.WindowsForms nuget 2.88.0
SkiaSharp.Views.WPF nuget 2.88.0
SkiaSharp.Views.Forms nuget 2.88.0
SkiaSharp.Views.Forms.WPF nuget 2.88.0
SkiaSharp.Views.Forms.GTK nuget 2.88.0
SkiaSharp.Views.Uno nuget 2.88.0
SkiaSharp.HarfBuzz nuget 2.88.0
SkiaSharp.Vulkan.SharpVk nuget 2.88.0
HarfBuzzSharp nuget 2.6.1.7
HarfBuzzSharp.NativeAssets.Linux nuget 2.6.1.7
HarfBuzzSharp.NativeAssets.WebAssembly nuget 2.6.1.7
Expand Down
6 changes: 6 additions & 0 deletions binding/Binding/Definitions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ public enum SKColorType
Alpha16 = 16,
Rg1616 = 17,
Rgba16161616 = 18,
Bgra1010102 = 19,
Bgr101010x = 20,
}

public static partial class SkiaExtensions
Expand Down Expand Up @@ -130,6 +132,8 @@ public static int GetBytesPerPixel (this SKColorType colorType) =>
SKColorType.AlphaF16 => 2,
// 4
SKColorType.Bgra8888 => 4,
SKColorType.Bgra1010102 => 4,
SKColorType.Bgr101010x => 4,
SKColorType.Rgba8888 => 4,
SKColorType.Rgb888x => 4,
SKColorType.Rgba1010102 => 4,
Expand Down Expand Up @@ -168,6 +172,7 @@ public static SKAlphaType GetAlphaType (this SKColorType colorType, SKAlphaType
case SKColorType.Rgba8888:
case SKColorType.Bgra8888:
case SKColorType.Rgba1010102:
case SKColorType.Bgra1010102:
case SKColorType.RgbaF16Clamped:
case SKColorType.RgbaF16:
case SKColorType.RgbaF32:
Expand All @@ -182,6 +187,7 @@ public static SKAlphaType GetAlphaType (this SKColorType colorType, SKAlphaType
case SKColorType.Rgb565:
case SKColorType.Rgb888x:
case SKColorType.Rgb101010x:
case SKColorType.Bgr101010x:
alphaType = SKAlphaType.Opaque;
break;

Expand Down
7 changes: 7 additions & 0 deletions binding/Binding/EnumMappings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public enum GRBackend
OpenGL = 1,
Vulkan = 2,
Dawn = 3,
Direct3D = 4,
}

[EditorBrowsable (EditorBrowsableState.Never)]
Expand Down Expand Up @@ -61,6 +62,7 @@ internal static GRBackendNative ToNative (this GRBackend backend) =>
GRBackend.OpenGL => GRBackendNative.OpenGL,
GRBackend.Vulkan => GRBackendNative.Vulkan,
GRBackend.Dawn => GRBackendNative.Dawn,
GRBackend.Direct3D => GRBackendNative.Direct3D,
_ => throw new ArgumentOutOfRangeException (nameof (backend)),
};

Expand All @@ -71,6 +73,7 @@ internal static GRBackend FromNative (this GRBackendNative backend) =>
GRBackendNative.OpenGL => GRBackend.OpenGL,
GRBackendNative.Vulkan => GRBackend.Vulkan,
GRBackendNative.Dawn => GRBackend.Dawn,
GRBackendNative.Direct3D => GRBackend.Direct3D,
_ => throw new ArgumentOutOfRangeException (nameof (backend)),
};

Expand All @@ -96,6 +99,8 @@ internal static SKColorTypeNative ToNative (this SKColorType colorType) =>
SKColorType.Alpha16 => SKColorTypeNative.A16Unorm,
SKColorType.Rg1616 => SKColorTypeNative.R16g16Unorm,
SKColorType.Rgba16161616 => SKColorTypeNative.R16g16b16a16Unorm,
SKColorType.Bgra1010102 => SKColorTypeNative.Bgra1010102,
SKColorType.Bgr101010x => SKColorTypeNative.Bgr101010x,
_ => throw new ArgumentOutOfRangeException (nameof (colorType)),
};

Expand All @@ -121,6 +126,8 @@ internal static SKColorType FromNative (this SKColorTypeNative colorType) =>
SKColorTypeNative.A16Unorm => SKColorType.Alpha16,
SKColorTypeNative.R16g16Unorm => SKColorType.Rg1616,
SKColorTypeNative.R16g16b16a16Unorm => SKColorType.Rgba16161616,
SKColorTypeNative.Bgra1010102 => SKColorType.Bgra1010102,
SKColorTypeNative.Bgr101010x => SKColorType.Bgr101010x,
_ => throw new ArgumentOutOfRangeException (nameof (colorType)),
};
}
Expand Down
49 changes: 28 additions & 21 deletions binding/Binding/GRContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ internal GRContext (IntPtr h, bool owns)
protected override void Dispose (bool disposing) =>
base.Dispose (disposing);

protected override void DisposeNative ()
{
AbandonContext ();

base.DisposeNative ();
}

// Create

[EditorBrowsable (EditorBrowsableState.Never)]
Expand Down Expand Up @@ -45,7 +52,7 @@ public static GRContext Create (GRBackend backend, IntPtr backendContext) =>
backend switch
{
GRBackend.Metal => throw new NotSupportedException (),
GRBackend.OpenGL => GetObject (SkiaApi.gr_context_make_gl (backendContext)),
GRBackend.OpenGL => GetObject (SkiaApi.gr_direct_context_make_gl (backendContext)),
GRBackend.Vulkan => throw new NotSupportedException (),
GRBackend.Dawn => throw new NotSupportedException (),
_ => throw new ArgumentOutOfRangeException (nameof (backend)),
Expand All @@ -67,10 +74,10 @@ public static GRContext CreateGl (GRGlInterface backendContext, GRContextOptions
var ctx = backendContext == null ? IntPtr.Zero : backendContext.Handle;

if (options == null) {
return GetObject (SkiaApi.gr_context_make_gl (ctx));
return GetObject (SkiaApi.gr_direct_context_make_gl (ctx));
} else {
var opts = options.ToNative ();
return GetObject (SkiaApi.gr_context_make_gl_with_options (ctx, &opts));
return GetObject (SkiaApi.gr_direct_context_make_gl_with_options (ctx, &opts));
}
}

Expand All @@ -85,10 +92,10 @@ public static GRContext CreateVulkan (GRVkBackendContext backendContext, GRConte
throw new ArgumentNullException (nameof (backendContext));

if (options == null) {
return GetObject (SkiaApi.gr_context_make_vulkan (backendContext.ToNative ()));
return GetObject (SkiaApi.gr_direct_context_make_vulkan (backendContext.ToNative ()));
} else {
var opts = options.ToNative ();
return GetObject (SkiaApi.gr_context_make_vulkan_with_options (backendContext.ToNative (), &opts));
return GetObject (SkiaApi.gr_direct_context_make_vulkan_with_options (backendContext.ToNative (), &opts));
}
}

Expand All @@ -108,25 +115,25 @@ public static GRContext CreateMetal (GRMtlBackendContext backendContext, GRConte
var queue = backendContext.Queue;

if (options == null) {
return GetObject (SkiaApi.gr_context_make_metal ((void*)device.Handle, (void*)queue.Handle));
return GetObject (SkiaApi.gr_direct_context_make_metal ((void*)device.Handle, (void*)queue.Handle));
} else {
var opts = options.ToNative ();
return GetObject (SkiaApi.gr_context_make_metal_with_options ((void*)device.Handle, (void*)queue.Handle, &opts));
return GetObject (SkiaApi.gr_direct_context_make_metal_with_options ((void*)device.Handle, (void*)queue.Handle, &opts));
}
}

#endif

//

public GRBackend Backend => SkiaApi.gr_context_get_backend (Handle).FromNative ();
public GRBackend Backend => SkiaApi.gr_direct_context_get_backend (Handle).FromNative ();

public void AbandonContext (bool releaseResources = false)
{
if (releaseResources)
SkiaApi.gr_context_release_resources_and_abandon_context (Handle);
SkiaApi.gr_direct_context_release_resources_and_abandon_context (Handle);
else
SkiaApi.gr_context_abandon_context (Handle);
SkiaApi.gr_direct_context_abandon_context (Handle);
}

[EditorBrowsable (EditorBrowsableState.Never)]
Expand All @@ -143,16 +150,16 @@ public void SetResourceCacheLimits (int maxResources, long maxResourceBytes) =>
SetResourceCacheLimit (maxResourceBytes);

public long GetResourceCacheLimit () =>
(long)SkiaApi.gr_context_get_resource_cache_limit (Handle);
(long)SkiaApi.gr_direct_context_get_resource_cache_limit (Handle);

public void SetResourceCacheLimit (long maxResourceBytes) =>
SkiaApi.gr_context_set_resource_cache_limit (Handle, (IntPtr)maxResourceBytes);
SkiaApi.gr_direct_context_set_resource_cache_limit (Handle, (IntPtr)maxResourceBytes);

public void GetResourceCacheUsage (out int maxResources, out long maxResourceBytes)
{
IntPtr maxResBytes;
fixed (int* maxRes = &maxResources) {
SkiaApi.gr_context_get_resource_cache_usage (Handle, maxRes, &maxResBytes);
SkiaApi.gr_direct_context_get_resource_cache_usage (Handle, maxRes, &maxResBytes);
}
maxResourceBytes = (long)maxResBytes;
}
Expand All @@ -164,32 +171,32 @@ public void ResetContext (GRBackendState state = GRBackendState.All) =>
ResetContext ((uint)state);

public void ResetContext (uint state) =>
SkiaApi.gr_context_reset_context (Handle, state);
SkiaApi.gr_direct_context_reset_context (Handle, state);

public void Flush () =>
SkiaApi.gr_context_flush (Handle);
SkiaApi.gr_direct_context_flush (Handle);

public int GetMaxSurfaceSampleCount (SKColorType colorType) =>
SkiaApi.gr_context_get_max_surface_sample_count_for_color_type (Handle, colorType.ToNative ());
SkiaApi.gr_direct_context_get_max_surface_sample_count_for_color_type (Handle, colorType.ToNative ());

[EditorBrowsable (EditorBrowsableState.Never)]
[Obsolete]
public int GetRecommendedSampleCount (GRPixelConfig config, float dpi) => 0;

public void DumpMemoryStatistics (SKTraceMemoryDump dump) =>
SkiaApi.gr_context_dump_memory_statistics (Handle, dump?.Handle ?? throw new ArgumentNullException (nameof (dump)));
SkiaApi.gr_direct_context_dump_memory_statistics (Handle, dump?.Handle ?? throw new ArgumentNullException (nameof (dump)));

public void PurgeResources () =>
SkiaApi.gr_context_free_gpu_resources (Handle);
SkiaApi.gr_direct_context_free_gpu_resources (Handle);

public void PurgeUnusedResources (long milliseconds) =>
SkiaApi.gr_context_perform_deferred_cleanup (Handle, milliseconds);
SkiaApi.gr_direct_context_perform_deferred_cleanup (Handle, milliseconds);

public void PurgeUnlockedResources (bool scratchResourcesOnly) =>
SkiaApi.gr_context_purge_unlocked_resources (Handle, scratchResourcesOnly);
SkiaApi.gr_direct_context_purge_unlocked_resources (Handle, scratchResourcesOnly);

public void PurgeUnlockedResources (long bytesToPurge, bool preferScratchResources) =>
SkiaApi.gr_context_purge_unlocked_resources_bytes (Handle, (IntPtr)bytesToPurge, preferScratchResources);
SkiaApi.gr_direct_context_purge_unlocked_resources_bytes (Handle, (IntPtr)bytesToPurge, preferScratchResources);

internal static GRContext GetObject (IntPtr handle) =>
handle == IntPtr.Zero ? null : new GRContext (handle, true);
Expand Down
2 changes: 2 additions & 0 deletions binding/Binding/GRDefinitions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ public static GRPixelConfig ToPixelConfig (this SKColorType colorType) =>
SKColorType.Rgb888x => GRPixelConfig.Rgb888,
SKColorType.Bgra8888 => GRPixelConfig.Bgra8888,
SKColorType.Rgba1010102 => GRPixelConfig.Rgba1010102,
SKColorType.Bgra1010102 => GRPixelConfig.Unknown,
SKColorType.AlphaF16 => GRPixelConfig.AlphaHalf,
SKColorType.RgbaF16 => GRPixelConfig.RgbaHalf,
SKColorType.RgbaF16Clamped => GRPixelConfig.RgbaHalfClamped,
Expand All @@ -334,6 +335,7 @@ public static GRPixelConfig ToPixelConfig (this SKColorType colorType) =>
SKColorType.RgF16 => GRPixelConfig.RgHalf,
SKColorType.Rg88 => GRPixelConfig.Rg88,
SKColorType.Rgb101010x => GRPixelConfig.Unknown,
SKColorType.Bgr101010x => GRPixelConfig.Unknown,
SKColorType.RgbaF32 => GRPixelConfig.Unknown,
_ => throw new ArgumentOutOfRangeException (nameof (colorType)),
};
Expand Down
5 changes: 3 additions & 2 deletions binding/Binding/SKBitmap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -459,9 +459,10 @@ public bool IsImmutable {
get { return SkiaApi.sk_bitmap_is_immutable (Handle); }
}

[Obsolete]
public bool IsVolatile {
get { return SkiaApi.sk_bitmap_is_volatile (Handle); }
set { SkiaApi.sk_bitmap_set_volatile (Handle, value); }
get => false;
set { }
}

[EditorBrowsable (EditorBrowsableState.Never)]
Expand Down
Loading

0 comments on commit 87fbd9c

Please sign in to comment.