This commit is contained in:
twinaphex 2016-02-14 05:26:17 +01:00
parent ead20f9ba5
commit 4fcb1469cc

View File

@ -98,7 +98,7 @@ static enum rarch_display_type video_driver_display_type;
static uint64_t video_driver_frame_count;
static void *video_driver_data = NULL;
static void *video_driver_data = NULL;
static video_driver_t *current_video = NULL;
/* Interface for "poking". */
@ -333,9 +333,9 @@ const video_poke_interface_t *video_driver_get_poke(void)
**/
uintptr_t video_driver_get_current_framebuffer(void)
{
if (video_driver_poke && video_driver_poke->get_current_framebuffer)
return video_driver_poke->get_current_framebuffer(video_driver_data);
return 0;
if (!video_driver_poke || !video_driver_poke->get_current_framebuffer)
return 0;
return video_driver_poke->get_current_framebuffer(video_driver_data);
}
bool video_driver_get_current_software_framebuffer(
@ -399,7 +399,8 @@ static void init_video_filter(enum retro_pixel_format colfmt)
return;
}
geom = av_info ? (struct retro_game_geometry*)&av_info->geometry : NULL;
if (av_info)
geom = (struct retro_game_geometry*)&av_info->geometry;
if (!geom)
return;
@ -420,22 +421,23 @@ static void init_video_filter(enum retro_pixel_format colfmt)
rarch_softfilter_get_max_output_size(video_driver_state.filter.filter,
&width, &height);
pow2_x = next_pow2(width);
pow2_y = next_pow2(height);
maxsize = max(pow2_x, pow2_y);
video_driver_state.filter.scale = maxsize / RARCH_SCALE_BASE;
pow2_x = next_pow2(width);
pow2_y = next_pow2(height);
maxsize = max(pow2_x, pow2_y);
video_driver_state.filter.scale = maxsize / RARCH_SCALE_BASE;
video_driver_state.filter.out_rgb32 = rarch_softfilter_get_output_format(
video_driver_state.filter.filter) == RETRO_PIXEL_FORMAT_XRGB8888;
video_driver_state.filter.out_bpp = video_driver_state.filter.out_rgb32 ?
video_driver_state.filter.out_bpp =
video_driver_state.filter.out_rgb32 ?
sizeof(uint32_t) : sizeof(uint16_t);
/* TODO: Aligned output. */
#ifdef _3DS
video_driver_state.filter.buffer = linearMemAlign(width
video_driver_state.filter.buffer = linearMemAlign(width
* height * video_driver_state.filter.out_bpp, 0x80);
#else
video_driver_state.filter.buffer = malloc(width
video_driver_state.filter.buffer = malloc(width
* height * video_driver_state.filter.out_bpp);
#endif
if (!video_driver_state.filter.buffer)
@ -487,8 +489,9 @@ error:
**/
static void video_monitor_compute_fps_statistics(void)
{
double avg_fps = 0.0, stddev = 0.0;
unsigned samples = 0;
double avg_fps = 0.0;
double stddev = 0.0;
unsigned samples = 0;
settings_t *settings = config_get_ptr();
if (settings->video.threaded)
@ -782,23 +785,19 @@ error:
bool video_driver_set_viewport(unsigned width, unsigned height,
bool force_fullscreen, bool allow_rotate)
{
if (current_video->set_viewport)
{
current_video->set_viewport(video_driver_data, width, height,
force_fullscreen, allow_rotate);
return true;
}
return false;
if (!current_video || !current_video->set_viewport)
return false;
current_video->set_viewport(video_driver_data, width, height,
force_fullscreen, allow_rotate);
return true;
}
bool video_driver_set_rotation(unsigned rotation)
{
if (current_video->set_rotation)
{
current_video->set_rotation(video_driver_data, rotation);
return true;
}
return false;
if (!current_video || !current_video->set_rotation)
return false;
current_video->set_rotation(video_driver_data, rotation);
return true;
}
bool video_driver_set_video_mode(unsigned width,
@ -822,13 +821,11 @@ bool video_driver_set_video_mode(unsigned width,
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);
return true;
}
return false;
if (!video_driver_poke || !video_driver_poke->get_video_output_size)
return false;
video_driver_poke->get_video_output_size(video_driver_data,
width, height);
return true;
}
void video_driver_set_osd_msg(const char *msg,
@ -857,34 +854,30 @@ void video_driver_set_texture_frame(const void *frame, bool rgb32,
bool video_driver_viewport_info(struct video_viewport *vp)
{
if (current_video->viewport_info)
{
current_video->viewport_info(video_driver_data, vp);
return true;
}
return false;
if (!current_video || !current_video->viewport_info)
return false;
current_video->viewport_info(video_driver_data, vp);
return true;
}
#ifdef HAVE_OVERLAY
bool video_driver_overlay_interface(const video_overlay_interface_t **iface)
{
if (current_video->overlay_interface)
{
current_video->overlay_interface(video_driver_data, iface);
return true;
}
return false;
if (!current_video || !current_video->overlay_interface)
return false;
current_video->overlay_interface(video_driver_data, iface);
return true;
}
#endif
void *video_driver_read_frame_raw(unsigned *width,
unsigned *height, size_t *pitch)
{
if (current_video->read_frame_raw)
return current_video->read_frame_raw(video_driver_data, width,
height, pitch);
return NULL;
if (!current_video || !current_video->read_frame_raw)
return NULL;
return current_video->read_frame_raw(video_driver_data, width,
height, pitch);
}
void video_driver_set_filtering(unsigned index, bool smooth)
@ -1035,7 +1028,7 @@ bool video_monitor_get_fps(char *buf, size_t size,
if (video_driver_frame_count)
{
static float last_fps;
bool ret = false;
bool ret = false;
unsigned write_index = video_driver_state.frame_time_samples_count++ &
(MEASURE_FRAME_TIME_SAMPLES_COUNT - 1);
@ -1350,7 +1343,7 @@ static void video_viewport_set_square_pixel(unsigned width, unsigned height)
**/
static bool video_viewport_set_config(void)
{
settings_t *settings = config_get_ptr();
settings_t *settings = config_get_ptr();
struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
if (settings->video.aspect_ratio < 0.0f)
@ -1443,9 +1436,9 @@ 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_game_geometry *geom = 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;
@ -1763,7 +1756,8 @@ void video_viewport_get_scaled_integer(struct video_viewport *vp,
unsigned width, unsigned height,
float aspect_ratio, bool keep_aspect)
{
int padding_x = 0, padding_y = 0;
int padding_x = 0;
int padding_y = 0;
settings_t *settings = config_get_ptr();
if (!vp)
@ -1777,8 +1771,8 @@ void video_viewport_get_scaled_integer(struct video_viewport *vp,
{
padding_x = width - custom->width;
padding_y = height - custom->height;
width = custom->width;
height = custom->height;
width = custom->width;
height = custom->height;
}
}
else
@ -1949,7 +1943,8 @@ void video_driver_frame(const void *data, unsigned width,
strlcpy(video_driver_msg, msg, sizeof(video_driver_msg));
if (!current_video || !current_video->frame(
video_driver_data, data, width, height, video_driver_frame_count,
video_driver_data, data, width, height,
video_driver_frame_count,
pitch, video_driver_msg))
video_driver_ctl(RARCH_DISPLAY_CTL_UNSET_ACTIVE, NULL);