diff options
author | Søren Sandmann Pedersen <ssp@redhat.com> | 2011-12-22 18:15:02 -0500 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@redhat.com> | 2012-01-10 09:04:45 -0500 |
commit | 55a010bf31d2eaf71126bdf93eca99fc02037535 (patch) | |
tree | 0b0a2358abe2b88f85601aa658f28a6dbac58cef | |
parent | 065666f33c414582425e4ac0ec9f694e93c2baf1 (diff) |
Move the color_correct() function from composite.c to utils.c
-rw-r--r-- | test/composite.c | 36 | ||||
-rw-r--r-- | test/utils.c | 30 | ||||
-rw-r--r-- | 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 <time.h> #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); |