pixman: Branch 'master' - 7 commits

Pekka Paalanen pq at kemper.freedesktop.org
Thu Apr 16 06:06:23 PDT 2015


 test/check-formats.c      |  192 -------------------
 test/lowlevel-blt-bench.c |  295 +++++++++++++++++++++++++++--
 test/utils.c              |  463 ++++++++++++++++++++++++++++++++--------------
 test/utils.h              |   12 +
 4 files changed, 608 insertions(+), 354 deletions(-)

New commits:
commit be49f929b656ef83420072e82658e3b3a96a9277
Author: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
Date:   Fri Apr 10 16:42:49 2015 +0300

    lowlevel-blt-bench: use the test pattern parser
    
    Let lowlevel-blt-bench parse the test name string from the command line,
    allowing to run almost infinitely more tests. One is no longer limited
    to the tests listed in the big table.
    
    While you can use the old short-hand names like src_8888_8888, you can
    also use all possible operators now, and specify pixel formats exactly
    rather than just x888, for instance.
    
    This even allows to run crazy patterns like
    conjoint_over_reverse_a8b8g8r8_n_r8g8b8x8.
    
    All individual patterns are now interpreted through the parser. The
    pattern "all" runs the same old default test set as before but through
    the parser instead of the hard-coded parameters.
    
    Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
    Reviewed-by: Ben Avison <bavison at riscosopen.org>

diff --git a/test/lowlevel-blt-bench.c b/test/lowlevel-blt-bench.c
index 7c1711b..9d80d21 100644
--- a/test/lowlevel-blt-bench.c
+++ b/test/lowlevel-blt-bench.c
@@ -367,14 +367,14 @@ bench_RT (pixman_op_t              op,
 }
 
 void
-bench_composite (char * testname,
-                 int    src_fmt,
-                 int    src_flags,
-                 int    op,
-                 int    mask_fmt,
-                 int    mask_flags,
-                 int    dst_fmt,
-                 double npix)
+bench_composite (const char *testname,
+                 int         src_fmt,
+                 int         src_flags,
+                 int         op,
+                 int         mask_fmt,
+                 int         mask_flags,
+                 int         dst_fmt,
+                 double      npix)
 {
     pixman_image_t *                src_img;
     pixman_image_t *                dst_img;
@@ -942,6 +942,36 @@ parser_self_test (void)
     printf ("Parser self-test complete.\n");
 }
 
+static void
+run_one_test (const char *pattern, double bandwidth_)
+{
+    test_entry_t test;
+
+    if (parse_test_pattern (&test, pattern) < 0)
+    {
+        printf ("Error: Could not parse the test pattern '%s'.\n", pattern);
+        return;
+    }
+
+    bench_composite (pattern,
+                     test.src_fmt,
+                     test.src_flags,
+                     test.op,
+                     test.mask_fmt,
+                     test.mask_flags,
+                     test.dst_fmt,
+                     bandwidth_ / 8);
+}
+
+static void
+run_default_tests (double bandwidth_)
+{
+    int i;
+
+    for (i = 0; i < ARRAY_LENGTH (tests_tbl); i++)
+        run_one_test (tests_tbl[i].testname, bandwidth_);
+}
+
 int
 main (int argc, char *argv[])
 {
@@ -1026,19 +1056,13 @@ main (int argc, char *argv[])
     }
     printf ("---\n");
 
-    for (i = 0; i < ARRAY_LENGTH (tests_tbl); i++)
+    if (strcmp (pattern, "all") == 0)
     {
-	if (strcmp (pattern, "all") == 0 || strcmp (tests_tbl[i].testname, pattern) == 0)
-	{
-	    bench_composite (tests_tbl[i].testname,
-			     tests_tbl[i].src_fmt,
-			     tests_tbl[i].src_flags,
-			     tests_tbl[i].op,
-			     tests_tbl[i].mask_fmt,
-			     tests_tbl[i].mask_flags,
-			     tests_tbl[i].dst_fmt,
-			     bandwidth/8);
-	}
+        run_default_tests (bandwidth);
+    }
+    else
+    {
+        run_one_test (pattern, bandwidth);
     }
 
     free (src);
commit 5b279121086274a18912de77865f83d637094739
Author: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
Date:   Fri Apr 10 14:39:13 2015 +0300

    lowlevel-blt-bench: add test name parser and self-test
    
    This patch is inspired by "lowlevel-blt-bench: Parse test name strings in
    general case" by Ben Avison. From Ben's commit message:
    
    "There are many types of composite operation that are useful to benchmark
    but which are omitted from the table. Continually having to add extra
    entries to the table is a nuisance and is prone to human error, so this
    patch adds the ability to break down unknow strings of the format
      <operation>_<src>[_<mask]_<dst>[_ca]
    where bitmap formats are specified by number of bits of each component
    (assumed in ARGB order) or 'n' to indicate a solid source or mask."
    
    Add the parser to lowlevel-blt-bench.c, but do not hook it up to the
    command line just yet. Instead, make it run a self-test.
    
    As we now dynamically parse strings similar to the test names in the
    huge table 'tests_tbl', we should make sure we can parse the old
    well-known test names and produce exactly the same test parameters. The
    self-test goes through this old table and verifies the parsing results.
    
    Unfortunately the old table is not exactly consistent, it contains some
    special cases that cannot be produced by the parsing rules. Whether
    these special cases are intentional or just an oversight is not always
    clear. Anyway, add a small table to reproduce the special cases
    verbatim.
    
    If we wanted, we could remove the big old table in a follow-up commit,
    but then we would also lose the parser self-test.
    
    The point of this whole excercise to let lowlevel-blt-bench recognize
    novel test patterns in the future, following exactly the conventions
    used in the old table.
    
    Ben, from what I see, this parser has one major difference to what you
    wrote. For a solid mask, your parser uses a8r8g8b8 format, while mine
    uses a8 which comes from the old table.
    
    Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
    Reviewed-by: Ben Avison <bavison at riscosopen.org>

