diff options
author | Michael Meeks <michael.meeks@suse.com> | 2012-12-11 11:28:30 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@suse.com> | 2012-12-11 11:54:09 +0000 |
commit | 055fca04a4e00b14e68fa5860b417cb25e471299 (patch) | |
tree | 5a3b44a9593e3f7c61fcfbebfa36b3cf925a4d53 /vcl/source/gdi/outdev4.cxx | |
parent | 017ac0b09ba511ad726149e9e5aaf1483ef88064 (diff) |
fdo#42553 - fix square gradient rendering by vcl.
Diffstat (limited to 'vcl/source/gdi/outdev4.cxx')
-rw-r--r-- | vcl/source/gdi/outdev4.cxx | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/vcl/source/gdi/outdev4.cxx b/vcl/source/gdi/outdev4.cxx index 8096924a1bfa..4e895eb8bb69 100644 --- a/vcl/source/gdi/outdev4.cxx +++ b/vcl/source/gdi/outdev4.cxx @@ -481,7 +481,18 @@ void OutputDevice::ImplDrawComplexGradient( const Rectangle& rRect, double fScanTop = aRect.Top(); double fScanRight = aRect.Right(); double fScanBottom = aRect.Bottom(); - double fScanInc = (double) nMinRect / (double) nSteps * 0.5; + double fScanIncX = (double) aRect.GetWidth() / (double) nSteps * 0.5; + double fScanIncY = (double) aRect.GetHeight() / (double) nSteps * 0.5; + + // all gradients are rendered as nested rectangles which shrink + // equally in each dimension - except for 'square' gradients + // which shrink to a central vertex but are not per-se square. + if( rGradient.GetStyle() != GradientStyle_SQUARE ) + { + fScanIncY = std::min( fScanIncY, fScanIncX ); + fScanIncX = fScanIncY; + } + sal_uInt8 nRed = (sal_uInt8) nStartRed, nGreen = (sal_uInt8) nStartGreen, nBlue = (sal_uInt8) nStartBlue; bool bPaintLastPolygon( false ); // #107349# Paint last polygon only if loop has generated any output @@ -512,10 +523,10 @@ void OutputDevice::ImplDrawComplexGradient( const Rectangle& rRect, for( long i = 1; i < nSteps; i++ ) { // neues Polygon berechnen - aRect.Left() = (long)( fScanLeft += fScanInc ); - aRect.Top() = (long)( fScanTop += fScanInc ); - aRect.Right() = (long)( fScanRight -= fScanInc ); - aRect.Bottom() = (long)( fScanBottom -= fScanInc ); + aRect.Left() = (long)( fScanLeft += fScanIncX ); + aRect.Top() = (long)( fScanTop += fScanIncY ); + aRect.Right() = (long)( fScanRight -= fScanIncX ); + aRect.Bottom() = (long)( fScanBottom -= fScanIncY ); if( ( aRect.GetWidth() < 2 ) || ( aRect.GetHeight() < 2 ) ) break; |