diff --git a/src/object/sp-ellipse.cpp b/src/object/sp-ellipse.cpp index 1db7c0ecd486fb68292d42e588a82c975c57bc3a..6293bc766c8f7b78622bbabdd2ae8be2d2b45004 100644 --- a/src/object/sp-ellipse.cpp +++ b/src/object/sp-ellipse.cpp @@ -212,7 +212,8 @@ void SPGenericEllipse::set(SPAttr key, gchar const *value) void SPGenericEllipse::update(SPCtx *ctx, guint flags) { // std::cout << "\nSPGenericEllipse::update: Entrance" << std::endl; - if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { + + if (validate_update(flags) && flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { Geom::Rect const &viewbox = ((SPItemCtx const *) ctx)->viewport; double const dx = viewbox.width(); @@ -228,7 +229,6 @@ void SPGenericEllipse::update(SPCtx *ctx, guint flags) this->set_shape(); } - SPShape::update(ctx, flags); // std::cout << "SPGenericEllipse::update: Exit\n" << std::endl; } diff --git a/src/object/sp-item.cpp b/src/object/sp-item.cpp index ce237b38cd29338bae6412a057db9848c8721ebc..9ec27e028b22a5490c64ca7eaf7f17e34513a350 100644 --- a/src/object/sp-item.cpp +++ b/src/object/sp-item.cpp @@ -1695,6 +1695,12 @@ void SPItem::doWriteTransform(Geom::Affine const &transform, Geom::Affine const void SPItem::set_item_transform(Geom::Affine const &transform_matrix) { if (!Geom::are_near(transform_matrix, transform, 1e-18)) { + if (Geom::are_near(transform_matrix, Geom::Affine())) { + if (auto shape = cast(this)) { + shape->bbox_geom_cache = Geom::OptRect(); + shape->bbox_vis_cache = Geom::OptRect(); + } + } transform = transform_matrix; /* The SP_OBJECT_USER_MODIFIED_FLAG_B is used to mark the fact that it's only a transformation. It's apparently not used anywhere else. */ diff --git a/src/object/sp-line.cpp b/src/object/sp-line.cpp index 1c89462b3954b02c393d600af500a59cea49f64f..c3efacd05ca7fb30a8c847dc714368753ed8c124 100644 --- a/src/object/sp-line.cpp +++ b/src/object/sp-line.cpp @@ -70,7 +70,7 @@ void SPLine::set(SPAttr key, const gchar* value) { } void SPLine::update(SPCtx *ctx, guint flags) { - if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { + if (validate_update(flags) && flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { SPStyle const *style = this->style; SPItemCtx const *ictx = (SPItemCtx const *) ctx; double const w = ictx->viewport.width(); @@ -85,7 +85,6 @@ void SPLine::update(SPCtx *ctx, guint flags) { this->set_shape(); } - SPShape::update(ctx, flags); } diff --git a/src/object/sp-offset.cpp b/src/object/sp-offset.cpp index 9021332ff3f195c25461a748d6b783821b6c835b..4b237a130260b98f6ece44bf8ac814b2050adfa4 100644 --- a/src/object/sp-offset.cpp +++ b/src/object/sp-offset.cpp @@ -298,21 +298,22 @@ void SPOffset::set(SPAttr key, const gchar* value) { } void SPOffset::update(SPCtx *ctx, guint flags) { - this->isUpdating=true; // prevent sp_offset_set from requesting updates - - if ( this->sourceDirty ) { - refresh_offset_source(this); - } - - if (flags & - (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | - SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { - - this->set_shape(); + if (validate_update(flags)) { + this->isUpdating=true; // prevent sp_offset_set from requesting updates + + if ( this->sourceDirty ) { + refresh_offset_source(this); + } + + if (flags & + (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | + SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { + + this->set_shape(); + } + + this->isUpdating=false; } - - this->isUpdating=false; - SPShape::update(ctx, flags); } diff --git a/src/object/sp-path.cpp b/src/object/sp-path.cpp index 1fe8d241ece5dfc9c1d4d3bec91579772018f2d5..c9604d6b5e566173c17cacc3ce120c0029001fc3 100644 --- a/src/object/sp-path.cpp +++ b/src/object/sp-path.cpp @@ -273,7 +273,7 @@ void SPPath::update_patheffect(bool write) { } void SPPath::update(SPCtx *ctx, guint flags) { - if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { + if (validate_update(flags) && flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { flags &= ~SP_OBJECT_USER_MODIFIED_FLAG_B; // since we change the description, it's not a "just translation" anymore } diff --git a/src/object/sp-rect.cpp b/src/object/sp-rect.cpp index def363af991feaf73f1f7495b848126e657be7b1..011755272b516dc865ef6e5a0773cdafd7cf71cd 100644 --- a/src/object/sp-rect.cpp +++ b/src/object/sp-rect.cpp @@ -147,8 +147,7 @@ void SPRect::update(SPCtx* ctx, unsigned int flags) { #ifdef OBJECT_TRACE objectTrace( "SPRect::update", true, flags ); #endif - - if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { + if (validate_update(flags) && flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { SPItemCtx const *ictx = reinterpret_cast(ctx); double const w = ictx->viewport.width(); diff --git a/src/object/sp-shape.cpp b/src/object/sp-shape.cpp index 0aa746f28d03794eddfdb3681153ceb62b794506..e56176d6a43e218318a024bdd201283a7c9d80ca 100644 --- a/src/object/sp-shape.cpp +++ b/src/object/sp-shape.cpp @@ -122,13 +122,19 @@ Inkscape::XML::Node* SPShape::write(Inkscape::XML::Document *xml_doc, Inkscape:: return repr; } +bool SPShape::validate_update(unsigned int flags) { + if (!bbox_geom_cache || !bbox_vis_cache || !(flags & SP_OBJECT_USER_MODIFIED_FLAG_B)) { + bbox_vis_cache_is_valid = false; + bbox_geom_cache_is_valid = false; + return true; + } + return !(flags & SP_OBJECT_USER_MODIFIED_FLAG_B); +} + void SPShape::update(SPCtx* ctx, guint flags) { // Any update can change the bounding box, // so the cached version can no longer be used. // But the idle checker usually is just moving the objects around. - bbox_vis_cache_is_valid = false; - bbox_geom_cache_is_valid = false; - // std::cout << "SPShape::update(): " << (getId()?getId():"null") << std::endl; SPLPEItem::update(ctx, flags); @@ -541,7 +547,8 @@ Geom::OptRect SPShape::either_bbox(Geom::Affine const &transform, SPItem::BBoxTy // Return the cache if possible. auto delta = transform_cache.inverse() * transform; if (cache_is_valid && bbox_cache && delta.isTranslation()) { - + // uncomenting cout fail some output based tests + // std::cout << "using cache bbox" << std::endl; // Don't re-adjust the cache if we haven't moved if (!delta.isNonzeroTranslation()) { return bbox_cache; @@ -549,7 +556,7 @@ Geom::OptRect SPShape::either_bbox(Geom::Affine const &transform, SPItem::BBoxTy // delta is pure translation so it's safe to use it as is return *bbox_cache * delta; } - + // std::cout << "not using cache bbox" << std::endl; if (!this->_curve || this->_curve->get_pathvector().empty()) { return bbox; } diff --git a/src/object/sp-shape.h b/src/object/sp-shape.h index 9d257290a1499ec6af39232218ab5181440c6e75..657e8608cb5a2d9314d54612bfed17c00f93dd74 100644 --- a/src/object/sp-shape.h +++ b/src/object/sp-shape.h @@ -78,7 +78,7 @@ public: void release() override; void update(SPCtx* ctx, unsigned int flags) override; void modified(unsigned int flags) override; - + bool validate_update(unsigned int flags); void set(SPAttr key, char const* value) override; Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags) override; diff --git a/src/object/sp-spiral.cpp b/src/object/sp-spiral.cpp index f471873bbcc562fef1450027bf7d1718cf17b945..971b7c371bf27bea04af9a08cd8bf7c38185eada 100644 --- a/src/object/sp-spiral.cpp +++ b/src/object/sp-spiral.cpp @@ -193,7 +193,7 @@ void SPSpiral::set(SPAttr key, gchar const* value) { } void SPSpiral::update(SPCtx *ctx, guint flags) { - if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { + if (validate_update(flags) && flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { this->set_shape(); } diff --git a/src/object/sp-star.cpp b/src/object/sp-star.cpp index de4e195d97824ff50916b8f20405569757841577..4faf20f9d6bdb7be7bce01315d3f7abf6e1779ec 100644 --- a/src/object/sp-star.cpp +++ b/src/object/sp-star.cpp @@ -214,7 +214,7 @@ void SPStar::set(SPAttr key, const gchar* value) { } void SPStar::update(SPCtx *ctx, guint flags) { - if (flags & (SP_OBJECT_MODIFIED_FLAG | + if (validate_update(flags) && flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {