mirror of
https://github.com/libretro/RetroArch
synced 2025-01-31 06:32:48 +00:00
Create d3d_calculate_rect
This commit is contained in:
parent
7bcf33bff3
commit
eb5db8ca60
@ -283,31 +283,27 @@ static bool d3d_init_base(void *data, const video_info_t *info)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void d3d_set_viewport(void *data,
|
static bool d3d_calculate_rect(void *data,
|
||||||
unsigned width, unsigned height,
|
unsigned *width, unsigned *height,
|
||||||
|
int *x, int *y,
|
||||||
bool force_full,
|
bool force_full,
|
||||||
bool allow_rotate)
|
bool allow_rotate)
|
||||||
{
|
{
|
||||||
D3DVIEWPORT viewport;
|
float device_aspect = (float)*width / *height;
|
||||||
d3d_video_t *d3d = (d3d_video_t*)data;
|
|
||||||
int x = 0;
|
|
||||||
int y = 0;
|
|
||||||
float device_aspect = (float)width / height;
|
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
float desired_aspect = video_driver_get_aspect_ratio();
|
float desired_aspect = video_driver_get_aspect_ratio();
|
||||||
|
|
||||||
video_driver_get_size(&width, &height);
|
video_driver_get_size(width, height);
|
||||||
|
gfx_ctx_translate_aspect(&device_aspect, *width, *height);
|
||||||
gfx_ctx_translate_aspect(&device_aspect, width, height);
|
|
||||||
|
|
||||||
if (settings->video.scale_integer && !force_full)
|
if (settings->video.scale_integer && !force_full)
|
||||||
{
|
{
|
||||||
struct video_viewport vp = {0};
|
struct video_viewport vp = {0};
|
||||||
video_viewport_get_scaled_integer(&vp, width, height, desired_aspect, d3d->keep_aspect);
|
video_viewport_get_scaled_integer(&vp, *width, *height, desired_aspect, d3d->keep_aspect);
|
||||||
x = vp.x;
|
*x = vp.x;
|
||||||
y = vp.y;
|
*y = vp.y;
|
||||||
width = vp.width;
|
*width = vp.width;
|
||||||
height = vp.height;
|
*height = vp.height;
|
||||||
}
|
}
|
||||||
else if (d3d->keep_aspect && !force_full)
|
else if (d3d->keep_aspect && !force_full)
|
||||||
{
|
{
|
||||||
@ -317,10 +313,10 @@ static void d3d_set_viewport(void *data,
|
|||||||
|
|
||||||
if (custom)
|
if (custom)
|
||||||
{
|
{
|
||||||
x = custom->x;
|
*x = custom->x;
|
||||||
y = custom->y;
|
*y = custom->y;
|
||||||
width = custom->width;
|
*width = custom->width;
|
||||||
height = custom->height;
|
*height = custom->height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -331,20 +327,33 @@ static void d3d_set_viewport(void *data,
|
|||||||
else if (device_aspect > desired_aspect)
|
else if (device_aspect > desired_aspect)
|
||||||
{
|
{
|
||||||
delta = (desired_aspect / device_aspect - 1.0f) / 2.0f + 0.5f;
|
delta = (desired_aspect / device_aspect - 1.0f) / 2.0f + 0.5f;
|
||||||
x = int(roundf(width * (0.5f - delta)));
|
*x = int(roundf(*width * (0.5f - delta)));
|
||||||
y = 0;
|
*y = 0;
|
||||||
width = unsigned(roundf(2.0f * width * delta));
|
*width = unsigned(roundf(2.0f * (*width) * delta));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
delta = (device_aspect / desired_aspect - 1.0f) / 2.0f + 0.5f;
|
delta = (device_aspect / desired_aspect - 1.0f) / 2.0f + 0.5f;
|
||||||
x = 0;
|
*x = 0;
|
||||||
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void d3d_set_viewport(void *data,
|
||||||
|
unsigned width, unsigned height,
|
||||||
|
bool force_full,
|
||||||
|
bool allow_rotate)
|
||||||
|
{
|
||||||
|
D3DVIEWPORT viewport;
|
||||||
|
int x = 0;
|
||||||
|
int y = 0;
|
||||||
|
d3d_video_t *d3d = (d3d_video_t*)data;
|
||||||
|
|
||||||
|
d3d_calculate_rect(data, &width, &height, &x, &y,
|
||||||
|
force_full, allow_rotate);
|
||||||
|
|
||||||
/* D3D doesn't support negative X/Y viewports ... */
|
/* D3D doesn't support negative X/Y viewports ... */
|
||||||
if (x < 0)
|
if (x < 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user