Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tile mode used in SkShader for a TileBrush with None TileMode #16021

Merged
merged 2 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Skia/Avalonia.Skia/DrawingContextImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1072,14 +1072,14 @@ private void ConfigureTileBrush(ref PaintWrapper paintWrapper, Rect targetBox, I

SKShaderTileMode tileX =
tileBrush.TileMode == TileMode.None
? SKShaderTileMode.Clamp
? SKShaderTileMode.Decal
: tileBrush.TileMode == TileMode.FlipX || tileBrush.TileMode == TileMode.FlipXY
? SKShaderTileMode.Mirror
: SKShaderTileMode.Repeat;

SKShaderTileMode tileY =
tileBrush.TileMode == TileMode.None
? SKShaderTileMode.Clamp
? SKShaderTileMode.Decal
: tileBrush.TileMode == TileMode.FlipY || tileBrush.TileMode == TileMode.FlipXY
? SKShaderTileMode.Mirror
: SKShaderTileMode.Repeat;
Expand Down Expand Up @@ -1225,14 +1225,14 @@ private void ConfigureSceneBrushContentWithPicture(ref PaintWrapper paintWrapper

SKShaderTileMode tileX =
tileBrush.TileMode == TileMode.None
? SKShaderTileMode.Clamp
? SKShaderTileMode.Decal
: tileBrush.TileMode == TileMode.FlipX || tileBrush.TileMode == TileMode.FlipXY
? SKShaderTileMode.Mirror
: SKShaderTileMode.Repeat;

SKShaderTileMode tileY =
tileBrush.TileMode == TileMode.None
? SKShaderTileMode.Clamp
? SKShaderTileMode.Decal
: tileBrush.TileMode == TileMode.FlipY || tileBrush.TileMode == TileMode.FlipXY
? SKShaderTileMode.Mirror
: SKShaderTileMode.Repeat;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,38 @@ public void Should_Render_Aligned_TileBrush()

}

[CrossFact]
public void Should_Render_TileBrush_With_TileMode_None()
{
var brush = new CrossDrawingBrush
{
TileMode = TileMode.None,
Stretch = Stretch.Fill,
Viewbox = new Rect(0, 0, 50, 50),
ViewboxUnits = BrushMappingMode.Absolute,
Viewport = new Rect(0, 0, 50, 50),
ViewportUnits = BrushMappingMode.Absolute,
Drawing = new CrossDrawingGroup()
{
Children = new List<CrossDrawing>()
{
new CrossGeometryDrawing(new CrossRectangleGeometry(new(0, 0, 50, 50)))
{
Brush = new CrossSolidColorBrush(Colors.Crimson)
},
}
}
};

RenderAndCompare(new CrossControl()
{
Width = 200,
Height = 200,
Background = brush
});

}

[CrossFact]
public void Should_Render_With_Transform()
{
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading