From 407d7e2c4e097b1b2be2f0b818f4d534981ab8bc Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 16 Feb 2018 19:25:19 +0100 Subject: [PATCH] (menu display) Get rid of more pointer grabbing --- menu/drivers/materialui.c | 2 +- menu/drivers_display/menu_display_caca.c | 2 +- menu/drivers_display/menu_display_ctr.c | 2 +- menu/drivers_display/menu_display_d3d.c | 6 +++--- menu/drivers_display/menu_display_d3d11.c | 13 +++++++++---- menu/drivers_display/menu_display_d3d12.c | 5 +++-- menu/drivers_display/menu_display_gdi.c | 4 +++- menu/drivers_display/menu_display_gl.c | 4 +++- menu/drivers_display/menu_display_null.c | 7 +++++-- menu/drivers_display/menu_display_vga.c | 4 +++- menu/drivers_display/menu_display_vita2d.c | 4 +++- menu/drivers_display/menu_display_vulkan.c | 5 +++-- menu/drivers_display/menu_display_wiiu.c | 4 +++- menu/menu_driver.c | 5 +++-- menu/menu_driver.h | 9 ++++++--- 15 files changed, 50 insertions(+), 26 deletions(-) diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 73adb5c854..7851144476 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -1459,7 +1459,7 @@ static void mui_frame(void *data, video_frame_info_t *video_info) } else { - menu_display_clear_color(&clearcolor); + menu_display_clear_color(&clearcolor, video_info); if (mui->textures.bg) { diff --git a/menu/drivers_display/menu_display_caca.c b/menu/drivers_display/menu_display_caca.c index 52ba509f5a..9d49190012 100644 --- a/menu/drivers_display/menu_display_caca.c +++ b/menu/drivers_display/menu_display_caca.c @@ -57,7 +57,7 @@ static void menu_display_caca_restore_clear_color(void) { } -static void menu_display_caca_clear_color(menu_display_ctx_clearcolor_t *clearcolor) +static void menu_display_caca_clear_color(menu_display_ctx_clearcolor_t *clearcolor, video_frame_info_t *video_info) { (void)clearcolor; } diff --git a/menu/drivers_display/menu_display_ctr.c b/menu/drivers_display/menu_display_ctr.c index 1e66a7bcfe..d2b2342e79 100644 --- a/menu/drivers_display/menu_display_ctr.c +++ b/menu/drivers_display/menu_display_ctr.c @@ -168,7 +168,7 @@ static void menu_display_ctr_restore_clear_color(void) #endif } -static void menu_display_ctr_clear_color(menu_display_ctx_clearcolor_t *clearcolor) +static void menu_display_ctr_clear_color(menu_display_ctx_clearcolor_t *clearcolor, video_frame_info_t *video_info) { if (!clearcolor) return; diff --git a/menu/drivers_display/menu_display_d3d.c b/menu/drivers_display/menu_display_d3d.c index a74655fc0c..ab67358ed7 100644 --- a/menu/drivers_display/menu_display_d3d.c +++ b/menu/drivers_display/menu_display_d3d.c @@ -277,11 +277,11 @@ static void menu_display_d3d_restore_clear_color(void) } static void menu_display_d3d_clear_color( - menu_display_ctx_clearcolor_t *clearcolor) + menu_display_ctx_clearcolor_t *clearcolor, video_frame_info_t *video_info) { DWORD clear_color = 0; - d3d_video_t *d3d = (d3d_video_t*) - video_driver_get_ptr(false); + d3d_video_t *d3d = video_info ? + (d3d_video_t*)video_info->userdata : NULL; if (!d3d || !clearcolor) return; diff --git a/menu/drivers_display/menu_display_d3d11.c b/menu/drivers_display/menu_display_d3d11.c index 4e76f75a9b..c1acebf68a 100644 --- a/menu/drivers_display/menu_display_d3d11.c +++ b/menu/drivers_display/menu_display_d3d11.c @@ -229,14 +229,18 @@ static void menu_display_d3d11_draw_pipeline(void* data, static void menu_display_d3d11_restore_clear_color(void) {} -static void menu_display_d3d11_clear_color(menu_display_ctx_clearcolor_t* clearcolor) +static void menu_display_d3d11_clear_color( + menu_display_ctx_clearcolor_t* clearcolor, + video_frame_info_t *video_info) { - d3d11_video_t* d3d11 = (d3d11_video_t*)video_driver_get_ptr(false); + d3d11_video_t *d3d11 = video_info ? + (d3d11_video_t*)video_info->userdata : NULL; if (!d3d11 || !clearcolor) return; - D3D11ClearRenderTargetView(d3d11->context, d3d11->renderTargetView, (float*)clearcolor); + D3D11ClearRenderTargetView(d3d11->context, + d3d11->renderTargetView, (float*)clearcolor); } static bool menu_display_d3d11_font_init_first( @@ -248,7 +252,8 @@ static bool menu_display_d3d11_font_init_first( { font_data_t** handle = (font_data_t**)font_handle; font_data_t* new_handle = font_driver_init_first( - video_data, font_path, font_size, true, is_threaded, FONT_DRIVER_RENDER_D3D11_API); + video_data, font_path, font_size, true, + is_threaded, FONT_DRIVER_RENDER_D3D11_API); if (!new_handle) return false; *handle = new_handle; diff --git a/menu/drivers_display/menu_display_d3d12.c b/menu/drivers_display/menu_display_d3d12.c index 90dcae5186..e20c8fd4d2 100644 --- a/menu/drivers_display/menu_display_d3d12.c +++ b/menu/drivers_display/menu_display_d3d12.c @@ -249,9 +249,10 @@ static void menu_display_d3d12_draw_pipeline(void* data, static void menu_display_d3d12_restore_clear_color(void) {} -static void menu_display_d3d12_clear_color(menu_display_ctx_clearcolor_t* clearcolor) +static void menu_display_d3d12_clear_color( + menu_display_ctx_clearcolor_t* clearcolor, video_frame_info_t *video_info) { - d3d12_video_t* d3d12 = (d3d12_video_t*)video_driver_get_ptr(false); + d3d12_video_t* d3d12 = video_info ? (d3d12_video_t*)video_info->userdata : NULL; if (!d3d12 || !clearcolor) return; diff --git a/menu/drivers_display/menu_display_gdi.c b/menu/drivers_display/menu_display_gdi.c index 6f37fd2ec6..5c6da5440a 100644 --- a/menu/drivers_display/menu_display_gdi.c +++ b/menu/drivers_display/menu_display_gdi.c @@ -73,7 +73,9 @@ static void menu_display_gdi_restore_clear_color(void) ReleaseDC(hwnd, hdc);*/ } -static void menu_display_gdi_clear_color(menu_display_ctx_clearcolor_t *clearcolor) +static void menu_display_gdi_clear_color( + menu_display_ctx_clearcolor_t *clearcolor, + video_frame_info_t *video_info) { (void)clearcolor; diff --git a/menu/drivers_display/menu_display_gl.c b/menu/drivers_display/menu_display_gl.c index 9679ab0a53..eddcf3c178 100644 --- a/menu/drivers_display/menu_display_gl.c +++ b/menu/drivers_display/menu_display_gl.c @@ -235,7 +235,9 @@ static void menu_display_gl_restore_clear_color(void) glClearColor(0.0f, 0.0f, 0.0f, 0.00f); } -static void menu_display_gl_clear_color(menu_display_ctx_clearcolor_t *clearcolor) +static void menu_display_gl_clear_color( + menu_display_ctx_clearcolor_t *clearcolor, + video_frame_info_t *video_info) { if (!clearcolor) return; diff --git a/menu/drivers_display/menu_display_null.c b/menu/drivers_display/menu_display_null.c index dd9cfdb1b5..47ad4bacba 100644 --- a/menu/drivers_display/menu_display_null.c +++ b/menu/drivers_display/menu_display_null.c @@ -41,7 +41,8 @@ static void menu_display_null_draw(void *data, video_frame_info_t *video_info) (void)data; } -static void menu_display_null_draw_pipeline(void *data, video_frame_info_t *video_info) +static void menu_display_null_draw_pipeline( + void *data, video_frame_info_t *video_info) { (void)data; } @@ -55,7 +56,9 @@ static void menu_display_null_restore_clear_color(void) { } -static void menu_display_null_clear_color(menu_display_ctx_clearcolor_t *clearcolor) +static void menu_display_null_clear_color( + menu_display_ctx_clearcolor_t *clearcolor, + video_frame_info_t *video_info) { (void)clearcolor; } diff --git a/menu/drivers_display/menu_display_vga.c b/menu/drivers_display/menu_display_vga.c index ec7e796bbc..c7a08bef00 100644 --- a/menu/drivers_display/menu_display_vga.c +++ b/menu/drivers_display/menu_display_vga.c @@ -57,7 +57,9 @@ static void menu_display_vga_restore_clear_color(void) { } -static void menu_display_vga_clear_color(menu_display_ctx_clearcolor_t *clearcolor) +static void menu_display_vga_clear_color( + menu_display_ctx_clearcolor_t *clearcolor, + video_frame_info_t *video_info) { (void)clearcolor; } diff --git a/menu/drivers_display/menu_display_vita2d.c b/menu/drivers_display/menu_display_vita2d.c index 1c31aa81f1..7176c55079 100644 --- a/menu/drivers_display/menu_display_vita2d.c +++ b/menu/drivers_display/menu_display_vita2d.c @@ -210,7 +210,9 @@ static void menu_display_vita2d_restore_clear_color(void) vita2d_set_clear_color(RGBA8(0x00, 0x00, 0x00, 0xFF)); } -static void menu_display_vita2d_clear_color(menu_display_ctx_clearcolor_t *clearcolor) +static void menu_display_vita2d_clear_color( + menu_display_ctx_clearcolor_t *clearcolor, + video_frame_info_t *video_info) { if (!clearcolor) return; diff --git a/menu/drivers_display/menu_display_vulkan.c b/menu/drivers_display/menu_display_vulkan.c index 699f3cf1dd..e2c5cb9498 100644 --- a/menu/drivers_display/menu_display_vulkan.c +++ b/menu/drivers_display/menu_display_vulkan.c @@ -282,11 +282,12 @@ static void menu_display_vk_restore_clear_color(void) } static void menu_display_vk_clear_color( - menu_display_ctx_clearcolor_t *clearcolor) + menu_display_ctx_clearcolor_t *clearcolor, + video_frame_info_t *video_info) { VkClearRect rect; VkClearAttachment attachment; - vk_t *vk = (vk_t*)video_driver_get_ptr(false); + vk_t *vk = video_info ? (vk_t*)video_info->userdata : NULL; if (!vk || !clearcolor) return; diff --git a/menu/drivers_display/menu_display_wiiu.c b/menu/drivers_display/menu_display_wiiu.c index 4fe9d5f419..aff373359d 100644 --- a/menu/drivers_display/menu_display_wiiu.c +++ b/menu/drivers_display/menu_display_wiiu.c @@ -298,7 +298,9 @@ static void menu_display_wiiu_restore_clear_color(void) #endif } -static void menu_display_wiiu_clear_color(menu_display_ctx_clearcolor_t *clearcolor) +static void menu_display_wiiu_clear_color( + menu_display_ctx_clearcolor_t *clearcolor, + video_frame_info_t *video_info) { if (!clearcolor) return; diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 6a04723ddc..2edb433db9 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -576,10 +576,11 @@ bool menu_display_restore_clear_color(void) return true; } -void menu_display_clear_color(menu_display_ctx_clearcolor_t *color) +void menu_display_clear_color(menu_display_ctx_clearcolor_t *color, + video_frame_info_t *video_info) { if (menu_disp && menu_disp->clear_color) - menu_disp->clear_color(color); + menu_disp->clear_color(color, video_info); } void menu_display_draw(menu_display_ctx_draw_t *draw, diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 7dece5d497..abb14d1afe 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -331,7 +331,8 @@ typedef struct menu_display_ctx_driver /* Set the clear color back to its default values. */ void (*restore_clear_color)(void); /* Set the color to be used when clearing the screen */ - void (*clear_color)(menu_display_ctx_clearcolor_t *clearcolor); + void (*clear_color)(menu_display_ctx_clearcolor_t *clearcolor, + video_frame_info_t *video_info); /* Get the default Model-View-Projection matrix */ void *(*get_default_mvp)(void); /* Get the default vertices matrix */ @@ -674,8 +675,10 @@ void menu_display_unset_framebuffer_dirty_flag(void); float menu_display_get_dpi(void); bool menu_display_init_first_driver(bool video_is_threaded); bool menu_display_restore_clear_color(void); -void menu_display_clear_color(menu_display_ctx_clearcolor_t *color); -void menu_display_draw(menu_display_ctx_draw_t *draw, video_frame_info_t *video_info); +void menu_display_clear_color(menu_display_ctx_clearcolor_t *color, + video_frame_info_t *video_info); +void menu_display_draw(menu_display_ctx_draw_t *draw, + video_frame_info_t *video_info); void menu_display_draw_pipeline(menu_display_ctx_draw_t *draw, video_frame_info_t *video_info);