From 6c5d250ff1b50c3ba9eeae249883a08bba712faa Mon Sep 17 00:00:00 2001 From: Sergi Granell Date: Mon, 31 Aug 2015 19:37:02 +0200 Subject: [PATCH 1/3] (Vita) Prepare code for fullscreen --- gfx/drivers/vita2d_gfx.c | 65 ++++++++++++++++++++++++++++++++-------- 1 file changed, 53 insertions(+), 12 deletions(-) diff --git a/gfx/drivers/vita2d_gfx.c b/gfx/drivers/vita2d_gfx.c index 549334ddd3..bcbe00488e 100644 --- a/gfx/drivers/vita2d_gfx.c +++ b/gfx/drivers/vita2d_gfx.c @@ -40,6 +40,7 @@ typedef struct vita_video int width; int height; + bool fullscreen; bool vsync; bool rgb32; @@ -77,8 +78,9 @@ static void *vita2d_gfx_init(const video_info_t *video, else vita->format = SCE_GXM_TEXTURE_FORMAT_R5G6B5; - vita->texture = NULL; + vita->fullscreen = video->fullscreen; + vita->texture = NULL; vita->menu.frame = NULL; vita->menu.active = 0; vita->menu.width = 0; @@ -149,16 +151,56 @@ static bool vita2d_gfx_frame(void *data, const void *frame, vita2d_clear_screen(); if (frame && vita->texture) - vita2d_draw_texture_scale(vita->texture, - SCREEN_W/2 - (vita->width/2)*2, - SCREEN_H/2 - (vita->height/2)*2, - 2.0f, 2.0f); + { + if (vita->fullscreen) + vita2d_draw_texture_scale(vita->texture, + 0, 0, + SCREEN_W/(float)vita->width, + SCREEN_H/(float)vita->height); + else + if (vita->width > vita->height) + { + float scale = SCREEN_H/(float)vita->height; + float w = vita->width * scale; + vita2d_draw_texture_scale(vita->texture, + SCREEN_W/2.0f - w/2.0f, 0.0f, + scale, scale); + } + else + { + float scale = SCREEN_W/(float)vita->width; + float h = vita->height * scale; + vita2d_draw_texture_scale(vita->texture, + 0.0f, SCREEN_H/2.0f - h/2.0f, + scale, scale); + } + } if (vita->menu.active && vita->menu.frame) - vita2d_draw_texture_scale(vita->menu.frame, - SCREEN_W/2 - (vita->menu.width/2)*2, - SCREEN_H/2 - (vita->menu.height/2)*2, - 2.0f, 2.0f); + { + if (vita->fullscreen) + vita2d_draw_texture_scale(vita->menu.frame, + 0, 0, + SCREEN_W/(float)vita->menu.width, + SCREEN_H/(float)vita->menu.height); + else + if (vita->menu.width > vita->menu.height) + { + float scale = SCREEN_H/(float)vita->menu.height; + float w = vita->menu.width * scale; + vita2d_draw_texture_scale(vita->menu.frame, + SCREEN_W/2.0f - w/2.0f, 0.0f, + scale, scale); + } + else + { + float scale = SCREEN_W/(float)vita->menu.width; + float h = vita->menu.height * scale; + vita2d_draw_texture_scale(vita->menu.frame, + 0.0f, SCREEN_H/2.0f - h/2.0f, + scale, scale); + } + } vita2d_end_drawing(); vita2d_swap_buffers(); @@ -336,11 +378,10 @@ static void vita_set_texture_frame(void *data, const void *frame, bool rgb32, static void vita_set_texture_enable(void *data, bool state, bool full_screen) { - vita_video_t *vid = (vita_video_t*)data; - + vita_video_t *vita = (vita_video_t*)data; (void)full_screen; - vid->menu.active = state; + vita->menu.active = state; } static const video_poke_interface_t vita_poke_interface = { From 56af52a268ed0de78c969273a328bac1f738dc32 Mon Sep 17 00:00:00 2001 From: Sergi Granell Date: Mon, 31 Aug 2015 21:37:50 +0200 Subject: [PATCH 2/3] (Vita) Fix spaces --- gfx/drivers/vita2d_gfx.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/gfx/drivers/vita2d_gfx.c b/gfx/drivers/vita2d_gfx.c index bcbe00488e..b4ad4b6952 100644 --- a/gfx/drivers/vita2d_gfx.c +++ b/gfx/drivers/vita2d_gfx.c @@ -160,16 +160,16 @@ static bool vita2d_gfx_frame(void *data, const void *frame, else if (vita->width > vita->height) { - float scale = SCREEN_H/(float)vita->height; - float w = vita->width * scale; + float scale = SCREEN_H/(float)vita->height; + float w = vita->width * scale; vita2d_draw_texture_scale(vita->texture, SCREEN_W/2.0f - w/2.0f, 0.0f, scale, scale); } else { - float scale = SCREEN_W/(float)vita->width; - float h = vita->height * scale; + float scale = SCREEN_W/(float)vita->width; + float h = vita->height * scale; vita2d_draw_texture_scale(vita->texture, 0.0f, SCREEN_H/2.0f - h/2.0f, scale, scale); @@ -186,16 +186,16 @@ static bool vita2d_gfx_frame(void *data, const void *frame, else if (vita->menu.width > vita->menu.height) { - float scale = SCREEN_H/(float)vita->menu.height; - float w = vita->menu.width * scale; + float scale = SCREEN_H/(float)vita->menu.height; + float w = vita->menu.width * scale; vita2d_draw_texture_scale(vita->menu.frame, SCREEN_W/2.0f - w/2.0f, 0.0f, scale, scale); } else { - float scale = SCREEN_W/(float)vita->menu.width; - float h = vita->menu.height * scale; + float scale = SCREEN_W/(float)vita->menu.width; + float h = vita->menu.height * scale; vita2d_draw_texture_scale(vita->menu.frame, 0.0f, SCREEN_H/2.0f - h/2.0f, scale, scale); From dbb91c85e6a7bdedfe0120d9284347e8bf591914 Mon Sep 17 00:00:00 2001 From: Sergi Granell Date: Mon, 31 Aug 2015 21:41:45 +0200 Subject: [PATCH 3/3] (Vita) Check vita->texture before freeing it --- gfx/drivers/vita2d_gfx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gfx/drivers/vita2d_gfx.c b/gfx/drivers/vita2d_gfx.c index b4ad4b6952..c6f358a254 100644 --- a/gfx/drivers/vita2d_gfx.c +++ b/gfx/drivers/vita2d_gfx.c @@ -251,7 +251,8 @@ static void vita2d_gfx_free(void *data) if (vita->menu.frame) vita2d_free_texture(vita->menu.frame); - vita2d_free_texture(vita->texture); + if (vita->texture) + vita2d_free_texture(vita->texture); vita2d_fini(); }