diff --git a/src/display/drawing-item.cpp b/src/display/drawing-item.cpp index 04a26836b872c6d90c958d0781db8ec3aac70700..960fee6bf3e19355d265d91d8375fe1774dab626 100644 --- a/src/display/drawing-item.cpp +++ b/src/display/drawing-item.cpp @@ -219,6 +219,7 @@ void DrawingItem::setTransform(Geom::Affine const &new_trans) if (_transform) { current = *_transform; } + _translating = new_trans.isTranslation(EPS); if (!Geom::are_near(current, new_trans, EPS)) { // mark the area where the object was for redraw. @@ -730,6 +731,9 @@ DrawingItem::render(DrawingContext &dc, Geom::IntRect const &area, unsigned flag _cache->paintFromCache(dc, carea, forcecache); if (!carea) { dc.setSource(0, 0, 0, 0); + if (Geom::are_near(_opacity,0.8)) { + std::cout << "CACHED" << std::endl; + } return RENDER_OK; } } else { @@ -745,7 +749,9 @@ DrawingItem::render(DrawingContext &dc, Geom::IntRect const &area, unsigned flag // if our caching was turned off after the last update, it was already // deleted in setCached() } - + if (Geom::are_near(_opacity,0.8)) { + std::cout << "NO CACHED" << std::endl; + } // determine whether this shape needs intermediate rendering. bool needs_intermediate_rendering = false; bool &nir = needs_intermediate_rendering; @@ -1072,8 +1078,8 @@ DrawingItem::_markForRendering() // dirty the caches of all parents DrawingItem *bkg_root = nullptr; - - for (DrawingItem *i = this; i; i = i->_parent) { + DrawingItem *i = _translating ? this->_parent : this; + for (DrawingItem *i = this->_parent; i; i = i->_parent) { if (i != this && i->_filter) { i->_filter->area_enlarge(*dirty, i); } @@ -1096,6 +1102,7 @@ DrawingItem::_markForRendering() // Can happen, e.g. Icon Preview dialog. // std::cerr << "DrawingItem::_markForRendering: Missing CanvasItemDrawing!" << std::endl; } + _translating = false; } diff --git a/src/display/drawing-item.h b/src/display/drawing-item.h index 284875be5c1ecb2d24073ad3cb60c6132c5e2b9c..b7fd159b27b672f0f4e02032b61a1d10db6b3f4c 100644 --- a/src/display/drawing-item.h +++ b/src/display/drawing-item.h @@ -215,7 +215,8 @@ protected: SPItem *_item; ///< Used to associate DrawingItems with SPItems that created them DrawingCache *_cache; bool _prev_nir = false; - + bool _translating = false; + CacheList::iterator _cache_iterator; bool style_vector_effect_size : 1; diff --git a/src/display/drawing-surface.cpp b/src/display/drawing-surface.cpp index ae27a58a2a82e35bdbe7ae59df7e6370b5ca67ed..66f84adb03ecc5512056134020cf3b4984289e84 100644 --- a/src/display/drawing-surface.cpp +++ b/src/display/drawing-surface.cpp @@ -251,24 +251,22 @@ DrawingCache::prepare() { Geom::IntRect old_area = pixelArea(); bool is_identity = _pending_transform.isIdentity(); - if (is_identity && _pending_area == old_area) return; // no change + if (is_identity && _pending_area.dimensions() == old_area.dimensions()) return; // no change bool is_integer_translation = is_identity; if (!is_identity && _pending_transform.isTranslation()) { - Geom::IntPoint t = _pending_transform.translation().round(); - if (Geom::are_near(Geom::Point(t), _pending_transform.translation())) { - is_integer_translation = true; - cairo_region_translate(_clean_region, t[X], t[Y]); - if (old_area + t == _pending_area) { - // if the areas match, the only thing to do - // is to ensure that the clean area is not too large - // we can exit early - cairo_rectangle_int_t limit = _convertRect(_pending_area); - cairo_region_intersect_rectangle(_clean_region, &limit); - _origin += t; - _pending_transform.setIdentity(); - return; - } + Geom::Point t = _pending_transform.translation(); + Geom::IntPoint tint = _pending_area.min() - old_area.min(); + cairo_region_translate(_clean_region, tint[X], tint[Y]); + if (old_area.dimensions() == _pending_area.dimensions()) { + // if the areas match, the only thing to do + // is to ensure that the clean area is not too large + // we can exit early + cairo_rectangle_int_t limit = _convertRect(_pending_area); + cairo_region_intersect_rectangle(_clean_region, &limit); + _origin += t; + _pending_transform.setIdentity(); + return; } } diff --git a/src/object/sp-item.cpp b/src/object/sp-item.cpp index 35f434cd7499cebc1713b9463bfc286a76f216e4..1eb7ff4db9a22ad26a306bd26ce97a3f34710b5f 100644 --- a/src/object/sp-item.cpp +++ b/src/object/sp-item.cpp @@ -1628,6 +1628,9 @@ void SPItem::doWriteTransform(Geom::Affine const &transform, Geom::Affine const // the object does not have a filter, or the transform is translation (which is supposed to not affect filters) ) { + for (auto &v : views) { + v.drawingitem->setCached(false, true); + } transform_attr = this->set_transform(transform); } if (freeze_stroke_width) {