pixman-filter: Nested polynomial for cubic
authorBill Spitzak <spitzak@gmail.com>
Wed, 31 Aug 2016 05:03:14 +0000 (22:03 -0700)
committerSøren Sandmann Pedersen <soren.sandmann@gmail.com>
Sat, 3 Sep 2016 18:53:07 +0000 (14:53 -0400)
v11: Restored range checks

Signed-off-by: Bill Spitzak <spitzak@gmail.com>
Reviewed-by: Oded Gabbay <oded.gabbay@gmail.com>
pixman/pixman-filter.c

index ee580453cc600d1f7730e528d4b43eabd8f6fb88..33188930713fdfe203a95771c5cc04aba188e02e 100644 (file)
@@ -109,14 +109,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;
+       return (((12 - 9 * B - 6 * C) * ax +
+                (-18 + 12 * B + 6 * C)) * ax * ax +
+               (6 - 2 * B)) / 6;
     }
-    else if (ax >= 1 && ax < 2)
+    else if (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 ((((-B - 6 * C) * ax +
+                 (6 * B + 30 * C)) * ax +
+                (-12 * B - 48 * C)) * ax +
+               (8 * B + 24 * C)) / 6;
     }
     else
     {