17 private readonly SKPaint _paint =
new()
20 FilterQuality = SKFilterQuality.Medium,
21 BlendMode = SKBlendMode.SrcOver
24 private SKBitmap? _cachedBitmap;
25 private int _cachedWidth;
26 private int _cachedHeight;
33 Rectangle? screenBounds,
34 Rectangle? worldBounds,
35 string? nickname =
null)
36 : base(renderSurfaceHost, mode, sceneLayer, view, screenBounds, worldBounds, nickname)
38 _svgResource = svgResource ??
throw new ArgumentNullException(nameof(svgResource));
52 Rectangle worldBounds,
53 string? nickname =
null)
68 Rectangle screenBounds,
69 string? nickname =
null)
70 : this(svgResource, renderSurfaceHost,
DirectDrawingMode.
View, null, view, screenBounds, null, nickname)
80 _paint.FilterQuality = quality;
88 int width = Math.Max(1, (
int)MathF.Round(destRectScreen.Width));
89 int height = Math.Max(1, (
int)MathF.Round(destRectScreen.Height));
91 if (_cachedBitmap is
null || _cachedWidth != width || _cachedHeight != height)
93 _cachedBitmap = _svgResource.Rasterize(width, height);
95 _cachedHeight = height;
98 backbuffer.
Canvas.DrawBitmap(_cachedBitmap, destRectScreen.ToPixelAlignedRect().ToSKRect(), _paint);
102 protected override void Dispose(
bool disposing)
107 _cachedBitmap =
null;
111 base.Dispose(disposing);
View? View
Gets the view to which this direct drawing is attached, or null if the drawing is in scene-layer mode...
SceneLayer? SceneLayer
Gets the scene layer to which this direct drawing is attached, or null if the drawing is in view mode...
DirectDrawingMovableBase(RenderSurfaceHostBase renderSurfaceHost, DirectDrawingMode mode, SceneLayer? sceneLayer, View? view, Rectangle? screenBounds, Rectangle? worldBounds, string? name=null)
Initializes a new instance of the DirectDrawingMovableBase class with integrated movement capabilitie...
DirectSvg SetFilterQuality(SKFilterQuality quality)
Sets the filter quality used when drawing the cached SVG bitmap.
DirectSvg(SvgResource svgResource, RenderSurfaceHostBase renderSurfaceHost, SceneLayer sceneLayer, Rectangle worldBounds, string? nickname=null)
Initializes a new world-space DirectSvg.
override void OnDraw(BackbufferBase backbuffer, RectangleF destRectScreen)
override void Dispose(bool disposing)
Releases resources used by this DirectDrawingBase instance.When disposing is true,...
DirectSvg(SvgResource svgResource, RenderSurfaceHostBase renderSurfaceHost, View view, Rectangle screenBounds, string? nickname=null)
Initializes a new screen-space DirectSvg.
Represents a loaded SVG asset that can be rasterized into cached bitmaps at requested sizes.
Represents a base class for managing a graphical backbuffer, and is the in-memory surface where rende...
SKCanvas Canvas
Gets the SkiaSharp canvas used for drawing operations on this backbuffer.
Represents a base class for hosting a render surface, providing functionality for managing rendering ...
DirectDrawingMode
Specifies where direct drawing operations are applied within the rendering pipeline.