mirror of
https://github.com/moonlight-stream/moonlight-qt
synced 2024-12-17 14:43:09 +00:00
Make scaleSourceToDestinationSurface() idempotent
Deviation between scaling done during window sizing and renderer viewport configuration can lead to small errors that create visible artifacts such as a single pixel pillarbox/letterbox on one side.
This commit is contained in:
parent
a860bd8dd5
commit
6771877a84
1 changed files with 2 additions and 4 deletions
|
@ -17,18 +17,16 @@ Uint32 StreamUtils::getPlatformWindowFlags()
|
|||
|
||||
void StreamUtils::scaleSourceToDestinationSurface(SDL_Rect* src, SDL_Rect* dst)
|
||||
{
|
||||
int dstH = dst->w * src->h / src->w;
|
||||
int dstW = dst->h * src->w / src->h;
|
||||
int dstH = SDL_ceilf((float)dst->w * src->h / src->w);
|
||||
int dstW = SDL_ceilf((float)dst->h * src->w / src->h);
|
||||
|
||||
if (dstH > dst->h) {
|
||||
dst->x += (dst->w - dstW) / 2;
|
||||
dst->w = dstW;
|
||||
SDL_assert(dst->w * src->h / src->w <= dst->h);
|
||||
}
|
||||
else {
|
||||
dst->y += (dst->h - dstH) / 2;
|
||||
dst->h = dstH;
|
||||
SDL_assert(dst->h * src->w / src->h <= dst->w);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue