(D3D) Cleanups

This commit is contained in:
twinaphex 2015-11-10 00:13:17 +01:00
parent 9bb564e7cc
commit c5b5d3c186

View File

@ -416,46 +416,58 @@ static void d3d_calculate_rect(d3d_video_t *d3d,
unsigned width, unsigned height, unsigned width, unsigned height,
bool keep, float desired_aspect) bool keep, float desired_aspect)
{ {
int x = 0;
int y = 0;
unsigned new_width = width;
unsigned new_height = height;
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
if (settings->video.scale_integer) if (settings->video.scale_integer)
{ {
struct video_viewport vp = {0}; struct video_viewport vp = {0};
video_viewport_get_scaled_integer(&vp, width, height, desired_aspect, keep); video_viewport_get_scaled_integer(&vp, width, height, desired_aspect, keep);
d3d_set_viewport(d3d, vp.x, vp.y, vp.width, vp.height); x = vp.x;
y = vp.y;
new_width = vp.width;
new_height = vp.height;
} }
else if (!keep) else if (keep)
d3d_set_viewport(d3d, 0, 0, width, height);
else
{ {
if (settings->video.aspect_ratio_idx == ASPECT_RATIO_CUSTOM) if (settings->video.aspect_ratio_idx == ASPECT_RATIO_CUSTOM)
{ {
video_viewport_t *custom = video_viewport_get_custom(); video_viewport_t *custom = video_viewport_get_custom();
if (custom) if (custom)
d3d_set_viewport(d3d, custom->x, custom->y, {
custom->width, custom->height); x = custom->x;
y = custom->y;
new_width = custom->width;
new_height = custom->height;
}
} }
else else
{ {
float device_aspect = ((float)width) / ((float)height); float device_aspect = ((float)width) / ((float)height);
if (fabsf(device_aspect - desired_aspect) < 0.0001f) if (fabsf(device_aspect - desired_aspect) < 0.0001f) { }
d3d_set_viewport(d3d, 0, 0, width, height);
else if (device_aspect > desired_aspect) else if (device_aspect > desired_aspect)
{ {
float delta = (desired_aspect / device_aspect - 1.0f) / 2.0f + 0.5f; float delta = (desired_aspect / device_aspect - 1.0f) / 2.0f + 0.5f;
d3d_set_viewport(d3d, int(roundf(width * (0.5f - delta))), x = int(roundf(width * (0.5f - delta)));
0, unsigned(roundf(2.0f * width * delta)), height); y = 0;
new_width = unsigned(roundf(2.0f * width * delta));
} }
else else
{ {
float delta = (device_aspect / desired_aspect - 1.0f) / 2.0f + 0.5f; float delta = (device_aspect / desired_aspect - 1.0f) / 2.0f + 0.5f;
d3d_set_viewport(d3d, 0, int(roundf(height * (0.5f - delta))), x = 0;
width, unsigned(roundf(2.0f * height * delta))); y = int(roundf(height * (0.5f - delta)));
new_height = unsigned(roundf(2.0f * height * delta));
} }
} }
} }
d3d_set_viewport(d3d, x, y, new_width, new_height);
} }
static void d3d_set_nonblock_state(void *data, bool state) static void d3d_set_nonblock_state(void *data, bool state)
@ -743,8 +755,13 @@ static void d3d_viewport_info(void *data, struct video_viewport *vp)
static void d3d_set_rotation(void *data, unsigned rot) static void d3d_set_rotation(void *data, unsigned rot)
{ {
d3d_video_t *d3d = (d3d_video_t*)data; d3d_video_t *d3d = (d3d_video_t*)data;
if (d3d) struct gfx_ortho ortho = {0, 1, 0, 1, -1, 1};
d3d->dev_rotation = rot;
if (!d3d)
return;
d3d->dev_rotation = rot;
//d3d_set_projection(d3d, &ortho, true);
} }
static void d3d_show_mouse(void *data, bool state) static void d3d_show_mouse(void *data, bool state)