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 From 1b7079f62b7c2bfe454e20bae3776a7e36e7e684 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Sun, 9 Oct 2016 20:37:54 +0200 Subject: Provide simple "preview" for mesh gradients. (bzr r15157) --- src/sp-gradient.cpp | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 2 deletions(-) (limited to 'src/sp-gradient.cpp') diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index d3e38485b..333316697 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -46,6 +46,7 @@ #include "sp-radial-gradient.h" #include "sp-mesh-gradient.h" #include "sp-mesh-row.h" +#include "sp-mesh-patch.h" #include "sp-stop.h" /// Has to be power of 2 Seems to be unused. @@ -229,8 +230,6 @@ SPGradient::SPGradient() : SPPaintServer(), units(), state(2), vector() { - this->has_patches = 0; - this->ref = new SPGradientReference(this); this->ref->changedSignal().connect(sigc::bind(sigc::ptr_fun(SPGradient::gradientRefChanged), this)); @@ -250,6 +249,7 @@ SPGradient::SPGradient() : SPPaintServer(), units(), this->spread_set = FALSE; this->has_stops = FALSE; + this->has_patches = FALSE; this->vector.built = false; this->vector.stops.clear(); @@ -275,6 +275,17 @@ void SPGradient::build(SPDocument *document, Inkscape::XML::Node *repr) this->has_stops = TRUE; break; } + if (SP_IS_MESHROW(&ochild)) { + for (auto& ochild2: ochild.children) { + if (SP_IS_MESHPATCH(&ochild2)) { + this->has_patches = TRUE; + break; + } + } + if (this->has_patches == TRUE) { + break; + } + } } this->readAttr( "gradientUnits" ); @@ -470,6 +481,9 @@ void SPGradient::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *re } } } + if ( ochild && SP_IS_MESHROW(ochild) ) { + this->has_patches = TRUE; + } /// \todo Fixme: should we schedule "modified" here? this->requestModified(SP_OBJECT_MODIFIED_FLAG); @@ -485,11 +499,23 @@ void SPGradient::remove_child(Inkscape::XML::Node *child) SPPaintServer::remove_child(child); this->has_stops = FALSE; + this->has_patches = FALSE; for (auto& ochild: children) { if (SP_IS_STOP(&ochild)) { this->has_stops = TRUE; break; } + if (SP_IS_MESHROW(&ochild)) { + for (auto& ochild2: ochild.children) { + if (SP_IS_MESHPATCH(&ochild2)) { + this->has_patches = TRUE; + break; + } + } + if (this->has_patches == TRUE) { + break; + } + } } if ( this->getStopCount() == 0 ) { @@ -765,6 +791,14 @@ static bool has_stopsFN(SPGradient const *gr) return gr->hasStops(); } +/** + * True if gradient has patches (i.e. a mesh). + */ +static bool has_patchesFN(SPGradient const *gr) +{ + return gr->hasPatches(); +} + /** * True if gradient has spread set. */ @@ -793,6 +827,16 @@ SPGradient *SPGradient::getVector(bool force_vector) return src; } +SPGradient *SPGradient::getArray(bool force_vector) +{ + SPGradient * src = chase_hrefs(this, has_patchesFN); + + // if (force_vector) { + // src = sp_gradient_ensure_vector_normalized(src); + // } + return src; +} + /** * Returns the effective spread of given gradient (climbing up the refs chain if needed). * @@ -1031,6 +1075,7 @@ void SPGradient::rebuildArray() } array.read( SP_MESHGRADIENT( this ) ); + has_patches = array.patch_columns() > 0; } Geom::Affine @@ -1132,6 +1177,20 @@ sp_gradient_create_preview_pattern(SPGradient *gr, double width) cairo_pattern_add_color_stop_rgba(pat, i->offset, i->color.v.c[0], i->color.v.c[1], i->color.v.c[2], i->opacity); } + } else { + + // For the moment, use the top row of nodes for preview. + unsigned columns = gr->array.patch_columns(); + + double offset = 1.0/double(columns); + + pat = cairo_pattern_create_linear(0, 0, width, 0); + + for (unsigned i = 0; i < columns+1; ++i) { + SPMeshNode* node = gr->array.node( 0, i*3 ); + cairo_pattern_add_color_stop_rgba(pat, i*offset, + node->color.v.c[0], node->color.v.c[1], node->color.v.c[2], node->opacity); + } } return pat; -- cgit v1.2.3 From ce1a41cdce443963665ad56e2a73cbe63e5cdf5f Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Wed, 12 Oct 2016 13:10:37 +0200 Subject: Render mesh gradients that reference other mesh gradients. (bzr r15163) --- src/sp-gradient.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/sp-gradient.cpp') diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index 333316697..49f117a51 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -1144,15 +1144,17 @@ sp_gradient_pattern_common_setup(cairo_pattern_t *cp, } // add stops - for (std::vector::iterator i = gr->vector.stops.begin(); - i != gr->vector.stops.end(); ++i) - { - // multiply stop opacity by paint opacity - cairo_pattern_add_color_stop_rgba(cp, i->offset, - i->color.v.c[0], i->color.v.c[1], i->color.v.c[2], i->opacity * opacity); + if (!SP_IS_MESHGRADIENT(gr)) { + for (std::vector::iterator i = gr->vector.stops.begin(); + i != gr->vector.stops.end(); ++i) + { + // multiply stop opacity by paint opacity + cairo_pattern_add_color_stop_rgba(cp, i->offset, + i->color.v.c[0], i->color.v.c[1], i->color.v.c[2], i->opacity * opacity); + } } - // set pattern matrix + // set pattern transform matrix Geom::Affine gs2user = gr->gradientTransform; if (gr->getUnits() == SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX && bbox) { Geom::Affine bbox2user(bbox->width(), 0, 0, bbox->height(), bbox->left(), bbox->top()); -- cgit v1.2.3 From 42d434bcfcddb8519272144ec8b3b579bb470238 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Thu, 20 Oct 2016 23:56:38 +0200 Subject: Fix gradient comparison. (bzr r15183) --- src/sp-gradient.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/sp-gradient.cpp') diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index 49f117a51..746c7fa41 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -127,7 +127,7 @@ bool SPGradient::isEquivalent(SPGradient *that) bool effective = true; while (effective && (as && bs)) { if (!as->getEffectiveColor().isClose(bs->getEffectiveColor(), 0.001) || - as->offset != bs->offset) { + as->offset != bs->offset || as->opacity != bs->opacity ) { effective = false; break; } -- cgit v1.2.3 From 3db7f06b5bf3f74bbe0256b680931c06996a44be Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Thu, 17 Nov 2016 11:18:14 +0100 Subject: Ensure getVector() and getArray() return a valid gradient pointer. (bzr r15253) --- src/sp-gradient.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/sp-gradient.cpp') diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index 746c7fa41..f02149cbb 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -820,6 +820,9 @@ has_units_set(SPGradient const *gr) SPGradient *SPGradient::getVector(bool force_vector) { SPGradient * src = chase_hrefs(this, has_stopsFN); + if (src == NULL) { + src = this; + } if (force_vector) { src = sp_gradient_ensure_vector_normalized(src); @@ -830,10 +833,9 @@ SPGradient *SPGradient::getVector(bool force_vector) SPGradient *SPGradient::getArray(bool force_vector) { SPGradient * src = chase_hrefs(this, has_patchesFN); - - // if (force_vector) { - // src = sp_gradient_ensure_vector_normalized(src); - // } + if (src == NULL) { + src = this; + } return src; } -- 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-gradient.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/sp-gradient.cpp') diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index f02149cbb..c1934dd92 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -24,6 +24,8 @@ #define noSP_GRADIENT_VERBOSE //#define OBJECT_TRACE +#include "sp-gradient.h" + #include #include @@ -34,12 +36,12 @@ #include #include +#include "bad-uri-exception.h" #include "display/cairo-utils.h" #include "svg/svg.h" #include "svg/css-ostringstream.h" #include "attributes.h" #include "document-private.h" -#include "sp-gradient.h" #include "gradient-chemistry.h" #include "sp-gradient-reference.h" #include "sp-linear-gradient.h" -- cgit v1.2.3