fractional scaling: another round(!) of rounding fixes

* Ensure buffer sizes are valid. That is, ensure that
  size / scale * scale == size.
* Do size calculation of the window geometry in the same way we
  calculate the CSD offsets.
This commit is contained in:
Daniel Eklöf 2023-07-28 15:28:10 +02:00
parent 753c4b5d4f
commit 1782474481
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
2 changed files with 73 additions and 66 deletions

View file

@ -2010,11 +2010,12 @@ wayl_surface_scale_explicit_width_height(
LOG_DBG("scaling by a factor of %.2f using fractional scaling "
"(width=%d, height=%d) ", scale, width, height);
xassert((int)roundf(scale * (int)roundf(width / scale)) == width);
xassert((int)roundf(scale * (int)roundf(height / scale)) == height);
wl_surface_set_buffer_scale(surf->surf, 1);
wp_viewport_set_destination(
surf->viewport,
(int32_t)roundf((float)width / scale),
(int32_t)roundf((float)height / scale));
surf->viewport, roundf(width / scale), roundf(height / scale));
#else
BUG("wayl_fraction_scaling() returned true, "
"but fractional scaling was not available at compile time");