summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Sandmann Pedersen <ssp@redhat.com>2012-01-07 17:11:45 -0500
committerSøren Sandmann Pedersen <ssp@redhat.com>2012-01-10 09:04:36 -0500
commitab584ab500b4e7011a5b82051a90e2eea6744270 (patch)
treee42e5f9cf4fb9eb15db189fb93f89e7fb9a5ccbc
parent4613f2caac595b3fa1298ac49f9c9fdcd907f14a (diff)
test/alphamap.c: Make dst and orig_dst more independent of each other
When making the copy of the destination, do so separately for the image and the alpha map. This ensures that the alpha channel of the alpha map will be different from the alpha channel of the actual image. Previously, orig_dst would be copied onto dst along with its alpha map, which mean that the alpha map of orig_dst would become the new alpha channel of *both* dst and dst's alpha map. This meant that test didn't actually test that the alpha maps alpha channel was actually fetched.
-rw-r--r--test/alphamap.c59
1 files changed, 32 insertions, 27 deletions
diff --git a/test/alphamap.c b/test/alphamap.c
index 4435ad0..0c5757e 100644
--- a/test/alphamap.c
+++ b/test/alphamap.c
@@ -2,8 +2,8 @@
#include <stdlib.h>
#include "utils.h"
-#define WIDTH 100
-#define HEIGHT 100
+#define WIDTH 48
+#define HEIGHT 48
static const pixman_format_code_t formats[] =
{
@@ -70,24 +70,6 @@ make_image (pixman_format_code_t format)
return image;
}
-static pixman_image_t *
-create_image (pixman_format_code_t format, pixman_format_code_t alpha_format,
- int alpha_origin_x, int alpha_origin_y)
-{
- pixman_image_t *image = make_image (format);
-
- if (alpha_format != PIXMAN_null)
- {
- pixman_image_t *alpha = make_image (alpha_format);
-
- pixman_image_set_alpha_map (image, alpha,
- alpha_origin_x, alpha_origin_y);
- pixman_image_unref (alpha);
- }
-
- return image;
-}
-
static uint8_t
get_alpha (pixman_image_t *image, int x, int y, int orig_x, int orig_y)
{
@@ -185,7 +167,7 @@ run_test (int s, int d, int sa, int da, int soff, int doff)
pixman_format_code_t df = formats[d];
pixman_format_code_t saf = alpha_formats[sa];
pixman_format_code_t daf = alpha_formats[da];
- pixman_image_t *src, *dst, *orig_dst;
+ pixman_image_t *src, *dst, *orig_dst, *alpha, *orig_alpha;
pixman_transform_t t1;
int j, k;
int n_alpha_bits, n_red_bits;
@@ -199,9 +181,35 @@ run_test (int s, int d, int sa, int da, int soff, int doff)
n_red_bits = PIXMAN_FORMAT_R (df);
- src = create_image (sf, saf, soff, soff);
- orig_dst = create_image (df, daf, doff, doff);
- dst = create_image (df, daf, doff, doff);
+ /* Source */
+ src = make_image (sf);
+ if (saf != PIXMAN_null)
+ {
+ alpha = make_image (saf);
+ pixman_image_set_alpha_map (src, alpha, soff, soff);
+ pixman_image_unref (alpha);
+ }
+
+ /* Destination */
+ orig_dst = make_image (df);
+ dst = make_image (df);
+ pixman_image_composite (PIXMAN_OP_SRC, orig_dst, NULL, dst,
+ 0, 0, 0, 0, 0, 0, WIDTH, HEIGHT);
+
+ if (daf != PIXMAN_null)
+ {
+ orig_alpha = make_image (daf);
+ alpha = make_image (daf);
+
+ pixman_image_composite (PIXMAN_OP_SRC, orig_alpha, NULL, alpha,
+ 0, 0, 0, 0, 0, 0, WIDTH, HEIGHT);
+
+ pixman_image_set_alpha_map (orig_dst, orig_alpha, doff, doff);
+ pixman_image_set_alpha_map (dst, alpha, doff, doff);
+
+ pixman_image_unref (orig_alpha);
+ pixman_image_unref (alpha);
+ }
/* Transformations, repeats and filters on destinations should be ignored,
* so just set some random ones.
@@ -215,9 +223,6 @@ run_test (int s, int d, int sa, int da, int soff, int doff)
pixman_image_set_filter (dst, PIXMAN_FILTER_BILINEAR, NULL, 0);
pixman_image_set_repeat (dst, PIXMAN_REPEAT_REFLECT);
- pixman_image_composite (PIXMAN_OP_SRC, orig_dst, NULL, dst,
- 0, 0, 0, 0, 0, 0, WIDTH, HEIGHT);
-
pixman_image_composite (PIXMAN_OP_ADD, src, NULL, dst,
0, 0, 0, 0, 0, 0, WIDTH, HEIGHT);