mirror of
https://github.com/fabiangreffrath/woof.git
synced 2025-09-22 11:22:18 -04:00
optimise HUD widget erasing, avoid flicker when screen size is reduced (#1349)
This commit is contained in:
parent
e4464862c5
commit
b2c7b40641
@ -317,6 +317,7 @@ void D_Display (void)
|
|||||||
if (borderdrawcount)
|
if (borderdrawcount)
|
||||||
{
|
{
|
||||||
R_DrawViewBorder (); // erase old menu stuff
|
R_DrawViewBorder (); // erase old menu stuff
|
||||||
|
HU_Drawer ();
|
||||||
borderdrawcount--;
|
borderdrawcount--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
37
src/hu_lib.c
37
src/hu_lib.c
@ -22,6 +22,8 @@
|
|||||||
#include "m_swap.h"
|
#include "m_swap.h"
|
||||||
#include "hu_lib.h"
|
#include "hu_lib.h"
|
||||||
#include "hu_stuff.h"
|
#include "hu_stuff.h"
|
||||||
|
#include "r_draw.h"
|
||||||
|
#include "v_video.h"
|
||||||
|
|
||||||
// [FG] horizontal alignment
|
// [FG] horizontal alignment
|
||||||
|
|
||||||
@ -121,13 +123,12 @@ boolean HUlib_add_key_to_line(hu_line_t *const l, unsigned char ch)
|
|||||||
{
|
{
|
||||||
if (ch >= ' ' && ch <= '_')
|
if (ch >= ' ' && ch <= '_')
|
||||||
add_char_to_line(l, (char) ch);
|
add_char_to_line(l, (char) ch);
|
||||||
else
|
else if (ch == KEY_BACKSPACE) // phares
|
||||||
if (ch == KEY_BACKSPACE) // phares
|
del_char_from_line(l);
|
||||||
del_char_from_line(l);
|
else if (ch != KEY_ENTER) // phares
|
||||||
else
|
return false; // did not eat key
|
||||||
if (ch != KEY_ENTER) // phares
|
|
||||||
return false; // did not eat key
|
return true; // ate the key
|
||||||
return true; // ate the key
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean HUlib_add_key_to_cur_line(hu_multiline_t *const m, unsigned char ch)
|
boolean HUlib_add_key_to_cur_line(hu_multiline_t *const m, unsigned char ch)
|
||||||
@ -503,6 +504,28 @@ void HUlib_init_multiline(hu_multiline_t *m,
|
|||||||
m->built = false;
|
m->built = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HUlib_erase_widget (const hu_widget_t *const w)
|
||||||
|
{
|
||||||
|
const hu_multiline_t *const m = w->multiline;
|
||||||
|
const hu_font_t *const f = *m->font;
|
||||||
|
|
||||||
|
const int height = m->numlines * f->line_height;
|
||||||
|
const int y = vert_align_widget(w, m, f, w->h_align, w->v_align);
|
||||||
|
|
||||||
|
if (y < scaledviewy || y >= scaledviewy + scaledviewheight)
|
||||||
|
{
|
||||||
|
// erase entire line
|
||||||
|
R_VideoErase(0, y, video.unscaledw, height);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// erase left border
|
||||||
|
R_VideoErase(0, y, scaledviewx, height);
|
||||||
|
// erase right border
|
||||||
|
R_VideoErase(scaledviewx + scaledviewwidth, y, scaledviewx, height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// $Log: hu_lib.c,v $
|
// $Log: hu_lib.c,v $
|
||||||
|
@ -137,6 +137,8 @@ void HUlib_init_multiline (hu_multiline_t *const m, int nl, hu_font_t **f, char
|
|||||||
boolean HUlib_add_key_to_line (hu_line_t *const l, unsigned char ch);
|
boolean HUlib_add_key_to_line (hu_line_t *const l, unsigned char ch);
|
||||||
boolean HUlib_add_key_to_cur_line (hu_multiline_t *const m, unsigned char ch);
|
boolean HUlib_add_key_to_cur_line (hu_multiline_t *const m, unsigned char ch);
|
||||||
|
|
||||||
|
void HUlib_erase_widget (const hu_widget_t *const w);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "hu_stuff.h"
|
#include "hu_stuff.h"
|
||||||
#include "hu_obituary.h"
|
#include "hu_obituary.h"
|
||||||
#include "hu_lib.h"
|
#include "hu_lib.h"
|
||||||
|
#include "r_state.h"
|
||||||
#include "st_stuff.h" /* jff 2/16/98 need loc of status bar */
|
#include "st_stuff.h" /* jff 2/16/98 need loc of status bar */
|
||||||
#include "w_wad.h"
|
#include "w_wad.h"
|
||||||
#include "s_sound.h"
|
#include "s_sound.h"
|
||||||
@ -1423,15 +1424,6 @@ void HU_Drawer(void)
|
|||||||
|
|
||||||
HUlib_reset_align_offsets();
|
HUlib_reset_align_offsets();
|
||||||
|
|
||||||
// jff 4/24/98 Erase current lines before drawing current
|
|
||||||
// needed when screen not fullsize
|
|
||||||
// killough 11/98: only do it when not fullsize
|
|
||||||
// moved here to properly update the w_sttime and w_monsec widgets
|
|
||||||
if (scaledviewheight < 200)
|
|
||||||
{
|
|
||||||
HU_Erase();
|
|
||||||
}
|
|
||||||
|
|
||||||
w = doom_widget;
|
w = doom_widget;
|
||||||
while (w->multiline)
|
while (w->multiline)
|
||||||
{
|
{
|
||||||
@ -1482,9 +1474,32 @@ void WI_DrawTimeWidget(void)
|
|||||||
|
|
||||||
void HU_Erase(void)
|
void HU_Erase(void)
|
||||||
{
|
{
|
||||||
// [FG] TODO optimize!
|
hu_widget_t *w;
|
||||||
if (!automapactive && viewwindowx)
|
|
||||||
R_DrawViewBorder();
|
if (automapactive || !scaledviewx)
|
||||||
|
return;
|
||||||
|
|
||||||
|
HUlib_reset_align_offsets();
|
||||||
|
|
||||||
|
w = doom_widget;
|
||||||
|
while (w->multiline)
|
||||||
|
{
|
||||||
|
if (*w->multiline->on)
|
||||||
|
{
|
||||||
|
HUlib_erase_widget(w);
|
||||||
|
}
|
||||||
|
w++;
|
||||||
|
}
|
||||||
|
|
||||||
|
w = boom_widget;
|
||||||
|
while (w->multiline)
|
||||||
|
{
|
||||||
|
if (w->multiline->built)
|
||||||
|
{
|
||||||
|
HUlib_erase_widget(w);
|
||||||
|
}
|
||||||
|
w++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
31
src/r_draw.c
31
src/r_draw.c
@ -913,9 +913,12 @@ void R_FillBackScreen (void)
|
|||||||
// Copy a screen buffer.
|
// Copy a screen buffer.
|
||||||
//
|
//
|
||||||
|
|
||||||
static void R_VideoErase(int x, int y, int w, int h)
|
void R_VideoErase(int x, int y, int w, int h)
|
||||||
{
|
{
|
||||||
V_CopyRect(x, y, background_buffer, w, h, x, y);
|
if (background_buffer == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
V_CopyRect(x, y, background_buffer, w, h, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -928,23 +931,23 @@ static void R_VideoErase(int x, int y, int w, int h)
|
|||||||
// can scale to hires automatically in R_VideoErase().
|
// can scale to hires automatically in R_VideoErase().
|
||||||
//
|
//
|
||||||
|
|
||||||
void R_DrawViewBorder(void)
|
void R_DrawViewBorder(void)
|
||||||
{
|
{
|
||||||
int side;
|
int side;
|
||||||
|
|
||||||
if (scaledviewwidth == video.unscaledw || background_buffer == NULL)
|
if (scaledviewwidth == video.unscaledw || background_buffer == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// copy top
|
// copy top
|
||||||
R_VideoErase(0, 0, video.unscaledw, scaledviewy);
|
R_VideoErase(0, 0, video.unscaledw, scaledviewy);
|
||||||
|
|
||||||
// copy sides
|
// copy sides
|
||||||
side = scaledviewx;
|
side = scaledviewx;
|
||||||
R_VideoErase(0, scaledviewy, side, scaledviewheight);
|
R_VideoErase(0, scaledviewy, side, scaledviewheight);
|
||||||
R_VideoErase(video.unscaledw - side, scaledviewy, side, scaledviewheight);
|
R_VideoErase(video.unscaledw - side, scaledviewy, side, scaledviewheight);
|
||||||
|
|
||||||
// copy bottom
|
// copy bottom
|
||||||
R_VideoErase(0, scaledviewy + scaledviewheight, video.unscaledw, scaledviewy);
|
R_VideoErase(0, scaledviewy + scaledviewheight, video.unscaledw, scaledviewy);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -82,6 +82,7 @@ void R_InitBuffer(void);
|
|||||||
void R_InitTranslationTables(void);
|
void R_InitTranslationTables(void);
|
||||||
|
|
||||||
// Rendering function.
|
// Rendering function.
|
||||||
|
void R_VideoErase(int x, int y, int w, int h);
|
||||||
void R_FillBackScreen(void);
|
void R_FillBackScreen(void);
|
||||||
void R_DrawBorder(int x, int y, int w, int h);
|
void R_DrawBorder(int x, int y, int w, int h);
|
||||||
|
|
||||||
|
@ -558,8 +558,6 @@ void R_ExecuteSetViewSize (void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//HU_disable_all_widgets();
|
|
||||||
|
|
||||||
// [crispy] forcefully initialize the status bar backing screen
|
// [crispy] forcefully initialize the status bar backing screen
|
||||||
ST_refreshBackground(true);
|
ST_refreshBackground(true);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user