Move conical gradient code to pixman-conical-gradient.c and delete pixman-source.c
authorSøren Sandmann Pedersen <sandmann@redhat.com>
Sun, 3 May 2009 05:18:49 +0000 (01:18 -0400)
committerSøren Sandmann Pedersen <sandmann@redhat.com>
Sat, 16 May 2009 19:12:36 +0000 (15:12 -0400)
pixman/Makefile.am
pixman/pixman-conical-gradient.c
pixman/pixman-source.c [deleted file]

index ed5fca9..07452f1 100644 (file)
@@ -17,7 +17,6 @@ libpixman_1_la_SOURCES =              \
        pixman-combine64.h              \
        pixman-compose.c                \
        pixman-pict.c                   \
-       pixman-source.c                 \
        pixman-solid-fill.c             \
        pixman-conical-gradient.c       \
        pixman-linear-gradient.c        \
index 974fd7c..023256a 100644 (file)
 /*
  * Copyright © 2000 SuSE, Inc.
  * Copyright © 2007 Red Hat, Inc.
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *             2005 Lars Knoll & Zack Rusin, Trolltech
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
  * the above copyright notice appear in all copies and that both that
  * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of SuSE not be used in advertising or
- * publicity pertaining to distribution of the software without specific,
- * written prior permission.  SuSE makes no representations about the
- * suitability of this software for any purpose.  It is provided "as is"
- * without express or implied warranty.
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
  *
- * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
- * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
  */
-
 #include <config.h>
 #include <stdlib.h>
+#include <math.h>
 #include "pixman-private.h"
 
 static void
+conical_gradient_get_scanline_32 (pixman_image_t *image, int x, int y, int width,
+                                 uint32_t *buffer, uint32_t *mask, uint32_t maskBits)
+{
+    source_image_t *source = (source_image_t *)image;
+    gradient_t *gradient = (gradient_t *)source;
+    conical_gradient_t *conical = (conical_gradient_t *)image;
+    uint32_t       *end = buffer + width;
+    GradientWalker  walker;
+    pixman_bool_t affine = TRUE;
+    double cx = 1.;
+    double cy = 0.;
+    double cz = 0.;
+    double rx = x + 0.5;
+    double ry = y + 0.5;
+    double rz = 1.;
+    double a = conical->angle/(180.*65536);
+
+    _pixman_gradient_walker_init (&walker, gradient, source->common.repeat);
+    
+    if (source->common.transform) {
+       pixman_vector_t v;
+       /* reference point is the center of the pixel */
+       v.vector[0] = pixman_int_to_fixed(x) + pixman_fixed_1/2;
+       v.vector[1] = pixman_int_to_fixed(y) + pixman_fixed_1/2;
+       v.vector[2] = pixman_fixed_1;
+       if (!pixman_transform_point_3d (source->common.transform, &v))
+           return;
+       
+       cx = source->common.transform->matrix[0][0]/65536.;
+       cy = source->common.transform->matrix[1][0]/65536.;
+       cz = source->common.transform->matrix[2][0]/65536.;
+       rx = v.vector[0]/65536.;
+       ry = v.vector[1]/65536.;
+       rz = v.vector[2]/65536.;
+       affine = source->common.transform->matrix[2][0] == 0 && v.vector[2] == pixman_fixed_1;
+    }
+    
+    if (affine) {
+       rx -= conical->center.x/65536.;
+       ry -= conical->center.y/65536.;
+       
+       while (buffer < end) {
+           double angle;
+           
+           if (!mask || *mask++ & maskBits)
+           {
+               pixman_fixed_48_16_t   t;
+               
+               angle = atan2(ry, rx) + a;
+               t     = (pixman_fixed_48_16_t) (angle * (65536. / (2*M_PI)));
+               
+               *(buffer) = _pixman_gradient_walker_pixel (&walker, t);
+           }
+           
+           ++buffer;
+           rx += cx;
+           ry += cy;
+       }
+    } else {
+       while (buffer < end) {
+           double x, y;
+           double angle;
+           
+           if (!mask || *mask++ & maskBits)
+           {
+               pixman_fixed_48_16_t  t;
+               
+               if (rz != 0) {
+                   x = rx/rz;
+                   y = ry/rz;
+               } else {
+                   x = y = 0.;
+               }
+               x -= conical->center.x/65536.;
+               y -= conical->center.y/65536.;
+               angle = atan2(y, x) + a;
+               t     = (pixman_fixed_48_16_t) (angle * (65536. / (2*M_PI)));
+               
+               *(buffer) = _pixman_gradient_walker_pixel (&walker, t);
+           }
+           
+           ++buffer;
+           rx += cx;
+           ry += cy;
+           rz += cz;
+       }
+    }
+}
+
+static void
 conical_gradient_property_changed (pixman_image_t *image)
 {
-    image->common.get_scanline_32 = (scanFetchProc)pixmanFetchGradient;
+    image->common.get_scanline_32 = (scanFetchProc)conical_gradient_get_scanline_32;
     image->common.get_scanline_64 = (scanFetchProc)_pixman_image_get_scanline_64_generic;
 }
 
