include/svx/sdr/contact/viewcontact.hxx | 3 ++- svx/source/sdr/contact/viewcontact.cxx | 30 +++++++++++++++++------------- 2 files changed, 19 insertions(+), 14 deletions(-)
New commits: commit 44711d9eb53eb6247ebdb9293a3eb5e643f78059 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Fri Apr 9 19:40:24 2021 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Sat Apr 10 16:53:59 2021 +0200 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.gran...@collabora.co.uk> diff --git a/include/svx/sdr/contact/viewcontact.hxx b/include/svx/sdr/contact/viewcontact.hxx index c5cc61883a49..d5603790ffd0 100644 --- a/include/svx/sdr/contact/viewcontact.hxx +++ b/include/svx/sdr/contact/viewcontact.hxx @@ -49,7 +49,8 @@ private: // Primitive2DContainer of the ViewContact. This contains all necessary information // for the graphical visualisation and needs to be supported by all VCs which // can be visualized. - drawinglayer::primitive2d::Primitive2DContainer mxViewIndependentPrimitive2DSequence; + mutable drawinglayer::primitive2d::Primitive2DContainer mxViewIndependentPrimitive2DSequence; + mutable bool mbNeedToCreatePrimitives; // A new ViewObjectContact was created and shall be remembered. void AddViewObjectContact(ViewObjectContact& rVOContact); 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; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits