include/vcl/virdev.hxx    |   43 ++++++++++++++++++++++++++++++++-----------
 vcl/source/gdi/virdev.cxx |   38 ++++++++++----------------------------
 2 files changed, 42 insertions(+), 39 deletions(-)

New commits:
commit 0378bfcea51ff0f379d0954aa6740f1829909dc3
Author:     Jan-Marek Glogowski <glo...@fbihome.de>
AuthorDate: Tue Oct 23 11:47:09 2018 +0000
Commit:     Jan-Marek Glogowski <glo...@fbihome.de>
CommitDate: Tue Oct 23 23:28:41 2018 +0200

    Constify VirtDevice::me(Alpha)?Format
    
    Change-Id: I619c19837c3bb6124009787ba0fc53991b4c4d0b
    Reviewed-on: https://gerrit.libreoffice.org/62256
    Tested-by: Jenkins
    Reviewed-by: Jan-Marek Glogowski <glo...@fbihome.de>

diff --git a/include/vcl/virdev.hxx b/include/vcl/virdev.hxx
index 06121aca050a..f608b5797844 100644
--- a/include/vcl/virdev.hxx
+++ b/include/vcl/virdev.hxx
@@ -50,12 +50,12 @@ private:
     VclPtr<VirtualDevice>  mpNext;
     sal_uInt16          mnBitCount;
     bool                mbScreenComp;
-    DeviceFormat        meFormat;
-    DeviceFormat        meAlphaFormat;
+    const DeviceFormat  meFormat;
+    const DeviceFormat  meAlphaFormat;
     RefDevMode          meRefDevMode;
     bool                mbForceZeroExtleadBug;
 
