gpu: Draw proper shadows again

The fix in commit 5e7f227d broke shadows while trying to make them
faster.
So use a better way to make them faster.

With the normalized blur radius, we can now conclude that all the values
too far from p.y will cause the gauss() call to return close to 0, so we
can skip any y value that is too far from p.y.

And that allows us to put an upper limit on the loop iterations.

Tests included

Fixes #6888
This commit is contained in:
Benjamin Otte 2024-07-28 20:10:56 +02:00
parent 5059ae1d7b
commit cc3ed89e34
6 changed files with 24 additions and 3 deletions

View File

@ -114,13 +114,15 @@ blur_corner (vec2 p,
p /= _sigma;
r /= _sigma;
float result = 0.0;
float step = max (1.0, r.y / 8.0);
for (float y = 0.5 * step; y <= r.y; y += step)
float start = max (p.y - 3.0, 0.0);
float end = min (p.y + 3.0, r.y);
float step = (end - start) / 7.0;
for (float y = start; y <= end; y += step)
{
float x = r.x - ellipse_x (r, r.y - y);
result -= gauss (p.y - y, 1.0) * erf_range (vec2 (- p.x, x - p.x), 1.0);
}
return result;
return step * result;
}
float

View File

@ -0,0 +1,10 @@
clip {
clip: 1400 1400 20 20;
child: color-matrix {
matrix: matrix3d(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255);
child: outset-shadow {
blur: 1000;
outline: 0 0 1000 1000 / 1000 0 1000 0;
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 B

View File

@ -0,0 +1,7 @@
clip {
clip: 0 0 15 15;
child: outset-shadow {
blur: 10;
outline: 0 0 100 100 / 100 0 100 0;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

@ -119,6 +119,8 @@ compare_render_tests = [
'opacity-colormatrix-combinations',
'opacity-overdraw',
'opacity-overlapping-children',
'outset-shadow-corner-blur',
'outset-shadow-corner-blur-huge-nocairo-nogl',
'outset_shadow_offset_both',
'outset_shadow_offset_x',
'outset_shadow_offset_y',