[Libreoffice-commits] core.git: vcl/inc vcl/win

Mike Kaganski mike.kaganski at collabora.com
Thu Oct 20 21:31:03 UTC 2016


 vcl/inc/win/salvd.h         |   20 +++++++-------
 vcl/win/gdi/salvd.cxx       |   59 +++++++++++++++++++-------------------------
 vcl/win/window/salframe.cxx |    8 ++---
 3 files changed, 40 insertions(+), 47 deletions(-)

New commits:
commit acfe9c225a8905f9742a9d9494ee242a45a15d50
Author: Mike Kaganski <mike.kaganski at collabora.com>
Date:   Thu Oct 20 15:11:01 2016 +1000

    Incapsulate WinSalVirtualDevice better
    
    Change-Id: I8de745e2318c69ccec2ffabb69df598a4bf60480
    Reviewed-on: https://gerrit.libreoffice.org/30071
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/vcl/inc/win/salvd.h b/vcl/inc/win/salvd.h
index d6ef119..a695bc7 100644
--- a/vcl/inc/win/salvd.h
+++ b/vcl/inc/win/salvd.h
@@ -29,12 +29,6 @@ class WinSalVirtualDevice : public SalVirtualDevice
 {
 private:
     HDC                     mhLocalDC;              // HDC or 0 for Cache Device
-
-public:
-    HDC getHDC() { return mhLocalDC; }
-    void setHDC(HDC aNew) { mhLocalDC = aNew; }
-
-public:
     HBITMAP                 mhBmp;                  // Memory Bitmap
     HBITMAP                 mhDefBmp;               // Default Bitmap
     WinSalGraphics*         mpGraphics;             // current VirDev graphics
@@ -44,13 +38,19 @@ public:
     bool                    mbForeignDC;            // uses a foreign DC instead of a bitmap
     long                    mnWidth;
     long                    mnHeight;
+public:
+    HDC getHDC() const { return mhLocalDC; }
+    WinSalGraphics* getGraphics() const { return mpGraphics; }
+    void setGraphics(WinSalGraphics* pVirGraphics) { mpGraphics = pVirGraphics; }
+    WinSalVirtualDevice* getNext() const { return mpNext; }
 
-    WinSalVirtualDevice();
+public:
+    WinSalVirtualDevice(HDC hDC = nullptr, HBITMAP hBMP = nullptr, sal_uInt16 nBitCount = 0, bool bForeignDC = false, long nWidth = 0, long nHeight = 0);
     virtual ~WinSalVirtualDevice() override;
 
-    virtual SalGraphics*            AcquireGraphics() override;
-    virtual void                    ReleaseGraphics( SalGraphics* pGraphics ) override;
-    virtual bool                    SetSize( long nNewDX, long nNewDY ) override;
+    virtual SalGraphics*    AcquireGraphics() override;
+    virtual void            ReleaseGraphics( SalGraphics* pGraphics ) override;
+    virtual bool            SetSize( long nNewDX, long nNewDY ) override;
 
     static HBITMAP ImplCreateVirDevBitmap(HDC hDC, long nDX, long nDY, sal_uInt16 nBitCount, void **ppDummy);
 
diff --git a/vcl/win/gdi/salvd.cxx b/vcl/win/gdi/salvd.cxx
index 5735ccd..65d8600 100644
--- a/vcl/win/gdi/salvd.cxx
+++ b/vcl/win/gdi/salvd.cxx
@@ -125,7 +125,7 @@ SalVirtualDevice* WinSalInstance::CreateVirtualDevice( SalGraphics* pSGraphics,
 
     if ( bOk )
     {
-        WinSalVirtualDevice*    pVDev = new WinSalVirtualDevice;
+        WinSalVirtualDevice*    pVDev = new WinSalVirtualDevice(hDC, hBmp, nBitCount, (pData != nullptr && pData->hDC != nullptr ), nDX, nDY);
         SalData*                pSalData = GetSalData();
         WinSalGraphics*         pVirGraphics = new WinSalGraphics(WinSalGraphics::VIRTUAL_DEVICE, pGraphics->isScreen(), nullptr, pVDev);
         pVirGraphics->SetLayout( SalLayoutFlags::NONE );   // by default no! mirroring for VirtualDevices, can be enabled with EnableRTL()
@@ -137,22 +137,7 @@ SalVirtualDevice* WinSalInstance::CreateVirtualDevice( SalGraphics* pSGraphics,
         }
         pVirGraphics->InitGraphics();
 
-        pVDev->mnWidth = nDX;
-        pVDev->mnHeight = nDY;
-        pVDev->setHDC(hDC);
-        pVDev->mhBmp        = hBmp;
-        if( hBmp )
-            pVDev->mhDefBmp = SelectBitmap( hDC, hBmp );
-        else
-            pVDev->mhDefBmp = nullptr;
-        pVDev->mpGraphics   = pVirGraphics;
-        pVDev->mnBitCount   = nBitCount;
-        pVDev->mbGraphics   = FALSE;
-        pVDev->mbForeignDC  = (pData != nullptr && pData->hDC != nullptr );
-
-        // insert VirDev in VirDevList
-        pVDev->mpNext = pSalData->mpFirstVD;
-        pSalData->mpFirstVD = pVDev;
+        pVDev->setGraphics(pVirGraphics);
 
         return pVDev;
     }
@@ -166,18 +151,26 @@ SalVirtualDevice* WinSalInstance::CreateVirtualDevice( SalGraphics* pSGraphics,
     }
 }
 
-WinSalVirtualDevice::WinSalVirtualDevice()
+WinSalVirtualDevice::WinSalVirtualDevice(HDC hDC, HBITMAP hBMP, sal_uInt16 nBitCount, bool bForeignDC, long nWidth, long nHeight)
+    : mhLocalDC(hDC),          // HDC or 0 for Cache Device
+      mhBmp(hBMP),             // Memory Bitmap
+      mpGraphics(nullptr),     // current VirDev graphics
+      mnBitCount(nBitCount),   // BitCount (0 or 1)
+      mbGraphics(false),       // is Graphics used
+      mbForeignDC(bForeignDC), // uses a foreign DC instead of a bitmap
+      mnWidth(nWidth),
+      mnHeight(nHeight)
 {
-    setHDC(nullptr);            // HDC or 0 for Cache Device
-    mhBmp = nullptr;            // Memory Bitmap
-    mhDefBmp = nullptr;         // Default Bitmap
-    mpGraphics = nullptr;       // current VirDev graphics
-    mpNext = nullptr;           // next VirDev
-    mnBitCount = 0;             // BitCount (0 or 1)
-    mbGraphics = FALSE;         // is Graphics used
-    mbForeignDC = FALSE;        // uses a foreign DC instead of a bitmap
-    mnWidth = 0;
-    mnHeight = 0;
+    // Default Bitmap
+    if (hBMP)
+        mhDefBmp = SelectBitmap(hDC, hBMP);
+    else
+        mhDefBmp = nullptr;
+
+    // insert VirDev into list of virtual devices
+    SalData* pSalData = GetSalData();
+    mpNext = pSalData->mpFirstVD;
+    pSalData->mpFirstVD = this;
 }
 
 WinSalVirtualDevice::~WinSalVirtualDevice()
@@ -209,20 +202,20 @@ SalGraphics* WinSalVirtualDevice::AcquireGraphics()
         return nullptr;
 
     if ( mpGraphics )
-        mbGraphics = TRUE;
+        mbGraphics = true;
 
     return mpGraphics;
 }
 
 void WinSalVirtualDevice::ReleaseGraphics( SalGraphics* )
 {
-    mbGraphics = FALSE;
+    mbGraphics = false;
 }
 
 bool WinSalVirtualDevice::SetSize( long nDX, long nDY )
 {
     if( mbForeignDC || !mhBmp )
-        return TRUE;    // ???
+        return true;    // ???
     else
     {
         void *pDummy;
@@ -243,13 +236,13 @@ bool WinSalVirtualDevice::SetSize( long nDX, long nDY )
                 if (pImpl)
                     pImpl->Init();
             }
-            return TRUE;
+            return true;
         }
         else
         {
             mnWidth = 0;
             mnHeight = 0;
-            return FALSE;
+            return false;
         }
     }
 }
diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx
index c3d31b0..8257ec0 100644
--- a/vcl/win/window/salframe.cxx
+++ b/vcl/win/window/salframe.cxx
@@ -4193,14 +4193,14 @@ static LRESULT ImplHandlePalette( bool bFrame, HWND hWnd, UINT nMsg,
     pTempVD = pSalData->mpFirstVD;
     while ( pTempVD )
     {
-        pGraphics = pTempVD->mpGraphics;
+        pGraphics = pTempVD->getGraphics();
         if ( pGraphics->getDefPal() )
         {
             SelectPalette( pGraphics->getHDC(),
                            pGraphics->getDefPal(),
                            TRUE );
         }
-        pTempVD = pTempVD->mpNext;
+        pTempVD = pTempVD->getNext();
     }
     pTempFrame = pSalData->mpFirstFrame;
     while ( pTempFrame )
@@ -4243,13 +4243,13 @@ static LRESULT ImplHandlePalette( bool bFrame, HWND hWnd, UINT nMsg,
     pTempVD = pSalData->mpFirstVD;
     while ( pTempVD )
     {
-        pGraphics = pTempVD->mpGraphics;
+        pGraphics = pTempVD->getGraphics();
         if ( pGraphics->getDefPal() )
         {
             SelectPalette( pGraphics->getHDC(), hPal, TRUE );
             RealizePalette( pGraphics->getHDC() );
         }
-        pTempVD = pTempVD->mpNext;
+        pTempVD = pTempVD->getNext();
     }
     pTempFrame = pSalData->mpFirstFrame;
     while ( pTempFrame )


More information about the Libreoffice-commits mailing list