Edit

Share via


SKGLView Class

Definition

A .NET MAUI view that uses GPU acceleration for hardware-accelerated 2D graphics rendering with SkiaSharp.

public class SKGLView : Microsoft.Maui.Controls.View, SkiaSharp.Views.Maui.Controls.ISKGLViewController
public class SKGLView : Microsoft.Maui.Controls.View, SkiaSharp.Views.Maui.ISKGLView
Inheritance
SKGLView
Implements

Remarks

The SKGLView provides a GPU-accelerated drawing surface for SkiaSharp graphics in .NET MAUI applications. This view can provide better performance than the software-rendered SKCanvasView for complex graphics or animations.

The underlying GPU technology varies by platform:

  • Android: OpenGL ES via SKGLTextureView
  • iOS/tvOS: OpenGL ES (deprecated) or Metal on Mac Catalyst
  • Mac Catalyst: Metal via SKMetalView
  • Windows: DirectX via ANGLE using SKSwapChainPanel

Subscribe to the PaintSurface event to draw custom graphics. Set HasRenderLoop to true for continuous rendering (e.g., for animations).

Note: On Windows, the Background property is not supported due to WinUI 3 limitations with SwapChainPanel.

Constructors

Name Description
SKGLView()

Initializes a new instance of the SKGLView class.

Fields

Name Description
EnableTouchEventsProperty

Identifies the EnableTouchEvents bindable property.

HasRenderLoopProperty

Identifies the HasRenderLoop bindable property.

IgnorePixelScalingProperty

Identifies the IgnorePixelScaling bindable property.

Properties

Name Description
CanvasSize

Gets the current size of the canvas in pixels.

EnableTouchEvents

Gets or sets a value indicating whether touch events are enabled for this view.

GRContext

Gets the GPU graphics context used for rendering.

HasRenderLoop

Gets or sets a value indicating whether the view should continuously render frames.

IgnorePixelScaling

Gets or sets a value indicating whether the view should ignore the device's pixel scaling.

Methods

Name Description
InvalidateSurface()

Invalidates the view, causing the PaintSurface event to be raised on the next frame.

OnMeasure(Double, Double)

Called during the measure pass of layout to determine the desired size of the view.

OnPaintSurface(SKPaintGLSurfaceEventArgs)

Raises the PaintSurface event.

OnTouch(SKTouchEventArgs)

Raises the Touch event.

Events

Name Description
PaintSurface

Occurs when the view needs to be painted.

Touch

Occurs when the view receives a touch event.

Explicit Interface Implementations

Name Description
ISKGLView.HasRenderLoop

This member implements HasRenderLoop to provide render loop state.

ISKGLView.OnCanvasSizeChanged(SKSizeI)

This member is used internally by the handler to notify size changes.

ISKGLView.OnGRContextChanged(GRContext)

This member is used internally by the handler to notify context changes.

ISKGLView.OnPaintSurface(SKPaintGLSurfaceEventArgs)

This member is used internally by the handler to trigger painting.

ISKGLView.OnTouch(SKTouchEventArgs)

This member is used internally by the handler to forward touch events.

ISKGLViewController.GetCanvasSize

This member is used internally by the handler to retrieve the canvas size.

ISKGLViewController.GetGRContext

This member is used internally by the handler to retrieve the graphics context.

ISKGLViewController.OnPaintSurface(SKPaintGLSurfaceEventArgs)

This member is used internally by the handler to trigger painting.

ISKGLViewController.OnTouch(SKTouchEventArgs)

This member is used internally by the handler to forward touch events.

ISKGLViewController.SurfaceInvalidated

This member is used internally by the handler to respond to surface invalidation.

Applies to