From c040e4cd08b35eaea3aef1e6f07558b8c585e4d8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 23 Sep 2020 22:14:30 +0200 Subject: [PATCH] Cleanups --- gfx/gfx_display.c | 12 ------ gfx/gfx_display.h | 5 --- gfx/gfx_thumbnail.c | 17 +++++--- gfx/gfx_widgets.c | 23 +++++++---- menu/drivers/materialui.c | 32 +++++++++------ menu/drivers/ozone/ozone_display.c | 9 +++- menu/drivers/stripes.c | 42 +++++++++++-------- menu/drivers/xmb.c | 66 ++++++++++++++++++++++-------- 8 files changed, 127 insertions(+), 79 deletions(-) diff --git a/gfx/gfx_display.c b/gfx/gfx_display.c index 0df40b79ef..41c95ba174 100644 --- a/gfx/gfx_display.c +++ b/gfx/gfx_display.c @@ -699,18 +699,6 @@ font_data_t *gfx_display_font_file( return font_data; } -void gfx_display_draw(gfx_display_ctx_draw_t *draw, - void *data, - unsigned video_width, - unsigned video_height) -{ - gfx_display_t *p_disp = disp_get_ptr(); - gfx_display_ctx_driver_t *dispctx = p_disp->dispctx; - if (draw && draw->height > 0 && draw->width > 0) - if (dispctx && dispctx->draw) - dispctx->draw(draw, data, video_width, video_height); -} - void gfx_display_draw_bg(gfx_display_ctx_draw_t *draw, void *userdata, bool add_opacity_to_wallpaper, float override_opacity) diff --git a/gfx/gfx_display.h b/gfx/gfx_display.h index 48ae66d347..a6f34de2a8 100644 --- a/gfx/gfx_display.h +++ b/gfx/gfx_display.h @@ -269,11 +269,6 @@ bool gfx_display_init_first_driver(bool video_is_threaded); gfx_display_t *disp_get_ptr(void); -void gfx_display_draw(gfx_display_ctx_draw_t *draw, - void *data, - unsigned video_width, - unsigned video_height); - void gfx_display_draw_keyboard( void *userdata, unsigned video_width, diff --git a/gfx/gfx_thumbnail.c b/gfx/gfx_thumbnail.c index bf17cae075..d92991bb1b 100644 --- a/gfx/gfx_thumbnail.c +++ b/gfx/gfx_thumbnail.c @@ -867,8 +867,9 @@ void gfx_thumbnail_draw( draw.y = shadow_y; /* Draw shadow */ - gfx_display_draw(&draw, userdata, - video_width, video_height); + if (draw.height > 0 && draw.width > 0) + if (dispctx && dispctx->draw) + dispctx->draw(&draw, userdata, video_width, video_height); } } @@ -880,9 +881,13 @@ void gfx_thumbnail_draw( draw.y = draw_y; /* Draw thumbnail */ - gfx_display_draw(&draw, userdata, - video_width, video_height); - if (dispctx && dispctx->blend_end) - dispctx->blend_end(userdata); + if (dispctx) + { + if (dispctx->draw) + if (draw.height > 0 && draw.width > 0) + dispctx->draw(&draw, userdata, video_width, video_height); + if (dispctx->blend_end) + dispctx->blend_end(userdata); + } } } diff --git a/gfx/gfx_widgets.c b/gfx/gfx_widgets.c index c2a39cfa1c..7b2a6b677a 100644 --- a/gfx/gfx_widgets.c +++ b/gfx/gfx_widgets.c @@ -610,6 +610,8 @@ void gfx_widgets_draw_icon( gfx_display_ctx_draw_t draw; struct video_coords coords; math_matrix_4x4 mymat; + gfx_display_t *p_disp = disp_get_ptr(); + gfx_display_ctx_driver_t *dispctx = p_disp->dispctx; if (!texture) return; @@ -641,8 +643,9 @@ void gfx_widgets_draw_icon( draw.prim_type = GFX_DISPLAY_PRIM_TRIANGLESTRIP; draw.pipeline_id = 0; - gfx_display_draw(&draw, userdata, - video_width, video_height); + if (draw.height > 0 && draw.width > 0) + if (dispctx->draw) + dispctx->draw(&draw, userdata, video_width, video_height); } #ifdef HAVE_TRANSLATE @@ -694,12 +697,16 @@ static void gfx_widgets_draw_icon_blend( draw.prim_type = GFX_DISPLAY_PRIM_TRIANGLESTRIP; draw.pipeline_id = 0; - if (dispctx && dispctx->blend_begin) - dispctx->blend_begin(userdata); - gfx_display_draw(&draw, userdata, - video_width, video_height); - if (dispctx && dispctx->blend_end) - dispctx->blend_end(userdata); + if (dispctx) + { + if (dispctx->blend_begin) + dispctx->blend_begin(userdata); + if (draw.height > 0 && draw.width > 0) + if (dispctx->draw) + dispctx->draw(&draw, userdata, video_width, video_height); + if (dispctx->blend_end) + dispctx->blend_end(userdata); + } } #endif diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index fdd8d6379b..678954c80b 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -2347,10 +2347,14 @@ static void materialui_draw_icon( draw.prim_type = GFX_DISPLAY_PRIM_TRIANGLESTRIP; draw.pipeline_id = 0; - gfx_display_draw(&draw, userdata, - video_width, video_height); - if (dispctx && dispctx->blend_end) - dispctx->blend_end(userdata); + if (dispctx) + { + if (dispctx->draw) + if (draw.height > 0 && draw.width > 0) + dispctx->draw(&draw, userdata, video_width, video_height); + if (dispctx->blend_end) + dispctx->blend_end(userdata); + } } static void materialui_draw_thumbnail( @@ -5052,14 +5056,18 @@ static void materialui_render_background(materialui_handle_t *mui, } /* Draw background */ - if (dispctx && dispctx->blend_begin) - dispctx->blend_begin(userdata); - gfx_display_draw_bg(&draw, userdata, - add_opacity, opacity_override); - gfx_display_draw(&draw, userdata, - video_width, video_height); - if (dispctx && dispctx->blend_end) - dispctx->blend_end(userdata); + if (dispctx) + { + if (dispctx->blend_begin) + dispctx->blend_begin(userdata); + gfx_display_draw_bg(&draw, userdata, + add_opacity, opacity_override); + if (dispctx->draw) + if (draw.height > 0 && draw.width > 0) + dispctx->draw(&draw, userdata, video_width, video_height); + if (dispctx->blend_end) + dispctx->blend_end(userdata); + } } static void materialui_render_landscape_border( diff --git a/menu/drivers/ozone/ozone_display.c b/menu/drivers/ozone/ozone_display.c index ab8ead4110..c261ab3b87 100644 --- a/menu/drivers/ozone/ozone_display.c +++ b/menu/drivers/ozone/ozone_display.c @@ -277,6 +277,10 @@ void ozone_draw_icon( gfx_display_ctx_draw_t draw; struct video_coords coords; math_matrix_4x4 mymat; + gfx_display_t + *p_disp = disp_get_ptr(); + gfx_display_ctx_driver_t + *dispctx = p_disp->dispctx; rotate_draw.matrix = &mymat; rotate_draw.rotation = rotation; @@ -305,8 +309,9 @@ void ozone_draw_icon( draw.prim_type = GFX_DISPLAY_PRIM_TRIANGLESTRIP; draw.pipeline_id = 0; - gfx_display_draw(&draw, userdata, - video_width, video_height); + if (draw.height > 0 && draw.width > 0) + if (dispctx && dispctx->draw) + dispctx->draw(&draw, userdata, video_width, video_height); } void ozone_draw_backdrop( diff --git a/menu/drivers/stripes.c b/menu/drivers/stripes.c index 7d1de2f933..756ec3d089 100644 --- a/menu/drivers/stripes.c +++ b/menu/drivers/stripes.c @@ -620,8 +620,9 @@ static void stripes_draw_icon( draw.y = draw.y + (icon_size-draw.width)/2; } #endif - gfx_display_draw(&draw, userdata, - video_width, video_height); + if (draw.height > 0 && draw.width > 0) + if (dispctx && dispctx->draw) + dispctx->draw(&draw, userdata, video_width, video_height); } coords.color = (const float*)color; @@ -635,8 +636,9 @@ static void stripes_draw_icon( draw.y = draw.y + (icon_size-draw.width)/2; } #endif - gfx_display_draw(&draw, userdata, - video_width, video_height); + if (draw.height > 0 && draw.width > 0) + if (dispctx && dispctx->draw) + dispctx->draw(&draw, userdata, video_width, video_height); } static void stripes_draw_text( @@ -2786,12 +2788,16 @@ static void stripes_draw_bg( draw.prim_type = GFX_DISPLAY_PRIM_TRIANGLESTRIP; draw.pipeline_id = 0; - if (dispctx && dispctx->blend_begin) - dispctx->blend_begin(userdata); - gfx_display_draw(&draw, userdata, - video_width, video_height); - if (dispctx && dispctx->blend_end) - dispctx->blend_end(userdata); + if (dispctx) + { + if (dispctx->blend_begin) + dispctx->blend_begin(userdata); + if (dispctx->draw) + if (draw.height > 0 && draw.width > 0) + dispctx->draw(&draw, userdata, video_width, video_height); + if (dispctx->blend_end) + dispctx->blend_end(userdata); + } } static void stripes_draw_dark_layer( @@ -2831,12 +2837,16 @@ static void stripes_draw_dark_layer( draw.prim_type = GFX_DISPLAY_PRIM_TRIANGLESTRIP; draw.pipeline_id = 0; - if (dispctx && dispctx->blend_begin) - dispctx->blend_begin(userdata); - gfx_display_draw(&draw, userdata, - video_width, video_height); - if (dispctx && dispctx->blend_end) - dispctx->blend_end(userdata); + if (dispctx) + { + if (dispctx->blend_begin) + dispctx->blend_begin(userdata); + if (dispctx->draw) + if (draw.height > 0 && draw.width > 0) + dispctx->draw(&draw, userdata, video_width, video_height); + if (dispctx->blend_end) + dispctx->blend_end(userdata); + } } static void stripes_frame(void *data, video_frame_info_t *video_info) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 820d47021d..c8570da30b 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -809,6 +809,8 @@ static void *xmb_list_get_entry(void *data, static void xmb_draw_icon( void *userdata, + gfx_display_t *p_disp, + gfx_display_ctx_driver_t *dispctx, unsigned video_width, unsigned video_height, bool xmb_shadows_enable, @@ -870,8 +872,9 @@ static void xmb_draw_icon( draw.y = draw.y + (icon_size-draw.width)/2; } #endif - gfx_display_draw(&draw, userdata, - video_width, video_height); + if (draw.height > 0 && draw.width > 0) + if (dispctx && dispctx->draw) + dispctx->draw(&draw, userdata, video_width, video_height); } coords.color = (const float*)color; @@ -885,8 +888,9 @@ static void xmb_draw_icon( draw.y = draw.y + (icon_size-draw.width)/2; } #endif - gfx_display_draw(&draw, userdata, - video_width, video_height); + if (draw.height > 0 && draw.width > 0) + if (dispctx && dispctx->draw) + dispctx->draw(&draw, userdata, video_width, video_height); } static void xmb_draw_text( @@ -3010,6 +3014,8 @@ static uintptr_t xmb_icon_get_id(xmb_handle_t *xmb, static int xmb_draw_item( void *userdata, + gfx_display_t *p_disp, + gfx_display_ctx_driver_t *dispctx, unsigned video_width, unsigned video_height, bool xmb_shadows_enable, @@ -3406,6 +3412,8 @@ static int xmb_draw_item( xmb_draw_icon( userdata, + p_disp, + dispctx, video_width, video_height, xmb_shadows_enable, @@ -3428,6 +3436,8 @@ static int xmb_draw_item( if (texture_switch != 0 && color[3] != 0 && !xmb->assets_missing) xmb_draw_icon( userdata, + p_disp, + dispctx, video_width, video_height, xmb_shadows_enable, @@ -3511,6 +3521,8 @@ static void xmb_draw_items( { if (xmb_draw_item( userdata, + p_disp, + dispctx, video_width, video_height, xmb_shadows_enable, @@ -4057,8 +4069,9 @@ static void xmb_draw_bg( gfx_display_draw_bg(&draw, userdata, false, menu_wallpaper_opacity); - gfx_display_draw(&draw, userdata, - video_width, video_height); + if (draw.height > 0 && draw.width > 0) + if (dispctx && dispctx->draw) + dispctx->draw(&draw, userdata, video_width, video_height); draw.pipeline_id = VIDEO_SHADER_MENU_2; @@ -4108,8 +4121,9 @@ static void xmb_draw_bg( gfx_display_draw_bg(&draw, userdata, false, menu_wallpaper_opacity); - gfx_display_draw(&draw, userdata, - video_width, video_height); + if (draw.height > 0 && draw.width > 0) + if (dispctx && dispctx->draw) + dispctx->draw(&draw, userdata, video_width, video_height); } { @@ -4129,10 +4143,14 @@ static void xmb_draw_bg( } } - gfx_display_draw(&draw, userdata, - video_width, video_height); - if (dispctx && dispctx->blend_end) - dispctx->blend_end(userdata); + if (dispctx) + { + if (dispctx->draw) + if (draw.height > 0 && draw.width > 0) + dispctx->draw(&draw, userdata, video_width, video_height); + if (dispctx->blend_end) + dispctx->blend_end(userdata); + } } static void xmb_draw_dark_layer( @@ -4170,12 +4188,16 @@ static void xmb_draw_dark_layer( draw.prim_type = GFX_DISPLAY_PRIM_TRIANGLESTRIP; draw.pipeline_id = 0; - if (dispctx && dispctx->blend_begin) - dispctx->blend_begin(userdata); - gfx_display_draw(&draw, userdata, - width, height); - if (dispctx && dispctx->blend_end) - dispctx->blend_end(userdata); + if (dispctx) + { + if (dispctx->blend_begin) + dispctx->blend_begin(userdata); + if (draw.height > 0 && draw.width > 0) + if (dispctx && dispctx->draw) + dispctx->draw(&draw, userdata, width, height); + if (dispctx->blend_end) + dispctx->blend_end(userdata); + } } static void xmb_draw_fullscreen_thumbnails( @@ -4964,6 +4986,8 @@ static void xmb_frame(void *data, video_frame_info_t *video_info) dispctx->blend_begin(userdata); xmb_draw_icon( userdata, + p_disp, + dispctx, video_width, video_height, xmb_shadows_enable, @@ -5018,6 +5042,8 @@ static void xmb_frame(void *data, video_frame_info_t *video_info) dispctx->blend_begin(userdata); xmb_draw_icon( userdata, + p_disp, + dispctx, video_width, video_height, xmb_shadows_enable, @@ -5065,6 +5091,8 @@ static void xmb_frame(void *data, video_frame_info_t *video_info) dispctx->blend_begin(userdata); xmb_draw_icon( userdata, + p_disp, + dispctx, video_width, video_height, xmb_shadows_enable, @@ -5150,6 +5178,8 @@ static void xmb_frame(void *data, video_frame_info_t *video_info) xmb_draw_icon( userdata, + p_disp, + dispctx, video_width, video_height, xmb_shadows_enable,