[gtk+/gtk-3-14] Make the blur code compile with clang
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-3-14] Make the blur code compile with clang
- Date: Mon, 23 Mar 2015 03:33:54 +0000 (UTC)
commit 8f5bdfe3e243eff2bf35f2829531bee4aee6d79e
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Mar 22 13:48:02 2015 -0400
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
gtk/gtkcairoblur.c | 33 +++++++++++++++++++++++----------
1 files changed, 23 insertions(+), 10 deletions(-)
---
diff --git a/gtk/gtkcairoblur.c b/gtk/gtkcairoblur.c
index 7a7a9c8..b1ff117 100644
--- a/gtk/gtkcairoblur.c
+++ b/gtk/gtkcairoblur.c
@@ -36,7 +36,20 @@
*/
#define GAUSSIAN_SCALE_FACTOR ((3.0 * sqrt(2 * G_PI) / 4))
-#define get_box_filter_size(radius) ((int)(GAUSSIAN_SCALE_FACTOR * radius))
+#define get_box_filter_size(radius) ((int)(GAUSSIAN_SCALE_FACTOR * (radius)))
+
+/* Sadly, clang is picky about get_box_filter_size(2) not being a
+ * constant expression, thus we have to use precomputed values.
+ */
+#define BOX_FILTER_SIZE_2 3
+#define BOX_FILTER_SIZE_3 5
+#define BOX_FILTER_SIZE_4 7
+#define BOX_FILTER_SIZE_5 9
+#define BOX_FILTER_SIZE_6 11
+#define BOX_FILTER_SIZE_7 13
+#define BOX_FILTER_SIZE_8 15
+#define BOX_FILTER_SIZE_9 16
+#define BOX_FILTER_SIZE_10 18
/* This applies a single box blur pass to a horizontal range of pixels;
* since the box blur has the same weight for all pixels, we can
@@ -94,15 +107,15 @@ blur_xspan (guchar *row,
* divide operation (not radius 1, because its a no-op) */
switch (d)
{
- case get_box_filter_size (2): BLUR_ROW_KERNEL (get_box_filter_size (2));
- case get_box_filter_size (3): BLUR_ROW_KERNEL (get_box_filter_size (3));
- case get_box_filter_size (4): BLUR_ROW_KERNEL (get_box_filter_size (4));
- case get_box_filter_size (5): BLUR_ROW_KERNEL (get_box_filter_size (5));
- case get_box_filter_size (6): BLUR_ROW_KERNEL (get_box_filter_size (6));
- case get_box_filter_size (7): BLUR_ROW_KERNEL (get_box_filter_size (7));
- case get_box_filter_size (8): BLUR_ROW_KERNEL (get_box_filter_size (8));
- case get_box_filter_size (9): BLUR_ROW_KERNEL (get_box_filter_size (9));
- case get_box_filter_size (10): BLUR_ROW_KERNEL (get_box_filter_size (10));
+ case BOX_FILTER_SIZE_2: BLUR_ROW_KERNEL (BOX_FILTER_SIZE_2);
+ case BOX_FILTER_SIZE_3: BLUR_ROW_KERNEL (BOX_FILTER_SIZE_3);
+ case BOX_FILTER_SIZE_4: BLUR_ROW_KERNEL (BOX_FILTER_SIZE_4);
+ case BOX_FILTER_SIZE_5: BLUR_ROW_KERNEL (BOX_FILTER_SIZE_5);
+ case BOX_FILTER_SIZE_6: BLUR_ROW_KERNEL (BOX_FILTER_SIZE_6);
+ case BOX_FILTER_SIZE_7: BLUR_ROW_KERNEL (BOX_FILTER_SIZE_7);
+ case BOX_FILTER_SIZE_8: BLUR_ROW_KERNEL (BOX_FILTER_SIZE_8);
+ case BOX_FILTER_SIZE_9: BLUR_ROW_KERNEL (BOX_FILTER_SIZE_9);
+ case BOX_FILTER_SIZE_10: BLUR_ROW_KERNEL (BOX_FILTER_SIZE_10);
default: BLUR_ROW_KERNEL (d);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]