From 857d0a5b39f4f2e00ea30d3e7de751682bbe3dfd Mon Sep 17 00:00:00 2001 From: zeromus Date: Sun, 6 May 2012 07:09:04 +0000 Subject: [PATCH] voila, "emu" resolution lua drawing, hacked in place of the native resolution drawing because rolanmen1 decided to destroy my surface management paradigms (i can tell because the earth is scorched with spaces instead of tabs) --- .../DisplayManager/DisplayManager.cs | 18 +++++++++++++++++- BizHawk.MultiClient/LuaImplementation.cs | 11 +++++++++++ BizHawk.MultiClient/tools/LuaConsole.cs | 6 +++--- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/BizHawk.MultiClient/DisplayManager/DisplayManager.cs b/BizHawk.MultiClient/DisplayManager/DisplayManager.cs index 16fd9523b4..c71845a615 100644 --- a/BizHawk.MultiClient/DisplayManager/DisplayManager.cs +++ b/BizHawk.MultiClient/DisplayManager/DisplayManager.cs @@ -591,6 +591,18 @@ namespace BizHawk.MultiClient return luaNativeSurfaceSet.AllocateSurface(currNativeWidth, currNativeHeight); } + SwappableDisplaySurfaceSet luaEmuSurfaceSet = new SwappableDisplaySurfaceSet(); + public void SetLuaSurfaceEmu(DisplaySurface surface) { luaEmuSurfaceSet.SetPending(surface); } + public DisplaySurface GetLuaEmuSurfaceEmu() + { + int width = 1, height = 1; + if (currentSourceSurface != null) + width = currentSourceSurface.Width; + if (currentSourceSurface != null) + height = currentSourceSurface.Height; + return luaEmuSurfaceSet.AllocateSurface(width, height); + } + int currNativeWidth, currNativeHeight; EventWaitHandle wakeupEvent, suspendReplyEvent; bool shutdownFlag, suspendFlag; @@ -677,11 +689,15 @@ namespace BizHawk.MultiClient g.CompositingMode = CompositingMode.SourceCopy; g.CompositingQuality = CompositingQuality.HighSpeed; g.DrawImage(currentSourceSurface.PeekBitmap(), 0, 0, w, h); - g.Clip = new Region(new Rectangle(0, 0, nativeBmp.Width, nativeBmp.Height)); //switch to fancier composition for OSD overlays and such g.CompositingMode = CompositingMode.SourceOver; + //this could have been done onto the source surface earlier and then scaled only once but the whole composition system needs revising, soo.. + DisplaySurface luaEmuSurface = luaEmuSurfaceSet.GetCurrent(); + if (luaEmuSurface != null) g.DrawImage(luaEmuSurface.PeekBitmap(), 0, 0, w, h); + g.Clip = new Region(new Rectangle(0, 0, nativeBmp.Width, nativeBmp.Height)); + //apply a lua layer var luaSurface = luaNativeSurfaceSet.GetCurrent(); if (luaSurface != null) g.DrawImageUnscaled(luaSurface.PeekBitmap(), 0, 0); diff --git a/BizHawk.MultiClient/LuaImplementation.cs b/BizHawk.MultiClient/LuaImplementation.cs index 902d5f5494..f6be4d8a7f 100644 --- a/BizHawk.MultiClient/LuaImplementation.cs +++ b/BizHawk.MultiClient/LuaImplementation.cs @@ -488,6 +488,11 @@ namespace BizHawk.MultiClient luaSurface = Global.DisplayManager.GetLuaSurfaceNative(); } + public void gui_drawNewEmu() + { + luaSurface = Global.DisplayManager.GetLuaEmuSurfaceEmu(); + } + /// /// finishes the current drawing and submits it to the display manager (at native [host] resolution pre-osd) /// you would probably want some way to specify which surface to set it to, when there are other surfaces. @@ -499,6 +504,12 @@ namespace BizHawk.MultiClient luaSurface = null; } + public void gui_drawFinishEmu() + { + Global.DisplayManager.SetLuaSurfaceEmu(luaSurface); + luaSurface = null; + } + /// /// draws a random rectangle for testing purposes /// diff --git a/BizHawk.MultiClient/tools/LuaConsole.cs b/BizHawk.MultiClient/tools/LuaConsole.cs index 4b3b12ca45..7933901480 100644 --- a/BizHawk.MultiClient/tools/LuaConsole.cs +++ b/BizHawk.MultiClient/tools/LuaConsole.cs @@ -832,8 +832,8 @@ namespace BizHawk.MultiClient { try { - LuaImp.gui_drawNew(); - //LuaImp.gui_clearGraphics(); + LuaImp.gui_drawNewEmu(); + //LuaImp.gui_clearGraphics(); if (s.Enabled && s.Thread != null && !s.Paused) { bool prohibit = false; @@ -844,7 +844,7 @@ namespace BizHawk.MultiClient var result = LuaImp.ResumeScript(s.Thread); s.FrameWaiting = result.WaitForFrame; } - LuaImp.gui_drawFinish(); + LuaImp.gui_drawFinishEmu(); } catch (Exception ex) {