summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2010-02-26 14:02:00 +0100
committerSøren Sandmann Pedersen <ssp@redhat.com>2010-07-07 10:23:04 -0400
commit4556d0a294b031fe116841127def5a013e8297bb (patch)
treec12f9c11657eb243b78b55e781fdfb730e7afe94
parent698e3a35b7351654d5227a90eb9c58b3a513c2b5 (diff)
Add pixman_format_is_opaque API
This is supposed to replace usages of PIXMAN_FORMAT_A().
-rw-r--r--pixman/pixman-bits-image.c2
-rw-r--r--pixman/pixman-format.c110
-rw-r--r--pixman/pixman-general.c8
-rw-r--r--pixman/pixman-image.c6
-rw-r--r--pixman/pixman.h1
5 files changed, 70 insertions, 57 deletions
diff --git a/pixman/pixman-bits-image.c b/pixman/pixman-bits-image.c
index 47ee87d8..04ff9549 100644
--- a/pixman/pixman-bits-image.c
+++ b/pixman/pixman-bits-image.c
@@ -991,7 +991,7 @@ _pixman_color_space_optimize (pixman_format_code_t format,
pixman_color_space_t color_space)
{
if (color_space == PIXMAN_COLOR_SPACE_ARGB_UNMULTIPLIED &&
- !PIXMAN_FORMAT_A (format))
+ pixman_format_is_opaque (format))
return PIXMAN_COLOR_SPACE_ARGB;
return color_space;
diff --git a/pixman/pixman-format.c b/pixman/pixman-format.c
index b9aeed75..d5ae5051 100644
--- a/pixman/pixman-format.c
+++ b/pixman/pixman-format.c
@@ -106,6 +106,7 @@ typedef struct {
pixman_format_code_t format;
pixman_bool_t supported_source;
pixman_bool_t supported_destination;
+ pixman_bool_t alpha;
unsigned int num_planes;
pixman_color_space_t default_color_space;
uint32_t * (* alloc_bits) (pixman_format_code_t format,
@@ -116,40 +117,40 @@ typedef struct {
} format_info_t;
static const format_info_t format_infos[] = {
- { PIXMAN_a2b10g10r10, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
- { PIXMAN_x2b10g10r10, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
- { PIXMAN_a2r10g10b10, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
- { PIXMAN_x2r10g10b10, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
- { PIXMAN_a8r8g8b8, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
- { PIXMAN_x8r8g8b8, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
- { PIXMAN_a8b8g8r8, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
- { PIXMAN_x8b8g8r8, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
- { PIXMAN_b8g8r8a8, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
- { PIXMAN_b8g8r8x8, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
- { PIXMAN_r8g8b8a8, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
- { PIXMAN_r8g8b8x8, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
- { PIXMAN_r8g8b8, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
- { PIXMAN_b8g8r8, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
- { PIXMAN_r5g6b5, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
- { PIXMAN_b5g6r5, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
+ { PIXMAN_a2b10g10r10, TRUE, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
+ { PIXMAN_x2b10g10r10, TRUE, TRUE, FALSE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
+ { PIXMAN_a2r10g10b10, TRUE, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
+ { PIXMAN_x2r10g10b10, TRUE, TRUE, FALSE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
+ { PIXMAN_a8r8g8b8, TRUE, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
+ { PIXMAN_x8r8g8b8, TRUE, TRUE, FALSE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
+ { PIXMAN_a8b8g8r8, TRUE, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
+ { PIXMAN_x8b8g8r8, TRUE, TRUE, FALSE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
+ { PIXMAN_b8g8r8a8, TRUE, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
+ { PIXMAN_b8g8r8x8, TRUE, TRUE, FALSE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
+ { PIXMAN_r8g8b8a8, TRUE, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
+ { PIXMAN_r8g8b8x8, TRUE, TRUE, FALSE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
+ { PIXMAN_r8g8b8, TRUE, TRUE, FALSE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
+ { PIXMAN_b8g8r8, TRUE, TRUE, FALSE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
/* 16 bpp formats */
- { PIXMAN_a1r5g5b5, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
- { PIXMAN_x1r5g5b5, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
- { PIXMAN_a1b5g5r5, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
- { PIXMAN_x1b5g5r5, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
- { PIXMAN_a4r4g4b4, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
- { PIXMAN_x4r4g4b4, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
- { PIXMAN_a4b4g4r4, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
- { PIXMAN_x4b4g4r4, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
+ { PIXMAN_r5g6b5, TRUE, TRUE, FALSE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
+ { PIXMAN_b5g6r5, TRUE, TRUE, FALSE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
+ { PIXMAN_a1r5g5b5, TRUE, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
+ { PIXMAN_x1r5g5b5, TRUE, TRUE, FALSE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
+ { PIXMAN_a1b5g5r5, TRUE, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
+ { PIXMAN_x1b5g5r5, TRUE, TRUE, FALSE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
+ { PIXMAN_a4r4g4b4, TRUE, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
+ { PIXMAN_x4r4g4b4, TRUE, TRUE, FALSE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
+ { PIXMAN_a4b4g4r4, TRUE, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
+ { PIXMAN_x4b4g4r4, TRUE, TRUE, FALSE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
/* 8bpp formats */
- { PIXMAN_a8, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
- { PIXMAN_r3g3b2, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
- { PIXMAN_b2g3r3, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
- { PIXMAN_a2r2g2b2, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
- { PIXMAN_a2b2g2r2, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
- { PIXMAN_c8, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
- { PIXMAN_g8, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
- { PIXMAN_x4a4, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
+ { PIXMAN_a8, TRUE, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
+ { PIXMAN_r3g3b2, TRUE, TRUE, FALSE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
+ { PIXMAN_b2g3r3, TRUE, TRUE, FALSE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
+ { PIXMAN_a2r2g2b2, TRUE, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
+ { PIXMAN_a2b2g2r2, TRUE, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
+ { PIXMAN_c8, TRUE, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
+ { PIXMAN_g8, TRUE, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
+ { PIXMAN_x4a4, TRUE, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
/* Collides with PIXMAN_c8
{ PIXMAN_x4c4, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
*/
@@ -157,30 +158,30 @@ static const format_info_t format_infos[] = {
{ PIXMAN_x4g4, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
*/
/* 4bpp formats */
- { PIXMAN_a4, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
- { PIXMAN_r1g2b1, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
- { PIXMAN_b1g2r1, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
- { PIXMAN_a1r1g1b1, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
- { PIXMAN_a1b1g1r1, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
- { PIXMAN_c4, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
- { PIXMAN_g4, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
+ { PIXMAN_a4, TRUE, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
+ { PIXMAN_r1g2b1, TRUE, TRUE, FALSE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
+ { PIXMAN_b1g2r1, TRUE, TRUE, FALSE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
+ { PIXMAN_a1r1g1b1, TRUE, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
+ { PIXMAN_a1b1g1r1, TRUE, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
+ { PIXMAN_c4, TRUE, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
+ { PIXMAN_g4, TRUE, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
/* 1bpp formats */
- { PIXMAN_a1, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
- { PIXMAN_g1, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
+ { PIXMAN_a1, TRUE, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
+ { PIXMAN_g1, TRUE, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits },
/* planar formats */
- { PIXMAN_y444, TRUE, TRUE, 3, PIXMAN_COLOR_SPACE_YCBCR_SD, alloc_y444 },
+ { PIXMAN_y444, TRUE, TRUE, FALSE, 3, PIXMAN_COLOR_SPACE_YCBCR_SD, alloc_y444 },
/* packed formats */
- { PIXMAN_yuy2, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_YCBCR_SD, alloc_bits },
- { PIXMAN_yvyu, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_YCBCR_SD, alloc_bits },
- { PIXMAN_uyvy, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_YCBCR_SD, alloc_bits },
- { PIXMAN_vyuy, TRUE, TRUE, 1, PIXMAN_COLOR_SPACE_YCBCR_SD, alloc_bits },
+ { PIXMAN_yuy2, TRUE, TRUE, FALSE, 1, PIXMAN_COLOR_SPACE_YCBCR_SD, alloc_bits },
+ { PIXMAN_yvyu, TRUE, TRUE, FALSE, 1, PIXMAN_COLOR_SPACE_YCBCR_SD, alloc_bits },
+ { PIXMAN_uyvy, TRUE, TRUE, FALSE, 1, PIXMAN_COLOR_SPACE_YCBCR_SD, alloc_bits },
+ { PIXMAN_vyuy, TRUE, TRUE, FALSE, 1, PIXMAN_COLOR_SPACE_YCBCR_SD, alloc_bits },
/* YUV formats */
- { PIXMAN_yv12, TRUE, FALSE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits }
+ { PIXMAN_yv12, TRUE, FALSE, FALSE, 1, PIXMAN_COLOR_SPACE_ARGB, alloc_bits }
};
/* default values for "invalid" at the end */
static const format_info_t invalid_format =
- { 0, FALSE, FALSE, 0, PIXMAN_COLOR_SPACE_ARGB, NULL };
+ { 0, FALSE, FALSE, FALSE, 0, PIXMAN_COLOR_SPACE_ARGB, NULL };
static const format_info_t *
@@ -271,3 +272,16 @@ pixman_format_num_planes (pixman_format_code_t format)
return num_planes;
}
+
+/**
+ * pixman_format_is_opaque:
+ * @format: A pixman_format_code_t format
+ *
+ * Returns: TRUE if images in the given @format are guaranteed to
+ * be completely opaque
+ **/
+PIXMAN_EXPORT pixman_bool_t
+pixman_format_is_opaque (pixman_format_code_t format)
+{
+ return !_get_format_info (format)->alpha;
+}
diff --git a/pixman/pixman-general.c b/pixman/pixman-general.c
index 3ea11d17..8cb05859 100644
--- a/pixman/pixman-general.c
+++ b/pixman/pixman-general.c
@@ -138,7 +138,7 @@ general_composite_rect (pixman_implementation_t *imp,
{
_pixman_color_space_get_converter (_pixman_image_get_color_space (src),
color_space,
- PIXMAN_FORMAT_A (src->bits.format),
+ !pixman_format_is_opaque (src->bits.format),
wide,
&convert_src,
&convert_src_data);
@@ -158,7 +158,7 @@ general_composite_rect (pixman_implementation_t *imp,
{
_pixman_color_space_get_converter (_pixman_image_get_color_space (mask),
color_space,
- PIXMAN_FORMAT_A (mask->bits.format),
+ !pixman_format_is_opaque (mask->bits.format),
wide,
&convert_mask,
&convert_mask_data);
@@ -178,7 +178,7 @@ general_composite_rect (pixman_implementation_t *imp,
{
_pixman_color_space_get_converter (_pixman_image_get_color_space (dest),
color_space,
- PIXMAN_FORMAT_A (dest->bits.format),
+ !pixman_format_is_opaque (dest->bits.format),
wide,
&convert_dest,
&convert_dest_data);
@@ -196,7 +196,7 @@ general_composite_rect (pixman_implementation_t *imp,
store = _pixman_image_store_scanline_32;
_pixman_color_space_get_converter (color_space,
_pixman_image_get_color_space (dest),
- PIXMAN_FORMAT_A (dest->bits.format),
+ !pixman_format_is_opaque (dest->bits.format),
wide,
&convert_dest_inv,
&convert_dest_inv_data);
diff --git a/pixman/pixman-image.c b/pixman/pixman-image.c
index 40285c19..b56feb88 100644
--- a/pixman/pixman-image.c
+++ b/pixman/pixman-image.c
@@ -391,10 +391,8 @@ compute_image_info (pixman_image_t *image)
}
}
- if (image->common.repeat != PIXMAN_REPEAT_NONE &&
- !PIXMAN_FORMAT_A (image->bits.format) &&
- PIXMAN_FORMAT_TYPE (image->bits.format) != PIXMAN_TYPE_GRAY &&
- PIXMAN_FORMAT_TYPE (image->bits.format) != PIXMAN_TYPE_COLOR)
+ if (image->common.repeat != PIXMAN_REPEAT_NONE &&
+ pixman_format_is_opaque (image->bits.format))
{
flags |= FAST_PATH_IS_OPAQUE;
}
diff --git a/pixman/pixman.h b/pixman/pixman.h
index 5d86084d..47ce1889 100644
--- a/pixman/pixman.h
+++ b/pixman/pixman.h
@@ -748,6 +748,7 @@ typedef enum {
pixman_bool_t pixman_format_supported_destination (pixman_format_code_t format);
pixman_bool_t pixman_format_supported_source (pixman_format_code_t format);
unsigned int pixman_format_num_planes (pixman_format_code_t format);
+pixman_bool_t pixman_format_is_opaque (pixman_format_code_t format);
/* Constructors */
pixman_image_t *pixman_image_create_solid_fill (pixman_color_t *color);