diff --git a/Makefile.common b/Makefile.common
index c35f34b151..fdc4f31289 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -2040,7 +2040,6 @@ ifneq ($(findstring Win32,$(OS)),)
ifeq ($(HAVE_GDI), 1)
OBJ += gfx/drivers/gdi_gfx.o \
- gfx/drivers_context/gdi_ctx.o \
gfx/drivers_font/gdi_font.o \
gfx/drivers_display/gfx_display_gdi.o
LIBS += -lmsimg32
diff --git a/gfx/common/gdi_common.h b/gfx/common/gdi_common.h
index 4ed7cd8e86..3f5efcbfac 100644
--- a/gfx/common/gdi_common.h
+++ b/gfx/common/gdi_common.h
@@ -34,8 +34,6 @@ typedef struct gdi
unsigned video_height;
unsigned screen_width;
unsigned screen_height;
- void *ctx_data;
- const gfx_ctx_driver_t *ctx_driver;
unsigned menu_width;
unsigned menu_height;
diff --git a/gfx/drivers/gdi_gfx.c b/gfx/drivers/gdi_gfx.c
index eb311b4d15..3832a74a16 100644
--- a/gfx/drivers/gdi_gfx.c
+++ b/gfx/drivers/gdi_gfx.c
@@ -39,6 +39,140 @@
#include "../common/win32_common.h"
#endif
+static HDC win32_gdi_hdc;
+static void *dinput_gdi;
+
+static void gfx_ctx_gdi_update_title(void)
+{
+ char title[128];
+ const ui_window_t *window = ui_companion_driver_get_window_ptr();
+
+ title[0] = '\0';
+
+ video_driver_get_window_title(title, sizeof(title));
+
+ if (window && title[0])
+ window->set_title(&main_window, title);
+}
+
+static void gfx_ctx_gdi_get_video_size(
+ unsigned *width, unsigned *height)
+{
+ HWND window = win32_get_window();
+
+ if (window)
+ {
+ *width = g_win32_resize_width;
+ *height = g_win32_resize_height;
+ }
+ else
+ {
+ RECT mon_rect;
+ MONITORINFOEX current_mon;
+ unsigned mon_id = 0;
+ HMONITOR hm_to_use = NULL;
+
+ win32_monitor_info(¤t_mon, &hm_to_use, &mon_id);
+ mon_rect = current_mon.rcMonitor;
+ *width = mon_rect.right - mon_rect.left;
+ *height = mon_rect.bottom - mon_rect.top;
+ }
+}
+
+static bool gfx_ctx_gdi_init(void)
+{
+ WNDCLASSEX wndclass = {0};
+
+ if (g_win32_inited)
+ return true;
+
+ win32_window_reset();
+ win32_monitor_init();
+
+ wndclass.lpfnWndProc = WndProcGDI;
+ if (!win32_window_init(&wndclass, true, NULL))
+ return false;
+ return true;
+}
+
+static void gfx_ctx_gdi_destroy(void)
+{
+ HWND window = win32_get_window();
+
+ if (window && win32_gdi_hdc)
+ {
+ ReleaseDC(window, win32_gdi_hdc);
+ win32_gdi_hdc = NULL;
+ }
+
+ if (window)
+ {
+ win32_monitor_from_window();
+ win32_destroy_window();
+ }
+
+ if (g_win32_restore_desktop)
+ {
+ win32_monitor_get_info();
+ g_win32_restore_desktop = false;
+ }
+
+ g_win32_inited = false;
+}
+
+static bool gfx_ctx_gdi_set_video_mode(
+ unsigned width, unsigned height,
+ bool fullscreen)
+{
+ if (!win32_set_video_mode(NULL, width, height, fullscreen))
+ {
+ gfx_ctx_gdi_destroy();
+ return false;
+ }
+
+ return true;
+}
+
+static void gfx_ctx_gdi_input_driver(
+ input_driver_t **input, void **input_data)
+{
+#if _WIN32_WINNT >= 0x0501
+#ifdef HAVE_WINRAWINPUT
+ settings_t *settings = config_get_ptr();
+
+ /* winraw only available since XP */
+ if (string_is_equal(settings->arrays.input_driver, "raw"))
+ {
+ *input_data = input_winraw.init(settings->arrays.input_driver);
+ if (*input_data)
+ {
+ *input = &input_winraw;
+ dinput_gdi = NULL;
+ return;
+ }
+ }
+#endif
+#endif
+
+#ifdef HAVE_DINPUT
+ dinput_gdi = input_dinput.init(settings->arrays.input_driver);
+ *input = dinput_gdi ? &input_dinput : NULL;
+#else
+ dinput_gdi = NULL;
+ *input = NULL;
+#endif
+ *input_data = dinput_gdi;
+}
+
+void create_gdi_context(HWND hwnd, bool *quit)
+{
+ win32_gdi_hdc = GetDC(hwnd);
+
+ win32_setup_pixel_format(win32_gdi_hdc, false);
+
+ g_win32_inited = true;
+}
+
static void gdi_gfx_create(gdi_t *gdi)
{
char os[64] = {0};
@@ -65,11 +199,10 @@ static void *gdi_gfx_init(const video_info_t *video,
input_driver_t **input, void **input_data)
{
unsigned full_x, full_y;
- gfx_ctx_input_t inp;
- gfx_ctx_mode_t mode;
void *ctx_data = NULL;
const gfx_ctx_driver_t *ctx_driver = NULL;
- unsigned win_width = 0, win_height = 0;
+ unsigned mode_width = 0, mode_height = 0;
+ unsigned win_width = 0, win_height = 0;
unsigned temp_width = 0, temp_height = 0;
settings_t *settings = config_get_ptr();
bool video_font_enable = settings->bools.video_font_enable;
@@ -93,28 +226,15 @@ static void *gdi_gfx_init(const video_info_t *video,
gdi->video_pitch = video->width * 2;
gdi_gfx_create(gdi);
-
- ctx_driver = video_context_driver_init_first(gdi,
- settings->arrays.video_context_driver,
- GFX_CTX_GDI_API, 1, 0, false, &ctx_data);
- if (!ctx_driver)
+ if (!gfx_ctx_gdi_init())
goto error;
- if (ctx_data)
- gdi->ctx_data = ctx_data;
+ gfx_ctx_gdi_get_video_size(&mode_width, &mode_height);
- gdi->ctx_driver = ctx_driver;
-
- video_context_driver_set((const gfx_ctx_driver_t*)ctx_driver);
-
- RARCH_LOG("[GDI]: Found GDI context: %s\n", ctx_driver->ident);
-
- video_context_driver_get_video_size(&mode);
-
- full_x = mode.width;
- full_y = mode.height;
- mode.width = 0;
- mode.height = 0;
+ full_x = mode_width;
+ full_y = mode_height;
+ mode_width = 0;
+ mode_height = 0;
RARCH_LOG("[GDI]: Detecting screen resolution %ux%u.\n", full_x, full_y);
@@ -127,22 +247,22 @@ static void *gdi_gfx_init(const video_info_t *video,
win_height = full_y;
}
- mode.width = win_width;
- mode.height = win_height;
- mode.fullscreen = video->fullscreen;
+ mode_width = win_width;
+ mode_height = win_height;
- if (!video_context_driver_set_video_mode(&mode))
+ if (!gfx_ctx_gdi_set_video_mode(mode_width,
+ mode_height, video->fullscreen))
goto error;
- mode.width = 0;
- mode.height = 0;
+ mode_width = 0;
+ mode_height = 0;
- video_context_driver_get_video_size(&mode);
+ gfx_ctx_gdi_get_video_size(&mode_width, &mode_height);
- temp_width = mode.width;
- temp_height = mode.height;
- mode.width = 0;
- mode.height = 0;
+ temp_width = mode_width;
+ temp_height = mode_height;
+ mode_width = 0;
+ mode_height = 0;
/* Get real known video size, which might have been altered by context. */
@@ -153,10 +273,7 @@ static void *gdi_gfx_init(const video_info_t *video,
RARCH_LOG("[GDI]: Using resolution %ux%u\n", temp_width, temp_height);
- inp.input = input;
- inp.input_data = input_data;
-
- video_context_driver_input_driver(&inp);
+ gfx_ctx_gdi_input_driver(input, input_data);
if (video_font_enable)
font_driver_init_osd(gdi,
@@ -170,7 +287,7 @@ static void *gdi_gfx_init(const video_info_t *video,
return gdi;
error:
- video_context_driver_destroy();
+ gfx_ctx_gdi_destroy();
if (gdi)
free(gdi);
return NULL;
@@ -181,7 +298,8 @@ static bool gdi_gfx_frame(void *data, const void *frame,
unsigned pitch, const char *msg, video_frame_info_t *video_info)
{
BITMAPINFO *info;
- gfx_ctx_mode_t mode;
+ unsigned mode_width = 0;
+ unsigned mode_height = 0;
const void *frame_to_copy = frame;
unsigned width = 0;
unsigned height = 0;
@@ -276,10 +394,10 @@ static bool gdi_gfx_frame(void *data, const void *frame,
}
}
- video_context_driver_get_video_size(&mode);
+ gfx_ctx_gdi_get_video_size(&mode_width, &mode_height);
- gdi->screen_width = mode.width;
- gdi->screen_height = mode.height;
+ gdi->screen_width = mode_width;
+ gdi->screen_height = mode_height;
info = (BITMAPINFO*)
calloc(1, sizeof(*info) + (3 * sizeof(RGBQUAD)));
@@ -350,9 +468,7 @@ static bool gdi_gfx_frame(void *data, const void *frame,
InvalidateRect(hwnd, NULL, false);
- if (gdi->ctx_driver->update_window_title)
- gdi->ctx_driver->update_window_title(
- gdi->ctx_data);
+ gfx_ctx_gdi_update_title();
return true;
}
@@ -368,12 +484,11 @@ static bool gdi_gfx_alive(void *data)
bool quit = false;
bool resize = false;
bool ret = false;
- gdi_t *gdi = (gdi_t*)data;
/* Needed because some context drivers don't track their sizes */
video_driver_get_size(&temp_width, &temp_height);
- gdi->ctx_driver->check_window(gdi->ctx_data,
+ win32_check_window(
&quit, &resize, &temp_width, &temp_height);
ret = !quit;
@@ -440,7 +555,7 @@ static void gdi_gfx_free(void *data)
}
font_driver_free_osd();
- video_context_driver_free();
+ gfx_ctx_gdi_destroy();
free(gdi);
}
@@ -495,13 +610,7 @@ static void gdi_set_texture_frame(void *data,
static void gdi_set_video_mode(void *data, unsigned width, unsigned height,
bool fullscreen)
{
- gfx_ctx_mode_t mode;
-
- mode.width = width;
- mode.height = height;
- mode.fullscreen = fullscreen;
-
- video_context_driver_set_video_mode(&mode);
+ gfx_ctx_gdi_set_video_mode(width, height, fullscreen);
}
static uintptr_t gdi_load_texture(void *video_data, void *data,
diff --git a/gfx/drivers_context/gdi_ctx.c b/gfx/drivers_context/gdi_ctx.c
deleted file mode 100644
index 154d07bb09..0000000000
--- a/gfx/drivers_context/gdi_ctx.c
+++ /dev/null
@@ -1,263 +0,0 @@
-/* RetroArch - A frontend for libretro.
- * Copyright (C) 2010-2014 - Hans-Kristian Arntzen
- * Copyright (C) 2011-2017 - Daniel De Matteis
- * Copyright (C) 2016-2019 - Brad Parker
- *
- * RetroArch is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Found-
- * ation, either version 3 of the License, or (at your option) any later version.
- *
- * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with RetroArch.
- * If not, see .
- */
-
-/* Win32/GDI context. */
-
-/* necessary for mingw32 multimon defines: */
-#ifndef _WIN32_WINNT
-#define _WIN32_WINNT 0x0500 /*_WIN32_WINNT_WIN2K */
-#endif
-
-#include
-#include
-
-#include
-#include
-
-#include
-
-#ifdef HAVE_CONFIG_H
-#include "../../config.h"
-#endif
-
-#include "../../dynamic.h"
-#include "../../configuration.h"
-#include "../../retroarch.h"
-#include "../../verbosity.h"
-#include "../../frontend/frontend_driver.h"
-
-#include "../common/win32_common.h"
-
-static HDC win32_gdi_hdc;
-
-static unsigned win32_gdi_major = 0;
-static unsigned win32_gdi_minor = 0;
-static int win32_gdi_interval = 0;
-static enum gfx_ctx_api win32_gdi_api = GFX_CTX_NONE;
-
-typedef struct gfx_ctx_gdi_data
-{
- void *empty;
-} gfx_ctx_gdi_data_t;
-
-static void *dinput_gdi;
-
-static void gfx_ctx_gdi_update_title(void *data)
-{
- const ui_window_t *window = ui_companion_driver_get_window_ptr();
- char title[128];
-
- title[0] = '\0';
-
- video_driver_get_window_title(title, sizeof(title));
-
- if (window && title[0])
- window->set_title(&main_window, title);
-}
-
-static void gfx_ctx_gdi_get_video_size(void *data,
- unsigned *width, unsigned *height)
-{
- HWND window = win32_get_window();
-
- (void)data;
-
- if (!window)
- {
- RECT mon_rect;
- MONITORINFOEX current_mon;
- unsigned mon_id = 0;
- HMONITOR hm_to_use = NULL;
-
- win32_monitor_info(¤t_mon, &hm_to_use, &mon_id);
- mon_rect = current_mon.rcMonitor;
- *width = mon_rect.right - mon_rect.left;
- *height = mon_rect.bottom - mon_rect.top;
- }
- else
- {
- *width = g_win32_resize_width;
- *height = g_win32_resize_height;
- }
-}
-
-static void *gfx_ctx_gdi_init(void *video_driver)
-{
- WNDCLASSEX wndclass = {0};
- gfx_ctx_gdi_data_t *gdi = (gfx_ctx_gdi_data_t*)calloc(1, sizeof(*gdi));
-
- if (!gdi)
- return NULL;
-
- if (g_win32_inited)
- goto error;
-
- win32_window_reset();
- win32_monitor_init();
-
- wndclass.lpfnWndProc = WndProcGDI;
- if (!win32_window_init(&wndclass, true, NULL))
- goto error;
-
- return gdi;
-
-error:
- if (gdi)
- free(gdi);
- return NULL;
-}
-
-static void gfx_ctx_gdi_destroy(void *data)
-{
- gfx_ctx_gdi_data_t *gdi = (gfx_ctx_gdi_data_t*)data;
- HWND window = win32_get_window();
-
- if (window && win32_gdi_hdc)
- {
- ReleaseDC(window, win32_gdi_hdc);
- win32_gdi_hdc = NULL;
- }
-
- if (window)
- {
- win32_monitor_from_window();
- win32_destroy_window();
- }
-
- if (g_win32_restore_desktop)
- {
- win32_monitor_get_info();
- g_win32_restore_desktop = false;
- }
-
- if (gdi)
- free(gdi);
-
- g_win32_inited = false;
- win32_gdi_major = 0;
- win32_gdi_minor = 0;
-}
-
-static bool gfx_ctx_gdi_set_video_mode(void *data,
- unsigned width, unsigned height,
- bool fullscreen)
-{
- if (!win32_set_video_mode(NULL, width, height, fullscreen))
- {
- RARCH_ERR("[GDI]: win32_set_video_mode failed.\n");
- gfx_ctx_gdi_destroy(data);
- return false;
- }
-
- return true;
-}
-
-static void gfx_ctx_gdi_input_driver(void *data,
- const char *joypad_name,
- input_driver_t **input, void **input_data)
-{
-#if _WIN32_WINNT >= 0x0501
-#ifdef HAVE_WINRAWINPUT
- settings_t *settings = config_get_ptr();
-
- /* winraw only available since XP */
- if (string_is_equal(settings->arrays.input_driver, "raw"))
- {
- *input_data = input_winraw.init(joypad_name);
- if (*input_data)
- {
- *input = &input_winraw;
- dinput_gdi = NULL;
- return;
- }
- }
-#endif
-#endif
-
-#ifdef HAVE_DINPUT
- dinput_gdi = input_dinput.init(joypad_name);
- *input = dinput_gdi ? &input_dinput : NULL;
-#else
- dinput_gdi = NULL;
- *input = NULL;
-#endif
- *input_data = dinput_gdi;
-}
-
-static bool gfx_ctx_gdi_bind_api(void *data,
- enum gfx_ctx_api api, unsigned major, unsigned minor)
-{
- (void)data;
-
- win32_gdi_major = major;
- win32_gdi_minor = minor;
- win32_gdi_api = api;
-
- return true;
-}
-
-static void gfx_ctx_gdi_check_window(void *data, bool *quit,
- bool *resize, unsigned *width, unsigned *height) { win32_check_window(quit, resize, width, height); }
-static bool gfx_ctx_gdi_set_resize(void *data, unsigned width, unsigned height) { return false; }
-static enum gfx_ctx_api gfx_ctx_gdi_get_api(void *data) { return win32_gdi_api; }
-static void gfx_ctx_gdi_swap_interval(void *data, int interval) { }
-static void gfx_ctx_gdi_set_flags(void *data, uint32_t flags) { }
-static uint32_t gfx_ctx_gdi_get_flags(void *data) { return 0; }
-static void gfx_ctx_gdi_swap_buffers(void *data) { SwapBuffers(win32_gdi_hdc); }
-
-void create_gdi_context(HWND hwnd, bool *quit)
-{
- win32_gdi_hdc = GetDC(hwnd);
-
- win32_setup_pixel_format(win32_gdi_hdc, false);
-
- g_win32_inited = true;
-}
-
-const gfx_ctx_driver_t gfx_ctx_gdi = {
- gfx_ctx_gdi_init,
- gfx_ctx_gdi_destroy,
- gfx_ctx_gdi_get_api,
- gfx_ctx_gdi_bind_api,
- gfx_ctx_gdi_swap_interval,
- gfx_ctx_gdi_set_video_mode,
- gfx_ctx_gdi_get_video_size,
- NULL, /* get_refresh_rate */
- NULL, /* get_video_output_size */
- NULL, /* get_video_output_prev */
- NULL, /* get_video_output_next */
- win32_get_metrics,
- NULL,
- gfx_ctx_gdi_update_title,
- gfx_ctx_gdi_check_window,
- gfx_ctx_gdi_set_resize,
- win32_has_focus,
- win32_suppress_screensaver,
- true, /* has_windowed */
- gfx_ctx_gdi_swap_buffers,
- gfx_ctx_gdi_input_driver,
- NULL,
- NULL,
- NULL,
- win32_show_cursor,
- "gdi",
- gfx_ctx_gdi_get_flags,
- gfx_ctx_gdi_set_flags,
- NULL,
- NULL,
- NULL
-};
diff --git a/griffin/griffin.c b/griffin/griffin.c
index de299c472b..c6017e260f 100644
--- a/griffin/griffin.c
+++ b/griffin/griffin.c
@@ -231,12 +231,6 @@ VIDEO CONTEXT
#include "../gfx/drivers_context/wgl_ctx.c"
#endif
-#if defined(_WIN32) && !defined(_XBOX) && !defined(__WINRT__)
-#ifdef HAVE_GDI
-#include "../gfx/drivers_context/gdi_ctx.c"
-#endif
-#endif
-
#include "../gfx/display_servers/dispserv_win32.c"
#if defined(HAVE_FFMPEG)
diff --git a/retroarch.c b/retroarch.c
index 3e5b80b76c..94ce38cd5a 100644
--- a/retroarch.c
+++ b/retroarch.c
@@ -642,11 +642,6 @@ static const gfx_ctx_driver_t *gfx_ctx_drivers[] = {
#if defined(HAVE_VULKAN) && defined(HAVE_VULKAN_DISPLAY)
&gfx_ctx_khr_display,
#endif
-#if defined(_WIN32) && !defined(_XBOX) && !defined(__WINRT__)
-#ifdef HAVE_GDI
- &gfx_ctx_gdi,
-#endif
-#endif
#ifdef HAVE_NETWORK_VIDEO
&gfx_ctx_network,
#endif