mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-01-11 11:05:28 +00:00
[OpenTK] Add allocated resource registry
This commit is contained in:
parent
864cc84019
commit
77a44b2c8e
|
@ -28,6 +28,7 @@
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
using OpenTK.Input;
|
using OpenTK.Input;
|
||||||
|
@ -42,12 +43,27 @@ namespace OpenTK.Platform
|
||||||
/// </summary>
|
/// </summary>
|
||||||
abstract class PlatformFactoryBase : IPlatformFactory
|
abstract class PlatformFactoryBase : IPlatformFactory
|
||||||
{
|
{
|
||||||
|
static readonly object sync = new object();
|
||||||
|
readonly List<IDisposable> Resources = new List<IDisposable>();
|
||||||
|
|
||||||
protected bool IsDisposed;
|
protected bool IsDisposed;
|
||||||
|
|
||||||
public PlatformFactoryBase()
|
public PlatformFactoryBase()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region Protected Members
|
||||||
|
|
||||||
|
protected void RegisterResource(IDisposable resource)
|
||||||
|
{
|
||||||
|
lock (sync)
|
||||||
|
{
|
||||||
|
Resources.Add(resource);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region IPlatformFactory Members
|
#region IPlatformFactory Members
|
||||||
|
|
||||||
public abstract INativeWindow CreateNativeWindow(int x, int y, int width, int height, string title, GraphicsMode mode, GameWindowFlags options, DisplayDevice device);
|
public abstract INativeWindow CreateNativeWindow(int x, int y, int width, int height, string title, GraphicsMode mode, GameWindowFlags options, DisplayDevice device);
|
||||||
|
@ -96,6 +112,13 @@ namespace OpenTK.Platform
|
||||||
{
|
{
|
||||||
if (manual)
|
if (manual)
|
||||||
{
|
{
|
||||||
|
lock (sync)
|
||||||
|
{
|
||||||
|
foreach (var resource in Resources)
|
||||||
|
{
|
||||||
|
resource.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue