Commit Graph

20 Commits

Author SHA1 Message Date
Matthias Clasen
2a444e30f7 Make the blur code compile with clang
clang complains that the expression involving sqrt() is not
constant, and thus refuses to accept it as a case label. So,
use precomputed values instead.

https://bugzilla.gnome.org/show_bug.cgi?id=746468
2015-03-22 13:49:24 -04:00
Alexander Larsson
967cb56275 shadow-box: Blur only horizontally/vertically for the non-corner parts
There is no need to e.g. blur in the x-direction for the top part
of a box shadow. Also, there is no need to extend the mask in the
non-blurred direction.

https://bugzilla.gnome.org/show_bug.cgi?id=746468
2015-03-21 21:31:49 +01:00
Alexander Larsson
9c2a16fb3b shadow-box: Bail out blur early if radius is 1px
For radius 1px the current implementation rounds down to a 1 px box
filter which is a no-op. Rather than creating useless shadow masks
in this case we bail out blurring early.

Another alternative would be to make radius 1px round up to a 2 px box
filter, but that would change the rendering of Adwaita which is probably
not a great idea this late in the cycle.

https://bugzilla.gnome.org/show_bug.cgi?id=746468
2015-03-21 21:07:26 +01:00
Alexander Larsson
d0dc1f52cc gtkcairoblur: Unroll inner loop for common radius values
This unrolls the inner blur loop for radius 1-10, allowing
the compiler to use a divide-by-constant operation instead
of a generic division.

Here is the blur-performance output before:

Radius  1: 124.95 msec, 32.01 kpixels/msec:
Radius  2: 117.27 msec, 34.11 kpixels/msec:
Radius  3: 123.57 msec, 32.37 kpixels/msec:
Radius  4: 118.17 msec, 33.85 kpixels/msec:
Radius  5: 119.32 msec, 33.52 kpixels/msec:
Radius  6: 124.17 msec, 32.21 kpixels/msec:
Radius  7: 121.04 msec, 33.05 kpixels/msec:
Radius  8: 130.64 msec, 30.62 kpixels/msec:
Radius  9: 119.47 msec, 33.48 kpixels/msec:
Radius 10: 117.95 msec, 33.91 kpixels/msec:
Radius 11: 122.38 msec, 32.68 kpixels/msec:
Radius 12: 121.92 msec, 32.81 kpixels/msec:
Radius 13: 125.45 msec, 31.89 kpixels/msec:
Radius 14: 121.63 msec, 32.89 kpixels/msec:
Radius 15: 120.18 msec, 33.28 kpixels/msec:

And after:

Radius  1: 42.26 msec, 94.65 kpixels/msec:
Radius  2: 59.15 msec, 67.62 kpixels/msec:
Radius  3: 60.29 msec, 66.35 kpixels/msec:
Radius  4: 64.53 msec, 61.99 kpixels/msec:
Radius  5: 60.07 msec, 66.59 kpixels/msec:
Radius  6: 62.43 msec, 64.07 kpixels/msec:
Radius  7: 60.36 msec, 66.27 kpixels/msec:
Radius  8: 59.59 msec, 67.13 kpixels/msec:
Radius  9: 76.17 msec, 52.51 kpixels/msec:
Radius 10: 79.41 msec, 50.37 kpixels/msec:
Radius 11: 118.92 msec, 33.64 kpixels/msec:
Radius 12: 121.31 msec, 32.97 kpixels/msec:
Radius 13: 118.30 msec, 33.81 kpixels/msec:
Radius 14: 116.82 msec, 34.24 kpixels/msec:
Radius 15: 116.99 msec, 34.19 kpixels/msec:

I.e. almost double performance for the unrolled radius values.

https://bugzilla.gnome.org/show_bug.cgi?id=746468
2015-03-21 21:07:26 +01:00
Alexander Larsson
ae21e08782 gtkcairoblur: Minor restructure
This just moves get_box_filter_size to the top and makes
it a macro (so it can be used as a constant later).

https://bugzilla.gnome.org/show_bug.cgi?id=746468
2015-03-21 20:59:57 +01:00
Benjamin Otte
98ee594f73 blur: Simplify return_if_fail() 2015-02-05 18:57:29 +01:00
Jasper St. Pierre
5f40f58c36 cairoblur: Fix the blur again once more
The differences between the mutter and GTK+ code are subtle, but it
turns out that _gtk_cairo_blur_compute_pixels actually returns the
shadow *spread*. Since we use a triple box blur, the constant was
multiplied by 1.5 to approximate three chained box blurs. Split this
out and use the correct value for the lobe width.
2014-10-27 10:20:43 -07:00
Jasper St. Pierre
ac9ac55555 cairoblur: Fix the blur code
We weren't passing in the right "d" value, which was causing the blur to
behave incorrectly, especially in the case of 1px blurs, which would
cause no blurs at all.

The blur should now match the web.
2014-10-27 10:10:32 -07:00
Jasper St. Pierre
08f6dceef5 gtkcairoblur: Relicense under LGPL
Both Owen Taylor and I, the originators of this code, allow the code
herein be relicensed to the LGPL, which is what GTK+ ships with. This
prevents GTK+ from being GPL-only.
2014-08-31 19:50:37 -07:00
Matthias Clasen
1c34ad2668 Small comment fixups
One factual pointed out in the review in
https://bugzilla.gnome.org/show_bug.cgi?id=734053, plus some
formatting nit picks.
2014-08-03 00:42:48 +02:00
Jasper St. Pierre
f5d8f75c0f gtkcairoblur: Replace our exponential blur with the box blur from mutter
https://bugzilla.gnome.org/show_bug.cgi?id=734053
2014-08-03 00:35:55 +02:00
Jasper St. Pierre
45bdec84f5 gtkcairoblur: Blur a CAIRO_A8 surface instead of a full CAIRO_ARGB32
This is considerably faster to draw and paint.
2014-07-29 10:49:39 +02:00
William Jon McCann
13998c55e7 docs: use proper quotations instead of '*' 2014-02-07 14:22:39 -05:00
Benjamin Otte
e9fb8ad1f7 css: Fix computation of pixels occupied by blur radius
These computations were done randomly in lots of places and more often
than not, they were also wrong.
This function was copied (with docs) from Firefox:
  http://lxr.mozilla.org/mozilla-central/source/gfx/2d/Blur.cpp

https://bugzilla.gnome.org/show_bug.cgi?id=723159
2014-02-03 21:38:16 +01:00
Benjamin Otte
a239f2e8b0 blur: Do the same thing for rows and cols 2012-09-20 02:45:41 +02:00
Benjamin Otte
502a2bf625 blur: Use rowstride 2012-09-20 02:45:41 +02:00
Benjamin Otte
65ba8901aa blur: Simplify code
It's always the same code, so there's no need for switch statements.
2012-09-20 02:45:41 +02:00
Benjamin Otte
267d1793c6 blur: Fix pixel sizes
The code accesses pixels in a chunks of 4 bytes, so we must only support
formats where the size of a single pixel is 4 bytes.
Fix RGB24 to be 4 bytes (the alpha channel is ignored) and disallow A8.
2012-09-20 02:45:41 +02:00
Benjamin Otte
1cecaf6d7e blur: Take the radius as a double parameter
It's only ever used like that
2012-09-20 02:45:41 +02:00
Andrea Cimitan
43673dafdc Add code for blurring (original code from Unico, copyright fine for Gtk+) 2012-09-20 02:45:41 +02:00