sw/source/core/layout/paintfrm.cxx | 40 ++++++++++++------------------------- 1 file changed, 14 insertions(+), 26 deletions(-)
New commits: commit 9f44d19815c32aa0cb53d0cb89bc396f5071fc81 Author: gkorepanov <gkorepanov...@gmail.com> Date: Sun Jan 22 20:18:13 2017 +0300 Made lcl_DrawDashedRect() more readable and faster a bit Change-Id: I58e06f090248e034541e276f11cecef8b26e874a Reviewed-on: https://gerrit.libreoffice.org/33394 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Björn Michaelsen <bjoern.michael...@canonical.com> diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index 27c722b..6fddaae 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -972,36 +972,24 @@ void SwLineRects::LockLines( bool bLock ) static void lcl_DrawDashedRect( OutputDevice * pOut, SwLineRect & rLRect ) { - double nHalfLWidth = rLRect.Height( ); - if ( nHalfLWidth > 1 ) - { - nHalfLWidth = nHalfLWidth / 2; - } - else - { - nHalfLWidth = 1; - } + long startX = rLRect.Left( ), endX; + long startY = rLRect.Top( ), endY; - long startX = rLRect.Left( ); - long startY = rLRect.Top( ) + static_cast<long>(nHalfLWidth); - long endX = rLRect.Left( ) + rLRect.Width( ); - long endY = rLRect.Top( ) + static_cast<long>(nHalfLWidth); + // Discriminate vertically stretched rect from horizontally stretched + // and restrict minimum nHalfLWidth to 1 + long nHalfLWidth = std::max( static_cast<long>(std::min( rLRect.Width( ), rLRect.Height( ) ) / 2), 1L ); if ( rLRect.Height( ) > rLRect.Width( ) ) { - nHalfLWidth = rLRect.Width( ); - if ( nHalfLWidth > 1 ) - { - nHalfLWidth = nHalfLWidth / 2; - } - else - { - nHalfLWidth = 1; - } - startX = rLRect.Left( ) + static_cast<long>(nHalfLWidth); - startY = rLRect.Top( ); - endX = rLRect.Left( ) + static_cast<long>(nHalfLWidth); - endY = rLRect.Top( ) + rLRect.Height( ); + startX += nHalfLWidth; + endX = startX; + endY = startY + rLRect.Height( ); + } + else + { + startY += nHalfLWidth; + endY = startY; + endX = startX + rLRect.Width( ); } svtools::DrawLine( *pOut, Point( startX, startY ), Point( endX, endY ),
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits