Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions binding/Binding/GRContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ public static GRContext CreateMetal (GRMtlBackendContext backendContext, GRConte

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

public bool IsAbandoned => SkiaApi.gr_context_is_abandoned (Handle);

public void AbandonContext (bool releaseResources = false)
{
if (releaseResources)
Expand Down
16 changes: 16 additions & 0 deletions binding/Binding/SkiaApi.generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,22 @@ internal static void gr_context_get_resource_cache_usage (gr_context_t context,
(gr_context_get_resource_cache_usage_delegate ??= GetSymbol<Delegates.gr_context_get_resource_cache_usage> ("gr_context_get_resource_cache_usage")).Invoke (context, maxResources, maxResourceBytes);
#endif

// bool gr_context_is_abandoned(gr_context_t* context)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs (UnmanagedType.I1)]
internal static extern bool gr_context_is_abandoned (gr_context_t context);
#else
private partial class Delegates {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
[return: MarshalAs (UnmanagedType.I1)]
internal delegate bool gr_context_is_abandoned (gr_context_t context);
}
private static Delegates.gr_context_is_abandoned gr_context_is_abandoned_delegate;
internal static bool gr_context_is_abandoned (gr_context_t context) =>
(gr_context_is_abandoned_delegate ??= GetSymbol<Delegates.gr_context_is_abandoned> ("gr_context_is_abandoned")).Invoke (context);
#endif

// gr_context_t* gr_context_make_gl(const gr_glinterface_t* glInterface)
#if !USE_DELEGATES
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
Expand Down
2 changes: 1 addition & 1 deletion externals/skia
17 changes: 17 additions & 0 deletions tests/Tests/GRContextTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,23 @@ public void CreateDefaultContextIsValid()
}
}

[Trait(CategoryKey, GpuCategory)]
[SkippableFact]
public void AbandonContextIsAbandoned()
{
using (var ctx = CreateGlContext()) {
ctx.MakeCurrent();

var grContext = GRContext.CreateGl();

Assert.False(grContext.IsAbandoned);

grContext.AbandonContext();

Assert.True(grContext.IsAbandoned);
}
}

[Trait(CategoryKey, GpuCategory)]
[SkippableFact]
public void CreateDefaultContextWithOptionsIsValid()
Expand Down