gpu: Handle tiny offscreens

Due to rounding errors, it is possible after intersecting a lot of
rectangles to end up with a tiny size for an offscreen. And because we
allow an epsilon before ceil()ing to an integer (see commit afc7b46264
for details) it is now possible that we end up with a size of 0.

Avoid that by always enforcing a minimum size of 1px.

Test included

The test uses a different codepath to arrive at the same problem - it
specifies the small size instead of triggering it via rounding errors
and clipping like the original bug (and most likely the more common case
to encounter this problem.

Fixes #6656
This commit is contained in:
Benjamin Otte 2024-04-28 06:56:56 +02:00
parent 4856e115a9
commit 719021e1f4
4 changed files with 16 additions and 2 deletions

View File

@ -345,8 +345,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 - EPSILON);
area.height = ceilf (graphene_vec2_get_y (scale) * viewport->size.height - EPSILON);
area.width = MAX (1, ceilf (graphene_vec2_get_x (scale) * viewport->size.width - EPSILON));
area.height = MAX (1, 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

@ -0,0 +1,13 @@
color {
color: black;
bounds: 0 0 20 20;
}
repeat {
bounds: 0 0 20 20;
child: color {
color: red;
/* 1/1024 */
bounds: 0 0 0.0009765625 0.0009765625;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 B

View File

@ -136,6 +136,7 @@ compare_render_tests = [
'repeat-repeats-nested-nogl',
'repeat-scaling',
'repeat-texture',
'repeat-tiny-nogl-nocairo',
'repeating-gradient-scaled',
'reuse-of-texture-nested-in-offscreens',
'rounded-clip-with-huge-bounds-nogl',