- changed DrawTexture so that the parameters get parsed in the varargs function directly and that the virtual function that is getting called gets the fully prepared data.

In order to avoid passing around tag lists, DrawTextV needs to parse everything itself and then pass a fully initialized structure to DrawTexture. This cannot be done if all variants require a varargs tag list.
Apparently the only reason for the old approach was the 'hw' parameter which was never used.
This commit is contained in:
Christoph Oelckers 2016-04-09 12:55:12 +02:00
parent ca317a87ea
commit 43dd759859
4 changed files with 55 additions and 54 deletions

View File

@ -110,23 +110,22 @@ void STACK_ARGS DCanvas::DrawTexture (FTexture *img, double x, double y, int tag
{
va_list tags;
va_start(tags, tags_first);
DrawTextureV(img, x, y, tags_first, tags);
DrawParms parms;
if (!ParseDrawTextureTags(img, x, y, tags_first, tags, &parms, false))
{
return;
}
DrawTextureParms(img, x, y, parms);
}
void STACK_ARGS DCanvas::DrawTextureV(FTexture *img, double x, double y, uint32 tag, va_list tags)
void DCanvas::DrawTextureParms(FTexture *img, double x, double y, DrawParms &parms)
{
#ifndef NO_SWRENDER
FTexture::Span unmaskedSpan[2];
const FTexture::Span **spanptr, *spans;
static short bottomclipper[MAXWIDTH], topclipper[MAXWIDTH];
DrawParms parms;
if (!ParseDrawTextureTags(img, x, y, tag, tags, &parms, false))
{
return;
}
if (parms.masked)
{
spanptr = &spans;
@ -171,6 +170,10 @@ void STACK_ARGS DCanvas::DrawTextureV(FTexture *img, double x, double y, uint32
BYTE *destorgsave = dc_destorg;
dc_destorg = screen->GetBuffer();
if (dc_destorg == NULL)
{
I_FatalError("Attempt to write to buffer of hardware canvas");
}
double x0 = parms.x - parms.left * parms.destwidth / parms.texwidth;
double y0 = parms.y - parms.top * parms.destheight / parms.texheight;
@ -327,7 +330,7 @@ void STACK_ARGS DCanvas::DrawTextureV(FTexture *img, double x, double y, uint32
#endif
}
bool DCanvas::ParseDrawTextureTags (FTexture *img, double x, double y, DWORD tag, va_list tags, DrawParms *parms, bool hw) const
bool DCanvas::ParseDrawTextureTags (FTexture *img, double x, double y, DWORD tag, va_list tags, DrawParms *parms, bool fortext) const
{
INTBOOL boolval;
int intval;

View File

@ -138,6 +138,40 @@ struct FRemapTable;
class player_t;
typedef uint32 angle_t;
struct DrawParms
{
double x, y;
double texwidth;
double texheight;
double destwidth;
double destheight;
double virtWidth;
double virtHeight;
double windowleft;
double windowright;
int dclip;
int uclip;
int lclip;
int rclip;
double top;
double left;
float Alpha;
uint32 fillcolor;
FRemapTable *remap;
const BYTE *translation;
uint32 colorOverlay;
INTBOOL alphaChannel;
INTBOOL flipX;
fixed_t shadowAlpha;
int shadowColor;
INTBOOL keepratio;
INTBOOL masked;
INTBOOL bilinear;
FRenderStyle style;
struct FSpecialColormap *specialcolormap;
struct FColormapStyle *colormapstyle;
};
//
// VIDEO
//
@ -223,40 +257,6 @@ public:
void DrawTextV (FFont *font, int normalcolor, int x, int y, const char *string, va_list tags);
void STACK_ARGS DrawChar (FFont *font, int normalcolor, int x, int y, BYTE character, ...);
struct DrawParms
{
double x, y;
double texwidth;
double texheight;
double destwidth;
double destheight;
double virtWidth;
double virtHeight;
double windowleft;
double windowright;
int dclip;
int uclip;
int lclip;
int rclip;
double top;
double left;
float Alpha;
uint32 fillcolor;
FRemapTable *remap;
const BYTE *translation;
uint32 colorOverlay;
INTBOOL alphaChannel;
INTBOOL flipX;
fixed_t shadowAlpha;
int shadowColor;
INTBOOL keepratio;
INTBOOL masked;
INTBOOL bilinear;
FRenderStyle style;
struct FSpecialColormap *specialcolormap;
struct FColormapStyle *colormapstyle;
};
protected:
BYTE *Buffer;
int Width;
@ -265,8 +265,9 @@ protected:
int LockCount;
bool ClipBox (int &left, int &top, int &width, int &height, const BYTE *&src, const int srcpitch) const;
virtual void STACK_ARGS DrawTextureV (FTexture *img, double x, double y, uint32 tag, va_list tags);
bool ParseDrawTextureTags (FTexture *img, double x, double y, uint32 tag, va_list tags, DrawParms *parms, bool hw) const;
void DrawTextureV(FTexture *img, double x, double y, uint32 tag, va_list tags) = delete;
virtual void DrawTextureParms(FTexture *img, double x, double y, DrawParms &parms);
bool ParseDrawTextureTags (FTexture *img, double x, double y, uint32 tag, va_list tags, DrawParms *parms, bool fortext) const;
DCanvas() {}

View File

@ -2762,17 +2762,14 @@ void D3DFB::DrawPixel(int x, int y, int palcolor, uint32 color)
//
//==========================================================================
void STACK_ARGS D3DFB::DrawTextureV (FTexture *img, double x, double y, uint32 tags_first, va_list tags)
void D3DFB::DrawTextureParms (FTexture *img, double x, double y, DrawParms &parms)
{
if (In2D < 2)
{
Super::DrawTextureV(img, x, y, tags_first, tags);
Super::DrawTextureParms(img, x, y, parms);
return;
}
DrawParms parms;
if (!InScene || !ParseDrawTextureTags(img, x, y, tags_first, tags, &parms, true))
if (!InScene)
{
return;
}

View File

@ -257,7 +257,7 @@ public:
void DrawBlendingRect ();
FNativeTexture *CreateTexture (FTexture *gametex, bool wrapping);
FNativePalette *CreatePalette (FRemapTable *remap);
void STACK_ARGS DrawTextureV (FTexture *img, double x, double y, uint32 tag, va_list tags);
void DrawTextureParms (FTexture *img, double x, double y, DrawParms &parms);
void Clear (int left, int top, int right, int bottom, int palcolor, uint32 color);
void Dim (PalEntry color, float amount, int x1, int y1, int w, int h);
void FlatFill (int left, int top, int right, int bottom, FTexture *src, bool local_origin);
@ -370,7 +370,7 @@ private:
void DrawPackedTextures(int packnum);
void DrawLetterbox();
void Draw3DPart(bool copy3d);
bool SetStyle(D3DTex *tex, DCanvas::DrawParms &parms, D3DCOLOR &color0, D3DCOLOR &color1, BufferedTris &quad);
bool SetStyle(D3DTex *tex, DrawParms &parms, D3DCOLOR &color0, D3DCOLOR &color1, BufferedTris &quad);
static D3DBLEND GetStyleAlpha(int type);
static void SetColorOverlay(DWORD color, float alpha, D3DCOLOR &color0, D3DCOLOR &color1);
void DoWindowedGamma();