gpu: Add an epsilon before ceil()ing for offscreen size

Avoids getting the scale wrong when due to a rounding error our
pixel-aligned rectangle is 5.000000003px big and we ceil() to 6px
and produce blurry output.

Fixes #6439
This commit is contained in:
Benjamin Otte 2024-02-14 04:47:18 +01:00
parent 86db9e2ce0
commit afc7b46264
2 changed files with 10 additions and 5 deletions

View File

@ -44,6 +44,11 @@
#include "gdk/gdkrgbaprivate.h"
#include "gdk/gdksubsurfaceprivate.h"
/* the epsilon we allow pixels to be off due to rounding errors.
* Chosen rather randomly.
*/
#define EPSILON 0.001
/* A note about coordinate systems
*
* The rendering code keeps track of multiple coordinate systems to optimize rendering as
@ -339,8 +344,8 @@ gsk_gpu_node_processor_init_draw (GskGpuNodeProcessor *self,
area.x = 0;
area.y = 0;
area.width = ceilf (graphene_vec2_get_x (scale) * viewport->size.width);
area.height = ceilf (graphene_vec2_get_y (scale) * viewport->size.height);
area.width = ceilf (graphene_vec2_get_x (scale) * viewport->size.width - EPSILON);
area.height = ceilf (graphene_vec2_get_y (scale) * viewport->size.height - EPSILON);
image = gsk_gpu_device_create_offscreen_image (gsk_gpu_frame_get_device (frame),
FALSE,

View File

@ -206,11 +206,11 @@ variants = {
}
compare_xfails = {
'ngl': { 'repeat-scaling': ['clipped'], # 6429
'ngl': {
'repeat-scaling': ['clipped'], # 6429
'radial-gradient-with-64-colorstops': ['clipped'],
'offscreen-pixel-alignment2': ['clipped'], # 6439
},
'vulkan': { 'offscreen-pixel-alignment2': ['clipped'], # 6439
'vulkan': {
'big-checkerboard': ['clipped'], # 6444
},
}