|
|
@@ -21,6 +21,7 @@ namespace Avalonia.Media
|
|
|
AvaloniaProperty.Register<Geometry, Transform?>(nameof(Transform));
|
|
|
|
|
|
private bool _isDirty = true;
|
|
|
+ private bool _canInvaldate = true;
|
|
|
private IGeometryImpl? _platformImpl;
|
|
|
|
|
|
static Geometry()
|
|
|
@@ -30,9 +31,14 @@ namespace Avalonia.Media
|
|
|
|
|
|
internal Geometry()
|
|
|
{
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ private protected Geometry(IGeometryImpl? platformImpl)
|
|
|
+ {
|
|
|
+ _platformImpl = platformImpl;
|
|
|
+ _isDirty = _canInvaldate = false;
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// Raised when the geometry changes.
|
|
|
/// </summary>
|
|
|
@@ -118,6 +124,17 @@ namespace Avalonia.Media
|
|
|
return PlatformImpl?.StrokeContains(pen, point) == true;
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Gets a <see cref="Geometry"/> that is the shape defined by the stroke on the Geometry
|
|
|
+ /// produced by the specified Pen.
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="pen">The pen to use.</param>
|
|
|
+ /// <returns>The outlined geometry.</returns>
|
|
|
+ public Geometry GetWidenedGeometry(IPen pen)
|
|
|
+ {
|
|
|
+ return new ImmutableGeometry(PlatformImpl?.GetWidenedGeometry(pen));
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// Marks a property as affecting the geometry's <see cref="PlatformImpl"/>.
|
|
|
/// </summary>
|
|
|
@@ -146,6 +163,9 @@ namespace Avalonia.Media
|
|
|
/// </summary>
|
|
|
protected void InvalidateGeometry()
|
|
|
{
|
|
|
+ if (!_canInvaldate)
|
|
|
+ return;
|
|
|
+
|
|
|
_isDirty = true;
|
|
|
_platformImpl = null;
|
|
|
Changed?.Invoke(this, EventArgs.Empty);
|