diff --git a/test/lowlevel-blt-bench.c b/test/lowlevel-blt-bench.c
index 3da094a..7c1711b 100644
--- a/test/lowlevel-blt-bench.c
+++ b/test/lowlevel-blt-bench.c
@@ -587,7 +587,7 @@ bench_composite (char * testname,
 
 #define PIXMAN_OP_OUT_REV (PIXMAN_OP_OUT_REVERSE)
 
-struct
+struct test_entry
 {
     char *testname;
     int   src_fmt;
@@ -596,8 +596,11 @@ struct
     int   mask_fmt;
     int   mask_flags;
     int   dst_fmt;
-}
-tests_tbl[] =
+};
+
+typedef struct test_entry test_entry_t;
+
+static const test_entry_t tests_tbl[] =
 {
     { "add_8_8_8",             PIXMAN_a8,          0, PIXMAN_OP_ADD,     PIXMAN_a8,       0, PIXMAN_a8 },
     { "add_n_8_8",             PIXMAN_a8r8g8b8,    1, PIXMAN_OP_ADD,     PIXMAN_a8,       0, PIXMAN_a8 },
@@ -719,6 +722,226 @@ tests_tbl[] =
     { "rpixbuf",               PIXMAN_x8b8g8r8,    0, PIXMAN_OP_SRC,     PIXMAN_a8b8g8r8, 0, PIXMAN_a8b8g8r8 },
 };
 
