render: fix rounding for fractional scaling

We currently scale the width/height of rectangles based on the scaled
x/y instead of the unscaled x/y. This however leads to inconsistent
width/height due to rounding. Fix this bug by basing width/height
scaling off of the original x/y.

Furthermore, fix a typo where we scaled the height off of the x
coordinate instead of the y coordinate.
This commit is contained in:
Isaac Freund 2023-01-08 15:25:16 +01:00
parent 4dd02358d9
commit f370202b68
No known key found for this signature in database
GPG Key ID: 86DED400DDFD7A11

View File

@ -418,10 +418,10 @@ fn renderRect(output: *const Output, box: wlr.Box, color: *const [4]f32) void {
/// Scale a wlr_box, taking the possibility of fractional scaling into account. /// Scale a wlr_box, taking the possibility of fractional scaling into account.
fn scaleBox(box: *wlr.Box, scale: f64) void { fn scaleBox(box: *wlr.Box, scale: f64) void {
box.width = scaleLength(box.width, box.x, scale);
box.height = scaleLength(box.height, box.y, scale);
box.x = @floatToInt(c_int, @round(@intToFloat(f64, box.x) * scale)); box.x = @floatToInt(c_int, @round(@intToFloat(f64, box.x) * scale));
box.y = @floatToInt(c_int, @round(@intToFloat(f64, box.y) * scale)); box.y = @floatToInt(c_int, @round(@intToFloat(f64, box.y) * scale));
box.width = scaleLength(box.width, box.x, scale);
box.height = scaleLength(box.height, box.x, scale);
} }
/// Scales a width/height. /// Scales a width/height.