Fix various stupid mistakes, such as inverted return_if_fail() tests
authorSoren Sandmann Pedersen <ssp@dhcp83-218.boston.redhat.com>
Wed, 9 May 2007 18:20:57 +0000 (14:20 -0400)
committerSoren Sandmann Pedersen <ssp@dhcp83-218.boston.redhat.com>
Wed, 9 May 2007 18:20:57 +0000 (14:20 -0400)
and only allocating space for a pointer instead of an image.

pixman/pixman-compose.c
pixman/pixman-image.c
pixman/pixman-private.h
test/composite-test.c

index 632197e..e5e4793 100644 (file)
@@ -1880,7 +1880,7 @@ static storeProc storeProcForPicture (bits_image_t * pict)
  * Combine src and mask
  */
 static FASTCALL void
-fbCombineMaskU (uint32_t *src, const uint32_t *mask, int width)
+pixman_fbCombineMaskU (uint32_t *src, const uint32_t *mask, int width)
 {
     int i;
     for (i = 0; i < width; ++i) {
@@ -2372,7 +2372,7 @@ fbCombineConjointXorU (uint32_t *dest, const uint32_t *src, int width)
     fbCombineConjointGeneralU (dest, src, width, CombineXor);
 }
 
-static CombineFuncU fbCombineFuncU[] = {
+static CombineFuncU pixman_fbCombineFuncU[] = {
     fbCombineClear,
     fbCombineSrcU,
     NULL, /* CombineDst */
@@ -3050,7 +3050,7 @@ fbCombineConjointXorC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
     fbCombineConjointGeneralC (dest, src, mask, width, CombineXor);
 }
 
-static CombineFuncC fbCombineFuncC[] = {
+static CombineFuncC pixman_fbCombineFuncC[] = {
     fbCombineClearC,
     fbCombineSrcC,
     NULL, /* Dest */
@@ -3098,10 +3098,10 @@ static CombineFuncC fbCombineFuncC[] = {
 };
 
 
-FbComposeFunctions composeFunctions = {
-    fbCombineFuncU,
-    fbCombineFuncC,
-    fbCombineMaskU
+FbComposeFunctions pixman_composeFunctions = {
+    pixman_fbCombineFuncU,
+    pixman_fbCombineFuncC,
+    pixman_fbCombineMaskU
 };
 
 
@@ -4382,7 +4382,7 @@ typedef void (*scanFetchProc)(pixman_image_t *, int, int, int, uint32_t *,
                              uint32_t *, uint32_t);
 
 void
-fbCompositeRect (const FbComposeData *data, uint32_t *scanline_buffer)
+pixmanCompositeRect (const FbComposeData *data, uint32_t *scanline_buffer)
 {
     uint32_t *src_buffer = scanline_buffer;
     uint32_t *dest_buffer = src_buffer + data->width;
@@ -4508,13 +4508,6 @@ fbCompositeRect (const FbComposeData *data, uint32_t *scanline_buffer)
     
     if (!store)
     {
-#if 0
-       int bpp;
-       
-#if 0
-       fbGetDrawable (data->dest->pDrawable, bits, stride, bpp, xoff, yoff);
-#endif
-#endif
        bits = data->dest->bits.bits;
        stride = data->dest->bits.rowstride;
        xoff = yoff = 0;
@@ -4534,7 +4527,7 @@ fbCompositeRect (const FbComposeData *data, uint32_t *scanline_buffer)
        PIXMAN_FORMAT_RGB (data->mask->bits.format))
     {
        uint32_t *mask_buffer = dest_buffer + data->width;
-       CombineFuncC compose = composeFunctions.combineC[data->op];
+       CombineFuncC compose = pixman_composeFunctions.combineC[data->op];
        if (!compose)
            return;
        
@@ -4598,7 +4591,7 @@ fbCompositeRect (const FbComposeData *data, uint32_t *scanline_buffer)
     else
     {
        uint32_t *src_mask_buffer = 0, *mask_buffer = 0;
-       CombineFuncU compose = composeFunctions.combineU[data->op];
+       CombineFuncU compose = pixman_composeFunctions.combineU[data->op];
        if (!compose)
            return;
        
@@ -4642,7 +4635,7 @@ fbCompositeRect (const FbComposeData *data, uint32_t *scanline_buffer)
                              0xff000000);
                    
                    if (mask_buffer)
-                       composeFunctions.combineMaskU (src_buffer,
+                       pixman_composeFunctions.combineMaskU (src_buffer,
                                                       mask_buffer,
                                                       data->width);
                    
index e0c98e6..2031243 100644 (file)
@@ -76,7 +76,7 @@ color_to_uint32 (const pixman_color_t *color)
 static pixman_image_t *
 allocate_image (void)
 {
-    pixman_image_t *image = malloc (sizeof (pixman_image_t *));
+    pixman_image_t *image = malloc (sizeof (pixman_image_t));
 
     if (image)
     {
@@ -154,7 +154,7 @@ pixman_image_create_linear_gradient (pixman_point_fixed_t         *p1,
     pixman_image_t *image;
     linear_gradient_t *linear;
 
-    return_val_if_fail (n_stops < 2, NULL);
+    return_val_if_fail (n_stops >= 2, NULL);
     
     image = allocate_image();
     
@@ -189,7 +189,7 @@ pixman_image_create_radial_gradient (pixman_point_fixed_t         *inner,
     pixman_image_t *image;
     radial_gradient_t *radial;
 
-    return_val_if_fail (n_stops < 2, NULL);
+    return_val_if_fail (n_stops >= 2, NULL);
     
     image = allocate_image();
 
@@ -282,7 +282,7 @@ pixman_image_set_clip_region (pixman_image_t    *image,
 {
     image_common_t *common = (image_common_t *)image;
 
-    if (!region)
+    if (region)
     {
        pixman_region_copy (&common->clip_region, region);
     }
@@ -407,6 +407,9 @@ pixman_image_composite (pixman_op_t  op,
     uint32_t _scanline_buffer[SCANLINE_BUFFER_LENGTH * 3];
     uint32_t *scanline_buffer = _scanline_buffer;
 
+    return_if_fail (src_img != NULL);
+    return_if_fail (dest_img != NULL);
+    
     if (width > SCANLINE_BUFFER_LENGTH)
     {
        scanline_buffer = (uint32_t *)malloc (width * 3 * sizeof (uint32_t));
@@ -428,7 +431,7 @@ pixman_image_composite (pixman_op_t  op,
     compose_data.width = width;
     compose_data.height = height;
 
-    fbCompositeRect (&compose_data, scanline_buffer);
+    pixmanCompositeRect (&compose_data, scanline_buffer);
 
     if (scanline_buffer != _scanline_buffer)
        free (scanline_buffer);
index 4299b58..700cddf 100644 (file)
@@ -205,8 +205,8 @@ union pixman_image
 
 int PictureTransformPoint3d (pixman_transform_t *trans,
                             pixman_vector_t *vector);
-void fbCompositeRect (const FbComposeData *data,
-                     uint32_t *scanline_buffer);
+void pixmanCompositeRect (const FbComposeData *data,
+                         uint32_t *scanline_buffer);
 
 
 
index 0dd8f8e..798b06a 100644 (file)
@@ -31,5 +31,8 @@ main ()
     pixman_image_composite (PIXMAN_OP_OVER, src_img, NULL, dest_img,
                            0, 0, 0, 0, 0, 0, 10, 10);
 
+    pixman_image_unref (src_img);
+    pixman_image_unref (dest_img);
+    
     return 0;
 }