test: Move image_endian_swap() from blitters-test.c to utils.[ch]
authorSøren Sandmann Pedersen <sandmann@redhat.com>
Tue, 10 Nov 2009 20:48:36 +0000 (15:48 -0500)
committerSøren Sandmann Pedersen <sandmann@redhat.com>
Tue, 17 Nov 2009 05:32:03 +0000 (00:32 -0500)
test/blitters-test.c
test/scaling-test.c
test/utils.c
test/utils.h

index 80fc8fa..979af24 100644 (file)
@@ -44,88 +44,6 @@ aligned_malloc (size_t align, size_t size)
     return result;
 }
 
-/* perform endian conversion of pixel data */
-static void
-image_endian_swap (pixman_image_t *img, int bpp)
-{
-    int stride = pixman_image_get_stride (img);
-    uint32_t *data = pixman_image_get_data (img);
-    int height = pixman_image_get_height (img);
-    int i, j;
-
-    /* swap bytes only on big endian systems */
-    volatile uint16_t endian_check_var = 0x1234;
-    if (*(volatile uint8_t *)&endian_check_var != 0x12)
-       return;
-
-    for (i = 0; i < height; i++)
-    {
-       uint8_t *line_data = (uint8_t *)data + stride * i;
-       /* swap bytes only for 16, 24 and 32 bpp for now */
-       switch (bpp)
-       {
-       case 1:
-           for (j = 0; j < stride; j++)
-           {
-               line_data[j] =
-                   ((line_data[j] & 0x80) >> 7) |
-                   ((line_data[j] & 0x40) >> 5) |
-                   ((line_data[j] & 0x20) >> 3) |
-                   ((line_data[j] & 0x10) >> 1) |
-                   ((line_data[j] & 0x08) << 1) |
-                   ((line_data[j] & 0x04) << 3) |
-                   ((line_data[j] & 0x02) << 5) |
-                   ((line_data[j] & 0x01) << 7);
-           }
-           break;
-       case 4:
-           for (j = 0; j < stride; j++)
-           {
-               line_data[j] = (line_data[j] >> 4) | (line_data[j] << 4);
-           }
-           break;
-       case 16:
-           for (j = 0; j + 2 <= stride; j += 2)
-           {
-               char t1 = line_data[j + 0];
-               char t2 = line_data[j + 1];
-
-               line_data[j + 1] = t1;
-               line_data[j + 0] = t2;
-           }
-           break;
-       case 24:
-           for (j = 0; j + 3 <= stride; j += 3)
-           {
-               char t1 = line_data[j + 0];
-               char t2 = line_data[j + 1];
-               char t3 = line_data[j + 2];
-
-               line_data[j + 2] = t1;
-               line_data[j + 1] = t2;
-               line_data[j + 0] = t3;
-           }
-           break;
-       case 32:
-           for (j = 0; j + 4 <= stride; j += 4)
-           {
-               char t1 = line_data[j + 0];
-               char t2 = line_data[j + 1];
-               char t3 = line_data[j + 2];
-               char t4 = line_data[j + 3];
-
-               line_data[j + 3] = t1;
-               line_data[j + 2] = t2;
-               line_data[j + 1] = t3;
-               line_data[j + 0] = t4;
-           }
-           break;
-       default:
-           break;
-       }
-    }
-}
-
 /* Create random image for testing purposes */
 static pixman_image_t *
 create_random_image (pixman_format_code_t *allowed_formats,
index 296b986..2977290 100644 (file)
 #include <stdio.h>
 #include "utils.h"
 
-/* perform endian conversion of pixel data */
-static void
-image_endian_swap (pixman_image_t *img,
-                  int             bpp)
-{
-    int       stride = pixman_image_get_stride (img);
-    uint32_t *data = pixman_image_get_data (img);
-    int       height = pixman_image_get_height (img);
-    int i, j;
-
-    /* swap bytes only on big endian systems */
-    volatile uint16_t endian_check_var = 0x1234;
-    if (*(volatile uint8_t *)&endian_check_var != 0x12)
-       return;
-
-    for (i = 0; i < height; i++)
-    {
-       char *line_data = (char *)data + stride * i;
-
-       /* swap bytes only for 16, 24 and 32 bpp for now */
-       switch (bpp)
-       {
-       case 16:
-           for (j = 0; j + 2 <= stride; j += 2)
-           {
-               char t1 = line_data[j + 0];
-               char t2 = line_data[j + 1];
-               line_data[j + 1] = t1;
-               line_data[j + 0] = t2;
-           }
-           break;
-
-       case 24:
-           for (j = 0; j + 3 <= stride; j += 3)
-           {
-               char t1 = line_data[j + 0];
-               char t2 = line_data[j + 1];
-               char t3 = line_data[j + 2];
-               line_data[j + 2] = t1;
-               line_data[j + 1] = t2;
-               line_data[j + 0] = t3;
-           }
-           break;
-
-       case 32:
-           for (j = 0; j + 4 <= stride; j += 4)
-           {
-               char t1 = line_data[j + 0];
-               char t2 = line_data[j + 1];
-               char t3 = line_data[j + 2];
-               char t4 = line_data[j + 3];
-               line_data[j + 3] = t1;
-               line_data[j + 2] = t2;
-               line_data[j + 1] = t3;
-               line_data[j + 0] = t4;
-           }
-           break;
-
-       default:
-           break;
-       }
-    }
-}
-
 #define MAX_SRC_WIDTH  10
 #define MAX_SRC_HEIGHT 10
 #define MAX_DST_WIDTH  10
index afd2a18..1e42d89 100644 (file)
@@ -109,3 +109,86 @@ compute_crc32 (uint32_t    in_crc32,
     return (crc32 ^ 0xFFFFFFFF);
 }
 
+/* perform endian conversion of pixel data
+ */
+void
+image_endian_swap (pixman_image_t *img, int bpp)
+{
+    int stride = pixman_image_get_stride (img);
+    uint32_t *data = pixman_image_get_data (img);
+    int height = pixman_image_get_height (img);
+    int i, j;
+
+    /* swap bytes only on big endian systems */
+    volatile uint16_t endian_check_var = 0x1234;
+    if (*(volatile uint8_t *)&endian_check_var != 0x12)
+       return;
+
+    for (i = 0; i < height; i++)
+    {
+       uint8_t *line_data = (uint8_t *)data + stride * i;
+       /* swap bytes only for 16, 24 and 32 bpp for now */
+       switch (bpp)
+       {
+       case 1:
+           for (j = 0; j < stride; j++)
+           {
+               line_data[j] =
+                   ((line_data[j] & 0x80) >> 7) |
+                   ((line_data[j] & 0x40) >> 5) |
+                   ((line_data[j] & 0x20) >> 3) |
+                   ((line_data[j] & 0x10) >> 1) |
+                   ((line_data[j] & 0x08) << 1) |
+                   ((line_data[j] & 0x04) << 3) |
+                   ((line_data[j] & 0x02) << 5) |
+                   ((line_data[j] & 0x01) << 7);
+           }
+           break;
+       case 4:
+           for (j = 0; j < stride; j++)
+           {
+               line_data[j] = (line_data[j] >> 4) | (line_data[j] << 4);
+           }
+           break;
+       case 16:
+           for (j = 0; j + 2 <= stride; j += 2)
+           {
+               char t1 = line_data[j + 0];
+               char t2 = line_data[j + 1];
+
+               line_data[j + 1] = t1;
+               line_data[j + 0] = t2;
+           }
+           break;
+       case 24:
+           for (j = 0; j + 3 <= stride; j += 3)
+           {
+               char t1 = line_data[j + 0];
+               char t2 = line_data[j + 1];
+               char t3 = line_data[j + 2];
+
+               line_data[j + 2] = t1;
+               line_data[j + 1] = t2;
+               line_data[j + 0] = t3;
+           }
+           break;
+       case 32:
+           for (j = 0; j + 4 <= stride; j += 4)
+           {
+               char t1 = line_data[j + 0];
+               char t2 = line_data[j + 1];
+               char t3 = line_data[j + 2];
+               char t4 = line_data[j + 3];
+
+               line_data[j + 3] = t1;
+               line_data[j + 2] = t2;
+               line_data[j + 1] = t3;
+               line_data[j + 0] = t4;
+           }
+           break;
+       default:
+           break;
+       }
+    }
+}
+
index 2d340d1..8fdb2ce 100644 (file)
@@ -35,3 +35,7 @@ compute_crc32 (uint32_t    in_crc32,
               const void *buf,
               size_t      buf_len);
 
+/* perform endian conversion of pixel data
+ */
+void
+image_endian_swap (pixman_image_t *img, int bpp);