summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2021-04-09 19:40:24 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-04-23 11:04:46 +0200
commit91385bbc7cccfdf59f60a24eaf81894772134af0 (patch)
treedc76dfb8bf82ed4f9ff37d8f15fc40b0fd36b3b0
parent6c9f5ddf3f905c854121b783a47959dc7618559c (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> (cherry picked from commit 44711d9eb53eb6247ebdb9293a3eb5e643f78059) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114505
-rw-r--r--include/svx/sdr/contact/viewcontact.hxx3
-rw-r--r--svx/source/sdr/contact/viewcontact.cxx30
2 files changed, 19 insertions, 14 deletions
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;
}