diff --git a/src/Avalonia.Controls/Presenters/ContentPresenter.cs b/src/Avalonia.Controls/Presenters/ContentPresenter.cs
index f75184c686..eeed2c6812 100644
--- a/src/Avalonia.Controls/Presenters/ContentPresenter.cs
+++ b/src/Avalonia.Controls/Presenters/ContentPresenter.cs
@@ -2,12 +2,11 @@ using System;
using Avalonia.Controls.Primitives;
using Avalonia.Controls.Templates;
using Avalonia.Controls.Utils;
-using Avalonia.Data;
-using Avalonia.Input;
using Avalonia.Layout;
using Avalonia.LogicalTree;
using Avalonia.Media;
using Avalonia.Metadata;
+using Avalonia.Utilities;
namespace Avalonia.Controls.Presenters
{
@@ -391,8 +390,8 @@ namespace Avalonia.Controls.Presenters
if (useLayoutRounding)
{
- originX = LayoutHelper.RoundLayoutValue(originX, scale);
- originY = LayoutHelper.RoundLayoutValue(originY, scale);
+ originX = MathUtilities.RoundLayoutValue(originX, scale);
+ originY = MathUtilities.RoundLayoutValue(originY, scale);
}
var boundsForChild =
diff --git a/src/Avalonia.Layout/LayoutHelper.cs b/src/Avalonia.Layout/LayoutHelper.cs
index d8fa00deb7..d5215b6b69 100644
--- a/src/Avalonia.Layout/LayoutHelper.cs
+++ b/src/Avalonia.Layout/LayoutHelper.cs
@@ -98,48 +98,11 @@ namespace Avalonia.Layout
///
public static Size RoundLayoutSize(Size size, double dpiScaleX, double dpiScaleY)
{
- return new Size(RoundLayoutValue(size.Width, dpiScaleX), RoundLayoutValue(size.Height, dpiScaleY));
+ var width = MathUtilities.RoundLayoutValue(size.Width, dpiScaleX);
+ var height = MathUtilities.RoundLayoutValue(size.Height, dpiScaleY);
+ return new Size(width, height);
}
- ///
- /// Calculates the value to be used for layout rounding at high DPI.
- ///
- /// Input value to be rounded.
- /// Ratio of screen's DPI to layout DPI
- /// Adjusted value that will produce layout rounding on screen at high dpi.
- ///
- /// This is a layout helper method. It takes DPI into account and also does not return
- /// the rounded value if it is unacceptable for layout, e.g. Infinity or NaN. It's a helper
- /// associated with the UseLayoutRounding property and should not be used as a general rounding
- /// utility.
- ///
- public static double RoundLayoutValue(double value, double dpiScale)
- {
- double newValue;
-
- // If DPI == 1, don't use DPI-aware rounding.
- if (!MathUtilities.AreClose(dpiScale, 1.0))
- {
- newValue = Math.Round(value * dpiScale) / dpiScale;
-
- // If rounding produces a value unacceptable to layout (NaN, Infinity or MaxValue),
- // use the original value.
- if (double.IsNaN(newValue) ||
- double.IsInfinity(newValue) ||
- MathUtilities.AreClose(newValue, double.MaxValue))
- {
- newValue = value;
- }
- }
- else
- {
- newValue = Math.Round(value);
- }
-
- return newValue;
- }
-
-
///
/// Calculates the min and max height for a control. Ported from WPF.
///
diff --git a/src/Avalonia.Layout/Layoutable.cs b/src/Avalonia.Layout/Layoutable.cs
index ce5200f4a4..d8bb0e864d 100644
--- a/src/Avalonia.Layout/Layoutable.cs
+++ b/src/Avalonia.Layout/Layoutable.cs
@@ -546,8 +546,8 @@ namespace Avalonia.Layout
if (UseLayoutRounding)
{
var scale = GetLayoutScale();
- width = LayoutHelper.RoundLayoutValue(width, scale);
- height = LayoutHelper.RoundLayoutValue(height, scale);
+ width = MathUtilities.RoundLayoutValue(width, scale);
+ height = MathUtilities.RoundLayoutValue(height, scale);
}
return NonNegative(new Size(width, height).Inflate(margin));
@@ -654,8 +654,8 @@ namespace Avalonia.Layout
if (useLayoutRounding)
{
- originX = LayoutHelper.RoundLayoutValue(originX, scale);
- originY = LayoutHelper.RoundLayoutValue(originY, scale);
+ originX = MathUtilities.RoundLayoutValue(originX, scale);
+ originY = MathUtilities.RoundLayoutValue(originY, scale);
}
Bounds = new Rect(originX, originY, size.Width, size.Height);