Limit access to sprite drawer variables

This commit is contained in:
Magnus Norddahl 2017-02-02 13:51:41 +01:00
parent f3d968cf41
commit d8c6f9acfd
5 changed files with 77 additions and 53 deletions

View file

@ -157,8 +157,8 @@ namespace swrenderer
void R_UpdateFuzzPos(const SpriteDrawerArgs &args) void R_UpdateFuzzPos(const SpriteDrawerArgs &args)
{ {
int yl = MAX(args.dc_yl, 1); int yl = MAX(args.FuzzY1(), 1);
int yh = MIN(args.dc_yh, fuzzviewheight); int yh = MIN(args.FuzzY2(), fuzzviewheight);
if (yl <= yh) if (yl <= yh)
fuzzpos = (fuzzpos + yh - yl + 1) % FUZZTABLE; fuzzpos = (fuzzpos + yh - yl + 1) % FUZZTABLE;
} }

View file

@ -867,21 +867,21 @@ namespace swrenderer
PalColumnCommand::PalColumnCommand(const SpriteDrawerArgs &args) PalColumnCommand::PalColumnCommand(const SpriteDrawerArgs &args)
{ {
_count = args.dc_count; _count = args.Count();
_dest = args.Dest(); _dest = args.Dest();
_dest_y = args.DestY(); _dest_y = args.DestY();
_pitch = RenderViewport::Instance()->RenderTarget->GetPitch(); _pitch = RenderViewport::Instance()->RenderTarget->GetPitch();
_iscale = args.dc_iscale; _iscale = args.TextureVStep();
_texturefrac = args.dc_texturefrac; _texturefrac = args.TextureVPos();
_colormap = args.Colormap(); _colormap = args.Colormap();
_source = args.dc_source; _source = args.TexturePixels();
_translation = args.TranslationMap(); _translation = args.TranslationMap();
_color = args.dc_color; _color = args.SolidColor();
_srcblend = args.dc_srcblend; _srcblend = args.SrcBlend();
_destblend = args.dc_destblend; _destblend = args.DestBlend();
_srccolor = args.dc_srccolor; _srccolor = args.SrcColorIndex();
_srcalpha = args.dc_srcalpha; _srcalpha = args.SrcAlpha();
_destalpha = args.dc_destalpha; _destalpha = args.DestAlpha();
} }
void DrawColumnPalCommand::Execute(DrawerThread *thread) void DrawColumnPalCommand::Execute(DrawerThread *thread)
@ -1764,9 +1764,9 @@ namespace swrenderer
DrawFuzzColumnPalCommand::DrawFuzzColumnPalCommand(const SpriteDrawerArgs &args) DrawFuzzColumnPalCommand::DrawFuzzColumnPalCommand(const SpriteDrawerArgs &args)
{ {
_yl = args.dc_yl; _yl = args.FuzzY1();
_yh = args.dc_yh; _yh = args.FuzzY2();
_x = args.dc_x; _x = args.FuzzX();
_destorg = RenderViewport::Instance()->GetDest(0, 0); _destorg = RenderViewport::Instance()->GetDest(0, 0);
_pitch = RenderViewport::Instance()->RenderTarget->GetPitch(); _pitch = RenderViewport::Instance()->RenderTarget->GetPitch();
_fuzzpos = fuzzpos; _fuzzpos = fuzzpos;

View file

@ -251,23 +251,23 @@ namespace swrenderer
auto shade_constants = drawerargs.ColormapConstants(); auto shade_constants = drawerargs.ColormapConstants();
args.dest = (uint32_t*)drawerargs.Dest(); args.dest = (uint32_t*)drawerargs.Dest();
args.source = drawerargs.dc_source; args.source = drawerargs.TexturePixels();
args.source2 = drawerargs.dc_source2; args.source2 = drawerargs.TexturePixels2();
args.colormap = drawerargs.Colormap(); args.colormap = drawerargs.Colormap();
args.translation = drawerargs.TranslationMap(); args.translation = drawerargs.TranslationMap();
args.basecolors = (const uint32_t *)GPalette.BaseColors; args.basecolors = (const uint32_t *)GPalette.BaseColors;
args.pitch = RenderViewport::Instance()->RenderTarget->GetPitch(); args.pitch = RenderViewport::Instance()->RenderTarget->GetPitch();
args.count = drawerargs.dc_count; args.count = drawerargs.Count();
args.dest_y = drawerargs.DestY(); args.dest_y = drawerargs.DestY();
args.iscale = drawerargs.dc_iscale; args.iscale = drawerargs.TextureVStep();
args.texturefracx = drawerargs.dc_texturefracx; args.texturefracx = drawerargs.TextureUPos();
args.textureheight = drawerargs.dc_textureheight; args.textureheight = drawerargs.TextureHeight();
args.texturefrac = drawerargs.dc_texturefrac; args.texturefrac = drawerargs.TextureVPos();
args.light = LightBgra::calc_light_multiplier(drawerargs.Light()); args.light = LightBgra::calc_light_multiplier(drawerargs.Light());
args.color = LightBgra::shade_pal_index_simple(drawerargs.dc_color, args.light); args.color = LightBgra::shade_pal_index_simple(drawerargs.SolidColor(), args.light);
args.srccolor = drawerargs.dc_srccolor_bgra; args.srccolor = drawerargs.SrcColorBgra();
args.srcalpha = drawerargs.dc_srcalpha >> (FRACBITS - 8); args.srcalpha = drawerargs.SrcAlpha() >> (FRACBITS - 8);
args.destalpha = drawerargs.dc_destalpha >> (FRACBITS - 8); args.destalpha = drawerargs.DestAlpha() >> (FRACBITS - 8);
args.light_red = shade_constants.light_red; args.light_red = shade_constants.light_red;
args.light_green = shade_constants.light_green; args.light_green = shade_constants.light_green;
args.light_blue = shade_constants.light_blue; args.light_blue = shade_constants.light_blue;
@ -328,9 +328,9 @@ namespace swrenderer
DrawFuzzColumnRGBACommand::DrawFuzzColumnRGBACommand(const SpriteDrawerArgs &drawerargs) DrawFuzzColumnRGBACommand::DrawFuzzColumnRGBACommand(const SpriteDrawerArgs &drawerargs)
{ {
_x = drawerargs.dc_x; _x = drawerargs.FuzzX();
_yl = drawerargs.dc_yl; _yl = drawerargs.FuzzY1();
_yh = drawerargs.dc_yh; _yh = drawerargs.FuzzY2();
_destorg = RenderViewport::Instance()->GetDest(0, 0); _destorg = RenderViewport::Instance()->GetDest(0, 0);
_pitch = RenderViewport::Instance()->RenderTarget->GetPitch(); _pitch = RenderViewport::Instance()->RenderTarget->GetPitch();
_fuzzpos = fuzzpos; _fuzzpos = fuzzpos;

View file

@ -192,11 +192,11 @@ namespace swrenderer
uint32_t TextureUPos() const { return dc_texturefracx; } uint32_t TextureUPos() const { return dc_texturefracx; }
fixed_t TextureVPos() const { return dc_texturefrac; } fixed_t TextureVPos() const { return dc_texturefrac; }
fixed_t TextureVStep() const { return dc_iscale; } fixed_t TextureVStep() const { return dc_iscale; }
uint32_t TextureHeight() const { return dc_textureheight; }
const uint8_t *TexturePixels() const { return dc_source; } const uint8_t *TexturePixels() const { return dc_source; }
const uint8_t *TexturePixels2() const { return dc_source2; } const uint8_t *TexturePixels2() const { return dc_source2; }
uint32_t TextureHeight() const { return dc_textureheight; }
int TextureFracBits() const { return dc_wall_fracbits; } int TextureFracBits() const { return dc_wall_fracbits; }
FVector3 dc_normal; FVector3 dc_normal;
@ -234,35 +234,37 @@ namespace swrenderer
bool SetPatchStyle(FRenderStyle style, fixed_t alpha, int translation, uint32_t color, FDynamicColormap *&basecolormap, fixed_t shadedlightshade = 0); bool SetPatchStyle(FRenderStyle style, fixed_t alpha, int translation, uint32_t color, FDynamicColormap *&basecolormap, fixed_t shadedlightshade = 0);
bool SetPatchStyle(FRenderStyle style, float alpha, int translation, uint32_t color, FDynamicColormap *&basecolormap, fixed_t shadedlightshade = 0); bool SetPatchStyle(FRenderStyle style, float alpha, int translation, uint32_t color, FDynamicColormap *&basecolormap, fixed_t shadedlightshade = 0);
void SetDest(int x, int y);
void SetCount(int count) { dc_count = count; }
void SetSolidColor(int color) { dc_color = color; }
void DrawMaskedColumn(int x, fixed_t iscale, FTexture *texture, fixed_t column, double spryscale, double sprtopscreen, bool sprflipvert, const short *mfloorclip, const short *mceilingclip, bool unmasked = false); void DrawMaskedColumn(int x, fixed_t iscale, FTexture *texture, fixed_t column, double spryscale, double sprtopscreen, bool sprflipvert, const short *mfloorclip, const short *mceilingclip, bool unmasked = false);
void FillColumn(); void FillColumn();
void SetDest(int x, int y);
uint8_t *Dest() const { return dc_dest; } uint8_t *Dest() const { return dc_dest; }
int DestY() const { return dc_dest_y; } int DestY() const { return dc_dest_y; }
int Count() const { return dc_count; }
int dc_x; int FuzzX() const { return dc_x; }
int dc_yl; int FuzzY1() const { return dc_yl; }
int dc_yh; int FuzzY2() const { return dc_yh; }
fixed_t dc_iscale; uint32_t TextureUPos() const { return dc_texturefracx; }
fixed_t dc_texturefrac; fixed_t TextureVPos() const { return dc_texturefrac; }
uint32_t dc_texturefracx; fixed_t TextureVStep() const { return dc_iscale; }
uint32_t dc_textureheight;
const uint8_t *dc_source;
const uint8_t *dc_source2;
int dc_count;
int dc_color = 0; int SolidColor() const { return dc_color; }
uint32_t dc_srccolor; uint32_t SrcColorIndex() const { return dc_srccolor; }
uint32_t dc_srccolor_bgra; uint32_t SrcColorBgra() const { return dc_srccolor_bgra; }
uint32_t *dc_srcblend; const uint8_t *TexturePixels() const { return dc_source; }
uint32_t *dc_destblend; const uint8_t *TexturePixels2() const { return dc_source2; }
fixed_t dc_srcalpha; uint32_t TextureHeight() const { return dc_textureheight; }
fixed_t dc_destalpha;
uint32_t *SrcBlend() const { return dc_srcblend; }
uint32_t *DestBlend() const { return dc_destblend; }
fixed_t SrcAlpha() const { return dc_srcalpha; }
fixed_t DestAlpha() const { return dc_destalpha; }
private: private:
bool SetBlendFunc(int op, fixed_t fglevel, fixed_t bglevel, int flags); bool SetBlendFunc(int op, fixed_t fglevel, fixed_t bglevel, int flags);
@ -271,8 +273,30 @@ namespace swrenderer
uint8_t *dc_dest = nullptr; uint8_t *dc_dest = nullptr;
int dc_dest_y = 0; int dc_dest_y = 0;
int dc_count = 0;
fixed_t dc_iscale;
fixed_t dc_texturefrac;
uint32_t dc_texturefracx;
uint32_t dc_textureheight = 0;
const uint8_t *dc_source = nullptr;
const uint8_t *dc_source2 = nullptr;
bool drawer_needs_pal_input = false; bool drawer_needs_pal_input = false;
uint32_t *dc_srcblend = nullptr;
uint32_t *dc_destblend = nullptr;
fixed_t dc_srcalpha = OPAQUE;
fixed_t dc_destalpha = 0;
int dc_x = 0;
int dc_yl = 0;
int dc_yh = 0;
int dc_color = 0;
uint32_t dc_srccolor = 0;
uint32_t dc_srccolor_bgra = 0;
typedef void(SWPixelFormatDrawers::*SpriteDrawerFunc)(const SpriteDrawerArgs &args); typedef void(SWPixelFormatDrawers::*SpriteDrawerFunc)(const SpriteDrawerArgs &args);
SpriteDrawerFunc colfunc; SpriteDrawerFunc colfunc;
}; };

View file

@ -342,8 +342,8 @@ namespace swrenderer
if (columnY1 < columnY2) if (columnY1 < columnY2)
{ {
drawerargs.SetDest(x, columnY1); drawerargs.SetDest(x, columnY1);
drawerargs.dc_color = color; drawerargs.SetSolidColor(color);
drawerargs.dc_count = columnY2 - columnY1; drawerargs.SetCount(columnY2 - columnY1);
drawerargs.FillColumn(); drawerargs.FillColumn();
} }
} }