include/vcl/outdev.hxx         |    3 ++-
 vcl/source/outdev/gradient.cxx |   41 ++++++++++++++++++++++++++++++-----------
 2 files changed, 32 insertions(+), 12 deletions(-)

New commits:
commit 4c3c94704704e5090c0382476251caee7a904454
Author:     Chris Sherlock <chris.sherloc...@gmail.com>
AuthorDate: Sun Oct 31 21:34:49 2021 +1100
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Wed Nov 17 20:57:42 2021 +0100

    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 <qui...@gmail.com>

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;
     }
 

Reply via email to