From ef79711837c364e00bc740e0ec731447f485f2e8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 15 Aug 2017 22:43:09 +0200 Subject: [PATCH] (MaterialUI) Hook up framebuffer opacity --- gfx/video_driver.c | 4 +++- gfx/video_driver.h | 5 +++-- menu/drivers/materialui.c | 41 ++++++++++++++++++++++----------------- menu/drivers/xmb.c | 8 +++++--- menu/drivers/zarch.c | 4 +++- menu/menu_driver.c | 8 +++++--- menu/menu_driver.h | 2 +- 7 files changed, 43 insertions(+), 29 deletions(-) diff --git a/gfx/video_driver.c b/gfx/video_driver.c index bc6941349e..a43cbe13af 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -2524,7 +2524,8 @@ void video_driver_build_info(video_frame_info_t *video_info) video_info->battery_level_enable = settings->bools.menu_battery_level_enable; video_info->xmb_shadows_enable = settings->bools.menu_xmb_shadows_enable; video_info->xmb_alpha_factor = settings->uints.menu_xmb_alpha_factor; - video_info->menu_wallpaper_opacity = settings->floats.menu_wallpaper_opacity; + video_info->menu_wallpaper_opacity = settings->floats.menu_wallpaper_opacity; + video_info->menu_framebuffer_opacity = settings->floats.menu_framebuffer_opacity; video_info->libretro_running = core_is_game_loaded(); #else @@ -2539,6 +2540,7 @@ void video_driver_build_info(video_frame_info_t *video_info) video_info->battery_level_enable = false; video_info->xmb_shadows_enable = false; video_info->xmb_alpha_factor = 0.0f; + video_info->menu_framebuffer_opacity = 0.0f; video_info->menu_wallpaper_opacity = 0.0f; #endif diff --git a/gfx/video_driver.h b/gfx/video_driver.h index cb816346a5..c2e72857e7 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -447,14 +447,15 @@ typedef struct video_frame_info unsigned custom_vp_full_height; float menu_wallpaper_opacity; + float menu_framebuffer_opacity; + float menu_header_opacity; + float menu_footer_opacity; float refresh_rate; float font_msg_pos_x; float font_msg_pos_y; float font_msg_color_r; float font_msg_color_g; float font_msg_color_b; - float menu_header_opacity; - float menu_footer_opacity; float xmb_alpha_factor; char fps_text[128]; diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 7e493c30d3..45d8d9d8ba 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -1095,6 +1095,9 @@ static int mui_get_core_title(char *s, size_t len) static void mui_draw_bg(menu_display_ctx_draw_t *draw, video_frame_info_t *video_info) { + bool add_opacity = false; + float opacity_override = video_info->menu_wallpaper_opacity; + menu_display_blend_begin(); draw->x = 0; @@ -1102,7 +1105,14 @@ static void mui_draw_bg(menu_display_ctx_draw_t *draw, draw->pipeline.id = 0; draw->pipeline.active = false; - menu_display_draw_bg(draw, video_info, false); + if (video_info->libretro_running) + { + add_opacity = true; + opacity_override = video_info->menu_framebuffer_opacity; + } + + menu_display_draw_bg(draw, video_info, add_opacity, + opacity_override); menu_display_draw(draw); menu_display_blend_end(); } @@ -1124,6 +1134,17 @@ static void mui_frame(void *data, video_frame_info_t *video_info) char title[255]; char title_buf[255]; char title_msg[255]; + float black_bg[16]; + float pure_white[16]; + float white_bg[16]; + float white_transp_bg[16]; + float grey_bg[16]; + float shadow_bg[16]= { + 0.00, 0.00, 0.00, 0.00, + 0.00, 0.00, 0.00, 0.00, + 0.00, 0.00, 0.00, 0.20, + 0.00, 0.00, 0.00, 0.20, + }; file_list_t *list = NULL; mui_node_t *node = NULL; @@ -1164,29 +1185,13 @@ static void mui_frame(void *data, video_frame_info_t *video_info) uint32_t black_opaque_87 = 0x000000DE; uint32_t white_opaque_70 = 0xFFFFFFB3; - /* Pallete of colors needed throughout the file */ - float black_bg[16]; + /* Palette of colors needed throughout the file */ hex32_to_rgba_normalized(0x000000, black_bg, 0.75); - - float pure_white[16]; hex32_to_rgba_normalized(0xFFFFFF, pure_white, 1.0); - - float white_bg[16]; hex32_to_rgba_normalized(0xFAFAFA, white_bg, 1.0); - - float white_transp_bg[16]; hex32_to_rgba_normalized(0xFAFAFA, white_transp_bg, 0.90); - - float grey_bg[16]; hex32_to_rgba_normalized(0xC7C7C7, grey_bg, 0.90); - float shadow_bg[16]= { - 0.00, 0.00, 0.00, 0.00, - 0.00, 0.00, 0.00, 0.00, - 0.00, 0.00, 0.00, 0.20, - 0.00, 0.00, 0.00, 0.20, - }; - memcpy(theme.passive_tab_icon_color, grey_bg, sizeof(grey_bg)); switch (video_info->materialui_color_theme) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 1f9a2146d0..683b249a40 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -2614,8 +2614,10 @@ static void xmb_draw_bg( menu_display_draw_gradient(&draw, video_info); { - bool add_opacity = false; - draw.texture = texture; + float override_opacity = video_info->menu_wallpaper_opacity; + bool add_opacity = false; + + draw.texture = texture; menu_display_set_alpha(draw.color, coord_white[3]); if (draw.texture) @@ -2624,7 +2626,7 @@ static void xmb_draw_bg( if (running || video_info->xmb_color_theme == XMB_THEME_WALLPAPER) add_opacity = true; - menu_display_draw_bg(&draw, video_info, add_opacity); + menu_display_draw_bg(&draw, video_info, add_opacity, override_opacity); } } diff --git a/menu/drivers/zarch.c b/menu/drivers/zarch.c index 11f97aaa3d..2417e35e43 100644 --- a/menu/drivers/zarch.c +++ b/menu/drivers/zarch.c @@ -976,7 +976,9 @@ static void zarch_frame(void *data, video_frame_info_t *video_info) menu_display_blend_begin(); draw.x = 0; draw.y = 0; - menu_display_draw_bg(&draw, video_info, false); + + menu_display_draw_bg(&draw, video_info, false, + video_info->menu_wallpaper_opacity); menu_display_draw(&draw); menu_display_blend_end(); diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 848e357be5..3c14267c81 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -578,7 +578,8 @@ void menu_display_draw_pipeline(menu_display_ctx_draw_t *draw) } void menu_display_draw_bg(menu_display_ctx_draw_t *draw, - video_frame_info_t *video_info, bool add_opacity_to_wallpaper) + video_frame_info_t *video_info, bool add_opacity_to_wallpaper, + float override_opacity) { static struct video_coords coords; const float *new_vertex = NULL; @@ -606,7 +607,7 @@ void menu_display_draw_bg(menu_display_ctx_draw_t *draw, add_opacity_to_wallpaper = true; if (add_opacity_to_wallpaper) - menu_display_set_alpha(draw->color, video_info->menu_wallpaper_opacity); + menu_display_set_alpha(draw->color, override_opacity); if (!draw->texture) draw->texture = menu_display_white_texture; @@ -621,7 +622,8 @@ void menu_display_draw_gradient(menu_display_ctx_draw_t *draw, draw->x = 0; draw->y = 0; - menu_display_draw_bg(draw, video_info, false); + menu_display_draw_bg(draw, video_info, false, + video_info->menu_wallpaper_opacity); menu_display_draw(draw); } diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 76c86b7a74..3d142e8053 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -669,7 +669,7 @@ void menu_display_draw_pipeline(menu_display_ctx_draw_t *draw); void menu_display_draw_bg( menu_display_ctx_draw_t *draw, video_frame_info_t *video_info, - bool add_opacity); + bool add_opacity, float opacity_override); void menu_display_draw_gradient( menu_display_ctx_draw_t *draw, video_frame_info_t *video_info);