Make colfunc, wallfunc, spanfunc private and remove the rest

This commit is contained in:
Magnus Norddahl 2017-01-30 11:43:15 +01:00
parent 2f365e7d2b
commit c486892c4a
4 changed files with 31 additions and 23 deletions

View file

@ -62,9 +62,6 @@ namespace swrenderer
SpriteDrawerArgs::SpriteDrawerArgs()
{
colfunc = &SWPixelFormatDrawers::DrawColumn;
basecolfunc = &SWPixelFormatDrawers::DrawColumn;
fuzzcolfunc = &SWPixelFormatDrawers::DrawFuzzColumn;
transcolfunc = &SWPixelFormatDrawers::DrawTranslatedColumn;
}
SpanDrawerArgs::SpanDrawerArgs()
@ -355,11 +352,11 @@ namespace swrenderer
}
else if (TranslationMap() == nullptr)
{
colfunc = basecolfunc;
colfunc = &SWPixelFormatDrawers::DrawColumn;
}
else
{
colfunc = transcolfunc;
colfunc = &SWPixelFormatDrawers::DrawTranslatedColumn;
drawer_needs_pal_input = true;
}
return true;
@ -530,7 +527,7 @@ namespace swrenderer
// Check for special modes
if (style.BlendOp == STYLEOP_Fuzz)
{
colfunc = fuzzcolfunc;
colfunc = &SWPixelFormatDrawers::DrawFuzzColumn;
return true;
}
else if (style == LegacyRenderStyles[STYLE_Shaded])
@ -600,6 +597,11 @@ namespace swrenderer
dc_dest_y = y;
}
void WallDrawerArgs::DrawColumn()
{
(Drawers()->*wallfunc)(*this);
}
void SpanDrawerArgs::SetSpanStyle(bool masked, bool additive, fixed_t alpha)
{
if (masked)
@ -687,6 +689,11 @@ namespace swrenderer
}
}
bool WallDrawerArgs::IsMaskedDrawer() const
{
return wallfunc == &SWPixelFormatDrawers::DrawWallMaskedColumn;
}
void SpanDrawerArgs::DrawSpan()
{
(Drawers()->*spanfunc)(*this);

View file

@ -132,6 +132,10 @@ namespace swrenderer
void SetStyle(bool masked, bool additive, fixed_t alpha);
void SetDest(int x, int y);
bool IsMaskedDrawer() const;
void DrawColumn();
uint8_t *Dest() const { return dc_dest; }
int DestY() const { return dc_dest_y; }
@ -156,11 +160,11 @@ namespace swrenderer
TriLight *dc_lights = nullptr;
int dc_num_lights = 0;
WallDrawerFunc wallfunc = nullptr;
private:
uint8_t *dc_dest = nullptr;
int dc_dest_y = 0;
WallDrawerFunc wallfunc = nullptr;
};
class SpriteDrawerArgs : public DrawerArgs
@ -200,11 +204,6 @@ namespace swrenderer
fixed_t dc_srcalpha;
fixed_t dc_destalpha;
SpriteDrawerFunc colfunc;
SpriteDrawerFunc basecolfunc;
SpriteDrawerFunc fuzzcolfunc;
SpriteDrawerFunc transcolfunc;
private:
bool SetBlendFunc(int op, fixed_t fglevel, fixed_t bglevel, int flags);
static fixed_t GetAlpha(int type, fixed_t alpha);
@ -213,6 +212,8 @@ namespace swrenderer
uint8_t *dc_dest = nullptr;
int dc_dest_y = 0;
bool drawer_needs_pal_input = false;
SpriteDrawerFunc colfunc;
};
void R_InitColumnDrawers();

View file

