diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2021-04-09 19:40:24 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-04-10 16:53:59 +0200 |
commit | 44711d9eb53eb6247ebdb9293a3eb5e643f78059 (patch) | |
tree | cdb23eee87489751e381ea8e5126ff9a3b4a5d64 /svx | |
parent | 566e43d2129dd6c70bb718296ce66353e7ff824b (diff) |
tdf#130326 related, speed up drawing
if we create the list every time we call
ViewContact::getViewIndependentPrimitive2DContainer
then caching the result is rather worthless.
So make the caching worthwhile, which means invalidating
it when something changes.
Change-Id: I081e9501255ec1c87454bfcc1e0a741109afa99f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113891
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/sdr/contact/viewcontact.cxx | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/svx/source/sdr/contact/viewcontact.cxx b/svx/source/sdr/contact/viewcontact.cxx index 8e8d35db4406..75c40cfb2cc4 100644 --- a/svx/source/sdr/contact/viewcontact.cxx +++ b/svx/source/sdr/contact/viewcontact.cxx @@ -39,6 +39,7 @@ ViewObjectContact& ViewContact::CreateObjectSpecificViewObjectContact(ObjectCont ViewContact::ViewContact() : maViewObjectContactVector() , mxViewIndependentPrimitive2DSequence() + , mbNeedToCreatePrimitives(true) { } @@ -61,6 +62,7 @@ void ViewContact::deleteAllVOCs() // assert when there were new entries added during deletion DBG_ASSERT(maViewObjectContactVector.empty(), "Corrupted ViewObjectContactList in VC (!)"); + mbNeedToCreatePrimitives = true; } // get an Object-specific ViewObjectContact for a specific @@ -96,6 +98,7 @@ ViewObjectContact& ViewContact::GetViewObjectContact(ObjectContact& rObjectConta void ViewContact::AddViewObjectContact(ViewObjectContact& rVOContact) { maViewObjectContactVector.push_back(&rVOContact); + mbNeedToCreatePrimitives = true; } // A ViewObjectContact was deleted and shall be forgotten. @@ -107,6 +110,7 @@ void ViewContact::RemoveViewObjectContact(ViewObjectContact& rVOContact) if (aFindResult != maViewObjectContactVector.end()) { maViewObjectContactVector.erase(aFindResult); + mbNeedToCreatePrimitives = true; } } @@ -182,6 +186,7 @@ void ViewContact::ActionChildInserted(ViewContact& rChild) // rectangle will be invalidated at the associated OutputDevice. pCandidate->ActionChildInserted(rChild); } + mbNeedToCreatePrimitives = true; } // React on changes of the object of this ViewContact @@ -199,6 +204,7 @@ void ViewContact::ActionChanged() pCandidate->ActionChanged(); } + mbNeedToCreatePrimitives = true; } // access to SdrObject and/or SdrPage. May return 0L like the default @@ -229,22 +235,20 @@ ViewContact::createViewIndependentPrimitive2DSequence() const drawinglayer::primitive2d::Primitive2DContainer const& ViewContact::getViewIndependentPrimitive2DContainer() const { - // local up-to-date checks. Create new list and compare. - drawinglayer::primitive2d::Primitive2DContainer xNew( - createViewIndependentPrimitive2DSequence()); - - if (!xNew.empty()) + if (mbNeedToCreatePrimitives) { - // allow evtl. embedding in object-specific infos, e.g. Name, Title, Description - xNew = embedToObjectSpecificInformation(std::move(xNew)); - } + drawinglayer::primitive2d::Primitive2DContainer xNew( + createViewIndependentPrimitive2DSequence()); - if (mxViewIndependentPrimitive2DSequence != xNew) - { - // has changed, copy content - const_cast<ViewContact*>(this)->mxViewIndependentPrimitive2DSequence = std::move(xNew); - } + if (!xNew.empty()) + { + // allow evtl. embedding in object-specific infos, e.g. Name, Title, Description + xNew = embedToObjectSpecificInformation(std::move(xNew)); + } + mxViewIndependentPrimitive2DSequence = std::move(xNew); + mbNeedToCreatePrimitives = false; + } // return current Primitive2DContainer return mxViewIndependentPrimitive2DSequence; } |