From afc7b46264b51a9753683cc1152a64e9411858fb Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 14 Feb 2024 04:47:18 +0100 Subject: [PATCH] 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 --- gsk/gpu/gskgpunodeprocessor.c | 9 +++++++-- testsuite/gsk/meson.build | 6 +++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/gsk/gpu/gskgpunodeprocessor.c b/gsk/gpu/gskgpunodeprocessor.c index e12a7a8b6c..47273be336 100644 --- a/gsk/gpu/gskgpunodeprocessor.c +++ b/gsk/gpu/gskgpunodeprocessor.c @@ -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, diff --git a/testsuite/gsk/meson.build b/testsuite/gsk/meson.build index 9a70f40256..dd7fe90516 100644 --- a/testsuite/gsk/meson.build +++ b/testsuite/gsk/meson.build @@ -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 }, }