From 6ba000db056d7e9b70a7e154a003644046bf7e98 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Sat, 29 Jan 2011 21:51:45 +0000 Subject: Add support for opacity property svn path=/trunk/libcss/; revision=11527 --- include/libcss/computed.h | 28 ++++++++++++++++++++++++++-- include/libcss/hint.h | 1 + include/libcss/properties.h | 8 +++++++- 3 files changed, 34 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/libcss/computed.h b/include/libcss/computed.h index 818d9db..094fd59 100644 --- a/include/libcss/computed.h +++ b/include/libcss/computed.h @@ -181,7 +181,7 @@ struct css_computed_style { * --- * 84 bits * - * Colours are 32bits of RRGGBBAA + * Colours are 32bits of AARRGGBB * Dimensions are encoded as a fixed point value + 4 bits of unit data * * background_color 2 4 @@ -269,7 +269,7 @@ struct css_computed_style { * 21 mmmmmccc min-width | clear * 22 tttttooo padding-top | overflow * 23 rrrrrppp padding-right | position - * 24 bbbbb... padding-bottom | + * 24 bbbbbo.. padding-bottom | opacity | * 25 lllllttt padding-left | text-transform * 26 tttttwww text-indent | white-space * 27 bbbbbbbb background-position @@ -315,6 +315,8 @@ struct css_computed_style { css_fixed min_height; css_fixed min_width; + css_fixed opacity; + css_fixed padding[4]; css_fixed text_indent; @@ -1771,6 +1773,28 @@ static inline uint8_t css_computed_position( #undef CSS_POSITION_SHIFT #undef CSS_POSITION_INDEX +#define CSS_OPACITY_INDEX 23 +#define CSS_OPACITY_SHIFT 2 +#define CSS_OPACITY_MASK 0x04 +static inline uint8_t css_computed_opacity( + const css_computed_style *style, + css_fixed *opacity) +{ + uint8_t bits = style->bits[CSS_OPACITY_INDEX]; + bits &= CSS_OPACITY_MASK; + bits >>= CSS_OPACITY_SHIFT; + + /* 1bit: t : type */ + if ((bits & 0x1) == CSS_OPACITY_SET) { + *opacity = style->opacity; + } + + return (bits & 0x1); +} +#undef CSS_OPACITY_MASK +#undef CSS_OPACITY_SHIFT +#undef CSS_OPACITY_INDEX + #define CSS_TEXT_TRANSFORM_INDEX 24 #define CSS_TEXT_TRANSFORM_SHIFT 0 #define CSS_TEXT_TRANSFORM_MASK 0x7 diff --git a/include/libcss/hint.h b/include/libcss/hint.h index 917794a..c3e928d 100644 --- a/include/libcss/hint.h +++ b/include/libcss/hint.h @@ -38,6 +38,7 @@ typedef struct css_hint { css_color color; css_computed_content_item *content; css_computed_counter *counter; + css_fixed fixed; int32_t integer; css_hint_length length; struct { diff --git a/include/libcss/properties.h b/include/libcss/properties.h index 11fb04d..4218956 100644 --- a/include/libcss/properties.h +++ b/include/libcss/properties.h @@ -113,8 +113,9 @@ enum css_properties_e { CSS_PROP_WIDTH = 0x060, CSS_PROP_WORD_SPACING = 0x061, CSS_PROP_Z_INDEX = 0x062, + CSS_PROP_OPACITY = 0x063, - CSS_N_PROPERTIES = CSS_PROP_Z_INDEX + 1 + CSS_N_PROPERTIES }; @@ -441,6 +442,11 @@ enum css_min_width_e { CSS_MIN_WIDTH_SET = 0x1 }; +enum css_opacity_e { + CSS_OPACITY_INHERIT = 0x0, + CSS_OPACITY_SET = 0x1 +}; + enum css_outline_color_e { CSS_OUTLINE_COLOR_INHERIT = CSS_BACKGROUND_COLOR_INHERIT, CSS_OUTLINE_COLOR_COLOR = CSS_BACKGROUND_COLOR_COLOR, -- cgit v1.2.3