[Libreoffice-commits] core.git: vcl/source

Chris Sherlock chris.sherlock79 at gmail.com
Tue Apr 8 04:54:50 PDT 2014


 vcl/source/gdi/outdev4.cxx |  126 +++++++++++++++++++++++----------------------
 1 file changed, 66 insertions(+), 60 deletions(-)

New commits:
commit 954d7ad4ea7ec3746b0f0cd3f850a25e82b39c14
Author: Chris Sherlock <chris.sherlock79 at gmail.com>
Date:   Tue Apr 8 21:49:24 2014 +1000

    Starting to bring DrawGradient functions into line with each other
    
    OutputDevice's DrawGradient functions are remarkably similar - I've
    reorganized them and brought them into line with some extra checks
    that seem to be missing. This will allow for easier refactoring.
    
    Change-Id: I6f83bb9fe73d34e3668d87b4a4ee91c49d8cea0f

diff --git a/vcl/source/gdi/outdev4.cxx b/vcl/source/gdi/outdev4.cxx
index 7e3ff3f..16a211f 100644
--- a/vcl/source/gdi/outdev4.cxx
+++ b/vcl/source/gdi/outdev4.cxx
@@ -606,87 +606,93 @@ void OutputDevice::SetGrayscaleColors( Gradient &rGradient )
 void OutputDevice::DrawGradient( const Rectangle& rRect,
                                  const Gradient& rGradient )
 {
-
     if ( mnDrawMode & DRAWMODE_NOGRADIENT )
-    {
         return;     // nothing to draw!
-    }
-    else if ( mnDrawMode & ( DRAWMODE_BLACKGRADIENT | DRAWMODE_WHITEGRADIENT | DRAWMODE_SETTINGSGRADIENT) )
-    {
 
-        Color aColor = GetSingleColorGradientFill();
+    if ( mbInitClipRegion )
+        ImplInitClipRegion();
 
-        Push( PUSH_LINECOLOR | PUSH_FILLCOLOR );
-        SetLineColor( aColor );
-        SetFillColor( aColor );
-        DrawRect( rRect );
-        Pop();
+    if ( mbOutputClipped )
         return;
-    }
 
-    Gradient aGradient( rGradient );
-
-    if ( mnDrawMode & ( DRAWMODE_GRAYGRADIENT | DRAWMODE_GHOSTEDGRADIENT ) )
+    if ( !rRect.IsEmpty() )
     {
-        SetGrayscaleColors( aGradient );
-    }
-
-    if( mpMetaFile )
-        mpMetaFile->AddAction( new MetaGradientAction( rRect, aGradient ) );
+        if ( mnDrawMode & ( DRAWMODE_BLACKGRADIENT | DRAWMODE_WHITEGRADIENT | DRAWMODE_SETTINGSGRADIENT) )
+        {
+            Color aColor = GetSingleColorGradientFill();
 
-    if( !IsDeviceOutputNecessary() || ImplIsRecordLayout() )
-        return;
+            Push( PUSH_LINECOLOR | PUSH_FILLCOLOR );
+            SetLineColor( aColor );
+            SetFillColor( aColor );
+            DrawRect( rRect );
+            Pop();
+            return;
+        }
 
-    // convert rectangle to pixels
-    Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
-    aRect.Justify();
+        Gradient aGradient( rGradient );
 
-    // do nothing if the rectangle is empty
-    if ( !aRect.IsEmpty() )
-    {
-        // Clip Region sichern
-        Push( PUSH_CLIPREGION );
-        IntersectClipRegion( rRect );
+        if( mpMetaFile )
+            mpMetaFile->AddAction( new MetaGradientAction( rRect, aGradient ) );
 
-        // because we draw with no border line, we have to expand gradient
-        // rect to avoid missing lines on the right and bottom edge
-        aRect.Left()--;
-        aRect.Top()--;
-        aRect.Right()++;
-        aRect.Bottom()++;
+        if( !IsDeviceOutputNecessary() || ImplIsRecordLayout() )
+            return;
 
-        // we need a graphics
-        if ( !mpGraphics )
+        if ( mnDrawMode & ( DRAWMODE_GRAYGRADIENT | DRAWMODE_GHOSTEDGRADIENT ) )
         {
-            if ( !ImplGetGraphics() )
-                return;
+            SetGrayscaleColors( aGradient );
         }
 
-        if ( mbInitClipRegion )
-            ImplInitClipRegion();
-
-        if ( !mbOutputClipped )
+        if ( !Rectangle( PixelToLogic( Point() ), GetOutputSize() ).IsEmpty() )
         {
-            // gradients are drawn without border
-            if ( mbLineColor || mbInitLineColor )
+            // convert rectangle to pixels
+            Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
+            aRect.Justify();
+
+            // do nothing if the rectangle is empty
+            if ( !aRect.IsEmpty() )
             {
-                mpGraphics->SetLineColor();
-                mbInitLineColor = true;
-            }
+                // we need a graphics
+                if ( !mpGraphics && !ImplGetGraphics() )
+                    return;
 
-            mbInitFillColor = true;
+                // secure clip region
+                Push( PUSH_CLIPREGION );
+                IntersectClipRegion( rRect );
 
-            // calculate step count if necessary
-            if ( !aGradient.GetSteps() )
-                aGradient.SetSteps( GRADIENT_DEFAULT_STEPCOUNT );
+                // because we draw with no border line, we have to expand gradient
+                // rect to avoid missing lines on the right and bottom edge
+                aRect.Left()--;
+                aRect.Top()--;
+                aRect.Right()++;
+                aRect.Bottom()++;
 
-            if( aGradient.GetStyle() == GradientStyle_LINEAR || aGradient.GetStyle() == GradientStyle_AXIAL )
-                ImplDrawLinearGradient( aRect, rGradient, false, NULL );
-            else
-                ImplDrawComplexGradient( aRect, rGradient, false, NULL );
-        }
+                if ( mbInitClipRegion )
+                    ImplInitClipRegion();
 
-        Pop();
+                if ( !mbOutputClipped )
+                {
+                    // gradients are drawn 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( aGradient.GetStyle() == GradientStyle_LINEAR || aGradient.GetStyle() == GradientStyle_AXIAL )
+                        ImplDrawLinearGradient( aRect, rGradient, false, NULL );
+                    else
+                        ImplDrawComplexGradient( aRect, rGradient, false, NULL );
+                }
+
+                Pop();
+            }
+        }
     }
 
     if( mpAlphaVDev )


More information about the Libreoffice-commits mailing list