[Libreoffice-commits] core.git: include/svx svx/source sw/source

Armin Le Grand (via logerrit) logerrit at kemper.freedesktop.org
Thu Feb 27 17:13:05 UTC 2020


 include/svx/sdrpaintwindow.hxx       |    7 +++++
 svx/source/svdraw/sdrpagewindow.cxx  |    2 +
 svx/source/svdraw/sdrpaintwindow.cxx |    3 +-
 svx/source/svdraw/svdpntv.cxx        |   18 ++++++++++---
 sw/source/core/view/viewsh.cxx       |   46 ++++++++++++++++++++++-------------
 5 files changed, 55 insertions(+), 21 deletions(-)

New commits:
commit 424312aa99307da9f0ee60ea6e3213b2b3dc26b4
Author:     Armin Le Grand <armin.le.grand at me.com>
AuthorDate: Thu Feb 27 16:43:44 2020 +0100
Commit:     Armin Le Grand <Armin.Le.Grand at me.com>
CommitDate: Thu Feb 27 18:12:30 2020 +0100

    tdf#130768 Make tiled writer paint reuse decomposes
    
    See more info in comment 23 of task. Roughly it's
    about correcting a helper that led to destroying the
    View and thus the OC and thus the whole primitive
    buffering - what was expensive, for the case where
    decompositions were expensive
    
    Change-Id: Ic661ae810083a35812eaa923b439b3856b34b9ba
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89640
    Tested-by: Jenkins
    Reviewed-by: Armin Le Grand <Armin.Le.Grand at me.com>

diff --git a/include/svx/sdrpaintwindow.hxx b/include/svx/sdrpaintwindow.hxx
index 55ecb22fd159..91183258a382 100644
--- a/include/svx/sdrpaintwindow.hxx
+++ b/include/svx/sdrpaintwindow.hxx
@@ -89,6 +89,9 @@ private:
 
     bool                                                mbOutputToWindow : 1;
 
+    // ref to patched
+    SdrPaintWindow*                                     mpPatched;
+
     // helpers
     void impCreateOverlayManager();
 
@@ -96,6 +99,10 @@ public:
     SdrPaintWindow(SdrPaintView& rNewPaintView, OutputDevice& rOut, vcl::Window* pWindow = nullptr);
     ~SdrPaintWindow();
 
+    // allow reference to patched, see patchPaintWindow/unpatchPaintWindow
+    void setPatched(SdrPaintWindow* pPaintWindow) { mpPatched = pPaintWindow; }
+    SdrPaintWindow* getPatched() const { return mpPatched; }
+
     // data read accesses
     OutputDevice& GetOutputDevice() const { return *mpOutputDevice; }
     vcl::Window* GetWindow() const { return mpWindow; }
diff --git a/svx/source/svdraw/sdrpagewindow.cxx b/svx/source/svdraw/sdrpagewindow.cxx
index b85ab66a9e12..31a28277cb71 100644
--- a/svx/source/svdraw/sdrpagewindow.cxx
+++ b/svx/source/svdraw/sdrpagewindow.cxx
@@ -173,6 +173,7 @@ void SdrPageWindow::patchPaintWindow(SdrPaintWindow& rPaintWindow)
 {
     mpImpl->mpOriginalPaintWindow = mpImpl->mpPaintWindow;
     mpImpl->mpPaintWindow = &rPaintWindow;
+    mpImpl->mpOriginalPaintWindow->setPatched(&rPaintWindow);
 }
 
 void SdrPageWindow::unpatchPaintWindow()
@@ -181,6 +182,7 @@ void SdrPageWindow::unpatchPaintWindow()
     if (mpImpl->mpOriginalPaintWindow)
     {
         mpImpl->mpPaintWindow = mpImpl->mpOriginalPaintWindow;
+        mpImpl->mpOriginalPaintWindow->setPatched(nullptr);
         mpImpl->mpOriginalPaintWindow = nullptr;
     }
 }
