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 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