include/vcl/outdev.hxx       |    4 ++
 include/vcl/window.hxx       |    2 +
 vcl/source/outdev/outdev.cxx |   68 +++++++++++++++++--------------------------
 vcl/source/window/window.cxx |   42 ++++++++++++++++++++++++++
 4 files changed, 76 insertions(+), 40 deletions(-)

New commits:
commit a68157c88add7a815678155f4d7a743b010d92f5
Author:     Yusuf Keten <ketenyu...@gmail.com>
AuthorDate: Sat Jan 4 20:39:42 2020 +0300
Commit:     Muhammet Kara <muhammet.k...@collabora.com>
CommitDate: Tue Feb 4 18:05:28 2020 +0100

    tdf#74702: Remove enum OutDevType from OutputDevice::drawOutDevDirect
    
    Extracted DrawOutDevDirectCheck and DrawOutDevDirectProcess. 
DrawoutDevDirectCheck checks OutputDeviceType and define pSrcGraphics according 
to its type. DrawOutDevDirectProcess perform some operations about drawing out 
according to its type and checks some pointers for avoiding NULL pointer.
    
    Change-Id: I24247ee42d2dd686dbd13bb5f6b24bbe8fab43ab
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86229
    Reviewed-by: Muhammet Kara <muhammet.k...@collabora.com>
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>
    Tested-by: Jenkins

diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index 022edb9e2a54..c991867495ea 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -559,6 +559,10 @@ protected:
 
     virtual void                CopyDeviceArea( SalTwoRect& aPosAry, bool 
bWindowInvalidate);
 
+    virtual void                DrawOutDevDirectCheck( const OutputDevice* 
pSrcDev, SalGraphics*& pSrcGraphics );
+
+    virtual void                DrawOutDevDirectProcess( const OutputDevice* 
pSrcDev, SalTwoRect& rPosAry, SalGraphics* pSrcGraphics );
+
     SAL_DLLPRIVATE void         drawOutDevDirect ( const OutputDevice* 
pSrcDev, SalTwoRect& rPosAry );
 
     SAL_DLLPRIVATE bool         is_double_buffered_window() const;
diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index a78259c5f222..6d98bec0576b 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -752,6 +752,8 @@ protected:
     virtual void                        ImplAdjustNWFSizes();
 
     virtual void                        CopyDeviceArea( SalTwoRect& aPosAry, 
bool bWindowInvalidate) override;
+    virtual void                        DrawOutDevDirectCheck(const 
OutputDevice* pSrcDev, SalGraphics*& pSrcGraphics) override;
+    virtual void                        DrawOutDevDirectProcess( const 
OutputDevice* pSrcDev, SalTwoRect& rPosAry, SalGraphics* pSrcGraphics ) 
override;
     virtual void                        ClipToPaintRegion( tools::Rectangle& 
rDstRect ) override;
     virtual bool                        UsePolyPolygonForComplexGradient() 
override;
 
