Revert "Run graphics rendering on a dedicated thread."

This reverts commit b9be52c5428d4a3862d62fe3a2c01663bd3692c3.
This commit is contained in:
Paul Chote
2018-06-03 19:06:26 +01:00
committed by reaperrr
parent afc5a54ab5
commit 6c338eb06c
14 changed files with 48 additions and 875 deletions

View File

@@ -18,7 +18,7 @@ using SDL2;
namespace OpenRA.Platforms.Default
{
sealed class Sdl2GraphicsDevice : ThreadAffine, IGraphicsDeviceInternal
sealed class Sdl2GraphicsDevice : ThreadAffine, IGraphicsDevice
{
readonly Sdl2Input input;
@@ -140,14 +140,6 @@ namespace OpenRA.Platforms.Default
SDL.SDL_SetHint(SDL.SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");
}
SDL.SDL_SetModState(SDL.SDL_Keymod.KMOD_NONE);
input = new Sdl2Input();
}
public void InitializeOpenGL()
{
SetThreadAffinity();
context = SDL.SDL_GL_CreateContext(window);
if (context == IntPtr.Zero || SDL.SDL_GL_MakeCurrent(window, context) < 0)
throw new InvalidOperationException("Can not create OpenGL context. (Error: {0})".F(SDL.SDL_GetError()));
@@ -160,6 +152,9 @@ namespace OpenRA.Platforms.Default
OpenGL.CheckGLError();
OpenGL.glEnableVertexAttribArray(Shader.TexMetadataAttributeIndex);
OpenGL.CheckGLError();
SDL.SDL_SetModState(SDL.SDL_Keymod.KMOD_NONE);
input = new Sdl2Input();
}
public IHardwareCursor CreateHardwareCursor(string name, Size size, byte[] data, int2 hotspot)
@@ -226,9 +221,7 @@ namespace OpenRA.Platforms.Default
SurfaceSize = new Size(width, height);
WindowScale = width * 1f / WindowSize.Width;
var onWindowScaleChanged = OnWindowScaleChanged;
if (onWindowScaleChanged != null)
onWindowScaleChanged(oldScale, WindowScale);
OnWindowScaleChanged(oldScale, WindowScale);
}
}
}
@@ -269,9 +262,14 @@ namespace OpenRA.Platforms.Default
}
}
~SDL2HardwareCursor()
{
Game.RunAfterTick(() => Dispose(false));
}
public void Dispose()
{
Dispose(true);
Game.RunAfterTick(() => Dispose(true));
GC.SuppressFinalize(this);
}
@@ -492,7 +490,7 @@ namespace OpenRA.Platforms.Default
public void PumpInput(IInputHandler inputHandler)
{
VerifyThreadAffinity();
Game.RunAfterTick(() => input.PumpInput(this, inputHandler));
input.PumpInput(this, inputHandler);
}
public string GetClipboardText()
@@ -526,14 +524,9 @@ namespace OpenRA.Platforms.Default
}
public IFrameBuffer CreateFrameBuffer(Size s)
{
return CreateFrameBuffer(s, new Texture());
}
public IFrameBuffer CreateFrameBuffer(Size s, ITextureInternal texture)
{
VerifyThreadAffinity();
return new FrameBuffer(s, texture);
return new FrameBuffer(s);
}
public IShader CreateShader(string name)