diff options
| author | Tavmjong Bah <tavmjong@free.fr> | 2014-12-21 14:29:02 +0000 |
|---|---|---|
| committer | tavmjong-free <tavmjong@free.fr> | 2014-12-21 14:29:02 +0000 |
| commit | b6d303d11e572d8888d29c44e11d06d256821a03 (patch) | |
| tree | 715b43f92a002f4c2a3bdadc7fb10675b60d85eb /src/display/nr-style.cpp | |
| parent | disable rev 13709, following Bug 1365451, comments 13-16 (diff) | |
| download | inkscape-b6d303d11e572d8888d29c44e11d06d256821a03.tar.gz inkscape-b6d303d11e572d8888d29c44e11d06d256821a03.zip | |
Implement rendering for 'context-fill' and 'context-stroke' (text not handled yet).
(bzr r13807)
Diffstat (limited to 'src/display/nr-style.cpp')
| -rw-r--r-- | src/display/nr-style.cpp | 89 |
1 files changed, 57 insertions, 32 deletions
diff --git a/src/display/nr-style.cpp b/src/display/nr-style.cpp index 70382ef50..9dadaf3f1 100644 --- a/src/display/nr-style.cpp +++ b/src/display/nr-style.cpp @@ -93,35 +93,41 @@ NRStyle::~NRStyle() text_decoration_stroke.clear(); } -void NRStyle::set(SPStyle *style) +void NRStyle::set(SPStyle *style, SPStyle *context_style) { // Handle 'context-fill' and 'context-stroke': Work in progress - SPIPaint &style_fill = style->fill; - if( style_fill.paintOrigin == SP_CSS_PAINT_ORIGIN_CONTEXT_FILL ) { - // std::cout << "NRStyle::set: fill: context-fill" << std::endl; - // style_fill = context_fill; - } else if ( style_fill.paintOrigin == SP_CSS_PAINT_ORIGIN_CONTEXT_STROKE ) { - //std::cout << "NRStyle::set: fill: context-stroke" << std::endl; - // style_fill = context_stroke; + const SPIPaint *style_fill = &(style->fill); + if( style_fill->paintOrigin == SP_CSS_PAINT_ORIGIN_CONTEXT_FILL ) { + if( context_style != NULL ) { + style_fill = &(context_style->fill); + } else { + std::cerr << "NRStyle::set: 'context-fill': 'context_style' is NULL" << std::endl; + } + } else if ( style_fill->paintOrigin == SP_CSS_PAINT_ORIGIN_CONTEXT_STROKE ) { + if( context_style != NULL ) { + style_fill = &(context_style->stroke); + } else { + std::cerr << "NRStyle::set: 'context-stroke': 'context_style' is NULL" << std::endl; + } } - - if ( style_fill.isPaintserver() ) { + + if ( style_fill->isPaintserver() ) { SPPaintServer* server = style->getFillPaintServer(); if ( server && server->isValid() ) { fill.set(server); - } else if ( style_fill.colorSet ) { - fill.set(style_fill.value.color); + } else if ( style_fill->colorSet ) { + fill.set(style_fill->value.color); } else { fill.clear(); } - } else if ( style_fill.isColor() ) { - fill.set(style_fill.value.color); - } else if ( style_fill.isNone() ) { + } else if ( style_fill->isColor() ) { + fill.set(style_fill->value.color); + } else if ( style_fill->isNone() ) { fill.clear(); - } else if ( style_fill.paintOrigin == SP_CSS_PAINT_ORIGIN_CONTEXT_FILL ) { - // std::cout << "NRStyle::set: fill: context-fill DOUBLE" << std::endl; - } else if ( style_fill.paintOrigin == SP_CSS_PAINT_ORIGIN_CONTEXT_STROKE ) { - // std::cout << "NRStyle::set: fill: context-stroke DOUBLE" << std::endl; + } else if ( style_fill->paintOrigin == SP_CSS_PAINT_ORIGIN_CONTEXT_FILL ) { + std::cerr << "NRStyle::set: fill: context-fill: Double" << std::endl; + } else if ( style_fill->paintOrigin == SP_CSS_PAINT_ORIGIN_CONTEXT_STROKE ) { + std::cerr << "NRStyle::set: fill: context-stroke: Double" << std::endl; } else { g_assert_not_reached(); } @@ -139,26 +145,42 @@ void NRStyle::set(SPStyle *style) g_assert_not_reached(); } - if ( style->stroke.isPaintserver() ) { + const SPIPaint *style_stroke = &(style->stroke); + if( style_stroke->paintOrigin == SP_CSS_PAINT_ORIGIN_CONTEXT_FILL ) { + if( context_style != NULL ) { + style_stroke = &(context_style->fill); + } else { + std::cerr << "NRStyle::set: 'context-fill': 'context_style' is NULL" << std::endl; + } + } else if ( style_stroke->paintOrigin == SP_CSS_PAINT_ORIGIN_CONTEXT_STROKE ) { + if( context_style != NULL ) { + style_stroke = &(context_style->stroke); + } else { + std::cerr << "NRStyle::set: 'context-stroke': 'context_style' is NULL" << std::endl; + } + } + + if ( style_stroke->isPaintserver() ) { SPPaintServer* server = style->getStrokePaintServer(); if ( server && server->isValid() ) { stroke.set(server); - } else if ( style->stroke.isColor() ) { - stroke.set(style->stroke.colorSet); + } else if ( style_stroke->isColor() ) { + stroke.set(style_stroke->colorSet); } else { stroke.clear(); } - } else if ( style->stroke.isColor() ) { - stroke.set(style->stroke.value.color); - } else if ( style->stroke.isNone() ) { + } else if ( style_stroke->isColor() ) { + stroke.set(style_stroke->value.color); + } else if ( style_stroke->isNone() ) { stroke.clear(); - } else if ( style->stroke.paintOrigin == SP_CSS_PAINT_ORIGIN_CONTEXT_FILL ) { - // std::cout << "NRStyle::set: stroke: context-fill" << std::endl; - } else if ( style->stroke.paintOrigin == SP_CSS_PAINT_ORIGIN_CONTEXT_STROKE ) { - // std::cout << "NRStyle::set: stroke: context-stroke" << std::endl; + } else if ( style_stroke->paintOrigin == SP_CSS_PAINT_ORIGIN_CONTEXT_FILL ) { + std::cerr << "NRStyle::set: stroke: context-fill: Double" << std::endl; + } else if ( style_stroke->paintOrigin == SP_CSS_PAINT_ORIGIN_CONTEXT_STROKE ) { + std::cerr << "NRStyle::set: stroke: context-stroke: Double" << std::endl; } else { g_assert_not_reached(); } + stroke.opacity = SP_SCALE24_TO_FLOAT(style->stroke_opacity.value); stroke_width = style->stroke_width.computed; switch (style->stroke_linecap.computed) { @@ -329,13 +351,16 @@ bool NRStyle::prepareFill(Inkscape::DrawingContext &dc, Geom::OptRect const &pai fill_pattern = pattern->renderPattern(fill.opacity); } else { fill_pattern = fill.server->pattern_new(dc.raw(), paintbox, fill.opacity); - } break; + } + break; case PAINT_COLOR: { SPColor const &c = fill.color; fill_pattern = cairo_pattern_create_rgba( c.v.c[0], c.v.c[1], c.v.c[2], fill.opacity); - } break; - default: break; + } + break; + default: + break; } } if (!fill_pattern) return false; |
