Add various accessors; remove composite_rect
authorSøren Sandmann <sandmann@redhat.com>
Tue, 12 Jun 2007 18:24:40 +0000 (14:24 -0400)
committerSøren Sandmann <sandmann@redhat.com>
Tue, 12 Jun 2007 18:24:40 +0000 (14:24 -0400)
TODO
configure.ac
pixman/pixman-image.c
pixman/pixman-pict.c
pixman/pixman.h
test/composite-test.c
test/gradient-test.c

diff --git a/TODO b/TODO
index e7f6c57..26eab05 100644 (file)
--- a/TODO
+++ b/TODO
@@ -62,3 +62,4 @@
 - Run cairo test suite; fix bugs
        - one bug in source-scale-clip
 
+- Default clip region should be the full image
\ No newline at end of file
index 5b604f1..b759c7f 100644 (file)
@@ -22,7 +22,7 @@ dnl Process this file with autoconf to create configure.
 
 AC_PREREQ([2.57])
 
-AC_INIT(pixman, 0.9.2, "sandmann@daimi.au.dk", pixman)
+AC_INIT(pixman, 0.9.3, "sandmann@daimi.au.dk", pixman)
 AM_INIT_AUTOMAKE([dist-bzip2])
 
 AM_CONFIG_HEADER(config.h)
