diff options
author | Søren Sandmann Pedersen <ssp@redhat.com> | 2010-09-12 04:35:08 -0400 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@redhat.com> | 2010-09-12 05:07:20 -0400 |
commit | 4b4a55caaa671e0a2c166102484f7fdbcfa7c465 (patch) | |
tree | c8d3bf59cef337fdcaaf9747a1ea6e4997b1f080 | |
parent | e9bdf98c02b2cfbe9cbb5ecf4837cf8467c32d56 (diff) |
Do opacity computation with shifts instead of comparing with 0
Also add a COMPILE_TIME_ASSERT() macro and use it to assert that the
shift is correct.
-rw-r--r-- | pixman/pixman-private.h | 3 | ||||
-rw-r--r-- | pixman/pixman.c | 14 |
2 files changed, 12 insertions, 5 deletions
diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h index 3557fb22..36b9d91b 100644 --- a/pixman/pixman-private.h +++ b/pixman/pixman-private.h @@ -744,6 +744,9 @@ pixman_region16_copy_from_region32 (pixman_region16_t *dst, #undef DEBUG +#define COMPILE_TIME_ASSERT(x) \ + do { typedef int compile_time_assertion [(x)?1:-1]; } while (0) + /* Turn on debugging depending on what type of release this is */ #if (((PIXMAN_VERSION_MICRO % 2) == 0) && ((PIXMAN_VERSION_MINOR % 2) == 1)) diff --git a/pixman/pixman.c b/pixman/pixman.c index 47ffdd6d..cdf4b75e 100644 --- a/pixman/pixman.c +++ b/pixman/pixman.c @@ -139,14 +139,18 @@ optimize_operator (pixman_op_t op, uint32_t dst_flags) { pixman_bool_t is_source_opaque, is_dest_opaque; - int opaqueness; - is_source_opaque = ((src_flags & mask_flags) & FAST_PATH_IS_OPAQUE) != 0; - is_dest_opaque = (dst_flags & FAST_PATH_IS_OPAQUE) != 0; +#define OPAQUE_SHIFT 13 + + COMPILE_TIME_ASSERT (FAST_PATH_IS_OPAQUE == (1 << OPAQUE_SHIFT)); + + is_dest_opaque = (dst_flags & FAST_PATH_IS_OPAQUE); + is_source_opaque = ((src_flags & mask_flags) & FAST_PATH_IS_OPAQUE); - opaqueness = ((is_dest_opaque << 1) | is_source_opaque); + is_dest_opaque >>= OPAQUE_SHIFT - 1; + is_source_opaque >>= OPAQUE_SHIFT; - return operator_table[op].opaque_info[opaqueness]; + return operator_table[op].opaque_info[is_dest_opaque | is_source_opaque]; } static void |