(GDI) Put gdi_menu_frame into struct

This commit is contained in:
twinaphex 2020-03-07 16:50:25 +01:00
parent efe72dea94
commit d63daacdf9
4 changed files with 19 additions and 19 deletions

View File

@ -49,6 +49,7 @@ typedef struct gdi
int win_minor; int win_minor;
bool lte_win98; bool lte_win98;
unsigned short *temp_buf; unsigned short *temp_buf;
unsigned char *menu_frame;
} gdi_t; } gdi_t;
typedef struct gdi_texture typedef struct gdi_texture

View File

@ -1149,7 +1149,7 @@ LRESULT CALLBACK WndProcGDI(HWND hwnd, UINT message,
gdi->bmp_old = (HBITMAP)SelectObject(gdi->memDC, gdi->bmp); gdi->bmp_old = (HBITMAP)SelectObject(gdi->memDC, gdi->bmp);
#ifdef HAVE_MENU #ifdef HAVE_MENU
if (menu_driver_is_alive() && !gdi_has_menu_frame()) if (menu_driver_is_alive() && !gdi_has_menu_frame(gdi))
{ {
/* draw menu contents behind a gradient background */ /* draw menu contents behind a gradient background */
if (gdi && gdi->memDC) if (gdi && gdi->memDC)

View File

@ -62,7 +62,7 @@ void create_graphics_context(HWND hwnd, bool *quit);
void create_gdi_context(HWND hwnd, bool *quit); void create_gdi_context(HWND hwnd, bool *quit);
bool gdi_has_menu_frame(void); bool gdi_has_menu_frame(void *data);
bool win32_get_video_output(DEVMODE *dm, int mode, size_t len); bool win32_get_video_output(DEVMODE *dm, int mode, size_t len);

View File

@ -39,8 +39,6 @@
#include "../common/win32_common.h" #include "../common/win32_common.h"
#endif #endif
static unsigned char *gdi_menu_frame = NULL;
static void gdi_gfx_create(gdi_t *gdi) static void gdi_gfx_create(gdi_t *gdi)
{ {
char os[64] = {0}; char os[64] = {0};
@ -215,9 +213,9 @@ static bool gdi_gfx_frame(void *data, const void *frame,
} }
} }
if (gdi_menu_frame && video_info->menu_is_alive) if (gdi->menu_frame && video_info->menu_is_alive)
{ {
frame_to_copy = gdi_menu_frame; frame_to_copy = gdi->menu_frame;
width = gdi->menu_width; width = gdi->menu_width;
height = gdi->menu_height; height = gdi->menu_height;
pitch = gdi->menu_pitch; pitch = gdi->menu_pitch;
@ -319,7 +317,7 @@ static bool gdi_gfx_frame(void *data, const void *frame,
info->bmiHeader.biCompression = BI_BITFIELDS; info->bmiHeader.biCompression = BI_BITFIELDS;
/* default 16-bit format on Windows is XRGB1555 */ /* default 16-bit format on Windows is XRGB1555 */
if (frame_to_copy == gdi_menu_frame) if (frame_to_copy == gdi->menu_frame)
{ {
/* map RGB444 color bits for RGUI */ /* map RGB444 color bits for RGUI */
masks[0] = 0xF000; masks[0] = 0xF000;
@ -411,9 +409,9 @@ static void gdi_gfx_free(void *data)
if (!gdi) if (!gdi)
return; return;
if (gdi_menu_frame) if (gdi->menu_frame)
free(gdi_menu_frame); free(gdi->menu_frame);
gdi_menu_frame = NULL; gdi->menu_frame = NULL;
if (gdi->temp_buf) if (gdi->temp_buf)
free(gdi->temp_buf); free(gdi->temp_buf);
@ -464,11 +462,11 @@ static void gdi_set_texture_frame(void *data,
if (rgb32) if (rgb32)
pitch = width * 4; pitch = width * 4;
if (gdi_menu_frame) if (gdi->menu_frame)
free(gdi_menu_frame); free(gdi->menu_frame);
gdi_menu_frame = NULL; gdi->menu_frame = NULL;
if ( !gdi_menu_frame || if ( !gdi->menu_frame ||
gdi->menu_width != width || gdi->menu_width != width ||
gdi->menu_height != height || gdi->menu_height != height ||
gdi->menu_pitch != pitch) gdi->menu_pitch != pitch)
@ -478,13 +476,13 @@ static void gdi_set_texture_frame(void *data,
unsigned char *tmp = (unsigned char*)malloc(pitch * height); unsigned char *tmp = (unsigned char*)malloc(pitch * height);
if (tmp) if (tmp)
gdi_menu_frame = tmp; gdi->menu_frame = tmp;
} }
} }
if (gdi_menu_frame && frame && pitch && height) if (gdi->menu_frame && frame && pitch && height)
{ {
memcpy(gdi_menu_frame, frame, pitch * height); memcpy(gdi->menu_frame, frame, pitch * height);
gdi->menu_width = width; gdi->menu_width = width;
gdi->menu_height = height; gdi->menu_height = height;
gdi->menu_pitch = pitch; gdi->menu_pitch = pitch;
@ -620,9 +618,10 @@ static void gdi_gfx_set_viewport(void *data, unsigned viewport_width,
{ {
} }
bool gdi_has_menu_frame(void) bool gdi_has_menu_frame(void *data)
{ {
return (gdi_menu_frame != NULL); gdi_t *gdi = (gdi_t*)data;
return (gdi->menu_frame != NULL);
} }
video_driver_t video_gdi = { video_driver_t video_gdi = {