From 77d630a0a51279b3f923554f4dc784e361af2b84 Mon Sep 17 00:00:00 2001
From: twinaphex <libretro@gmail.com>
Date: Thu, 9 Jul 2020 09:40:13 +0200
Subject: [PATCH] (GDI) Only render framebuffer texture when menu is enabled

---
 gfx/common/gdi_common.h |  3 +++
 gfx/drivers/gdi_gfx.c   | 16 ++++++++++++++--
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/gfx/common/gdi_common.h b/gfx/common/gdi_common.h
index 3f5efcbfac..3b234abcc2 100644
--- a/gfx/common/gdi_common.h
+++ b/gfx/common/gdi_common.h
@@ -48,6 +48,9 @@ typedef struct gdi
    bool lte_win98;
    unsigned short *temp_buf;
    unsigned char *menu_frame;
+
+   bool menu_enable;
+   bool menu_full_screen;
 } gdi_t;
 
 typedef struct gdi_texture
diff --git a/gfx/drivers/gdi_gfx.c b/gfx/drivers/gdi_gfx.c
index a3a055a6ca..09cf97d867 100644
--- a/gfx/drivers/gdi_gfx.c
+++ b/gfx/drivers/gdi_gfx.c
@@ -317,7 +317,8 @@ static bool gdi_gfx_frame(void *data, const void *frame,
       return true;
 
 #ifdef HAVE_MENU
-   menu_driver_frame(menu_is_alive, video_info);
+   if (gdi->menu_enable)
+      menu_driver_frame(menu_is_alive, video_info);
 #endif
 
    if (  gdi->video_width  != frame_width  ||
@@ -574,6 +575,17 @@ static bool gdi_gfx_set_shader(void *data,
    return false;
 }
 
+static void gdi_set_texture_enable(
+      void *data, bool state, bool full_screen)
+{
+   gdi_t *gdi     = (gdi_t*)data;
+   if (!gdi)
+      return;
+
+   gdi->menu_enable      = state;
+   gdi->menu_full_screen = full_screen;
+}
+
 static void gdi_set_texture_frame(void *data,
       const void *frame, bool rgb32, unsigned width, unsigned height,
       float alpha)
@@ -694,7 +706,7 @@ static const video_poke_interface_t gdi_poke_interface = {
    NULL,
    NULL,
    gdi_set_texture_frame,
-   NULL,
+   gdi_set_texture_enable,
    font_driver_render_msg,
    NULL,
    NULL,                         /* grab_mouse_toggle */