[Libreoffice-commits] core.git: Branch 'libreoffice-4-2' - include/vcl vcl/source

Jan Holesovsky kendy at collabora.com
Wed Mar 12 11:02:36 PDT 2014


 include/vcl/outdev.hxx       |    1 +
 vcl/source/gdi/outdev.cxx    |    1 +
 vcl/source/gdi/virdev.cxx    |    2 ++
 vcl/source/window/window.cxx |    8 ++++++++
 4 files changed, 12 insertions(+)

New commits:
commit 52cb1085edc66995393d5be5a55cb45b73a95292
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Thu Mar 6 18:39:51 2014 +0100

    Introduce DPI scale factor for Hi-DPI displays.
    
    This is supposed to stay 1 (no scale) for printers and default virtual
    devices, but should be set accordingly (2 or 3) for windows and virtual
    devices derived from windows.
    
    Various VCL widgets or paint operations should incrementally become aware of
    this, and changed so that they draw nicely on the Hi-DPI displays.  This patch
    only introduces the behavior for waved lines.
    
    The default is currently being set depending on the DPI setting only; could be
    changed to a more clever way if necessary.
    
    Change-Id: I71118f9ab6b64028d1eeee76e860e999d5cd9d19
    Reviewed-on: https://gerrit.libreoffice.org/8516
    Reviewed-by: Norbert Thiebaud <nthiebaud at gmail.com>
    Tested-by: Norbert Thiebaud <nthiebaud at gmail.com>

diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index 047a79d..1bd07a2 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -310,6 +310,7 @@ private:
     long                mnOutHeight;
     sal_Int32           mnDPIX;
     sal_Int32           mnDPIY;
+    sal_Int32           mnDPIScaleFactor; ///< For Hi-DPI displays, we want to draw everything mnDPIScaleFactor-times larger
     /// font specific text alignment offsets in pixel units
     mutable long        mnTextOffX;
     mutable long        mnTextOffY;
diff --git a/vcl/source/gdi/outdev.cxx b/vcl/source/gdi/outdev.cxx
index b777dbe..f8ec872 100644
--- a/vcl/source/gdi/outdev.cxx
+++ b/vcl/source/gdi/outdev.cxx
@@ -349,6 +349,7 @@ OutputDevice::OutputDevice() :
     mnOutHeight         = 0;
     mnDPIX              = 0;
     mnDPIY              = 0;
+    mnDPIScaleFactor    = 1;
     mnTextOffX          = 0;
     mnTextOffY          = 0;
     mnOutOffOrigX       = 0;
diff --git a/vcl/source/gdi/virdev.cxx b/vcl/source/gdi/virdev.cxx
index 4ef94b9..0e9d316 100644
--- a/vcl/source/gdi/virdev.cxx
+++ b/vcl/source/gdi/virdev.cxx
@@ -97,6 +97,7 @@ void VirtualDevice::ImplInitVirDev( const OutputDevice* pOutDev,
     mpFontCache     = pSVData->maGDIData.mpScreenFontCache;
     mnDPIX          = pOutDev->mnDPIX;
     mnDPIY          = pOutDev->mnDPIY;
+    mnDPIScaleFactor = pOutDev->mnDPIScaleFactor;
     maFont          = pOutDev->maFont;
 
     if( maTextColor != pOutDev->maTextColor )
@@ -406,6 +407,7 @@ void VirtualDevice::ImplSetReferenceDevice( RefDevMode i_eRefDevMode, sal_Int32
 {
     mnDPIX = i_nDPIX;
     mnDPIY = i_nDPIY;
+    mnDPIScaleFactor = 1;
 
     EnableOutput( sal_False );  // prevent output on reference device
     mbScreenComp = sal_False;
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 60a14f1..f1cab66 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -982,6 +982,9 @@ void Window::ImplInit( Window* pParent, WinBits nStyle, SystemParentData* pSyste
 
     }
 
+    // setup the scale factor for Hi-DPI displays
+    mnDPIScaleFactor = std::max((sal_Int32)1, (mpWindowImpl->mpFrameData->mnDPIY + 48) / 96);
+
     const StyleSettings& rStyleSettings = maSettings.GetStyleSettings();
     sal_uInt16 nScreenZoom = rStyleSettings.GetScreenZoom();
     mnDPIX          = (mpWindowImpl->mpFrameData->mnDPIX*nScreenZoom)/100;
@@ -1718,12 +1721,17 @@ void Window::ImplInitResolutionSettings()
         sal_uInt16 nScreenZoom = rStyleSettings.GetScreenZoom();
         mnDPIX = (mpWindowImpl->mpFrameData->mnDPIX*nScreenZoom)/100;
         mnDPIY = (mpWindowImpl->mpFrameData->mnDPIY*nScreenZoom)/100;
+
+        // setup the scale factor for Hi-DPI displays
+        mnDPIScaleFactor = std::max(1, (mpWindowImpl->mpFrameData->mnDPIY + 48) / 96);
+
         SetPointFont( rStyleSettings.GetAppFont() );
     }
     else if ( mpWindowImpl->mpParent )
     {
         mnDPIX  = mpWindowImpl->mpParent->mnDPIX;
         mnDPIY  = mpWindowImpl->mpParent->mnDPIY;
+        mnDPIScaleFactor = mpWindowImpl->mpParent->mnDPIScaleFactor;
     }
 
     // update the recalculated values for logical units


More information about the Libreoffice-commits mailing list