+static const test_entry_t special_patterns[] =
+{
+    { "add_n_2x10",            PIXMAN_a2r10g10b10, 1, PIXMAN_OP_ADD,     PIXMAN_null,     0, PIXMAN_x2r10g10b10 },
+    { "add_n_2a10",            PIXMAN_a2r10g10b10, 1, PIXMAN_OP_ADD,     PIXMAN_null,     0, PIXMAN_a2r10g10b10 },
+    { "src_n_2x10",            PIXMAN_a2r10g10b10, 1, PIXMAN_OP_SRC,     PIXMAN_null,     0, PIXMAN_x2r10g10b10 },
+    { "src_n_2a10",            PIXMAN_a2r10g10b10, 1, PIXMAN_OP_SRC,     PIXMAN_null,     0, PIXMAN_a2r10g10b10 },
+    { "src_0888_8888_rev",     PIXMAN_b8g8r8,      0, PIXMAN_OP_SRC,     PIXMAN_null,     0, PIXMAN_x8r8g8b8 },
+    { "src_0888_0565_rev",     PIXMAN_b8g8r8,      0, PIXMAN_OP_SRC,     PIXMAN_null,     0, PIXMAN_r5g6b5 },
+    { "src_n_8",               PIXMAN_a8,          1, PIXMAN_OP_SRC,     PIXMAN_null,     0, PIXMAN_a8 },
+    { "pixbuf",                PIXMAN_x8b8g8r8,    0, PIXMAN_OP_SRC,     PIXMAN_a8b8g8r8, 0, PIXMAN_a8r8g8b8 },
+    { "rpixbuf",               PIXMAN_x8b8g8r8,    0, PIXMAN_OP_SRC,     PIXMAN_a8b8g8r8, 0, PIXMAN_a8b8g8r8 },
+};
+
+/* Returns the sub-string's end pointer in string. */
+static const char *
+copy_sub_string (char       *buf,
+                 const char *string,
+                 const char *scan_from,
+                 const char *end)
+{
+    const char *delim;
+    size_t n;
+
+    delim = strchr (scan_from, '_');
+    if (!delim)
+        delim = end;
+
+    n = delim - string;
+    strncpy(buf, string, n);
+    buf[n] = '\0';
+
+    return delim;
+}
+
+static pixman_op_t
+parse_longest_operator (char *buf, const char **strp, const char *end)
+{
+    const char *p = *strp;
+    const char *sub_end;
+    const char *best_end = p;
+    pixman_op_t best_op = PIXMAN_OP_NONE;
+    pixman_op_t op;
+
+    while (p < end)
+    {
+        sub_end = copy_sub_string (buf, *strp, p, end);
+        op = operator_from_string (buf);
+        p = sub_end + 1;
+
+        if (op != PIXMAN_OP_NONE)
+        {
+            best_end = p;
+            best_op = op;
+        }
+    }
+
+    *strp = best_end;
+    return best_op;
+}
+
+static pixman_format_code_t
+parse_format (char *buf, const char **p, const char *end)
+{
+    pixman_format_code_t format;
+    const char *delim;
+
+    if (*p >= end)
+        return PIXMAN_null;
+
+    delim = copy_sub_string (buf, *p, *p, end);
+    format = format_from_string (buf);
+
+    if (format != PIXMAN_null)
+        *p = delim + 1;
+
+    return format;
+}
+
+static int
+parse_test_pattern (test_entry_t *test, const char *pattern)
+{
+    const char *p = pattern;
+    const char *end = pattern + strlen (pattern);
+    char buf[1024];
+    pixman_format_code_t format[3];
+    int i;
+
+    if (strlen (pattern) > sizeof (buf) - 1)
+        return -1;
+
+    /* Special cases that the parser cannot produce. */
+    for (i = 0; i < ARRAY_LENGTH (special_patterns); i++)
+    {
+        if (strcmp (pattern, special_patterns[i].testname) == 0)
+        {
+            *test = special_patterns[i];
+            return 0;
+        }
+    }
+
+    /* Extract operator, may contain delimiters,
+     * so take the longest string that matches.
+     */
+    test->op = parse_longest_operator (buf, &p, end);
+    if (test->op == PIXMAN_OP_NONE)
+        return -1;
+
+    /* extract up to three pixel formats */
+    format[0] = parse_format (buf, &p, end);
+    format[1] = parse_format (buf, &p, end);
+    format[2] = parse_format (buf, &p, end);
+
+    if (format[0] == PIXMAN_null || format[1] == PIXMAN_null)
+        return -1;
+
+    /* recognize CA flag */
+    test->mask_flags = 0;
+    if (p < end)
+    {
+        if (strcmp (p, "ca") == 0)
+            test->mask_flags |= CA_FLAG;
+        else
+            return -1; /* trailing garbage */
+    }
+
+    test->src_fmt = format[0];
+    if (format[2] == PIXMAN_null)
+    {
+        test->mask_fmt = PIXMAN_null;
+        test->dst_fmt = format[1];
+    }
+    else
+    {
+        test->mask_fmt = format[1];
+        test->dst_fmt = format[2];
+    }
+
+    test->src_flags = 0;
+    if (test->src_fmt == PIXMAN_solid)
+    {
+        test->src_fmt = PIXMAN_a8r8g8b8;
+        test->src_flags |= SOLID_FLAG;
+    }
+
+    if (test->mask_fmt == PIXMAN_solid)
+    {
+        test->mask_fmt = PIXMAN_a8;
+        test->mask_flags |= SOLID_FLAG;
+    }
+
+    return 0;
+}
+
+static int
+check_int (int got, int expected, const char *name, const char *field)
+{
+    if (got == expected)
+        return 0;
+
+    printf ("%s: %s failure: expected %d, got %d.\n",
+            name, field, expected, got);
+
+    return 1;
+}
+
+static int
+check_format (int got, int expected, const char *name, const char *field)
+{
+    if (got == expected)
+        return 0;
+
+    printf ("%s: %s failure: expected %s (%#x), got %s (%#x).\n",
+            name, field,
+            format_name (expected), expected,
+            format_name (got), got);
+
+    return 1;
+}
+
+static void
+parser_self_test (void)
+{
+    const test_entry_t *ent;
+    test_entry_t test;
+    int fails = 0;
+    int i;
+
+    for (i = 0; i < ARRAY_LENGTH (tests_tbl); i++)
+    {
+        ent = &tests_tbl[i];
+
+        if (parse_test_pattern (&test, ent->testname) < 0)
+        {
+            printf ("parsing failed for '%s'\n", ent->testname);
+            fails++;
+            continue;
+        }
+
+        fails += check_format (test.src_fmt, ent->src_fmt,
+                               ent->testname, "src_fmt");
+        fails += check_format (test.mask_fmt, ent->mask_fmt,
+                               ent->testname, "mask_fmt");
+        fails += check_format (test.dst_fmt, ent->dst_fmt,
+                               ent->testname, "dst_fmt");
+        fails += check_int    (test.src_flags, ent->src_flags,
+                               ent->testname, "src_flags");
+        fails += check_int    (test.mask_flags, ent->mask_flags,
+                               ent->testname, "mask_flags");
+        fails += check_int    (test.op, ent->op, ent->testname, "op");
+    }
+
+    if (fails)
+    {
+        printf ("Parser self-test failed.\n");
+        exit (EXIT_FAILURE);
+    }
+
+    printf ("Parser self-test complete.\n");
+}
+
 int
 main (int argc, char *argv[])
 {
@@ -754,6 +977,8 @@ main (int argc, char *argv[])
 	return 1;
     }
 
+    parser_self_test ();
+
     src = aligned_malloc (4096, BUFSIZE * 3);
     memset (src, 0xCC, BUFSIZE * 3);
     dst = src + (BUFSIZE / 4);
commit 1f45bd6565607049c7bcf707f2fdaedbb16bc926
Author: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
Date:   Fri Apr 10 12:50:23 2015 +0300

    test/utils: add format aliases used by lowlevel-blt-bench
    
    Lowlevel-blt-bench uses several pixel format shorthands. Pick them from
    the great table in lowlevel-blt-bench.c and add them here so that
    format_from_string() can recognize them.
    
    Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
    Reviewed-by: Ben Avison <bavison at riscosopen.org>

diff --git a/test/utils.c b/test/utils.c
index 2052ff0..5663aec 100644
--- a/test/utils.c
+++ b/test/utils.c
@@ -1059,7 +1059,9 @@ static const format_entry_t format_list[] =
 
 /* 32bpp formats */
     ENTRY (a8r8g8b8),
+    ALIAS (a8r8g8b8,		"8888"),
     ENTRY (x8r8g8b8),
+    ALIAS (x8r8g8b8,		"x888"),
     ENTRY (a8b8g8r8),
     ENTRY (x8b8g8r8),
     ENTRY (b8g8r8a8),
