Remove unnecessary uses of System.Drawing primitives.

This commit is contained in:
Paul Chote
2018-12-30 15:41:53 +00:00
parent 00496e2ec2
commit 0b641c20df
4 changed files with 13 additions and 20 deletions

View File

@@ -78,16 +78,6 @@ namespace OpenRA
return val;
}
public static bool Contains(this Rectangle r, int2 p)
{
return r.Contains(p.ToPoint());
}
public static bool Contains(this RectangleF r, int2 p)
{
return r.Contains(p.ToPointF());
}
static int WindingDirectionTest(int2 v0, int2 v1, int2 p)
{
return (v1.X - v0.X) * (p.Y - v0.Y) - (p.X - v0.X) * (v1.Y - v0.Y);

View File

@@ -23,13 +23,8 @@ namespace OpenRA
public readonly float X, Y;
public float2(float x, float y) { X = x; Y = y; }
public float2(PointF p) { X = p.X; Y = p.Y; }
public float2(Point p) { X = p.X; Y = p.Y; }
public float2(Size p) { X = p.Width; Y = p.Height; }
public float2(SizeF p) { X = p.Width; Y = p.Height; }
public PointF ToPointF() { return new PointF(X, Y); }
public SizeF ToSizeF() { return new SizeF(X, Y); }
public float2(int2 p) { X = p.X; Y = p.Y; }
public static implicit operator float2(int2 src) { return new float2(src.X, src.Y); }

View File

@@ -20,7 +20,6 @@ namespace OpenRA
{
public readonly int X, Y;
public int2(int x, int y) { X = x; Y = y; }
public int2(Point p) { X = p.X; Y = p.Y; }
public int2(Size p) { X = p.Width; Y = p.Height; }
public static int2 operator +(int2 a, int2 b) { return new int2(a.X + b.X, a.Y + b.Y); }
@@ -60,8 +59,6 @@ namespace OpenRA
public static int2 Min(int2 a, int2 b) { return new int2(Math.Min(a.X, b.X), Math.Min(a.Y, b.Y)); }
public static readonly int2 Zero = new int2(0, 0);
public Point ToPoint() { return new Point(X, Y); }
public PointF ToPointF() { return new PointF(X, Y); }
public float2 ToFloat2() { return new float2(X, Y); }
// Change endianness of a uint32
@@ -87,5 +84,16 @@ namespace OpenRA
}
public static int Dot(int2 a, int2 b) { return a.X * b.X + a.Y * b.Y; }
// Temporary shims that will be removed when System.Drawing.Rectangle is replaced with our own implementation
public static implicit operator Point(int2 xy)
{
return new Point(xy.X, xy.Y);
}
public static implicit operator int2(Point xy)
{
return new int2(xy.X, xy.Y);
}
}
}

View File

@@ -178,7 +178,7 @@ namespace OpenRA.Mods.Common.Widgets
var drawBounds = backgroundRect.InflateBy(-BorderWidth, -BorderWidth, -BorderWidth, -BorderWidth);
Game.Renderer.EnableScissor(drawBounds);
drawBounds.Offset((-ChildOrigin).ToPoint());
drawBounds.Offset(-ChildOrigin);
foreach (var child in Children)
if (child.Bounds.IntersectsWith(drawBounds))
child.DrawOuter();