2020-04-22 04:10:27 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Runtime.InteropServices;
|
2019-09-19 00:45:11 +00:00
|
|
|
|
|
2019-11-03 17:26:29 +00:00
|
|
|
|
namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
2019-09-19 00:45:11 +00:00
|
|
|
|
{
|
|
|
|
|
[StructLayout(LayoutKind.Sequential, Size = 0x10)]
|
2020-04-22 04:10:27 +00:00
|
|
|
|
struct Rect : IEquatable<Rect>
|
2019-09-19 00:45:11 +00:00
|
|
|
|
{
|
|
|
|
|
public int Left;
|
2020-04-22 04:10:27 +00:00
|
|
|
|
public int Top;
|
2019-09-19 00:45:11 +00:00
|
|
|
|
public int Right;
|
|
|
|
|
public int Bottom;
|
2020-04-22 04:10:27 +00:00
|
|
|
|
|
|
|
|
|
public int Width => Right - Left;
|
|
|
|
|
public int Height => Bottom - Top;
|
|
|
|
|
|
|
|
|
|
public Rect(int width, int height)
|
|
|
|
|
{
|
|
|
|
|
Left = 0;
|
|
|
|
|
Top = 0;
|
|
|
|
|
Right = width;
|
|
|
|
|
Bottom = height;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsEmpty()
|
|
|
|
|
{
|
|
|
|
|
return Width <= 0 || Height <= 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool Intersect(Rect other, out Rect result)
|
|
|
|
|
{
|
|
|
|
|
result = new Rect
|
|
|
|
|
{
|
|
|
|
|
Left = Math.Max(Left, other.Left),
|
|
|
|
|
Top = Math.Max(Top, other.Top),
|
|
|
|
|
Right = Math.Min(Right, other.Right),
|
|
|
|
|
Bottom = Math.Min(Bottom, other.Bottom)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return !result.IsEmpty();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void MakeInvalid()
|
|
|
|
|
{
|
|
|
|
|
Right = -1;
|
|
|
|
|
Bottom = -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static bool operator ==(Rect x, Rect y)
|
|
|
|
|
{
|
|
|
|
|
return x.Equals(y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static bool operator !=(Rect x, Rect y)
|
|
|
|
|
{
|
|
|
|
|
return !x.Equals(y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool Equals(object obj)
|
|
|
|
|
{
|
|
|
|
|
return obj is Rect rect && Equals(rect);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool Equals(Rect cmpObj)
|
|
|
|
|
{
|
|
|
|
|
return Left == cmpObj.Left && Top == cmpObj.Top && Right == cmpObj.Right && Bottom == cmpObj.Bottom;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override int GetHashCode() => HashCode.Combine(Left, Top, Right, Bottom);
|
2019-09-19 00:45:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|