summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Sherlock <chris.sherlock79@gmail.com>2014-04-06 17:18:09 +1000
committerChris Sherlock <chris.sherlock79@gmail.com>2014-04-06 06:05:39 -0500
commitc8e7bae4da31ca7ed0a30ad476b7733f3c770bf9 (patch)
treeca22d0f1d5b95eb9affd3ab8cad19899f8aa327e
parentcb554bc388b09ef34af44be611fc6e798eb2bb5b (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>
-rw-r--r--include/vcl/outdev.hxx2
-rw-r--r--vcl/source/gdi/outdev4.cxx32
2 files changed, 10 insertions, 24 deletions
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index 56aa0739c04f..016fc168513c 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -853,7 +853,7 @@ private:
SAL_DLLPRIVATE void ImplClearFontData( bool bNewFontLists );
SAL_DLLPRIVATE void ImplRefreshFontData( bool bNewFontLists );
SAL_DLLPRIVATE static void ImplUpdateFontDataForAllFrames( FontUpdateHandler_t pHdl, bool bNewFontLists );
- SAL_DLLPRIVATE long ImplGetGradientSteps( const Gradient& rGradient, const Rectangle& rRect, bool bMtf );
+ SAL_DLLPRIVATE long ImplGetGradientSteps( const Gradient& rGradient, const Rectangle& rRect, bool bMtf, bool bComplex=false );
// not implemented; to detect misuses of DrawOutDev(...OutputDevice&);
void DrawOutDev( const Point&, const Size&, const Point&, const Size&, const Printer&);
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 );