summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/blitters-test.c31
-rw-r--r--test/utils.c39
-rw-r--r--test/utils.h7
3 files changed, 46 insertions, 31 deletions
diff --git a/test/blitters-test.c b/test/blitters-test.c
index feea308c..6a3cc864 100644
--- a/test/blitters-test.c
+++ b/test/blitters-test.c
@@ -83,39 +83,10 @@ free_random_image (uint32_t initcrc,
pixman_format_code_t fmt)
{
uint32_t crc32 = 0;
- int stride = pixman_image_get_stride (img);
uint32_t *data = pixman_image_get_data (img);
- int height = pixman_image_get_height (img);
if (fmt != PIXMAN_null)
- {
- /* mask unused 'x' part */
- if (PIXMAN_FORMAT_BPP (fmt) - PIXMAN_FORMAT_DEPTH (fmt) &&
- PIXMAN_FORMAT_DEPTH (fmt) != 0)
- {
- int i;
- uint32_t *data = pixman_image_get_data (img);
- uint32_t mask = (1 << PIXMAN_FORMAT_DEPTH (fmt)) - 1;
-
- if (PIXMAN_FORMAT_TYPE (fmt) == PIXMAN_TYPE_BGRA ||
- PIXMAN_FORMAT_TYPE (fmt) == PIXMAN_TYPE_RGBA)
- {
- mask <<= (PIXMAN_FORMAT_BPP (fmt) - PIXMAN_FORMAT_DEPTH (fmt));
- }
-
- for (i = 0; i * PIXMAN_FORMAT_BPP (fmt) < 32; i++)
- mask |= mask << (i * PIXMAN_FORMAT_BPP (fmt));
-
- for (i = 0; i < stride * height / 4; i++)
- data[i] &= mask;
- }
-
- /* swap endiannes in order to provide identical results on both big
- * and litte endian systems
- */
- image_endian_swap (img);
- crc32 = compute_crc32 (initcrc, data, stride * height);
- }
+ crc32 = compute_crc32_for_image (initcrc, img);
pixman_image_unref (img);
free (data);
diff --git a/test/utils.c b/test/utils.c
index c1bf6dc2..fcf9a362 100644
--- a/test/utils.c
+++ b/test/utils.c
@@ -135,6 +135,45 @@ compute_crc32 (uint32_t in_crc32,
return (crc32 ^ 0xFFFFFFFF);
}
+uint32_t
+compute_crc32_for_image (uint32_t in_crc32,
+ pixman_image_t *img)
+{
+ pixman_format_code_t fmt = pixman_image_get_format (img);
+ uint32_t *data = pixman_image_get_data (img);
+ int stride = pixman_image_get_stride (img);
+ int height = pixman_image_get_height (img);
+ uint32_t crc32;
+
+ /* mask unused 'x' part */
+ if (PIXMAN_FORMAT_BPP (fmt) - PIXMAN_FORMAT_DEPTH (fmt) &&
+ PIXMAN_FORMAT_DEPTH (fmt) != 0)
+ {
+ uint32_t mask = (1 << PIXMAN_FORMAT_DEPTH (fmt)) - 1;
+ int i;
+
+ if (PIXMAN_FORMAT_TYPE (fmt) == PIXMAN_TYPE_BGRA ||
+ PIXMAN_FORMAT_TYPE (fmt) == PIXMAN_TYPE_RGBA)
+ {
+ mask <<= (PIXMAN_FORMAT_BPP (fmt) - PIXMAN_FORMAT_DEPTH (fmt));
+ }
+
+ for (i = 0; i * PIXMAN_FORMAT_BPP (fmt) < 32; i++)
+ mask |= mask << (i * PIXMAN_FORMAT_BPP (fmt));
+
+ for (i = 0; i < stride * height / 4; i++)
+ data[i] &= mask;
+ }
+
+ /* swap endiannes in order to provide identical results on both big
+ * and litte endian systems
+ */
+ image_endian_swap (img);
+ crc32 = compute_crc32 (in_crc32, data, stride * height);
+
+ return crc32;
+}
+
pixman_bool_t
is_little_endian (void)
{
diff --git a/test/utils.h b/test/utils.h
index 01af316d..ac2decd1 100644
--- a/test/utils.h
+++ b/test/utils.h
@@ -63,7 +63,12 @@ compute_crc32 (uint32_t in_crc32,
const void *buf,
size_t buf_len);
-/* Returns TRUE if running on a little endian system */
+uint32_t
+compute_crc32_for_image (uint32_t in_crc32,
+ pixman_image_t *image);
+
+/* Returns TRUE if running on a little endian system
+ */
pixman_bool_t
is_little_endian (void);