sw/source/core/crsr/crsrsh.cxx     |    2 +-
 sw/source/core/inc/viewimp.hxx     |   10 ++++++----
 sw/source/core/layout/layact.cxx   |   12 ++++++------
 sw/source/core/layout/paintfrm.cxx |    2 +-
 sw/source/core/view/viewimp.cxx    |   16 +++++-----------
 sw/source/core/view/viewsh.cxx     |   26 +++++++++++---------------
 6 files changed, 30 insertions(+), 38 deletions(-)

New commits:
commit 80bb2ab680ea889a4bcf7104e5c8b1bdce22c9f3
Author:     Luboš Luňák <l.lu...@collabora.com>
AuthorDate: Sun Sep 19 10:02:18 2021 +0200
Commit:     Luboš Luňák <l.lu...@collabora.com>
CommitDate: Mon Sep 20 12:11:09 2021 +0200

    improve the SwViewShellImpl paint region API a bit
    
    Make it clear that the region is a paint region, and make
    the ownership clearer when SwViewShell takes it over.
    
    Change-Id: I229255a8e2d07ccc228e894e85b0a47f1e2b1259
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122309
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lu...@collabora.com>

diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 916e1aa6f980..7bce5b73b488 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -247,7 +247,7 @@ void SwCursorShell::EndAction( const bool bIdleEnd )
     bool bVis = m_bSVCursorVis;
 
     // Idle-formatting?
-    if( bIdleEnd && Imp()->GetRegion() )
+    if( bIdleEnd && Imp()->HasPaintRegion() )
     {
         m_pCurrentCursor->Hide();
     }
diff --git a/sw/source/core/inc/viewimp.hxx b/sw/source/core/inc/viewimp.hxx
index aff1e701245a..06e8968d9483 100644
--- a/sw/source/core/inc/viewimp.hxx
+++ b/sw/source/core/inc/viewimp.hxx
@@ -22,6 +22,7 @@
 #include <tools/color.hxx>
 #include <svx/svdtypes.hxx>
 #include <swrect.hxx>
+#include <swregion.hxx>
 #include <vector>
 #include <memory>
 
@@ -29,7 +30,6 @@ class OutputDevice;
 class SwViewShell;
 class SwFlyFrame;
 class SwViewOption;
-class SwRegionRects;
 class SwFrame;
 class SwLayAction;
 class SwLayIdle;
@@ -64,7 +64,7 @@ class SwViewShellImp
     SdrPageView *m_pSdrPageView;  // Exactly one Page for our DrawView
 
     SwPageFrame     *m_pFirstVisiblePage; // Always points to the first 
visible Page
-    std::unique_ptr<SwRegionRects> m_pRegion; // Collector of Paintrects from 
the LayAction
+    std::unique_ptr<SwRegionRects> m_pPaintRegion; // Collector of Paintrects 
from the LayAction
 
     SwLayAction   *m_pLayAction;      // Is set if an Action object exists
                                  // Is registered by the SwLayAction ctor and 
deregistered by the dtor
@@ -146,8 +146,10 @@ public:
     void SetFirstVisPageInvalid() { m_bFirstPageInvalid = true; }
 
     bool AddPaintRect( const SwRect &rRect );
-    SwRegionRects *GetRegion()      { return m_pRegion.get(); }
-    void DelRegion();
+    bool HasPaintRegion()      { return static_cast<bool>(m_pPaintRegion); }
+    std::unique_ptr<SwRegionRects> TakePaintRegion() { return 
std::move(m_pPaintRegion); }
+    const SwRegionRects* GetPaintRegion() { return m_pPaintRegion.get(); }
+    void DeletePaintRegion() { m_pPaintRegion.reset(); }
 
     /// New Interface for StarView Drawing
     bool  HasDrawView()             const { return nullptr != m_pDrawView; }
diff --git a/sw/source/core/layout/layact.cxx b/sw/source/core/layout/layact.cxx
index 5205e214b735..0605ad1f8cdf 100644
--- a/sw/source/core/layout/layact.cxx
+++ b/sw/source/core/layout/layact.cxx
@@ -2262,15 +2262,15 @@ SwLayIdle::SwLayIdle( SwRootFrame *pRt, SwViewShellImp 
*pI ) :
             --rSh.mnStartAction;
 
             // When using tiled rendering, idle painting is disabled and 