@ -168,7 +168,7 @@ namespace swrenderer
}
// Draw a column with support for non-power-of-two ranges
void RenderWallPart::Draw1Column(int x, int y1, int y2, WallSampler &sampler, WallDrawerFunc draw1column)
void RenderWallPart::Draw1Column(int x, int y1, int y2, WallSampler &sampler)
{
if (r_dynlights && light_list)
{
@ -248,7 +248,7 @@ namespace swrenderer
drawerargs.dc_iscale = sampler.uv_step;
drawerargs.dc_texturefrac = sampler.uv_pos;
drawerargs.dc_textureheight = sampler.height;
(drawerargs.Drawers()->*draw1column)(drawerargs);
drawerargs.DrawColumn();
uint64_t step64 = sampler.uv_step;
uint64_t pos64 = sampler.uv_pos;
@ -267,7 +267,7 @@ namespace swrenderer
drawerargs.dc_count = count;
drawerargs.dc_iscale = sampler.uv_step;
drawerargs.dc_texturefrac = sampler.uv_pos;
(drawerargs.Drawers()->*draw1column)(drawerargs);
drawerargs.DrawColumn();
uint64_t step64 = sampler.uv_step;
uint64_t pos64 = sampler.uv_pos;
@ -293,7 +293,7 @@ namespace swrenderer
drawerargs.dc_count = count;
drawerargs.dc_iscale = sampler.uv_step;
drawerargs.dc_texturefrac = uv_pos;
(drawerargs.Drawers()->*draw1column)(drawerargs);
drawerargs.DrawColumn();
left -= count;
uv_pos += sampler.uv_step * count;
@ -306,7 +306,7 @@ namespace swrenderer
}
}
void RenderWallPart::ProcessWallWorker(const short *uwal, const short *dwal, double texturemid, float *swal, fixed_t *lwal, WallDrawerFunc drawcolumn)
void RenderWallPart::ProcessWallWorker(const short *uwal, const short *dwal, double texturemid, float *swal, fixed_t *lwal)
{
if (rw_pic->UseType == FTexture::TEX_Null)
return;
@ -352,7 +352,7 @@ namespace swrenderer
if (x + 1 < x2) xmagnitude = fabs(FIXED2DBL(lwal[x + 1]) - FIXED2DBL(lwal[x]));
WallSampler sampler(y1, texturemid, swal[x], yrepeat, lwal[x] + xoffset, xmagnitude, rw_pic);
Draw1Column(x, y1, y2, sampler, drawcolumn);
Draw1Column(x, y1, y2, sampler);
}
NetUpdate();
@ -360,7 +360,7 @@ namespace swrenderer
void RenderWallPart::ProcessNormalWall(const short *uwal, const short *dwal, double texturemid, float *swal, fixed_t *lwal)
{
ProcessWallWorker(uwal, dwal, texturemid, swal, lwal, drawerargs.wallfunc);
ProcessWallWorker(uwal, dwal, texturemid, swal, lwal);
}
void RenderWallPart::ProcessStripedWall(const short *uwal, const short *dwal, double texturemid, float *swal, fixed_t *lwal)
@ -403,7 +403,7 @@ namespace swrenderer
void RenderWallPart::ProcessWall(const short *uwal, const short *dwal, double texturemid, float *swal, fixed_t *lwal)
{
// Textures that aren't masked can use the faster ProcessNormalWall.
if (!rw_pic->bMasked && drawerargs.wallfunc == &SWPixelFormatDrawers::DrawWallMaskedColumn)
if (!rw_pic->bMasked && drawerargs.IsMaskedDrawer())
{
drawerargs.SetStyle(true, false, OPAQUE);
}

View file

@ -63,8 +63,8 @@ namespace swrenderer
void ProcessWall(const short *uwal, const short *dwal, double texturemid, float *swal, fixed_t *lwal);
void ProcessStripedWall(const short *uwal, const short *dwal, double texturemid, float *swal, fixed_t *lwal);
void ProcessNormalWall(const short *uwal, const short *dwal, double texturemid, float *swal, fixed_t *lwal);
void ProcessWallWorker(const short *uwal, const short *dwal, double texturemid, float *swal, fixed_t *lwal, WallDrawerFunc drawcolumn);
void Draw1Column(int x, int y1, int y2, WallSampler &sampler, WallDrawerFunc draw1column);
void ProcessWallWorker(const short *uwal, const short *dwal, double texturemid, float *swal, fixed_t *lwal);
void Draw1Column(int x, int y1, int y2, WallSampler &sampler);
int x1 = 0;
int x2 = 0;