diff --git a/svx/source/svdraw/sdrpaintwindow.cxx b/svx/source/svdraw/sdrpaintwindow.cxx
index 6f396c7540ed..29bbec832122 100644
--- a/svx/source/svdraw/sdrpaintwindow.cxx
+++ b/svx/source/svdraw/sdrpaintwindow.cxx
@@ -241,7 +241,8 @@ SdrPaintWindow::SdrPaintWindow(SdrPaintView& rNewPaintView, OutputDevice& rOut,
     mpWindow(pWindow),
     mrPaintView(rNewPaintView),
     mbTemporaryTarget(false), // #i72889#
-    mbOutputToWindow(OUTDEV_WINDOW == mpOutputDevice->GetOutDevType())
+    mbOutputToWindow(OUTDEV_WINDOW == mpOutputDevice->GetOutDevType()),
+    mpPatched(nullptr)
 {
 }
 
diff --git a/svx/source/svdraw/svdpntv.cxx b/svx/source/svdraw/svdpntv.cxx
index 16123f23c22b..32feb27b3f4f 100644
--- a/svx/source/svdraw/svdpntv.cxx
+++ b/svx/source/svdraw/svdpntv.cxx
@@ -66,10 +66,20 @@ using namespace ::com::sun::star;
 
 SdrPaintWindow* SdrPaintView::FindPaintWindow(const OutputDevice& rOut) const
 {
-    auto a = std::find_if(maPaintWindows.begin(), maPaintWindows.end(),
-        [&rOut](const std::unique_ptr<SdrPaintWindow>& pWindow) { return &(pWindow->GetOutputDevice()) == &rOut; });
-    if (a != maPaintWindows.end())
-        return a->get();
+    // back to loop - there is more to test than a std::find_if and a lamba can do
+    for(auto& candidate : maPaintWindows)
+    {
+        if(&(candidate->GetOutputDevice()) == &rOut)
+        {
+            return candidate.get();
+        }
+
+        // check for patched to allow finding in that state, too
+        if(nullptr != candidate->getPatched() && &(candidate->getPatched()->GetOutputDevice()) == &rOut)
+        {
+            return candidate->getPatched();
+        }
+    }
 
     return nullptr;
 }
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index d2ae3da70e6b..555f17436b03 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -72,6 +72,8 @@
 #include <vcl/svapp.hxx>
 #include <svx/sdrpaintwindow.hxx>
 #include <svx/sdr/overlay/overlaymanager.hxx>
+#include <svx/sdrpagewindow.hxx>
+#include <svx/svdpagv.hxx>
 #include <comphelper/lok.hxx>
 #include <sfx2/lokhelper.hxx>
 
@@ -1715,35 +1717,47 @@ class RenderContextGuard
     VclPtr<vcl::RenderContext>& m_pRef;
     VclPtr<vcl::RenderContext> m_pOriginalValue;
     SwViewShell* m_pShell;
+    std::unique_ptr<SdrPaintWindow> m_TemporaryPaintWindow;
+    SdrPageWindow* m_pPatchedPageWindow;
 
 public:
     RenderContextGuard(VclPtr<vcl::RenderContext>& pRef, vcl::RenderContext* pValue, SwViewShell* pShell)
         : m_pRef(pRef),
         m_pOriginalValue(m_pRef),
-        m_pShell(pShell)
+        m_pShell(pShell),
+        m_TemporaryPaintWindow(),
+        m_pPatchedPageWindow(nullptr)
     {
         m_pRef = pValue;
-        if (pValue != m_pShell->GetWin() && m_pShell->Imp()->GetDrawView())
-            m_pShell->Imp()->GetDrawView()->AddWindowToPaintView(pValue, m_pShell->GetWin());
-    }
 
-    ~RenderContextGuard()
-    {
-        if (m_pRef != m_pShell->GetWin() && m_pShell->Imp()->GetDrawView())
+        if (pValue != m_pShell->GetWin())
         {
-            // Need to explicitly draw the overlay on m_pRef, since by default
-            // they would be only drawn for m_pOriginalValue.
-            SdrPaintWindow* pOldPaintWindow = m_pShell->Imp()->GetDrawView()->GetPaintWindow(0);
-            const rtl::Reference<sdr::overlay::OverlayManager>& xOldManager = pOldPaintWindow->GetOverlayManager();
-            if (xOldManager.is())
+            SdrView* pDrawView(m_pShell->Imp()->GetDrawView());
+
+            if (nullptr != pDrawView)
             {
-                if (SdrPaintWindow* pNewPaintWindow = m_pShell->Imp()->GetDrawView()->FindPaintWindow(*m_pRef))
-                    xOldManager->completeRedraw(pNewPaintWindow->GetRedrawRegion(), m_pRef);
+                SdrPageView* pSdrPageView(pDrawView->GetSdrPageView());
+
+                if (nullptr != pSdrPageView)
+                {
+                    m_pPatchedPageWindow = pSdrPageView->FindPageWindow(*m_pShell->GetWin());
+
+                    if (nullptr != m_pPatchedPageWindow)
+                    {
+                        m_TemporaryPaintWindow.reset(new SdrPaintWindow(*pDrawView, *pValue));
+                        m_pPatchedPageWindow->patchPaintWindow(*m_TemporaryPaintWindow);
+                    }
+                }
             }
+        }
+    }
 
-            m_pShell->Imp()->GetDrawView()->DeleteWindowFromPaintView(m_pRef);
+    ~RenderContextGuard()
+    {
+        if(nullptr != m_pPatchedPageWindow)
+        {
+            m_pPatchedPageWindow->unpatchPaintWindow();
         }
-        m_pRef = m_pOriginalValue;
     }
 };
 }


More information about the Libreoffice-commits mailing list