diff options
| author | Krzysztof Kosi??ski <tweenk.pl@gmail.com> | 2011-07-10 03:33:59 +0000 |
|---|---|---|
| committer | Krzysztof KosiĆski <tweenk.pl@gmail.com> | 2011-07-10 03:33:59 +0000 |
| commit | 3099a49e82622b42547088666099f33d0d55b1ad (patch) | |
| tree | 5489f800f9f2444cbd2a976eec10c4cf3ca24242 /src/display | |
| parent | Redesign the rendering pipeline. Clipping paths are now rasterized. (diff) | |
| download | inkscape-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/display')
| -rw-r--r-- | src/display/nr-arena-glyphs.cpp | 10 | ||||
| -rw-r--r-- | src/display/nr-arena-group.cpp | 14 | ||||
| -rw-r--r-- | src/display/nr-arena-shape.cpp | 12 |
3 files changed, 31 insertions, 5 deletions
diff --git a/src/display/nr-arena-glyphs.cpp b/src/display/nr-arena-glyphs.cpp index 185551d31..b76e87a78 100644 --- a/src/display/nr-arena-glyphs.cpp +++ b/src/display/nr-arena-glyphs.cpp @@ -360,6 +360,14 @@ static unsigned int nr_arena_glyphs_group_clip(cairo_t *ct, NRArenaItem *item, N NRArenaGroup *ggroup = NR_ARENA_GLYPHS_GROUP(item); cairo_save(ct); + // handle clip-rule + if (ggroup->style) { + if (ggroup->style->clip_rule.computed == SP_WIND_RULE_EVENODD) { + cairo_set_fill_rule(ct, CAIRO_FILL_RULE_EVEN_ODD); + } else { + cairo_set_fill_rule(ct, CAIRO_FILL_RULE_WINDING); + } + } ink_cairo_transform(ct, ggroup->ctm); for (NRArenaItem *child = ggroup->children; child != NULL; child = child->next) { @@ -369,9 +377,9 @@ static unsigned int nr_arena_glyphs_group_clip(cairo_t *ct, NRArenaItem *item, N cairo_save(ct); ink_cairo_transform(ct, g->g_transform); feed_pathvector_to_cairo(ct, pathv); - cairo_fill(ct); cairo_restore(ct); } + cairo_fill(ct); cairo_restore(ct); return item->state; diff --git a/src/display/nr-arena-group.cpp b/src/display/nr-arena-group.cpp index 5f11c1a6b..714c4ecff 100644 --- a/src/display/nr-arena-group.cpp +++ b/src/display/nr-arena-group.cpp @@ -12,6 +12,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include "display/canvas-bpath.h" #include "display/nr-arena-group.h" #include "display/nr-filter.h" #include "display/nr-filter-types.h" @@ -234,14 +235,25 @@ static unsigned int nr_arena_group_clip (cairo_t *ct, NRArenaItem *item, NRRectL *area) { NRArenaGroup *group = NR_ARENA_GROUP (item); - unsigned int ret = item->state; + cairo_save(ct); + + // handle clip-rule + if (group->style) { + if (group->style->clip_rule.computed == SP_WIND_RULE_EVENODD) { + cairo_set_fill_rule(ct, CAIRO_FILL_RULE_EVEN_ODD); + } else { + cairo_set_fill_rule(ct, CAIRO_FILL_RULE_WINDING); + } + } + for (NRArenaItem *child = group->children; child != NULL; child = child->next) { ret = nr_arena_item_invoke_clip (ct, child, area); if (ret & NR_ARENA_ITEM_STATE_INVALID) break; } + cairo_restore(ct); return ret; } diff --git a/src/display/nr-arena-shape.cpp b/src/display/nr-arena-shape.cpp index 9bece05b5..6d65611bf 100644 --- a/src/display/nr-arena-shape.cpp +++ b/src/display/nr-arena-shape.cpp @@ -21,6 +21,7 @@ #include <2geom/svg-path-parser.h> #include "display/cairo-utils.h" #include "display/canvas-arena.h" +#include "display/canvas-bpath.h" #include "display/curve.h" #include "display/nr-arena.h" #include "display/nr-arena-shape.h" @@ -401,10 +402,15 @@ static guint nr_arena_shape_clip(cairo_t *ct, NRArenaItem *item, NRRectL * /*are return item->state; } - // TODO: Handling of the clip-rule property / CSS attribute. - // Once the required bits are in SPStyle, this is as trivial as adding a single - // call to cairo_set_fill_rule() before cairo_fill(). cairo_save(ct); + // handle clip-rule + if (shape->style) { + if (shape->style->clip_rule.computed == SP_WIND_RULE_EVENODD) { + cairo_set_fill_rule(ct, CAIRO_FILL_RULE_EVEN_ODD); + } else { + cairo_set_fill_rule(ct, CAIRO_FILL_RULE_WINDING); + } + } ink_cairo_transform(ct, shape->ctm); feed_pathvector_to_cairo(ct, shape->curve->get_pathvector()); cairo_fill(ct); |