index 1cc28b2..a719f3a 100644 (file)
@@ -268,13 +268,13 @@ pixman_image_create_bits (pixman_format_code_t  format,
                          int                   width,
                          int                   height,
                          uint32_t             *bits,
-                         int                   rowstride)
+                         int                   rowstride_bytes)
 {
     pixman_image_t *image;
 
-    return_val_if_fail ((rowstride & 0x3) == 0, NULL); /* must be a
-                                                       * multiple of 4
-                                                       */
+    /* must be a whole number of uint32_t's 
+     */
+    return_val_if_fail ((rowstride_bytes % sizeof (uint32_t)) == 0, NULL); 
 
     image = allocate_image();
 
@@ -286,9 +286,9 @@ pixman_image_create_bits (pixman_format_code_t  format,
     image->bits.width = width;
     image->bits.height = height;
     image->bits.bits = bits;
-    image->bits.rowstride = rowstride / 4; /* we store it in number
-                                           * of uint32_t's
-                                           */
+    image->bits.rowstride = rowstride_bytes / sizeof (uint32_t); /* we store it in number
+                                                                 * of uint32_t's
+                                                                 */
     image->bits.indexed = NULL;
 
     return image;
@@ -429,8 +429,6 @@ pixman_image_set_component_alpha   (pixman_image_t       *image,
 }
 
 
-#define SCANLINE_BUFFER_LENGTH 2048
-
 void
 pixman_image_set_accessors (pixman_image_t             *image,
                            pixman_read_memory_func_t   read_func,
@@ -442,50 +440,43 @@ pixman_image_set_accessors (pixman_image_t             *image,
     image->common.write_func = write_func;
 }
 
-void
-pixman_image_composite_rect  (pixman_op_t                   op,
-                             pixman_image_t               *src,
-                             pixman_image_t               *mask,
-                             pixman_image_t               *dest,
-                             int16_t                       src_x,
-                             int16_t                       src_y,
-                             int16_t                       mask_x,
-                             int16_t                       mask_y,
-                             int16_t                       dest_x,
-                             int16_t                       dest_y,
-                             uint16_t                      width,
-                             uint16_t                      height)
+uint32_t *
+pixman_image_get_data (pixman_image_t *image)
 {
-    FbComposeData compose_data;
-    uint32_t _scanline_buffer[SCANLINE_BUFFER_LENGTH * 3];
-    uint32_t *scanline_buffer = _scanline_buffer;
+    return_val_if_fail (image->type == BITS, NULL);
 
-    return_if_fail (src != NULL);
-    return_if_fail (dest != NULL);
-    
-    if (width > SCANLINE_BUFFER_LENGTH)
-    {
-       scanline_buffer = (uint32_t *)malloc (width * 3 * sizeof (uint32_t));
+    return image->bits.bits;
+}
 
-       if (!scanline_buffer)
-           return;
-    }
+int
+pixman_image_get_width (pixman_image_t *image)
+{
+    return_val_if_fail (image->type == BITS, -1);
+
+    return image->bits.width;
     
-    compose_data.op = op;
-    compose_data.src = src;
-    compose_data.mask = mask;
-    compose_data.dest = dest;
-    compose_data.xSrc = src_x;
-    compose_data.ySrc = src_y;
-    compose_data.xMask = mask_x;
-    compose_data.yMask = mask_y;
-    compose_data.xDest = dest_x;
-    compose_data.yDest = dest_y;
-    compose_data.width = width;
-    compose_data.height = height;
-
-    pixmanCompositeRect (&compose_data, scanline_buffer);
-
-    if (scanline_buffer != _scanline_buffer)
-       free (scanline_buffer);
+}
+
+int
+pixman_image_get_height (pixman_image_t *image)
+{
+    return_val_if_fail (image->type == BITS, -1);
+
+    return image->bits.height;
+}
+
+int
+pixman_image_get_stride (pixman_image_t *image)
+{
+    return_val_if_fail (image->type == BITS, -1);
+
+    return sizeof (uint32_t) * image->bits.rowstride;
+}
+
+int
+pixman_image_get_depth (pixman_image_t *image)
+{
+    return_val_if_fail (image->type == BITS, -1);
+
+    return PIXMAN_FORMAT_DEPTH (image->bits.format);
 }
index 5d5417c..741ede6 100644 (file)
@@ -1063,6 +1063,56 @@ can_get_solid (pixman_image_t *image)
     }
 }
 
+#define SCANLINE_BUFFER_LENGTH 2048
+
+static void
+pixman_image_composite_rect  (pixman_op_t                   op,
+                             pixman_image_t               *src,
+                             pixman_image_t               *mask,
+                             pixman_image_t               *dest,
+                             int16_t                       src_x,
+                             int16_t                       src_y,
+                             int16_t                       mask_x,
+                             int16_t                       mask_y,
+                             int16_t                       dest_x,
+                             int16_t                       dest_y,
+                             uint16_t                      width,
+                             uint16_t                      height)
+{
+    FbComposeData compose_data;
+    uint32_t _scanline_buffer[SCANLINE_BUFFER_LENGTH * 3];
+    uint32_t *scanline_buffer = _scanline_buffer;
+
+    return_if_fail (src != NULL);
+    return_if_fail (dest != NULL);
+    
+    if (width > SCANLINE_BUFFER_LENGTH)
+    {
+       scanline_buffer = (uint32_t *)malloc (width * 3 * sizeof (uint32_t));
+
+       if (!scanline_buffer)
+           return;
+    }
+    
+    compose_data.op = op;
+    compose_data.src = src;
+    compose_data.mask = mask;
+    compose_data.dest = dest;
+    compose_data.xSrc = src_x;
+    compose_data.ySrc = src_y;
+    compose_data.xMask = mask_x;
+    compose_data.yMask = mask_y;
+    compose_data.xDest = dest_x;
+    compose_data.yDest = dest_y;
+    compose_data.width = width;
+    compose_data.height = height;
+
+    pixmanCompositeRect (&compose_data, scanline_buffer);
+
+    if (scanline_buffer != _scanline_buffer)
+       free (scanline_buffer);
+}
+
 void
 pixman_image_composite (pixman_op_t      op,
                        pixman_image_t * pSrc,
index 277fc0f..3ca6be0 100644 (file)
@@ -479,6 +479,11 @@ void               pixman_image_set_accessors           (pixman_image_t               *image,
                                                      pixman_write_memory_func_t    write_func);
 void           pixman_image_set_indexed             (pixman_image_t               *image,
                                                      const pixman_indexed_t       *indexed);
+uint32_t       *pixman_image_get_data                (pixman_image_t               *image);
+int            pixman_image_get_width               (pixman_image_t               *image);
+int             pixman_image_get_height              (pixman_image_t               *image);
+int            pixman_image_get_stride              (pixman_image_t               *image);
+int            pixman_image_get_depth               (pixman_image_t               *image);
 
 /* Composite */
 pixman_bool_t   pixman_compute_composite_region (pixman_region16_t *   pRegion,
@@ -493,30 +498,18 @@ pixman_bool_t   pixman_compute_composite_region (pixman_region16_t *      pRegion,
                                                 int16_t                yDst,
                                                 uint16_t               width,
                                                 uint16_t               height);
-void           pixman_image_composite               (pixman_op_t                   op,
-                                                     pixman_image_t               *src,
-                                                     pixman_image_t               *mask,
-                                                     pixman_image_t               *dest,
-                                                     int16_t                       src_x,
-                                                     int16_t                       src_y,
-                                                     int16_t                       mask_x,
-                                                     int16_t                       mask_y,
-                                                     int16_t                       dest_x,
-                                                     int16_t                       dest_y,
-                                                     uint16_t                      width,
-                                                     uint16_t                      height);
-void            pixman_image_composite_rect          (pixman_op_t                   op,
-                                                     pixman_image_t               *src,
-                                                     pixman_image_t               *mask,
-                                                     pixman_image_t               *dest,
-                                                     int16_t                       src_x,
-                                                     int16_t                       src_y,
-                                                     int16_t                       mask_x,
-                                                     int16_t                       mask_y,
-                                                     int16_t                       dest_x,
-                                                     int16_t                       dest_y,
-                                                     uint16_t                      width,
-                                                     uint16_t                      height);
+void           pixman_image_composite          (pixman_op_t                op,
+                                                pixman_image_t            *src,
+                                                pixman_image_t               *mask,
+                                                pixman_image_t               *dest,
+                                                int16_t                       src_x,
+                                                int16_t                       src_y,
+                                                int16_t                       mask_x,
+                                                int16_t                       mask_y,
+                                                int16_t                       dest_x,
+                                                int16_t                       dest_y,
+                                                uint16_t                      width,
+                                                uint16_t                      height);
 
 /*
  * Trapezoids
index 567d620..cee9609 100644 (file)
@@ -129,8 +129,8 @@ main (int argc, char **argv)
                                         dest,
                                         WIDTH * 4);
 
-    pixman_image_composite_rect (PIXMAN_OP_OVER, src_img, NULL, dest_img,
-                                0, 0, 0, 0, 0, 0, WIDTH, HEIGHT);
+    pixman_image_composite (PIXMAN_OP_OVER, src_img, NULL, dest_img,
+                           0, 0, 0, 0, 0, 0, WIDTH, HEIGHT);
 
 #if 0
     for (i = 0; i < WIDTH; ++i)
index 149d034..f6e3ca3 100644 (file)
@@ -129,8 +129,8 @@ main (int argc, char **argv)
 #endif
     pixman_image_set_transform (src_img, &trans);
     
-    pixman_image_composite_rect (PIXMAN_OP_OVER, src_img, NULL, dest_img,
-                                0, 0, 0, 0, 0, 0, WIDTH, HEIGHT);
+    pixman_image_composite (PIXMAN_OP_OVER, src_img, NULL, dest_img,
+                           0, 0, 0, 0, 0, 0, WIDTH, HEIGHT);
     
     printf ("0, 0: %x\n", dest[0]);
     printf ("10, 10: %x\n", dest[10 * 10 + 10]);