@@ -39,24 +133,24 @@ pixman_image_create_conical_gradient (pixman_point_fixed_t         *center,
 {
     pixman_image_t *image = _pixman_image_allocate();
     conical_gradient_t *conical;
-
+    
     if (!image)
        return NULL;
-
+    
     conical = &image->conical;
-
+    
     if (!_pixman_init_gradient (&conical->common, stops, n_stops))
     {
        free (image);
        return NULL;
     }
-
+    
     image->type = CONICAL;
     conical->center = *center;
     conical->angle = angle;
-
+    
     image->common.property_changed = conical_gradient_property_changed;
-
+    
     conical_gradient_property_changed (image);
     
     return image;
diff --git a/pixman/pixman-source.c b/pixman/pixman-source.c
deleted file mode 100644 (file)
index dfdb183..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- *
- * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
- *             2005 Lars Knoll & Zack Rusin, Trolltech
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Keith Packard makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
- * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
- * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
- * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdlib.h>
-#include <math.h>
-
-#include "pixman-private.h"
-
-void
-pixmanFetchGradient(gradient_t *gradient, int x, int y, int width,
-                   uint32_t *buffer, uint32_t *mask, uint32_t maskBits)
-{
-    GradientWalker  walker;
-    uint32_t       *end = buffer + width;
-    source_image_t *pict;
-
-    pict = (source_image_t *)gradient;
-
-    _pixman_gradient_walker_init (&walker, gradient, pict->common.repeat);
-
-    if (pict->common.type == LINEAR) {
-       assert (0);
-    } else {
-        if (pict->common.type == RADIAL) {
-           assert (0);
-        } else /* SourcePictTypeConical */ {
-           /* radial or conical */
-           pixman_bool_t affine = TRUE;
-           double cx = 1.;
-           double cy = 0.;
-           double cz = 0.;
-           double rx = x + 0.5;
-           double ry = y + 0.5;
-           double rz = 1.;
-           
-           if (pict->common.transform) {
-               pixman_vector_t v;
-               /* reference point is the center of the pixel */
-               v.vector[0] = pixman_int_to_fixed(x) + pixman_fixed_1/2;
-               v.vector[1] = pixman_int_to_fixed(y) + pixman_fixed_1/2;
-               v.vector[2] = pixman_fixed_1;
-               if (!pixman_transform_point_3d (pict->common.transform, &v))
-                   return;
-               
-               cx = pict->common.transform->matrix[0][0]/65536.;
-               cy = pict->common.transform->matrix[1][0]/65536.;
-               cz = pict->common.transform->matrix[2][0]/65536.;
-               rx = v.vector[0]/65536.;
-               ry = v.vector[1]/65536.;
-               rz = v.vector[2]/65536.;
-               affine = pict->common.transform->matrix[2][0] == 0 && v.vector[2] == pixman_fixed_1;
-           }
-           
-           conical_gradient_t *conical = (conical_gradient_t *)pict;
-            double a = conical->angle/(180.*65536);
-            if (affine) {
-                rx -= conical->center.x/65536.;
-                ry -= conical->center.y/65536.;
-
-                while (buffer < end) {
-                   double angle;
-
-                    if (!mask || *mask++ & maskBits)
-                   {
-                        pixman_fixed_48_16_t   t;
-
-                        angle = atan2(ry, rx) + a;
-                       t     = (pixman_fixed_48_16_t) (angle * (65536. / (2*M_PI)));
-
-                       *(buffer) = _pixman_gradient_walker_pixel (&walker, t);
-                   }
-
-                    ++buffer;
-                    rx += cx;
-                    ry += cy;
-                }
-            } else {
-                while (buffer < end) {
-                    double x, y;
-                    double angle;
-
-                    if (!mask || *mask++ & maskBits)
-                    {
-                       pixman_fixed_48_16_t  t;
-
-                       if (rz != 0) {
-                           x = rx/rz;
-                           y = ry/rz;
-                       } else {
-                           x = y = 0.;
-                       }
-                       x -= conical->center.x/65536.;
-                       y -= conical->center.y/65536.;
-                       angle = atan2(y, x) + a;
-                       t     = (pixman_fixed_48_16_t) (angle * (65536. / (2*M_PI)));
-
-                       *(buffer) = _pixman_gradient_walker_pixel (&walker, t);
-                   }
-
-                    ++buffer;
-                    rx += cx;
-                    ry += cy;
-                    rz += cz;
-                }
-            }
-        }
-    }
-}