Merge pull request #2108 from frangarcj/master

(Vita) Add Rotation
This commit is contained in:
Twinaphex 2015-09-11 18:20:08 +02:00
commit e579e82692

View File

@ -185,10 +185,12 @@ static bool vita2d_gfx_frame(void *data, const void *frame,
PSP_FB_HEIGHT / (float)vita->height); PSP_FB_HEIGHT / (float)vita->height);
else else
{ {
const float radian = 90 * 0.0174532925f;
const float rad = vita->rotation * radian;
float scalex = vita->vp.width / (float)vita->width; float scalex = vita->vp.width / (float)vita->width;
float scaley = vita->vp.height / (float)vita->height; float scaley = vita->vp.height / (float)vita->height;
vita2d_draw_texture_scale(vita->texture, vita->vp.x, vita2d_draw_texture_scale_rotate(vita->texture, vita->vp.x,
vita->vp.y, scalex, scaley); vita->vp.y, scalex, scaley, rad);
} }
} }
@ -315,7 +317,12 @@ static void vita2d_gfx_update_viewport(vita_video_t* vita)
{ {
float delta; float delta;
float desired_aspect = video_driver_get_aspect_ratio(); float desired_aspect = video_driver_get_aspect_ratio();
if (vita->rotation == ORIENTATION_VERTICAL ||
vita->rotation == ORIENTATION_FLIPPED_ROTATED){
device_aspect = 1.0 / device_aspect;
width = PSP_FB_HEIGHT;
height = PSP_FB_WIDTH;
}
#if defined(HAVE_MENU) #if defined(HAVE_MENU)
if (settings->video.aspect_ratio_idx == ASPECT_RATIO_CUSTOM) if (settings->video.aspect_ratio_idx == ASPECT_RATIO_CUSTOM)
{ {
@ -332,8 +339,7 @@ static void vita2d_gfx_update_viewport(vita_video_t* vita)
else else
#endif #endif
{ {
if ((fabsf(device_aspect - desired_aspect) < 0.0001f) if ((fabsf(device_aspect - desired_aspect) < 0.0001f))
|| (fabsf((16.0/9.0) - desired_aspect) < 0.02f))
{ {
/* If the aspect ratios of screen and desired aspect /* If the aspect ratios of screen and desired aspect
* ratio are sufficiently equal (floating point stuff), * ratio are sufficiently equal (floating point stuff),
@ -354,6 +360,12 @@ static void vita2d_gfx_update_viewport(vita_video_t* vita)
y = (int)roundf(height * (0.5f - delta)); y = (int)roundf(height * (0.5f - delta));
height = (unsigned)roundf(2.0f * height * delta); height = (unsigned)roundf(2.0f * height * delta);
} }
if (vita->rotation == ORIENTATION_VERTICAL ||
vita->rotation == ORIENTATION_FLIPPED_ROTATED){
x = (PSP_FB_WIDTH - width) * 0.5f;
y = (PSP_FB_HEIGHT - height) * 0.5f;
}
} }
vita->vp.x = x; vita->vp.x = x;
@ -378,8 +390,13 @@ static void vita2d_gfx_update_viewport(vita_video_t* vita)
static void vita2d_gfx_set_rotation(void *data, static void vita2d_gfx_set_rotation(void *data,
unsigned rotation) unsigned rotation)
{ {
(void)data; vita_video_t *vita = (vita_video_t*)data;
(void)rotation;
if (!vita)
return;
vita->rotation = rotation;
vita->should_resize = true;
} }
static void vita2d_gfx_viewport_info(void *data, static void vita2d_gfx_viewport_info(void *data,