Skip to content

ply-rectangle: Use floats for storing position

Sebastian Krzyszkowiak requested to merge dos/plymouth:float-rect into main

On high DPI screens, ply_rectangles get transformed between logical and device coordinate system a lot. However, going from device to logical coords is a lossy operation when using integers to store the position.

An example of why this is problematic can be seen in ply_pixel_buffer_fill_with_argb32_data_at_opacity_with_clip_and_scale, where fill_area passed in device coords is scaled down to logical coords and then used to determine cropped_area expressed back in device coords. When fill_area has a position that isn't divisible by scale factor, this ends up with out-of-bounds reads since cropped_area ends up with position values smaller than fill_area's due to integer rounding.

This is solved by changing the type of ply_rectangle's position to float, which makes coordinate transformations properly lossless.

Merge request reports