[cairo] [PATCH pixman 12/13] pixman-filter: refactor polynominal and don't range check

Bill Spitzak spitzak at gmail.com
Thu Sep 11 19:12:29 PDT 2014


Also made impulse filter not range check. All the other filters do
not test for x in range.
---
 pixman/pixman-filter.c |   18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/pixman/pixman-filter.c b/pixman/pixman-filter.c
index dcbed11..8416550 100644
--- a/pixman/pixman-filter.c
+++ b/pixman/pixman-filter.c
@@ -45,7 +45,7 @@ typedef struct
 static double
 impulse_kernel (double x)
 {
-    return (x == 0.0)? 1.0 : 0.0;
+    return 1;
 }
 
 static double
@@ -106,18 +106,16 @@ general_cubic (double x, double B, double C)
 
     if (ax < 1)
     {
-	return ((12 - 9 * B - 6 * C) * ax * ax * ax +
-		(-18 + 12 * B + 6 * C) * ax * ax + (6 - 2 * B)) / 6;
-    }
-    else if (ax >= 1 && ax < 2)
-    {
-	return ((-B - 6 * C) * ax * ax * ax +
-		(6 * B + 30 * C) * ax * ax + (-12 * B - 48 * C) *
-		ax + (8 * B + 24 * C)) / 6;
+	return (((12 - 9 * B - 6 * C) * ax +
+		 (-18 + 12 * B + 6 * C)) * ax * ax +
+		(6 - 2 * B)) / 6;
     }
     else
     {
-	return 0;
+	return ((((-B - 6 * C) * ax +
+		 (6 * B + 30 * C)) * ax +
+		(-12 * B - 48 * C)) * ax +
+		(8 * B + 24 * C)) / 6;
     }
 }
 
-- 
1.7.9.5



More information about the cairo mailing list