mirror of
https://github.com/libretro/RetroArch
synced 2025-01-29 09:32:52 +00:00
Create set_viewport wrapper function - threaded video mode's
set_viewport function does not work yet
This commit is contained in:
parent
b980f5c4de
commit
a9dee4877e
@ -374,6 +374,31 @@ static void d3d_set_viewport(d3d_video_t *d3d, int x, int y,
|
||||
|
||||
d3d_set_font_rect(d3d, NULL);
|
||||
}
|
||||
|
||||
static void d3d_set_viewport_wrap(void *data,
|
||||
unsigned width, unsigned height,
|
||||
bool force_fullscreen,
|
||||
bool allow_rotate)
|
||||
{
|
||||
D3DVIEWPORT vp_full;
|
||||
LPDIRECT3DDEVICE d3dr;
|
||||
d3d_video_t *d3d = (d3d_video_t*)data;
|
||||
|
||||
vp_full.X = 0;
|
||||
vp_full.Y = 0;
|
||||
vp_full.Width = width;
|
||||
vp_full.Height = height;
|
||||
vp_full.MinZ = 0.0f;
|
||||
vp_full.MaxZ = 1.0f;
|
||||
|
||||
d3dr = (LPDIRECT3DDEVICE)d3d->dev;
|
||||
|
||||
if (force_fullscreen)
|
||||
d3d_set_viewport(d3dr, &vp_full);
|
||||
else
|
||||
d3d_set_viewport(d3dr, &d3d->final_viewport);
|
||||
}
|
||||
|
||||
bool d3d_restore(d3d_video_t *d3d)
|
||||
{
|
||||
d3d_deinitialize(d3d);
|
||||
@ -1973,6 +1998,7 @@ video_driver_t video_d3d = {
|
||||
d3d_set_shader,
|
||||
d3d_free,
|
||||
"d3d",
|
||||
d3d_set_viewport_wrap,
|
||||
d3d_set_rotation,
|
||||
d3d_viewport_info,
|
||||
d3d_read_viewport,
|
||||
|
@ -553,7 +553,7 @@ video_driver_t video_ctr =
|
||||
ctr_set_shader,
|
||||
ctr_free,
|
||||
"ctr",
|
||||
|
||||
NULL, /* set_viewport */
|
||||
ctr_set_rotation,
|
||||
ctr_viewport_info,
|
||||
ctr_read_viewport,
|
||||
|
@ -651,7 +651,7 @@ video_driver_t video_dispmanx = {
|
||||
dispmanx_gfx_set_shader,
|
||||
dispmanx_gfx_free,
|
||||
"dispmanx",
|
||||
|
||||
NULL, /* set_viewport */
|
||||
dispmanx_gfx_set_rotation,
|
||||
dispmanx_gfx_viewport_info,
|
||||
dispmanx_gfx_read_viewport,
|
||||
|
@ -1675,6 +1675,7 @@ video_driver_t video_exynos = {
|
||||
exynos_gfx_set_shader,
|
||||
exynos_gfx_free,
|
||||
"exynos",
|
||||
NULL, /* set_viewport */
|
||||
exynos_gfx_set_rotation,
|
||||
exynos_gfx_viewport_info,
|
||||
exynos_gfx_read_viewport,
|
||||
|
@ -771,7 +771,7 @@ static void gl_set_projection(gl_t *gl, struct gl_ortho *ortho, bool allow_rotat
|
||||
matrix_4x4_multiply(&gl->mvp, &rot, &gl->mvp_no_rot);
|
||||
}
|
||||
|
||||
void gl_set_viewport(gl_t *gl, unsigned width,
|
||||
static void gl_set_viewport(void *data, unsigned width,
|
||||
unsigned height, bool force_full, bool allow_rotate)
|
||||
{
|
||||
int x = 0, y = 0;
|
||||
@ -779,6 +779,7 @@ void gl_set_viewport(gl_t *gl, unsigned width,
|
||||
struct gl_ortho ortho = {0, 1, 0, 1, -1, 1};
|
||||
settings_t *settings = config_get_ptr();
|
||||
global_t *global = global_get_ptr();
|
||||
gl_t *gl = (gl_t*)data;
|
||||
|
||||
gfx_ctx_translate_aspect(gl, &device_aspect, width, height);
|
||||
|
||||
@ -3224,6 +3225,7 @@ video_driver_t video_gl = {
|
||||
gl_free,
|
||||
"gl",
|
||||
|
||||
gl_set_viewport,
|
||||
gl_set_rotation,
|
||||
|
||||
gl_viewport_info,
|
||||
|
@ -392,9 +392,6 @@ static INLINE bool gl_check_error(void)
|
||||
return false;
|
||||
}
|
||||
|
||||
void gl_set_viewport(gl_t *gl, unsigned width, unsigned height,
|
||||
bool force_full, bool allow_rotate);
|
||||
|
||||
void gl_load_texture_data(GLuint id,
|
||||
enum gfx_wrap_type wrap_type,
|
||||
enum texture_filter_type filter_type,
|
||||
|
@ -1510,6 +1510,7 @@ video_driver_t video_gx = {
|
||||
gx_set_shader,
|
||||
gx_free,
|
||||
"gx",
|
||||
NULL, /* set_viewport */
|
||||
gx_set_rotation,
|
||||
gx_viewport_info,
|
||||
gx_read_viewport,
|
||||
|
@ -127,6 +127,7 @@ video_driver_t video_null = {
|
||||
null_gfx_set_shader,
|
||||
null_gfx_free,
|
||||
"null",
|
||||
NULL, /* set_viewport */
|
||||
null_gfx_set_rotation,
|
||||
null_gfx_viewport_info,
|
||||
null_gfx_read_viewport,
|
||||
|
@ -1174,7 +1174,7 @@ video_driver_t video_omap = {
|
||||
omap_gfx_set_shader,
|
||||
omap_gfx_free,
|
||||
"omap",
|
||||
|
||||
NULL, /* set_viewport */
|
||||
omap_gfx_set_rotation,
|
||||
omap_gfx_viewport_info,
|
||||
omap_gfx_read_viewport,
|
||||
|
@ -969,7 +969,7 @@ video_driver_t video_psp1 = {
|
||||
psp_set_shader,
|
||||
psp_free,
|
||||
"psp1",
|
||||
|
||||
NULL, /* set_viewport */
|
||||
psp_set_rotation,
|
||||
psp_viewport_info,
|
||||
psp_read_viewport,
|
||||
|
@ -764,6 +764,7 @@ video_driver_t video_sdl2 = {
|
||||
sdl2_gfx_free,
|
||||
"sdl2",
|
||||
|
||||
NULL,
|
||||
sdl2_gfx_set_rotation,
|
||||
sdl2_gfx_viewport_info,
|
||||
sdl2_gfx_read_viewport,
|
||||
|
@ -574,6 +574,7 @@ video_driver_t video_sdl = {
|
||||
sdl_gfx_set_shader,
|
||||
sdl_gfx_free,
|
||||
"sdl",
|
||||
NULL,
|
||||
sdl_gfx_set_rotation,
|
||||
sdl_gfx_viewport_info,
|
||||
sdl_gfx_read_viewport,
|
||||
|
@ -965,6 +965,7 @@ video_driver_t video_sunxi = {
|
||||
sunxi_gfx_set_shader,
|
||||
sunxi_gfx_free,
|
||||
"sunxi",
|
||||
NULL, /* set_viewport */
|
||||
sunxi_gfx_set_rotation,
|
||||
sunxi_gfx_viewport_info,
|
||||
NULL, /* read_viewport */
|
||||
|
@ -491,6 +491,7 @@ video_driver_t video_vg = {
|
||||
vg_set_shader,
|
||||
vg_free,
|
||||
"vg",
|
||||
NULL, /* set_viewport */
|
||||
vg_set_rotation,
|
||||
vg_viewport_info,
|
||||
vg_read_viewport,
|
||||
|
@ -320,6 +320,7 @@ video_driver_t video_xenon360 = {
|
||||
xenon360_gfx_set_shader,
|
||||
xenon360_gfx_free,
|
||||
"xenon360",
|
||||
NULL, /* set_viewport */
|
||||
xenon360_gfx_set_rotation,
|
||||
xenon360_gfx_viewport_info,
|
||||
xenon360_gfx_read_viewport,
|
||||
|
@ -947,6 +947,7 @@ video_driver_t video_xvideo = {
|
||||
xv_set_shader,
|
||||
xv_free,
|
||||
"xvideo",
|
||||
NULL, /* set_viewport */
|
||||
xv_set_rotation,
|
||||
xv_viewport_info,
|
||||
xv_read_viewport,
|
||||
|
@ -263,7 +263,8 @@ static void gl_raster_font_setup_viewport(gl_raster_t *font, bool full_screen)
|
||||
if (!gl)
|
||||
return;
|
||||
|
||||
gl_set_viewport(gl, global->video_data.width, global->video_data.height, full_screen, false);
|
||||
video_driver_set_viewport(global->video_data.width,
|
||||
global->video_data.height, full_screen, false);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
@ -282,7 +283,8 @@ static void gl_raster_font_restore_viewport(gl_t *gl)
|
||||
glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]);
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
gl_set_viewport(gl, global->video_data.width, global->video_data.height, false, true);
|
||||
video_driver_set_viewport(global->video_data.width,
|
||||
global->video_data.height, false, true);
|
||||
}
|
||||
|
||||
static void gl_raster_font_render_msg(void *data, const char *msg,
|
||||
|
@ -613,6 +613,21 @@ void video_driver_set_nonblock_state(bool toggle)
|
||||
video->set_nonblock_state(driver->video_data, toggle);
|
||||
}
|
||||
|
||||
bool video_driver_set_viewport(unsigned width, unsigned height,
|
||||
bool force_fullscreen, bool allow_rotate)
|
||||
{
|
||||
driver_t *driver = driver_get_ptr();
|
||||
const video_driver_t *video = video_driver_ctx_get_ptr();
|
||||
|
||||
if (video->set_viewport)
|
||||
{
|
||||
video->set_viewport(driver->video_data, width, height,
|
||||
force_fullscreen, allow_rotate);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool video_driver_set_rotation(unsigned rotation)
|
||||
{
|
||||
driver_t *driver = driver_get_ptr();
|
||||
|
@ -166,6 +166,9 @@ typedef struct video_driver
|
||||
/* Human-readable identifier. */
|
||||
const char *ident;
|
||||
|
||||
void (*set_viewport)(void *data, unsigned width, unsigned height,
|
||||
bool force_full, bool allow_rotate);
|
||||
|
||||
void (*set_rotation)(void *data, unsigned rotation);
|
||||
void (*viewport_info)(void *data, struct video_viewport *vp);
|
||||
|
||||
@ -333,6 +336,9 @@ bool video_driver_suppress_screensaver(bool enable);
|
||||
|
||||
const char *video_driver_get_ident(void);
|
||||
|
||||
bool video_driver_set_viewport(unsigned width, unsigned height,
|
||||
bool force_fullscreen, bool allow_rotate);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -128,6 +128,16 @@ static void thread_loop(void *data)
|
||||
thread_reply(thr, CMD_FREE);
|
||||
return;
|
||||
|
||||
case CMD_SET_VIEWPORT:
|
||||
if (thr->driver && thr->driver->set_viewport)
|
||||
thr->driver->set_viewport(thr->driver_data,
|
||||
thr->cmd_data.set_viewport.width,
|
||||
thr->cmd_data.set_viewport.height,
|
||||
thr->cmd_data.set_viewport.force_full,
|
||||
thr->cmd_data.set_viewport.allow_rotate);
|
||||
thread_reply(thr, CMD_SET_VIEWPORT);
|
||||
break;
|
||||
|
||||
case CMD_SET_ROTATION:
|
||||
if (thr->driver && thr->driver->set_rotation)
|
||||
thr->driver->set_rotation(thr->driver_data, thr->cmd_data.i);
|
||||
@ -607,6 +617,23 @@ static bool thread_set_shader(void *data,
|
||||
return thr->cmd_data.b;
|
||||
}
|
||||
|
||||
static void thread_set_viewport(void *data, unsigned width,
|
||||
unsigned height, bool force_full, bool allow_rotate)
|
||||
{
|
||||
thread_video_t *thr = (thread_video_t*)data;
|
||||
|
||||
if (!thr)
|
||||
return;
|
||||
|
||||
thr->cmd_data.set_viewport.width = width;
|
||||
thr->cmd_data.set_viewport.height = height;
|
||||
thr->cmd_data.set_viewport.force_full = force_full;
|
||||
thr->cmd_data.set_viewport.allow_rotate = allow_rotate;
|
||||
|
||||
thread_send_cmd(thr, CMD_SET_VIEWPORT);
|
||||
thread_wait_reply(thr, CMD_SET_VIEWPORT);
|
||||
}
|
||||
|
||||
static void thread_set_rotation(void *data, unsigned rotation)
|
||||
{
|
||||
thread_video_t *thr = (thread_video_t*)data;
|
||||
@ -979,6 +1006,7 @@ static const video_driver_t video_thread = {
|
||||
thread_set_shader,
|
||||
thread_free,
|
||||
"Thread wrapper",
|
||||
thread_set_viewport,
|
||||
thread_set_rotation,
|
||||
thread_viewport_info,
|
||||
thread_read_viewport,
|
||||
@ -997,6 +1025,8 @@ static void thread_set_callbacks(thread_video_t *thr,
|
||||
/* Disable optional features if not present. */
|
||||
if (!drv->read_viewport)
|
||||
thr->video_thread.read_viewport = NULL;
|
||||
if (!drv->set_viewport)
|
||||
thr->video_thread.set_viewport = NULL;
|
||||
if (!drv->set_rotation)
|
||||
thr->video_thread.set_rotation = NULL;
|
||||
if (!drv->set_shader)
|
||||
|
@ -30,6 +30,7 @@ enum thread_cmd
|
||||
CMD_SET_SHADER,
|
||||
CMD_FREE,
|
||||
CMD_ALIVE, /* Blocking alive check. Used when paused. */
|
||||
CMD_SET_VIEWPORT,
|
||||
CMD_SET_ROTATION,
|
||||
CMD_READ_VIEWPORT,
|
||||
|
||||
@ -126,6 +127,14 @@ typedef struct thread_video
|
||||
const char *path;
|
||||
} set_shader;
|
||||
|
||||
struct
|
||||
{
|
||||
unsigned width;
|
||||
unsigned height;
|
||||
bool force_full;
|
||||
bool allow_rotate;
|
||||
} set_viewport;
|
||||
|
||||
struct
|
||||
{
|
||||
unsigned index;
|
||||
|
@ -164,63 +164,15 @@ bool menu_display_font_flush_block(menu_handle_t *menu,
|
||||
void menu_display_set_viewport(menu_handle_t *menu)
|
||||
{
|
||||
global_t *global = global_get_ptr();
|
||||
driver_t *driver = driver_get_ptr();
|
||||
const char *ident = video_driver_get_ident();
|
||||
|
||||
#ifdef HAVE_OPENGL
|
||||
if (!strcmp(ident, "gl"))
|
||||
{
|
||||
gl_set_viewport(driver->video_data,
|
||||
global->video_data.width,
|
||||
global->video_data.height, true, false);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_D3D
|
||||
if (!strcmp(ident, "d3d"))
|
||||
{
|
||||
D3DVIEWPORT vp_full;
|
||||
LPDIRECT3DDEVICE d3dr;
|
||||
d3d_video_t *d3d = (d3d_video_t*)driver->video_data;
|
||||
|
||||
vp_full.X = 0;
|
||||
vp_full.Y = 0;
|
||||
vp_full.Width = global->video_data.width;
|
||||
vp_full.Height = global->video_data.height;
|
||||
vp_full.MinZ = 0.0f;
|
||||
vp_full.MaxZ = 1.0f;
|
||||
|
||||
d3dr = (LPDIRECT3DDEVICE)d3d->dev;
|
||||
|
||||
d3d_set_viewport(d3dr, &vp_full);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
video_driver_set_viewport(global->video_data.width,
|
||||
global->video_data.height, true, false);
|
||||
}
|
||||
|
||||
void menu_display_unset_viewport(menu_handle_t *menu)
|
||||
{
|
||||
driver_t *driver = driver_get_ptr();
|
||||
global_t *global = global_get_ptr();
|
||||
const char *ident = video_driver_get_ident();
|
||||
|
||||
#ifdef HAVE_OPENGL
|
||||
if (!strcmp(ident, "gl"))
|
||||
{
|
||||
gl_set_viewport(driver->video_data,
|
||||
global->video_data.width,
|
||||
global->video_data.height,
|
||||
false, true);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_D3D
|
||||
if (!strcmp(ident, "d3d"))
|
||||
{
|
||||
d3d_video_t *d3d = (d3d_video_t*)driver->video_data;
|
||||
LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev;
|
||||
d3d_set_viewport(d3dr, &d3d->final_viewport);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
video_driver_set_viewport(global->video_data.width,
|
||||
global->video_data.height, false, true);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user