From dc5a5419fc3118f958f2799d6b19780dbbdf294b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 14 Apr 2017 10:48:18 +0200 Subject: [PATCH] - took DCanvas and all its subtypes out of the DObject tree. I have no idea why they were even in there, as they intentionally circumvented all GC related features - they declared themselves fixed if prone to getting collected, they all used OF_YesReallyDelete when destroying themselves and they never used any of the object creation or RTTI features, aside from a single assert in V_Init2. Essentially they were a drag on the system and OF_YesReallyDelete was effectively added just to deal with the canvases which were DObjects but not supposed to behave like them in the first place. --- src/dobjgc.cpp | 1 - src/gl/system/gl_framebuffer.cpp | 1 - src/gl/system/gl_framebuffer.h | 4 +--- src/gl/system/gl_swframebuffer.cpp | 2 -- src/gl/system/gl_swframebuffer.h | 4 +--- src/posix/sdl/sdlglvideo.cpp | 3 --- src/posix/sdl/sdlglvideo.h | 4 ++-- src/posix/sdl/sdlvideo.cpp | 2 -- src/posix/sdl/sdlvideo.h | 2 +- src/swrenderer/r_swrenderer.cpp | 3 --- src/textures/canvastexture.cpp | 10 ++-------- src/v_video.cpp | 13 +------------ src/v_video.h | 7 +++---- src/win32/fb_d3d9.cpp | 2 -- src/win32/fb_ddraw.cpp | 2 -- src/win32/hardware.cpp | 1 - src/win32/win32gliface.cpp | 2 -- src/win32/win32gliface.h | 2 +- src/win32/win32iface.h | 2 +- src/win32/win32swiface.h | 4 ++-- src/win32/win32video.cpp | 6 +----- 21 files changed, 16 insertions(+), 61 deletions(-) diff --git a/src/dobjgc.cpp b/src/dobjgc.cpp index 5779b3903..c44f77b80 100644 --- a/src/dobjgc.cpp +++ b/src/dobjgc.cpp @@ -326,7 +326,6 @@ static void MarkRoot() Gray = NULL; Mark(Args); - Mark(screen); Mark(StatusBar); M_MarkMenus(); Mark(DIntermissionController::CurrentIntermission); diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index cef60ed7a..24e6ee626 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -52,7 +52,6 @@ #include "gl/renderer/gl_2ddrawer.h" #include "gl_debug.h" -IMPLEMENT_CLASS(OpenGLFrameBuffer, false, false) EXTERN_CVAR (Float, vid_brightness) EXTERN_CVAR (Float, vid_contrast) EXTERN_CVAR (Bool, vid_vsync) diff --git a/src/gl/system/gl_framebuffer.h b/src/gl/system/gl_framebuffer.h index 72bdb7315..0d88667ca 100644 --- a/src/gl/system/gl_framebuffer.h +++ b/src/gl/system/gl_framebuffer.h @@ -17,13 +17,11 @@ extern long gl_frameMS; class OpenGLFrameBuffer : public Win32GLFrameBuffer { typedef Win32GLFrameBuffer Super; - DECLARE_CLASS(OpenGLFrameBuffer, Win32GLFrameBuffer) #else #include "sdlglvideo.h" class OpenGLFrameBuffer : public SDLGLFB { -// typedef SDLGLFB Super; //[C]commented, DECLARE_CLASS defines this in linux - DECLARE_CLASS(OpenGLFrameBuffer, SDLGLFB) + typedef SDLGLFB Super; //[C]commented, DECLARE_CLASS defines this in linux #endif diff --git a/src/gl/system/gl_swframebuffer.cpp b/src/gl/system/gl_swframebuffer.cpp index 4a97eb95b..7b9e54cfb 100644 --- a/src/gl/system/gl_swframebuffer.cpp +++ b/src/gl/system/gl_swframebuffer.cpp @@ -113,8 +113,6 @@ DFrameBuffer *CreateGLSWFrameBuffer(int width, int height, bool bgra, bool fulls } #endif -IMPLEMENT_CLASS(OpenGLSWFrameBuffer, false, false) - const char *const OpenGLSWFrameBuffer::ShaderDefines[OpenGLSWFrameBuffer::NUM_SHADERS] = { "#define ENORMALCOLOR", // NormalColor diff --git a/src/gl/system/gl_swframebuffer.h b/src/gl/system/gl_swframebuffer.h index 0f9c0a0ef..dcb67e138 100644 --- a/src/gl/system/gl_swframebuffer.h +++ b/src/gl/system/gl_swframebuffer.h @@ -17,13 +17,11 @@ class FGLDebug; class OpenGLSWFrameBuffer : public Win32GLFrameBuffer { typedef Win32GLFrameBuffer Super; - DECLARE_CLASS(OpenGLSWFrameBuffer, Win32GLFrameBuffer) #else #include "sdlglvideo.h" class OpenGLSWFrameBuffer : public SDLGLFB { -// typedef SDLGLFB Super; //[C]commented, DECLARE_CLASS defines this in linux - DECLARE_CLASS(OpenGLSWFrameBuffer, SDLGLFB) + typedef SDLGLFB Super; //[C]commented, DECLARE_CLASS defines this in linux #endif diff --git a/src/posix/sdl/sdlglvideo.cpp b/src/posix/sdl/sdlglvideo.cpp index 1e602f102..196f2034b 100644 --- a/src/posix/sdl/sdlglvideo.cpp +++ b/src/posix/sdl/sdlglvideo.cpp @@ -30,9 +30,6 @@ // TYPES ------------------------------------------------------------------- -IMPLEMENT_CLASS(SDLBaseFB, true, false) -IMPLEMENT_CLASS(SDLGLFB, true, false) - struct MiniModeInfo { uint16_t Width, Height; diff --git a/src/posix/sdl/sdlglvideo.h b/src/posix/sdl/sdlglvideo.h index de37abbf4..69472c848 100644 --- a/src/posix/sdl/sdlglvideo.h +++ b/src/posix/sdl/sdlglvideo.h @@ -37,7 +37,7 @@ private: class SDLBaseFB : public DFrameBuffer { - DECLARE_CLASS(SDLBaseFB, DFrameBuffer) + typedef DFrameBuffer Super; public: using DFrameBuffer::DFrameBuffer; virtual SDL_Window *GetSDLWindow() = 0; @@ -47,7 +47,7 @@ public: class SDLGLFB : public SDLBaseFB { - DECLARE_CLASS(SDLGLFB, SDLBaseFB) + typedef SDLBaseFB Super; public: // this must have the same parameters as the Windows version, even if they are not used! SDLGLFB (void *hMonitor, int width, int height, int, int, bool fullscreen, bool bgra); diff --git a/src/posix/sdl/sdlvideo.cpp b/src/posix/sdl/sdlvideo.cpp index 030129fc0..4c830fe6c 100644 --- a/src/posix/sdl/sdlvideo.cpp +++ b/src/posix/sdl/sdlvideo.cpp @@ -24,8 +24,6 @@ // TYPES ------------------------------------------------------------------- -IMPLEMENT_CLASS(SDLFB, false, false) - struct MiniModeInfo { uint16_t Width, Height; diff --git a/src/posix/sdl/sdlvideo.h b/src/posix/sdl/sdlvideo.h index 001d6c088..31a168aa6 100644 --- a/src/posix/sdl/sdlvideo.h +++ b/src/posix/sdl/sdlvideo.h @@ -4,7 +4,7 @@ class SDLFB : public SDLBaseFB { - DECLARE_CLASS(SDLFB, SDLBaseFB) + typedef SDLBaseFB Super; public: SDLFB(int width, int height, bool bgra, bool fullscreen, SDL_Window *oldwin); ~SDLFB(); diff --git a/src/swrenderer/r_swrenderer.cpp b/src/swrenderer/r_swrenderer.cpp index 9f6da2a14..de1172740 100644 --- a/src/swrenderer/r_swrenderer.cpp +++ b/src/swrenderer/r_swrenderer.cpp @@ -206,7 +206,6 @@ void FSoftwareRenderer::WriteSavePic (player_t *player, FileWriter *file, int wi PalEntry palette[256]; // Take a snapshot of the player's view - pic->ObjectFlags |= OF_Fixed; pic->Lock (); if (r_polyrenderer) { @@ -227,8 +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()); pic->Unlock (); - pic->Destroy(); - pic->ObjectFlags |= OF_YesReallyDelete; delete pic; } diff --git a/src/textures/canvastexture.cpp b/src/textures/canvastexture.cpp index ed72b0eee..eba5d2fea 100644 --- a/src/textures/canvastexture.cpp +++ b/src/textures/canvastexture.cpp @@ -114,7 +114,6 @@ void FCanvasTexture::MakeTexture () { Canvas = new DSimpleCanvas (Width, Height, false); Canvas->Lock (); - GC::AddSoftRoot(Canvas); if (Width != Height || Width != Canvas->GetPitch()) { @@ -136,7 +135,6 @@ void FCanvasTexture::MakeTextureBgra() { CanvasBgra = new DSimpleCanvas(Width, Height, true); CanvasBgra->Lock(); - GC::AddSoftRoot(CanvasBgra); if (Width != Height || Width != CanvasBgra->GetPitch()) { @@ -172,16 +170,12 @@ void FCanvasTexture::Unload () if (Canvas != NULL) { - GC::DelSoftRoot(Canvas); - Canvas->Destroy(); - Canvas = NULL; + delete Canvas; } if (CanvasBgra != NULL) { - GC::DelSoftRoot(CanvasBgra); - CanvasBgra->Destroy(); - CanvasBgra = NULL; + delete CanvasBgra; } FTexture::Unload(); diff --git a/src/v_video.cpp b/src/v_video.cpp index 96b45fad6..49cf088ea 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -73,8 +73,6 @@ int active_con_scale(); FRenderer *Renderer; -IMPLEMENT_CLASS(DCanvas, true, false) -IMPLEMENT_CLASS(DFrameBuffer, true, false) EXTERN_CVAR (Bool, swtruecolor) EXTERN_CVAR (Bool, fullscreen) @@ -86,7 +84,7 @@ EXTERN_CVAR (Bool, fullscreen) class DDummyFrameBuffer : public DFrameBuffer { - DECLARE_CLASS (DDummyFrameBuffer, DFrameBuffer); + typedef DFrameBuffer Super; public: DDummyFrameBuffer (int width, int height) : DFrameBuffer (0, 0, false) @@ -112,11 +110,6 @@ public: float Gamma; }; -IMPLEMENT_CLASS(DDummyFrameBuffer, true, false) - -// SimpleCanvas is not really abstract, but this macro does not -// try to generate a CreateNew() function. -IMPLEMENT_CLASS(DSimpleCanvas, true, false) class FPaletteTester : public FTexture { @@ -1272,7 +1265,6 @@ bool V_DoModeSetup (int width, int height, int bits) } screen = buff; - GC::WriteBarrier(screen); screen->SetGamma (Gamma); // Load fonts now so they can be packed into textures straight away, @@ -1544,7 +1536,6 @@ void V_Init (bool restart) void V_Init2() { - assert (screen->IsKindOf(RUNTIME_CLASS(DDummyFrameBuffer))); int width = screen->GetWidth(); int height = screen->GetHeight(); float gamma = static_cast(screen)->Gamma; @@ -1552,7 +1543,6 @@ void V_Init2() { DFrameBuffer *s = screen; screen = NULL; - s->ObjectFlags |= OF_YesReallyDelete; delete s; } @@ -1579,7 +1569,6 @@ void V_Shutdown() { DFrameBuffer *s = screen; screen = NULL; - s->ObjectFlags |= OF_YesReallyDelete; delete s; } V_ClearFonts(); diff --git a/src/v_video.h b/src/v_video.h index 56cb3ee0d..c4f9bdb95 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -198,9 +198,8 @@ struct VMVa_List // // [RH] Made screens more implementation-independant: // -class DCanvas : public DObject +class DCanvas { - DECLARE_ABSTRACT_CLASS (DCanvas, DObject) public: DCanvas (int width, int height, bool bgra); virtual ~DCanvas (); @@ -317,7 +316,7 @@ private: class DSimpleCanvas : public DCanvas { - DECLARE_CLASS (DSimpleCanvas, DCanvas) + typedef DCanvas Super; public: DSimpleCanvas (int width, int height, bool bgra); ~DSimpleCanvas (); @@ -357,7 +356,7 @@ public: class DFrameBuffer : public DSimpleCanvas { - DECLARE_ABSTRACT_CLASS (DFrameBuffer, DSimpleCanvas) + typedef DSimpleCanvas Super; public: DFrameBuffer (int width, int height, bool bgra); diff --git a/src/win32/fb_d3d9.cpp b/src/win32/fb_d3d9.cpp index 85331a347..188d2530e 100644 --- a/src/win32/fb_d3d9.cpp +++ b/src/win32/fb_d3d9.cpp @@ -92,8 +92,6 @@ // TYPES ------------------------------------------------------------------- -IMPLEMENT_CLASS(D3DFB, false, false) - struct D3DFB::PackedTexture { D3DFB::Atlas *Owner; diff --git a/src/win32/fb_ddraw.cpp b/src/win32/fb_ddraw.cpp index b7f314608..729bbaa91 100644 --- a/src/win32/fb_ddraw.cpp +++ b/src/win32/fb_ddraw.cpp @@ -60,8 +60,6 @@ // TYPES ------------------------------------------------------------------- -IMPLEMENT_CLASS(DDrawFB, false, false) - // EXTERNAL FUNCTION PROTOTYPES -------------------------------------------- // PUBLIC FUNCTION PROTOTYPES ---------------------------------------------- diff --git a/src/win32/hardware.cpp b/src/win32/hardware.cpp index b083f4fe9..7c3127164 100644 --- a/src/win32/hardware.cpp +++ b/src/win32/hardware.cpp @@ -142,7 +142,6 @@ void I_ShutdownGraphics () { DFrameBuffer *s = screen; screen = NULL; - s->ObjectFlags |= OF_YesReallyDelete; delete s; } if (Video) diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp index 2074a17d8..96c1510df 100644 --- a/src/win32/win32gliface.cpp +++ b/src/win32/win32gliface.cpp @@ -945,8 +945,6 @@ bool Win32GLVideo::SetFullscreen(const char *devicename, int w, int h, int bits, // //========================================================================== -IMPLEMENT_CLASS(Win32GLFrameBuffer, true, false) - //========================================================================== // // diff --git a/src/win32/win32gliface.h b/src/win32/win32gliface.h index ca949c864..09e9e5642 100644 --- a/src/win32/win32gliface.h +++ b/src/win32/win32gliface.h @@ -27,7 +27,7 @@ FRenderer *gl_CreateInterface(); class Win32GLFrameBuffer : public BaseWinFB { - DECLARE_CLASS(Win32GLFrameBuffer, BaseWinFB) + typedef BaseWinFB Super; public: Win32GLFrameBuffer() {} diff --git a/src/win32/win32iface.h b/src/win32/win32iface.h index 8e7768b64..7ea190135 100644 --- a/src/win32/win32iface.h +++ b/src/win32/win32iface.h @@ -103,7 +103,7 @@ class Win32Video : public IVideo class BaseWinFB : public DFrameBuffer { - DECLARE_ABSTRACT_CLASS(BaseWinFB, DFrameBuffer) + typedef DFrameBuffer Super; public: BaseWinFB(int width, int height, bool bgra) : DFrameBuffer(width, height, bgra), Windowed(true) {} diff --git a/src/win32/win32swiface.h b/src/win32/win32swiface.h index 5c0a456e4..59101c602 100644 --- a/src/win32/win32swiface.h +++ b/src/win32/win32swiface.h @@ -18,7 +18,7 @@ extern HANDLE FPSLimitEvent; class DDrawFB : public BaseWinFB { - DECLARE_CLASS(DDrawFB, BaseWinFB) + typedef BaseWinFB Super; public: DDrawFB (int width, int height, bool fullscreen); ~DDrawFB (); @@ -100,7 +100,7 @@ private: class D3DFB : public BaseWinFB { - DECLARE_CLASS(D3DFB, BaseWinFB) + typedef BaseWinFB Super; public: D3DFB (UINT adapter, int width, int height, bool bgra, bool fullscreen); ~D3DFB (); diff --git a/src/win32/win32video.cpp b/src/win32/win32video.cpp index f734ac789..0ef278105 100644 --- a/src/win32/win32video.cpp +++ b/src/win32/win32video.cpp @@ -80,8 +80,6 @@ // TYPES ------------------------------------------------------------------- -IMPLEMENT_CLASS(BaseWinFB, true, false) - typedef IDirect3D9 *(WINAPI *DIRECT3DCREATE9FUNC)(UINT SDKVersion); typedef HRESULT (WINAPI *DIRECTDRAWCREATEFUNC)(GUID FAR *lpGUID, LPDIRECTDRAW FAR *lplpDD, IUnknown FAR *pUnkOuter); @@ -662,8 +660,7 @@ DFrameBuffer *Win32Video::CreateFrameBuffer (int width, int height, bool bgra, b return old; } old->GetFlash (flashColor, flashAmount); - old->ObjectFlags |= OF_YesReallyDelete; - if (old == screen) screen = NULL; + if (old == screen) screen = nullptr; delete old; } else @@ -700,7 +697,6 @@ DFrameBuffer *Win32Video::CreateFrameBuffer (int width, int height, bool bgra, b { hr = fb->GetHR (); } - fb->ObjectFlags |= OF_YesReallyDelete; delete fb; LOG1 ("fb is bad: %08lx\n", hr);