From dd0480ab34c173027c3bcc639efc927e42700457 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 6 Sep 2022 02:53:13 +0200 Subject: [PATCH] Minor code tweaks in Rectangle64.Intersect --- .../Shaders/Interop/Helpers/Rectangle64.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Helpers/Rectangle64.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Helpers/Rectangle64.cs index 26e7da54..7a87df79 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Helpers/Rectangle64.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Helpers/Rectangle64.cs @@ -112,15 +112,15 @@ internal struct Rectangle64 /// The input instance to compute the intersection with. public void Intersect(Rectangle64 rectangle) { - long maxLeft = Math.Max(this.x, rectangle.x); - long maxTop = Math.Max(this.y, rectangle.y); - long width = Math.Max(Math.Min(this.Right, rectangle.Right) - maxLeft, 0); - long height = Math.Max(Math.Min(this.Bottom, rectangle.Bottom) - maxTop, 0); + long left = Math.Max(this.x, rectangle.x); + long top = Math.Max(this.y, rectangle.y); + long right = Math.Min(this.Right, rectangle.Right); + long bottom = Math.Min(this.Bottom, rectangle.Bottom); - this.x = maxLeft; - this.y = maxTop; - this.width = width; - this.height = height; + this.x = left; + this.y = top; + this.width = Math.Max(right - left, 0); + this.height = Math.Max(bottom - top, 0); } ///