@@ -1068,7 +1070,9 @@ static const format_entry_t format_list[] =
     ENTRY (r8g8b8x8),
     ENTRY (x14r6g6b6),
     ENTRY (x2r10g10b10),
+    ALIAS (x2r10g10b10,		"2x10"),
     ENTRY (a2r10g10b10),
+    ALIAS (a2r10g10b10,		"2a10"),
     ENTRY (x2b10g10r10),
     ENTRY (a2b10g10r10),
 
@@ -1077,26 +1081,32 @@ static const format_entry_t format_list[] =
 
 /* 24bpp formats */
     ENTRY (r8g8b8),
+    ALIAS (r8g8b8,		"0888"),
     ENTRY (b8g8r8),
 
 /* 16 bpp formats */
     ENTRY (r5g6b5),
+    ALIAS (r5g6b5,		"0565"),
     ENTRY (b5g6r5),
 
     ENTRY (a1r5g5b5),
+    ALIAS (a1r5g5b5,		"1555"),
     ENTRY (x1r5g5b5),
     ENTRY (a1b5g5r5),
     ENTRY (x1b5g5r5),
     ENTRY (a4r4g4b4),
+    ALIAS (a4r4g4b4,		"4444"),
     ENTRY (x4r4g4b4),
     ENTRY (a4b4g4r4),
     ENTRY (x4b4g4r4),
 
 /* 8bpp formats */
     ENTRY (a8),
+    ALIAS (a8,			"8"),
     ENTRY (r3g3b2),
     ENTRY (b2g3r3),
     ENTRY (a2r2g2b2),
+    ALIAS (a2r2g2b2,		"2222"),
     ENTRY (a2b2g2r2),
 
     ALIAS (c8,			"x4c4 / c8"),
@@ -1137,6 +1147,7 @@ static const format_entry_t format_list[] =
 /* Fake formats, not in pixman_format_code_t enum */
     ALIAS (null,		"null"),
     ALIAS (solid,		"solid"),
+    ALIAS (solid,		"n"),
     ALIAS (pixbuf,		"pixbuf"),
     ALIAS (rpixbuf,		"rpixbuf"),
     ALIAS (unknown,		"unknown"),
commit ef9c28a0e44f7220f49a5a47cb33077cbbba00ee
Author: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
Date:   Mon Apr 13 10:06:31 2015 +0300

    test/utils: add operator aliases for lowlevel-blt-bench
    
    Lowlevel-blt-bench uses the operator alias "outrev". Add an alias for it
    in the operator-name table.
    
    Also add aliases for overrev, inrev and atoprev, so that
    lowlevel-blt-bench can later recognize them for new test cases.
    
    The aliases are added such, that an operator to name lookup will never
    return them; it returns the proper names instead.
    
    Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
    Reviewed-by: Ben Avison <bavison at riscosopen.org>

diff --git a/test/utils.c b/test/utils.c
index 9d4e350..2052ff0 100644
--- a/test/utils.c
+++ b/test/utils.c
@@ -974,12 +974,16 @@ static const operator_entry_t op_list[] =
     ENTRY (DST),
     ENTRY (OVER),
     ENTRY (OVER_REVERSE),
+    ALIAS (OVER_REVERSE,		"overrev"),
     ENTRY (IN),
     ENTRY (IN_REVERSE),
+    ALIAS (IN_REVERSE,			"inrev"),
     ENTRY (OUT),
     ENTRY (OUT_REVERSE),
+    ALIAS (OUT_REVERSE,			"outrev"),
     ENTRY (ATOP),
     ENTRY (ATOP_REVERSE),
+    ALIAS (ATOP_REVERSE,		"atoprev"),
     ENTRY (XOR),
     ENTRY (ADD),
     ENTRY (SATURATE),
commit f1f6cc23ce340087035e7ec912723e8a6134efc3
Author: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
Date:   Thu Apr 9 14:17:54 2015 +0300

    test/utils: support format name aliases
    
    Previously there was a flat list of formats, used to iterate over all
    formats when looking up a format from name or listing them. This cannot
    support name aliases.
    
    To support name aliases (multiple name strings mapping to the same
    format), create a format-name mapping table. Functions format_name(),
    format_from_string(), and list_formats() should keep on working exactly
    like before, except format_from_string() now recognizes the additional
    formats that format_name() already supported.
    
    The only the formats from the old format list are added with ENTRY, so
    that list_formats() works as before. The whole list is verified against
    the authoritative list in pixman.h, entries missing from the old list
    are commented out.
    
    The extra formats supported by the old format_name() are added as
    ALIASes. A side-effect of that is that now also format_from_string()
    recognizes the following new names: x4c4 / c8, x4g4 / g8, c4, g4, g1,
    yuy2, yv12, null, solid, pixbuf, rpixbuf, unknown.
    
    Name aliases will be useful in follow-up patches, where
    lowlevel-blt-bench.c is converted to parse short-hand format names from
    strings.
    
    Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
    Reviewed-by: Ben Avison <bavison at riscosopen.org>

diff --git a/test/utils.c b/test/utils.c
index f6b30a2..9d4e350 100644
--- a/test/utils.c
+++ b/test/utils.c
@@ -1032,46 +1032,113 @@ static const operator_entry_t op_list[] =
 #undef ALIAS
 };
 
