diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2013-11-12 23:54:23 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2013-11-12 23:54:23 +0000 |
| commit | 072f4e717d42b6a70532fb755b8e31a54cd313b6 (patch) | |
| tree | c26166b179735d68a965a6be90ae320133afe012 /src | |
| parent | Update to trunk (diff) | |
| parent | fix C++11 compilation. There A LOT of const_casts in this file... :-( (diff) | |
| download | inkscape-072f4e717d42b6a70532fb755b8e31a54cd313b6.tar.gz inkscape-072f4e717d42b6a70532fb755b8e31a54cd313b6.zip | |
Update to trunk
(bzr r11950.1.199)
Diffstat (limited to 'src')
| -rw-r--r-- | src/2geom/sbasis.h | 13 | ||||
| -rw-r--r-- | src/display/drawing-context.h | 4 | ||||
| -rw-r--r-- | src/display/drawing-image.cpp | 25 | ||||
| -rw-r--r-- | src/dom/svgimpl.cpp | 8 | ||||
| -rw-r--r-- | src/libnrtype/Layout-TNG-OutIter.cpp | 27 | ||||
| -rw-r--r-- | src/livarot/PathOutline.cpp | 2 | ||||
| -rw-r--r-- | src/remove-last.h | 7 | ||||
| -rw-r--r-- | src/sp-item-rm-unsatisfied-cns.cpp | 6 | ||||
| -rw-r--r-- | src/splivarot.cpp | 36 | ||||
| -rw-r--r-- | src/trace/siox.cpp | 1 | ||||
| -rw-r--r-- | src/ui/tool/node.h | 8 |
11 files changed, 78 insertions, 59 deletions
diff --git a/src/2geom/sbasis.h b/src/2geom/sbasis.h index e201f16ec..ca864ac7c 100644 --- a/src/2geom/sbasis.h +++ b/src/2geom/sbasis.h @@ -74,14 +74,16 @@ class SBasis{ public: // As part of our migration away from SBasis isa vector we provide this minimal set of vector interface methods. size_t size() const {return d.size();} + typedef std::vector<Linear>::iterator iterator; + typedef std::vector<Linear>::const_iterator const_iterator; Linear operator[](unsigned i) const { return d[i]; } Linear& operator[](unsigned i) { return d.at(i); } - Linear const* begin() const { return (Linear const*)&*d.begin();} - Linear const* end() const { return (Linear const*)&*d.end();} - Linear* begin() { return (Linear*)&*d.begin();} - Linear* end() { return (Linear*)&*d.end();} + const_iterator begin() const { return d.begin();} + const_iterator end() const { return d.end();} + iterator begin() { return d.begin();} + iterator end() { return d.end();} bool empty() const {return d.empty();} Linear &back() {return d.back();} Linear const &back() const {return d.back();} @@ -90,8 +92,7 @@ public: void resize(unsigned n, Linear const& l) { d.resize(n, l);} void reserve(unsigned n) { d.reserve(n);} void clear() {d.clear();} - void insert(Linear* before, const Linear* src_begin, const Linear* src_end) { d.insert(std::vector<Linear>::iterator(before), src_begin, src_end);} - //void insert(Linear* aa, Linear* bb, Linear* cc} { d.insert(aa, bb, cc);} + void insert(iterator before, const_iterator src_begin, const_iterator src_end) { d.insert(before, src_begin, src_end);} Linear& at(unsigned i) { return d.at(i);} //void insert(Linear* before, int& n, Linear const &l) { d.insert(std::vector<Linear>::iterator(before), n, l);} bool operator==(SBasis const&B) const { return d == B.d;} diff --git a/src/display/drawing-context.h b/src/display/drawing-context.h index d4f0dbfc3..35be9a86b 100644 --- a/src/display/drawing-context.h +++ b/src/display/drawing-context.h @@ -111,6 +111,10 @@ public: void setSource(DrawingSurface *s); void setSourceCheckerboard(); + void patternSetFilter(cairo_filter_t filter) { + cairo_pattern_set_filter(cairo_get_source(_ct), filter); + } + Geom::Rect targetLogicalBounds() const; cairo_t *raw() { return _ct; } diff --git a/src/display/drawing-image.cpp b/src/display/drawing-image.cpp index a9c0499c2..1b9214c49 100644 --- a/src/display/drawing-image.cpp +++ b/src/display/drawing-image.cpp @@ -108,13 +108,6 @@ unsigned DrawingImage::_renderItem(DrawingContext &ct, Geom::IntRect const &/*ar if (!outline) { if (!_pixbuf) return RENDER_OK; - - // if (_style) { - // _style->image_rendering.computed - // See: http://www.w3.org/TR/SVG/painting.html#ImageRenderingProperty - // http://www.w3.org/TR/css4-images/#the-image-rendering - // style.h/style.cpp - // } Inkscape::DrawingContext::Save save(ct); ct.transform(_ctm); @@ -126,6 +119,24 @@ unsigned DrawingImage::_renderItem(DrawingContext &ct, Geom::IntRect const &/*ar ct.scale(_scale); ct.setSource(_pixbuf->getSurfaceRaw(), 0, 0); + if (_style) { + // See: http://www.w3.org/TR/SVG/painting.html#ImageRenderingProperty + // http://www.w3.org/TR/css4-images/#the-image-rendering + // style.h/style.cpp + switch (_style->image_rendering.computed) { + case SP_CSS_COLOR_RENDERING_AUTO: + // Do nothing + break; + case SP_CSS_COLOR_RENDERING_OPTIMIZEQUALITY: + ct.patternSetFilter( CAIRO_FILTER_BEST ); + break; + case SP_CSS_COLOR_RENDERING_OPTIMIZESPEED: + default: + ct.patternSetFilter( CAIRO_FILTER_NEAREST ); + break; + } + } + ct.paint(_opacity); } else { // outline; draw a rect instead diff --git a/src/dom/svgimpl.cpp b/src/dom/svgimpl.cpp index 4372e1b87..0f420dc87 100644 --- a/src/dom/svgimpl.cpp +++ b/src/dom/svgimpl.cpp @@ -81,7 +81,7 @@ static double s2d(const DOMString &s) typedef struct { const char *name; - int type; + unsigned int type; } SVGTableEntry; @@ -119,7 +119,7 @@ SVGTableEntry interfaceTable[] = { "SVGUnitTypes", SVG_UNIT_TYPES }, { "SVGURIReference", SVG_URI_REFERENCE }, { "SVGViewSpec", SVG_VIEW_SPEC }, - { "SVGZoomAndPan", static_cast<int>(SVG_ZOOM_AND_PAN)} + { "SVGZoomAndPan", SVG_ZOOM_AND_PAN } }; @@ -266,9 +266,9 @@ int svgInterfaceStrToEnum(const char *str) * Return the string corresponding to a given SVG element type enum * Return "unknown" if not found */ -const char *svgInterfaceEnumToStr(int type) +const char *svgInterfaceEnumToStr(unsigned int type) { - if (type < 1 || type > (int)SVG_ZOOM_AND_PAN) + if (type < 1 || type > SVG_ZOOM_AND_PAN) return "unknown"; SVGTableEntry *entry = interfaceTable; for (int i = 0 ; i < SVG_NR_INTERFACES ; i++) diff --git a/src/libnrtype/Layout-TNG-OutIter.cpp b/src/libnrtype/Layout-TNG-OutIter.cpp index 4e61c10a0..8d8621d64 100644 --- a/src/libnrtype/Layout-TNG-OutIter.cpp +++ b/src/libnrtype/Layout-TNG-OutIter.cpp @@ -168,7 +168,7 @@ Layout::iterator Layout::getLetterAt(double x, double y) const return end(); } -Layout::iterator Layout::sourceToIterator(void *source_cookie, Glib::ustring::const_iterator text_iterator) const +Layout::iterator Layout::sourceToIterator(void *source_cookie /*, Glib::ustring::const_iterator text_iterator*/) const { unsigned source_index; if (_characters.empty()) return end(); @@ -182,6 +182,8 @@ Layout::iterator Layout::sourceToIterator(void *source_cookie, Glib::ustring::co return iterator(this, char_index); InputStreamTextSource const *text_source = static_cast<InputStreamTextSource const *>(_input_stream[source_index]); + return iterator(this, char_index); + /* This code was never used, the text_iterator argument was "NULL" in all calling code if (text_iterator <= text_source->text_begin) return iterator(this, char_index); if (text_iterator >= text_source->text_end) { if (source_index == _input_stream.size() - 1) return end(); @@ -194,11 +196,7 @@ Layout::iterator Layout::sourceToIterator(void *source_cookie, Glib::ustring::co iter_text++; } return end(); // never happens -} - -Layout::iterator Layout::sourceToIterator(void *source_cookie) const -{ - return sourceToIterator(source_cookie, Glib::ustring::const_iterator(std::string::const_iterator(NULL))); + */ } Geom::OptRect Layout::glyphBoundingBox(iterator const &it, double *rotation) const @@ -534,19 +532,24 @@ void Layout::getSourceOfCharacter(iterator const &it, void **source_cookie, Glib InputStreamItem *stream_item = _input_stream[_spans[_characters[it._char_index].in_span].in_input_stream_item]; *source_cookie = stream_item->source_cookie; if (text_iterator && stream_item->Type() == TEXT_SOURCE) { - InputStreamTextSource const *text_source = static_cast<InputStreamTextSource const *>(stream_item); - Glib::ustring::const_iterator text_iter_const = text_source->text_begin; + InputStreamTextSource *text_source = dynamic_cast<InputStreamTextSource *>(stream_item); + + // In order to return a non-const iterator in text_iterator, do the const_cast here. + // Note that, although ugly, it is safe because we do not write to *iterator anywhere. + Glib::ustring::iterator text_iter = const_cast<Glib::ustring *>(text_source->text)->begin(); + unsigned char_index = it._char_index; unsigned original_input_source_index = _spans[_characters[char_index].in_span].in_input_stream_item; // confusing algorithm because the iterator goes forwards while the index goes backwards. // It's just that it's faster doing it that way while (char_index && _spans[_characters[char_index - 1].in_span].in_input_stream_item == original_input_source_index) { - ++text_iter_const; + ++text_iter; char_index--; } - text_source->text->begin().base() + (text_iter_const.base() - text_source->text->begin().base()); - *text_iterator = Glib::ustring::iterator(std::string::iterator(const_cast<char*>(&*text_source->text->begin().base() + (text_iter_const.base() - text_source->text->begin().base())))); - // the caller owns the string, so they're going to want a non-const iterator + + if (text_iterator) { + *text_iterator = text_iter; + } } } diff --git a/src/livarot/PathOutline.cpp b/src/livarot/PathOutline.cpp index fbfaa98aa..f15da4af7 100644 --- a/src/livarot/PathOutline.cpp +++ b/src/livarot/PathOutline.cpp @@ -1183,7 +1183,7 @@ Path::OutlineJoin (Path * dest, Geom::Point pos, Geom::Point stNor, Geom::Point const double angSi = cross (enNor,stNor); const double angCo = dot (stNor, enNor); - if (angSi == 0 && angCo > 0) { // The join is straight -> nothing to do. + if (fabs(angSi < .0000001) && angCo > 0) { // The join is straight -> nothing to do. } else { if ((angSi > 0 && width >= 0) || (angSi < 0 && width < 0)) { // This is an inside join -> join is independent of chosen JoinType. diff --git a/src/remove-last.h b/src/remove-last.h index a5bbd89f8..8c84d0ed4 100644 --- a/src/remove-last.h +++ b/src/remove-last.h @@ -8,12 +8,9 @@ template<class T> inline void remove_last(std::vector<T> &seq, T const &elem) { - using std::vector; - - typename vector<T>::reverse_iterator i(find(seq.rbegin(), seq.rend(), elem)); + typename std::vector<T>::reverse_iterator i(find(seq.rbegin(), seq.rend(), elem)); g_assert( i != seq.rend() ); - typename vector<T>::iterator ii(&*i); - seq.erase(ii); + seq.erase(i.base()); } diff --git a/src/sp-item-rm-unsatisfied-cns.cpp b/src/sp-item-rm-unsatisfied-cns.cpp index 8fb171c08..7a712b083 100644 --- a/src/sp-item-rm-unsatisfied-cns.cpp +++ b/src/sp-item-rm-unsatisfied-cns.cpp @@ -24,10 +24,12 @@ void sp_item_rm_unsatisfied_cns(SPItem &item) g_assert( snappoint_ix < int(snappoints.size()) ); if (!Geom::are_near(cn.g->getDistanceFrom(snappoints[snappoint_ix].getPoint()), 0, 1e-2)) { + remove_last(cn.g->attached_items, SPGuideAttachment(&item, cn.snappoint_ix)); + g_assert( i < item.constraints.size() ); - vector<SPGuideConstraint>::iterator const ei(&item.constraints[i]); - item.constraints.erase(ei); + + item.constraints.erase(item.constraints.begin() + i); } } } diff --git a/src/splivarot.cpp b/src/splivarot.cpp index ad40178fb..7bf556aa1 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -338,6 +338,8 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool return; } + g_assert(il != NULL); + if (g_slist_length(il) > 2) { if (bop == bool_op_diff || bop == bool_op_cut || bop == bool_op_slice ) { boolop_display_error_message(desktop, _("Select <b>exactly 2 paths</b> to perform difference, division, or path cut.")); @@ -352,8 +354,8 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool if (bop == bool_op_diff || bop == bool_op_cut || bop == bool_op_slice) { // check in the tree to find which element of the selection list is topmost (for 2-operand commands only) - Inkscape::XML::Node *a = reinterpret_cast<SPObject *>(il->data)->getRepr(); - Inkscape::XML::Node *b = reinterpret_cast<SPObject *>(il->next->data)->getRepr(); + Inkscape::XML::Node *a = SP_OBJECT(il->data)->getRepr(); + Inkscape::XML::Node *b = SP_OBJECT(il->next->data)->getRepr(); if (a == NULL || b == NULL) { boolop_display_error_message(desktop, _("Unable to determine the <b>z-order</b> of the objects selected for difference, XOR, division, or path cut.")); @@ -393,6 +395,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool } il = g_slist_copy(il); + g_assert(il != NULL); // first check if all the input objects have shapes // otherwise bail out @@ -1160,7 +1163,7 @@ sp_selected_path_outline(SPDesktop *desktop) items != NULL; items = items->next) { - SPItem *item = (SPItem *) items->data; + SPItem *item = SP_ITEM(items->data); if (!SP_IS_SHAPE(item) && !SP_IS_TEXT(item)) continue; @@ -1177,6 +1180,8 @@ sp_selected_path_outline(SPDesktop *desktop) continue; } + g_assert(curve != NULL); + if (curve->get_pathvector().empty()) { continue; } @@ -1595,6 +1600,8 @@ void sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool } } + g_assert(curve != NULL); + Geom::Affine const transform(item->transform); item->doWriteTransform(item->getRepr(), Geom::identity()); @@ -1610,9 +1617,6 @@ void sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool float o_width = 0; { - SPStyle *i_style = item->style; - - o_width = i_style->stroke_width.computed; { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); o_width = prefs->getDouble("/options/defaultoffsetwidth/value", 1.0, "px"); @@ -1774,7 +1778,7 @@ sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset) items != NULL; items = items->next) { - SPItem *item = (SPItem *) items->data; + SPItem *item = SP_ITEM(items->data); if (!SP_IS_SHAPE(item) && !SP_IS_TEXT(item)) continue; @@ -1791,6 +1795,9 @@ sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset) continue; } + // We've now checked that there is a curve for this item + g_assert(curve != NULL); + Geom::Affine const transform(item->transform); item->doWriteTransform(item->getRepr(), Geom::identity()); @@ -1805,9 +1812,6 @@ sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset) { SPStyle *i_style = item->style; int jointype = i_style->stroke_linejoin.value; - //int captype = i_style->stroke_linecap.value; - - o_width = i_style->stroke_width.computed; switch (jointype) { case SP_STROKE_LINEJOIN_MITER: @@ -1821,18 +1825,6 @@ sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset) break; } - /*switch (captype) { - case SP_STROKE_LINECAP_SQUARE: - o_butt = butt_square; - break; - case SP_STROKE_LINECAP_ROUND: - o_butt = butt_round; - break; - default: - o_butt = butt_straight; - break; - }*/ - o_width = prefOffset; if (o_width < 0.1) diff --git a/src/trace/siox.cpp b/src/trace/siox.cpp index 92992d440..0706cfed1 100644 --- a/src/trace/siox.cpp +++ b/src/trace/siox.cpp @@ -11,6 +11,7 @@ #include <stdarg.h> #include <map> #include <algorithm> +#include <cstdlib> namespace org diff --git a/src/ui/tool/node.h b/src/ui/tool/node.h index 224d00855..d257db86a 100644 --- a/src/ui/tool/node.h +++ b/src/ui/tool/node.h @@ -16,7 +16,13 @@ #include <iosfwd> #include <stdexcept> #include <cstddef> + +#if __cplusplus >= 201103L +#include <functional> +#else #include <tr1/functional> +#endif + #include <boost/enable_shared_from_this.hpp> #include <boost/shared_ptr.hpp> #include "ui/tool/selectable-control-point.h" @@ -31,11 +37,13 @@ template <typename> class NodeIterator; } } +#if __cplusplus < 201103L namespace std { namespace tr1 { template <typename N> struct hash< Inkscape::UI::NodeIterator<N> >; } } +#endif namespace Inkscape { namespace UI { |
