Skip to content

Commit

Permalink
Implement set_video_mode in video poke interface
Browse files Browse the repository at this point in the history
  • Loading branch information
inactive123 committed Feb 24, 2015
1 parent 8813752 commit f80e374
Show file tree
Hide file tree
Showing 13 changed files with 74 additions and 29 deletions.
1 change: 1 addition & 0 deletions gfx/d3d/d3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1917,6 +1917,7 @@ static void d3d_set_menu_texture_enable(void *data,
#endif

static const video_poke_interface_t d3d_poke_interface = {
NULL,
NULL,
NULL, /* get_video_output_size */
NULL, /* get_video_output_prev */
Expand Down
1 change: 1 addition & 0 deletions gfx/drivers/exynos_gfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1613,6 +1613,7 @@ static void exynos_show_mouse(void *data, bool state)
}

static const video_poke_interface_t exynos_poke_interface = {
NULL, /* set_video_mode */
NULL, /* set_filtering */
NULL, /* get_video_output_size */
NULL, /* get_video_output_prev */
Expand Down
10 changes: 10 additions & 0 deletions gfx/drivers/gl.c
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,15 @@ static void gl_set_rotation(void *data, unsigned rotation)
gl_set_projection(gl, &ortho, true);
}

static void gl_set_video_mode(void *data, unsigned width, unsigned height,
bool fullscreen)
{
gl_t *gl = (gl_t*)data;

if (gl && gl->ctx_driver && gl->ctx_driver->set_video_mode)
gl->ctx_driver->set_video_mode(gl, width, height, fullscreen);
}

#ifdef HAVE_FBO
static inline void gl_start_frame_fbo(gl_t *gl)
{
Expand Down Expand Up @@ -3114,6 +3123,7 @@ static void gl_get_video_output_next(void *data)


static const video_poke_interface_t gl_poke_interface = {
gl_set_video_mode,
NULL,
gl_get_video_output_size,
gl_get_video_output_prev,
Expand Down
12 changes: 8 additions & 4 deletions gfx/drivers/gx_gfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ enum
GX_RESOLUTIONS_LAST,
};

static unsigned menu_current_gx_resolution = GX_RESOLUTIONS_640_480;

unsigned menu_gx_resolutions[GX_RESOLUTIONS_LAST][2] = {
{ 512, 192 },
{ 598, 200 },
Expand Down Expand Up @@ -200,7 +202,8 @@ static void gx_free_overlay(gx_video_t *gx)
}
#endif

void gx_set_video_mode(void *data, unsigned fbWidth, unsigned lines)
static void gx_set_video_mode(void *data, unsigned fbWidth, unsigned lines,
bool fullscreen)
{
unsigned modetype, level, viHeightMultiplier, viWidth, tvmode,
max_width, max_height, i;
Expand Down Expand Up @@ -433,7 +436,7 @@ static void setup_video_mode(void *data)
OSInitThreadQueue(&g_video_cond);

VIDEO_GetPreferredMode(&gx_mode);
gx_set_video_mode(data, 0, 0);
gx_set_video_mode(data, 0, 0, true);
}

static void init_texture(void *data, unsigned width, unsigned height)
Expand Down Expand Up @@ -1241,13 +1244,13 @@ static void gx_get_video_output_size(void *data, unsigned *width, unsigned *heig
*height = menu_gx_resolutions[menu_current_gx_resolution][1];
}

static void gx_video_output_get_prev(void *data)
static void gx_get_video_output_prev(void *data)
{
if (menu_current_gx_resolution > 0)
menu_current_gx_resolution--;
}

static void gx_video_output_get_next(void *data)
static void gx_get_video_output_next(void *data)
{
if (menu_current_gx_resolution < GX_RESOLUTIONS_LAST - 1)
{
Expand All @@ -1262,6 +1265,7 @@ static void gx_video_output_get_next(void *data)
}

static const video_poke_interface_t gx_poke_interface = {
gx_set_video_mode,
NULL,
gx_get_video_output_size,
gx_get_video_output_prev,
Expand Down
3 changes: 0 additions & 3 deletions gfx/drivers/gx_gfx.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,5 @@ typedef struct gx_video
#endif
} gx_video_t;

void gx_set_video_mode(void *data, unsigned fbWidth, unsigned lines);
const char *gx_get_video_mode(void);

#endif

1 change: 1 addition & 0 deletions gfx/drivers/psp1_gfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,7 @@ static void psp_viewport_info(void *data, struct video_viewport *vp)
}

static const video_poke_interface_t psp_poke_interface = {
NULL,
psp_set_filtering,
NULL, /* get_video_output_size */
NULL, /* get_video_output_prev */
Expand Down
1 change: 1 addition & 0 deletions gfx/drivers/sdl2_gfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,7 @@ void sdl2_grab_mouse_toggle(void *data)
}

static video_poke_interface_t sdl2_video_poke_interface = {
NULL,
sdl2_poke_set_filtering,
NULL, /* get_video_output_size */
NULL, /* get_video_output_prev */
Expand Down
1 change: 1 addition & 0 deletions gfx/drivers/sdl_gfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,7 @@ static void sdl_grab_mouse_toggle(void *data)
}

static const video_poke_interface_t sdl_poke_interface = {
NULL,
sdl_set_filtering,
NULL, /* get_video_output_size */
NULL, /* get_video_output_prev */
Expand Down
15 changes: 15 additions & 0 deletions gfx/drivers_context/ps3_ctx.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,21 @@ static bool gfx_ctx_ps3_set_video_mode(void *data,
bool fullscreen)
{
(void)data;

if (g_extern.console.screen.resolutions.list[
g_extern.console.screen.resolutions.current.idx] ==
CELL_VIDEO_OUT_RESOLUTION_576)
{
if (g_extern.console.screen.pal_enable)
g_extern.console.screen.pal60_enable = true;
}
else
{
g_extern.console.screen.pal_enable = false;
g_extern.console.screen.pal60_enable = false;
}

rarch_main_command(RARCH_CMD_REINIT);
return true;
}

Expand Down
1 change: 1 addition & 0 deletions gfx/video_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ enum texture_filter_type

typedef struct video_poke_interface
{
void (*set_video_mode)(void *data, unsigned width, unsigned height, bool fullscreen);
void (*set_filtering)(void *data, unsigned index, bool smooth);
void (*get_video_output_size)(void *data, unsigned *width, unsigned *height);
void (*get_video_output_prev)(void *data);
Expand Down
23 changes: 23 additions & 0 deletions gfx/video_thread_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,14 @@ static void thread_loop(void *data)
break;
#endif

case CMD_POKE_SET_VIDEO_MODE:
if (thr->poke && thr->poke->set_video_mode)
thr->poke->set_video_mode(thr->driver_data,
thr->cmd_data.new_mode.width,
thr->cmd_data.new_mode.height,
thr->cmd_data.new_mode.fullscreen);
thread_reply(thr, CMD_POKE_SET_VIDEO_MODE);
break;
case CMD_POKE_SET_FILTERING:
if (thr->poke && thr->poke->set_filtering)
thr->poke->set_filtering(thr->driver_data,
Expand Down Expand Up @@ -767,6 +775,20 @@ static void thread_get_overlay_interface(void *data,
}
#endif

static void thread_set_video_mode(void *data, unsigned width, unsigned height,
bool fullscreen)
{
thread_video_t *thr = (thread_video_t*)data;

if (!thr)
return;
thr->cmd_data.new_mode.width = width;
thr->cmd_data.new_mode.height = height;
thr->cmd_data.new_mode.fullscreen = fullscreen;
thread_send_cmd(thr, CMD_POKE_SET_VIDEO_MODE);
thread_wait_reply(thr, CMD_POKE_SET_VIDEO_MODE);
}

static void thread_set_filtering(void *data, unsigned idx, bool smooth)
{
thread_video_t *thr = (thread_video_t*)data;
Expand Down Expand Up @@ -904,6 +926,7 @@ static struct video_shader *thread_get_current_shader(void *data)
}

static const video_poke_interface_t thread_poke = {
thread_set_video_mode,
thread_set_filtering,
thread_get_video_output_size,
thread_get_video_output_prev,
Expand Down
8 changes: 8 additions & 0 deletions gfx/video_thread_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ enum thread_cmd
CMD_OVERLAY_FULL_SCREEN,
#endif

CMD_POKE_SET_VIDEO_MODE,
CMD_POKE_SET_FILTERING,
CMD_POKE_GET_VIDEO_OUTPUT_SIZE,
CMD_POKE_GET_VIDEO_OUTPUT_PREV,
Expand Down Expand Up @@ -143,6 +144,13 @@ typedef struct thread_video
unsigned height;
} output;

struct
{
unsigned width;
unsigned height;
bool fullscreen;
} new_mode;

struct
{
unsigned index;
Expand Down
26 changes: 4 additions & 22 deletions menu/menu_entries_cbs.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@

#include "../gfx/video_viewport.h"

#ifdef GEKKO
unsigned menu_current_gx_resolution = GX_RESOLUTIONS_640_480;
#endif

static unsigned rdb_entry_start_game_selection_ptr;

static int archive_open(void)
Expand Down Expand Up @@ -2376,32 +2372,18 @@ static int action_toggle_shader_num_passes(unsigned type, const char *label,
static int action_ok_video_resolution(const char *path,
const char *label, unsigned type, size_t idx)
{
#ifdef GEKKO
if (driver.video_data && driver.video_poke &&
driver.video_poke->get_video_output_size)
{
unsigned width = 0, height = 0;
driver.video_poke->get_video_output_size(driver.video_data,
&width, &height);

gx_set_video_mode(driver.video_data, width, height);
}
#elif defined(__CELLOS_LV2__)
if (g_extern.console.screen.resolutions.list[
g_extern.console.screen.resolutions.current.idx] ==
CELL_VIDEO_OUT_RESOLUTION_576)
{
if (g_extern.console.screen.pal_enable)
g_extern.console.screen.pal60_enable = true;
}
else
{
g_extern.console.screen.pal_enable = false;
g_extern.console.screen.pal60_enable = false;
if (driver.video_data && driver.video_poke &&
driver.video_poke->set_video_mode)
driver.video_poke->set_video_mode(driver.video_data,
width, height, true);
}

rarch_main_command(RARCH_CMD_REINIT);
#endif
return 0;
}

Expand Down

0 comments on commit f80e374

Please sign in to comment.