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-gradient.cpp | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'src/sp-gradient.cpp') diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index 854d53dc4..abfae1a1f 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -276,8 +276,8 @@ void SPGradient::build(SPDocument *document, Inkscape::XML::Node *repr) SPPaintServer::build(document, repr); - for ( SPObject *ochild = this->firstChild() ; ochild ; ochild = ochild->getNext() ) { - if (SP_IS_STOP(ochild)) { + for (auto& ochild: _children) { + if (SP_IS_STOP(&ochild)) { this->has_stops = TRUE; break; } @@ -481,8 +481,8 @@ void SPGradient::remove_child(Inkscape::XML::Node *child) SPPaintServer::remove_child(child); this->has_stops = FALSE; - for ( SPObject *ochild = this->firstChild() ; ochild ; ochild = ochild->getNext() ) { - if (SP_IS_STOP(ochild)) { + for (auto& ochild: _children) { + if (SP_IS_STOP(&ochild)) { this->has_stops = TRUE; break; } @@ -536,9 +536,9 @@ void SPGradient::modified(guint flags) // FIXME: climb up the ladder of hrefs GSList *l = NULL; - for (SPObject *child = this->firstChild() ; child; child = child->getNext() ) { - sp_object_ref(child); - l = g_slist_prepend(l, child); + for (auto& child: _children) { + sp_object_ref(&child); + l = g_slist_prepend(l, &child); } l = g_slist_reverse(l); @@ -557,10 +557,11 @@ void SPGradient::modified(guint flags) SPStop* SPGradient::getFirstStop() { - SPStop* first = 0; - for (SPObject *ochild = firstChild(); ochild && !first; ochild = ochild->getNext()) { - if (SP_IS_STOP(ochild)) { - first = SP_STOP(ochild); + SPStop* first = nullptr; + for (auto& ochild: _children) { + if (SP_IS_STOP(&ochild)) { + first = SP_STOP(&ochild); + break; } } return first; @@ -587,8 +588,8 @@ Inkscape::XML::Node *SPGradient::write(Inkscape::XML::Document *xml_doc, Inkscap if (flags & SP_OBJECT_WRITE_BUILD) { GSList *l = NULL; - for (SPObject *child = this->firstChild(); child; child = child->getNext()) { - Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags); + for (auto& child: _children) { + Inkscape::XML::Node *crepr = child.updateRepr(xml_doc, NULL, flags); if (crepr) { l = g_slist_prepend(l, crepr); @@ -915,8 +916,8 @@ bool SPGradient::invalidateArray() void SPGradient::rebuildVector() { gint len = 0; - for ( SPObject *child = firstChild() ; child ; child = child->getNext() ) { - if (SP_IS_STOP(child)) { + for (auto& child: _children) { + if (SP_IS_STOP(&child)) { len ++; } } @@ -937,9 +938,9 @@ void SPGradient::rebuildVector() } } - for ( SPObject *child = firstChild(); child; child = child->getNext() ) { - if (SP_IS_STOP(child)) { - SPStop *stop = SP_STOP(child); + for (auto& child: _children) { + if (SP_IS_STOP(&child)) { + SPStop *stop = SP_STOP(&child); SPGradientStop gstop; if (!vector.stops.empty()) { @@ -1022,8 +1023,8 @@ void SPGradient::rebuildArray() array.read( SP_MESH( this ) ); has_patches = false; - for ( SPObject *ro = firstChild() ; ro ; ro = ro->getNext() ) { - if (SP_IS_MESHROW(ro)) { + for (auto& ro: _children) { + if (SP_IS_MESHROW(&ro)) { has_patches = true; // std::cout << " Has Patches" << std::endl; break; -- 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-gradient.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/sp-gradient.cpp') diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index abfae1a1f..afa209dbe 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -276,7 +276,7 @@ void SPGradient::build(SPDocument *document, Inkscape::XML::Node *repr) SPPaintServer::build(document, repr); - for (auto& ochild: _children) { + for (auto& ochild: children) { if (SP_IS_STOP(&ochild)) { this->has_stops = TRUE; break; @@ -481,7 +481,7 @@ void SPGradient::remove_child(Inkscape::XML::Node *child) SPPaintServer::remove_child(child); this->has_stops = FALSE; - for (auto& ochild: _children) { + for (auto& ochild: children) { if (SP_IS_STOP(&ochild)) { this->has_stops = TRUE; break; @@ -536,7 +536,7 @@ void SPGradient::modified(guint flags) // FIXME: climb up the ladder of hrefs GSList *l = NULL; - for (auto& child: _children) { + for (auto& child: children) { sp_object_ref(&child); l = g_slist_prepend(l, &child); } @@ -558,7 +558,7 @@ void SPGradient::modified(guint flags) SPStop* SPGradient::getFirstStop() { SPStop* first = nullptr; - for (auto& ochild: _children) { + for (auto& ochild: children) { if (SP_IS_STOP(&ochild)) { first = SP_STOP(&ochild); break; @@ -588,7 +588,7 @@ Inkscape::XML::Node *SPGradient::write(Inkscape::XML::Document *xml_doc, Inkscap if (flags & SP_OBJECT_WRITE_BUILD) { GSList *l = NULL; - for (auto& child: _children) { + for (auto& child: children) { Inkscape::XML::Node *crepr = child.updateRepr(xml_doc, NULL, flags); if (crepr) { @@ -916,7 +916,7 @@ bool SPGradient::invalidateArray() void SPGradient::rebuildVector() { gint len = 0; - for (auto& child: _children) { + for (auto& child: children) { if (SP_IS_STOP(&child)) { len ++; } @@ -938,7 +938,7 @@ void SPGradient::rebuildVector() } } - for (auto& child: _children) { + for (auto& child: children) { if (SP_IS_STOP(&child)) { SPStop *stop = SP_STOP(&child); @@ -1023,7 +1023,7 @@ void SPGradient::rebuildArray() array.read( SP_MESH( this ) ); has_patches = false; - for (auto& ro: _children) { + for (auto& ro: children) { if (SP_IS_MESHROW(&ro)) { has_patches = true; // std::cout << " Has Patches" << std::endl; -- 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-gradient.cpp | 7 ------- 1 file changed, 7 deletions(-) (limited to 'src/sp-gradient.cpp') diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index 854d53dc4..49143bda4 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -35,7 +35,6 @@ #include "display/cairo-utils.h" #include "svg/svg.h" -#include "svg/svg-color.h" #include "svg/css-ostringstream.h" #include "attributes.h" #include "document-private.h" @@ -46,13 +45,7 @@ #include "sp-radial-gradient.h" #include "sp-mesh.h" #include "sp-mesh-row.h" -#include "sp-mesh-patch.h" #include "sp-stop.h" -#include "streq.h" -#include "uri.h" -#include "xml/repr.h" -#include "style.h" -#include "display/grayscale.h" /// Has to be power of 2 Seems to be unused. //#define NCOLORS NR_GRADIENT_VECTOR_LENGTH -- 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-gradient.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/sp-gradient.cpp') diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index 49143bda4..854d53dc4 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -35,6 +35,7 @@ #include "display/cairo-utils.h" #include "svg/svg.h" +#include "svg/svg-color.h" #include "svg/css-ostringstream.h" #include "attributes.h" #include "document-private.h" @@ -45,7 +46,13 @@ #include "sp-radial-gradient.h" #include "sp-mesh.h" #include "sp-mesh-row.h" +#include "sp-mesh-patch.h" #include "sp-stop.h" +#include "streq.h" +#include "uri.h" +#include "xml/repr.h" +#include "style.h" +#include "display/grayscale.h" /// Has to be power of 2 Seems to be unused. //#define NCOLORS NR_GRADIENT_VECTOR_LENGTH -- 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-gradient.cpp | 7 ------- 1 file changed, 7 deletions(-) (limited to 'src/sp-gradient.cpp') diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index 854d53dc4..49143bda4 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -35,7 +35,6 @@ #include "display/cairo-utils.h" #include "svg/svg.h" -#include "svg/svg-color.h" #include "svg/css-ostringstream.h" #include "attributes.h" #include "document-private.h" @@ -46,13 +45,7 @@ #include "sp-radial-gradient.h" #include "sp-mesh.h" #include "sp-mesh-row.h" -#include "sp-mesh-patch.h" #include "sp-stop.h" -#include "streq.h" -#include "uri.h" -#include "xml/repr.h" -#include "style.h" -#include "display/grayscale.h" /// Has to be power of 2 Seems to be unused. //#define NCOLORS NR_GRADIENT_VECTOR_LENGTH -- cgit v1.2.3 From f273f14eb1b54861f1b3a7eb622cb481ee33cec9 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Mon, 26 Sep 2016 13:26:47 +0200 Subject: Fix undo/redo for mesh gradients. (bzr r15135) --- src/sp-gradient.cpp | 86 +++++++++++++++++++++++------------------------------ 1 file changed, 38 insertions(+), 48 deletions(-) (limited to 'src/sp-gradient.cpp') diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index f24e25ab1..5c0fdfe2b 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -22,6 +22,7 @@ */ #define noSP_GRADIENT_VERBOSE +//#define OBJECT_TRACE #include #include @@ -228,7 +229,7 @@ SPGradient::SPGradient() : SPPaintServer(), units(), state(2), vector() { - this->has_patches = 0; + this->has_patches = 0; this->ref = new SPGradientReference(this); this->ref->changedSignal().connect(sigc::bind(sigc::ptr_fun(SPGradient::gradientRefChanged), this)); @@ -318,6 +319,12 @@ void SPGradient::release() */ void SPGradient::set(unsigned key, gchar const *value) { +#ifdef OBJECT_TRACE + std::stringstream temp; + temp << "SPGradient::set: " << key << " " << (value?value:"null"); + objectTrace( temp.str() ); +#endif + switch (key) { case SP_ATTR_GRADIENTUNITS: if (value) { @@ -409,6 +416,10 @@ void SPGradient::set(unsigned key, gchar const *value) SPPaintServer::set(key, value); break; } + +#ifdef OBJECT_TRACE + objectTrace( "SPGradient::set", false ); +#endif } /** @@ -498,29 +509,24 @@ void SPGradient::remove_child(Inkscape::XML::Node *child) */ void SPGradient::modified(guint flags) { +#ifdef OBJECT_TRACE + objectTrace( "SPGradient::modified" ); +#endif + if (flags & SP_OBJECT_CHILD_MODIFIED_FLAG) { - // CPPIFY - // This comparison has never worked (i. e. always evaluated to false), - // the right value would have been SP_TYPE_MESH - //if( this->get_type() != SP_GRADIENT_TYPE_MESH ) { -// if (!SP_IS_MESH(this)) { -// this->invalidateVector(); -// } else { -// this->invalidateArray(); -// } - this->invalidateVector(); + if (SP_IS_MESH(this)) { + this->invalidateArray(); + } else { + this->invalidateVector(); + } } if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) { - // CPPIFY - // see above - //if( this->get_type() != SP_GRADIENT_TYPE_MESH ) { -// if (!SP_IS_MESH(this)) { -// this->ensureVector(); -// } else { -// this->ensureArray(); -// } - this->ensureVector(); + if (SP_IS_MESH(this)) { + this->ensureArray(); + } else { + this->ensureVector(); + } } if (flags & SP_OBJECT_MODIFIED_FLAG) flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; @@ -546,6 +552,10 @@ void SPGradient::modified(guint flags) sp_object_unref(child); } + +#ifdef OBJECT_TRACE + objectTrace( "SPGradient::modified", false ); +#endif } SPStop* SPGradient::getFirstStop() @@ -576,6 +586,10 @@ int SPGradient::getStopCount() const */ Inkscape::XML::Node *SPGradient::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { +#ifdef OBJECT_TRACE + objectTrace( "SPGradient::write" ); +#endif + SPPaintServer::write(xml_doc, repr, flags); if (flags & SP_OBJECT_WRITE_BUILD) { @@ -646,6 +660,9 @@ Inkscape::XML::Node *SPGradient::write(Inkscape::XML::Document *xml_doc, Inkscap repr->setAttribute( "osb:paint", 0 ); } +#ifdef OBJECT_TRACE + objectTrace( "SPGradient::write", false ); +#endif return repr; } @@ -898,7 +915,7 @@ bool SPGradient::invalidateArray() if (array.built) { array.built = false; - array.clear(); + // array.clear(); ret = true; } @@ -1014,33 +1031,6 @@ void SPGradient::rebuildArray() } array.read( SP_MESH( this ) ); - - has_patches = false; - for (auto& ro: children) { - if (SP_IS_MESHROW(&ro)) { - has_patches = true; - // std::cout << " Has Patches" << std::endl; - break; - } - } - - // MESH_FIXME: TO PROPERLY COPY - SPGradient *reffed = ref->getObject(); - if ( !hasPatches() && reffed ) { - std::cout << "SPGradient::rebuildArray(): reffed array NOT IMPLEMENTED!!!" << std::endl; - /* Copy array from referenced gradient */ - array.built = true; // Prevent infinite recursion. - reffed->ensureArray(); - // if (!reffed->array.nodes.empty()) { - // array.built = reffed->array.built; - // for( uint i = 0; i < reffed->array.nodes.size(); ++i ) { - // array.nodes[i].assign(reffed->array.nodes[i].begin(), reffed->array.nodes[i].end()); - - // // FILL ME - // } - // return; - // } - } } Geom::Affine -- cgit v1.2.3 From f9ec83dbb254701f39d3b7a30c0bacb5eaae9ee9 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Tue, 27 Sep 2016 10:51:26 +0200 Subject: Rename to per SVG 2 CR specificiation. Note: has been repurposed to be a special shape that tightly wraps a mesh gradient. (bzr r15137) --- src/sp-gradient.cpp | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'src/sp-gradient.cpp') diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index 5c0fdfe2b..d3e38485b 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -1,6 +1,6 @@ /** \file * SPGradient, SPStop, SPLinearGradient, SPRadialGradient, - * SPMesh, SPMeshRow, SPMeshPatch + * SPMeshGradient, SPMeshRow, SPMeshPatch */ /* * Authors: @@ -44,7 +44,7 @@ #include "sp-gradient-reference.h" #include "sp-linear-gradient.h" #include "sp-radial-gradient.h" -#include "sp-mesh.h" +#include "sp-mesh-gradient.h" #include "sp-mesh-row.h" #include "sp-stop.h" @@ -115,7 +115,7 @@ bool SPGradient::isEquivalent(SPGradient *that) else if ( (SP_IS_LINEARGRADIENT(this) && SP_IS_LINEARGRADIENT(that)) || (SP_IS_RADIALGRADIENT(this) && SP_IS_RADIALGRADIENT(that)) || - (SP_IS_MESH(this) && SP_IS_MESH(that))) { + (SP_IS_MESHGRADIENT(this) && SP_IS_MESHGRADIENT(that))) { if(!this->isAligned(that))break; } else { break; } // this should never happen, some unhandled type of gradient @@ -200,9 +200,9 @@ bool SPGradient::isAligned(SPGradient *that) (sg->fy.computed != tg->fy.computed) ) { break; } } else if( sg->cx._set || sg->cy._set || sg->fx._set || sg->fy._set || sg->r._set ) { break; } // some mix of set and not set // none set? assume aligned and fall through - } else if (SP_IS_MESH(this) && SP_IS_MESH(that)) { - SPMesh *sg=SP_MESH(this); - SPMesh *tg=SP_MESH(that); + } else if (SP_IS_MESHGRADIENT(this) && SP_IS_MESHGRADIENT(that)) { + SPMeshGradient *sg=SP_MESHGRADIENT(this); + SPMeshGradient *tg=SP_MESHGRADIENT(that); if( sg->x._set != !tg->x._set) { break; } if( sg->y._set != !tg->y._set) { break; } @@ -514,7 +514,7 @@ void SPGradient::modified(guint flags) #endif if (flags & SP_OBJECT_CHILD_MODIFIED_FLAG) { - if (SP_IS_MESH(this)) { + if (SP_IS_MESHGRADIENT(this)) { this->invalidateArray(); } else { this->invalidateVector(); @@ -522,7 +522,7 @@ void SPGradient::modified(guint flags) } if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) { - if (SP_IS_MESH(this)) { + if (SP_IS_MESHGRADIENT(this)) { this->ensureArray(); } else { this->ensureVector(); @@ -1025,12 +1025,12 @@ void SPGradient::rebuildArray() { // std::cout << "SPGradient::rebuildArray()" << std::endl; - if( !SP_IS_MESH(this) ) { + if( !SP_IS_MESHGRADIENT(this) ) { g_warning( "SPGradient::rebuildArray() called for non-mesh gradient" ); return; } - array.read( SP_MESH( this ) ); + array.read( SP_MESHGRADIENT( this ) ); } Geom::Affine @@ -1121,9 +1121,7 @@ sp_gradient_create_preview_pattern(SPGradient *gr, double width) { cairo_pattern_t *pat = NULL; - // CPPIFY - //if( gr->get_type() != SP_GRADIENT_TYPE_MESH ) { - if (!SP_IS_MESH(gr)) { + if (!SP_IS_MESHGRADIENT(gr)) { gr->ensureVector(); pat = cairo_pattern_create_linear(0, 0, width, 0); -- cgit v1.2.3