Skip to content

Commit

Permalink
Fix transforms
Browse files Browse the repository at this point in the history
  • Loading branch information
wieslawsoltes committed Aug 29, 2024
1 parent a477078 commit 224c822
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/Avalonia.Controls.Skia/SKBitmapControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public override void Render(DrawingContext context)
}

using (context.PushClip(destRect))
using (context.PushTransform(translateMatrix * scaleMatrix))
using (context.PushTransform(scaleMatrix * translateMatrix))
{
context.Custom(new SKBitmapDrawOperation(new Rect(0, 0, bounds.Width, bounds.Height), bitmap));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Avalonia.Controls.Skia/SKBitmapImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void IImage.Draw(DrawingContext context, Rect sourceRect, Rect destRect)
var scaleMatrix = Matrix.CreateScale(destRect.Width / sourceRect.Width, destRect.Height / sourceRect.Height);
var translateMatrix = Matrix.CreateTranslation(-sourceRect.X + destRect.X - bounds.Top, -sourceRect.Y + destRect.Y - bounds.Left);
using (context.PushClip(destRect))
using (context.PushTransform(translateMatrix * scaleMatrix))
using (context.PushTransform(scaleMatrix * translateMatrix))
{
context.Custom(new SKBitmapDrawOperation(new Rect(0, 0, bounds.Width, bounds.Height), source));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Avalonia.Controls.Skia/SKPathControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public override void Render(DrawingContext context)
}

using (context.PushClip(destRect))
using (context.PushTransform(translateMatrix * scaleMatrix))
using (context.PushTransform(scaleMatrix * translateMatrix))
{
context.Custom(
new SKPathDrawOperation(
Expand Down
2 changes: 1 addition & 1 deletion src/Avalonia.Controls.Skia/SKPathImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void IImage.Draw(DrawingContext context, Rect sourceRect, Rect destRect)
var scaleMatrix = Matrix.CreateScale(destRect.Width / sourceRect.Width, destRect.Height / sourceRect.Height);
var translateMatrix = Matrix.CreateTranslation(-sourceRect.X + destRect.X - bounds.Top, -sourceRect.Y + destRect.Y - bounds.Left);
using (context.PushClip(destRect))
using (context.PushTransform(translateMatrix * scaleMatrix))
using (context.PushTransform(scaleMatrix * translateMatrix))
{
context.Custom(new SKPathDrawOperation(new Rect(0, 0, bounds.Width, bounds.Height), source, paint));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Avalonia.Controls.Skia/SKPictureControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public override void Render(DrawingContext context)
}

using (context.PushClip(destRect))
using (context.PushTransform(translateMatrix * scaleMatrix))
using (context.PushTransform(scaleMatrix * translateMatrix))
{
context.Custom(
new SKPictureDrawOperation(
Expand Down
2 changes: 1 addition & 1 deletion src/Avalonia.Controls.Skia/SKPictureImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void IImage.Draw(DrawingContext context, Rect sourceRect, Rect destRect)
var scaleMatrix = Matrix.CreateScale(destRect.Width / sourceRect.Width, destRect.Height / sourceRect.Height);
var translateMatrix = Matrix.CreateTranslation(-sourceRect.X + destRect.X - bounds.Top, -sourceRect.Y + destRect.Y - bounds.Left);
using (context.PushClip(destRect))
using (context.PushTransform(translateMatrix * scaleMatrix))
using (context.PushTransform(scaleMatrix * translateMatrix))
{
context.Custom(new SKPictureDrawOperation(new Rect(0, 0, bounds.Width, bounds.Height), source));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Avalonia.Svg.Skia/Svg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public override void Render(DrawingContext context)
-sourceRect.Y + destRect.Y - bounds.Left);

using (context.PushClip(destRect))
using (context.PushTransform(translateMatrix * scaleMatrix))
using (context.PushTransform(scaleMatrix * translateMatrix))
{
context.Custom(
new SvgSourceCustomDrawOperation(
Expand Down
2 changes: 1 addition & 1 deletion src/Avalonia.Svg/Svg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public override void Render(DrawingContext context)
-sourceRect.Y + destRect.Y - bounds.Left);

using (context.PushClip(destRect))
using (context.PushTransform(translateMatrix * scaleMatrix))
using (context.PushTransform(scaleMatrix * translateMatrix))
{
if (_avaloniaPicture is { })
{
Expand Down
2 changes: 1 addition & 1 deletion src/Avalonia.Svg/SvgImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void IImage.Draw(
-sourceRect.X + destRect.X - bounds.Top,
-sourceRect.Y + destRect.Y - bounds.Left);
using (context.PushClip(destRect))
using (context.PushTransform(translateMatrix * scaleMatrix))
using (context.PushTransform(scaleMatrix * translateMatrix))
{
try
{
Expand Down

0 comments on commit 224c822

Please sign in to comment.