diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2021-10-04 22:58:24 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2021-10-05 08:01:42 +0200 |
commit | 71429b93ec0687bbbedcbb776b38c981f4017177 (patch) | |
tree | d0cd66b02f6d13fe282c0d615d1bc4a58cf854a1 /sw/source/core/view | |
parent | 8e49016473f0142cb07a1b30f4073f3e73aa4747 (diff) |
try to merge rectangles already in AddPaintRect()
It turns out that e.g. adding a new line in Writer results
in a number of paint rectangles that actually often line up and
form a large rectangle. So try to detect these and merge them
directly, resulting in less work for SwRegionsRects::Compress().
Change-Id: If89ae9463d9c80a1492431afd37bcedfd24bea2d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123077
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'sw/source/core/view')
-rw-r--r-- | sw/source/core/view/viewimp.cxx | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/sw/source/core/view/viewimp.cxx b/sw/source/core/view/viewimp.cxx index e2243bb1ad88..abb2ef6b174a 100644 --- a/sw/source/core/view/viewimp.cxx +++ b/sw/source/core/view/viewimp.cxx @@ -126,6 +126,32 @@ bool SwViewShellImp::AddPaintRect( const SwRect &rRect ) m_pPaintRegion.reset(new SwRegionRects); m_pPaintRegion->ChangeOrigin(rArea); } + if(!m_pPaintRegion->empty()) + { + // This function often gets called with rectangles that line up vertically. + // Try to extend the last one downwards to include the new one. + SwRect& last = m_pPaintRegion->back(); + if(last.Left() == rRect.Left() && last.Width() == rRect.Width() + && last.Bottom() + 1 >= rRect.Top() && last.Bottom() <= rRect.Bottom()) + { + last = SwRect( last.TopLeft(), rRect.BottomRight()); + // And these rectangles lined up vertically often come up in groups + // that line up horizontally. Try to extend the previous rectangle + // to the right to include the last one. + if(m_pPaintRegion->size() > 1) + { + SwRect& last2 = (*m_pPaintRegion)[m_pPaintRegion->size() - 2]; + if(last2.Top() == last.Top() && last2.Height() == last.Height() + && last2.Right() + 1 >= last.Left() && last2.Right() <= last2.Right()) + { + last2 = SwRect( last.TopLeft(), rRect.BottomRight()); + m_pPaintRegion->pop_back(); + return true; + } + } + return true; + } + } (*m_pPaintRegion) += rRect; return true; } |