[Pixman] [PATCH pixman 08/15] pixman-filter: Don't recurse unnecessarily.

Bill Spitzak spitzak at gmail.com
Tue Dec 23 17:52:05 PST 2014


Only LINEAR is not differentiable at zero, so only do the recursive
split of the integral for it.
---
 pixman/pixman-filter.c |   34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/pixman/pixman-filter.c b/pixman/pixman-filter.c
index 782f73d..0cd4a68 100644
--- a/pixman/pixman-filter.c
+++ b/pixman/pixman-filter.c
@@ -160,38 +160,38 @@ integral (pixman_kernel_t reconstruct, double x1,
 	  pixman_kernel_t sample, double scale, double x2,
 	  double width)
 {
+    if (reconstruct == PIXMAN_KERNEL_IMPULSE)
+    {
+	assert (width == 0.0);
+	return filters[sample].func (x2 / scale);
+    }
+    else if (reconstruct == PIXMAN_KERNEL_BOX && sample == PIXMAN_KERNEL_BOX)
+    {
+	assert (width <= 1.0);
+	return width;
+    }
+    else if (sample == PIXMAN_KERNEL_IMPULSE)
+    {
+	assert (width == 0.0);
+	return filters[reconstruct].func (x1);
+    }
     /* If the integration interval crosses zero, break it into
      * two separate integrals. This ensures that filters such
      * as LINEAR that are not differentiable at 0 will still
      * integrate properly.
      */
-    if (x1 < 0 && x1 + width > 0)
+    else if (reconstruct == PIXMAN_KERNEL_LINEAR && x1 < 0 && x1 + width > 0)
     {
 	return
 	    integral (reconstruct, x1, sample, scale, x2, - x1) +
 	    integral (reconstruct, 0, sample, scale, x2 - x1, width + x1);
     }
-    else if (x2 < 0 && x2 + width > 0)
+    else if (sample == PIXMAN_KERNEL_LINEAR && x2 < 0 && x2 + width > 0)
     {
 	return
 	    integral (reconstruct, x1, sample, scale, x2, - x2) +
 	    integral (reconstruct, x1 - x2, sample, scale, 0, width + x2);
     }
-    else if (reconstruct == PIXMAN_KERNEL_IMPULSE)
-    {
-	assert (width == 0.0);
-	return filters[sample].func (x2 / scale);
-    }
-    else if (reconstruct == PIXMAN_KERNEL_BOX && sample == PIXMAN_KERNEL_BOX)
-    {
-	assert (width <= 1.0);
-	return width;
-    }
-    else if (sample == PIXMAN_KERNEL_IMPULSE)
-    {
-	assert (width == 0.0);
-	return filters[reconstruct].func (x1);
-    }
     else
     {
 	/* Integration via Simpson's rule */
-- 
1.7.9.5



More information about the Pixman mailing list