[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - sc/source

Dennis Francis (via logerrit) logerrit at kemper.freedesktop.org
Mon Jul 6 16:08:47 UTC 2020


 sc/source/ui/unoobj/docuno.cxx |   38 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 37 insertions(+), 1 deletion(-)

New commits:
commit f54d3aa9bee7bc794b18b968835c6d6393f350ea
Author:     Dennis Francis <dennis.francis at collabora.com>
AuthorDate: Tue Jun 23 21:15:40 2020 +0530
Commit:     Dennis Francis <dennis.francis at collabora.com>
CommitDate: Mon Jul 6 18:08:12 2020 +0200

    paintTile: Try to find a view that matches the tile-zoom requested...
    
    by iterating over first few shells to avoid switching of zooms in
    ScGridWindow::PaintTile and hence avoid grid-offset recomputation on all
    shapes which is not cheap.
    
    Change-Id: Ib086112ebd504087d80c6d6f2879a69dca8ce44f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98168
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Dennis Francis <dennis.francis at collabora.com>

diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 20730f1912ea..b51e63419f57 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -494,6 +494,32 @@ void ScModelObj::RepaintRange( const ScRangeList& rRange )
         pDocShell->PostPaint( rRange, PaintPartFlags::Grid );
 }
 
+static ScViewData* lcl_getViewMatchingDocZoomTab(const Fraction& rZoomX,
+                                              const Fraction& rZoomY,
+                                              const SCTAB nTab,
+                                              const ViewShellDocId& rDocId,
+                                              const size_t nMaxIter = 5)
+{
+    size_t nIter = 0;
+    for (SfxViewShell* pViewShell = SfxViewShell::GetFirst();
+            pViewShell && nIter < nMaxIter;
+            (pViewShell = SfxViewShell::GetNext(*pViewShell)), ++nIter)
+    {
+        if (pViewShell->GetDocId() != rDocId)
+            continue;
+
+        ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(pViewShell);
+        if (!pTabViewShell)
+            continue;
+
+        ScViewData& rData = pTabViewShell->GetViewData();
+        if (rData.GetTabNo() == nTab && rData.GetZoomX() == rZoomX && rData.GetZoomY() == rZoomY)
+            return &rData;
+    }
+
+    return nullptr;
+}
+
 void ScModelObj::paintTile( VirtualDevice& rDevice,
                             int nOutputWidth, int nOutputHeight,
                             int nTilePosX, int nTilePosY,
@@ -505,7 +531,17 @@ void ScModelObj::paintTile( VirtualDevice& rDevice,
     if (!pViewShell)
         return;
 
-    ScViewData* pViewData = &pViewShell->GetViewData();
+    ScViewData* pActiveViewData = &pViewShell->GetViewData();
+    Fraction aFracX(long(nOutputWidth * TWIPS_PER_PIXEL), nTileWidth);
+    Fraction aFracY(long(nOutputHeight * TWIPS_PER_PIXEL), nTileHeight);
+
+    // Try to find a view that matches the tile-zoom requested by iterating over
+    // first few shells. This is to avoid switching of zooms in ScGridWindow::PaintTile
+    // and hence avoid grid-offset recomputation on all shapes which is not cheap.
+    ScViewData* pViewData = lcl_getViewMatchingDocZoomTab(aFracX, aFracY,
+            pActiveViewData->GetTabNo(), pViewShell->GetDocId());
+    if (!pViewData)
+        pViewData = pActiveViewData;
 
     ScGridWindow* pGridWindow = pViewData->GetActiveWin();
 


More information about the Libreoffice-commits mailing list