summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Sandmann Pedersen <ssp@redhat.com>2010-09-12 04:35:08 -0400
committerSøren Sandmann Pedersen <ssp@redhat.com>2010-09-14 08:57:52 -0400
commit9a82f8e6bf065c0760c6a0ec4bb485bc620c1d0b (patch)
tree98275272fdbab0feff5561ece5fcd1cde1a692d4
parentfb819c0e93b301757f8549cf7738c2b8c356ee7e (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.h3
-rw-r--r--pixman/pixman.c14
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