summaryrefslogtreecommitdiffstats
path: root/src/display/drawing-shape.cpp
diff options
context:
space:
mode:
authorTavmjong Bah <tavmjong@free.fr>2014-02-18 21:18:19 +0000
committertavmjong-free <tavmjong@free.fr>2014-02-18 21:18:19 +0000
commit32ee2790305a26563723e75a3b84e0baa3f0dbf0 (patch)
tree5bf7cc5aae37490a0a845eb7c78844c80e9a11d2 /src/display/drawing-shape.cpp
parentImplement 'paint-order' for text. (diff)
downloadinkscape-32ee2790305a26563723e75a3b84e0baa3f0dbf0.tar.gz
inkscape-32ee2790305a26563723e75a3b84e0baa3f0dbf0.zip
Implement 'paint-order' for shapes (and paths).
(bzr r13040)
Diffstat (limited to 'src/display/drawing-shape.cpp')
-rw-r--r--src/display/drawing-shape.cpp132
1 files changed, 103 insertions, 29 deletions
diff --git a/src/display/drawing-shape.cpp b/src/display/drawing-shape.cpp
index f99f9442f..92d71fad3 100644
--- a/src/display/drawing-shape.cpp
+++ b/src/display/drawing-shape.cpp
@@ -149,6 +149,51 @@ DrawingShape::_updateItem(Geom::IntRect const &area, UpdateContext const &ctx, u
return STATE_ALL;
}
+#ifdef WITH_SVG2
+void
+DrawingShape::_renderFill(DrawingContext &dc)
+{
+ Inkscape::DrawingContext::Save save(dc);
+ dc.transform(_ctm);
+
+ bool has_fill = _nrstyle.prepareFill(dc, _item_bbox);
+
+ if( has_fill ) {
+ dc.path(_curve->get_pathvector());
+ _nrstyle.applyFill(dc);
+ dc.fillPreserve();
+ dc.newPath(); // clear path
+ }
+}
+
+void
+DrawingShape::_renderStroke(DrawingContext &dc)
+{
+ Inkscape::DrawingContext::Save save(dc);
+ dc.transform(_ctm);
+
+ bool has_stroke = _nrstyle.prepareStroke(dc, _item_bbox);
+ has_stroke &= (_nrstyle.stroke_width != 0);
+
+ if( has_stroke ) {
+ // TODO: remove segments outside of bbox when no dashes present
+ dc.path(_curve->get_pathvector());
+ _nrstyle.applyStroke(dc);
+ dc.strokePreserve();
+ dc.newPath(); // clear path
+ }
+}
+#endif
+
+void
+DrawingShape::_renderMarkers(DrawingContext &dc, Geom::IntRect const &area, unsigned flags, DrawingItem *stop_at)
+{
+ // marker rendering
+ for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) {
+ i->render(dc, area, flags, stop_at);
+ }
+}
+
unsigned
DrawingShape::_renderItem(DrawingContext &dc, Geom::IntRect const &area, unsigned flags, DrawingItem *stop_at)
{
@@ -160,6 +205,7 @@ DrawingShape::_renderItem(DrawingContext &dc, Geom::IntRect const &area, unsigne
if (outline) {
guint32 rgba = _drawing.outlinecolor;
+ // paint-order doesn't matter
{ Inkscape::DrawingContext::Save save(dc);
dc.transform(_ctm);
dc.path(_curve->get_pathvector());
@@ -170,39 +216,67 @@ DrawingShape::_renderItem(DrawingContext &dc, Geom::IntRect const &area, unsigne
dc.setTolerance(0.5);
dc.stroke();
}
- } else {
- bool has_stroke, has_fill;
- // we assume the context has no path
- Inkscape::DrawingContext::Save save(dc);
- dc.transform(_ctm);
-
- // update fill and stroke paints.
- // this cannot be done during nr_arena_shape_update, because we need a Cairo context
- // to render svg:pattern
- has_fill = _nrstyle.prepareFill(dc, _item_bbox);
- has_stroke = _nrstyle.prepareStroke(dc, _item_bbox);
- has_stroke &= (_nrstyle.stroke_width != 0);
-
- if (has_fill || has_stroke) {
- // TODO: remove segments outside of bbox when no dashes present
- dc.path(_curve->get_pathvector());
- if (has_fill) {
- _nrstyle.applyFill(dc);
- dc.fillPreserve();
- }
- if (has_stroke) {
- _nrstyle.applyStroke(dc);
- dc.strokePreserve();
- }
- dc.newPath(); // clear path
- } // has fill or stroke pattern
+
+ _renderMarkers(dc, area, flags, stop_at);
+ return RENDER_OK;
+
}
- // marker rendering
- for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) {
- i->render(dc, area, flags, stop_at);
+#ifdef WITH_SVG2
+ if( _nrstyle.paint_order_layer[0] == NRStyle::PAINT_ORDER_NORMAL ) {
+ // This is the most common case, special case so we don't call get_pathvector(), etc. twice
+#endif
+ {
+ // we assume the context has no path
+ Inkscape::DrawingContext::Save save(dc);
+ dc.transform(_ctm);
+
+ // update fill and stroke paints.
+ // this cannot be done during nr_arena_shape_update, because we need a Cairo context
+ // to render svg:pattern
+ bool has_fill = _nrstyle.prepareFill(dc, _item_bbox);
+ bool has_stroke = _nrstyle.prepareStroke(dc, _item_bbox);
+ has_stroke &= (_nrstyle.stroke_width != 0);
+
+ if (has_fill || has_stroke) {
+ // TODO: remove segments outside of bbox when no dashes present
+ dc.path(_curve->get_pathvector());
+ if (has_fill) {
+ _nrstyle.applyFill(dc);
+ dc.fillPreserve();
+ }
+ if (has_stroke) {
+ _nrstyle.applyStroke(dc);
+ dc.strokePreserve();
+ }
+ dc.newPath(); // clear path
+ } // has fill or stroke pattern
+ }
+ _renderMarkers(dc, area, flags, stop_at);
+ return RENDER_OK;
+
+#ifdef WITH_SVG2
+ }
+
+ // Handle different paint orders
+ for (unsigned i = 0; i < NRStyle::PAINT_ORDER_LAYERS; ++i) {
+ switch (_nrstyle.paint_order_layer[i]) {
+ case NRStyle::PAINT_ORDER_FILL:
+ _renderFill(dc);
+ break;
+ case NRStyle::PAINT_ORDER_STROKE:
+ _renderStroke(dc);
+ break;
+ case NRStyle::PAINT_ORDER_MARKER:
+ _renderMarkers(dc, area, flags, stop_at);
+ break;
+ default:
+ // PAINT_ORDER_AUTO Should not happen
+ break;
+ }
}
return RENDER_OK;
+#endif
}
void DrawingShape::_clipItem(DrawingContext &dc, Geom::IntRect const & /*area*/)