diff options
author | Chris Sherlock <chris.sherlock79@gmail.com> | 2014-04-08 21:49:24 +1000 |
---|---|---|
committer | Chris Sherlock <chris.sherlock79@gmail.com> | 2014-04-08 21:54:07 +1000 |
commit | 954d7ad4ea7ec3746b0f0cd3f850a25e82b39c14 (patch) | |
tree | 7fdaa38060dd40824bde910cf151b856c3234e29 | |
parent | 486b47ae45727402317bed047c80a6ab7e134491 (diff) |
Starting to bring DrawGradient functions into line with each other
OutputDevice's DrawGradient functions are remarkably similar - I've
reorganized them and brought them into line with some extra checks
that seem to be missing. This will allow for easier refactoring.
Change-Id: I6f83bb9fe73d34e3668d87b4a4ee91c49d8cea0f
-rw-r--r-- | vcl/source/gdi/outdev4.cxx | 126 |
1 files changed, 66 insertions, 60 deletions
diff --git a/vcl/source/gdi/outdev4.cxx b/vcl/source/gdi/outdev4.cxx index 7e3ff3f42bee..16a211f4a928 100644 --- a/vcl/source/gdi/outdev4.cxx +++ b/vcl/source/gdi/outdev4.cxx @@ -606,87 +606,93 @@ void OutputDevice::SetGrayscaleColors( Gradient &rGradient ) void OutputDevice::DrawGradient( const Rectangle& rRect, const Gradient& rGradient ) { - if ( mnDrawMode & DRAWMODE_NOGRADIENT ) - { return; // nothing to draw! - } - else if ( mnDrawMode & ( DRAWMODE_BLACKGRADIENT | DRAWMODE_WHITEGRADIENT | DRAWMODE_SETTINGSGRADIENT) ) - { - Color aColor = GetSingleColorGradientFill(); + if ( mbInitClipRegion ) + ImplInitClipRegion(); - Push( PUSH_LINECOLOR | PUSH_FILLCOLOR ); - SetLineColor( aColor ); - SetFillColor( aColor ); - DrawRect( rRect ); - Pop(); + if ( mbOutputClipped ) return; - } - Gradient aGradient( rGradient ); - - if ( mnDrawMode & ( DRAWMODE_GRAYGRADIENT | DRAWMODE_GHOSTEDGRADIENT ) ) + if ( !rRect.IsEmpty() ) { - SetGrayscaleColors( aGradient ); - } - - if( mpMetaFile ) - mpMetaFile->AddAction( new MetaGradientAction( rRect, aGradient ) ); + if ( mnDrawMode & ( DRAWMODE_BLACKGRADIENT | DRAWMODE_WHITEGRADIENT | DRAWMODE_SETTINGSGRADIENT) ) + { + Color aColor = GetSingleColorGradientFill(); - if( !IsDeviceOutputNecessary() || ImplIsRecordLayout() ) - return; + Push( PUSH_LINECOLOR | PUSH_FILLCOLOR ); + SetLineColor( aColor ); + SetFillColor( aColor ); + DrawRect( rRect ); + Pop(); + return; + } - // convert rectangle to pixels - Rectangle aRect( ImplLogicToDevicePixel( rRect ) ); - aRect.Justify(); + Gradient aGradient( rGradient ); - // do nothing if the rectangle is empty - if ( !aRect.IsEmpty() ) - { - // Clip Region sichern - Push( PUSH_CLIPREGION ); - IntersectClipRegion( rRect ); + if( mpMetaFile ) + mpMetaFile->AddAction( new MetaGradientAction( rRect, aGradient ) ); - // because we draw with no border line, we have to expand gradient - // rect to avoid missing lines on the right and bottom edge - aRect.Left()--; - aRect.Top()--; - aRect.Right()++; - aRect.Bottom()++; + if( !IsDeviceOutputNecessary() || ImplIsRecordLayout() ) + return; - // we need a graphics - if ( !mpGraphics ) + if ( mnDrawMode & ( DRAWMODE_GRAYGRADIENT | DRAWMODE_GHOSTEDGRADIENT ) ) { - if ( !ImplGetGraphics() ) - return; + SetGrayscaleColors( aGradient ); } - if ( mbInitClipRegion ) - ImplInitClipRegion(); - - if ( !mbOutputClipped ) + if ( !Rectangle( PixelToLogic( Point() ), GetOutputSize() ).IsEmpty() ) { - // gradients are drawn without border - if ( mbLineColor || mbInitLineColor ) + // convert rectangle to pixels + Rectangle aRect( ImplLogicToDevicePixel( rRect ) ); + aRect.Justify(); + + // do nothing if the rectangle is empty + if ( !aRect.IsEmpty() ) { - mpGraphics->SetLineColor(); - mbInitLineColor = true; - } + // we need a graphics + if ( !mpGraphics && !ImplGetGraphics() ) + return; - mbInitFillColor = true; + // secure clip region + Push( PUSH_CLIPREGION ); + IntersectClipRegion( rRect ); - // calculate step count if necessary - if ( !aGradient.GetSteps() ) - aGradient.SetSteps( GRADIENT_DEFAULT_STEPCOUNT ); + // because we draw with no border line, we have to expand gradient + // rect to avoid missing lines on the right and bottom edge + aRect.Left()--; + aRect.Top()--; + aRect.Right()++; + aRect.Bottom()++; - if( aGradient.GetStyle() == GradientStyle_LINEAR || aGradient.GetStyle() == GradientStyle_AXIAL ) - ImplDrawLinearGradient( aRect, rGradient, false, NULL ); - else - ImplDrawComplexGradient( aRect, rGradient, false, NULL ); - } + if ( mbInitClipRegion ) + ImplInitClipRegion(); - Pop(); + if ( !mbOutputClipped ) + { + // gradients are drawn without border + if ( mbLineColor || mbInitLineColor ) + { + mpGraphics->SetLineColor(); + mbInitLineColor = true; + } + + mbInitFillColor = true; + + // calculate step count if necessary + if ( !aGradient.GetSteps() ) + aGradient.SetSteps( GRADIENT_DEFAULT_STEPCOUNT ); + + if( aGradient.GetStyle() == GradientStyle_LINEAR || aGradient.GetStyle() == GradientStyle_AXIAL ) + ImplDrawLinearGradient( aRect, rGradient, false, NULL ); + else + ImplDrawComplexGradient( aRect, rGradient, false, NULL ); + } + + Pop(); + } + } } if( mpAlphaVDev ) |