diff options
author | Chris Sherlock <chris.sherlock79@gmail.com> | 2021-10-31 21:34:49 +1100 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2021-11-17 20:57:42 +0100 |
commit | 4c3c94704704e5090c0382476251caee7a904454 (patch) | |
tree | bcc34e89d4f07733fd19dc2912acb11a98e6e140 | |
parent | b5c22a9371e22162ff7305ffaa393ed908eee610 (diff) |
vcl: split GetGradientSteps() into Get{Complex|Linear}GradientSteps()
Change-Id: Ieb0d5d6f1a7c9fff3671ef74ffac9eaf37dcb0e1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123060
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r-- | include/vcl/outdev.hxx | 3 | ||||
-rw-r--r-- | vcl/source/outdev/gradient.cxx | 41 |
2 files changed, 32 insertions, 12 deletions
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx index e82bf1e357a6..eec957e14973 100644 --- a/include/vcl/outdev.hxx +++ b/include/vcl/outdev.hxx @@ -815,7 +815,8 @@ private: SAL_DLLPRIVATE void DrawLinearGradientToMetafile( const tools::Rectangle& rRect, const Gradient& rGradient ); SAL_DLLPRIVATE void DrawComplexGradientToMetafile( const tools::Rectangle& rRect, const Gradient& rGradient ); - SAL_DLLPRIVATE tools::Long GetGradientSteps( const Gradient& rGradient, const tools::Rectangle& rRect, bool bMtf, bool bComplex=false ); + SAL_DLLPRIVATE tools::Long GetLinearGradientSteps( const Gradient& rGradient, const tools::Rectangle& rRect, bool bMtf); + SAL_DLLPRIVATE tools::Long GetComplexGradientSteps( const Gradient& rGradient, const tools::Rectangle& rRect, bool bMtf); SAL_DLLPRIVATE Color GetSingleColorGradientFill(); ///@} diff --git a/vcl/source/outdev/gradient.cxx b/vcl/source/outdev/gradient.cxx index 6bb6e8de64fc..7dc5523480db 100644 --- a/vcl/source/outdev/gradient.cxx +++ b/vcl/source/outdev/gradient.cxx @@ -357,7 +357,7 @@ void OutputDevice::DrawLinearGradient( const tools::Rectangle& rRect, } // calculate step count - tools::Long nStepCount = GetGradientSteps( rGradient, aRect, false/*bMtf*/ ); + tools::Long nStepCount = GetLinearGradientSteps(rGradient, aRect, false/*bMtf*/); // minimal three steps and maximal as max color steps tools::Long nAbsRedSteps = std::abs( nEndRed - nStartRed ); @@ -479,7 +479,7 @@ void OutputDevice::DrawComplexGradient( const tools::Rectangle& rRect, if ( UsePolyPolygonForComplexGradient() ) xPolyPoly = tools::PolyPolygon( 2 ); - tools::Long nStepCount = GetGradientSteps( rGradient, rRect, false/*bMtf*/, true/*bComplex*/ ); + tools::Long nStepCount = GetComplexGradientSteps(rGradient, rRect, false/*bMtf*/); // at least three steps and at most the number of colour differences tools::Long nSteps = std::max( nStepCount, tools::Long(2) ); @@ -715,7 +715,7 @@ void OutputDevice::DrawLinearGradientToMetafile( const tools::Rectangle& rRect, } } - tools::Long nStepCount = GetGradientSteps( rGradient, aRect, true/*bMtf*/ ); + tools::Long nStepCount = GetLinearGradientSteps( rGradient, aRect, true/*bMtf*/ ); // minimal three steps and maximal as max color steps tools::Long nAbsRedSteps = std::abs( nEndRed - nStartRed ); @@ -816,7 +816,7 @@ void OutputDevice::DrawComplexGradientToMetafile( const tools::Rectangle& rRect, xPolyPoly = tools::PolyPolygon( 2 ); // last parameter - true if complex gradient, false if linear - tools::Long nStepCount = GetGradientSteps(rGradient, rRect, true, true); + tools::Long nStepCount = GetComplexGradientSteps(rGradient, rRect, true); // at least three steps and at most the number of colour differences tools::Long nSteps = std::max(nStepCount, tools::Long(2)); @@ -951,25 +951,44 @@ tools::Long OutputDevice::GetGradientStepCount( tools::Long nMinRect ) return nInc; } -tools::Long OutputDevice::GetGradientSteps( const Gradient& rGradient, const tools::Rectangle& rRect, bool bMtf, bool bComplex ) +tools::Long OutputDevice::GetLinearGradientSteps(Gradient const& rGradient, tools::Rectangle const& rRect, bool bMtf) { // calculate step count tools::Long nStepCount = rGradient.GetSteps(); - tools::Long nMinRect; // generate nStepCount, if not passed - if (bComplex) - nMinRect = std::min( rRect.GetWidth(), rRect.GetHeight() ); - else - nMinRect = rRect.GetHeight(); + tools::Long nMinRect = rRect.GetHeight(); if ( !nStepCount ) { tools::Long nInc; - nInc = GetGradientStepCount (nMinRect); + nInc = GetGradientStepCount(nMinRect); if ( !nInc || bMtf ) nInc = 1; + + nStepCount = nMinRect / nInc; + } + + return nStepCount; +} + +tools::Long OutputDevice::GetComplexGradientSteps(Gradient const& rGradient, tools::Rectangle const& rRect, bool bMtf) +{ + // calculate step count + tools::Long nStepCount = rGradient.GetSteps(); + + // generate nStepCount, if not passed + tools::Long nMinRect = std::min(rRect.GetWidth(), rRect.GetHeight()); + + if ( !nStepCount ) + { + tools::Long nInc; + nInc = GetGradientStepCount(nMinRect); + + if ( !nInc || bMtf ) + nInc = 1; + nStepCount = nMinRect / nInc; } |