diff --git a/vcl/source/outdev/outdev.cxx b/vcl/source/outdev/outdev.cxx
index 6776cb3d7c85..880181cb5407 100644
--- a/vcl/source/outdev/outdev.cxx
+++ b/vcl/source/outdev/outdev.cxx
@@ -532,41 +532,9 @@ void OutputDevice::CopyDeviceArea( SalTwoRect& aPosAry, 
bool /*bWindowInvalidate
 void OutputDevice::drawOutDevDirect( const OutputDevice* pSrcDev, SalTwoRect& 
rPosAry )
 {
     SalGraphics* pSrcGraphics;
+    SalGraphics*& pSrcGraphicsRef = pSrcGraphics;
 
-    if ( this == pSrcDev )
-        pSrcGraphics = nullptr;
-    else
-    {
-        if ( (GetOutDevType() != pSrcDev->GetOutDevType()) ||
-             (GetOutDevType() != OUTDEV_WINDOW) )
-        {
-            if ( !pSrcDev->mpGraphics )
-            {
-                if ( !pSrcDev->AcquireGraphics() )
-                    return;
-            }
-            pSrcGraphics = pSrcDev->mpGraphics;
-        }
-        else
-        {
-            if ( static_cast<vcl::Window*>(this)->mpWindowImpl->mpFrameWindow 
== static_cast<const vcl::Window*>(pSrcDev)->mpWindowImpl->mpFrameWindow )
-                pSrcGraphics = nullptr;
-            else
-            {
-                if ( !pSrcDev->mpGraphics )
-                {
-                    if ( !pSrcDev->AcquireGraphics() )
-                        return;
-                }
-                pSrcGraphics = pSrcDev->mpGraphics;
-
-                if ( !mpGraphics && !AcquireGraphics() )
-                    return;
-                SAL_WARN_IF( !mpGraphics || !pSrcDev->mpGraphics, "vcl.gdi",
-                            "OutputDevice::DrawOutDev(): We need more than one 
Graphics" );
-            }
-        }
-    }
+    DrawOutDevDirectCheck(pSrcDev, pSrcGraphicsRef);
 
     // #102532# Offset only has to be pseudo window offset
     const tools::Rectangle aSrcOutRect( Point( pSrcDev->mnOutOffX, 
pSrcDev->mnOutOffY ),
@@ -580,17 +548,37 @@ void OutputDevice::drawOutDevDirect( const OutputDevice* 
pSrcDev, SalTwoRect& rP
         // mirroring may be required
         // because only windows have a SalGraphicsLayout
         // mirroring is performed here
-        if( (GetOutDevType() != OUTDEV_WINDOW) && pSrcGraphics && 
(pSrcGraphics->GetLayout() & SalLayoutFlags::BiDiRtl) )
+        DrawOutDevDirectProcess( pSrcDev, rPosAry, pSrcGraphics);
+    }
+}
+
+void OutputDevice::DrawOutDevDirectCheck( const OutputDevice* pSrcDev, 
SalGraphics*& pSrcGraphics )
+{
+    if ( this == pSrcDev )
+        pSrcGraphics = nullptr;
+    else
+    {
+        if ( !pSrcDev->mpGraphics )
         {
-            SalTwoRect aPosAry2 = rPosAry;
-            pSrcGraphics->mirror( aPosAry2.mnSrcX, aPosAry2.mnSrcWidth, 
pSrcDev );
-            mpGraphics->CopyBits( aPosAry2, pSrcGraphics, this, pSrcDev );
+            if ( !pSrcDev->AcquireGraphics() )
+                return;
         }
-        else
-            mpGraphics->CopyBits( rPosAry, pSrcGraphics, this, pSrcDev );
+        pSrcGraphics = pSrcDev->mpGraphics;
     }
 }
 
+void OutputDevice::DrawOutDevDirectProcess( const OutputDevice* pSrcDev, 
SalTwoRect& rPosAry, SalGraphics* pSrcGraphics )
+{
+    if( pSrcGraphics && (pSrcGraphics->GetLayout() & SalLayoutFlags::BiDiRtl) )
+    {
+        SalTwoRect aPosAry2 = rPosAry;
+        pSrcGraphics->mirror( aPosAry2.mnSrcX, aPosAry2.mnSrcWidth, pSrcDev );
+        mpGraphics->CopyBits( aPosAry2, pSrcGraphics, this, pSrcDev );
+    }
+    else
+        mpGraphics->CopyBits( rPosAry, pSrcGraphics, this, pSrcDev );
+}
+
 // Layout public functions
 
 void OutputDevice::EnableRTL( bool bEnable )
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 027f491c5bcd..ac4f90123da4 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -1244,6 +1244,48 @@ void Window::CopyDeviceArea( SalTwoRect& aPosAry, bool 
bWindowInvalidate )
     OutputDevice::CopyDeviceArea(aPosAry, bWindowInvalidate);
 }
 
+void Window::DrawOutDevDirectCheck(const OutputDevice* pSrcDev, SalGraphics*& 
pSrcGraphics)
+{
+    if ( this == pSrcDev )
+        pSrcGraphics = nullptr;
+    else
+    {
+        if ( GetOutDevType() != pSrcDev->GetOutDevType() )
+        {
+            if ( !pSrcDev->mpGraphics )
+            {
+                if ( !pSrcDev->AcquireGraphics() )
+                    return;
+            }
+            pSrcGraphics = pSrcDev->mpGraphics;
+        }
+        else
+        {
+            if ( this->mpWindowImpl->mpFrameWindow == static_cast<const 
vcl::Window*>(pSrcDev)->mpWindowImpl->mpFrameWindow )
+                pSrcGraphics = nullptr;
+            else
+            {
+                if ( !pSrcDev->mpGraphics )
+                {
+                    if ( !pSrcDev->AcquireGraphics() )
+                        return;
+                }
+                pSrcGraphics = pSrcDev->mpGraphics;
+
+                if ( !mpGraphics && !AcquireGraphics() )
+                    return;
+                SAL_WARN_IF( !mpGraphics || !pSrcDev->mpGraphics, "vcl.gdi",
+                            "OutputDevice::DrawOutDev(): We need more than one 
Graphics" );
+            }
+        }
+    }
+}
+
+void Window::DrawOutDevDirectProcess( const OutputDevice* pSrcDev, SalTwoRect& 
rPosAry, SalGraphics* pSrcGraphics )
+{
+    mpGraphics->CopyBits( rPosAry, pSrcGraphics, this, pSrcDev );
+}
+
 SalGraphics* Window::ImplGetFrameGraphics() const
 {
     if ( mpWindowImpl->mpFrameWindow->mpGraphics )
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to