[Libreoffice-commits] core.git: 2 commits - include/svx svx/source vcl/win
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Thu Sep 9 11:01:49 UTC 2021
include/svx/svdpage.hxx | 3 ++
svx/source/svdraw/svdpage.cxx | 56 ++++++++++++++++++++++++++++++++++++++++
svx/source/unodraw/unoshape.cxx | 6 ----
vcl/win/app/salinst.cxx | 5 +++
4 files changed, 65 insertions(+), 5 deletions(-)
New commits:
commit a9cd44f8deeccbb8afc7209fdf86fbc26ea7a464
Author: Noel Grandin <noel at peralex.com>
AuthorDate: Wed Sep 8 11:45:08 2021 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Sep 9 13:01:23 2021 +0200
tdf#144052 speedup inserting large charts
we don't need to immediately re-order objects when setting the
Z-order, just set the dirty flag and we can calculate the proper order
layout.
This takes the time for the chart to appear from multiple minutes
to 20sec for me.
Change-Id: If80569da09469423f19f9fe82b40dfbdac14f161
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121806
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/include/svx/svdpage.hxx b/include/svx/svdpage.hxx
index 40268b3248fb..d16a9dc3887e 100644
--- a/include/svx/svdpage.hxx
+++ b/include/svx/svdpage.hxx
@@ -125,6 +125,9 @@ public:
/// Modify ZOrder of an SdrObject
virtual SdrObject* SetObjectOrdNum(size_t nOldObjNum, size_t nNewObjNum);
+ /// Modify ZOrder of an SdrObject, object must already be in the list
+ virtual void SetExistingObjectOrdNum(SdrObject* pExistingObj, size_t nNewObjNum);
+
void SetSdrObjListRectsDirty();
const tools::Rectangle& GetAllObjSnapRect() const;
diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx
index 40044d78aa4f..0c56086d1097 100644
--- a/svx/source/svdraw/svdpage.cxx
+++ b/svx/source/svdraw/svdpage.cxx
@@ -561,6 +561,62 @@ SdrObject* SdrObjList::SetObjectOrdNum(size_t nOldObjNum, size_t nNewObjNum)
return pObj;
}
+void SdrObjList::SetExistingObjectOrdNum(SdrObject* pObj, size_t nNewObjNum)
+{
+ assert(std::find(maList.begin(), maList.end(), pObj) != maList.end() && "This method requires that the child object already be inserted");
+ assert(pObj->IsInserted() && "SdrObjList::SetObjectOrdNum: the object does not have status Inserted.");
+
+ // I am deliberately bypassing getOrdNum() because I dont want to unnecessarily
+ // trigger RecalcObjOrdNums()
+ const sal_uInt32 nOldOrdNum = pObj->m_nOrdNum;
+ if (!mbObjOrdNumsDirty && nOldOrdNum == nNewObjNum)
+ return;
+
+ // Update the navigation positions.
+ if (HasObjectNavigationOrder())
+ {
+ tools::WeakReference<SdrObject> aReference (pObj);
+ auto iObject = ::std::find(
+ mxNavigationOrder->begin(),
+ mxNavigationOrder->end(),
+ aReference);
+ mxNavigationOrder->erase(iObject);
+ mbIsNavigationOrderDirty = true;
+ // The new object does not have a user defined position so append it
+ // to the list.
+ pObj->SetNavigationPosition(mxNavigationOrder->size());
+ mxNavigationOrder->push_back(pObj);
+ }
+ if (nOldOrdNum < maList.size() && maList[nOldOrdNum] == pObj)
+ maList.erase(maList.begin()+nOldOrdNum);
+ else
+ {
+ auto it = std::find(maList.begin(), maList.end(), pObj);
+ maList.erase(it);
+ }
+ // Insert object into object list. Because the insert() method requires
+ // a valid iterator as insertion position, we have to use push_back() to
+ // insert at the end of the list.
+ if (nNewObjNum >= maList.size())
+ maList.push_back(pObj);
+ else
+ maList.insert(maList.begin()+nNewObjNum, pObj);
+
+ mbObjOrdNumsDirty=true;
+
+ // No need to delete visualisation data since same object
+ // gets inserted again. Also a single ActionChanged is enough
+ pObj->ActionChanged();
+
+ pObj->SetOrdNum(nNewObjNum);
+ mbObjOrdNumsDirty=true;
+
+ // TODO: We need a different broadcast here.
+ if (pObj->getSdrPageFromSdrObject()!=nullptr)
+ pObj->getSdrModelFromSdrObject().Broadcast(SdrHint(SdrHintKind::ObjectChange, *pObj));
+ pObj->getSdrModelFromSdrObject().SetChanged();
+}
+
void SdrObjList::sort( std::vector<sal_Int32>& sortOrder)
{
// no negative indexes and indexes larger than maList size are allowed
diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx
index 6445b81e06db..759f61d107ac 100644
--- a/svx/source/unodraw/unoshape.cxx
+++ b/svx/source/unodraw/unoshape.cxx
@@ -2126,11 +2126,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertyMapEn
{
SdrObjList* pObjList = GetSdrObject()->getParentSdrObjListFromSdrObject();
if( pObjList )
- {
- SdrObject* pCheck =
- pObjList->SetObjectOrdNum( GetSdrObject()->GetOrdNum(), static_cast<size_t>(nNewOrdNum) );
- DBG_ASSERT( pCheck == GetSdrObject(), "GetOrdNum() failed!" );
- }
+ pObjList->SetExistingObjectOrdNum( GetSdrObject(), static_cast<size_t>(nNewOrdNum) );
return true;
}
break;
commit 7b4b032daa2381e5c2f102d4e9619adf38968f94
Author: Noel Grandin <noel at peralex.com>
AuthorDate: Thu Sep 9 09:08:34 2021 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Sep 9 13:01:15 2021 +0200
reduce time in ResetEvent (tdf#144052)
Change-Id: I3e9c906a026e7455fb775d110eca32f8533614e9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121836
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx
index dd35317040d4..a34448884057 100644
--- a/vcl/win/app/salinst.cxx
+++ b/vcl/win/app/salinst.cxx
@@ -130,6 +130,11 @@ void SalYieldMutex::doAcquire( sal_uInt32 nLockCount )
// Window's create/destroy is called via SendMessage() from another thread.
// Have a look at the osl_waitCondition implementation for more info.
do {
+ // Calling Condition::reset frequently turns out to be a little expensive,
+ // and the vast majority of the time there is no contention, so first
+ // try just acquiring the mutex.
+ if (m_aMutex.tryToAcquire())
+ break;
// reset condition *before* acquiring!
m_condition.reset();
if (m_aMutex.tryToAcquire())
More information about the Libreoffice-commits
mailing list