Jumar Macato
5 years ago
No known key found for this signature in database
GPG Key ID: B19884DAC3A5BF3F
6 changed files with
61 additions and
0 deletions
-
src/Avalonia.Headless/HeadlessPlatformRenderInterface.cs
-
src/Avalonia.Visuals/Platform/IGeometryImpl.cs
-
src/Skia/Avalonia.Skia/GeometryImpl.cs
-
src/Windows/Avalonia.Direct2D1/Media/GeometryImpl.cs
-
tests/Avalonia.UnitTests/MockStreamGeometryImpl.cs
-
tests/Avalonia.Visuals.UnitTests/VisualTree/MockRenderInterface.cs
|
|
@ -142,6 +142,12 @@ namespace Avalonia.Headless |
|
|
tangent = new Point(); |
|
|
tangent = new Point(); |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public bool TryGetSegment(float startDistance, float stopDistance, bool startOnBeginFigure, out IGeometryImpl segmentGeometry) |
|
|
|
|
|
{ |
|
|
|
|
|
segmentGeometry = null; |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
class HeadlessTransformedGeometryStub : HeadlessGeometryStub, ITransformedGeometryImpl |
|
|
class HeadlessTransformedGeometryStub : HeadlessGeometryStub, ITransformedGeometryImpl |
|
|
|
|
|
@ -73,5 +73,18 @@ namespace Avalonia.Platform |
|
|
/// <param name="tangent">The tangent in the specified distance.</param>
|
|
|
/// <param name="tangent">The tangent in the specified distance.</param>
|
|
|
/// <returns>If there's valid point and tangent at the specified distance.</returns>
|
|
|
/// <returns>If there's valid point and tangent at the specified distance.</returns>
|
|
|
bool TryGetPointAndTangentAtDistance(double distance, out Point point, out Point tangent); |
|
|
bool TryGetPointAndTangentAtDistance(double distance, out Point point, out Point tangent); |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Attempts to get the corresponding path segment
|
|
|
|
|
|
/// given by the two distances specified.
|
|
|
|
|
|
/// Imagine it like snipping a part of the current
|
|
|
|
|
|
/// geometry.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="startDistance">The contour distance to start snipping from.</param>
|
|
|
|
|
|
/// <param name="stopDistance">The contour distance to stop snipping to.</param>
|
|
|
|
|
|
/// <param name="startOnBeginFigure">If ture, the resulting snipped path will start with a BeginFigure call.</param>
|
|
|
|
|
|
/// <param name="segmentGeometry">The resulting snipped path.</param>
|
|
|
|
|
|
/// <returns>If the snipping operation is successful.</returns>
|
|
|
|
|
|
bool TryGetSegment (float startDistance, float stopDistance, bool startOnBeginFigure, out IGeometryImpl segmentGeometry); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
@ -138,6 +138,28 @@ namespace Avalonia.Skia |
|
|
return res; |
|
|
return res; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public bool TryGetSegment(float startDistance, float stopDistance, bool startOnBeginFigure, out IGeometryImpl segmentGeometry) |
|
|
|
|
|
{ |
|
|
|
|
|
if (_pathCache.CachePathMeasure is null) |
|
|
|
|
|
{ |
|
|
|
|
|
segmentGeometry = null; |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
segmentGeometry = null; |
|
|
|
|
|
|
|
|
|
|
|
SKPath _skPathSegment = null; |
|
|
|
|
|
|
|
|
|
|
|
var res = _pathCache.CachePathMeasure.GetSegment(startDistance, stopDistance, _skPathSegment, startOnBeginFigure); |
|
|
|
|
|
|
|
|
|
|
|
if (res) |
|
|
|
|
|
{ |
|
|
|
|
|
segmentGeometry = new StreamGeometryImpl(_skPathSegment); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return res; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Invalidate all caches. Call after chaining path contents.
|
|
|
/// Invalidate all caches. Call after chaining path contents.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
|
|
|
@ -82,6 +82,15 @@ namespace Avalonia.Direct2D1.Media |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public bool TryGetSegment(float startDistance, float stopDistance, bool startOnBeginFigure, out IGeometryImpl segmentGeometry) |
|
|
|
|
|
{ |
|
|
|
|
|
// Direct2D doesnt have this too sadly.
|
|
|
|
|
|
Logger.TryGet(LogEventLevel.Warning, LogArea.Visual)?.Log(this, "TryGetSegment is not available in Direct2D."); |
|
|
|
|
|
|
|
|
|
|
|
segmentGeometry = null; |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
protected virtual Geometry GetSourceGeometry() => Geometry; |
|
|
protected virtual Geometry GetSourceGeometry() => Geometry; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
@ -84,6 +84,12 @@ namespace Avalonia.UnitTests |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public bool TryGetSegment(float startDistance, float stopDistance, bool startOnBeginFigure, out IGeometryImpl segmentGeometry) |
|
|
|
|
|
{ |
|
|
|
|
|
segmentGeometry = null; |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
class MockStreamGeometryContext : IStreamGeometryContextImpl |
|
|
class MockStreamGeometryContext : IStreamGeometryContextImpl |
|
|
{ |
|
|
{ |
|
|
private List<Point> points = new List<Point>(); |
|
|
private List<Point> points = new List<Point>(); |
|
|
|
|
|
@ -163,6 +163,11 @@ namespace Avalonia.Visuals.UnitTests.VisualTree |
|
|
throw new NotImplementedException(); |
|
|
throw new NotImplementedException(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public bool TryGetSegment(float startDistance, float stopDistance, bool startOnBeginFigure, out IGeometryImpl segmentGeometry) |
|
|
|
|
|
{ |
|
|
|
|
|
throw new NotImplementedException(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
class MockStreamGeometryContext : IStreamGeometryContextImpl |
|
|
class MockStreamGeometryContext : IStreamGeometryContextImpl |
|
|
{ |
|
|
{ |
|
|
private List<Point> points = new List<Point>(); |
|
|
private List<Point> points = new List<Point>(); |
|
|
|