Browse Source

Remove Rect.operator*

It was wrong - use Rect.TransformToAABB instead.
Steven Kirk 8 years ago
parent
commit
99c1df0da0

+ 1 - 1
src/Avalonia.Controls/Presenters/ScrollContentPresenter.cs

@@ -133,7 +133,7 @@ namespace Avalonia.Controls.Presenters
                 return false;
                 return false;
             }
             }
 
 
-            var rect = targetRect * transform.Value;
+            var rect = targetRect.TransformToAABB(transform.Value);
             var offset = Offset;
             var offset = Offset;
             var result = false;
             var result = false;
 
 

+ 1 - 12
src/Avalonia.Visuals/Rect.cs

@@ -183,7 +183,7 @@ namespace Avalonia
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// Multiplies a rectangle by a vector.
+        /// Multiplies a rectangle by a scaling vector.
         /// </summary>
         /// </summary>
         /// <param name="rect">The rectangle.</param>
         /// <param name="rect">The rectangle.</param>
         /// <param name="scale">The vector scale.</param>
         /// <param name="scale">The vector scale.</param>
@@ -197,17 +197,6 @@ namespace Avalonia
                 rect.Height * scale.Y);
                 rect.Height * scale.Y);
         }
         }
 
 
-        /// <summary>
-        /// Transforms a rectangle by a matrix and returns the axis-aligned bounding box.
-        /// </summary>
-        /// <param name="rect">The rectangle.</param>
-        /// <param name="matrix">The matrix.</param>
-        /// <returns>The axis-aligned bounding box.</returns>
-        public static Rect operator *(Rect rect, Matrix matrix)
-        {
-            return new Rect(rect.TopLeft * matrix, rect.BottomRight * matrix);
-        }
-
         /// <summary>
         /// <summary>
         /// Divides a rectangle by a vector.
         /// Divides a rectangle by a vector.
         /// </summary>
         /// </summary>

+ 1 - 1
src/Avalonia.Visuals/Rendering/SceneGraph/GeometryNode.cs

@@ -11,7 +11,7 @@ namespace Avalonia.Rendering.SceneGraph
     {
     {
         public GeometryNode(Matrix transform, IBrush brush, Pen pen, IGeometryImpl geometry)
         public GeometryNode(Matrix transform, IBrush brush, Pen pen, IGeometryImpl geometry)
         {
         {
-            Bounds = geometry.Bounds * transform;
+            Bounds = geometry.Bounds.TransformToAABB(transform);
             Transform = transform;
             Transform = transform;
             Brush = brush;
             Brush = brush;
             Pen = pen;
             Pen = pen;

+ 1 - 1
src/Avalonia.Visuals/Rendering/SceneGraph/ImageNode.cs

@@ -11,7 +11,7 @@ namespace Avalonia.Rendering.SceneGraph
     {
     {
         public ImageNode(Matrix transform, IBitmapImpl source, double opacity, Rect sourceRect, Rect destRect)
         public ImageNode(Matrix transform, IBitmapImpl source, double opacity, Rect sourceRect, Rect destRect)
         {
         {
-            Bounds = destRect * transform;
+            Bounds = destRect.TransformToAABB(transform);
             Transform = transform;
             Transform = transform;
             Source = source;
             Source = source;
             Opacity = opacity;
             Opacity = opacity;

+ 1 - 1
src/Avalonia.Visuals/Rendering/SceneGraph/RectangleNode.cs

@@ -10,7 +10,7 @@ namespace Avalonia.Rendering.SceneGraph
     {
     {
         public RectangleNode(Matrix transform, IBrush brush, Pen pen, Rect rect, float cornerRadius)
         public RectangleNode(Matrix transform, IBrush brush, Pen pen, Rect rect, float cornerRadius)
         {
         {
-            Bounds = (rect * transform).Inflate(pen?.Thickness ?? 0);
+            Bounds = rect.TransformToAABB(transform).Inflate(pen?.Thickness ?? 0);
             Transform = transform;
             Transform = transform;
             Brush = brush;
             Brush = brush;
             Pen = pen;
             Pen = pen;

+ 1 - 1
src/Avalonia.Visuals/Rendering/SceneGraph/SceneBuilder.cs

@@ -155,7 +155,7 @@ namespace Avalonia.Rendering.SceneGraph
                     forceRecurse = forceRecurse || node.Transform != contextImpl.Transform;
                     forceRecurse = forceRecurse || node.Transform != contextImpl.Transform;
 
 
                     node.Transform = contextImpl.Transform;
                     node.Transform = contextImpl.Transform;
-                    node.ClipBounds = (bounds * node.Transform).Intersect(clip);
+                    node.ClipBounds = bounds.TransformToAABB(node.Transform).Intersect(clip);
                     node.ClipToBounds = clipToBounds;
                     node.ClipToBounds = clipToBounds;
                     node.GeometryClip = visual.Clip;
                     node.GeometryClip = visual.Clip;
                     node.Opacity = opacity;
                     node.Opacity = opacity;

+ 1 - 1
src/Avalonia.Visuals/Rendering/SceneGraph/TextNode.cs

@@ -11,7 +11,7 @@ namespace Avalonia.Rendering.SceneGraph
     {
     {
         public TextNode(Matrix transform, IBrush foreground, Point origin, IFormattedTextImpl text)
         public TextNode(Matrix transform, IBrush foreground, Point origin, IFormattedTextImpl text)
         {
         {
-            Bounds = new Rect(origin, text.Size) * transform;
+            Bounds = new Rect(origin, text.Size).TransformToAABB(transform);
             Transform = transform;
             Transform = transform;
             Foreground = foreground;
             Foreground = foreground;
             Origin = origin;
             Origin = origin;