Split solid fill images into pixman-solid-fill.c
authorSøren Sandmann Pedersen <sandmann@redhat.com>
Sun, 3 May 2009 00:40:16 +0000 (20:40 -0400)
committerSøren Sandmann Pedersen <sandmann@redhat.com>
Sat, 16 May 2009 19:12:35 +0000 (15:12 -0400)
pixman/Makefile.am
pixman/pixman-image.c
pixman/pixman-private.h
pixman/pixman-solid-fill.c [new file with mode: 0644]

index 776d396..377b393 100644 (file)
@@ -17,6 +17,7 @@ libpixman_1_la_SOURCES =              \
        pixman-compose.c                \
        pixman-pict.c                   \
        pixman-source.c                 \
+       pixman-solid-fill.c             \
        pixman-transformed.c            \
        pixman-transformed-accessors.c  \
        pixman-utils.c                  \
index 2030ddd..d09cd59 100644 (file)
@@ -43,11 +43,7 @@ SourcePictureClassify (pixman_image_t *image,
     
     pict->class = SOURCE_IMAGE_CLASS_UNKNOWN;
     
-    if (pict->common.type == SOLID)
-    {
-       pict->class = SOURCE_IMAGE_CLASS_HORIZONTAL;
-    }
-    else if (pict->common.type == LINEAR)
+    if (pict->common.type == LINEAR)
     {
        linear_gradient_t *linear = (linear_gradient_t *)pict;
        pixman_vector_t   v;
@@ -131,18 +127,8 @@ init_gradient (gradient_t     *gradient,
     return TRUE;
 }
 
-static uint32_t
-color_to_uint32 (const pixman_color_t *color)
-{
-    return
-       (color->alpha >> 8 << 24) |
-       (color->red >> 8 << 16) |
-        (color->green & 0xff00) |
-       (color->blue >> 8);
-}
-
-static pixman_image_t *
-allocate_image (void)
+pixman_image_t *
+_pixman_image_allocate (void)
 {
     pixman_image_t *image = malloc (sizeof (pixman_image_t));
 
@@ -385,21 +371,6 @@ pixman_image_unref (pixman_image_t *image)
 
 /* Constructors */
 PIXMAN_EXPORT pixman_image_t *
-pixman_image_create_solid_fill (pixman_color_t *color)
-{
-    pixman_image_t *img = allocate_image();
-    if (!img)
-       return NULL;
-
-    init_source_image (&img->solid.common);
-
-    img->type = SOLID;
-    img->solid.color = color_to_uint32 (color);
-
-    return img;
-}
-
-PIXMAN_EXPORT pixman_image_t *
 pixman_image_create_linear_gradient (pixman_point_fixed_t         *p1,
                                     pixman_point_fixed_t         *p2,
                                     const pixman_gradient_stop_t *stops,
@@ -410,7 +381,7 @@ pixman_image_create_linear_gradient (pixman_point_fixed_t         *p1,
 
     return_val_if_fail (n_stops >= 2, NULL);
 
-    image = allocate_image();
+    image = _pixman_image_allocate();
 
     if (!image)
        return NULL;
@@ -445,7 +416,7 @@ pixman_image_create_radial_gradient (pixman_point_fixed_t         *inner,
 
     return_val_if_fail (n_stops >= 2, NULL);
 
-    image = allocate_image();
+    image = _pixman_image_allocate();
 
     if (!image)
        return NULL;
@@ -482,7 +453,7 @@ pixman_image_create_conical_gradient (pixman_point_fixed_t *center,
                                      const pixman_gradient_stop_t *stops,
                                      int n_stops)
 {
-    pixman_image_t *image = allocate_image();
+    pixman_image_t *image = _pixman_image_allocate();
     conical_gradient_t *conical;
 
     if (!image)
@@ -584,7 +555,7 @@ pixman_image_create_bits (pixman_format_code_t  format,
            return NULL;
     }
 
-    image = allocate_image();
+    image = _pixman_image_allocate();
 
     if (!image) {
        if (free_me)
@@ -846,6 +817,16 @@ pixman_image_get_depth (pixman_image_t *image)
     return 0;
 }
 
+static uint32_t
+color_to_uint32 (const pixman_color_t *color)
+{
+    return
+       (color->alpha >> 8 << 24) |
+       (color->red >> 8 << 16) |
+        (color->green & 0xff00) |
+       (color->blue >> 8);
+}
+
 static pixman_bool_t
 color_to_pixel (pixman_color_t *color,
                uint32_t       *pixel,
index 0ef2ef2..faf9b20 100644 (file)
@@ -301,6 +301,9 @@ scanStoreProc
 _pixman_image_get_storer (pixman_image_t *image,
                          int             wide);
 
+pixman_image_t *
+_pixman_image_allocate (void);
+
 struct point
 {
     int16_t x, y;
diff --git a/pixman/pixman-solid-fill.c b/pixman/pixman-solid-fill.c
new file mode 100644 (file)
index 0000000..af32d5a
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright © 2000 SuSE, Inc.
+ * Copyright © 2007, 2009 Red Hat, Inc.
+ * Copyright © 2009 Soren Sandmann
+ *
+ * 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.
+ *
+ * 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.
+ */
+
+#include <config.h>
+#include "pixman-private.h"
+
+static source_pict_class_t
+solid_fill_classify (pixman_image_t *image,
+                    int             x,
+                    int             y,
+                    int             width,
+                    int             height)
+{
+    return (image->source.class = SOURCE_IMAGE_CLASS_HORIZONTAL);
+}
+
+static uint32_t
+color_to_uint32 (const pixman_color_t *color)
+{
+    return
+       (color->alpha >> 8 << 24) |
+       (color->red >> 8 << 16) |
+        (color->green & 0xff00) |
+       (color->blue >> 8);
+}
+
+PIXMAN_EXPORT pixman_image_t *
+pixman_image_create_solid_fill (pixman_color_t *color)
+{
+    pixman_image_t *img = _pixman_image_allocate();
+    
+    if (!img)
+       return NULL;
+
+    img->source.class = SOURCE_IMAGE_CLASS_UNKNOWN;
+    img->common.classify = solid_fill_classify;
+    
+    img->type = SOLID;
+    img->solid.color = color_to_uint32 (color);
+
+    return img;
+}