summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Sandmann Pedersen <ssp@redhat.com>2013-01-22 11:57:53 -0500
committerSøren Sandmann Pedersen <ssp@redhat.com>2013-02-13 02:18:01 -0500
commit5eb61f72ea50e02eb185c746108909945b589e65 (patch)
treede877054dce837eea630ea3afcf3d6743382a7d4
parent3ae717f71a31620a5cb28792b9effd0c69ffb822 (diff)
test/utils.[ch]: Add pixel_checker_convert_pixel_to_color()
This function takes a pixel in the format corresponding to the pixel checker, and converts to a color_t.
-rw-r--r--test/utils.c36
-rw-r--r--test/utils.h4
2 files changed, 40 insertions, 0 deletions
diff --git a/test/utils.c b/test/utils.c
index 27d8fd9..eed2476 100644
--- a/test/utils.c
+++ b/test/utils.c
@@ -1421,6 +1421,42 @@ pixel_checker_split_pixel (const pixel_checker_t *checker, uint32_t pixel,
*b = (pixel & checker->bm) >> checker->bs;
}
+void
+pixel_checker_convert_pixel_to_color (const pixel_checker_t *checker,
+ uint32_t pixel, color_t *color)
+{
+ int a, r, g, b;
+
+ pixel_checker_split_pixel (checker, pixel, &a, &r, &g, &b);
+
+ if (checker->am == 0)
+ color->a = 1.0;
+ else
+ color->a = a / (double)(checker->am >> checker->as);
+
+ if (checker->rm == 0)
+ color->r = 0.0;
+ else
+ color->r = r / (double)(checker->rm >> checker->rs);
+
+ if (checker->gm == 0)
+ color->g = 0.0;
+ else
+ color->g = g / (double)(checker->gm >> checker->gs);
+
+ if (checker->bm == 0)
+ color->b = 0.0;
+ else
+ color->b = b / (double)(checker->bm >> checker->bs);
+
+ if (PIXMAN_FORMAT_TYPE (checker->format) == PIXMAN_TYPE_ARGB_SRGB)
+ {
+ color->r = convert_srgb_to_linear (color->r);
+ color->g = convert_srgb_to_linear (color->g);
+ color->b = convert_srgb_to_linear (color->b);
+ }
+}
+
static int32_t
convert (double v, uint32_t width, uint32_t mask, uint32_t shift, double def)
{
diff --git a/test/utils.h b/test/utils.h
index 162aacb..f6dc193 100644
--- a/test/utils.h
+++ b/test/utils.h
@@ -225,3 +225,7 @@ pixel_checker_get_min (const pixel_checker_t *checker, color_t *color,
pixman_bool_t
pixel_checker_check (const pixel_checker_t *checker,
uint32_t pixel, color_t *color);
+
+void
+pixel_checker_convert_pixel_to_color (const pixel_checker_t *checker,
+ uint32_t pixel, color_t *color);