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

Tomaž Vajngerl tomaz.vajngerl at collabora.co.uk
Fri Dec 23 22:03:55 UTC 2016


 vcl/inc/implimagetree.hxx           |    3 ++
 vcl/source/image/ImplImageTree.cxx  |   50 ++++++++++++++++++++----------------
 vcl/unx/generic/window/salframe.cxx |   11 +++++--
 3 files changed, 40 insertions(+), 24 deletions(-)

New commits:
commit 96b95f5010be090ebae6f755d4d3891a2334332c
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Thu Dec 22 22:28:23 2016 +0100

    tdf#103626 don't scale application icon to prevent a start-up loop
    
    Change-Id: I2e65ba16d93167dc4abb029c7e941e91be9a62ab
    Reviewed-on: https://gerrit.libreoffice.org/32382
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/vcl/inc/implimagetree.hxx b/vcl/inc/implimagetree.hxx
index 108dc97..5fa528e 100644
--- a/vcl/inc/implimagetree.hxx
+++ b/vcl/inc/implimagetree.hxx
@@ -53,6 +53,9 @@ struct ImageRequestParameters
         , mbLocalized(bLocalized)
         , meFlags(eFlags)
     {}
+
+    bool convertToDarkTheme();
+    sal_Int32 scalePrecentage();
 };
 
 class ImplImageTree
diff --git a/vcl/source/image/ImplImageTree.cxx b/vcl/source/image/ImplImageTree.cxx
index 4cd491d..42f2104 100644
--- a/vcl/source/image/ImplImageTree.cxx
+++ b/vcl/source/image/ImplImageTree.cxx
@@ -49,6 +49,25 @@
 #include <vcl/BitmapTools.hxx>
 #include <vcl/pngwrite.hxx>
 
