diff --git a/gfx/font_driver.c b/gfx/font_driver.c index 0368b0cf0e..536076dcd0 100644 --- a/gfx/font_driver.c +++ b/gfx/font_driver.c @@ -42,7 +42,8 @@ int font_renderer_create_default(const void **data, void **handle, { unsigned i; - const font_renderer_driver_t **drv = (const font_renderer_driver_t**)data; + const font_renderer_driver_t **drv = + (const font_renderer_driver_t**)data; for (i = 0; font_backends[i]; i++) { @@ -91,7 +92,8 @@ static bool d3d_font_init_first( for (i = 0; i < ARRAY_SIZE(d3d_font_backends); i++) { - void *data = d3d_font_backends[i]->init(video_data, font_path, font_size); + void *data = d3d_font_backends[i]->init( + video_data, font_path, font_size); if (!data) continue; @@ -123,7 +125,8 @@ static bool gl_font_init_first( for (i = 0; gl_font_backends[i]; i++) { - void *data = gl_font_backends[i]->init(video_data, font_path, font_size); + void *data = gl_font_backends[i]->init( + video_data, font_path, font_size); if (!data) continue; @@ -150,7 +153,8 @@ static bool vita2d_font_init_first( for (i = 0; vita2d_font_backends[i]; i++) { - void *data = vita2d_font_backends[i]->init(video_data, font_path, font_size); + void *data = vita2d_font_backends[i]->init( + video_data, font_path, font_size); if (!data) continue; @@ -164,7 +168,8 @@ static bool vita2d_font_init_first( } #endif -static bool font_init_first(const void **font_driver, void **font_handle, +static bool font_init_first( + const void **font_driver, void **font_handle, void *video_data, const char *font_path, float font_size, enum font_driver_render_api api) { @@ -206,18 +211,21 @@ bool font_driver_has_render_msg(void) return true; } -void font_driver_render_msg(void *font_data, const char *msg, const struct font_params *params) +void font_driver_render_msg(void *font_data, + const char *msg, const struct font_params *params) { const font_renderer_t *font_ctx = font_osd_driver; if (font_ctx->render_msg) - font_ctx->render_msg(font_data ? font_data : font_osd_data, msg, params); + font_ctx->render_msg(font_data + ? font_data : font_osd_data, msg, params); } void font_driver_bind_block(void *font_data, void *block) { const font_renderer_t *font_ctx = font_osd_driver; - void *new_font_data = font_data ? font_data : font_osd_data; + void *new_font_data = font_data + ? font_data : font_osd_data; if (font_ctx->bind_block) font_ctx->bind_block(new_font_data, block); @@ -231,7 +239,8 @@ void font_driver_flush(void *data) font_ctx->flush(data); } -int font_driver_get_message_width(void *data, const char *msg, unsigned len, float scale) +int font_driver_get_message_width(void *data, + const char *msg, unsigned len, float scale) { const font_renderer_t *font_ctx = font_osd_driver; @@ -242,7 +251,8 @@ int font_driver_get_message_width(void *data, const char *msg, unsigned len, flo void font_driver_free(void *data) { - const font_renderer_t *font_ctx = (const font_renderer_t*)font_osd_driver; + const font_renderer_t *font_ctx = + (const font_renderer_t*)font_osd_driver; if (font_ctx->free) font_ctx->free(data ? data : font_osd_data); @@ -254,7 +264,8 @@ void font_driver_free(void *data) font_osd_driver = NULL; } -bool font_driver_init_first(const void **font_driver, void **font_handle, +bool font_driver_init_first( + const void **font_driver, void **font_handle, void *data, const char *font_path, float font_size, bool threading_hint, enum font_driver_render_api api) diff --git a/gfx/video_common.c b/gfx/video_common.c index 2748bf4b6e..9bcea93924 100644 --- a/gfx/video_common.c +++ b/gfx/video_common.c @@ -36,7 +36,8 @@ static INLINE bool realloc_checked(void **ptr, size_t size) return *ptr == nptr; } -bool gfx_coord_array_add(gfx_coord_array_t *ca, const gfx_coords_t *coords, unsigned count) +bool gfx_coord_array_add(gfx_coord_array_t *ca, + const gfx_coords_t *coords, unsigned count) { size_t base_size, offset; bool success = false; diff --git a/gfx/video_context_driver.c b/gfx/video_context_driver.c index a86cb03adf..ff5c8e7d61 100644 --- a/gfx/video_context_driver.c +++ b/gfx/video_context_driver.c @@ -175,7 +175,8 @@ bool gfx_ctx_set_video_mode( bool fullscreen) { if (current_video_context->set_video_mode) - return current_video_context->set_video_mode(video_context_data, width, height, fullscreen); + return current_video_context->set_video_mode( + video_context_data, width, height, fullscreen); return false; } @@ -185,7 +186,8 @@ void gfx_ctx_translate_aspect(float *aspect, if (!current_video_context || !current_video_context->translate_aspect) return; - *aspect = current_video_context->translate_aspect(video_context_data, width, height); + *aspect = current_video_context->translate_aspect( + video_context_data, width, height); } bool gfx_ctx_get_metrics(enum display_metric_types type, float *value) @@ -210,7 +212,8 @@ bool gfx_ctx_image_buffer_write(const void *frame, unsigned width, { const gfx_ctx_driver_t *ctx = current_video_context; if (ctx->image_buffer_write) - return ctx->image_buffer_write(video_context_data, frame, width, height, pitch, + return ctx->image_buffer_write(video_context_data, + frame, width, height, pitch, rgb32, index, image_handle); return false; } @@ -243,7 +246,8 @@ bool gfx_ctx_check_window(bool *quit, bool *resize, if (!video_context_data) return false; - current_video_context->check_window(video_context_data, quit, resize, width, height, (unsigned int)*frame_count); + current_video_context->check_window(video_context_data, quit, + resize, width, height, (unsigned int)*frame_count); return true; } @@ -251,7 +255,8 @@ bool gfx_ctx_check_window(bool *quit, bool *resize, bool gfx_ctx_suppress_screensaver(bool enable) { if (video_context_data && current_video_context) - return current_video_context->suppress_screensaver(video_context_data, enable); + return current_video_context->suppress_screensaver( + video_context_data, enable); return false; } @@ -272,14 +277,16 @@ bool gfx_ctx_set_resize(unsigned width, unsigned height) if (!current_video_context) return false; - return current_video_context->set_resize(video_context_data, width, height); + return current_video_context->set_resize( + video_context_data, width, height); } void gfx_ctx_input_driver( const input_driver_t **input, void **input_data) { if (current_video_context) - current_video_context->input_driver(video_context_data, input, input_data); + current_video_context->input_driver( + video_context_data, input, input_data); } /** @@ -440,5 +447,6 @@ const gfx_ctx_driver_t *gfx_ctx_init_first(void *data, const char *ident, enum gfx_ctx_api api, unsigned major, unsigned minor, bool hw_render_ctx) { - return gfx_ctx_find_driver(data, ident, api, major, minor, hw_render_ctx); + return gfx_ctx_find_driver(data, ident, api, + major, minor, hw_render_ctx); } diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 3b887f91eb..9c6bfa6f73 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -330,10 +330,13 @@ uintptr_t video_driver_get_current_framebuffer(void) return 0; } -bool video_driver_get_current_software_framebuffer(struct retro_framebuffer *framebuffer) +bool video_driver_get_current_software_framebuffer( + struct retro_framebuffer *framebuffer) { - if (video_driver_poke && video_driver_poke->get_current_software_framebuffer) - return video_driver_poke->get_current_software_framebuffer(video_driver_data, framebuffer); + if (video_driver_poke + && video_driver_poke->get_current_software_framebuffer) + return video_driver_poke->get_current_software_framebuffer( + video_driver_data, framebuffer); return false; } @@ -360,7 +363,8 @@ static void deinit_video_filter(void) #else free(video_driver_state.filter.buffer); #endif - memset(&video_driver_state.filter, 0, sizeof(video_driver_state.filter)); + memset(&video_driver_state.filter, 0, + sizeof(video_driver_state.filter)); } static void init_video_filter(enum retro_pixel_format colfmt) @@ -419,9 +423,11 @@ static void init_video_filter(enum retro_pixel_format colfmt) /* TODO: Aligned output. */ #ifdef _3DS - video_driver_state.filter.buffer = linearMemAlign(width * height * video_driver_state.filter.out_bpp, 0x80); + video_driver_state.filter.buffer = linearMemAlign(width + * height * video_driver_state.filter.out_bpp, 0x80); #else - video_driver_state.filter.buffer = malloc(width * height * video_driver_state.filter.out_bpp); + video_driver_state.filter.buffer = malloc(width + * height * video_driver_state.filter.out_bpp); #endif if (!video_driver_state.filter.buffer) goto error; @@ -482,7 +488,8 @@ static void video_monitor_compute_fps_statistics(void) return; } - if (video_driver_state.frame_time_samples_count < 2 * MEASURE_FRAME_TIME_SAMPLES_COUNT) + if (video_driver_state.frame_time_samples_count < + (2 * MEASURE_FRAME_TIME_SAMPLES_COUNT)) { RARCH_LOG( "Does not have enough samples for monitor refresh rate estimation. Requires to run for at least %u frames.\n", @@ -571,12 +578,14 @@ static bool init_video_pixel_converter(unsigned size) RARCH_WARN("0RGB1555 pixel format is deprecated, and will be slower. For 15/16-bit, RGB565 format is preferred.\n"); - video_driver_scaler_ptr = (video_pixel_scaler_t*)calloc(1, sizeof(*video_driver_scaler_ptr)); + video_driver_scaler_ptr = (video_pixel_scaler_t*) + calloc(1, sizeof(*video_driver_scaler_ptr)); if (!video_driver_scaler_ptr) goto error; - video_driver_scaler_ptr->scaler = (struct scaler_ctx*)calloc(1, sizeof(*video_driver_scaler_ptr->scaler)); + video_driver_scaler_ptr->scaler = (struct scaler_ctx*) + calloc(1, sizeof(*video_driver_scaler_ptr->scaler)); if (!video_driver_scaler_ptr->scaler) goto error; @@ -590,7 +599,8 @@ static bool init_video_pixel_converter(unsigned size) if (!scaler_ctx_gen_filter(video_driver_scaler_ptr->scaler)) goto error; - video_driver_scaler_ptr->scaler_out = calloc(sizeof(uint16_t), size * size); + video_driver_scaler_ptr->scaler_out = + calloc(sizeof(uint16_t), size * size); if (!video_driver_scaler_ptr->scaler_out) goto error; @@ -719,12 +729,14 @@ static bool init_video(void) video_driver_ctl(RARCH_DISPLAY_CTL_FIND_DRIVER, NULL); #ifdef HAVE_THREADS - if (settings->video.threaded && !video_driver_state.hw_render_callback.context_type) + if (settings->video.threaded + && !video_driver_state.hw_render_callback.context_type) { /* Can't do hardware rendering with threaded driver currently. */ RARCH_LOG("Starting threaded video driver ...\n"); - if (!rarch_threaded_video_init((const video_driver_t**)¤t_video, &video_driver_data, + if (!rarch_threaded_video_init((const video_driver_t**)¤t_video, + &video_driver_data, input_get_double_ptr(), input_driver_get_data_ptr(), current_video, &video)) { @@ -813,7 +825,8 @@ bool video_driver_set_video_mode(unsigned width, { if (video_driver_poke && video_driver_poke->set_video_mode) { - video_driver_poke->set_video_mode(video_driver_data, width, height, fullscreen); + video_driver_poke->set_video_mode(video_driver_data, + width, height, fullscreen); return true; } @@ -824,7 +837,8 @@ bool video_driver_get_video_output_size(unsigned *width, unsigned *height) { if (video_driver_poke && video_driver_poke->get_video_output_size) { - video_driver_poke->get_video_output_size(video_driver_data, width, height); + video_driver_poke->get_video_output_size(video_driver_data, + width, height); return true; } return false; @@ -841,7 +855,8 @@ void video_driver_set_texture_enable(bool enable, bool fullscreen) { #ifdef HAVE_MENU if (video_driver_poke && video_driver_poke->set_texture_enable) - video_driver_poke->set_texture_enable(video_driver_data, enable, fullscreen); + video_driver_poke->set_texture_enable(video_driver_data, + enable, fullscreen); #endif } @@ -850,7 +865,8 @@ void video_driver_set_texture_frame(const void *frame, bool rgb32, { #ifdef HAVE_MENU if (video_driver_poke && video_driver_poke->set_texture_frame) - video_driver_poke->set_texture_frame(video_driver_data, frame, rgb32, width, height, alpha); + video_driver_poke->set_texture_frame(video_driver_data, + frame, rgb32, width, height, alpha); #endif } @@ -941,7 +957,8 @@ void video_monitor_set_refresh_rate(float hz) char msg[128]; settings_t *settings = config_get_ptr(); - snprintf(msg, sizeof(msg), "Setting refresh rate to: %.3f Hz.", hz); + snprintf(msg, sizeof(msg), + "Setting refresh rate to: %.3f Hz.", hz); runloop_msg_queue_push(msg, 1, 180, false); RARCH_LOG("%s\n", msg); @@ -1285,7 +1302,8 @@ void video_driver_menu_settings(void **list_data, void *list_info_data, 1, true, true); - settings_data_list_current_add_flags(list, list_info, SD_FLAG_CMD_APPLY_AUTO|SD_FLAG_ADVANCED); + settings_data_list_current_add_flags(list, list_info, + SD_FLAG_CMD_APPLY_AUTO|SD_FLAG_ADVANCED); #endif #if defined(_XBOX1) || defined(HW_RVL) CONFIG_BOOL( @@ -1456,13 +1474,18 @@ bool video_driver_ctl(enum rarch_display_ctl_state state, void *data) return video_viewport_set_config(); case RARCH_DISPLAY_CTL_SET_VIEWPORT_SQUARE_PIXEL: { - struct retro_system_av_info *av_info = video_viewport_get_system_av_info(); - struct retro_game_geometry *geom = av_info ? &av_info->geometry : NULL; + struct retro_system_av_info *av_info = + video_viewport_get_system_av_info(); + struct retro_game_geometry *geom = NULL; + + if (av_info) + geom = &av_info->geometry; if (!geom) return false; - video_viewport_set_square_pixel(geom->base_width, geom->base_height); + video_viewport_set_square_pixel( + geom->base_width, geom->base_height); } return true; case RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE: @@ -1540,7 +1563,8 @@ bool video_driver_ctl(enum rarch_display_ctl_state state, void *data) case RARCH_DISPLAY_CTL_SET_ASPECT_RATIO: if (!video_driver_poke || !video_driver_poke->set_aspect_ratio) return false; - video_driver_poke->set_aspect_ratio(video_driver_data, settings->video.aspect_ratio_idx); + video_driver_poke->set_aspect_ratio( + video_driver_data, settings->video.aspect_ratio_idx); return true; case RARCH_DISPLAY_CTL_SHOW_MOUSE: if (!video_driver_poke) @@ -1580,7 +1604,8 @@ bool video_driver_ctl(enum rarch_display_ctl_state state, void *data) case RARCH_DISPLAY_CTL_CACHED_FRAME_HAS_VALID_FB: if (!video_driver_state.frame_cache.data) return false; - return (video_driver_state.frame_cache.data == RETRO_HW_FRAME_BUFFER_VALID); + return (video_driver_state.frame_cache.data + == RETRO_HW_FRAME_BUFFER_VALID); case RARCH_DISPLAY_CTL_CACHED_FRAME_RENDER: if (!current_video) return false; @@ -1629,21 +1654,27 @@ bool video_driver_ctl(enum rarch_display_ctl_state state, void *data) if (!conf) return false; - CONFIG_GET_BOOL_BASE(conf, global, console.screen.gamma_correction, "gamma_correction"); + CONFIG_GET_BOOL_BASE(conf, global, + console.screen.gamma_correction, "gamma_correction"); config_get_bool(conf, "flicker_filter_enable", &global->console.flickerfilter_enable); config_get_bool(conf, "soft_filter_enable", &global->console.softfilter_enable); - CONFIG_GET_INT_BASE(conf, global, console.screen.resolutions.width, + CONFIG_GET_INT_BASE(conf, global, + console.screen.resolutions.width, "console_resolution_width"); - CONFIG_GET_INT_BASE(conf, global, console.screen.resolutions.height, + CONFIG_GET_INT_BASE(conf, global, + console.screen.resolutions.height, "console_resolution_height"); - CONFIG_GET_INT_BASE(conf, global, console.screen.soft_filter_index, + CONFIG_GET_INT_BASE(conf, global, + console.screen.soft_filter_index, "soft_filter_index"); - CONFIG_GET_INT_BASE(conf, global, console.screen.resolutions.current.id, + CONFIG_GET_INT_BASE(conf, global, + console.screen.resolutions.current.id, "current_resolution_id"); - CONFIG_GET_INT_BASE(conf, global, console.screen.flicker_filter_index, + CONFIG_GET_INT_BASE(conf, global, + console.screen.flicker_filter_index, "flicker_filter_index"); } return true; @@ -1779,8 +1810,12 @@ void video_viewport_get_scaled_integer(struct video_viewport *vp, unsigned base_width; /* Use system reported sizes as these define the * geometry for the "normal" case. */ - struct retro_system_av_info *av_info = video_viewport_get_system_av_info(); - unsigned base_height = av_info ? av_info->geometry.base_height : 0; + struct retro_system_av_info *av_info = + video_viewport_get_system_av_info(); + unsigned base_height = 0; + + if (av_info) + base_height = av_info->geometry.base_height; if (base_height == 0) base_height = 1; @@ -1799,7 +1834,8 @@ void video_viewport_get_scaled_integer(struct video_viewport *vp, if (keep_aspect) { /* X/Y scale must be same. */ - unsigned max_scale = min(width / base_width, height / base_height); + unsigned max_scale = min(width / base_width, + height / base_height); padding_x = width - base_width * max_scale; padding_y = height - base_height * max_scale; } @@ -1853,7 +1889,8 @@ static bool video_pixel_frame_scale(const void *data, rarch_perf_init(&video_frame_conv, "video_frame_conv"); - if (!data || video_driver_get_pixel_format() != RETRO_PIXEL_FORMAT_0RGB1555) + if ( !data + || video_driver_get_pixel_format() != RETRO_PIXEL_FORMAT_0RGB1555) return false; if (data == RETRO_HW_FRAME_BUFFER_VALID) return false; diff --git a/gfx/video_shader_driver.c b/gfx/video_shader_driver.c index c5fd67ed1c..8953456beb 100644 --- a/gfx/video_shader_driver.c +++ b/gfx/video_shader_driver.c @@ -100,7 +100,8 @@ void video_shader_driver_scale(unsigned idx, struct gfx_fbo_scale *scale) current_shader->shader_scale(shader_data, idx, scale); } -bool video_shader_driver_init(const shader_backend_t *shader, void *data, const char *path) +bool video_shader_driver_init(const shader_backend_t *shader, + void *data, const char *path) { void *tmp = NULL; @@ -220,6 +221,7 @@ void video_shader_driver_set_params( current_shader->set_params(data, shader_data, width, height, tex_width, tex_height, - out_width, out_height, frame_counter, info, prev_info, feedback_info, + out_width, out_height, frame_counter, info, + prev_info, feedback_info, fbo_info, fbo_info_cnt); } diff --git a/gfx/video_shader_parse.c b/gfx/video_shader_parse.c index 37bca58418..4ada660725 100644 --- a/gfx/video_shader_parse.c +++ b/gfx/video_shader_parse.c @@ -111,7 +111,8 @@ static enum gfx_wrap_type wrap_str_to_mode(const char *wrap_mode) * * Returns: true (1) if successful, otherwise false (0). **/ -static bool video_shader_parse_pass(config_file_t *conf, struct video_shader_pass *pass, unsigned i) +static bool video_shader_parse_pass(config_file_t *conf, + struct video_shader_pass *pass, unsigned i) { char shader_name[64] = {0}; char filter_name_buf[64] = {0}; @@ -135,7 +136,8 @@ static bool video_shader_parse_pass(config_file_t *conf, struct video_shader_pas /* Source */ snprintf(shader_name, sizeof(shader_name), "shader%u", i); - if (!config_get_path(conf, shader_name, pass->source.path, sizeof(pass->source.path))) + if (!config_get_path(conf, shader_name, + pass->source.path, sizeof(pass->source.path))) { RARCH_ERR("Couldn't parse shader source (%s).\n", shader_name); return false; @@ -364,7 +366,8 @@ static bool video_shader_parse_textures(config_file_t *conf, * Returns: handle to shader parameter if successful, otherwise NULL. **/ static struct video_shader_parameter *video_shader_parse_find_parameter( - struct video_shader_parameter *params, unsigned num_params, const char *id) + struct video_shader_parameter *params, + unsigned num_params, const char *id) { unsigned i;