-    SAL_DLLPRIVATE void ImplInitVirDev( const OutputDevice* pOutDev, long nDX, 
long nDY, DeviceFormat eFormat, const SystemGraphicsData *pData = nullptr );
+    SAL_DLLPRIVATE void ImplInitVirDev( const OutputDevice* pOutDev, long nDX, 
long nDY, const SystemGraphicsData *pData = nullptr );
     SAL_DLLPRIVATE bool InnerImplSetOutputSizePixel( const Size& rNewSize, 
bool bErase,
                                                      sal_uInt8* pBuffer );
     SAL_DLLPRIVATE bool ImplSetOutputSizePixel( const Size& rNewSize, bool 
bErase,
@@ -74,6 +74,24 @@ protected:
     virtual bool AcquireGraphics() const override;
     virtual void ReleaseGraphics( bool bRelease = true ) override;
 
+    /** Create a virtual device of size 1x1
+
+        @param pCompDev
+        The generated vdev will be compatible to this device.
+        If it's the nullptr, it uses Application::GetDefaultDevice().
+
+        @param eFormat
+        Device format of the generated virtual device. Use 
DeviceFormat::DEFAULT here, to
+        indicate: take default screen depth. Only DeviceFormat::BITMASK
+        is the other possibility to denote a binary mask.
+
+        @param eAlphaFormat
+        Device format of the generated virtual device. Use 
DeviceFormat::DEFAULT here, to
+        indicate: take default screen depth. Only DeviceFormat::BITMASK
+        is the other possibility to denote a binary mask.
+     */
+    explicit VirtualDevice(const OutputDevice* pCompDev, DeviceFormat eFormat, 
DeviceFormat eAlphaFormat);
+
 public:
 
     /** Create a virtual device of size 1x1
@@ -83,7 +101,8 @@ public:
         indicate: take default screen depth. Only DeviceFormat::BITMASK
         is the other possibility to denote a binary mask.
      */
-    explicit            VirtualDevice(DeviceFormat eFormat = 
DeviceFormat::DEFAULT);
+    explicit VirtualDevice(DeviceFormat eFormat = DeviceFormat::DEFAULT)
+        : VirtualDevice(nullptr, eFormat, DeviceFormat::NONE) {}
 
     /** Create a virtual device of size 1x1
 
@@ -95,8 +114,9 @@ public:
         indicate: take default screen depth. Only DeviceFormat::BITMASK
         is the other possibility to denote a binary mask.
      */
-     explicit           VirtualDevice(const OutputDevice& rCompDev,
-                                      DeviceFormat eFormat = 
DeviceFormat::DEFAULT);
+    explicit VirtualDevice(const OutputDevice& rCompDev,
+                           DeviceFormat eFormat = DeviceFormat::DEFAULT)
+        : VirtualDevice(&rCompDev, eFormat, DeviceFormat::NONE) {}
 
     /** Create a virtual device  of size 1x1 with alpha channel
 
@@ -113,15 +133,16 @@ public:
         indicate: take default screen depth. Only DeviceFormat::BITMASK
         is the other possibility to denote a binary mask.
      */
-     explicit           VirtualDevice( const OutputDevice& rCompDev,
-                                       DeviceFormat eFormat, DeviceFormat 
eAlphaFormat);
+    explicit VirtualDevice(const OutputDevice& rCompDev,
+                           DeviceFormat eFormat, DeviceFormat eAlphaFormat)
+        : VirtualDevice(&rCompDev, eFormat, eAlphaFormat) {}
 
     /** Create a virtual device using an existing system dependent device or 
graphics context
         Any rendering will happen directly on the context and not on any 
intermediate bitmap.
         Note: This might not be supported on all platforms !
-    */
-    explicit            VirtualDevice(const SystemGraphicsData *pData, const 
Size &rSize,
-                                      DeviceFormat eFormat);
+     */
+    explicit VirtualDevice(const SystemGraphicsData *pData, const Size &rSize,
+                           DeviceFormat eFormat);
 
     virtual             ~VirtualDevice() override;
     virtual void        dispose() override;
diff --git a/vcl/source/gdi/virdev.cxx b/vcl/source/gdi/virdev.cxx
index 425b2d153a4e..284706c1a730 100644
--- a/vcl/source/gdi/virdev.cxx
+++ b/vcl/source/gdi/virdev.cxx
@@ -108,9 +108,9 @@ void VirtualDevice::ReleaseGraphics( bool bRelease )
 }
 
 void VirtualDevice::ImplInitVirDev( const OutputDevice* pOutDev,
-                                    long nDX, long nDY, DeviceFormat eFormat, 
const SystemGraphicsData *pData )
+                                    long nDX, long nDY, const 
SystemGraphicsData *pData )
 {
-    SAL_INFO( "vcl.virdev", "ImplInitVirDev(" << nDX << "," << nDY << "," << 
static_cast<int>(eFormat) << ")" );
+    SAL_INFO( "vcl.virdev", "ImplInitVirDev(" << nDX << "," << nDY << ")" );
 
     meRefDevMode = RefDevMode::NONE;
     mbForceZeroExtleadBug = false;
@@ -135,7 +135,7 @@ void VirtualDevice::ImplInitVirDev( const OutputDevice* 
pOutDev,
         (void)pOutDev->AcquireGraphics();
     pGraphics = pOutDev->mpGraphics;
     if ( pGraphics )
-        mpVirDev = pSVData->mpDefInst->CreateVirtualDevice(pGraphics, nDX, 
nDY, eFormat, pData);
+        mpVirDev = pSVData->mpDefInst->CreateVirtualDevice(pGraphics, nDX, 
nDY, meFormat, pData);
     else
         mpVirDev = nullptr;
     if ( !mpVirDev )
@@ -146,7 +146,6 @@ void VirtualDevice::ImplInitVirDev( const OutputDevice* 
pOutDev,
             css::uno::Reference< css::uno::XInterface >() );
     }
 
-    meFormat        = eFormat;
     switch (meFormat)
     {
         case DeviceFormat::BITMASK:
@@ -159,7 +158,6 @@ void VirtualDevice::ImplInitVirDev( const OutputDevice* 
pOutDev,
     mnOutWidth      = nDX;
     mnOutHeight     = nDY;
     mbScreenComp    = true;
-    meAlphaFormat   = DeviceFormat::NONE;
 
     if (meFormat == DeviceFormat::BITMASK)
         SetAntialiasing( AntialiasingFlags::DisableText );
@@ -200,42 +198,26 @@ void VirtualDevice::ImplInitVirDev( const OutputDevice* 
pOutDev,
     pSVData->maGDIData.mpFirstVirDev = this;
 }
 
-VirtualDevice::VirtualDevice(DeviceFormat eFormat)
-    : OutputDevice(OUTDEV_VIRDEV)
-{
-    SAL_INFO( "vcl.virdev", "VirtualDevice::VirtualDevice( " << 
static_cast<int>(eFormat) << " )" );
-
-    ImplInitVirDev(Application::GetDefaultDevice(), 0, 0, eFormat);
-}
-
-VirtualDevice::VirtualDevice(const OutputDevice& rCompDev, DeviceFormat 
eFormat)
-    : OutputDevice(OUTDEV_VIRDEV)
-{
-    SAL_INFO( "vcl.virdev", "VirtualDevice::VirtualDevice( " << 
static_cast<int>(eFormat) << " )" );
-
-    ImplInitVirDev(&rCompDev, 0, 0, eFormat);
-}
-
-VirtualDevice::VirtualDevice(const OutputDevice& rCompDev, DeviceFormat 
eFormat, DeviceFormat eAlphaFormat)
+VirtualDevice::VirtualDevice(const OutputDevice* pCompDev, DeviceFormat 
eFormat, DeviceFormat eAlphaFormat)
     : OutputDevice(OUTDEV_VIRDEV)
+    , meFormat(eFormat)
+    , meAlphaFormat(eAlphaFormat)
 {
     SAL_INFO( "vcl.virdev",
             "VirtualDevice::VirtualDevice( " << static_cast<int>(eFormat) << 
", " << static_cast<int>(eAlphaFormat) << " )" );
 
-    ImplInitVirDev(&rCompDev, 0, 0, eFormat);
-
-    // Enable alpha channel
-    meAlphaFormat = eAlphaFormat;
+    ImplInitVirDev(pCompDev ? pCompDev : Application::GetDefaultDevice(), 0, 
0);
 }
 
 VirtualDevice::VirtualDevice(const SystemGraphicsData *pData, const Size 
&rSize,
                              DeviceFormat eFormat)
     : OutputDevice(OUTDEV_VIRDEV)
+    , meFormat(eFormat)
+    , meAlphaFormat(DeviceFormat::NONE)
 {
     SAL_INFO( "vcl.virdev", "VirtualDevice::VirtualDevice( " << 
static_cast<int>(eFormat) << " )" );
 
-    ImplInitVirDev(Application::GetDefaultDevice(), rSize.Width(), 
rSize.Height(),
-                   eFormat, pData);
+    ImplInitVirDev(Application::GetDefaultDevice(), rSize.Width(), 
rSize.Height(), pData);
 }
 
 VirtualDevice::~VirtualDevice()
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to