Skip to content

Commit

Permalink
Fix tile mode used in SkShader for a TileBrush with None TileMode (#1…
Browse files Browse the repository at this point in the history
…6021)

* add cross test for tile brush with None tile mode

* use Decal skshader tile mode for tile brush tilemode None
  • Loading branch information
emmauss authored Jun 13, 2024
1 parent eb4f575 commit e8c3bf5
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
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.

0 comments on commit e8c3bf5

Please sign in to comment.