diff options
Diffstat (limited to 'src/sp-gradient.cpp')
| -rw-r--r-- | src/sp-gradient.cpp | 106 |
1 files changed, 47 insertions, 59 deletions
diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index f24e25ab1..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: @@ -22,6 +22,7 @@ */ #define noSP_GRADIENT_VERBOSE +//#define OBJECT_TRACE #include <cstring> #include <string> @@ -43,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" @@ -114,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 @@ -199,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; } @@ -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_MESHGRADIENT(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_MESHGRADIENT(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; } @@ -1008,39 +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 ) ); - - 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; - // } - } + array.read( SP_MESHGRADIENT( this ) ); } Geom::Affine @@ -1131,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); |
