diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index 6a1af71c1f..b4feaf53e4 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -424,9 +424,10 @@ static int win32_drag_query_file(HWND hwnd, WPARAM wparam) static LRESULT win32_handle_keyboard_event(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { - unsigned keycode; - uint16_t mod = 0; - bool keydown = true; + unsigned keycode = 0; + uint16_t mod = 0; + bool keydown = true; + settings_t *settings = NULL; if (GetKeyState(VK_SHIFT) & 0x80) mod |= RETROKMOD_SHIFT; @@ -460,7 +461,8 @@ static LRESULT win32_handle_keyboard_event(HWND hwnd, UINT message, keydown = false; #if _WIN32_WINNT >= 0x0501 /* XP */ - if (string_is_equal(config_get_ptr()->arrays.input_driver, "raw")) + settings = config_get_ptr(); + if (settings && string_is_equal(settings->arrays.input_driver, "raw")) keycode = input_keymaps_translate_keysym_to_rk((unsigned)(wparam)); else #endif diff --git a/gfx/drivers/d3d10.c b/gfx/drivers/d3d10.c index c0f41e9f2d..ca9aab3304 100644 --- a/gfx/drivers/d3d10.c +++ b/gfx/drivers/d3d10.c @@ -499,22 +499,29 @@ static bool d3d10_gfx_read_viewport(void* data, uint8_t* buffer, bool is_idle) static void d3d10_set_menu_texture_frame( void* data, const void* frame, bool rgb32, unsigned width, unsigned height, float alpha) { - d3d10_video_t* d3d10 = (d3d10_video_t*)data; - int pitch = width * (rgb32 ? sizeof(uint32_t) : sizeof(uint16_t)); - DXGI_FORMAT format = rgb32 ? DXGI_FORMAT_B8G8R8A8_UNORM : (DXGI_FORMAT)DXGI_FORMAT_EX_A4R4G4B4_UNORM; + d3d10_video_t* d3d10 = (d3d10_video_t*)data; + settings_t* settings = config_get_ptr(); + int pitch = width * (rgb32 ? sizeof(uint32_t) + : sizeof(uint16_t)); + DXGI_FORMAT format = rgb32 ? DXGI_FORMAT_B8G8R8A8_UNORM + : (DXGI_FORMAT)DXGI_FORMAT_EX_A4R4G4B4_UNORM; - if (d3d10->menu.texture.desc.Width != width || d3d10->menu.texture.desc.Height != height) + if ( d3d10->menu.texture.desc.Width != width || + d3d10->menu.texture.desc.Height != height) { - d3d10->menu.texture.desc.Format = d3d10_get_closest_match_texture2D(d3d10->device, format); + d3d10->menu.texture.desc.Format = d3d10_get_closest_match_texture2D( + d3d10->device, format); d3d10->menu.texture.desc.Width = width; d3d10->menu.texture.desc.Height = height; d3d10_init_texture(d3d10->device, &d3d10->menu.texture); } - d3d10_update_texture(width, height, pitch, format, frame, &d3d10->menu.texture); - d3d10->menu.sampler = config_get_ptr()->bools.menu_linear_filter ? d3d10->sampler_linear - : d3d10->sampler_nearest; + d3d10_update_texture(width, height, pitch, format, + frame, &d3d10->menu.texture); + d3d10->menu.sampler = settings->bools.menu_linear_filter + ? d3d10->sampler_linear : d3d10->sampler_nearest; } + static void d3d10_set_menu_texture_enable(void* data, bool state, bool full_screen) { d3d10_video_t* d3d10 = (d3d10_video_t*)data; diff --git a/gfx/drivers/d3d11.c b/gfx/drivers/d3d11.c index cddf096d83..7bb3474fec 100644 --- a/gfx/drivers/d3d11.c +++ b/gfx/drivers/d3d11.c @@ -574,9 +574,9 @@ static void* d3d11_gfx_init(const video_info_t* video, const input_driver_t** input, void** input_data) { unsigned i; - WNDCLASSEX wndclass = { 0 }; MONITORINFOEX current_mon; HMONITOR hm_to_use; + WNDCLASSEX wndclass = { 0 }; settings_t* settings = config_get_ptr(); d3d11_video_t* d3d11 = (d3d11_video_t*)calloc(1, sizeof(*d3d11)); @@ -1446,11 +1446,14 @@ static bool d3d11_gfx_read_viewport(void* data, uint8_t* buffer, bool is_idle) static void d3d11_set_menu_texture_frame( void* data, const void* frame, bool rgb32, unsigned width, unsigned height, float alpha) { - d3d11_video_t* d3d11 = (d3d11_video_t*)data; - DXGI_FORMAT format = - rgb32 ? DXGI_FORMAT_B8G8R8A8_UNORM : (DXGI_FORMAT)DXGI_FORMAT_EX_A4R4G4B4_UNORM; + d3d11_video_t* d3d11 = (d3d11_video_t*)data; + settings_t* settings = config_get_ptr(); + DXGI_FORMAT format = rgb32 ? DXGI_FORMAT_B8G8R8A8_UNORM : + (DXGI_FORMAT)DXGI_FORMAT_EX_A4R4G4B4_UNORM; - if (d3d11->menu.texture.desc.Width != width || d3d11->menu.texture.desc.Height != height) + if ( + d3d11->menu.texture.desc.Width != width || + d3d11->menu.texture.desc.Height != height) { d3d11->menu.texture.desc.Format = format; d3d11->menu.texture.desc.Width = width; @@ -1458,11 +1461,12 @@ static void d3d11_set_menu_texture_frame( d3d11_init_texture(d3d11->device, &d3d11->menu.texture); } - d3d11_update_texture(d3d11->context, width, height, 0, format, frame, &d3d11->menu.texture); + d3d11_update_texture(d3d11->context, width, height, 0, + format, frame, &d3d11->menu.texture); d3d11->menu.texture.sampler = d3d11->samplers - [config_get_ptr()->bools.menu_linear_filter - ? RARCH_FILTER_LINEAR - : RARCH_FILTER_NEAREST][RARCH_WRAP_DEFAULT]; + [settings->bools.menu_linear_filter + ? RARCH_FILTER_LINEAR + : RARCH_FILTER_NEAREST][RARCH_WRAP_DEFAULT]; } static void d3d11_set_menu_texture_enable(void* data, bool state, bool full_screen) diff --git a/gfx/drivers/d3d12.c b/gfx/drivers/d3d12.c index dafe301cea..16879caa8c 100644 --- a/gfx/drivers/d3d12.c +++ b/gfx/drivers/d3d12.c @@ -871,9 +871,9 @@ static void d3d12_gfx_free(void* data) static void* d3d12_gfx_init(const video_info_t* video, const input_driver_t** input, void** input_data) { - WNDCLASSEX wndclass = { 0 }; MONITORINFOEX current_mon; HMONITOR hm_to_use; + WNDCLASSEX wndclass = { 0 }; settings_t* settings = config_get_ptr(); d3d12_video_t* d3d12 = (d3d12_video_t*)calloc(1, sizeof(*d3d12)); @@ -1597,14 +1597,19 @@ static bool d3d12_gfx_read_viewport(void* data, uint8_t* buffer, bool is_idle) } static void d3d12_set_menu_texture_frame( - void* data, const void* frame, bool rgb32, unsigned width, unsigned height, float alpha) + void* data, const void* frame, bool rgb32, + unsigned width, unsigned height, float alpha) { - d3d12_video_t* d3d12 = (d3d12_video_t*)data; - int pitch = width * (rgb32 ? sizeof(uint32_t) : sizeof(uint16_t)); - DXGI_FORMAT format = - rgb32 ? DXGI_FORMAT_B8G8R8A8_UNORM : (DXGI_FORMAT)DXGI_FORMAT_EX_A4R4G4B4_UNORM; + d3d12_video_t* d3d12 = (d3d12_video_t*)data; + settings_t* settings = config_get_ptr(); + int pitch = width * + (rgb32 ? sizeof(uint32_t) : sizeof(uint16_t)); + DXGI_FORMAT format = rgb32 ? DXGI_FORMAT_B8G8R8A8_UNORM + : (DXGI_FORMAT)DXGI_FORMAT_EX_A4R4G4B4_UNORM; - if (d3d12->menu.texture.desc.Width != width || d3d12->menu.texture.desc.Height != height) + if ( + d3d12->menu.texture.desc.Width != width || + d3d12->menu.texture.desc.Height != height) { d3d12->menu.texture.desc.Width = width; d3d12->menu.texture.desc.Height = height; @@ -1613,13 +1618,14 @@ static void d3d12_set_menu_texture_frame( d3d12_init_texture(d3d12->device, &d3d12->menu.texture); } - d3d12_update_texture(width, height, pitch, format, frame, &d3d12->menu.texture); + d3d12_update_texture(width, height, pitch, + format, frame, &d3d12->menu.texture); d3d12->menu.alpha = alpha; { D3D12_RANGE read_range = { 0, 0 }; - d3d12_vertex_t* v; + d3d12_vertex_t* v = NULL; D3D12Map(d3d12->menu.vbo, 0, &read_range, (void**)&v); v[0].color[3] = alpha; @@ -1629,19 +1635,27 @@ static void d3d12_set_menu_texture_frame( D3D12Unmap(d3d12->menu.vbo, 0, NULL); } - d3d12->menu.texture.sampler = config_get_ptr()->bools.menu_linear_filter - ? d3d12->samplers[RARCH_FILTER_LINEAR][RARCH_WRAP_DEFAULT] - : d3d12->samplers[RARCH_FILTER_NEAREST][RARCH_WRAP_DEFAULT]; + d3d12->menu.texture.sampler = settings->bools.menu_linear_filter + ? d3d12->samplers[RARCH_FILTER_LINEAR][RARCH_WRAP_DEFAULT] + : d3d12->samplers[RARCH_FILTER_NEAREST][RARCH_WRAP_DEFAULT]; } -static void d3d12_set_menu_texture_enable(void* data, bool state, bool full_screen) + +static void d3d12_set_menu_texture_enable(void* data, + bool state, bool full_screen) { - d3d12_video_t* d3d12 = (d3d12_video_t*)data; + d3d12_video_t* d3d12 = (d3d12_video_t*)data; + + if (!d3d12) + return; d3d12->menu.enabled = state; d3d12->menu.fullscreen = full_screen; } -static void d3d12_gfx_show_mouse(void* data, bool state) { win32_show_cursor(state); } +static void d3d12_gfx_show_mouse(void* data, bool state) +{ + win32_show_cursor(state); +} static void d3d12_gfx_set_aspect_ratio(void* data, unsigned aspect_ratio_idx) { @@ -1663,21 +1677,21 @@ static void d3d12_gfx_apply_state_changes(void* data) } static void d3d12_gfx_set_osd_msg( - void* data, video_frame_info_t* video_info, const char* msg, const void* params, void* font) + void* data, video_frame_info_t* video_info, + const char* msg, const void* params, void* font) { d3d12_video_t* d3d12 = (d3d12_video_t*)data; - if (d3d12) - { - if (d3d12->sprites.enabled) - font_driver_render_msg(video_info, font, msg, (const struct font_params*)params); - else - printf("OSD msg: %s\n", msg); - } + if (!d3d12 || !d3d12->sprites.enabled) + return; + + font_driver_render_msg(video_info, font, msg, + (const struct font_params*)params); } static uintptr_t d3d12_gfx_load_texture( - void* video_data, void* data, bool threaded, enum texture_filter_type filter_type) + void* video_data, void* data, bool threaded, + enum texture_filter_type filter_type) { d3d12_texture_t* texture = NULL; d3d12_video_t* d3d12 = (d3d12_video_t*)video_data; @@ -1696,12 +1710,14 @@ static uintptr_t d3d12_gfx_load_texture( case TEXTURE_FILTER_MIPMAP_LINEAR: texture->desc.MipLevels = UINT16_MAX; case TEXTURE_FILTER_LINEAR: - texture->sampler = d3d12->samplers[RARCH_FILTER_LINEAR][RARCH_WRAP_EDGE]; + texture->sampler = d3d12->samplers[ + RARCH_FILTER_LINEAR][RARCH_WRAP_EDGE]; break; case TEXTURE_FILTER_MIPMAP_NEAREST: texture->desc.MipLevels = UINT16_MAX; case TEXTURE_FILTER_NEAREST: - texture->sampler = d3d12->samplers[RARCH_FILTER_NEAREST][RARCH_WRAP_EDGE]; + texture->sampler = d3d12->samplers[ + RARCH_FILTER_NEAREST][RARCH_WRAP_EDGE]; break; } @@ -1713,7 +1729,8 @@ static uintptr_t d3d12_gfx_load_texture( d3d12_init_texture(d3d12->device, texture); d3d12_update_texture( - image->width, image->height, 0, DXGI_FORMAT_B8G8R8A8_UNORM, image->pixels, texture); + image->width, image->height, 0, + DXGI_FORMAT_B8G8R8A8_UNORM, image->pixels, texture); return (uintptr_t)texture; } diff --git a/gfx/drivers_context/xegl_ctx.c b/gfx/drivers_context/xegl_ctx.c index e791bf1f42..b470ccc6db 100644 --- a/gfx/drivers_context/xegl_ctx.c +++ b/gfx/drivers_context/xegl_ctx.c @@ -273,6 +273,7 @@ static bool gfx_ctx_xegl_set_video_mode(void *data, XSetWindowAttributes swa = {0}; XVisualInfo *vi = NULL; xegl_ctx_data_t *xegl = (xegl_ctx_data_t*)data; + settings_t *settings = config_get_ptr(); int (*old_handler)(Display*, XErrorEvent*) = NULL; @@ -344,10 +345,10 @@ static bool gfx_ctx_xegl_set_video_mode(void *data, CWOverrideRedirect, &swa); XSetWindowBackground(g_x11_dpy, g_x11_win, 0); - if (fullscreen && config_get_ptr()->bools.video_disable_composition) + if (fullscreen && settings && settings->bools.video_disable_composition) { - uint32_t value = 1; - Atom cardinal = XInternAtom(g_x11_dpy, "CARDINAL", False); + uint32_t value = 1; + Atom cardinal = XInternAtom(g_x11_dpy, "CARDINAL", False); Atom net_wm_bypass_compositor = XInternAtom(g_x11_dpy, "_NET_WM_BYPASS_COMPOSITOR", False); RARCH_LOG("[X/EGL]: Requesting compositor bypass.\n"); diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 83e0a598e3..cd4cd47d7d 100755 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -513,7 +513,7 @@ static xmb_node_t *xmb_copy_node(const xmb_node_t *old_node) static const char *xmb_thumbnails_ident(char pos) { - char folder; + char folder = 0; settings_t *settings = config_get_ptr(); if (pos == 'R') @@ -598,7 +598,8 @@ static size_t xmb_list_get_size(void *data, enum menu_list_type type) return 0; } -static void *xmb_list_get_entry(void *data, enum menu_list_type type, unsigned i) +static void *xmb_list_get_entry(void *data, + enum menu_list_type type, unsigned i) { size_t list_size = 0; xmb_handle_t *xmb = (xmb_handle_t*)data; @@ -1571,7 +1572,8 @@ static void xmb_list_open_new(xmb_handle_t *xmb, xmb->old_depth = xmb->depth; menu_entries_ctl(MENU_ENTRIES_CTL_SET_START, &skip); - xmb_system_tab = xmb_get_system_tab(xmb, (unsigned)xmb->categories_selection_ptr); + xmb_system_tab = xmb_get_system_tab(xmb, + (unsigned)xmb->categories_selection_ptr); if (xmb_system_tab <= XMB_SYSTEM_TAB_SETTINGS) { @@ -1584,10 +1586,11 @@ static void xmb_list_open_new(xmb_handle_t *xmb, } } -static xmb_node_t *xmb_node_allocate_userdata(xmb_handle_t *xmb, unsigned i) +static xmb_node_t *xmb_node_allocate_userdata( + xmb_handle_t *xmb, unsigned i) { + xmb_node_t *tmp = NULL; xmb_node_t *node = xmb_alloc_node(); - xmb_node_t *tmp; if (!node) { @@ -1604,7 +1607,8 @@ static xmb_node_t *xmb_node_allocate_userdata(xmb_handle_t *xmb, unsigned i) node->zoom = xmb->categories_active_zoom; } - tmp = (xmb_node_t*)file_list_get_userdata_at_offset(xmb->horizontal_list, i); + tmp = (xmb_node_t*)file_list_get_userdata_at_offset( + xmb->horizontal_list, i); xmb_free_node(tmp); file_list_set_userdata(xmb->horizontal_list, i, node); @@ -1619,7 +1623,8 @@ static xmb_node_t* xmb_get_userdata_from_horizontal_list( file_list_get_userdata_at_offset(xmb->horizontal_list, i); } -static void xmb_push_animations(xmb_node_t *node, uintptr_t tag, float ia, float ix) +static void xmb_push_animations(xmb_node_t *node, + uintptr_t tag, float ia, float ix) { menu_animation_ctx_entry_t anim_entry; @@ -1654,7 +1659,8 @@ static void xmb_list_switch_old(xmb_handle_t *xmb, last = end > 0 ? end - 1 : 0; video_driver_get_size(NULL, &height); - xmb_calculate_visible_range(xmb, height, end, current, &first, &last); + xmb_calculate_visible_range(xmb, height, end, + current, &first, &last); for (i = 0; i < end; i++) { @@ -1773,7 +1779,8 @@ static void xmb_set_title(xmb_handle_t *xmb) if (!path) return; - fill_pathname_base_noext(xmb->title_name, path, sizeof(xmb->title_name)); + fill_pathname_base_noext( + xmb->title_name, path, sizeof(xmb->title_name)); } } @@ -1867,7 +1874,8 @@ static void xmb_list_switch(xmb_handle_t *xmb) xmb_list_switch_horizontal_list(xmb); anim_entry.duration = XMB_DELAY; - anim_entry.target_value = xmb->icon_spacing_horizontal * -(float)xmb->categories_selection_ptr; + anim_entry.target_value = xmb->icon_spacing_horizontal + * -(float)xmb->categories_selection_ptr; anim_entry.subject = &xmb->categories_x_pos; anim_entry.easing_enum = EASING_OUT_QUAD; /* TODO/FIXME - integer conversion resulted in change of sign */ @@ -2045,11 +2053,12 @@ static void xmb_context_reset_horizontal_list( size_t list_size = xmb_list_get_size(xmb, MENU_LIST_HORIZONTAL); - xmb->categories_x_pos = xmb->icon_spacing_horizontal * + xmb->categories_x_pos = + xmb->icon_spacing_horizontal * -(float)xmb->categories_selection_ptr; - depth = (xmb->depth > 1) ? 2 : 1; - xmb->x = xmb->icon_size * -(depth*2-2); + depth = (xmb->depth > 1) ? 2 : 1; + xmb->x = xmb->icon_size * -(depth*2-2); for (i = 0; i < list_size; i++) { @@ -2077,9 +2086,12 @@ static void xmb_context_reset_horizontal_list( { struct texture_image ti; char sysname[256]; - char *iconpath = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); - char *texturepath = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); - char *content_texturepath = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); + char *iconpath = (char*) + malloc(PATH_MAX_LENGTH * sizeof(char)); + char *texturepath = (char*) + malloc(PATH_MAX_LENGTH * sizeof(char)); + char *content_texturepath = (char*) + malloc(PATH_MAX_LENGTH * sizeof(char)); iconpath[0] = sysname[0] = texturepath[0] = content_texturepath[0] = '\0'; @@ -2149,7 +2161,8 @@ static void xmb_refresh_horizontal_list(xmb_handle_t *xmb) menu_driver_ctl(RARCH_MENU_CTL_SET_PREVENT_POPULATE, NULL); - xmb->horizontal_list = (file_list_t*)calloc(1, sizeof(file_list_t)); + xmb->horizontal_list = (file_list_t*) + calloc(1, sizeof(file_list_t)); if (xmb->horizontal_list) xmb_init_horizontal_list(xmb); @@ -2338,7 +2351,8 @@ static uintptr_t xmb_icon_get_id(xmb_handle_t *xmb, if (core_node) return core_node->content_icon; - switch (xmb_get_system_tab(xmb, (unsigned)xmb->categories_selection_ptr)) + switch (xmb_get_system_tab(xmb, + (unsigned)xmb->categories_selection_ptr)) { case XMB_SYSTEM_TAB_FAVORITES: return xmb->textures.list[XMB_TEXTURE_FAVORITE]; @@ -2413,11 +2427,13 @@ static uintptr_t xmb_icon_get_id(xmb_handle_t *xmb, #ifdef HAVE_NETWORKING case MENU_ROOM: return xmb->textures.list[XMB_TEXTURE_ROOM]; - /* stub these out until we have the icons +#if 0 + /* stub these out until we have the icons */ case MENU_ROOM_LAN: return xmb->textures.list[XMB_TEXTURE_ROOM_LAN]; case MENU_ROOM_MITM: - return xmb->textures.list[XMB_TEXTURE_ROOM_MITM]; */ + return xmb->textures.list[XMB_TEXTURE_ROOM_MITM]; +#endif #endif } @@ -2452,7 +2468,8 @@ static void xmb_calculate_visible_range(const xmb_handle_t *xmb, { for (j = current; j-- > 0; ) { - float bottom = xmb_item_y(xmb, j, current) + base_y + xmb->icon_size; + float bottom = xmb_item_y(xmb, j, current) + + base_y + xmb->icon_size; if (bottom < 0) break; @@ -2538,16 +2555,20 @@ static int xmb_draw_item( } } - if (string_is_equal(entry->value, msg_hash_to_str(MENU_ENUM_LABEL_DISABLED)) || - (string_is_equal(entry->value, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF)))) + if (string_is_equal(entry->value, + msg_hash_to_str(MENU_ENUM_LABEL_DISABLED)) || + (string_is_equal(entry->value, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF)))) { if (xmb->textures.list[XMB_TEXTURE_SWITCH_OFF]) texture_switch = xmb->textures.list[XMB_TEXTURE_SWITCH_OFF]; else do_draw_text = true; } - else if (string_is_equal(entry->value, msg_hash_to_str(MENU_ENUM_LABEL_ENABLED)) || - (string_is_equal(entry->value, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_ON)))) + else if (string_is_equal(entry->value, + msg_hash_to_str(MENU_ENUM_LABEL_ENABLED)) || + (string_is_equal(entry->value, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_ON)))) { if (xmb->textures.list[XMB_TEXTURE_SWITCH_ON]) texture_switch = xmb->textures.list[XMB_TEXTURE_SWITCH_ON]; @@ -2834,7 +2855,8 @@ static void xmb_render(void *data, bool is_idle) video_driver_get_size(NULL, &height); if (height) - xmb_calculate_visible_range(xmb, height, end, selection, &first, &last); + xmb_calculate_visible_range(xmb, height, + end, selection, &first, &last); for (i = first; i <= last; i++) {