mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-12 07:34:50 +00:00
- 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:
parent
ca317a87ea
commit
43dd759859
4 changed files with 55 additions and 54 deletions
|
@ -110,23 +110,22 @@ void STACK_ARGS DCanvas::DrawTexture (FTexture *img, double x, double y, int tag
|
||||||
{
|
{
|
||||||
va_list tags;
|
va_list tags;
|
||||||
va_start(tags, tags_first);
|
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
|
#ifndef NO_SWRENDER
|
||||||
FTexture::Span unmaskedSpan[2];
|
FTexture::Span unmaskedSpan[2];
|
||||||
const FTexture::Span **spanptr, *spans;
|
const FTexture::Span **spanptr, *spans;
|
||||||
static short bottomclipper[MAXWIDTH], topclipper[MAXWIDTH];
|
static short bottomclipper[MAXWIDTH], topclipper[MAXWIDTH];
|
||||||
|
|
||||||
DrawParms parms;
|
|
||||||
|
|
||||||
if (!ParseDrawTextureTags(img, x, y, tag, tags, &parms, false))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parms.masked)
|
if (parms.masked)
|
||||||
{
|
{
|
||||||
spanptr = &spans;
|
spanptr = &spans;
|
||||||
|
@ -171,6 +170,10 @@ void STACK_ARGS DCanvas::DrawTextureV(FTexture *img, double x, double y, uint32
|
||||||
|
|
||||||
BYTE *destorgsave = dc_destorg;
|
BYTE *destorgsave = dc_destorg;
|
||||||
dc_destorg = screen->GetBuffer();
|
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 x0 = parms.x - parms.left * parms.destwidth / parms.texwidth;
|
||||||
double y0 = parms.y - parms.top * parms.destheight / parms.texheight;
|
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
|
#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;
|
INTBOOL boolval;
|
||||||
int intval;
|
int intval;
|
||||||
|
|
|
@ -138,6 +138,40 @@ struct FRemapTable;
|
||||||
class player_t;
|
class player_t;
|
||||||
typedef uint32 angle_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
|
// VIDEO
|
||||||
//
|
//
|
||||||
|
@ -223,40 +257,6 @@ public:
|
||||||
void DrawTextV (FFont *font, int normalcolor, int x, int y, const char *string, va_list tags);
|
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, ...);
|
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:
|
protected:
|
||||||
BYTE *Buffer;
|
BYTE *Buffer;
|
||||||
int Width;
|
int Width;
|
||||||
|
@ -265,8 +265,9 @@ protected:
|
||||||
int LockCount;
|
int LockCount;
|
||||||
|
|
||||||
bool ClipBox (int &left, int &top, int &width, int &height, const BYTE *&src, const int srcpitch) const;
|
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);
|
void DrawTextureV(FTexture *img, double x, double y, uint32 tag, va_list tags) = delete;
|
||||||
bool ParseDrawTextureTags (FTexture *img, double x, double y, uint32 tag, va_list tags, DrawParms *parms, bool hw) const;
|
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() {}
|
DCanvas() {}
|
||||||
|
|
||||||
|
|
|
@ -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)
|
if (In2D < 2)
|
||||||
{
|
{
|
||||||
Super::DrawTextureV(img, x, y, tags_first, tags);
|
Super::DrawTextureParms(img, x, y, parms);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!InScene)
|
||||||
DrawParms parms;
|
|
||||||
|
|
||||||
if (!InScene || !ParseDrawTextureTags(img, x, y, tags_first, tags, &parms, true))
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -257,7 +257,7 @@ public:
|
||||||
void DrawBlendingRect ();
|
void DrawBlendingRect ();
|
||||||
FNativeTexture *CreateTexture (FTexture *gametex, bool wrapping);
|
FNativeTexture *CreateTexture (FTexture *gametex, bool wrapping);
|
||||||
FNativePalette *CreatePalette (FRemapTable *remap);
|
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 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 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);
|
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 DrawPackedTextures(int packnum);
|
||||||
void DrawLetterbox();
|
void DrawLetterbox();
|
||||||
void Draw3DPart(bool copy3d);
|
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 D3DBLEND GetStyleAlpha(int type);
|
||||||
static void SetColorOverlay(DWORD color, float alpha, D3DCOLOR &color0, D3DCOLOR &color1);
|
static void SetColorOverlay(DWORD color, float alpha, D3DCOLOR &color0, D3DCOLOR &color1);
|
||||||
void DoWindowedGamma();
|
void DoWindowedGamma();
|
||||||
|
|
Loading…
Reference in a new issue