From d1947e768272c703674129d5c583204ff2b59251 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Wed, 13 Jul 2016 13:36:19 +0200 Subject: Second part of new SPObject children list (bzr r14954.1.19) --- src/sp-pattern.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'src/sp-pattern.cpp') diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index 55110f3c5..fde9f90f1 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -223,8 +223,8 @@ void SPPattern::_getChildren(std::list &l) { for (SPPattern *pat_i = this; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { if (pat_i->firstChild()) { // find the first one with children - for (SPObject *child = pat_i->firstChild(); child; child = child->getNext()) { - l.push_back(child); + for (auto& child: pat_i->_children) { + l.push_back(&child); } break; // do not go further up the chain if children are found } @@ -319,8 +319,8 @@ guint SPPattern::_countHrefs(SPObject *o) const i++; } - for (SPObject *child = o->firstChild(); child != NULL; child = child->next) { - i += _countHrefs(child); + for (auto& child: o->_children) { + i += _countHrefs(&child); } return i; @@ -508,13 +508,13 @@ Geom::OptRect SPPattern::viewbox() const bool SPPattern::_hasItemChildren() const { - bool hasChildren = false; - for (SPObject const *child = firstChild(); child && !hasChildren; child = child->getNext()) { - if (SP_IS_ITEM(child)) { - hasChildren = true; + for (auto& child: _children) { + if (SP_IS_ITEM(&child)) { + return true; } } - return hasChildren; + + return false; } bool SPPattern::isValid() const @@ -558,12 +558,12 @@ cairo_pattern_t *SPPattern::pattern_new(cairo_t *base_ct, Geom::OptRect const &b Inkscape::DrawingGroup *root = new Inkscape::DrawingGroup(drawing); drawing.setRoot(root); - for (SPObject *child = shown->firstChild(); child != NULL; child = child->getNext()) { - if (SP_IS_ITEM(child)) { + for (auto& child: shown->_children) { + if (SP_IS_ITEM(&child)) { // for each item in pattern, show it on our drawing, add to the group, // and connect to the release signal in case the item gets deleted Inkscape::DrawingItem *cai; - cai = SP_ITEM(child)->invoke_show(drawing, dkey, SP_ITEM_SHOW_DISPLAY); + cai = SP_ITEM(&child)->invoke_show(drawing, dkey, SP_ITEM_SHOW_DISPLAY); root->appendChild(cai); } } @@ -654,9 +654,9 @@ cairo_pattern_t *SPPattern::pattern_new(cairo_t *base_ct, Geom::OptRect const &b // Render drawing to pattern_surface via drawing context, this calls root->render // which is really DrawingItem->render(). drawing.render(dc, one_tile); - for (SPObject *child = shown->firstChild(); child != NULL; child = child->getNext()) { - if (SP_IS_ITEM(child)) { - SP_ITEM(child)->invoke_hide(dkey); + for (auto& child: shown->_children) { + if (SP_IS_ITEM(&child)) { + SP_ITEM(&child)->invoke_hide(dkey); } } -- cgit v1.2.3 From 24d3f50003ca3cec6a03a7f5267cc4fe5588c69f Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Thu, 14 Jul 2016 13:17:21 +0200 Subject: Renamed children list in SPObject (bzr r14954.1.21) --- src/sp-pattern.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/sp-pattern.cpp') diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index fde9f90f1..3b1ae3f0b 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -223,7 +223,7 @@ void SPPattern::_getChildren(std::list &l) { for (SPPattern *pat_i = this; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { if (pat_i->firstChild()) { // find the first one with children - for (auto& child: pat_i->_children) { + for (auto& child: pat_i->children) { l.push_back(&child); } break; // do not go further up the chain if children are found @@ -319,7 +319,7 @@ guint SPPattern::_countHrefs(SPObject *o) const i++; } - for (auto& child: o->_children) { + for (auto& child: o->children) { i += _countHrefs(&child); } @@ -508,7 +508,7 @@ Geom::OptRect SPPattern::viewbox() const bool SPPattern::_hasItemChildren() const { - for (auto& child: _children) { + for (auto& child: children) { if (SP_IS_ITEM(&child)) { return true; } @@ -558,7 +558,7 @@ cairo_pattern_t *SPPattern::pattern_new(cairo_t *base_ct, Geom::OptRect const &b Inkscape::DrawingGroup *root = new Inkscape::DrawingGroup(drawing); drawing.setRoot(root); - for (auto& child: shown->_children) { + for (auto& child: shown->children) { if (SP_IS_ITEM(&child)) { // for each item in pattern, show it on our drawing, add to the group, // and connect to the release signal in case the item gets deleted @@ -654,7 +654,7 @@ cairo_pattern_t *SPPattern::pattern_new(cairo_t *base_ct, Geom::OptRect const &b // Render drawing to pattern_surface via drawing context, this calls root->render // which is really DrawingItem->render(). drawing.render(dc, one_tile); - for (auto& child: shown->_children) { + for (auto& child: shown->children) { if (SP_IS_ITEM(&child)) { SP_ITEM(&child)->invoke_hide(dkey); } -- cgit v1.2.3 From f35bb1f74a0ffeb5c6477a25e3c4cde87a97bcf1 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Thu, 28 Jul 2016 12:06:06 +0200 Subject: Removed unused includes, decrease compilation time (bzr r15025) --- src/sp-pattern.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src/sp-pattern.cpp') diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index 55110f3c5..a68bee721 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -13,14 +13,13 @@ */ #ifdef HAVE_CONFIG_H -#include "config.h" +#include #endif #include #include #include #include <2geom/transforms.h> -#include #include "svg/svg.h" #include "display/cairo-utils.h" @@ -30,10 +29,7 @@ #include "display/drawing-group.h" #include "attributes.h" #include "document-private.h" -#include "uri.h" -#include "style.h" #include "sp-pattern.h" -#include "xml/repr.h" #include "sp-factory.h" -- cgit v1.2.3 From 43b49e325db73cc19b1731db6c69545664ee8fbe Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Thu, 28 Jul 2016 13:26:17 +0200 Subject: Reverted changes to r15024 after many building problems (bzr r15027) --- src/sp-pattern.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/sp-pattern.cpp') diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index a68bee721..55110f3c5 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -13,13 +13,14 @@ */ #ifdef HAVE_CONFIG_H -#include +#include "config.h" #endif #include #include #include #include <2geom/transforms.h> +#include #include "svg/svg.h" #include "display/cairo-utils.h" @@ -29,7 +30,10 @@ #include "display/drawing-group.h" #include "attributes.h" #include "document-private.h" +#include "uri.h" +#include "style.h" #include "sp-pattern.h" +#include "xml/repr.h" #include "sp-factory.h" -- cgit v1.2.3 From 35830f456cadaecf8b8e3944e3031a1a93f6cb41 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Wed, 3 Aug 2016 15:29:38 +0200 Subject: Removed unused includes, decreased compilation time. Once again (bzr r15034) --- src/sp-pattern.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src/sp-pattern.cpp') diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index 55110f3c5..a68bee721 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -13,14 +13,13 @@ */ #ifdef HAVE_CONFIG_H -#include "config.h" +#include #endif #include #include #include #include <2geom/transforms.h> -#include #include "svg/svg.h" #include "display/cairo-utils.h" @@ -30,10 +29,7 @@ #include "display/drawing-group.h" #include "attributes.h" #include "document-private.h" -#include "uri.h" -#include "style.h" #include "sp-pattern.h" -#include "xml/repr.h" #include "sp-factory.h" -- cgit v1.2.3 From 32e9ba119663b9d5800392ba34700053eaaa7f90 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Tue, 6 Sep 2016 12:37:35 +0200 Subject: Improve pattern rendering with large pattern transform. Partial fix for bug #1465753. (bzr r15108) --- src/sp-pattern.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/sp-pattern.cpp') diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index 77fa9034d..9d6296a0d 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -670,10 +670,20 @@ cairo_pattern_t *SPPattern::pattern_new(cairo_t *base_ct, Geom::OptRect const &b dc.paint(opacity); // apply opacity } - cairo_pattern_t *cp = cairo_pattern_create_for_surface(pattern_surface.raw()); // Apply transformation to user space. Also compensate for oversampling. - ink_cairo_pattern_set_matrix(cp, ps2user.inverse() * pattern_surface.drawingTransform()); + Geom::Affine raw_transform = ps2user.inverse() * pattern_surface.drawingTransform(); + + // Cairo doesn't like large values of x0 and y0. We can replace x0 and y0 by equivalent + // values close to zero (since one tile on a grid is the same as another it doesn't + // matter which tile is used as the base tile). + int w = one_tile[Geom::X].extent(); + int h = one_tile[Geom::Y].extent(); + int m = raw_transform[4] / w; + int n = raw_transform[5] / h; + raw_transform *= Geom::Translate( -m*w, -n*h ); + cairo_pattern_t *cp = cairo_pattern_create_for_surface(pattern_surface.raw()); + ink_cairo_pattern_set_matrix(cp, raw_transform); cairo_pattern_set_extend(cp, CAIRO_EXTEND_REPEAT); return cp; -- cgit v1.2.3 From 349536d49558ec5841e799eb33a4cbbb3fa9722d Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 5 Feb 2017 16:04:35 +0000 Subject: Fix C++11 errors and warnings with g++-7 Fixed bugs: - https://launchpad.net/bugs/1660992 (bzr r15477) --- src/sp-pattern.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/sp-pattern.cpp') diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index 9d6296a0d..377c035fc 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -16,11 +16,14 @@ #include #endif +#include "sp-pattern.h" + #include #include #include #include <2geom/transforms.h> +#include "bad-uri-exception.h" #include "svg/svg.h" #include "display/cairo-utils.h" #include "display/drawing-context.h" @@ -29,7 +32,6 @@ #include "display/drawing-group.h" #include "attributes.h" #include "document-private.h" -#include "sp-pattern.h" #include "sp-factory.h" -- cgit v1.2.3 From 66e9382175c3fb844d19b23f9d278a603f527d5e Mon Sep 17 00:00:00 2001 From: chr Date: Thu, 18 May 2017 19:58:59 +0200 Subject: bugfix crash while moving objects sp_svg_transform_write can return NULL and Glib::ustring blows up: terminate called after throwing an instance of 'std::logic_error' what(): basic_string::_S_construct null not valid #0 0x00007fffed6ec067 in raise () from /lib/x86_64-linux-gnu/libc.so.6 #1 0x00007fffed6ed448 in abort () from /lib/x86_64-linux-gnu/libc.so.6 #2 0x00007fffedac2b3d in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #3 0x00007fffedac0bb6 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #4 0x00007fffedac0c01 in std::terminate() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #5 0x00007fffedac0e19 in __cxa_throw () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #6 0x00007fffedb168b6 in std::__throw_logic_error(char const*) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #7 0x00007ffff76e83d5 in char* std::string::_S_construct(char const*, char const*, std::allocator const&, std::forward_iterator_tag) () from /usr/bin/../lib/inkscape/libinkscape_base.so #8 0x00007fffedb22c46 in std::basic_string, std::allocator >::basic_string(char const*, std::allocator const&) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #9 0x00007ffff036055e in Glib::ustring::ustring(char const*) () from /usr/lib/x86_64-linux-gnu/libglibmm-2.4.so.1 #10 0x00007ffff75650e3 in SPPattern::transform_multiply(Geom::Affine, bool) () from /usr/bin/../lib/inkscape/libinkscape_base.so #11 0x00007ffff753d862 in SPItem::adjust_pattern(Geom::Affine const&, bool, PatternTransform) () from /usr/bin/../lib/inkscape/libinkscape_base.so #12 0x00007ffff7562897 in SPPath::set_transform(Geom::Affine const&) () from /usr/bin/../lib/inkscape/libinkscape_base.so (bzr r15698.1.1) --- src/sp-pattern.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/sp-pattern.cpp') diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index 377c035fc..fcfdf552e 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -372,8 +372,9 @@ void SPPattern::transform_multiply(Geom::Affine postmul, bool set) } _pattern_transform_set = true; - Glib::ustring c = sp_svg_transform_write(_pattern_transform); + gchar *c = sp_svg_transform_write(_pattern_transform); getRepr()->setAttribute("patternTransform", c); + g_free(c); } const gchar *SPPattern::produce(const std::vector &reprs, Geom::Rect bounds, @@ -390,7 +391,7 @@ const gchar *SPPattern::produce(const std::vector &reprs, sp_repr_set_svg_double(repr, "height", bounds.dimensions()[Geom::Y]); //TODO: Maybe is better handle it in sp_svg_transform_write if(transform != Geom::Affine()){ - Glib::ustring t = sp_svg_transform_write(transform); + gchar *t = sp_svg_transform_write(transform); repr->setAttribute("patternTransform", t); } defsrepr->appendChild(repr); -- cgit v1.2.3 From 6c05c1c14cb8d29fb06d6779ec9817615c518ab5 Mon Sep 17 00:00:00 2001 From: chr Date: Thu, 18 May 2017 19:58:59 +0200 Subject: fix a brunch of memory leaks (bzr r15698.1.2) --- src/sp-pattern.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/sp-pattern.cpp') diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index fcfdf552e..1e198506b 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -393,6 +393,7 @@ const gchar *SPPattern::produce(const std::vector &reprs, if(transform != Geom::Affine()){ gchar *t = sp_svg_transform_write(transform); repr->setAttribute("patternTransform", t); + g_free(t); } defsrepr->appendChild(repr); const gchar *pat_id = repr->attribute("id"); -- cgit v1.2.3