mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-01-27 03:41:12 +00:00
Implemented IDisposable pattern.
This commit is contained in:
parent
f031e34ecf
commit
e7fd9eb296
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace OpenTK.Platform.Egl
|
namespace OpenTK.Platform.Egl
|
||||||
{
|
{
|
||||||
|
@ -12,6 +13,7 @@ namespace OpenTK.Platform.Egl
|
||||||
IntPtr handle;
|
IntPtr handle;
|
||||||
EGLDisplay display;
|
EGLDisplay display;
|
||||||
EGLSurface surface;
|
EGLSurface surface;
|
||||||
|
bool disposed;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -49,13 +51,41 @@ namespace OpenTK.Platform.Egl
|
||||||
// Surface = Egl.CreatePbufferSurface(Display, config, null);
|
// Surface = Egl.CreatePbufferSurface(Display, config, null);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
public void DestroySurface()
|
||||||
|
{
|
||||||
|
if (Surface.Handle != EGLSurface.None.Handle)
|
||||||
|
if (!Egl.DestroySurface(Display, Surface))
|
||||||
|
Debug.Print("[Warning] Failed to destroy {0}:{1}.", Surface.GetType().Name, Surface);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region IDisposable Members
|
#region IDisposable Members
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
Dispose(true);
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Dispose(bool manual)
|
||||||
|
{
|
||||||
|
if (!disposed)
|
||||||
|
{
|
||||||
|
if (manual)
|
||||||
|
{
|
||||||
|
DestroySurface();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.Print("[Warning] Failed to destroy {0}:{1}.", this.GetType().Name, Handle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
~EglWindowInfo()
|
||||||
|
{
|
||||||
|
Dispose(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
Loading…
Reference in a new issue