summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Avison <bavison@riscosopen.org>2015-03-03 15:24:17 +0000
committerPekka Paalanen <pekka.paalanen@collabora.co.uk>2015-04-13 10:11:51 +0300
commitf122907dc1d18cdd7e11fec5e4f9c220c62e6e77 (patch)
treef7c66d7a5818525b148cb7d649ad8354ee263dec
parent9bc025f7cd6e37f5cc1a2c2799aea6850763a33f (diff)
test: Move format and operator string functions to utils.[ch]
This permits format_from_string(), list_formats(), list_operators() and operator_from_string() to be used from tests other than check-formats. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
-rw-r--r--test/check-formats.c192
-rw-r--r--test/utils.c193
-rw-r--r--test/utils.h12
3 files changed, 205 insertions, 192 deletions
diff --git a/test/check-formats.c b/test/check-formats.c
index 8eb263b..4e2633c 100644
--- a/test/check-formats.c
+++ b/test/check-formats.c
@@ -104,198 +104,6 @@ check_op (pixman_op_t op,
return retval;
}
-static const pixman_op_t op_list[] =
-{
- PIXMAN_OP_CLEAR,
- PIXMAN_OP_SRC,
- PIXMAN_OP_DST,
- PIXMAN_OP_OVER,
- PIXMAN_OP_OVER_REVERSE,
- PIXMAN_OP_IN,
- PIXMAN_OP_IN_REVERSE,
- PIXMAN_OP_OUT,
- PIXMAN_OP_OUT_REVERSE,
- PIXMAN_OP_ATOP,
- PIXMAN_OP_ATOP_REVERSE,
- PIXMAN_OP_XOR,
- PIXMAN_OP_ADD,
- PIXMAN_OP_SATURATE,
-
- PIXMAN_OP_DISJOINT_CLEAR,
- PIXMAN_OP_DISJOINT_SRC,
- PIXMAN_OP_DISJOINT_DST,
- PIXMAN_OP_DISJOINT_OVER,
- PIXMAN_OP_DISJOINT_OVER_REVERSE,
- PIXMAN_OP_DISJOINT_IN,
- PIXMAN_OP_DISJOINT_IN_REVERSE,
- PIXMAN_OP_DISJOINT_OUT,
- PIXMAN_OP_DISJOINT_OUT_REVERSE,
- PIXMAN_OP_DISJOINT_ATOP,
- PIXMAN_OP_DISJOINT_ATOP_REVERSE,
- PIXMAN_OP_DISJOINT_XOR,
-
- PIXMAN_OP_CONJOINT_CLEAR,
- PIXMAN_OP_CONJOINT_SRC,
- PIXMAN_OP_CONJOINT_DST,
- PIXMAN_OP_CONJOINT_OVER,
- PIXMAN_OP_CONJOINT_OVER_REVERSE,
- PIXMAN_OP_CONJOINT_IN,
- PIXMAN_OP_CONJOINT_IN_REVERSE,
- PIXMAN_OP_CONJOINT_OUT,
- PIXMAN_OP_CONJOINT_OUT_REVERSE,
- PIXMAN_OP_CONJOINT_ATOP,
- PIXMAN_OP_CONJOINT_ATOP_REVERSE,
- PIXMAN_OP_CONJOINT_XOR,
-
- PIXMAN_OP_MULTIPLY,
- PIXMAN_OP_SCREEN,
- PIXMAN_OP_OVERLAY,
- PIXMAN_OP_DARKEN,
- PIXMAN_OP_LIGHTEN,
- PIXMAN_OP_COLOR_DODGE,
- PIXMAN_OP_COLOR_BURN,
- PIXMAN_OP_HARD_LIGHT,
- PIXMAN_OP_SOFT_LIGHT,
- PIXMAN_OP_DIFFERENCE,
- PIXMAN_OP_EXCLUSION,
- PIXMAN_OP_HSL_HUE,
- PIXMAN_OP_HSL_SATURATION,
- PIXMAN_OP_HSL_COLOR,
- PIXMAN_OP_HSL_LUMINOSITY
-};
-
-static const pixman_format_code_t format_list[] =
-{
- PIXMAN_a8r8g8b8,
- PIXMAN_x8r8g8b8,
- PIXMAN_a8b8g8r8,
- PIXMAN_x8b8g8r8,
- PIXMAN_b8g8r8a8,
- PIXMAN_b8g8r8x8,
- PIXMAN_r8g8b8a8,
- PIXMAN_r8g8b8x8,
- PIXMAN_x14r6g6b6,
- PIXMAN_x2r10g10b10,
- PIXMAN_a2r10g10b10,
- PIXMAN_x2b10g10r10,
- PIXMAN_a2b10g10r10,
- PIXMAN_a8r8g8b8_sRGB,
- PIXMAN_r8g8b8,
- PIXMAN_b8g8r8,
- PIXMAN_r5g6b5,
- PIXMAN_b5g6r5,
- PIXMAN_a1r5g5b5,
- PIXMAN_x1r5g5b5,
- PIXMAN_a1b5g5r5,
- PIXMAN_x1b5g5r5,
- PIXMAN_a4r4g4b4,
- PIXMAN_x4r4g4b4,
- PIXMAN_a4b4g4r4,
- PIXMAN_x4b4g4r4,
- PIXMAN_a8,
- PIXMAN_r3g3b2,
- PIXMAN_b2g3r3,
- PIXMAN_a2r2g2b2,
- PIXMAN_a2b2g2r2,
- PIXMAN_x4a4,
- PIXMAN_a4,
- PIXMAN_r1g2b1,
- PIXMAN_b1g2r1,
- PIXMAN_a1r1g1b1,
- PIXMAN_a1b1g1r1,
- PIXMAN_a1,
-};
-
-static pixman_format_code_t
-format_from_string (const char *s)
-{
- int i;
-
- for (i = 0; i < ARRAY_LENGTH (format_list); ++i)
- {
- if (strcasecmp (format_name (format_list[i]), s) == 0)
- return format_list[i];
- }
-
- return PIXMAN_null;
-}
-
-static void
-emit (const char *s, int *n_chars)
-{
- *n_chars += printf ("%s,", s);
- if (*n_chars > 60)
- {
- printf ("\n ");
- *n_chars = 0;
- }
- else
- {
- printf (" ");
- (*n_chars)++;
- }
-}
-
-static void
-list_formats (void)
-{
- int n_chars;
- int i;
-
- printf ("Formats:\n ");
-
- n_chars = 0;
- for (i = 0; i < ARRAY_LENGTH (format_list); ++i)
- emit (format_name (format_list[i]), &n_chars);
-
- printf ("\n\n");
-}
-
-static void
-list_operators (void)
-{
- char short_name [128] = { 0 };
- int i, n_chars;
-
- printf ("Operators:\n ");
-
- n_chars = 0;
- for (i = 0; i < ARRAY_LENGTH (op_list); ++i)
- {
- pixman_op_t op = op_list[i];
- int j;
-
- snprintf (short_name, sizeof (short_name) - 1, "%s",
- operator_name (op) + strlen ("PIXMAN_OP_"));
-
- for (j = 0; short_name[j] != '\0'; ++j)
- short_name[j] = tolower (short_name[j]);
-
- emit (short_name, &n_chars);
- }
-
- printf ("\n\n");
-}
-
-static pixman_op_t
-operator_from_string (const char *s)
-{
- char full_name[128] = { 0 };
- int i;
-
- snprintf (full_name, (sizeof full_name) - 1, "PIXMAN_OP_%s", s);
-
- for (i = 0; i < ARRAY_LENGTH (op_list); ++i)
- {
- pixman_op_t op = op_list[i];
-
- if (strcasecmp (operator_name (op), full_name) == 0)
- return op;
- }
-
- return PIXMAN_OP_NONE;
-}
-
int
main (int argc, char **argv)
{
diff --git a/test/utils.c b/test/utils.c
index ab3424f..efec632 100644
--- a/test/utils.c
+++ b/test/utils.c
@@ -5,6 +5,7 @@
#include <signal.h>
#include <stdlib.h>
#include <float.h>
+#include <ctype.h>
#ifdef HAVE_GETTIMEOFDAY
#include <sys/time.h>
@@ -948,6 +949,198 @@ initialize_palette (pixman_indexed_t *palette, uint32_t depth, int is_rgb)
}
}
+static const pixman_op_t op_list[] =
+{
+ PIXMAN_OP_CLEAR,
+ PIXMAN_OP_SRC,
+ PIXMAN_OP_DST,
+ PIXMAN_OP_OVER,
+ PIXMAN_OP_OVER_REVERSE,
+ PIXMAN_OP_IN,
+ PIXMAN_OP_IN_REVERSE,
+ PIXMAN_OP_OUT,
+ PIXMAN_OP_OUT_REVERSE,
+ PIXMAN_OP_ATOP,
+ PIXMAN_OP_ATOP_REVERSE,
+ PIXMAN_OP_XOR,
+ PIXMAN_OP_ADD,
+ PIXMAN_OP_SATURATE,
+
+ PIXMAN_OP_DISJOINT_CLEAR,
+ PIXMAN_OP_DISJOINT_SRC,
+ PIXMAN_OP_DISJOINT_DST,
+ PIXMAN_OP_DISJOINT_OVER,
+ PIXMAN_OP_DISJOINT_OVER_REVERSE,
+ PIXMAN_OP_DISJOINT_IN,
+ PIXMAN_OP_DISJOINT_IN_REVERSE,
+ PIXMAN_OP_DISJOINT_OUT,
+ PIXMAN_OP_DISJOINT_OUT_REVERSE,
+ PIXMAN_OP_DISJOINT_ATOP,
+ PIXMAN_OP_DISJOINT_ATOP_REVERSE,
+ PIXMAN_OP_DISJOINT_XOR,
+
+ PIXMAN_OP_CONJOINT_CLEAR,
+ PIXMAN_OP_CONJOINT_SRC,
+ PIXMAN_OP_CONJOINT_DST,
+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b4,
+ PIXMAN_x4r4g4b4,
+ PIXMAN_a4b4g4r4,
+ PIXMAN_x4b4g4r4,
+ PIXMAN_a8,
+ PIXMAN_r3g3b2,
+ PIXMAN_b2g3r3,
+ PIXMAN_a2r2g2b2,
+ PIXMAN_a2b2g2r2,
+ PIXMAN_x4a4,
+ PIXMAN_a4,
+ PIXMAN_r1g2b1,
+ PIXMAN_b1g2r1,
+ PIXMAN_a1r1g1b1,
+ PIXMAN_a1b1g1r1,
+ PIXMAN_a1,
+};
+
+pixman_format_code_t
+format_from_string (const char *s)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_LENGTH (format_list); ++i)
+ {
+ if (strcasecmp (format_name (format_list[i]), s) == 0)
+ return format_list[i];
+ }
+
+ return PIXMAN_null;
+}
+
+static void
+emit (const char *s, int *n_chars)
+{
+ *n_chars += printf ("%s,", s);
+ if (*n_chars > 60)
+ {
+ printf ("\n ");
+ *n_chars = 0;
+ }
+ else
+ {
+ printf (" ");
+ (*n_chars)++;
+ }
+}
+
+void
+list_formats (void)
+{
+ int n_chars;
+ int i;
+
+ printf ("Formats:\n ");
+
+ n_chars = 0;
+ for (i = 0; i < ARRAY_LENGTH (format_list); ++i)
+ emit (format_name (format_list[i]), &n_chars);
+
+ printf ("\n\n");
+}
+
+void
+list_operators (void)
+{
+ char short_name [128] = { 0 };
+ int i, n_chars;
+
+ printf ("Operators:\n ");
+
+ n_chars = 0;
+ for (i = 0; i < ARRAY_LENGTH (op_list); ++i)
+ {
+ pixman_op_t op = op_list[i];
+ int j;
+
+ snprintf (short_name, sizeof (short_name) - 1, "%s",
+ operator_name (op) + strlen ("PIXMAN_OP_"));
+
+ for (j = 0; short_name[j] != '\0'; ++j)
+ short_name[j] = tolower (short_name[j]);
+
+ emit (short_name, &n_chars);
+ }
+
+ printf ("\n\n");
+}
+
+pixman_op_t
+operator_from_string (const char *s)
+{
+ char full_name[128] = { 0 };
+ int i;
+
+ snprintf (full_name, (sizeof full_name) - 1, "PIXMAN_OP_%s", s);
+
+ for (i = 0; i < ARRAY_LENGTH (op_list); ++i)
+ {
+ pixman_op_t op = op_list[i];
+
+ if (strcasecmp (operator_name (op), full_name) == 0)
+ return op;
+ }
+
+ return PIXMAN_OP_NONE;
+}
+
const char *
operator_name (pixman_op_t op)
{
diff --git a/test/utils.h b/test/utils.h
index 6804334..fc10524 100644
--- a/test/utils.h
+++ b/test/utils.h
@@ -187,6 +187,18 @@ convert_linear_to_srgb (double component);
void
initialize_palette (pixman_indexed_t *palette, uint32_t depth, int is_rgb);
+pixman_format_code_t
+format_from_string (const char *s);
+
+void
+list_formats (void);
+
+void
+list_operators (void);
+
+pixman_op_t
+operator_from_string (const char *s);
+
const char *
operator_name (pixman_op_t op);