vcl/source/outdev/gradient.cxx |  100 ++++++++++++++++++++---------------------
 1 file changed, 50 insertions(+), 50 deletions(-)

New commits:
commit bf348b395f0ed66e3e7263144d77200d8f176010
Author:     Christopher Sherlock <chris.sherloc...@gmail.com>
AuthorDate: Thu Aug 14 23:44:58 2025 +1000
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Thu Aug 28 13:59:53 2025 +0200

    vcl: flatten OutputDevice::DrawGradient()
    
    Change-Id: Ie534864d8bb32621a65eb638f5ee50e5e013f358
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189700
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Tested-by: Jenkins

diff --git a/vcl/source/outdev/gradient.cxx b/vcl/source/outdev/gradient.cxx
index f8d3ca98d8a7..063da7bbb2c6 100644
--- a/vcl/source/outdev/gradient.cxx
+++ b/vcl/source/outdev/gradient.cxx
@@ -78,66 +78,66 @@ void OutputDevice::DrawGradient( const tools::PolyPolygon& 
rPolyPoly,
         return;
 
     // Clip and then draw the gradient
-    if( !tools::Rectangle( PixelToLogic( Point() ), GetOutputSize() 
).IsEmpty() )
+    if (tools::Rectangle(PixelToLogic(Point()), GetOutputSize()).IsEmpty())
+        return;
+
+    const tools::Rectangle aBoundRect( rPolyPoly.GetBoundRect() );
+
+    // convert rectangle to pixels
+    tools::Rectangle aRect( ImplLogicToDevicePixel( aBoundRect ) );
+    aRect.Normalize();
+
+    // do nothing if the rectangle is empty
+    if ( !aRect.IsEmpty() )
     {
-        const tools::Rectangle aBoundRect( rPolyPoly.GetBoundRect() );
+        tools::PolyPolygon aClixPolyPoly( ImplLogicToDevicePixel( rPolyPoly ) 
);
+        bool bDrawn = false;
 
-        // convert rectangle to pixels
-        tools::Rectangle aRect( ImplLogicToDevicePixel( aBoundRect ) );
-        aRect.Normalize();
+        if( !mpGraphics && !AcquireGraphics() )
+            return;
 
-        // do nothing if the rectangle is empty
-        if ( !aRect.IsEmpty() )
-        {
-            tools::PolyPolygon aClixPolyPoly( ImplLogicToDevicePixel( 
rPolyPoly ) );
-            bool bDrawn = false;
+        // secure clip region
+        auto popIt = ScopedPush(vcl::PushFlags::CLIPREGION);
+        IntersectClipRegion( aBoundRect );
 
-            if( !mpGraphics && !AcquireGraphics() )
-                return;
+        if (mbInitClipRegion)
+            InitClipRegion();
 
-            // secure clip region
-            auto popIt = ScopedPush(vcl::PushFlags::CLIPREGION);
-            IntersectClipRegion( aBoundRect );
+        // try to draw gradient natively
+        if (!mbOutputClipped)
+            bDrawn = mpGraphics->DrawGradient( aClixPolyPoly, aGradient, *this 
);
 
-            if (mbInitClipRegion)
-                InitClipRegion();
+        if (!bDrawn && !mbOutputClipped)
+        {
+            // draw gradients without border
+            if( mbLineColor || mbInitLineColor )
+            {
+                mpGraphics->SetLineColor();
+                mbInitLineColor = true;
+            }
 
-            // try to draw gradient natively
-            if (!mbOutputClipped)
-                bDrawn = mpGraphics->DrawGradient( aClixPolyPoly, aGradient, 
*this );
+            mbInitFillColor = true;
 
-            if (!bDrawn && !mbOutputClipped)
+            // calculate step count if necessary
+            if ( !aGradient.GetSteps() )
+                aGradient.SetSteps( GRADIENT_DEFAULT_STEPCOUNT );
+
+            if ( rPolyPoly.IsRect() )
             {
-                // draw gradients 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 ( rPolyPoly.IsRect() )
-                {
-                    // because we draw with no border line, we have to expand 
gradient
-                    // rect to avoid missing lines on the right and bottom edge
-                    aRect.AdjustLeft( -1 );
-                    aRect.AdjustTop( -1 );
-                    aRect.AdjustRight( 1 );
-                    aRect.AdjustBottom( 1 );
-                }
-
-                // if the clipping polypolygon is a rectangle, then it's the 
same size as the bounding of the
-                // polypolygon, so pass in a NULL for the clipping parameter
-                if( aGradient.GetStyle() == css::awt::GradientStyle_LINEAR || 
rGradient.GetStyle() == css::awt::GradientStyle_AXIAL )
-                    DrawLinearGradient( aRect, aGradient, 
aClixPolyPoly.IsRect() ? nullptr : &aClixPolyPoly );
-                else
-                    DrawComplexGradient( aRect, aGradient, 
aClixPolyPoly.IsRect() ? nullptr : &aClixPolyPoly );
+                // because we draw with no border line, we have to expand 
gradient
+                // rect to avoid missing lines on the right and bottom edge
+                aRect.AdjustLeft( -1 );
+                aRect.AdjustTop( -1 );
+                aRect.AdjustRight( 1 );
+                aRect.AdjustBottom( 1 );
             }
+
+            // if the clipping polypolygon is a rectangle, then it's the same 
size as the bounding of the
+            // polypolygon, so pass in a NULL for the clipping parameter
+            if( aGradient.GetStyle() == css::awt::GradientStyle_LINEAR || 
rGradient.GetStyle() == css::awt::GradientStyle_AXIAL )
+                DrawLinearGradient( aRect, aGradient, aClixPolyPoly.IsRect() ? 
nullptr : &aClixPolyPoly );
+            else
+                DrawComplexGradient( aRect, aGradient, aClixPolyPoly.IsRect() 
? nullptr : &aClixPolyPoly );
         }
     }
 }

Reply via email to