-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,
+struct format_entry
+{
+    pixman_format_code_t format;
+    const char		*name;
+    pixman_bool_t	 is_alias;
+};
+
+typedef struct format_entry format_entry_t;
+
+static const format_entry_t format_list[] =
+{
+#define ENTRY(f)							\
+    { PIXMAN_##f, #f, FALSE }
+#define ALIAS(f, nam)							\
+    { PIXMAN_##f, nam, TRUE }
+
+    /* format_name () will return the first hit in this table,
+     * so keep the list properly ordered between entries and aliases.
+     * Aliases are not listed by list_formats ().
+     */
+
+/* 32bpp formats */
+    ENTRY (a8r8g8b8),
+    ENTRY (x8r8g8b8),
+    ENTRY (a8b8g8r8),
+    ENTRY (x8b8g8r8),
+    ENTRY (b8g8r8a8),
+    ENTRY (b8g8r8x8),
+    ENTRY (r8g8b8a8),
+    ENTRY (r8g8b8x8),
+    ENTRY (x14r6g6b6),
+    ENTRY (x2r10g10b10),
+    ENTRY (a2r10g10b10),
+    ENTRY (x2b10g10r10),
+    ENTRY (a2b10g10r10),
+
+/* sRGB formats */
+    ENTRY (a8r8g8b8_sRGB),
+
+/* 24bpp formats */
+    ENTRY (r8g8b8),
+    ENTRY (b8g8r8),
+
+/* 16 bpp formats */
+    ENTRY (r5g6b5),
+    ENTRY (b5g6r5),
+
+    ENTRY (a1r5g5b5),
+    ENTRY (x1r5g5b5),
+    ENTRY (a1b5g5r5),
+    ENTRY (x1b5g5r5),
+    ENTRY (a4r4g4b4),
+    ENTRY (x4r4g4b4),
+    ENTRY (a4b4g4r4),
+    ENTRY (x4b4g4r4),
+
+/* 8bpp formats */
+    ENTRY (a8),
+    ENTRY (r3g3b2),
+    ENTRY (b2g3r3),
+    ENTRY (a2r2g2b2),
+    ENTRY (a2b2g2r2),
+
+    ALIAS (c8,			"x4c4 / c8"),
+    /* ENTRY (c8), */
+    ALIAS (g8,			"x4g4 / g8"),
+    /* ENTRY (g8), */
+
+    ENTRY (x4a4),
+
+    /* These format codes are identical to c8 and g8, respectively. */
+    /* ENTRY (x4c4), */
+    /* ENTRY (x4g4), */
+
+/* 4 bpp formats */
+    ENTRY (a4),
+    ENTRY (r1g2b1),
+    ENTRY (b1g2r1),
+    ENTRY (a1r1g1b1),
+    ENTRY (a1b1g1r1),
+
+    ALIAS (c4,			"c4"),
+    /* ENTRY (c4), */
+    ALIAS (g4,			"g4"),
+    /* ENTRY (g4), */
+
+/* 1bpp formats */
+    ENTRY (a1),
+
+    ALIAS (g1,			"g1"),
+    /* ENTRY (g1), */
+
+/* YUV formats */
+    ALIAS (yuy2,		"yuy2"),
+    /* ENTRY (yuy2), */
+    ALIAS (yv12,		"yv12"),
+    /* ENTRY (yv12), */
+
+/* Fake formats, not in pixman_format_code_t enum */
+    ALIAS (null,		"null"),
+    ALIAS (solid,		"solid"),
+    ALIAS (pixbuf,		"pixbuf"),
+    ALIAS (rpixbuf,		"rpixbuf"),
+    ALIAS (unknown,		"unknown"),
+
+#undef ENTRY
+#undef ALIAS
 };
 
 pixman_format_code_t
@@ -1081,8 +1148,10 @@ format_from_string (const char *s)
 
     for (i = 0; i < ARRAY_LENGTH (format_list); ++i)
     {
-        if (strcasecmp (format_name (format_list[i]), s) == 0)
-            return format_list[i];
+        const format_entry_t *ent = &format_list[i];
+
+        if (strcasecmp (ent->name, s) == 0)
+            return ent->format;
     }
 
     return PIXMAN_null;
@@ -1114,7 +1183,14 @@ list_formats (void)
 
     n_chars = 0;
     for (i = 0; i < ARRAY_LENGTH (format_list); ++i)
-        emit (format_name (format_list[i]), &n_chars);
+    {
+        const format_entry_t *ent = &format_list[i];
+
+        if (ent->is_alias)
+            continue;
+
+        emit (ent->name, &n_chars);
+    }
 
     printf ("\n\n");
 }
@@ -1191,92 +1267,15 @@ operator_name (pixman_op_t op)
 const char *
 format_name (pixman_format_code_t format)
 {
-    switch (format)
-    {
-/* 32bpp formats */
-    case PIXMAN_a8r8g8b8: return "a8r8g8b8";
-    case PIXMAN_x8r8g8b8: return "x8r8g8b8";
-    case PIXMAN_a8b8g8r8: return "a8b8g8r8";
-    case PIXMAN_x8b8g8r8: return "x8b8g8r8";
-    case PIXMAN_b8g8r8a8: return "b8g8r8a8";
-    case PIXMAN_b8g8r8x8: return "b8g8r8x8";
-    case PIXMAN_r8g8b8a8: return "r8g8b8a8";
-    case PIXMAN_r8g8b8x8: return "r8g8b8x8";
-    case PIXMAN_x14r6g6b6: return "x14r6g6b6";
-    case PIXMAN_x2r10g10b10: return "x2r10g10b10";
-    case PIXMAN_a2r10g10b10: return "a2r10g10b10";
-    case PIXMAN_x2b10g10r10: return "x2b10g10r10";
-    case PIXMAN_a2b10g10r10: return "a2b10g10r10";
-
-/* sRGB formats */
-    case PIXMAN_a8r8g8b8_sRGB: return "a8r8g8b8_sRGB";
-
-/* 24bpp formats */
-    case PIXMAN_r8g8b8: return "r8g8b8";
-    case PIXMAN_b8g8r8: return "b8g8r8";
-
-/* 16bpp formats */
-    case PIXMAN_r5g6b5: return "r5g6b5";
-    case PIXMAN_b5g6r5: return "b5g6r5";
-
-    case PIXMAN_a1r5g5b5: return "a1r5g5b5";
-    case PIXMAN_x1r5g5b5: return "x1r5g5b5";
-    case PIXMAN_a1b5g5r5: return "a1b5g5r5";
-    case PIXMAN_x1b5g5r5: return "x1b5g5r5";
-    case PIXMAN_a4r4g4b4: return "a4r4g4b4";
-    case PIXMAN_x4r4g4b4: return "x4r4g4b4";
-    case PIXMAN_a4b4g4r4: return "a4b4g4r4";
-    case PIXMAN_x4b4g4r4: return "x4b4g4r4";
-
-/* 8bpp formats */
-    case PIXMAN_a8: return "a8";
-    case PIXMAN_r3g3b2: return "r3g3b2";
-    case PIXMAN_b2g3r3: return "b2g3r3";
-    case PIXMAN_a2r2g2b2: return "a2r2g2b2";
-    case PIXMAN_a2b2g2r2: return "a2b2g2r2";
-
-#if 0
-    case PIXMAN_x4c4: return "x4c4";
-    case PIXMAN_g8: return "g8";
-#endif
-    case PIXMAN_c8: return "x4c4 / c8";
-    case PIXMAN_x4g4: return "x4g4 / g8";
-
-    case PIXMAN_x4a4: return "x4a4";
-
-/* 4bpp formats */
-    case PIXMAN_a4: return "a4";
-    case PIXMAN_r1g2b1: return "r1g2b1";
-    case PIXMAN_b1g2r1: return "b1g2r1";
-    case PIXMAN_a1r1g1b1: return "a1r1g1b1";
-    case PIXMAN_a1b1g1r1: return "a1b1g1r1";
-
-    case PIXMAN_c4: return "c4";
-    case PIXMAN_g4: return "g4";
-
-/* 1bpp formats */
-    case PIXMAN_a1: return "a1";
-
-    case PIXMAN_g1: return "g1";
-
-/* YUV formats */
-    case PIXMAN_yuy2: return "yuy2";
-    case PIXMAN_yv12: return "yv12";
-    };
+    int i;
 
-    /* Fake formats.
-     *
-     * This is separate switch to prevent GCC from complaining
-     * that the values are not in the pixman_format_code_t enum.
-     */
-    switch ((uint32_t)format)
+    for (i = 0; i < ARRAY_LENGTH (format_list); ++i)
     {
-    case PIXMAN_null: return "null"; 
-    case PIXMAN_solid: return "solid"; 
-    case PIXMAN_pixbuf: return "pixbuf"; 
-    case PIXMAN_rpixbuf: return "rpixbuf"; 
-    case PIXMAN_unknown: return "unknown"; 
-    };
+        const format_entry_t *ent = &format_list[i];
+
+        if (ent->format == format)
+            return ent->name;
+    }
 
     return "<unknown format>";
 };
