Add video_poke_interface_t.

This commit is contained in:
Themaister 2013-03-10 01:16:56 +01:00
parent e983684359
commit 2681f14032
5 changed files with 97 additions and 37 deletions

View File

@ -830,6 +830,9 @@ void init_video_input(void)
rarch_fail(1, "init_video_input()"); rarch_fail(1, "init_video_input()");
} }
if (driver.video->poke_interface)
driver.video->poke_interface(driver.video_data, &driver.video_poke);
if (driver.video->set_rotation && g_extern.system.rotation) if (driver.video->set_rotation && g_extern.system.rotation)
video_set_rotation_func(g_extern.system.rotation); video_set_rotation_func(g_extern.system.rotation);

View File

@ -226,6 +226,15 @@ typedef struct video_overlay_interface
} video_overlay_interface_t; } video_overlay_interface_t;
#endif #endif
// Optionally implemented interface to poke more deeply into video driver.
// Only used by RGUI atm.
typedef struct video_poke_interface
{
void (*set_filtering)(void *data, unsigned index, bool smooth);
void (*set_fbo_state)(void *data, unsigned state);
void (*set_aspect_ratio)(void *data, unsigned aspectratio_index);
} video_poke_interface_t;
typedef struct video_driver typedef struct video_driver
{ {
void *(*init)(const video_info_t *video, const input_driver_t **input, void **input_data); void *(*init)(const video_info_t *video, const input_driver_t **input, void **input_data);
@ -245,9 +254,6 @@ typedef struct video_driver
void (*stop)(void); void (*stop)(void);
void (*restart)(void); void (*restart)(void);
#endif #endif
#if defined(HAVE_RMENU) || defined(HAVE_RGUI)
void (*set_aspect_ratio)(void *data, unsigned aspectratio_index);
#endif
void (*set_rotation)(void *data, unsigned rotation); void (*set_rotation)(void *data, unsigned rotation);
void (*viewport_info)(void *data, struct rarch_viewport *vp); void (*viewport_info)(void *data, struct rarch_viewport *vp);
@ -258,6 +264,7 @@ typedef struct video_driver
#ifdef HAVE_OVERLAY #ifdef HAVE_OVERLAY
void (*overlay_interface)(void *data, const video_overlay_interface_t **iface); void (*overlay_interface)(void *data, const video_overlay_interface_t **iface);
#endif #endif
void (*poke_interface)(void *data, const video_poke_interface_t **iface);
} video_driver_t; } video_driver_t;
enum rarch_display_type enum rarch_display_type
@ -318,6 +325,9 @@ typedef struct driver
input_overlay_t *overlay; input_overlay_t *overlay;
uint64_t overlay_state; uint64_t overlay_state;
#endif #endif
// Interface for "poking".
const video_poke_interface_t *video_poke;
} driver_t; } driver_t;
void init_drivers(void); void init_drivers(void);

View File

@ -169,8 +169,6 @@ void gfx_scale_integer(struct rarch_viewport *vp, unsigned width, unsigned heigh
vp->y = padding_y >> 1; vp->y = padding_y >> 1;
} }
#if defined(HAVE_RMENU) || defined(HAVE_RGUI)
struct aspect_ratio_elem aspectratio_lut[ASPECT_RATIO_END] = { struct aspect_ratio_elem aspectratio_lut[ASPECT_RATIO_END] = {
{ "1:1", 1.0f }, { "1:1", 1.0f },
{ "2:1", 2.0f }, { "2:1", 2.0f },
@ -206,7 +204,7 @@ char rotation_lut[ASPECT_RATIO_END][32] =
void gfx_set_auto_viewport(unsigned width, unsigned height) void gfx_set_auto_viewport(unsigned width, unsigned height)
{ {
if(width == 0 || height == 0) if (width == 0 || height == 0)
return; return;
unsigned aspect_x, aspect_y, len, highest, i; unsigned aspect_x, aspect_y, len, highest, i;
@ -222,8 +220,11 @@ void gfx_set_auto_viewport(unsigned width, unsigned height)
aspect_x = width / highest; aspect_x = width / highest;
aspect_y = height / highest; aspect_y = height / highest;
snprintf(aspectratio_lut[ASPECT_RATIO_AUTO].name, sizeof(aspectratio_lut[ASPECT_RATIO_AUTO].name), "%d:%d (Auto)", aspect_x, aspect_y); snprintf(aspectratio_lut[ASPECT_RATIO_AUTO].name,
aspectratio_lut[ASPECT_RATIO_AUTO].value = (float) aspect_x / aspect_y; sizeof(aspectratio_lut[ASPECT_RATIO_AUTO].name),
"%d:%d (Auto)", aspect_x, aspect_y);
aspectratio_lut[ASPECT_RATIO_AUTO].value = (float)aspect_x / aspect_y;
} }
void gfx_set_core_viewport(void) void gfx_set_core_viewport(void)
@ -233,9 +234,8 @@ void gfx_set_core_viewport(void)
// fallback to 1:1 pixel ratio if none provided // fallback to 1:1 pixel ratio if none provided
if (g_extern.system.av_info.geometry.aspect_ratio == 0.0) if (g_extern.system.av_info.geometry.aspect_ratio == 0.0)
aspectratio_lut[ASPECT_RATIO_CORE].value = (float) g_extern.system.av_info.geometry.base_width / g_extern.system.av_info.geometry.base_height; aspectratio_lut[ASPECT_RATIO_CORE].value = (float)g_extern.system.av_info.geometry.base_width / g_extern.system.av_info.geometry.base_height;
else else
aspectratio_lut[ASPECT_RATIO_CORE].value = g_extern.system.av_info.geometry.aspect_ratio; aspectratio_lut[ASPECT_RATIO_CORE].value = g_extern.system.av_info.geometry.aspect_ratio;
} }
#endif

