From c574b0ad3f3b8bd07ca0ab9e23ea5e438c7ef289 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 30 Jan 2017 11:53:11 +0100 Subject: [PATCH] Remove R_InitColumnDrawers and only allow DrawerArgs classes to call drawers --- src/swrenderer/drawers/r_drawerargs.cpp | 24 ++++++--------- src/swrenderer/drawers/r_drawerargs.h | 40 ++++++++++++------------- src/swrenderer/scene/r_scene.cpp | 8 ----- src/v_draw.cpp | 6 +--- 4 files changed, 29 insertions(+), 49 deletions(-) diff --git a/src/swrenderer/drawers/r_drawerargs.cpp b/src/swrenderer/drawers/r_drawerargs.cpp index c7e5bede54..82c0675042 100644 --- a/src/swrenderer/drawers/r_drawerargs.cpp +++ b/src/swrenderer/drawers/r_drawerargs.cpp @@ -39,24 +39,18 @@ namespace swrenderer { - namespace - { - SWPixelFormatDrawers *active_drawers; - SWPalDrawers pal_drawers; - SWTruecolorDrawers tc_drawers; - } - - void R_InitColumnDrawers() + SWPixelFormatDrawers *DrawerArgs::Drawers() { if (r_swtruecolor) - active_drawers = &tc_drawers; + { + static SWTruecolorDrawers tc_drawers; + return &tc_drawers; + } else - active_drawers = &pal_drawers; - } - - SWPixelFormatDrawers *DrawerArgs::Drawers() const - { - return active_drawers; + { + static SWPalDrawers pal_drawers; + return &pal_drawers; + } } SpriteDrawerArgs::SpriteDrawerArgs() diff --git a/src/swrenderer/drawers/r_drawerargs.h b/src/swrenderer/drawers/r_drawerargs.h index f1ff939a09..5ae0dadd0f 100644 --- a/src/swrenderer/drawers/r_drawerargs.h +++ b/src/swrenderer/drawers/r_drawerargs.h @@ -19,25 +19,7 @@ namespace swrenderer { class SWPixelFormatDrawers; class DrawerArgs; - - struct ShadeConstants - { - uint16_t light_alpha; - uint16_t light_red; - uint16_t light_green; - uint16_t light_blue; - uint16_t fade_alpha; - uint16_t fade_red; - uint16_t fade_green; - uint16_t fade_blue; - uint16_t desaturate; - bool simple_shade; - }; - - typedef void(SWPixelFormatDrawers::*DrawerFunc)(const DrawerArgs &args); - typedef void(SWPixelFormatDrawers::*WallDrawerFunc)(const WallDrawerArgs &args); - typedef void(SWPixelFormatDrawers::*SpriteDrawerFunc)(const SpriteDrawerArgs &args); - typedef void(SWPixelFormatDrawers::*SpanDrawerFunc)(const SpanDrawerArgs &args); + struct ShadeConstants; class DrawerArgs { @@ -51,7 +33,8 @@ namespace swrenderer ShadeConstants ColormapConstants() const; fixed_t Light() const { return LIGHTSCALE(mLight, mShade); } - SWPixelFormatDrawers *Drawers() const; + protected: + static SWPixelFormatDrawers *Drawers(); private: FSWColormap *mBaseColormap = nullptr; @@ -123,6 +106,7 @@ namespace swrenderer int dc_num_lights = 0; private: + typedef void(SWPixelFormatDrawers::*SpanDrawerFunc)(const SpanDrawerArgs &args); SpanDrawerFunc spanfunc; }; @@ -164,6 +148,7 @@ namespace swrenderer uint8_t *dc_dest = nullptr; int dc_dest_y = 0; + typedef void(SWPixelFormatDrawers::*WallDrawerFunc)(const WallDrawerArgs &args); WallDrawerFunc wallfunc = nullptr; }; @@ -213,8 +198,21 @@ namespace swrenderer int dc_dest_y = 0; bool drawer_needs_pal_input = false; + typedef void(SWPixelFormatDrawers::*SpriteDrawerFunc)(const SpriteDrawerArgs &args); SpriteDrawerFunc colfunc; }; - void R_InitColumnDrawers(); + struct ShadeConstants + { + uint16_t light_alpha; + uint16_t light_red; + uint16_t light_green; + uint16_t light_blue; + uint16_t fade_alpha; + uint16_t fade_red; + uint16_t fade_green; + uint16_t fade_blue; + uint16_t desaturate; + bool simple_shade; + }; } diff --git a/src/swrenderer/scene/r_scene.cpp b/src/swrenderer/scene/r_scene.cpp index 4914fbe251..24e04d5e88 100644 --- a/src/swrenderer/scene/r_scene.cpp +++ b/src/swrenderer/scene/r_scene.cpp @@ -79,7 +79,6 @@ namespace swrenderer if (r_swtruecolor != screen->IsBgra()) { r_swtruecolor = screen->IsBgra(); - R_InitColumnDrawers(); } if (r_clearbuffer != 0) @@ -202,7 +201,6 @@ namespace swrenderer if (r_swtruecolor != canvas->IsBgra()) { r_swtruecolor = canvas->IsBgra(); - R_InitColumnDrawers(); } R_BeginDrawerCommands(); @@ -233,11 +231,6 @@ namespace swrenderer viewactive = savedviewactive; r_swtruecolor = savedoutputformat; - - if (r_swtruecolor != canvas->IsBgra()) - { - R_InitColumnDrawers(); - } } void RenderScene::ScreenResized() @@ -259,7 +252,6 @@ namespace swrenderer fillshort(zeroarray, MAXWIDTH, 0); R_InitShadeMaps(); - R_InitColumnDrawers(); } void RenderScene::Deinit() diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 1736837f13..9ad73942d4 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -147,11 +147,7 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms) static short bottomclipper[MAXWIDTH], topclipper[MAXWIDTH]; const BYTE *translation = NULL; - if (r_swtruecolor != IsBgra()) - { - r_swtruecolor = IsBgra(); - R_InitColumnDrawers(); - } + r_swtruecolor = IsBgra(); if (APART(parms.colorOverlay) != 0) {