summaryrefslogtreecommitdiffstats
path: root/src/style.cpp
diff options
context:
space:
mode:
authorKrzysztof Kosi??ski <tweenk.pl@gmail.com>2011-07-10 03:33:59 +0000
committerKrzysztof KosiƄski <tweenk.pl@gmail.com>2011-07-10 03:33:59 +0000
commit3099a49e82622b42547088666099f33d0d55b1ad (patch)
tree5489f800f9f2444cbd2a976eec10c4cf3ca24242 /src/style.cpp
parentRedesign the rendering pipeline. Clipping paths are now rasterized. (diff)
downloadinkscape-3099a49e82622b42547088666099f33d0d55b1ad.tar.gz
inkscape-3099a49e82622b42547088666099f33d0d55b1ad.zip
Implement handling of the clip-rule property. Partially based on
a patch by Andrew Lutomirski. Fixed bugs: - https://launchpad.net/bugs/171243 (bzr r10347.1.8)
Diffstat (limited to 'src/style.cpp')
-rw-r--r--src/style.cpp30
1 files changed, 28 insertions, 2 deletions
diff --git a/src/style.cpp b/src/style.cpp
index 37a784e2a..e66c15494 100644
--- a/src/style.cpp
+++ b/src/style.cpp
@@ -335,6 +335,12 @@ static SPStyleEnum const enum_enable_background[] = {
{NULL, -1}
};
+static SPStyleEnum const enum_clip_rule[] = {
+ {"nonzero", SP_WIND_RULE_NONZERO},
+ {"evenodd", SP_WIND_RULE_EVENODD},
+ {NULL, -1}
+};
+
/**
* Release callback.
*/
@@ -767,6 +773,9 @@ sp_style_read(SPStyle *style, SPObject *object, Inkscape::XML::Node *repr)
SPS_READ_PENUM_IF_UNSET(&style->enable_background, repr,
"enable-background", enum_enable_background, true);
+ /* clip-rule */
+ SPS_READ_PENUM_IF_UNSET(&style->clip_rule, repr, "clip-rule", enum_clip_rule, true);
+
/* 3. Merge from parent */
if (object) {
if (object->parent) {
@@ -1020,7 +1029,9 @@ sp_style_merge_property(SPStyle *style, gint id, gchar const *val)
style->object->getRepr()->setAttribute("clip-path", val);
break;
case SP_PROP_CLIP_RULE:
- g_warning("Unimplemented style property SP_PROP_CLIP_RULE: value: %s", val);
+ if (!style->clip_rule.set) {
+ sp_style_read_ienum(&style->clip_rule, val, enum_clip_rule, true);
+ }
break;
case SP_PROP_MASK:
/** \todo
@@ -1645,6 +1656,11 @@ sp_style_merge_from_parent(SPStyle *const style, SPStyle const *const parent)
if(style->enable_background.inherit) {
style->enable_background.value = parent->enable_background.value;
}
+
+ /* Clipping */
+ if (!style->clip_rule.set || style->clip_rule.inherit) {
+ style->clip_rule.computed = parent->clip_rule.computed;
+ }
}
template <typename T>
@@ -1906,7 +1922,7 @@ sp_style_merge_from_dying_parent(SPStyle *const style, SPStyle const *const pare
/* Enum values that don't have any relative settings (other than `inherit'). */
{
SPIEnum SPStyle::*const fields[] = {
- //nyi: SPStyle::clip_rule,
+ &SPStyle::clip_rule,
//nyi: SPStyle::color_interpolation,
//nyi: SPStyle::color_interpolation_filters,
//nyi: SPStyle::color_rendering,
@@ -2446,6 +2462,9 @@ sp_style_write_string(SPStyle const *const style, guint const flags)
p += sp_style_write_ienum(p, c + BMAX - p, "enable-background", enum_enable_background, &style->enable_background, NULL, flags);
+ /* clipping */
+ p += sp_style_write_ienum(p, c + BMAX - p, "clip-rule", enum_clip_rule, &style->clip_rule, NULL, flags);
+
/* fixme: */
p += sp_text_style_write(p, c + BMAX - p, style->text, flags);
@@ -2592,6 +2611,8 @@ sp_style_write_difference(SPStyle const *const from, SPStyle const *const to)
p += sp_text_style_write(p, c + BMAX - p, from->text, SP_STYLE_FLAG_IFDIFF);
+ p += sp_style_write_ienum(p, c + BMAX - p, "clip-rule", enum_clip_rule, &from->clip_rule, &to->clip_rule, SP_STYLE_FLAG_IFDIFF);
+
/** \todo
* The reason we use IFSET rather than IFDIFF is the belief that the IFDIFF
* flag is mainly only for attributes that don't handle explicit unset well.
@@ -2783,6 +2804,8 @@ sp_style_clear(SPStyle *style)
style->enable_background.value = SP_CSS_BACKGROUND_ACCUMULATE;
style->enable_background.set = false;
style->enable_background.inherit = false;
+
+ style->clip_rule.value = style->clip_rule.computed = SP_WIND_RULE_NONZERO;
}
@@ -4178,6 +4201,9 @@ sp_style_unset_property_attrs(SPObject *o)
if (style->enable_background.set) {
repr->setAttribute("enable-background", NULL);
}
+ if (style->clip_rule.set) {
+ repr->setAttribute("clip-rule", NULL);
+ }
}
/**