commit 2c5fac932061351ae2153026003539745aa9b44e
Author: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
Date:   Thu Apr 9 13:13:09 2015 +0300

    test/utils: support operator name aliases
    
    Previously there was a flat list of operators (pixman_op_t), used to
    iterate over all operators when looking up an operator from name or
    listing them. This cannot support name aliases.
    
    To support name aliases (multiple name strings mapping to the same
    operator), create an operator-name mapping table. Functions
    operator_name, operator_from_string, and list_operators should keep on
    working exactly like before, except operator_from_string now recognizes
    a few aliases too.
    
    Name aliases will be useful in follow-up patches, where
    lowlevel-blt-bench.c is converted to parse operator names from strings.
    Lowlevel-blt-bench uses shorthand names instead of the usual names. This
    change allows lowlevel-blt-bench.s to use operator_from_string in the
    future.
    
    Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
    Reviewed-by: Ben Avison <bavison at riscosopen.org>

diff --git a/test/utils.c b/test/utils.c
index efec632..f6b30a2 100644
--- a/test/utils.c
+++ b/test/utils.c
@@ -949,64 +949,87 @@ initialize_palette (pixman_indexed_t *palette, uint32_t depth, int is_rgb)
     }
 }
 
-static const pixman_op_t op_list[] =
+struct operator_entry {
+    pixman_op_t		 op;
+    const char		*name;
+    pixman_bool_t	 is_alias;
+};
+
+typedef struct operator_entry operator_entry_t;
+
+static const operator_entry_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
+#define ENTRY(op)							\
+    { PIXMAN_OP_##op, "PIXMAN_OP_" #op, FALSE }
+#define ALIAS(op, nam)							\
+    { PIXMAN_OP_##op, nam, TRUE }
+
+    /* operator_name () will return the first hit in this table,
+     * so keep the list properly ordered between entries and aliases.
+     * Aliases are not listed by list_operators ().
+     */
+
+    ENTRY (CLEAR),
+    ENTRY (SRC),
+    ENTRY (DST),
+    ENTRY (OVER),
+    ENTRY (OVER_REVERSE),
+    ENTRY (IN),
+    ENTRY (IN_REVERSE),
+    ENTRY (OUT),
+    ENTRY (OUT_REVERSE),
+    ENTRY (ATOP),
+    ENTRY (ATOP_REVERSE),
+    ENTRY (XOR),
+    ENTRY (ADD),
+    ENTRY (SATURATE),
+
+    ENTRY (DISJOINT_CLEAR),
+    ENTRY (DISJOINT_SRC),
+    ENTRY (DISJOINT_DST),
+    ENTRY (DISJOINT_OVER),
+    ENTRY (DISJOINT_OVER_REVERSE),
+    ENTRY (DISJOINT_IN),
+    ENTRY (DISJOINT_IN_REVERSE),
+    ENTRY (DISJOINT_OUT),
+    ENTRY (DISJOINT_OUT_REVERSE),
+    ENTRY (DISJOINT_ATOP),
+    ENTRY (DISJOINT_ATOP_REVERSE),
+    ENTRY (DISJOINT_XOR),
+
+    ENTRY (CONJOINT_CLEAR),
+    ENTRY (CONJOINT_SRC),
+    ENTRY (CONJOINT_DST),
+    ENTRY (CONJOINT_OVER),
+    ENTRY (CONJOINT_OVER_REVERSE),
+    ENTRY (CONJOINT_IN),
+    ENTRY (CONJOINT_IN_REVERSE),
+    ENTRY (CONJOINT_OUT),
+    ENTRY (CONJOINT_OUT_REVERSE),
+    ENTRY (CONJOINT_ATOP),
+    ENTRY (CONJOINT_ATOP_REVERSE),
+    ENTRY (CONJOINT_XOR),
+
+    ENTRY (MULTIPLY),
+    ENTRY (SCREEN),
+    ENTRY (OVERLAY),
+    ENTRY (DARKEN),
+    ENTRY (LIGHTEN),
+    ENTRY (COLOR_DODGE),
+    ENTRY (COLOR_BURN),
+    ENTRY (HARD_LIGHT),
+    ENTRY (SOFT_LIGHT),
+    ENTRY (DIFFERENCE),
+    ENTRY (EXCLUSION),
+    ENTRY (HSL_HUE),
+    ENTRY (HSL_SATURATION),
+    ENTRY (HSL_COLOR),
+    ENTRY (HSL_LUMINOSITY),
+
+    ALIAS (NONE, "<invalid operator 'none'>")
+
+#undef ENTRY
+#undef ALIAS
 };
 
 static const pixman_format_code_t format_list[] =
@@ -1107,11 +1130,14 @@ list_operators (void)
     n_chars = 0;
     for (i = 0; i < ARRAY_LENGTH (op_list); ++i)
     {
-        pixman_op_t op = op_list[i];
+        const operator_entry_t *ent = &op_list[i];
         int j;
 
+        if (ent->is_alias)
+            continue;
+
         snprintf (short_name, sizeof (short_name) - 1, "%s",
-                  operator_name (op) + strlen ("PIXMAN_OP_"));
+                  ent->name + strlen ("PIXMAN_OP_"));
 
         for (j = 0; short_name[j] != '\0'; ++j)
             short_name[j] = tolower (short_name[j]);
@@ -1125,17 +1151,22 @@ list_operators (void)
 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];
