Edit

SKGraphiteContext Class

Definition

Represents a Graphite GPU context that owns backend resources and executes recordings against a Dawn, Metal, or Vulkan backend.

public class SKGraphiteContext : SkiaSharp.SKObject
Inheritance
SKGraphiteContext

Examples

using var context = SKGraphiteContext.CreateMetal(backendContext);
using var recorder = context.CreateRecorder();

var info = new SKImageInfo(256, 256);
using var surface = SKSurface.Create(recorder, info);
surface.Canvas.Clear(SKColors.CornflowerBlue);

using var recording = recorder.Snap();
context.InsertRecording(recording);
context.Submit();

Remarks

Create a context from a backend-specific backend context, for example CreateVulkan(SKGraphiteVkBackendContext), CreateMetal(SKGraphiteMtlBackendContext), or CreateDawn(SKGraphiteDawnBackendContext). Create one or more recorders with CreateRecorder(Int64), draw into Graphite-backed surfaces, snap the work into recordings, insert them into the context, and submit.

This type wraps a native Skia resource and implements IDisposable. Dispose it after all its recorders and surfaces have been disposed.

Properties

Name Description
Backend

Gets the graphics backend that this context uses.

CurrentBudgetedBytes

Gets the number of bytes of GPU memory currently used by budgeted resources.

Handle

Gets or sets the handle to the underlying native object.

(Inherited from SKObject)
IgnorePublicDispose

Gets a value indicating whether the call the public Dispose() should be no-op.

(Inherited from SKNativeObject)
IsDeviceLost

Gets a value indicating whether the underlying GPU device has been lost.

IsDisposed

Gets a value indicating whether the object has already been disposed.

(Inherited from SKNativeObject)
MaxBudgetedBytes

Gets or sets the maximum number of bytes of GPU memory the resource cache may use.

MaxTextureSize

Gets the maximum texture dimension supported by the context's backend, in pixels.

OwnsHandle

Gets or sets a value indicating whether this object owns its handle and should destroy the native object when it is disposed.

(Inherited from SKNativeObject)
SupportsProtectedContent

Gets a value indicating whether the context supports protected content.

Methods

Name Description
CheckAsyncWorkCompletion()

Checks for and processes any completed asynchronous GPU work, invoking pending callbacks.

CreateDawn(SKGraphiteDawnBackendContext, SKGraphiteContextOptions)

Creates a Dawn (WebGPU) backed Graphite context using the specified options.

CreateDawn(SKGraphiteDawnBackendContext)

Creates a Dawn (WebGPU) backed Graphite context using the default options.

CreateMetal(SKGraphiteMtlBackendContext, SKGraphiteContextOptions)

Creates a Metal-backed Graphite context using the specified options.

CreateMetal(SKGraphiteMtlBackendContext)

Creates a Metal-backed Graphite context using the default options.

CreateRecorder(Int64, SKGraphiteFindOrCreateImageDelegate, Action)

Creates a new recorder associated with this context, using the specified callback to provide Graphite-backed images.

CreateRecorder(Int64)

Creates a new recorder associated with this context.

CreateVulkan(SKGraphiteVkBackendContext, SKGraphiteContextOptions)

Creates a Vulkan-backed Graphite context using the specified options.

CreateVulkan(SKGraphiteVkBackendContext)

Creates a Vulkan-backed Graphite context using the default options.

DeleteBackendTexture(SKGraphiteBackendTexture)

Deletes a backend texture that was created by this context.

Dispose()

Releases all resources used by this SKNativeObject.

(Inherited from SKNativeObject)
Dispose(Boolean)

Releases the unmanaged resources used by the SKObject and optionally releases the managed resources.

(Inherited from SKObject)
DisposeInternal()

Triggers a dispose, ignoring the value of IgnorePublicDispose.

(Inherited from SKNativeObject)
DisposeManaged()

Implemented by derived SKObject types to destroy any managed objects.

(Inherited from SKObject)
DisposeNative()

Releases the native resources used by the context.

DisposeUnownedManaged()

Implemented by derived SKObject types to dispose managed objects that are not owned by this instance.

(Inherited from SKObject)
FreeGpuResources()

Frees GPU resources held by the context's resource cache.

InsertRecording(SKGraphiteInsertRecordingInfo)

Inserts a recording into the context using the specified insertion parameters.

InsertRecording(SKGraphiteRecording)

Inserts a recording into the context so its commands are executed on the next submit.

IsBackendAvailable(SKGraphiteBackend)

Determines whether the specified Graphite backend is available in this build of SkiaSharp.

PerformDeferredCleanup(TimeSpan)

Purges GPU resources that have not been used for at least the specified duration.

RequestReadPixels(SKSurface, SKImageInfo, SKRectI, Action<SKImageReadPixelsResult>)

Asynchronously reads pixels from the specified surface into a result delivered to a callback, using nearest sampling.

RequestReadPixels(SKSurface, SKImageInfo, SKRectI, SKImageRescaleGamma, SKImageRescaleMode, Action<SKImageReadPixelsResult>)

Asynchronously reads and rescales pixels from the specified surface into a result delivered to a callback.

Submit()

Submits all inserted recordings to the GPU without waiting for completion.

Submit(SKGraphiteSubmitInfo)

Submits all inserted recordings to the GPU using the specified submission options.

Applies to