From: thefiddler Date: Wed, 23 Jul 2014 19:24:24 +0000 (+0200) Subject: [Graphics] Implemented structural equality X-Git-Tag: 2.0-0~105^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=15f87c15a153fc20df343b99657bb156cc310b1f;p=platform%2Fcore%2Fcsapi%2Fopentk.git [Graphics] Implemented structural equality GraphicsContexts are now considered equal if they store the same context handle. Debugging information is also improved. --- diff --git a/Source/OpenTK/Graphics/GraphicsContextBase.cs b/Source/OpenTK/Graphics/GraphicsContextBase.cs index ddfd491..d6537f5 100644 --- a/Source/OpenTK/Graphics/GraphicsContextBase.cs +++ b/Source/OpenTK/Graphics/GraphicsContextBase.cs @@ -36,7 +36,7 @@ using OpenTK.Platform; namespace OpenTK.Graphics { // Provides the foundation for all IGraphicsContext implementations. - abstract class GraphicsContextBase : IGraphicsContext, IGraphicsContextInternal + abstract class GraphicsContextBase : IGraphicsContext, IGraphicsContextInternal, IEquatable { #region Fields @@ -127,5 +127,36 @@ namespace OpenTK.Graphics #endif #endregion + + #region IEquatable Members + + public bool Equals(IGraphicsContextInternal other) + { + return Context.Equals(other.Context); + } + + #endregion + + #region Public Members + + public override string ToString() + { + return string.Format("[{0}: IsCurrent={1}, IsDisposed={2}, VSync={3}, SwapInterval={4}, GraphicsMode={5}, ErrorChecking={6}, Implementation={7}, Context={8}]", + GetType().Name, IsCurrent, IsDisposed, VSync, SwapInterval, GraphicsMode, ErrorChecking, Implementation, Context); + } + + public override int GetHashCode() + { + return Handle.GetHashCode(); + } + + public override bool Equals(object obj) + { + return + obj is IGraphicsContextInternal && + Equals((IGraphicsContextInternal)obj); + } + + #endregion } }