mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-28 02:30:35 +00:00
video_driver.c - Refactor
This commit is contained in:
parent
ef825e0c6a
commit
128fbce403
@ -222,6 +222,14 @@ void *video_driver_get_ptr(const video_driver_t **drv)
|
||||
return driver->video_data;
|
||||
}
|
||||
|
||||
static const video_poke_interface_t *video_driver_get_poke_ptr(void)
|
||||
{
|
||||
driver_t *driver = driver_get_ptr();
|
||||
if (!driver)
|
||||
return NULL;
|
||||
return driver->video_poke;
|
||||
}
|
||||
|
||||
/**
|
||||
* video_driver_get_current_framebuffer:
|
||||
*
|
||||
@ -233,18 +241,22 @@ void *video_driver_get_ptr(const video_driver_t **drv)
|
||||
uintptr_t video_driver_get_current_framebuffer(void)
|
||||
{
|
||||
#ifdef HAVE_FBO
|
||||
driver_t *driver = driver_get_ptr();
|
||||
if (driver && driver->video_poke && driver->video_poke->get_current_framebuffer)
|
||||
return driver->video_poke->get_current_framebuffer(driver->video_data);
|
||||
driver_t *driver = driver_get_ptr();
|
||||
const video_poke_interface_t *poke = video_driver_get_poke_ptr();
|
||||
|
||||
if (poke && poke->get_current_framebuffer)
|
||||
return poke->get_current_framebuffer(driver->video_data);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
retro_proc_address_t video_driver_get_proc_address(const char *sym)
|
||||
{
|
||||
driver_t *driver = driver_get_ptr();
|
||||
if (driver && driver->video_data && driver->video_poke && driver->video_poke->get_proc_address)
|
||||
return driver->video_poke->get_proc_address(driver->video_data, sym);
|
||||
driver_t *driver = driver_get_ptr();
|
||||
const video_poke_interface_t *poke = video_driver_get_poke_ptr();
|
||||
|
||||
if (poke && poke->get_proc_address)
|
||||
return poke->get_proc_address(driver->video_data, sym);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -600,30 +612,26 @@ bool video_driver_set_rotation(unsigned rotation)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void video_driver_set_video_mode(unsigned width,
|
||||
unsigned height, bool fullscreen)
|
||||
{
|
||||
driver_t *driver = driver_get_ptr();
|
||||
driver_t *driver = driver_get_ptr();
|
||||
const video_poke_interface_t *poke = video_driver_get_poke_ptr();
|
||||
|
||||
if (driver
|
||||
&& driver->video_data
|
||||
&& driver->video_poke
|
||||
&& driver->video_poke->set_video_mode)
|
||||
driver->video_poke->set_video_mode(driver->video_data,
|
||||
if (poke && poke->set_video_mode)
|
||||
poke->set_video_mode(driver->video_data,
|
||||
width, height, fullscreen);
|
||||
}
|
||||
|
||||
bool video_driver_get_video_output_size(unsigned *width, unsigned *height)
|
||||
{
|
||||
driver_t *driver = driver_get_ptr();
|
||||
driver_t *driver = driver_get_ptr();
|
||||
const video_poke_interface_t *poke = video_driver_get_poke_ptr();
|
||||
|
||||
if (driver
|
||||
&& driver->video_data
|
||||
&& driver->video_poke
|
||||
&& driver->video_poke->get_video_output_size)
|
||||
if (poke && poke->get_video_output_size)
|
||||
{
|
||||
driver->video_poke->get_video_output_size(driver->video_data,
|
||||
width, height);
|
||||
poke->get_video_output_size(driver->video_data, width, height);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -631,51 +639,40 @@ bool video_driver_get_video_output_size(unsigned *width, unsigned *height)
|
||||
|
||||
void video_driver_set_aspect_ratio(unsigned aspectratio_index)
|
||||
{
|
||||
driver_t *driver = driver_get_ptr();
|
||||
driver_t *driver = driver_get_ptr();
|
||||
const video_poke_interface_t *poke = video_driver_get_poke_ptr();
|
||||
|
||||
if (driver
|
||||
&& driver->video_data
|
||||
&& driver->video_poke
|
||||
&& driver->video_poke->set_aspect_ratio)
|
||||
driver->video_poke->set_aspect_ratio(driver->video_data,
|
||||
aspectratio_index);
|
||||
if (poke && poke->set_aspect_ratio)
|
||||
poke->set_aspect_ratio(driver->video_data, aspectratio_index);
|
||||
}
|
||||
|
||||
void video_driver_show_mouse(bool state)
|
||||
{
|
||||
driver_t *driver = driver_get_ptr();
|
||||
driver_t *driver = driver_get_ptr();
|
||||
const video_poke_interface_t *poke = video_driver_get_poke_ptr();
|
||||
|
||||
if (driver
|
||||
&& driver->video_data
|
||||
&& driver->video_poke
|
||||
&& driver->video_poke->show_mouse)
|
||||
driver->video_poke->show_mouse(
|
||||
driver->video_data, state);
|
||||
if (poke && poke->show_mouse)
|
||||
poke->show_mouse(driver->video_data, state);
|
||||
}
|
||||
|
||||
void video_driver_set_osd_msg(const char *msg,
|
||||
const struct font_params *params, void *font)
|
||||
{
|
||||
driver_t *driver = driver_get_ptr();
|
||||
driver_t *driver = driver_get_ptr();
|
||||
const video_poke_interface_t *poke = video_driver_get_poke_ptr();
|
||||
|
||||
if (driver
|
||||
&& driver->video_data
|
||||
&& driver->video_poke
|
||||
&& driver->video_poke->set_osd_msg)
|
||||
driver->video_poke->set_osd_msg(driver->video_data,
|
||||
msg, params, font);
|
||||
if (poke && poke->set_osd_msg)
|
||||
poke->set_osd_msg(driver->video_data, msg, params, font);
|
||||
}
|
||||
|
||||
void video_driver_set_texture_enable(bool enable, bool fullscreen)
|
||||
{
|
||||
#ifdef HAVE_MENU
|
||||
driver_t *driver = driver_get_ptr();
|
||||
driver_t *driver = driver_get_ptr();
|
||||
const video_poke_interface_t *poke = video_driver_get_poke_ptr();
|
||||
|
||||
if (driver
|
||||
&& driver->video_data
|
||||
&& driver->video_poke
|
||||
&& driver->video_poke->set_texture_enable)
|
||||
driver->video_poke->set_texture_enable(driver->video_data,
|
||||
if (poke && poke->set_texture_enable)
|
||||
poke->set_texture_enable(driver->video_data,
|
||||
enable, fullscreen);
|
||||
#endif
|
||||
}
|
||||
@ -684,14 +681,12 @@ void video_driver_set_texture_frame(const void *frame, bool rgb32,
|
||||
unsigned width, unsigned height, float alpha)
|
||||
{
|
||||
#ifdef HAVE_MENU
|
||||
driver_t *driver = driver_get_ptr();
|
||||
driver_t *driver = driver_get_ptr();
|
||||
const video_poke_interface_t *poke = video_driver_get_poke_ptr();
|
||||
|
||||
if (driver
|
||||
&& driver->video_data
|
||||
&& driver->video_poke
|
||||
&& driver->video_poke->set_texture_frame)
|
||||
driver->video_poke->set_texture_frame(
|
||||
driver->video_data, frame, rgb32, width, height, alpha);
|
||||
if (poke && poke->set_texture_frame)
|
||||
poke->set_texture_frame(driver->video_data,
|
||||
frame, rgb32, width, height, alpha);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -762,46 +757,38 @@ void * video_driver_read_frame_raw(unsigned *width,
|
||||
|
||||
void video_driver_set_filtering(unsigned index, bool smooth)
|
||||
{
|
||||
driver_t *driver = driver_get_ptr();
|
||||
driver_t *driver = driver_get_ptr();
|
||||
const video_poke_interface_t *poke = video_driver_get_poke_ptr();
|
||||
|
||||
if (driver
|
||||
&& driver->video && driver->video_poke
|
||||
&& driver->video_poke->set_filtering)
|
||||
driver->video_poke->set_filtering(driver->video_data,
|
||||
index, smooth);
|
||||
if (poke && poke->set_filtering)
|
||||
poke->set_filtering(driver->video_data, index, smooth);
|
||||
}
|
||||
|
||||
void video_driver_apply_state_changes(void)
|
||||
{
|
||||
driver_t *driver = driver_get_ptr();
|
||||
driver_t *driver = driver_get_ptr();
|
||||
const video_poke_interface_t *poke = video_driver_get_poke_ptr();
|
||||
|
||||
if (driver && driver->video && driver->video_poke
|
||||
&& driver->video_poke->apply_state_changes)
|
||||
driver->video_poke->apply_state_changes(driver->video_data);
|
||||
if (poke && poke->apply_state_changes)
|
||||
poke->apply_state_changes(driver->video_data);
|
||||
}
|
||||
|
||||
void video_driver_get_video_output_next(void)
|
||||
{
|
||||
driver_t *driver = driver_get_ptr();
|
||||
driver_t *driver = driver_get_ptr();
|
||||
const video_poke_interface_t *poke = video_driver_get_poke_ptr();
|
||||
|
||||
if (driver
|
||||
&& driver->video
|
||||
&& driver->video_data
|
||||
&& driver->video_poke
|
||||
&& driver->video_poke->get_video_output_next)
|
||||
driver->video_poke->get_video_output_next(driver->video_data);
|
||||
if (poke && poke->get_video_output_next)
|
||||
poke->get_video_output_next(driver->video_data);
|
||||
}
|
||||
|
||||
void video_driver_get_video_output_prev(void)
|
||||
{
|
||||
driver_t *driver = driver_get_ptr();
|
||||
driver_t *driver = driver_get_ptr();
|
||||
const video_poke_interface_t *poke = video_driver_get_poke_ptr();
|
||||
|
||||
if (driver
|
||||
&& driver->video
|
||||
&& driver->video_data
|
||||
&& driver->video_poke
|
||||
&& driver->video_poke->get_video_output_prev)
|
||||
driver->video_poke->get_video_output_prev(driver->video_data);
|
||||
if (poke && poke->get_video_output_prev)
|
||||
poke->get_video_output_prev(driver->video_data);
|
||||
}
|
||||
|
||||
bool video_driver_frame(const void *frame, unsigned width,
|
||||
|
Loading…
Reference in New Issue
Block a user