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

Merge Metal APIs from main branch #1598

Merged
merged 28 commits into from
Feb 2, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f3f0d44
Add Metal
mattleibow Jul 10, 2020
2115f62
Update externals
mattleibow Jul 10, 2020
c5eb1c6
Changes
mattleibow Jul 11, 2020
a0e2c59
undos
mattleibow Jul 11, 2020
ded3586
dsfgdsf 
mattleibow Jul 11, 2020
488cbde
Merge branch 'master' into dev/metal
mattleibow Jul 19, 2020
e14b92b
Merge branch 'master' into dev/metal
mattleibow Jul 19, 2020
cba19ad
Merge branch 'master' into dev/metal
mattleibow Jul 21, 2020
a1a7b18
regen
mattleibow Jul 21, 2020
96f4a26
sdfasdf
mattleibow Jul 21, 2020
6d7d0d9
SKMetalView
mattleibow Jul 21, 2020
719368a
Merge master into dev/metal
mattleibow Oct 10, 2020
1fd0a1d
Update PR
mattleibow Feb 1, 2021
951333d
Merge branch 'master' into dev/metal
mattleibow Feb 1, 2021
753d395
Merge branch 'dev/skia-update' into dev/metal-update
mattleibow Feb 1, 2021
6b6213f
Some fixes
mattleibow Feb 1, 2021
daf2657
Fixing things up
mattleibow Feb 1, 2021
fc244e3
Fix changed enums
mattleibow Feb 1, 2021
7d087c9
Remove the externals/harfbuzz submodule (#1599)
mattleibow Feb 1, 2021
2a87a0d
Add Metal APIs for macOS and iOS (#1394)
mattleibow Feb 2, 2021
112025b
Revert "Add Metal APIs for macOS and iOS (#1394)"
mattleibow Feb 2, 2021
29e8f26
Add Metal APIs for macOS and iOS (#1394)
mattleibow Feb 2, 2021
d966ef2
docs: Add unoplatform references (#1602)
jeromelaban Feb 2, 2021
97efda8
Merge branch 'dev/skia-update' into dev/metal-update
mattleibow Feb 2, 2021
fa6fbbe
Merge branch 'master' into dev/metal-update
mattleibow Feb 2, 2021
abc73fe
Merge branch 'master' into dev/metal-update
mattleibow Feb 2, 2021
e3a2414
Add a symlink for a "missing" file
mattleibow Feb 2, 2021
f66ea3b
Merge branch 'master' into dev/metal-update
mattleibow Feb 2, 2021
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
Next Next commit
Merge branch 'dev/skia-update' into dev/metal-update
# Conflicts:
#	binding/Binding/SkiaApi.generated.cs
#	externals/skia
#	native/macos/libSkiaSharp/libSkiaSharp.xcodeproj/project.pbxproj
  • Loading branch information
mattleibow committed Feb 1, 2021
commit 753d3956c65665879174c42d05f014db03a18f76
4 changes: 0 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
path = externals/depot_tools
url = https://chromium.googlesource.com/chromium/tools/depot_tools.git
branch = master
[submodule "externals/harfbuzz"]
path = externals/harfbuzz
url = https://github.com/harfbuzz/harfbuzz.git
branch = 2.6.1
[submodule "docs"]
path = docs
url = https://github.com/mono/SkiaSharp-API-docs
Expand Down
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
34 changes: 17 additions & 17 deletions binding/Binding/GRContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ backend switch
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 @@ -57,7 +57,7 @@ backend switch
CreateGl (null);

public static GRContext CreateGl (GRGlInterface backendContext) =>
GetObject (SkiaApi.gr_context_make_gl (backendContext == null ? IntPtr.Zero : backendContext.Handle));
GetObject (SkiaApi.gr_direct_context_make_gl (backendContext == null ? IntPtr.Zero : backendContext.Handle));

// CreateVulkan

Expand All @@ -66,7 +66,7 @@ public static GRContext CreateVulkan (GRVkBackendContext backendContext)
if (backendContext == null)
throw new ArgumentNullException (nameof (backendContext));

return GetObject (SkiaApi.gr_context_make_vulkan (backendContext.ToNative ()));
return GetObject (SkiaApi.gr_direct_context_make_vulkan (backendContext.ToNative ()));
}

#if __IOS__ || __MACOS__
Expand All @@ -87,14 +87,14 @@ public static GRContext CreateMetal (Metal.IMTLDevice device, Metal.IMTLCommandQ

//

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 @@ -111,16 +111,16 @@ public void GetResourceCacheLimits (out int maxResources, out long maxResourceBy
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 @@ -132,32 +132,32 @@ public void GetResourceCacheUsage (out int maxResources, out long maxResourceByt
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
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 void SetColorTable (SKColorTable ct)
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
63 changes: 13 additions & 50 deletions binding/Binding/SKCanvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -490,30 +490,25 @@ public void DrawDrawable (SKDrawable drawable, SKPoint p)

// DrawBitmap

public void DrawBitmap (SKBitmap bitmap, SKPoint p, SKPaint paint = null)
{
public void DrawBitmap (SKBitmap bitmap, SKPoint p, SKPaint paint = null) =>
DrawBitmap (bitmap, p.X, p.Y, paint);
}

public void DrawBitmap (SKBitmap bitmap, float x, float y, SKPaint paint = null)
{
if (bitmap == null)
throw new ArgumentNullException (nameof (bitmap));
SkiaApi.sk_canvas_draw_bitmap (Handle, bitmap.Handle, x, y, paint == null ? IntPtr.Zero : paint.Handle);
using var image = SKImage.FromBitmap (bitmap);
DrawImage (image, x, y, paint);
}

public void DrawBitmap (SKBitmap bitmap, SKRect dest, SKPaint paint = null)
{
if (bitmap == null)
throw new ArgumentNullException (nameof (bitmap));
SkiaApi.sk_canvas_draw_bitmap_rect (Handle, bitmap.Handle, null, &dest, paint == null ? IntPtr.Zero : paint.Handle);
using var image = SKImage.FromBitmap (bitmap);
DrawImage (image, dest, paint);
}

public void DrawBitmap (SKBitmap bitmap, SKRect source, SKRect dest, SKPaint paint = null)
{
if (bitmap == null)
throw new ArgumentNullException (nameof (bitmap));
SkiaApi.sk_canvas_draw_bitmap_rect (Handle, bitmap.Handle, &source, &dest, paint == null ? IntPtr.Zero : paint.Handle);
using var image = SKImage.FromBitmap (bitmap);
DrawImage (image, source, dest, paint);
}

// DrawSurface
Expand Down Expand Up @@ -839,13 +834,8 @@ public SKData DrawLinkDestinationAnnotation (SKRect rect, string value)

public void DrawBitmapNinePatch (SKBitmap bitmap, SKRectI center, SKRect dst, SKPaint paint = null)
{
if (bitmap == null)
throw new ArgumentNullException (nameof (bitmap));
// the "center" rect must fit inside the bitmap "rect"
if (!SKRect.Create (bitmap.Info.Size).Contains (center))
throw new ArgumentException ("Center rectangle must be contained inside the bitmap bounds.", nameof (center));

SkiaApi.sk_canvas_draw_bitmap_nine (Handle, bitmap.Handle, &center, &dst, paint == null ? IntPtr.Zero : paint.Handle);
using var image = SKImage.FromBitmap (bitmap);
DrawImageNinePatch (image, center, dst, paint);
}

public void DrawImageNinePatch (SKImage image, SKRectI center, SKRect dst, SKPaint paint = null)
Expand All @@ -863,11 +853,8 @@ public void DrawImageNinePatch (SKImage image, SKRectI center, SKRect dst, SKPai

public void DrawBitmapLattice (SKBitmap bitmap, int[] xDivs, int[] yDivs, SKRect dst, SKPaint paint = null)
{
var lattice = new SKLattice {
XDivs = xDivs,
YDivs = yDivs
};
DrawBitmapLattice (bitmap, lattice, dst, paint);
using var image = SKImage.FromBitmap (bitmap);
DrawImageLattice (image, xDivs, yDivs, dst, paint);
}

public void DrawImageLattice (SKImage image, int[] xDivs, int[] yDivs, SKRect dst, SKPaint paint = null)
Expand All @@ -881,32 +868,8 @@ public void DrawImageLattice (SKImage image, int[] xDivs, int[] yDivs, SKRect ds

public void DrawBitmapLattice (SKBitmap bitmap, SKLattice lattice, SKRect dst, SKPaint paint = null)
{
if (bitmap == null)
throw new ArgumentNullException (nameof (bitmap));
if (lattice.XDivs == null)
throw new ArgumentNullException (nameof (lattice.XDivs));
if (lattice.YDivs == null)
throw new ArgumentNullException (nameof (lattice.YDivs));

fixed (int* x = lattice.XDivs)
fixed (int* y = lattice.YDivs)
fixed (SKLatticeRectType* r = lattice.RectTypes)
fixed (SKColor* c = lattice.Colors) {
var nativeLattice = new SKLatticeInternal {
fBounds = null,
fRectTypes = r,
fXCount = lattice.XDivs.Length,
fXDivs = x,
fYCount = lattice.YDivs.Length,
fYDivs = y,
fColors = (uint*)c,
};
if (lattice.Bounds != null) {
var bounds = lattice.Bounds.Value;
nativeLattice.fBounds = &bounds;
}
SkiaApi.sk_canvas_draw_bitmap_lattice (Handle, bitmap.Handle, &nativeLattice, &dst, paint == null ? IntPtr.Zero : paint.Handle);
}
using var image = SKImage.FromBitmap (bitmap);
DrawImageLattice (image, lattice, dst, paint);
}

public void DrawImageLattice (SKImage image, SKLattice lattice, SKRect dst, SKPaint paint = null)
Expand Down
7 changes: 5 additions & 2 deletions binding/Binding/SKColorSpaceStructs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,13 @@ public unsafe partial struct SKColorSpaceXyz
}
}

public static SKColorSpaceXyz Dcip3 {
[Obsolete ("Use DisplayP3 instead.")]
public static SKColorSpaceXyz Dcip3 => DisplayP3;

public static SKColorSpaceXyz DisplayP3 {
get {
SKColorSpaceXyz xyz;
SkiaApi.sk_colorspace_xyz_named_dcip3 (&xyz);
SkiaApi.sk_colorspace_xyz_named_display_p3 (&xyz);
return xyz;
}
}
Expand Down
18 changes: 14 additions & 4 deletions binding/Binding/SKImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,16 +172,15 @@ public static SKImage FromEncodedData (SKData data, SKRectI subset)
if (data == null)
throw new ArgumentNullException (nameof (data));

var handle = SkiaApi.sk_image_new_from_encoded (data.Handle, &subset);
return GetObject (handle);
return FromEncodedData (data)?.Subset (subset);
}

public static SKImage FromEncodedData (SKData data)
{
if (data == null)
throw new ArgumentNullException (nameof (data));

var handle = SkiaApi.sk_image_new_from_encoded (data.Handle, null);
var handle = SkiaApi.sk_image_new_from_encoded (data.Handle);
return GetObject (handle);
}

Expand Down Expand Up @@ -655,7 +654,18 @@ public SKImage ApplyImageFilter (SKImageFilter filter, SKRectI subset, SKRectI c

fixed (SKRectI* os = &outSubset)
fixed (SKPointI* oo = &outOffset) {
return GetObject (SkiaApi.sk_image_make_with_filter (Handle, filter.Handle, &subset, &clipBounds, os, oo));
return GetObject (SkiaApi.sk_image_make_with_filter_legacy (Handle, filter.Handle, &subset, &clipBounds, os, oo));
}
}

public SKImage ApplyImageFilter (GRContext context, SKImageFilter filter, SKRectI subset, SKRectI clipBounds, out SKRectI outSubset, out SKPointI outOffset)
{
if (filter == null)
throw new ArgumentNullException (nameof (filter));

fixed (SKRectI* os = &outSubset)
fixed (SKPointI* oo = &outOffset) {
return GetObject (SkiaApi.sk_image_make_with_filter (Handle, context?.Handle ?? IntPtr.Zero, filter.Handle, &subset, &clipBounds, os, oo));
}
}

Expand Down
16 changes: 12 additions & 4 deletions binding/Binding/SKPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@

namespace SkiaSharp
{
public enum SKPathConvexity
{
Unknown = 0,
Convex = 1,
Concave = 2,
}

public unsafe class SKPath : SKObject, ISKSkipObjectRegistration
{
internal SKPath (IntPtr handle, bool owns)
Expand Down Expand Up @@ -38,13 +45,14 @@ public SKPath (SKPath path)
}

public SKPathConvexity Convexity {
get => SkiaApi.sk_path_get_convexity (Handle);
set => SkiaApi.sk_path_set_convexity (Handle, value);
get => IsConvex ? SKPathConvexity.Convex : SKPathConvexity.Concave;
[Obsolete]
set { }
}

public bool IsConvex => Convexity == SKPathConvexity.Convex;
public bool IsConvex => SkiaApi.sk_path_is_convex(Handle);

public bool IsConcave => Convexity == SKPathConvexity.Concave;
public bool IsConcave => !IsConvex;

public bool IsEmpty => VerbCount == 0;

Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.