View File

@ -40,8 +40,6 @@ void gfx_set_dwm(void);
void gfx_scale_integer(struct rarch_viewport *vp, unsigned win_width, unsigned win_height, void gfx_scale_integer(struct rarch_viewport *vp, unsigned win_width, unsigned win_height,
float aspect_ratio, bool keep_aspect); float aspect_ratio, bool keep_aspect);
#if defined(HAVE_RMENU) || defined(HAVE_RGUI)
#define MIN_SCALING_FACTOR (1.0f) #define MIN_SCALING_FACTOR (1.0f)
#if defined(__CELLOS_LV2__) #if defined(__CELLOS_LV2__)
@ -90,7 +88,7 @@ enum rotation
ORIENTATION_END ORIENTATION_END
}; };
#define LAST_ORIENTATION (ORIENTATION_END-1) #define LAST_ORIENTATION (ORIENTATION_END - 1)
extern char rotation_lut[ASPECT_RATIO_END][32]; extern char rotation_lut[ASPECT_RATIO_END][32];
@ -119,8 +117,6 @@ extern struct aspect_ratio_elem aspectratio_lut[ASPECT_RATIO_END];
extern void gfx_set_auto_viewport(unsigned width, unsigned height); extern void gfx_set_auto_viewport(unsigned width, unsigned height);
extern void gfx_set_core_viewport(void); extern void gfx_set_core_viewport(void);
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -2081,25 +2081,6 @@ static void gl_restart(void)
} }
#endif #endif
#if defined(HAVE_RGUI) || defined(HAVE_RMENU)
static void gl_set_aspect_ratio(void *data, unsigned aspectratio_index)
{
(void)data;
gl_t *gl = driver.video_data;
if (g_settings.video.aspect_ratio_idx == ASPECT_RATIO_AUTO)
gfx_set_auto_viewport(g_extern.frame_cache.width, g_extern.frame_cache.height);
else if(g_settings.video.aspect_ratio_idx == ASPECT_RATIO_CORE)
gfx_set_core_viewport();
g_settings.video.aspect_ratio = aspectratio_lut[g_settings.video.aspect_ratio_idx].value;
g_settings.video.force_aspect = false;
gl->keep_aspect = true;
gl->should_resize = true;
}
#endif
#ifdef HAVE_OVERLAY #ifdef HAVE_OVERLAY
static bool gl_overlay_load(void *data, const uint32_t *image, unsigned width, unsigned height) static bool gl_overlay_load(void *data, const uint32_t *image, unsigned width, unsigned height)
{ {
@ -2224,6 +2205,78 @@ static void gl_get_overlay_interface(void *data, const video_overlay_interface_t
} }
#endif #endif
static void gl_set_filtering(void *data, unsigned index, bool smooth)
{
gl_t *gl = (gl_t*)data;
GLuint filter = smooth ? GL_LINEAR : GL_NEAREST;
if (index == 1)
{
gl->tex_filter = filter;
// Apply to all PREV textures.
for (unsigned i = 0; i < TEXTURES; i++)
{
glBindTexture(GL_TEXTURE_2D, gl->texture[i]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
}
}
else if (index >= 2 && gl->fbo_inited)
{
glBindTexture(GL_TEXTURE_2D, gl->fbo_texture[index - 2]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
}
glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]);
}
static void gl_set_fbo_state(void *data, unsigned mode)
{
gl_t *gl = (gl_t*)data;
switch (mode)
{
case FBO_DEINIT:
gl_deinit_fbo(gl);
break;
case FBO_REINIT:
gl_deinit_fbo(gl);
// Fallthrough
case FBO_INIT:
gl_init_fbo(gl, gl->tex_w, gl->tex_h);
break;
}
}
static void gl_set_aspect_ratio(void *data, unsigned aspectratio_index)
{
gl_t *gl = (gl_t*)data;
if (g_settings.video.aspect_ratio_idx == ASPECT_RATIO_AUTO)
gfx_set_auto_viewport(g_extern.frame_cache.width, g_extern.frame_cache.height);
else if (g_settings.video.aspect_ratio_idx == ASPECT_RATIO_CORE)
gfx_set_core_viewport();
g_settings.video.aspect_ratio = aspectratio_lut[g_settings.video.aspect_ratio_idx].value;
g_settings.video.force_aspect = false;
gl->keep_aspect = true;
gl->should_resize = true;
}
static const video_poke_interface_t gl_poke_interface = {
gl_set_filtering,
gl_set_fbo_state,
gl_set_aspect_ratio,
};
static void gl_get_poke_interface(void *data, const video_poke_interface_t **iface)
{
(void)data;
*iface = &gl_poke_interface;
}
const video_driver_t video_gl = { const video_driver_t video_gl = {
gl_init, gl_init,
gl_frame, gl_frame,
@ -2244,9 +2297,6 @@ const video_driver_t video_gl = {
gl_start, gl_start,
gl_stop, gl_stop,
gl_restart, gl_restart,
#endif
#if defined(HAVE_RMENU) || defined(HAVE_RGUI)
gl_set_aspect_ratio,
#endif #endif
gl_set_rotation, gl_set_rotation,
@ -2261,6 +2311,7 @@ const video_driver_t video_gl = {
#ifdef HAVE_OVERLAY #ifdef HAVE_OVERLAY
gl_get_overlay_interface, gl_get_overlay_interface,
#endif #endif
gl_get_poke_interface,
}; };