diff options
| author | Nathan Lee <2431820-nathanal@users.noreply.gitlab.com> | 2019-09-28 22:52:26 +0000 |
|---|---|---|
| committer | Nathan Lee <2431820-nathanal@users.noreply.gitlab.com> | 2019-10-01 00:07:58 +0000 |
| commit | 6309cb45261959aa56bd516c34af26711991bd08 (patch) | |
| tree | c84df9bd2bcb05d38fd70d48fab12c7d135eaebe /src/object/sp-shape.cpp | |
| parent | Allow duplication of objects with empty ids (diff) | |
| download | inkscape-6309cb45261959aa56bd516c34af26711991bd08.tar.gz inkscape-6309cb45261959aa56bd516c34af26711991bd08.zip | |
Use two bounding box caches instead of one
gitlab.com/inkscape/inbox/issues/943
gitlab.com/inkscape/inkscape/issues/339
Diffstat (limited to 'src/object/sp-shape.cpp')
| -rw-r--r-- | src/object/sp-shape.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/object/sp-shape.cpp b/src/object/sp-shape.cpp index 2070bf4a1..30e841dc0 100644 --- a/src/object/sp-shape.cpp +++ b/src/object/sp-shape.cpp @@ -120,7 +120,8 @@ Inkscape::XML::Node* SPShape::write(Inkscape::XML::Document *xml_doc, Inkscape:: void SPShape::update(SPCtx* ctx, guint flags) { // Any update can change the bounding box, // so the cached version can no longer be used. - bbox_cache_is_valid = false; + 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); @@ -464,8 +465,9 @@ Geom::OptRect SPShape::bbox(Geom::Affine const &transform, SPItem::BBoxType bbox // If the object is clipped, the update funcation that invalidates // the cache doesn't get called if the object is moved, so we need // to compare the transformations as well. - if (bbox_cache_is_valid && transform == bbox_transform_cache) { - return bbox_cache; + bool cached = (bboxtype == SPItem::VISUAL_BBOX) ? bbox_vis_cache_is_valid : bbox_geom_cache_is_valid; + if (cached && transform == bbox_transform_cache) { + return (bboxtype == SPItem::VISUAL_BBOX) ? bbox_vis_cache : bbox_geom_cache; } Geom::OptRect bbox; @@ -654,8 +656,13 @@ Geom::OptRect SPShape::bbox(Geom::Affine const &transform, SPItem::BBoxType bbox } bbox_transform_cache = transform; - bbox_cache = bbox; - bbox_cache_is_valid = true; + if (bboxtype == SPItem::VISUAL_BBOX) { + bbox_vis_cache = bbox; + bbox_vis_cache_is_valid = true; + } else { + bbox_geom_cache = bbox; + bbox_geom_cache_is_valid = true; + } return bbox; } |
