|
|
@@ -9,6 +9,7 @@ namespace Avalonia.Rendering.Utilities
|
|
|
{
|
|
|
private readonly Size _imageSize;
|
|
|
private readonly Rect _drawRect;
|
|
|
+ private readonly Vector _dpi;
|
|
|
|
|
|
public bool IsValid { get; }
|
|
|
|
|
|
@@ -18,7 +19,7 @@ namespace Avalonia.Rendering.Utilities
|
|
|
/// <param name="brush">The brush to be rendered.</param>
|
|
|
/// <param name="contentSize">The size of the content of the tile brush.</param>
|
|
|
/// <param name="targetSize">The size of the control to which the brush is being rendered.</param>
|
|
|
- public TileBrushCalculator(ITileBrush brush, Size contentSize, Size targetSize)
|
|
|
+ public TileBrushCalculator(ITileBrush brush, Size contentSize, Size targetSize, Vector dpi)
|
|
|
: this(
|
|
|
brush.TileMode,
|
|
|
brush.Stretch,
|
|
|
@@ -27,7 +28,8 @@ namespace Avalonia.Rendering.Utilities
|
|
|
brush.SourceRect,
|
|
|
brush.DestinationRect,
|
|
|
contentSize,
|
|
|
- targetSize)
|
|
|
+ targetSize,
|
|
|
+ dpi)
|
|
|
{
|
|
|
}
|
|
|
|
|
|
@@ -50,12 +52,14 @@ namespace Avalonia.Rendering.Utilities
|
|
|
RelativeRect sourceRect,
|
|
|
RelativeRect destinationRect,
|
|
|
Size contentSize,
|
|
|
- Size targetSize)
|
|
|
+ Size targetSize,
|
|
|
+ Vector dpi)
|
|
|
{
|
|
|
_imageSize = contentSize;
|
|
|
+ _dpi = dpi;
|
|
|
|
|
|
- SourceRect = sourceRect.ToPixels(_imageSize);
|
|
|
- DestinationRect = destinationRect.ToPixels(targetSize);
|
|
|
+ SourceRect = sourceRect.ToPixels(_imageSize) * (_dpi / 96);
|
|
|
+ DestinationRect = destinationRect.ToPixels(targetSize) * (dpi / 96);
|
|
|
|
|
|
var scale = stretch.CalculateScaling(DestinationRect.Size, SourceRect.Size);
|
|
|
var translate = CalculateTranslate(alignmentX, alignmentY, SourceRect, DestinationRect, scale);
|