+        const operator_entry_t *ent = &op_list[i];
 
-        if (strcasecmp (operator_name (op), full_name) == 0)
-            return op;
+        if (ent->is_alias)
+        {
+            if (strcasecmp (ent->name, s) == 0)
+                return ent->op;
+        }
+        else
+        {
+            if (strcasecmp (ent->name + strlen ("PIXMAN_OP_"), s) == 0)
+                return ent->op;
+        }
     }
 
     return PIXMAN_OP_NONE;
@@ -1144,68 +1175,15 @@ operator_from_string (const char *s)
 const char *
 operator_name (pixman_op_t op)
 {
-    switch (op)
+    int i;
+
+    for (i = 0; i < ARRAY_LENGTH (op_list); ++i)
     {
-    case PIXMAN_OP_CLEAR: return "PIXMAN_OP_CLEAR";
-    case PIXMAN_OP_SRC: return "PIXMAN_OP_SRC";
-    case PIXMAN_OP_DST: return "PIXMAN_OP_DST";
-    case PIXMAN_OP_OVER: return "PIXMAN_OP_OVER";
-    case PIXMAN_OP_OVER_REVERSE: return "PIXMAN_OP_OVER_REVERSE";
-    case PIXMAN_OP_IN: return "PIXMAN_OP_IN";
-    case PIXMAN_OP_IN_REVERSE: return "PIXMAN_OP_IN_REVERSE";
-    case PIXMAN_OP_OUT: return "PIXMAN_OP_OUT";
-    case PIXMAN_OP_OUT_REVERSE: return "PIXMAN_OP_OUT_REVERSE";
-    case PIXMAN_OP_ATOP: return "PIXMAN_OP_ATOP";
-    case PIXMAN_OP_ATOP_REVERSE: return "PIXMAN_OP_ATOP_REVERSE";
-    case PIXMAN_OP_XOR: return "PIXMAN_OP_XOR";
-    case PIXMAN_OP_ADD: return "PIXMAN_OP_ADD";
-    case PIXMAN_OP_SATURATE: return "PIXMAN_OP_SATURATE";
-
-    case PIXMAN_OP_DISJOINT_CLEAR: return "PIXMAN_OP_DISJOINT_CLEAR";
-    case PIXMAN_OP_DISJOINT_SRC: return "PIXMAN_OP_DISJOINT_SRC";
-    case PIXMAN_OP_DISJOINT_DST: return "PIXMAN_OP_DISJOINT_DST";
-    case PIXMAN_OP_DISJOINT_OVER: return "PIXMAN_OP_DISJOINT_OVER";
-    case PIXMAN_OP_DISJOINT_OVER_REVERSE: return "PIXMAN_OP_DISJOINT_OVER_REVERSE";
-    case PIXMAN_OP_DISJOINT_IN: return "PIXMAN_OP_DISJOINT_IN";
-    case PIXMAN_OP_DISJOINT_IN_REVERSE: return "PIXMAN_OP_DISJOINT_IN_REVERSE";
-    case PIXMAN_OP_DISJOINT_OUT: return "PIXMAN_OP_DISJOINT_OUT";
-    case PIXMAN_OP_DISJOINT_OUT_REVERSE: return "PIXMAN_OP_DISJOINT_OUT_REVERSE";
-    case PIXMAN_OP_DISJOINT_ATOP: return "PIXMAN_OP_DISJOINT_ATOP";
-    case PIXMAN_OP_DISJOINT_ATOP_REVERSE: return "PIXMAN_OP_DISJOINT_ATOP_REVERSE";
-    case PIXMAN_OP_DISJOINT_XOR: return "PIXMAN_OP_DISJOINT_XOR";
-
-    case PIXMAN_OP_CONJOINT_CLEAR: return "PIXMAN_OP_CONJOINT_CLEAR";
-    case PIXMAN_OP_CONJOINT_SRC: return "PIXMAN_OP_CONJOINT_SRC";
-    case PIXMAN_OP_CONJOINT_DST: return "PIXMAN_OP_CONJOINT_DST";
-    case PIXMAN_OP_CONJOINT_OVER: return "PIXMAN_OP_CONJOINT_OVER";
-    case PIXMAN_OP_CONJOINT_OVER_REVERSE: return "PIXMAN_OP_CONJOINT_OVER_REVERSE";
-    case PIXMAN_OP_CONJOINT_IN: return "PIXMAN_OP_CONJOINT_IN";
-    case PIXMAN_OP_CONJOINT_IN_REVERSE: return "PIXMAN_OP_CONJOINT_IN_REVERSE";
-    case PIXMAN_OP_CONJOINT_OUT: return "PIXMAN_OP_CONJOINT_OUT";
-    case PIXMAN_OP_CONJOINT_OUT_REVERSE: return "PIXMAN_OP_CONJOINT_OUT_REVERSE";
-    case PIXMAN_OP_CONJOINT_ATOP: return "PIXMAN_OP_CONJOINT_ATOP";
-    case PIXMAN_OP_CONJOINT_ATOP_REVERSE: return "PIXMAN_OP_CONJOINT_ATOP_REVERSE";
-    case PIXMAN_OP_CONJOINT_XOR: return "PIXMAN_OP_CONJOINT_XOR";
-
-    case PIXMAN_OP_MULTIPLY: return "PIXMAN_OP_MULTIPLY";
-    case PIXMAN_OP_SCREEN: return "PIXMAN_OP_SCREEN";
-    case PIXMAN_OP_OVERLAY: return "PIXMAN_OP_OVERLAY";
-    case PIXMAN_OP_DARKEN: return "PIXMAN_OP_DARKEN";
-    case PIXMAN_OP_LIGHTEN: return "PIXMAN_OP_LIGHTEN";
-    case PIXMAN_OP_COLOR_DODGE: return "PIXMAN_OP_COLOR_DODGE";
-    case PIXMAN_OP_COLOR_BURN: return "PIXMAN_OP_COLOR_BURN";
-    case PIXMAN_OP_HARD_LIGHT: return "PIXMAN_OP_HARD_LIGHT";
-    case PIXMAN_OP_SOFT_LIGHT: return "PIXMAN_OP_SOFT_LIGHT";
-    case PIXMAN_OP_DIFFERENCE: return "PIXMAN_OP_DIFFERENCE";
-    case PIXMAN_OP_EXCLUSION: return "PIXMAN_OP_EXCLUSION";
-    case PIXMAN_OP_HSL_HUE: return "PIXMAN_OP_HSL_HUE";
-    case PIXMAN_OP_HSL_SATURATION: return "PIXMAN_OP_HSL_SATURATION";
-    case PIXMAN_OP_HSL_COLOR: return "PIXMAN_OP_HSL_COLOR";
-    case PIXMAN_OP_HSL_LUMINOSITY: return "PIXMAN_OP_HSL_LUMINOSITY";
-
-    case PIXMAN_OP_NONE:
-	return "<invalid operator 'none'>";
-    };
+        const operator_entry_t *ent = &op_list[i];
+
+        if (ent->op == op)
+            return ent->name;
+    }
 
     return "<unknown operator>";
 }
commit f122907dc1d18cdd7e11fec5e4f9c220c62e6e77
Author: Ben Avison <bavison at riscosopen.org>
Date:   Tue Mar 3 15:24:17 2015 +0000

    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 at collabora.co.uk>

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,
+    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,
+};
+
+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);
 


More information about the xorg-commit mailing list