paints are done
-            // only later by tiled rendering. But paints call 
SwViewShellImp::DelRegion()
-            // to reset this GetRegion(), and if it's done too late,
+            // only later by tiled rendering. But paints call 
SwViewShellImp::DeletePaintRegion()
+            // to reset this HasPaintRegion(), and if it's done too late,
             // SwTiledRenderingTest::testTablePaintInvalidate() will end up in 
an infinite
             // loop, because the idle layout will call this code repeatedly, 
because there
-            // will be no idle paints to reset GetRegion().
+            // will be no idle paints to reset HasPaintRegion().
             // This code dates back to the initial commit, and I find its 
purpose unclear,
             // so I'm still leaving it here in case it turns out it serves a 
purpose.
             static const bool blockOnRepaints = true;
-            if (!blockOnRepaints && rSh.Imp()->GetRegion())
+            if (!blockOnRepaints && rSh.Imp()->HasPaintRegion())
                 bActions = true;
             else
             {
@@ -2309,9 +2309,9 @@ SwLayIdle::SwLayIdle( SwRootFrame *pRt, SwViewShellImp 
*pI ) :
                 // solution would be disproportionally expensive.
                 SwViewShellImp *pViewImp = rSh.Imp();
                 bool bUnlock = false;
-                if ( pViewImp->GetRegion() )
+                if ( pViewImp->HasPaintRegion() )
                 {
-                    pViewImp->DelRegion();
+                    pViewImp->DeletePaintRegion();
 
                     // Cause a repaint with virtual device.
                     rSh.LockPaint();
diff --git a/sw/source/core/layout/paintfrm.cxx 
b/sw/source/core/layout/paintfrm.cxx
index c910daa2053e..59b6922ddc04 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -3075,7 +3075,7 @@ void SwRootFrame::PaintSwFrame(vcl::RenderContext& 
rRenderContext, SwRect const&
         aAction.Action(&rRenderContext);
         ResetTurboFlag();
         if ( !pSh->ActionPend() )
-            pSh->Imp()->DelRegion();
+            pSh->Imp()->DeletePaintRegion();
     }
 
     aRect.Intersection( pSh->VisArea() );
diff --git a/sw/source/core/view/viewimp.cxx b/sw/source/core/view/viewimp.cxx
index 6f9492df7f4d..e2243bb1ad88 100644
--- a/sw/source/core/view/viewimp.cxx
+++ b/sw/source/core/view/viewimp.cxx
@@ -23,7 +23,6 @@
 #include <viewopt.hxx>
 #include <flyfrm.hxx>
 #include <layact.hxx>
-#include <swregion.hxx>
 #include <dview.hxx>
 #include <swmodule.hxx>
 #include <svx/svdpage.hxx>
@@ -108,31 +107,26 @@ SwViewShellImp::~SwViewShellImp()
 
     m_pDrawView.reset();
 
-    DelRegion();
+    DeletePaintRegion();
 
     OSL_ENSURE( !m_pLayAction, "Have action for the rest of your life." );
     OSL_ENSURE( !m_pIdleAct,"Be idle for the rest of your life." );
 }
 
-void SwViewShellImp::DelRegion()
-{
-    m_pRegion.reset();
-}
-
 bool SwViewShellImp::AddPaintRect( const SwRect &rRect )
 {
     // In case of tiled rendering the visual area is the last painted tile -> 
not interesting.
     if ( rRect.Overlaps( m_pShell->VisArea() ) || 
comphelper::LibreOfficeKit::isActive() )
     {
-        if ( !m_pRegion )
+        if ( !m_pPaintRegion )
         {
             // In case of normal rendering, this makes sure only visible 
rectangles are painted.
             // Otherwise get the rectangle of the full document, so all paint 
rectangles are invalidated.
             const SwRect& rArea = comphelper::LibreOfficeKit::isActive() ? 
m_pShell->GetLayout()->getFrameArea() : m_pShell->VisArea();
-            m_pRegion.reset(new SwRegionRects);
-            m_pRegion->ChangeOrigin(rArea);
+            m_pPaintRegion.reset(new SwRegionRects);
+            m_pPaintRegion->ChangeOrigin(rArea);
         }
-        (*m_pRegion) += rRect;
+        (*m_pPaintRegion) += rRect;
         return true;
     }
     return false;
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index e80d07769f09..758782b8e3ce 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -274,8 +274,8 @@ void SwViewShell::ImplEndAction( const bool bIdleEnd )
     if ( Imp()->HasDrawView() && !Imp()->GetDrawView()->areMarkHandlesHidden() 
)
         Imp()->StartAction();
 
-    if ( Imp()->GetRegion() && Imp()->GetRegion()->GetOrigin() != VisArea() )
-        Imp()->DelRegion();
+    if ( Imp()->HasPaintRegion() && Imp()->GetPaintRegion()->GetOrigin() != 
VisArea() )
+        Imp()->DeletePaintRegion();
 
     const bool bExtraData = ::IsExtraData( GetDoc() );
 
@@ -294,7 +294,7 @@ void SwViewShell::ImplEndAction( const bool bIdleEnd )
 
     //If we don't call Paints, we wait for the Paint of the system.
     //Then the clipping is set correctly; e.g. shifting of a Draw object
-    if ( Imp()->GetRegion()     ||
+    if ( Imp()->HasPaintRegion()     ||
          maInvalidRect.HasArea() ||
          bExtraData )
     {
@@ -314,7 +314,7 @@ void SwViewShell::ImplEndAction( const bool bIdleEnd )
             }
             mbPaintWorks = true;
 
-            std::unique_ptr<SwRegionRects> pRegion = 
std::move(Imp()->m_pRegion);
+            std::unique_ptr<SwRegionRects> pRegion = Imp()->TakePaintRegion();
 
             //JP 27.11.97: what hid the selection, must also Show it,
             //             else we get Paint errors!
@@ -437,7 +437,7 @@ void SwViewShell::ImplEndAction( const bool bIdleEnd )
         }
         else
         {
-            Imp()->DelRegion();
+            Imp()->DeletePaintRegion();
             mbPaintWorks =  true;
         }
     }
@@ -1094,8 +1094,8 @@ void SwViewShell::VisPortChgd( const SwRect &rRect)
     //the PaintRegion is at least by now obsolete. The PaintRegion can
     //have been created by RootFrame::PaintSwFrame.
     if ( !mbInEndAction &&
-         Imp()->GetRegion() && Imp()->GetRegion()->GetOrigin() != VisArea() )
-        Imp()->DelRegion();
+         Imp()->HasPaintRegion() && Imp()->GetPaintRegion()->GetOrigin() != 
VisArea() )
+        Imp()->DeletePaintRegion();
 
     CurrShell aCurr( this );
 
