summaryrefslogtreecommitdiff
path: root/vcl/source
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2016-10-28 23:24:30 +0200
committerTomaž Vajngerl <quikee@gmail.com>2016-10-29 21:47:41 +0000
commit69b6ab1f8de08b3418fd42d56076a73d40a29229 (patch)
treeb9d3ced7be6ab7c70388a91cd8b56b68d3651d07 /vcl/source
parenta86144696df87cd81795e071a30b74af127c7948 (diff)
tdf#100164 change scaling unit to precentage for *.5x factors
Currently we support DPI scaling by a integer factor. This commit changes that to percentage so we can have scaling factors like 1.5x or 1.25x. This is useful with 2.7k monitors that are in between standard DPI and HiDPI. Thresholding was adjusted to scale to 1.5x when DPI is between 120 and 168 DPI. The old method GetDPIScaleFactor has been changed to return a float value insted of int. Sometimes it is however more accurate to use GetDPIScalePercentage which was added in this commit. Change-Id: Iaecee793ff3d5084d00adeebbcf5d7368c580882 Reviewed-on: https://gerrit.libreoffice.org/30379 Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl/source')
-rw-r--r--vcl/source/gdi/virdev.cxx4
-rw-r--r--vcl/source/image/ImplImageTree.cxx16
-rw-r--r--vcl/source/outdev/outdev.cxx2
-rw-r--r--vcl/source/outdev/textline.cxx16
-rw-r--r--vcl/source/window/window.cxx16
5 files changed, 30 insertions, 24 deletions
diff --git a/vcl/source/gdi/virdev.cxx b/vcl/source/gdi/virdev.cxx
index 4d5c197d99fa..2e80762581bd 100644
--- a/vcl/source/gdi/virdev.cxx
+++ b/vcl/source/gdi/virdev.cxx
@@ -181,7 +181,7 @@ void VirtualDevice::ImplInitVirDev( const OutputDevice* pOutDev,
mpFontCache = pSVData->maGDIData.mpScreenFontCache;
mnDPIX = pOutDev->mnDPIX;
mnDPIY = pOutDev->mnDPIY;
- mnDPIScaleFactor = pOutDev->mnDPIScaleFactor;
+ mnDPIScalePercentage = pOutDev->mnDPIScalePercentage;
maFont = pOutDev->maFont;
if( maTextColor != pOutDev->maTextColor )
@@ -486,7 +486,7 @@ void VirtualDevice::ImplSetReferenceDevice( RefDevMode i_eRefDevMode, sal_Int32
{
mnDPIX = i_nDPIX;
mnDPIY = i_nDPIY;
- mnDPIScaleFactor = 1;
+ mnDPIScalePercentage = 100;
EnableOutput( false ); // prevent output on reference device
mbScreenComp = false;
diff --git a/vcl/source/image/ImplImageTree.cxx b/vcl/source/image/ImplImageTree.cxx
index a112ddb2bcb7..c101e5b7ed11 100644
--- a/vcl/source/image/ImplImageTree.cxx
+++ b/vcl/source/image/ImplImageTree.cxx
@@ -124,9 +124,9 @@ void loadImageFromStream(std::shared_ptr<SvStream> const & xStream, OUString con
if (eFlags & ImageLoadFlags::IgnoreDarkTheme)
bConvertToDarkTheme = false;
- sal_Int32 aScaleFactor = Application::GetDefaultDevice()->GetDPIScaleFactor();
+ float aScaleFactor = Application::GetDefaultDevice()->GetDPIScaleFactor();
if (eFlags & ImageLoadFlags::IgnoreScalingFactor)
- aScaleFactor = 1;
+ aScaleFactor = 1.0f;
if (rPath.endsWith(".png"))
{
@@ -149,7 +149,7 @@ void loadImageFromStream(std::shared_ptr<SvStream> const & xStream, OUString con
if (bConvertToDarkTheme)
rBitmap = BitmapProcessor::createLightImage(rBitmap);
- if (aScaleFactor > 1)
+ if (aScaleFactor > 1.0f)
rBitmap.Scale(double(aScaleFactor), double(aScaleFactor), BmpScaleFlag::Fast);
}
@@ -284,13 +284,15 @@ OUString createVariant(const ImageLoadFlags eFlags)
if (eFlags & ImageLoadFlags::IgnoreDarkTheme)
bConvertToDarkTheme = false;
- sal_Int32 aScaleFactor = Application::GetDefaultDevice()->GetDPIScaleFactor();
+ sal_Int32 aScalePercentage = Application::GetDefaultDevice()->GetDPIScalePercentage();
if (eFlags & ImageLoadFlags::IgnoreScalingFactor)
- aScaleFactor = 1;
+ aScalePercentage = 100;
OUString aVariant;
- if (aScaleFactor == 2)
- aVariant = "2x";
+ if (aScalePercentage == 100 && !bConvertToDarkTheme)
+ return aVariant;
+
+ aVariant = OUString::number(aScalePercentage);
if (bConvertToDarkTheme)
aVariant += "-dark";
diff --git a/vcl/source/outdev/outdev.cxx b/vcl/source/outdev/outdev.cxx
index 8555f5cd12d4..5cb45be03b09 100644
--- a/vcl/source/outdev/outdev.cxx
+++ b/vcl/source/outdev/outdev.cxx
@@ -68,7 +68,7 @@ OutputDevice::OutputDevice() :
mnOutHeight = 0;
mnDPIX = 0;
mnDPIY = 0;
- mnDPIScaleFactor = 1;
+ mnDPIScalePercentage = 100;
mnTextOffX = 0;
mnTextOffY = 0;
mnOutOffOrigX = 0;
diff --git a/vcl/source/outdev/textline.cxx b/vcl/source/outdev/textline.cxx
index cdf40b3d6d2a..d742e8fcf098 100644
--- a/vcl/source/outdev/textline.cxx
+++ b/vcl/source/outdev/textline.cxx
@@ -1017,20 +1017,20 @@ void OutputDevice::DrawWaveLine( const Point& rStartPos, const Point& rEndPos )
aStartPt.RotateAround( nEndX, nEndY, -nOrientation );
}
- long nWaveHeight;
-
- nWaveHeight = 3;
+ long nWaveHeight = 3;
nStartY++;
nEndY++;
- if (mnDPIScaleFactor > 1)
+ float fScaleFactor = GetDPIScaleFactor();
+
+ if (fScaleFactor > 1.0f)
{
- nWaveHeight *= mnDPIScaleFactor;
+ nWaveHeight *= fScaleFactor;
- nStartY += mnDPIScaleFactor - 1; // Shift down additional pixel(s) to create more visual separation.
+ nStartY += fScaleFactor - 1; // Shift down additional pixel(s) to create more visual separation.
// odd heights look better than even
- if (mnDPIScaleFactor % 2 == 0)
+ if (nWaveHeight % 2 == 0)
{
nWaveHeight--;
}
@@ -1044,7 +1044,7 @@ void OutputDevice::DrawWaveLine( const Point& rStartPos, const Point& rEndPos )
}
ImplDrawWaveLine(nStartX, nStartY, 0, 0,
nEndX-nStartX, nWaveHeight,
- mnDPIScaleFactor, nOrientation, GetLineColor());
+ fScaleFactor, nOrientation, GetLineColor());
if( mpAlphaVDev )
mpAlphaVDev->DrawWaveLine( rStartPos, rEndPos );
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 2c97ee561662..9170c6b31a06 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -869,7 +869,7 @@ void Window::ReleaseGraphics( bool bRelease )
static sal_Int32 CountDPIScaleFactor(sal_Int32 nDPI)
{
- sal_Int32 nResult = 1;
+ sal_Int32 nResult = 100;
#ifndef MACOSX
// Setting of HiDPI is unfortunately all only a heuristic; and to add
@@ -877,8 +877,12 @@ static sal_Int32 CountDPIScaleFactor(sal_Int32 nDPI)
// the DPI and whatnot
// eg. fdo#77059 - set the value from which we do consider the
// screen hi-dpi to greater than 168
- if (nDPI > 168)
- nResult = std::max(sal_Int32(1), (nDPI + 48) / 96);
+ if (nDPI > 216) // 96 * 2 + 96 / 4
+ nResult = 250;
+ else if (nDPI > 168) // 96 * 2 - 96 / 4
+ nResult = 200;
+ else if (nDPI > 120) // 96 * 1.5 - 96 / 4
+ nResult = 150;
#else
(void)nDPI;
#endif
@@ -1130,7 +1134,7 @@ void Window::ImplInit( vcl::Window* pParent, WinBits nStyle, SystemParentData* p
}
// setup the scale factor for Hi-DPI displays
- mnDPIScaleFactor = CountDPIScaleFactor(mpWindowImpl->mpFrameData->mnDPIY);
+ mnDPIScalePercentage = CountDPIScaleFactor(mpWindowImpl->mpFrameData->mnDPIY);
mnDPIX = mpWindowImpl->mpFrameData->mnDPIX;
mnDPIY = mpWindowImpl->mpFrameData->mnDPIY;
@@ -1316,7 +1320,7 @@ void Window::ImplInitResolutionSettings()
mnDPIY = mpWindowImpl->mpFrameData->mnDPIY;
// setup the scale factor for Hi-DPI displays
- mnDPIScaleFactor = CountDPIScaleFactor(mpWindowImpl->mpFrameData->mnDPIY);
+ mnDPIScalePercentage = CountDPIScaleFactor(mpWindowImpl->mpFrameData->mnDPIY);
const StyleSettings& rStyleSettings = mxSettings->GetStyleSettings();
SetPointFont(*this, rStyleSettings.GetAppFont());
}
@@ -1324,7 +1328,7 @@ void Window::ImplInitResolutionSettings()
{
mnDPIX = mpWindowImpl->mpParent->mnDPIX;
mnDPIY = mpWindowImpl->mpParent->mnDPIY;
- mnDPIScaleFactor = mpWindowImpl->mpParent->mnDPIScaleFactor;
+ mnDPIScalePercentage = mpWindowImpl->mpParent->mnDPIScalePercentage;
}
// update the recalculated values for logical units