+bool ImageRequestParameters::convertToDarkTheme()
+{
+    static bool bIconsForDarkTheme = !!getenv("VCL_ICONS_FOR_DARK_THEME");
+
+    bool bConvertToDarkTheme = false;
+    if (!(meFlags & ImageLoadFlags::IgnoreDarkTheme))
+        bConvertToDarkTheme = bIconsForDarkTheme;
+
+    return bConvertToDarkTheme;
+}
+
+sal_Int32 ImageRequestParameters::scalePrecentage()
+{
+    sal_Int32 aScalePercentage = 100;
+    if (!(meFlags & ImageLoadFlags::IgnoreScalingFactor))
+        aScalePercentage = Application::GetDefaultDevice()->GetDPIScalePercentage();
+    return aScalePercentage;
+}
+
 namespace
 {
 
@@ -134,15 +153,8 @@ std::shared_ptr<SvStream> wrapStream(css::uno::Reference< css::io::XInputStream
 
 void loadImageFromStream(std::shared_ptr<SvStream> const & xStream, OUString const & rPath, ImageRequestParameters& rParameters)
 {
-    static bool bIconsForDarkTheme = !!getenv("VCL_ICONS_FOR_DARK_THEME");
-
-    bool bConvertToDarkTheme = bIconsForDarkTheme;
-    if (rParameters.meFlags & ImageLoadFlags::IgnoreDarkTheme)
-        bConvertToDarkTheme = false;
-
-    float aScaleFactor = Application::GetDefaultDevice()->GetDPIScaleFactor();
-    if (rParameters.meFlags & ImageLoadFlags::IgnoreScalingFactor)
-        aScaleFactor = 1.0f;
+    bool bConvertToDarkTheme = rParameters.convertToDarkTheme();
+    sal_Int32 aScalePercentage = rParameters.scalePrecentage();
 
     if (rPath.endsWith(".png"))
     {
@@ -152,7 +164,7 @@ void loadImageFromStream(std::shared_ptr<SvStream> const & xStream, OUString con
     }
     else if (rPath.endsWith(".svg"))
     {
-        vcl::bitmap::loadFromSvg(*xStream.get(), rPath, rParameters.mrBitmap, double(aScaleFactor));
+        vcl::bitmap::loadFromSvg(*xStream.get(), rPath, rParameters.mrBitmap, aScalePercentage / 100.0);
         if (bConvertToDarkTheme)
             rParameters.mrBitmap = BitmapProcessor::createLightImage(rParameters.mrBitmap);
         return;
@@ -165,8 +177,11 @@ void loadImageFromStream(std::shared_ptr<SvStream> const & xStream, OUString con
     if (bConvertToDarkTheme)
         rParameters.mrBitmap = BitmapProcessor::createLightImage(rParameters.mrBitmap);
 
-    if (aScaleFactor > 1.0f)
-        rParameters.mrBitmap.Scale(double(aScaleFactor), double(aScaleFactor), BmpScaleFlag::Fast);
+    if (aScalePercentage > 100)
+    {
+        double aScaleFactor(aScalePercentage / 100.0);
+        rParameters.mrBitmap.Scale(aScaleFactor, aScaleFactor, BmpScaleFlag::Fast);
+    }
 }
 
 } // end anonymous namespace
@@ -283,15 +298,8 @@ bool ImplImageTree::loadDefaultImage(OUString const & style, BitmapEx& bitmap, c
 
 OUString createVariant(ImageRequestParameters& rParameters)
 {
-    static bool bIconsForDarkTheme = !!getenv("VCL_ICONS_FOR_DARK_THEME");
-
-    bool bConvertToDarkTheme = bIconsForDarkTheme;
-    if (rParameters.meFlags & ImageLoadFlags::IgnoreDarkTheme)
-        bConvertToDarkTheme = false;
-
-    sal_Int32 aScalePercentage = Application::GetDefaultDevice()->GetDPIScalePercentage();
-    if (rParameters.meFlags & ImageLoadFlags::IgnoreScalingFactor)
-        aScalePercentage = 100;
+    bool bConvertToDarkTheme = rParameters.convertToDarkTheme();
+    sal_Int32 aScalePercentage = rParameters.scalePrecentage();
 
     OUString aVariant;
     if (aScalePercentage == 100 && !bConvertToDarkTheme)
diff --git a/vcl/unx/generic/window/salframe.cxx b/vcl/unx/generic/window/salframe.cxx
index ba4c190..ffbccc7 100644
--- a/vcl/unx/generic/window/salframe.cxx
+++ b/vcl/unx/generic/window/salframe.cxx
@@ -35,6 +35,7 @@
 #include <vcl/settings.hxx>
 #include <vcl/bitmapaccess.hxx>
 #include <vcl/opengl/OpenGLContext.hxx>
+#include <vcl/BitmapTools.hxx>
 
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
@@ -209,7 +210,10 @@ static void CreateNetWmAppIcon( sal_uInt16 nIcon, NetWmIconData& netwm_icon )
             nIconSizeOffset = SV_ICON_SIZE32_START;
         else
             nIconSizeOffset = SV_ICON_SIZE16_START;
-        BitmapEx aIcon( ResId(nIconSizeOffset + nIcon, *ImplGetResMgr()));
+
+        BitmapEx aIcon = vcl::bitmap::loadFromResource(ResId(nIconSizeOffset + nIcon, *ImplGetResMgr()),
+                                                       ImageLoadFlags::IgnoreScalingFactor);
+
         if( aIcon.IsEmpty())
             continue;
         Bitmap icon = aIcon.GetBitmap();
@@ -250,7 +254,6 @@ static bool lcl_SelectAppIconPixmap( SalDisplay *pDisplay, SalX11Screen nXScreen
                                          sal_uInt16 nIcon, sal_uInt16 iconSize,
                                          Pixmap& icon_pixmap, Pixmap& icon_mask, NetWmIconData& netwm_icon)
 {
-    return true;
     if( ! ImplGetResMgr() )
         return false;
 
@@ -267,7 +270,9 @@ static bool lcl_SelectAppIconPixmap( SalDisplay *pDisplay, SalX11Screen nXScreen
     else
         return false;
 
-    BitmapEx aIcon( ResId(nIconSizeOffset + nIcon, *ImplGetResMgr()));
+    BitmapEx aIcon = vcl::bitmap::loadFromResource(ResId(nIconSizeOffset + nIcon, *ImplGetResMgr()),
+                                                   ImageLoadFlags::IgnoreScalingFactor);
+
     if( aIcon.IsEmpty() )
         return false;
 


More information about the Libreoffice-commits mailing list