using System; using NvAPIWrapper.GPU; namespace NvAPIWrapper.Mosaic { /// /// Holds information about a display in a topology /// public class TopologyDisplay : IEquatable { internal TopologyDisplay(Native.Mosaic.Structures.TopologyDetails.LayoutCell layoutCell) { PhysicalGPU = !layoutCell.PhysicalGPUHandle.IsNull ? new PhysicalGPU(layoutCell.PhysicalGPUHandle) : null; Output = new GPUOutput(layoutCell.DisplayOutputId, PhysicalGPU); Overlap = new Overlap(layoutCell.OverlapX, layoutCell.OverlapY); } /// /// Gets the GPU output used for this display /// public GPUOutput Output { get; } /// /// Gets the display overlap values /// public Overlap Overlap { get; } /// /// Gets the corresponding physical GPU of this display /// public PhysicalGPU PhysicalGPU { get; } /// public bool Equals(TopologyDisplay other) { if (ReferenceEquals(null, other)) { return false; } if (ReferenceEquals(this, other)) { return true; } return PhysicalGPU.Equals(other.PhysicalGPU) && Output.Equals(other.Output) && Overlap.Equals(other.Overlap); } /// /// 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 ==(TopologyDisplay left, TopologyDisplay right) { return right?.Equals(left) ?? ReferenceEquals(left, null); } /// /// 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 !=(TopologyDisplay left, TopologyDisplay right) { return !(left == right); } /// public override bool Equals(object obj) { if (ReferenceEquals(null, obj)) { return false; } if (ReferenceEquals(this, obj)) { return true; } if (obj.GetType() != GetType()) { return false; } return Equals((TopologyDisplay) obj); } /// public override int GetHashCode() { unchecked { var hashCode = PhysicalGPU != null ? PhysicalGPU.GetHashCode() : 0; hashCode = (hashCode * 397) ^ (Output != null ? Output.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Overlap.GetHashCode(); return hashCode; } } } }