From 55a010bf31d2eaf71126bdf93eca99fc02037535 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=B8ren=20Sandmann=20Pedersen?= Date: Thu, 22 Dec 2011 18:15:02 -0500 Subject: [PATCH] Move the color_correct() function from composite.c to utils.c --- test/composite.c | 36 ------------------------------------ test/utils.c | 30 ++++++++++++++++++++++++++++++ test/utils.h | 9 +++++++++ 3 files changed, 39 insertions(+), 36 deletions(-) diff --git a/test/composite.c b/test/composite.c index fe59eae..edf7257 100644 --- a/test/composite.c +++ b/test/composite.c @@ -28,16 +28,10 @@ #include #include "utils.h" -typedef struct color_t color_t; typedef struct format_t format_t; typedef struct image_t image_t; typedef struct operator_t operator_t; -struct color_t -{ - double r, g, b, a; -}; - struct format_t { pixman_format_code_t format; @@ -481,36 +475,6 @@ do_composite (pixman_op_t op, } static void -color_correct (pixman_format_code_t format, - color_t *color) -{ -#define MASK(x) ((1 << (x)) - 1) -#define round_pix(pix, m) \ - ((int)((pix) * (MASK(m)) + .5) / (double) (MASK(m))) - - if (PIXMAN_FORMAT_R (format) == 0) - { - color->r = 0.0; - color->g = 0.0; - color->b = 0.0; - } - else - { - color->r = round_pix (color->r, PIXMAN_FORMAT_R (format)); - color->g = round_pix (color->g, PIXMAN_FORMAT_G (format)); - color->b = round_pix (color->b, PIXMAN_FORMAT_B (format)); - } - - if (PIXMAN_FORMAT_A (format) == 0) - color->a = 1.0; - else - color->a = round_pix (color->a, PIXMAN_FORMAT_A (format)); - -#undef round_pix -#undef MASK -} - -static void get_pixel (pixman_image_t *image, pixman_format_code_t format, color_t *color) diff --git a/test/utils.c b/test/utils.c index 204066f..038fd2b 100644 --- a/test/utils.c +++ b/test/utils.c @@ -703,3 +703,33 @@ initialize_palette (pixman_indexed_t *palette, uint32_t depth, int is_rgb) assert (palette->ent[CONVERT_15 (palette->rgba[i], is_rgb)] == i); } } + +void +color_correct (pixman_format_code_t format, + color_t *color) +{ +#define MASK(x) ((1 << (x)) - 1) +#define round_pix(pix, m) \ + ((int)((pix) * (MASK(m)) + .5) / (double) (MASK(m))) + + if (PIXMAN_FORMAT_R (format) == 0) + { + color->r = 0.0; + color->g = 0.0; + color->b = 0.0; + } + else + { + color->r = round_pix (color->r, PIXMAN_FORMAT_R (format)); + color->g = round_pix (color->g, PIXMAN_FORMAT_G (format)); + color->b = round_pix (color->b, PIXMAN_FORMAT_B (format)); + } + + if (PIXMAN_FORMAT_A (format) == 0) + color->a = 1.0; + else + color->a = round_pix (color->a, PIXMAN_FORMAT_A (format)); + +#undef round_pix +#undef MASK +} diff --git a/test/utils.h b/test/utils.h index 3bff78e..fbbd30b 100644 --- a/test/utils.h +++ b/test/utils.h @@ -151,3 +151,12 @@ aligned_malloc (size_t align, size_t size); void initialize_palette (pixman_indexed_t *palette, uint32_t depth, int is_rgb); + +typedef struct +{ + double r, g, b, a; +} color_t; + +void +color_correct (pixman_format_code_t format, + color_t *color); -- 2.7.4