include/svx/sdr/contact/viewobjectcontact.hxx |    1 
 svx/source/sdr/contact/viewobjectcontact.cxx  |    4 ---
 svx/source/svdraw/sdrhittesthelper.cxx        |   27 +++++++++++++++-----------
 3 files changed, 18 insertions(+), 14 deletions(-)

New commits:
commit e6a8c40e5051363d5825bd09131b86cf8a2b659b
Author:     Noel Grandin <[email protected]>
AuthorDate: Tue Sep 30 14:54:37 2025 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Tue Sep 30 18:22:59 2025 +0200

    tdf#116975 Laggy behavior when clicking between table cells in impress
    
    Only compute the object range when we actually need it.
    Takes the hit test processing completely off the performance profile,
    reducing CPU usage by 50%
    
    Change-Id: I3bc7efa187897274d6ef86e7b259b0dba40dc398
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191667
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/include/svx/sdr/contact/viewobjectcontact.hxx 
b/include/svx/sdr/contact/viewobjectcontact.hxx
index fa54bd470580..eab0aed2c093 100644
--- a/include/svx/sdr/contact/viewobjectcontact.hxx
+++ b/include/svx/sdr/contact/viewobjectcontact.hxx
@@ -97,6 +97,7 @@ public:
 
     // get the object size range
     const basegfx::B2DRange& getObjectRange() const;
+    bool hasCachedObjectRange() const { return !maObjectRange.isEmpty(); }
 
     // React on changes of the object of this ViewContact
     virtual void ActionChanged();
diff --git a/svx/source/sdr/contact/viewobjectcontact.cxx 
b/svx/source/sdr/contact/viewobjectcontact.cxx
index aecbd0f9f016..d5cf6e6ae7f7 100644
--- a/svx/source/sdr/contact/viewobjectcontact.cxx
+++ b/svx/source/sdr/contact/viewobjectcontact.cxx
@@ -517,9 +517,7 @@ drawinglayer::primitive2d::Primitive2DContainer const & 
ViewObjectContact::getPr
         // check for animated stuff
         const_cast< ViewObjectContact* 
>(this)->checkForPrimitive2DAnimations();
 
-        // always update object range when PrimitiveSequence changes
-        const drawinglayer::geometry::ViewInformation2D& 
rViewInformation2D(GetObjectContact().getViewInformation2D());
-        const_cast< ViewObjectContact* >(this)->maObjectRange = 
mxPrimitive2DSequence.getB2DRange(rViewInformation2D);
+        const_cast< ViewObjectContact* >(this)->maObjectRange.reset();
     }
 
     // return current Primitive2DContainer
diff --git a/svx/source/svdraw/sdrhittesthelper.cxx 
b/svx/source/svdraw/sdrhittesthelper.cxx
index 72e41dbc2dc8..2262172465d0 100644
--- a/svx/source/svdraw/sdrhittesthelper.cxx
+++ b/svx/source/svdraw/sdrhittesthelper.cxx
@@ -120,20 +120,25 @@ bool ViewObjectContactPrimitiveHit(
     bool bTextOnly,
     drawinglayer::primitive2d::Primitive2DContainer* pHitContainer)
 {
-    basegfx::B2DRange aObjectRange(rVOC.getObjectRange());
+    // Only use the range if we already have it, computing the range can be 
more expensive
+    // than running the HitTestProcessor.
+    if (rVOC.hasCachedObjectRange())
+    {
+        basegfx::B2DRange aObjectRange(rVOC.getObjectRange());
 
-    if(aObjectRange.isEmpty())
-        return false;
+        if(aObjectRange.isEmpty())
+            return false;
 
-    // first do a rough B2DRange based HitTest; do not forget to
-    // include the HitTolerance if given
-    if(rLogicHitTolerance.getX() > 0 || rLogicHitTolerance.getY() > 0)
-    {
-        aObjectRange.grow(rLogicHitTolerance);
-    }
+        // first do a rough B2DRange based HitTest; do not forget to
+        // include the HitTolerance if given
+        if(rLogicHitTolerance.getX() > 0 || rLogicHitTolerance.getY() > 0)
+        {
+            aObjectRange.grow(rLogicHitTolerance);
+        }
 
-    if(!aObjectRange.isInside(rHitPosition))
-        return false;
+        if(!aObjectRange.isInside(rHitPosition))
+            return false;
+    }
 
     // get primitive sequence
     sdr::contact::DisplayInfo aDisplayInfo;

Reply via email to