Browse Source
Merge pull request #2349 from MarchingCube/feature/fix-skia-0px-stroke
Fix Skia rendering hairline width strokes when Pen thickness is 0.
pull/2353/head
Steven Kirk
8 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
27 additions and
1 deletions
-
src/Skia/Avalonia.Skia/DrawingContextImpl.cs
-
tests/Avalonia.RenderTests/Shapes/RectangleTests.cs
-
BIN
tests/TestFiles/Direct2D1/Shapes/Rectangle/Rectangle_0px_Stroke.expected.png
-
BIN
tests/TestFiles/Skia/Shapes/Rectangle/Rectangle_0px_Stroke.expected.png
|
|
@ -501,7 +501,6 @@ namespace Avalonia.Skia |
|
|
{ |
|
|
{ |
|
|
var paint = new SKPaint |
|
|
var paint = new SKPaint |
|
|
{ |
|
|
{ |
|
|
IsStroke = false, |
|
|
|
|
|
IsAntialias = true |
|
|
IsAntialias = true |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
@ -558,6 +557,13 @@ namespace Avalonia.Skia |
|
|
/// <returns></returns>
|
|
|
/// <returns></returns>
|
|
|
private PaintWrapper CreatePaint(Pen pen, Size targetSize) |
|
|
private PaintWrapper CreatePaint(Pen pen, Size targetSize) |
|
|
{ |
|
|
{ |
|
|
|
|
|
// In Skia 0 thickness means - use hairline rendering
|
|
|
|
|
|
// and for us it means - there is nothing rendered.
|
|
|
|
|
|
if (pen.Thickness == 0d) |
|
|
|
|
|
{ |
|
|
|
|
|
return default; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
var rv = CreatePaint(pen.Brush, targetSize); |
|
|
var rv = CreatePaint(pen.Brush, targetSize); |
|
|
var paint = rv.Paint; |
|
|
var paint = rv.Paint; |
|
|
|
|
|
|
|
|
|
|
|
@ -20,6 +20,26 @@ namespace Avalonia.Direct2D1.RenderTests.Shapes |
|
|
{ |
|
|
{ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Fact] |
|
|
|
|
|
public async Task Rectangle_0px_Stroke() |
|
|
|
|
|
{ |
|
|
|
|
|
Decorator target = new Decorator |
|
|
|
|
|
{ |
|
|
|
|
|
Padding = new Thickness(8), |
|
|
|
|
|
Width = 200, |
|
|
|
|
|
Height = 200, |
|
|
|
|
|
Child = new Rectangle |
|
|
|
|
|
{ |
|
|
|
|
|
Fill = Brushes.Transparent, |
|
|
|
|
|
Stroke = Brushes.Black, |
|
|
|
|
|
StrokeThickness = 0 |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
await RenderToFile(target); |
|
|
|
|
|
CompareImages(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
[Fact] |
|
|
[Fact] |
|
|
public async Task Rectangle_1px_Stroke() |
|
|
public async Task Rectangle_1px_Stroke() |
|
|
{ |
|
|
{ |
|
|
|
Width:
|
Height:
|
Size: 610 B
|
Width:
|
Height:
|
Size: 610 B
|