Remove R_InitColumnDrawers and only allow DrawerArgs classes to call drawers

This commit is contained in:
Magnus Norddahl 2017-01-30 11:53:11 +01:00
parent c486892c4a
commit c574b0ad3f
4 changed files with 29 additions and 49 deletions

View file

@ -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()

View file

@ -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;
};
}

View file

@ -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()

View file

@ -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)
{