From ba799aebbd8786c90a64fecc0409d40d4254d663 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 27 Mar 2018 11:12:13 +0200 Subject: [PATCH] - moved locking logic from DCanvas to DFrameBuffer. The software canvases used for rendering camera textures and save pictures in the software renderer do not need this. --- src/c_console.cpp | 28 ---------------------------- src/polyrenderer/poly_renderer.cpp | 4 ---- src/posix/cocoa/i_video.mm | 6 ------ src/posix/cocoa/sdlglvideo.h | 1 - src/posix/sdl/sdlglvideo.cpp | 5 ----- src/posix/sdl/sdlglvideo.h | 1 - src/swrenderer/r_swrenderer.cpp | 2 -- src/v_video.cpp | 8 +++----- src/v_video.h | 10 +++------- src/win32/win32gliface.cpp | 5 ----- src/win32/win32gliface.h | 1 - 11 files changed, 6 insertions(+), 65 deletions(-) diff --git a/src/c_console.cpp b/src/c_console.cpp index bebd6a52c..ab0db58ff 100644 --- a/src/c_console.cpp +++ b/src/c_console.cpp @@ -516,31 +516,6 @@ CUSTOM_CVAR (Int, msgmidcolor2, 4, CVAR_ARCHIVE) setmsgcolor (PRINTLEVELS+1, self); } -static void maybedrawnow (bool tick, bool force) -{ - // FIXME: Does not work right with hw2d - if (ConsoleDrawing || screen == NULL || screen->IsLocked () || screen->Accel2D || ConFont == NULL) - { - return; - } - - if (vidactive && - (((tick || gameaction != ga_nothing) && ConsoleState == c_down) - || gamestate == GS_STARTUP)) - { - static size_t lastprinttime = 0; - size_t nowtime = I_GetTime(); - - if (nowtime - lastprinttime > 1 || force) - { - screen->Lock (false); - C_DrawConsole (false); - screen->Update (); - lastprinttime = nowtime; - } - } -} - struct TextQueue { TextQueue (bool notify, int printlevel, const char *text) @@ -857,7 +832,6 @@ int PrintString (int printlevel, const char *outline) if (vidactive && screen && SmallFont) { NotifyStrings.AddString(printlevel, outline); - maybedrawnow (false, false); } } else if (Logfile != NULL) @@ -1088,13 +1062,11 @@ void C_InitTicker (const char *label, unsigned int max, bool showpercent) TickerMax = max; TickerLabel = label; TickerAt = 0; - maybedrawnow (true, false); } void C_SetTicker (unsigned int at, bool forceUpdate) { TickerAt = at > TickerMax ? TickerMax : at; - maybedrawnow (true, TickerVisible ? forceUpdate : false); } void C_DrawConsole (bool hw2d) diff --git a/src/polyrenderer/poly_renderer.cpp b/src/polyrenderer/poly_renderer.cpp index 7517083c5..696233d84 100644 --- a/src/polyrenderer/poly_renderer.cpp +++ b/src/polyrenderer/poly_renderer.cpp @@ -93,13 +93,9 @@ void PolyRenderer::RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, int viewwindowy = y; viewactive = true; - canvas->Lock(true); - RenderActorView(actor, dontmaplines); Threads.MainThread()->FlushDrawQueue(); DrawerThreads::WaitForWorkers(); - - canvas->Unlock(); RenderTarget = screen; R_ExecuteSetViewSize(Viewpoint, Viewwindow); diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index ecbb3b928..27054c62e 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -1171,12 +1171,6 @@ void SDLGLFB::Unlock() } } -bool SDLGLFB::IsLocked() -{ - return m_Lock > 0; -} - - bool SDLGLFB::IsFullscreen() { return CocoaVideo::IsFullscreen(); diff --git a/src/posix/cocoa/sdlglvideo.h b/src/posix/cocoa/sdlglvideo.h index 55e08c583..93edc14b4 100644 --- a/src/posix/cocoa/sdlglvideo.h +++ b/src/posix/cocoa/sdlglvideo.h @@ -57,7 +57,6 @@ public: virtual bool Lock(bool buffered = true); virtual void Unlock(); - virtual bool IsLocked(); virtual bool IsFullscreen(); virtual void SetVSync(bool vsync); diff --git a/src/posix/sdl/sdlglvideo.cpp b/src/posix/sdl/sdlglvideo.cpp index 5b48c1c4c..59f8afb29 100644 --- a/src/posix/sdl/sdlglvideo.cpp +++ b/src/posix/sdl/sdlglvideo.cpp @@ -524,11 +524,6 @@ void SDLGLFB::Unlock () } } -bool SDLGLFB::IsLocked () -{ - return m_Lock>0;// true; -} - bool SDLGLFB::IsFullscreen () { return (SDL_GetWindowFlags (Screen) & SDL_WINDOW_FULLSCREEN_DESKTOP) != 0; diff --git a/src/posix/sdl/sdlglvideo.h b/src/posix/sdl/sdlglvideo.h index 2dce3aeed..704839433 100644 --- a/src/posix/sdl/sdlglvideo.h +++ b/src/posix/sdl/sdlglvideo.h @@ -56,7 +56,6 @@ public: bool Lock(bool buffered); bool Lock (); void Unlock(); - bool IsLocked (); bool IsValid (); bool IsFullscreen (); diff --git a/src/swrenderer/r_swrenderer.cpp b/src/swrenderer/r_swrenderer.cpp index e4afda993..d8ea79907 100644 --- a/src/swrenderer/r_swrenderer.cpp +++ b/src/swrenderer/r_swrenderer.cpp @@ -208,7 +208,6 @@ void FSoftwareRenderer::WriteSavePic (player_t *player, FileWriter *file, int wi PalEntry palette[256]; // Take a snapshot of the player's view - pic->Lock (); if (r_polyrenderer) { PolyRenderer::Instance()->Viewpoint = r_viewpoint; @@ -227,7 +226,6 @@ void FSoftwareRenderer::WriteSavePic (player_t *player, FileWriter *file, int wi } screen->GetFlashedPalette (palette); M_CreatePNG (file, pic->GetBuffer(), palette, SS_PAL, width, height, pic->GetPitch(), Gamma); - pic->Unlock (); delete pic; } diff --git a/src/v_video.cpp b/src/v_video.cpp index ef02f9466..61de0a64d 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -95,11 +95,7 @@ FRenderer *Renderer; EXTERN_CVAR (Bool, swtruecolor) EXTERN_CVAR (Bool, fullscreen) -#if defined(_DEBUG) && defined(_M_IX86) && !defined(__MINGW32__) -#define DBGBREAK { __asm int 3 } -#else -#define DBGBREAK -#endif +#define DBGBREAK assert(0) class DDummyFrameBuffer : public DFrameBuffer { @@ -111,7 +107,9 @@ public: Width = width; Height = height; } + // These methods should never be called. bool Lock(bool buffered) { DBGBREAK; return false; } + void Unlock() { DBGBREAK; } void Update() { DBGBREAK; } PalEntry *GetPalette() { DBGBREAK; return NULL; } void GetFlashedPalette(PalEntry palette[256]) { DBGBREAK; } diff --git a/src/v_video.h b/src/v_video.h index 98acd52c5..47d1f1b0e 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -214,11 +214,6 @@ public: virtual bool IsValid (); - // Access control - virtual bool Lock (bool buffered=true) = 0; // Returns true if the surface was lost since last time - virtual void Unlock () = 0; - virtual bool IsLocked () { return Buffer != NULL; } // Returns true if the surface is locked - protected: uint8_t *Buffer; int Width; @@ -298,8 +293,9 @@ protected: public: DFrameBuffer (int width, int height, bool bgra); - // Force the surface to use buffered output if true is passed. - virtual bool Lock (bool buffered) = 0; + // Access control + virtual bool Lock(bool buffered = true) = 0; // Returns true if the surface was lost since last time + virtual void Unlock() = 0; // Make the surface visible. Also implies Unlock(). virtual void Update () = 0; diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp index 0d6088f2d..b95e6dd64 100644 --- a/src/win32/win32gliface.cpp +++ b/src/win32/win32gliface.cpp @@ -1183,11 +1183,6 @@ void Win32GLFrameBuffer::Unlock () m_Lock--; } -bool Win32GLFrameBuffer::IsLocked () -{ - return m_Lock > 0; -} - //========================================================================== // // diff --git a/src/win32/win32gliface.h b/src/win32/win32gliface.h index b5cfe3dbf..d34d970b5 100644 --- a/src/win32/win32gliface.h +++ b/src/win32/win32gliface.h @@ -57,7 +57,6 @@ public: bool Lock(bool buffered); bool Lock (); void Unlock(); - bool IsLocked (); bool IsFullscreen();