[client] fixed strange resize effect due to loss of precision

This commit is contained in:
Geoffrey McRae 2020-01-03 17:23:48 +11:00
parent 49bf115c84
commit 127113a59b
2 changed files with 18 additions and 7 deletions

View File

@ -1 +1 @@
B1-49-g2196516e2b+1 B1-50-g49bf115c84+1

View File

@ -75,6 +75,17 @@ static void updatePositionInfo()
{ {
const float srcAspect = (float)state.srcSize.y / (float)state.srcSize.x; const float srcAspect = (float)state.srcSize.y / (float)state.srcSize.x;
const float wndAspect = (float)state.windowH / (float)state.windowW; const float wndAspect = (float)state.windowH / (float)state.windowW;
bool force = true;
if ((int)(wndAspect * 1000) == (int)(srcAspect * 1000))
{
force = false;
state.dstRect.w = state.windowW;
state.dstRect.h = state.windowH;
state.dstRect.x = 0;
state.dstRect.y = 0;
}
else
if (wndAspect < srcAspect) if (wndAspect < srcAspect)
{ {
state.dstRect.w = (float)state.windowH / srcAspect; state.dstRect.w = (float)state.windowH / srcAspect;
@ -89,6 +100,12 @@ static void updatePositionInfo()
state.dstRect.x = 0; state.dstRect.x = 0;
state.dstRect.y = (state.windowH >> 1) - (state.dstRect.h >> 1); state.dstRect.y = (state.windowH >> 1) - (state.dstRect.h >> 1);
} }
if (force && params.forceAspect)
{
state.resizeTimeout = getMicrotime() + RESIZE_TIMEOUT;
state.resizeDone = false;
}
} }
else else
{ {
@ -101,12 +118,6 @@ static void updatePositionInfo()
state.scaleX = (float)state.srcSize.y / (float)state.dstRect.h; state.scaleX = (float)state.srcSize.y / (float)state.dstRect.h;
state.scaleY = (float)state.srcSize.x / (float)state.dstRect.w; state.scaleY = (float)state.srcSize.x / (float)state.dstRect.w;
if (params.forceAspect)
{
state.resizeTimeout = getMicrotime() + RESIZE_TIMEOUT;
state.resizeDone = false;
}
} }
state.lgrResize = true; state.lgrResize = true;