@@ -1630,8 +1630,8 @@ bool SwViewShell::CheckInvalidForPaint( const SwRect 
&rRect )
         //Unfortunately Start/EndAction won't help here, as the Paint 
originated
         //from GUI and so Clipping has been set against getting through.
         //Ergo: do it all yourself (see ImplEndAction())
-        if ( Imp()->GetRegion() && Imp()->GetRegion()->GetOrigin() != 
VisArea())
-             Imp()->DelRegion();
+        if ( Imp()->HasPaintRegion() && Imp()->GetPaintRegion()->GetOrigin() 
!= VisArea())
+             Imp()->DeletePaintRegion();
 
         SwLayAction aAction( GetLayout(), Imp() );
         aAction.SetComplete( false );
@@ -1644,7 +1644,7 @@ bool SwViewShell::CheckInvalidForPaint( const SwRect 
&rRect )
         aAction.Action(GetWin()->GetOutDev());
         --mnStartAction;
 
-        SwRegionRects *pRegion = Imp()->GetRegion();
+        std::unique_ptr<SwRegionRects> pRegion = Imp()->TakePaintRegion();
         if ( pRegion && aAction.IsBrowseActionStop() )
         {
             //only of interest when something has changed in the visible range
@@ -1657,10 +1657,7 @@ bool SwViewShell::CheckInvalidForPaint( const SwRect 
&rRect )
                     break;
             }
             if ( bStop )
-            {
-                Imp()->DelRegion();
-                pRegion = nullptr;
-            }
+                pRegion.reset();
         }
 
         if ( pRegion )
@@ -1701,7 +1698,6 @@ bool SwViewShell::CheckInvalidForPaint( const SwRect 
&rRect )
             }
             else
                 bRet = false;
-            Imp()->DelRegion();
         }
         else
             bRet = false;

Reply via email to