using System;
using System.Runtime.InteropServices;
using NvAPIWrapper.Native.Display;
using NvAPIWrapper.Native.Interfaces.Mosaic;
namespace NvAPIWrapper.Native.Mosaic.Structures
{
///
/// Holds information about a display in a grid topology
///
[StructLayout(LayoutKind.Sequential, Pack = 8)]
public struct GridTopologyDisplayV1 : IGridTopologyDisplay, IEquatable
{
internal readonly uint _DisplayId;
internal readonly int _OverlapX;
internal readonly int _OverlapY;
internal readonly Rotate _Rotation;
internal readonly uint _CloneGroup;
///
/// Creates a new GridTopologyDisplayV1
///
/// Display identification
/// Horizontal overlap (+overlap, -gap)
/// Vertical overlap (+overlap, -gap)
/// Rotation of display
/// Clone group identification; Reserved, must be 0
// ReSharper disable once TooManyDependencies
public GridTopologyDisplayV1(uint displayId, int overlapX, int overlapY, Rotate rotation, uint cloneGroup = 0)
: this()
{
_DisplayId = displayId;
_OverlapX = overlapX;
_OverlapY = overlapY;
_Rotation = rotation;
_CloneGroup = cloneGroup;
}
///
public bool Equals(GridTopologyDisplayV1 other)
{
return _DisplayId == other._DisplayId &&
_OverlapX == other._OverlapX &&
_OverlapY == other._OverlapY &&
_Rotation == other._Rotation &&
_CloneGroup == other._CloneGroup;
}
///
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
return obj is GridTopologyDisplayV1 v1 && Equals(v1);
}
///
public override int GetHashCode()
{
unchecked
{
var hashCode = (int) _DisplayId;
hashCode = (hashCode * 397) ^ _OverlapX;
hashCode = (hashCode * 397) ^ _OverlapY;
hashCode = (hashCode * 397) ^ (int) _Rotation;
hashCode = (hashCode * 397) ^ (int) _CloneGroup;
return hashCode;
}
}
///
/// Checks for equality between two objects of same type
///
/// The first object
/// The second object
/// true, if both objects are equal, otherwise false
public static bool operator ==(GridTopologyDisplayV1 left, GridTopologyDisplayV1 right)
{
return left.Equals(right);
}
///
/// Checks for inequality between two objects of same type
///
/// The first object
/// The second object
/// true, if both objects are not equal, otherwise false
public static bool operator !=(GridTopologyDisplayV1 left, GridTopologyDisplayV1 right)
{
return !left.Equals(right);
}
///
public uint DisplayId
{
get => _DisplayId;
}
///
public int OverlapX
{
get => _OverlapX;
}
///
public int OverlapY
{
get => _OverlapY;
}
///
public Rotate Rotation
{
get => _Rotation;
}
///
public uint CloneGroup
{
get => _CloneGroup;
}
///
public PixelShiftType PixelShiftType
{
get => PixelShiftType.NoPixelShift;
}
}
}