diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2014-01-12 19:02:53 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2014-01-12 19:02:53 +0000 |
| commit | ad38e0a823da469ba8a4866e0d6c46c87ed1b69c (patch) | |
| tree | 10d2a97375a51ad9ab32e9de58a1fb513e82cdef /src/display | |
| parent | Update to trunk (diff) | |
| parent | pass class variables by reference for performance (diff) | |
| download | inkscape-ad38e0a823da469ba8a4866e0d6c46c87ed1b69c.tar.gz inkscape-ad38e0a823da469ba8a4866e0d6c46c87ed1b69c.zip | |
update to trunk
(bzr r12588.1.31)
Diffstat (limited to 'src/display')
| -rw-r--r-- | src/display/canvas-axonomgrid.cpp | 6 | ||||
| -rw-r--r-- | src/display/canvas-axonomgrid.h | 6 | ||||
| -rw-r--r-- | src/display/canvas-grid.cpp | 6 | ||||
| -rw-r--r-- | src/display/canvas-grid.h | 6 | ||||
| -rw-r--r-- | src/display/drawing-item.cpp | 88 | ||||
| -rw-r--r-- | src/display/drawing-item.h | 5 | ||||
| -rw-r--r-- | src/display/drawing-text.cpp | 34 | ||||
| -rw-r--r-- | src/display/nr-filter-blend.cpp | 52 | ||||
| -rw-r--r-- | src/display/nr-filter-blend.h | 16 | ||||
| -rw-r--r-- | src/display/nr-filter-composite.cpp | 35 | ||||
| -rw-r--r-- | src/display/snap-indicator.cpp | 48 |
11 files changed, 238 insertions, 64 deletions
diff --git a/src/display/canvas-axonomgrid.cpp b/src/display/canvas-axonomgrid.cpp index d66b97bbc..858312f5b 100644 --- a/src/display/canvas-axonomgrid.cpp +++ b/src/display/canvas-axonomgrid.cpp @@ -727,19 +727,19 @@ CanvasAxonomGridSnapper::_getSnapLines(Geom::Point const &p) const return s; } -void CanvasAxonomGridSnapper::_addSnappedLine(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const normal_to_line, Geom::Point const point_on_line) const +void CanvasAxonomGridSnapper::_addSnappedLine(IntermSnapResults &isr, Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const &normal_to_line, Geom::Point const &point_on_line) const { SnappedLine dummy = SnappedLine(snapped_point, snapped_distance, source, source_num, Inkscape::SNAPTARGET_GRID, getSnapperTolerance(), getSnapperAlwaysSnap(), normal_to_line, point_on_line); isr.grid_lines.push_back(dummy); } -void CanvasAxonomGridSnapper::_addSnappedPoint(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const +void CanvasAxonomGridSnapper::_addSnappedPoint(IntermSnapResults &isr, Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const { SnappedPoint dummy = SnappedPoint(snapped_point, source, source_num, Inkscape::SNAPTARGET_GRID, snapped_distance, getSnapperTolerance(), getSnapperAlwaysSnap(), constrained_snap, true); isr.points.push_back(dummy); } -void CanvasAxonomGridSnapper::_addSnappedLinePerpendicularly(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const +void CanvasAxonomGridSnapper::_addSnappedLinePerpendicularly(IntermSnapResults &isr, Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const { SnappedPoint dummy = SnappedPoint(snapped_point, source, source_num, Inkscape::SNAPTARGET_GRID_PERPENDICULAR, snapped_distance, getSnapperTolerance(), getSnapperAlwaysSnap(), constrained_snap, true); isr.points.push_back(dummy); diff --git a/src/display/canvas-axonomgrid.h b/src/display/canvas-axonomgrid.h index 4e5af863d..3888a3dc4 100644 --- a/src/display/canvas-axonomgrid.h +++ b/src/display/canvas-axonomgrid.h @@ -72,9 +72,9 @@ public: private: LineList _getSnapLines(Geom::Point const &p) const; - void _addSnappedLine(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const normal_to_line, const Geom::Point point_on_line) const; - void _addSnappedPoint(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const; - void _addSnappedLinePerpendicularly(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const; + void _addSnappedLine(IntermSnapResults &isr, Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const &normal_to_line, const Geom::Point &point_on_line) const; + void _addSnappedPoint(IntermSnapResults &isr, Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const; + void _addSnappedLinePerpendicularly(IntermSnapResults &isr, Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const; CanvasAxonomGrid *grid; }; diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp index 192cc4cba..3c4ad9b00 100644 --- a/src/display/canvas-grid.cpp +++ b/src/display/canvas-grid.cpp @@ -1031,19 +1031,19 @@ CanvasXYGridSnapper::_getSnapLines(Geom::Point const &p) const return s; } -void CanvasXYGridSnapper::_addSnappedLine(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const normal_to_line, Geom::Point const point_on_line) const +void CanvasXYGridSnapper::_addSnappedLine(IntermSnapResults &isr, Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const &normal_to_line, Geom::Point const &point_on_line) const { SnappedLine dummy = SnappedLine(snapped_point, snapped_distance, source, source_num, Inkscape::SNAPTARGET_GRID, getSnapperTolerance(), getSnapperAlwaysSnap(), normal_to_line, point_on_line); isr.grid_lines.push_back(dummy); } -void CanvasXYGridSnapper::_addSnappedPoint(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const +void CanvasXYGridSnapper::_addSnappedPoint(IntermSnapResults &isr, Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const { SnappedPoint dummy = SnappedPoint(snapped_point, source, source_num, Inkscape::SNAPTARGET_GRID, snapped_distance, getSnapperTolerance(), getSnapperAlwaysSnap(), constrained_snap, true); isr.points.push_back(dummy); } -void CanvasXYGridSnapper::_addSnappedLinePerpendicularly(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const +void CanvasXYGridSnapper::_addSnappedLinePerpendicularly(IntermSnapResults &isr, Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const { SnappedPoint dummy = SnappedPoint(snapped_point, source, source_num, Inkscape::SNAPTARGET_GRID_PERPENDICULAR, snapped_distance, getSnapperTolerance(), getSnapperAlwaysSnap(), constrained_snap, true); isr.points.push_back(dummy); diff --git a/src/display/canvas-grid.h b/src/display/canvas-grid.h index 078670da7..5a23dee52 100644 --- a/src/display/canvas-grid.h +++ b/src/display/canvas-grid.h @@ -167,9 +167,9 @@ public: private: LineList _getSnapLines(Geom::Point const &p) const; - void _addSnappedLine(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const normal_to_line, const Geom::Point point_on_line) const; - void _addSnappedPoint(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const; - void _addSnappedLinePerpendicularly(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const; + void _addSnappedLine(IntermSnapResults &isr, Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const &normal_to_line, const Geom::Point &point_on_line) const; + void _addSnappedPoint(IntermSnapResults &isr, Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const; + void _addSnappedLinePerpendicularly(IntermSnapResults &isr, Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const; CanvasXYGrid *grid; }; diff --git a/src/display/drawing-item.cpp b/src/display/drawing-item.cpp index a8257e6e5..a9b07bb6e 100644 --- a/src/display/drawing-item.cpp +++ b/src/display/drawing-item.cpp @@ -23,6 +23,66 @@ namespace Inkscape { +#ifdef WITH_CSSBLEND +void set_cairo_blend_operator( DrawingContext &ct, unsigned blend_mode ) { + + // All of the blend modes are implemented in Cairo as of 1.10. + // For a detailed description, see: + // http://cairographics.org/operators/ + switch (blend_mode) { + case SP_CSS_BLEND_MULTIPLY: + ct.setOperator(CAIRO_OPERATOR_MULTIPLY); + break; + case SP_CSS_BLEND_SCREEN: + ct.setOperator(CAIRO_OPERATOR_SCREEN); + break; + case SP_CSS_BLEND_DARKEN: + ct.setOperator(CAIRO_OPERATOR_DARKEN); + break; + case SP_CSS_BLEND_LIGHTEN: + ct.setOperator(CAIRO_OPERATOR_LIGHTEN); + break; + case SP_CSS_BLEND_OVERLAY: + ct.setOperator(CAIRO_OPERATOR_OVERLAY); + break; + case SP_CSS_BLEND_COLORDODGE: + ct.setOperator(CAIRO_OPERATOR_COLOR_DODGE); + break; + case SP_CSS_BLEND_COLORBURN: + ct.setOperator(CAIRO_OPERATOR_COLOR_BURN); + break; + case SP_CSS_BLEND_HARDLIGHT: + ct.setOperator(CAIRO_OPERATOR_HARD_LIGHT); + break; + case SP_CSS_BLEND_SOFTLIGHT: + ct.setOperator(CAIRO_OPERATOR_SOFT_LIGHT); + break; + case SP_CSS_BLEND_DIFFERENCE: + ct.setOperator(CAIRO_OPERATOR_DIFFERENCE); + break; + case SP_CSS_BLEND_EXCLUSION: + ct.setOperator(CAIRO_OPERATOR_EXCLUSION); + break; + case SP_CSS_BLEND_HUE: + ct.setOperator(CAIRO_OPERATOR_HSL_HUE); + break; + case SP_CSS_BLEND_SATURATION: + ct.setOperator(CAIRO_OPERATOR_HSL_SATURATION); + break; + case SP_CSS_BLEND_COLOR: + ct.setOperator(CAIRO_OPERATOR_HSL_COLOR); + break; + case SP_CSS_BLEND_LUMINOSITY: + ct.setOperator(CAIRO_OPERATOR_HSL_LUMINOSITY); + break; + case SP_CSS_BLEND_NORMAL: + default: + ct.setOperator(CAIRO_OPERATOR_OVER); + break; + } +} +#endif + /** * @class DrawingItem * SVG drawing item for display. @@ -67,6 +127,8 @@ DrawingItem::DrawingItem(Drawing &drawing) , _propagate(0) // , _renders_opacity(0) , _pick_children(0) + , _isolation(SP_CSS_ISOLATION_AUTO) + , _blend_mode(SP_CSS_BLEND_NORMAL) {} DrawingItem::~DrawingItem() @@ -209,6 +271,22 @@ DrawingItem::setOpacity(float opacity) } void +DrawingItem::setIsolation(unsigned isolation) +{ + _isolation = isolation; + //if( isolation != 0 ) std::cout << "isolation: " << isolation << std::endl; + _markForRendering(); +} + +void +DrawingItem::setBlendMode(unsigned blend_mode) +{ + _blend_mode = blend_mode; + //if( blend_mode != 0 ) std::cout << "setBlendMode: " << blend_mode << std::endl; + _markForRendering(); +} + +void DrawingItem::setVisible(bool v) { _visible = v; @@ -494,6 +572,9 @@ DrawingItem::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flag if (_cached) { if (_cache) { _cache->prepare(); +#ifdef WITH_CSSBLEND + set_cairo_blend_operator( ct, _blend_mode ); +#endif _cache->paintFromCache(ct, carea); if (!carea) return RENDER_OK; } else { @@ -522,6 +603,10 @@ DrawingItem::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flag nir |= (_filter != NULL && render_filters); // 3. it has a filter nir |= needs_opacity; // 4. it is non-opaque nir |= (_cache != NULL); // 5. it is cached +#ifdef WITH_CSSBLEND + nir |= (_blend_mode != SP_CSS_BLEND_NORMAL); // 6. Blend mode not normal + nir |= (_isolation == SP_CSS_ISOLATION_ISOLATE); // 7. Explicit isolatiom +#endif /* How the rendering is done. * @@ -633,6 +718,9 @@ DrawingItem::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flag } ct.rectangle(*carea); ct.setSource(&intermediate); +#ifdef WITH_CSSBLEND + set_cairo_blend_operator( ct, _blend_mode ); +#endif ct.fill(); ct.setSource(0,0,0,0); // the call above is to clear a ref on the intermediate surface held by ct diff --git a/src/display/drawing-item.h b/src/display/drawing-item.h index e03bbd0f7..1796d29d6 100644 --- a/src/display/drawing-item.h +++ b/src/display/drawing-item.h @@ -108,6 +108,8 @@ public: void setCached(bool c, bool persistent = false); void setOpacity(float opacity); + void setIsolation(unsigned isolation); // CSS Compositing and Blending + void setBlendMode(unsigned blend_mode); void setTransform(Geom::Affine const &trans); void setClip(DrawingItem *item); void setMask(DrawingItem *item); @@ -204,6 +206,9 @@ protected: unsigned _pick_children : 1; ///< For groups: if true, children are returned from pick(), /// otherwise the group is returned + unsigned _isolation : 1; + unsigned _blend_mode : 4; + friend class Drawing; }; diff --git a/src/display/drawing-text.cpp b/src/display/drawing-text.cpp index f37f4d3c4..f652a2970 100644 --- a/src/display/drawing-text.cpp +++ b/src/display/drawing-text.cpp @@ -67,13 +67,11 @@ unsigned DrawingGlyphs::_updateItem(Geom::IntRect const &/*area*/, UpdateContext _pick_bbox = Geom::IntRect(); _bbox = Geom::IntRect(); - Geom::OptRect b; - /* orignally it did the one line below, but it did not handle ws characters at all, and it had problems with scaling for overline/underline. Replaced with the section below, which seems to be much more stable. - b = bounds_exact_transformed(*_font->PathVector(_glyph), ctx.ctm); + Geom::OptRect b = bounds_exact_transformed(*_font->PathVector(_glyph), ctx.ctm); */ /* Make a bounding box that is a little taller and lower (currently 10% extra) than the font's drawing box. Extra space is to hold overline or underline, if present. All characters in a font use the same ascent and descent, @@ -81,37 +79,37 @@ unsigned DrawingGlyphs::_updateItem(Geom::IntRect const &/*area*/, UpdateContext the bounding box is limited to the box surrounding the drawn parts of visible glyphs only, and draws outside are ignored. */ - float scale = 1.0; - if(_transform){ scale /= _transform->descrim(); } - - Geom::Rect bigbox(Geom::Point(0.0, _asc*scale*1.1),Geom::Point(_width*scale, -_dsc*scale*1.1)); - b = bigbox * ctx.ctm; + float scale_bigbox = 1.0; + if (_transform) { + scale_bigbox /= _transform->descrim(); + } - if (b && (ggroup->_nrstyle.stroke.type != NRStyle::PAINT_NONE)) { - float width, scale; + Geom::Rect bigbox(Geom::Point(0.0, _asc*scale_bigbox*1.1),Geom::Point(_width*scale_bigbox, -_dsc*scale_bigbox*1.1)); + Geom::Rect b = bigbox * ctx.ctm; + if (ggroup->_nrstyle.stroke.type != NRStyle::PAINT_NONE) { // this expands the selection box for cases where the stroke is "thick" - scale = ctx.ctm.descrim(); + float scale = ctx.ctm.descrim(); if (_transform) { scale /= _transform->descrim(); // FIXME temporary hack } - width = MAX(0.125, ggroup->_nrstyle.stroke_width * scale); + float width = MAX(0.125, ggroup->_nrstyle.stroke_width * scale); if ( fabs(ggroup->_nrstyle.stroke_width * scale) > 0.01 ) { // FIXME: this is always true - b->expandBy(0.5 * width); + b.expandBy(0.5 * width); } // save bbox without miters for picking - _pick_bbox = b->roundOutwards(); + _pick_bbox = b.roundOutwards(); float miterMax = width * ggroup->_nrstyle.miter_limit; if ( miterMax > 0.01 ) { // grunt mode. we should compute the various miters instead // (one for each point on the curve) - b->expandBy(miterMax); + b.expandBy(miterMax); } - _bbox = b->roundOutwards(); - } else if (b) { - _bbox = b->roundOutwards(); + _bbox = b.roundOutwards(); + } else { + _bbox = b.roundOutwards(); _pick_bbox = *_bbox; } /* diff --git a/src/display/nr-filter-blend.cpp b/src/display/nr-filter-blend.cpp index bff7405b7..099816bce 100644 --- a/src/display/nr-filter-blend.cpp +++ b/src/display/nr-filter-blend.cpp @@ -83,6 +83,43 @@ void FilterBlend::render_cairo(FilterSlot &slot) case BLEND_LIGHTEN: cairo_set_operator(out_ct, CAIRO_OPERATOR_LIGHTEN); break; +#ifdef WITH_CSSBLEND + // NEW + case BLEND_OVERLAY: + cairo_set_operator(out_ct, CAIRO_OPERATOR_OVERLAY); + break; + case BLEND_COLORDODGE: + cairo_set_operator(out_ct, CAIRO_OPERATOR_COLOR_DODGE); + break; + case BLEND_COLORBURN: + cairo_set_operator(out_ct, CAIRO_OPERATOR_COLOR_BURN); + break; + case BLEND_HARDLIGHT: + cairo_set_operator(out_ct, CAIRO_OPERATOR_HARD_LIGHT); + break; + case BLEND_SOFTLIGHT: + cairo_set_operator(out_ct, CAIRO_OPERATOR_SOFT_LIGHT); + break; + case BLEND_DIFFERENCE: + cairo_set_operator(out_ct, CAIRO_OPERATOR_DIFFERENCE); + break; + case BLEND_EXCLUSION: + cairo_set_operator(out_ct, CAIRO_OPERATOR_EXCLUSION); + break; + case BLEND_HUE: + cairo_set_operator(out_ct, CAIRO_OPERATOR_HSL_HUE); + break; + case BLEND_SATURATION: + cairo_set_operator(out_ct, CAIRO_OPERATOR_HSL_SATURATION); + break; + case BLEND_COLOR: + cairo_set_operator(out_ct, CAIRO_OPERATOR_HSL_COLOR); + break; + case BLEND_LUMINOSITY: + cairo_set_operator(out_ct, CAIRO_OPERATOR_HSL_LUMINOSITY); + break; +#endif + case BLEND_NORMAL: default: cairo_set_operator(out_ct, CAIRO_OPERATOR_OVER); @@ -128,9 +165,18 @@ void FilterBlend::set_input(int input, int slot) { } void FilterBlend::set_mode(FilterBlendMode mode) { - if (mode == BLEND_NORMAL || mode == BLEND_MULTIPLY || - mode == BLEND_SCREEN || mode == BLEND_DARKEN || - mode == BLEND_LIGHTEN) + if (mode == BLEND_NORMAL || mode == BLEND_MULTIPLY || + mode == BLEND_SCREEN || mode == BLEND_DARKEN || + mode == BLEND_LIGHTEN +#ifdef WITH_CSSBLEND + || mode == BLEND_OVERLAY || + mode == BLEND_COLORDODGE || mode == BLEND_COLORBURN || + mode == BLEND_HARDLIGHT || mode == BLEND_SOFTLIGHT || + mode == BLEND_DIFFERENCE || mode == BLEND_EXCLUSION || + mode == BLEND_HUE || mode == BLEND_SATURATION || + mode == BLEND_COLOR || mode == BLEND_LUMINOSITY +#endif + ) { _blend_mode = mode; } diff --git a/src/display/nr-filter-blend.h b/src/display/nr-filter-blend.h index 957d3cfc8..0a2927d87 100644 --- a/src/display/nr-filter-blend.h +++ b/src/display/nr-filter-blend.h @@ -28,7 +28,21 @@ enum FilterBlendMode { BLEND_SCREEN, BLEND_DARKEN, BLEND_LIGHTEN, - BLEND_ENDMODE +#ifdef WITH_CSSBLEND + // New in CSS Compositing and Blending Level 1 + BLEND_OVERLAY, + BLEND_COLORDODGE, + BLEND_COLORBURN, + BLEND_HARDLIGHT, + BLEND_SOFTLIGHT, + BLEND_DIFFERENCE, + BLEND_EXCLUSION, + BLEND_HUE, + BLEND_SATURATION, + BLEND_COLOR, + BLEND_LUMINOSITY, +#endif + BLEND_ENDMODE, }; class FilterBlend : public FilterPrimitive { diff --git a/src/display/nr-filter-composite.cpp b/src/display/nr-filter-composite.cpp index f6decad0d..dc5e4278f 100644 --- a/src/display/nr-filter-composite.cpp +++ b/src/display/nr-filter-composite.cpp @@ -98,6 +98,33 @@ void FilterComposite::render_cairo(FilterSlot &slot) case COMPOSITE_XOR: cairo_set_operator(ct, CAIRO_OPERATOR_XOR); break; +#ifdef WITH_CSSCOMPOSITE + /* New CSS Operators */ + case COMPOSITE_CLEAR: + cairo_set_operator(ct, CAIRO_OPERATOR_CLEAR); + break; + case COMPOSITE_COPY: + cairo_set_operator(ct, CAIRO_OPERATOR_SOURCE); + break; + case COMPOSITE_DESTINATION: + cairo_set_operator(ct, CAIRO_OPERATOR_DEST); + break; + case COMPOSITE_DESTINATION_OVER: + cairo_set_operator(ct, CAIRO_OPERATOR_DEST_OVER); + break; + case COMPOSITE_DESTINATION_IN: + cairo_set_operator(ct, CAIRO_OPERATOR_DEST_IN); + break; + case COMPOSITE_DESTINATION_OUT: + cairo_set_operator(ct, CAIRO_OPERATOR_DEST_OUT); + break; + case COMPOSITE_DESTINATION_ATOP: + cairo_set_operator(ct, CAIRO_OPERATOR_DEST_ATOP); + break; + case COMPOSITE_LIGHTER: + cairo_set_operator(ct, CAIRO_OPERATOR_ADD); + break; +#endif case COMPOSITE_OVER: case COMPOSITE_DEFAULT: default: @@ -129,13 +156,7 @@ void FilterComposite::set_input(int input, int slot) { void FilterComposite::set_operator(FeCompositeOperator op) { if (op == COMPOSITE_DEFAULT) { this->op = COMPOSITE_OVER; - } else if (op == COMPOSITE_OVER || - op == COMPOSITE_IN || - op == COMPOSITE_OUT || - op == COMPOSITE_ATOP || - op == COMPOSITE_XOR || - op == COMPOSITE_ARITHMETIC) - { + } else if (op != COMPOSITE_ENDOPERATOR) { this->op = op; } } diff --git a/src/display/snap-indicator.cpp b/src/display/snap-indicator.cpp index 1dd3022c7..627bfb2ab 100644 --- a/src/display/snap-indicator.cpp +++ b/src/display/snap-indicator.cpp @@ -262,36 +262,38 @@ SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const &p, bool pre_snap // Display the tooltip, which reveals the type of snap source and the type of snap target gchar *tooltip_str = NULL; - if (p.getSource() != SNAPSOURCE_GRID_PITCH) { + if ( (p.getSource() != SNAPSOURCE_GRID_PITCH) && (p.getTarget() != SNAPTARGET_UNDEFINED) ) { tooltip_str = g_strconcat(source_name, _(" to "), target_name, NULL); - } else { + } else if (p.getSource() != SNAPSOURCE_UNDEFINED) { tooltip_str = g_strdup(source_name); } double fontsize = prefs->getInt("/tools/measure/fontsize"); - Geom::Point tooltip_pos = p.getPoint(); - if (tools_isactive(_desktop, TOOLS_MEASURE)) { - // Make sure that the snap tooltips do not overlap the ones from the measure tool - tooltip_pos += _desktop->w2d(Geom::Point(0, -3*fontsize)); - } else { - tooltip_pos += _desktop->w2d(Geom::Point(0, -2*fontsize)); + if (tooltip_str) { + Geom::Point tooltip_pos = p.getPoint(); + if (tools_isactive(_desktop, TOOLS_MEASURE)) { + // Make sure that the snap tooltips do not overlap the ones from the measure tool + tooltip_pos += _desktop->w2d(Geom::Point(0, -3*fontsize)); + } else { + tooltip_pos += _desktop->w2d(Geom::Point(0, -2*fontsize)); + } + + SPCanvasItem *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(_desktop), _desktop, tooltip_pos, tooltip_str); + sp_canvastext_set_fontsize(SP_CANVASTEXT(canvas_tooltip), fontsize); + SP_CANVASTEXT(canvas_tooltip)->rgba = 0xffffffff; + SP_CANVASTEXT(canvas_tooltip)->outline = false; + SP_CANVASTEXT(canvas_tooltip)->background = true; + if (pre_snap) { + SP_CANVASTEXT(canvas_tooltip)->rgba_background = 0x33337f40; + } else { + SP_CANVASTEXT(canvas_tooltip)->rgba_background = 0x33337f7f; + } + SP_CANVASTEXT(canvas_tooltip)->anchor_position = TEXT_ANCHOR_CENTER; + g_free(tooltip_str); + + _snaptarget_tooltip = _desktop->add_temporary_canvasitem(canvas_tooltip, timeout_val); } - SPCanvasItem *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(_desktop), _desktop, tooltip_pos, tooltip_str); - sp_canvastext_set_fontsize(SP_CANVASTEXT(canvas_tooltip), fontsize); - SP_CANVASTEXT(canvas_tooltip)->rgba = 0xffffffff; - SP_CANVASTEXT(canvas_tooltip)->outline = false; - SP_CANVASTEXT(canvas_tooltip)->background = true; - if (pre_snap) { - SP_CANVASTEXT(canvas_tooltip)->rgba_background = 0x33337f40; - } else { - SP_CANVASTEXT(canvas_tooltip)->rgba_background = 0x33337f7f; - } - SP_CANVASTEXT(canvas_tooltip)->anchor_position = TEXT_ANCHOR_CENTER; - g_free(tooltip_str); - - _snaptarget_tooltip = _desktop->add_temporary_canvasitem(canvas_tooltip, timeout_val); - // Display the bounding box, if we snapped to one Geom::OptRect const bbox = p.getTargetBBox(); if (bbox) { |
