gpu: Consider scissor when intersecting with recangle

The clip might be different from the scissor due to incompatible
intersections.

But the resulting intersection might be fully clipped, so we should
consider it.

Testsuite with longer explanation attached.

Fixes #7044
This commit is contained in:
Benjamin Otte
2024-09-29 05:58:55 +02:00
parent 187763d286
commit e18c553457
4 changed files with 56 additions and 0 deletions

View File

@@ -1039,6 +1039,19 @@ gsk_gpu_node_processor_add_node_clipped (GskGpuNodeProcessor *self,
}
else
{
graphene_rect_t scissored_clip;
if (gsk_gpu_node_processor_rect_device_to_clip (self,
&GSK_RECT_INIT_CAIRO (&self->scissor),
&scissored_clip))
{
if (!gsk_rect_intersection (&scissored_clip, &clip, &clip))
{
gsk_gpu_clip_init_copy (&self->clip, &old_clip);
return;
}
}
if (!gsk_gpu_clip_intersect_rect (&self->clip, &old_clip, &clip))
{
GskGpuImage *image;

View File

@@ -0,0 +1,42 @@
/* establish proper bounds for the node */
color {
bounds: 0 0 200 200;
color: black;
}
/* ensure the scissor is set */
clip {
clip: 0 0 100 100;
/* Create a cip that does not intersect the scissor
* and will be taken verbatim.
* We now have a scissor and a clip that overlap,
* but neither contains the other
*/
child: rounded-clip {
clip: 90.5 90.5 100 100 / 20;
child: container {
/* Guarantee the rounded-clip's bounds match
* its clip bounds.
*/
color {
bounds: 0 0 200 200;
color: black;
}
/* Clip by a region that has these characteristics:
* 1. It does not intersect with the scissor above
* 2. It is not pixel-aligned, so it can't be
* represented with a scissor.
* Code should properly detect (1).
*/
clip {
clip: 100 100 55.5 55.5;
/* Draw a child that triggers "Clipping is broken" */
child: linear-gradient {
bounds: 0 0 200 200;
stops: 0 red, 0.1 green, 0.2 red, 0.3 blue, 0.4 yellow,
0.5 blue, 0.6 white, 0.7 purple, 0.8 pink, 0.9 orange, 1.0 red;
}
}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 B

View File

@@ -31,6 +31,7 @@ compare_render_tests = [
'border-zero-width-color',
'borders-rotated',
'borders-scaled-nogl',
'clip-all-clipped-issue-7044',
'clip-contained',
'clip-coordinates-2d',
'clip-coordinates-nocairo',