Reindent and reformat pixman-radial-gradient.c
authorSøren Sandmann Pedersen <sandmann@redhat.com>
Sun, 12 Jul 2009 23:59:17 +0000 (19:59 -0400)
committerSøren Sandmann Pedersen <sandmann@redhat.com>
Mon, 13 Jul 2009 23:55:34 +0000 (19:55 -0400)
pixman/pixman-radial-gradient.c

index 870c4ce..06d6ef9 100644 (file)
 #include "pixman-private.h"
 
 static void
-radial_gradient_get_scanline_32 (pixman_image_t *image, int x, int y, int width, uint32_t *buffer,
-                                const uint32_t *mask, uint32_t mask_bits)
+radial_gradient_get_scanline_32 (pixman_image_t *image,
+                                 int             x,
+                                 int             y,
+                                 int             width,
+                                 uint32_t *      buffer,
+                                 const uint32_t *mask,
+                                 uint32_t        mask_bits)
 {
     /*
      * In the radial gradient problem we are given two circles (c₁,r₁) and
@@ -153,8 +158,8 @@ radial_gradient_get_scanline_32 (pixman_image_t *image, int x, int y, int width,
     gradient_t *gradient = (gradient_t *)image;
     source_image_t *source = (source_image_t *)image;
     radial_gradient_t *radial = (radial_gradient_t *)image;
-    uint32_t       *end = buffer + width;
-    pixman_gradient_walker_t  walker;
+    uint32_t *end = buffer + width;
+    pixman_gradient_walker_t walker;
     pixman_bool_t affine = TRUE;
     double cx = 1.;
     double cy = 0.;
@@ -162,29 +167,37 @@ radial_gradient_get_scanline_32 (pixman_image_t *image, int x, int y, int width,
     double rx = x + 0.5;
     double ry = y + 0.5;
     double rz = 1.;
-    
+
     _pixman_gradient_walker_init (&walker, gradient, source->common.repeat);
-    
-    if (source->common.transform) {
+
+    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[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.;
        
-       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;
+       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) {
-       while (buffer < end) {
+
+    if (affine)
+    {
+       while (buffer < end)
+       {
            if (!mask || *mask++ & mask_bits)
            {
                double pdx, pdy;
@@ -194,34 +207,37 @@ radial_gradient_get_scanline_32 (pixman_image_t *image, int x, int y, int width,
                double c1y = radial->c1.y / 65536.0;
                double r1  = radial->c1.radius / 65536.0;
                pixman_fixed_48_16_t t;
-               
+
                pdx = rx - c1x;
                pdy = ry - c1y;
-               
-               B = -2 * (  pdx * radial->cdx
-                           + pdy * radial->cdy
-                           + r1 * radial->dr);
-               C = (pdx * pdx + pdy * pdy - r1 * r1);
-               
+
+               B = -2 * (pdx * radial->cdx +
+                         pdy * radial->cdy +
+                         r1 * radial->dr);
+               C = pdx * pdx + pdy * pdy - r1 * r1;
+
                det = (B * B) - (4 * radial->A * C);
                if (det < 0.0)
                    det = 0.0;
-               
+
                if (radial->A < 0)
-                   t = (pixman_fixed_48_16_t) ((- B - sqrt(det)) / (2.0 * radial->A) * 65536);
+                   t = (pixman_fixed_48_16_t) ((-B - sqrt (det)) / (2.0 * radial->A) * 65536);
                else
-                   t = (pixman_fixed_48_16_t) ((- B + sqrt(det)) / (2.0 * radial->A) * 65536);
-               
-               *(buffer) = _pixman_gradient_walker_pixel (&walker, t);
+                   t = (pixman_fixed_48_16_t) ((-B + sqrt (det)) / (2.0 * radial->A) * 65536);
+
+               *buffer = _pixman_gradient_walker_pixel (&walker, t);
            }
            ++buffer;
-           
+
            rx += cx;
            ry += cy;
        }
-    } else {
+    }
+    else
+    {
        /* projective */
-       while (buffer < end) {
+       while (buffer < end)
+       {
            if (!mask || *mask++ & mask_bits)
            {
                double pdx, pdy;
@@ -232,41 +248,44 @@ radial_gradient_get_scanline_32 (pixman_image_t *image, int x, int y, int width,
                double r1  = radial->c1.radius / 65536.0;
                pixman_fixed_48_16_t t;
                double x, y;
-               
-               if (rz != 0) {
-                   x = rx/rz;
-                   y = ry/rz;
-               } else {
+
+               if (rz != 0)
+               {
+                   x = rx / rz;
+                   y = ry / rz;
+               }
+               else
+               {
                    x = y = 0.;
                }
-               
+
                pdx = x - c1x;
                pdy = y - c1y;
-               
-               B = -2 * (  pdx * radial->cdx
-                           + pdy * radial->cdy
-                           + r1 * radial->dr);
+
+               B = -2 * (pdx * radial->cdx +
+                         pdy * radial->cdy +
+                         r1 * radial->dr);
                C = (pdx * pdx + pdy * pdy - r1 * r1);
-               
+
                det = (B * B) - (4 * radial->A * C);
                if (det < 0.0)
                    det = 0.0;
-               
+
                if (radial->A < 0)
-                   t = (pixman_fixed_48_16_t) ((- B - sqrt(det)) / (2.0 * radial->A) * 65536);
+                   t = (pixman_fixed_48_16_t) ((-B - sqrt (det)) / (2.0 * radial->A) * 65536);
                else
-                   t = (pixman_fixed_48_16_t) ((- B + sqrt(det)) / (2.0 * radial->A) * 65536);
-               
-               *(buffer) = _pixman_gradient_walker_pixel (&walker, t);
+                   t = (pixman_fixed_48_16_t) ((-B + sqrt (det)) / (2.0 * radial->A) * 65536);
+
+               *buffer = _pixman_gradient_walker_pixel (&walker, t);
            }
-           ++buffer;
            
+           ++buffer;
+
            rx += cx;
            ry += cy;
            rz += cz;
        }
     }
-    
 }
 
 static void
@@ -277,33 +296,33 @@ radial_gradient_property_changed (pixman_image_t *image)
 }
 
 PIXMAN_EXPORT pixman_image_t *
-pixman_image_create_radial_gradient (pixman_point_fixed_t         *inner,
-                                    pixman_point_fixed_t         *outer,
-                                    pixman_fixed_t                inner_radius,
-                                    pixman_fixed_t                outer_radius,
-                                    const pixman_gradient_stop_t *stops,
-                                    int                           n_stops)
+pixman_image_create_radial_gradient (pixman_point_fixed_t *        inner,
+                                     pixman_point_fixed_t *        outer,
+                                     pixman_fixed_t                inner_radius,
+                                     pixman_fixed_t                outer_radius,
+                                     const pixman_gradient_stop_t *stops,
+                                     int                           n_stops)
 {
     pixman_image_t *image;
     radial_gradient_t *radial;
-    
+
     return_val_if_fail (n_stops >= 2, NULL);
-    
-    image = _pixman_image_allocate();
-    
+
+    image = _pixman_image_allocate ();
+
     if (!image)
        return NULL;
-    
+
     radial = &image->radial;
-    
+
     if (!_pixman_init_gradient (&radial->common, stops, n_stops))
     {
        free (image);
        return NULL;
     }
-    
+
     image->type = RADIAL;
-    
+
     radial->c1.x = inner->x;
     radial->c1.y = inner->y;
     radial->c1.radius = inner_radius;
@@ -313,14 +332,14 @@ pixman_image_create_radial_gradient (pixman_point_fixed_t         *inner,
     radial->cdx = pixman_fixed_to_double (radial->c2.x - radial->c1.x);
     radial->cdy = pixman_fixed_to_double (radial->c2.y - radial->c1.y);
     radial->dr = pixman_fixed_to_double (radial->c2.radius - radial->c1.radius);
-    radial->A = (radial->cdx * radial->cdx
-                + radial->cdy * radial->cdy
-                radial->dr  * radial->dr);
-    
+    radial->A = (radial->cdx * radial->cdx +
+                radial->cdy * radial->cdy -
+                radial->dr  * radial->dr);
+
     image->common.property_changed = radial_gradient_property_changed;
-    
+
     radial_gradient_property_changed (image);
-    
+
     return image;
 }