diff options
author | Chris Sherlock <chris.sherlock79@gmail.com> | 2014-04-06 17:18:09 +1000 |
---|---|---|
committer | Chris Sherlock <chris.sherlock79@gmail.com> | 2014-04-06 06:05:39 -0500 |
commit | c8e7bae4da31ca7ed0a30ad476b7733f3c770bf9 (patch) | |
tree | ca22d0f1d5b95eb9affd3ab8cad19899f8aa327e /vcl/source/gdi | |
parent | cb554bc388b09ef34af44be611fc6e798eb2bb5b (diff) |
fdo#74702 use same gradient steps func. to draw linear and complex grads
Reworked Output::ImplGetGradientSteps to be usable for both linear and
complex (actually, axial, but that's another story) gradients by adding
a default parameter.
This gets rid of another meOutDevType from gradient functions
Change-Id: I1dc918e4c3153617d172560523cfca303f0b904c
Reviewed-on: https://gerrit.libreoffice.org/8872
Reviewed-by: Chris Sherlock <chris.sherlock79@gmail.com>
Tested-by: Chris Sherlock <chris.sherlock79@gmail.com>
Diffstat (limited to 'vcl/source/gdi')
-rw-r--r-- | vcl/source/gdi/outdev4.cxx | 32 |
1 files changed, 9 insertions, 23 deletions
diff --git a/vcl/source/gdi/outdev4.cxx b/vcl/source/gdi/outdev4.cxx index a8dc07d1a65e..4b825f44dbfd 100644 --- a/vcl/source/gdi/outdev4.cxx +++ b/vcl/source/gdi/outdev4.cxx @@ -145,13 +145,17 @@ long OutputDevice::ImplGetGradientStepCount( long nMinRect ) return nInc; } -long OutputDevice::ImplGetGradientSteps( const Gradient& rGradient, const Rectangle& rRect, bool bMtf ) +long OutputDevice::ImplGetGradientSteps( const Gradient& rGradient, const Rectangle& rRect, bool bMtf, bool bComplex ) { // calculate step count - long nStepCount = rGradient.GetSteps(); + long nStepCount = rGradient.GetSteps(); + long nMinRect; // generate nStepCount, if not passed - long nMinRect = rRect.GetHeight(); + if (bComplex) + nMinRect = std::min( rRect.GetWidth(), rRect.GetHeight() ); + else + nMinRect = rRect.GetHeight(); if ( !nStepCount ) { @@ -385,7 +389,6 @@ void OutputDevice::ImplDrawComplexGradient( const Rectangle& rRect, long nRedSteps = nEndRed - nStartRed; long nGreenSteps = nEndGreen - nStartGreen; long nBlueSteps = nEndBlue - nStartBlue; - long nStepCount = rGradient.GetSteps(); sal_uInt16 nAngle = rGradient.GetAngle() % 3600; rGradient.GetBoundRect( rRect, aRect, aCenter ); @@ -393,25 +396,8 @@ void OutputDevice::ImplDrawComplexGradient( const Rectangle& rRect, if ( UsePolyPolygonForComplexGradient() || bMtf ) pPolyPoly.reset(new PolyPolygon( 2 )); - long nMinRect = std::min( aRect.GetWidth(), aRect.GetHeight() ); - - // calculate number of steps, if this was not passed - if( !nStepCount ) - { - long nInc; - - if ( meOutDevType != OUTDEV_PRINTER && !bMtf ) - { - nInc = ( nMinRect < 50 ) ? 2 : 4; - } - else - { - // #105998# Use display-equivalent step size calculation - nInc = (nMinRect < 800) ? 10 : 20; - } - - nStepCount = nMinRect / nInc; - } + // last parameter - true if complex gradient, false if linear + long nStepCount = ImplGetGradientSteps( rGradient, rRect, bMtf, true ); // at least three steps and at most the number of colour differences long nSteps = std::max( nStepCount, 2L ); |