diff options
author | Søren Sandmann Pedersen <ssp@redhat.com> | 2012-09-15 12:48:42 -0400 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@redhat.com> | 2012-09-19 12:22:58 -0400 |
commit | 7ef4436abbdb898dc656ebb5832ed5d6fd764bba (patch) | |
tree | c11b89e4ce5f99ebb7e3dfbfa9d115c6dd3726f0 | |
parent | 3124a51abb89475b8c5045bc96e04c5852694a16 (diff) |
implementation: Write lookup_combiner() in a less convoluted way.
Instead of initializing an array on the stack, just use a simple
switch to select which set of combiners to look up in.
-rw-r--r-- | pixman/pixman-implementation.c | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/pixman/pixman-implementation.c b/pixman/pixman-implementation.c index 77d0906c..d2573ab7 100644 --- a/pixman/pixman-implementation.c +++ b/pixman/pixman-implementation.c @@ -121,25 +121,36 @@ _pixman_implementation_lookup_combiner (pixman_implementation_t *imp, pixman_bool_t component_alpha, pixman_bool_t narrow) { - pixman_combine_32_func_t f; - - do + while (imp) { - pixman_combine_32_func_t (*combiners[]) = + pixman_combine_32_func_t f = NULL; + + switch ((narrow << 1) | component_alpha) { - (pixman_combine_32_func_t *)imp->combine_64, - (pixman_combine_32_func_t *)imp->combine_64_ca, - imp->combine_32, - imp->combine_32_ca, - }; + case 0: /* not narrow, not component alpha */ + f = (pixman_combine_32_func_t)imp->combine_64[op]; + break; + + case 1: /* not narrow, component_alpha */ + f = (pixman_combine_32_func_t)imp->combine_64_ca[op]; + break; + + case 2: /* narrow, not component alpha */ + f = imp->combine_32[op]; + break; + + case 3: /* narrow, component_alpha */ + f = imp->combine_32_ca[op]; + break; + } - f = combiners[component_alpha | (narrow << 1)][op]; + if (f) + return f; imp = imp->delegate; } - while (!f); - return f; + return NULL; } pixman_bool_t |