/// <summary> /// Performs a rendering pass on the specified <see cref="SkiaFrameworkElement"/> and its descendants. /// </summary> /// <param name="element">The element.</param> /// <param name="mode">The mode.</param> protected void RenderSingle(SkiaFrameworkElement element, BindingPropertyMode mode) { SkiaFrameworkElement toRender = element.Parent != null ? element.Parent : element; var bounds = toRender.Bounds; if (mode == BindingPropertyMode.AffectsLayout) { toRender.InvalidateBounds(); if (toRender.Bounds.Contains(bounds)) { bounds = toRender.Bounds; } else { bounds.Width += 1; bounds.Height += 1; } } if (bounds.Left < Source.Width && bounds.Top < Source.Height) { Source.Lock(); T context = CreateDrawingContext(); context.BeginDrawing(); context.ClipRect(bounds, new CornerRadius()); context.Clear(Colors.Transparent); SkiaTree.Root.Invalidate(context, bounds, 1); context.EndDrawing(); if (bounds.Right > Source.Width) { bounds.Width = Source.Width - bounds.Left; } if (bounds.Bottom > Source.Height) { bounds.Height = Source.Height - bounds.Top; } OnRenderCompleted(Source.BackBuffer, (int)Source.Width, (int)Source.Height, (int)Source.Width * 4); Source.AddDirtyRect(new Int32Rect((int)Math.Max(bounds.Left, 0), (int)Math.Max(bounds.Top, 0), (int)bounds.Width, (int)bounds.Height)); Source.Unlock(); } }
/// <summary> /// Performs a full rendering of the current <see cref="SkiaTree"/>. /// </summary> protected void Render() { Source.Lock(); T context = CreateDrawingContext(); context.BeginDrawing(); context.Clear(Colors.Transparent); SkiaTree.Root.Render(context, new Rect(0, 0, _host.ActualWidth, _host.ActualHeight), GetVirtualizedBounds(), 1); context.EndDrawing(); OnRenderCompleted(Source.BackBuffer, (int)Source.Width, (int)Source.Height, (int)Source.Width * 4); Source.AddDirtyRect(new Int32Rect(0, 0, (int)Source.Width, (int)Source.Height)); Source.Unlock(); OnSourceChanged(); }