[Libreoffice-commits] core.git: vcl/inc vcl/osx vcl/qa vcl/quartz

Thorsten Wagner (via logerrit) logerrit at kemper.freedesktop.org
Tue Feb 23 07:22:43 UTC 2021


 vcl/inc/quartz/salgdi.h                          |    3 -
 vcl/osx/salgdiutils.cxx                          |   50 +++++++++++------------
 vcl/osx/salmacos.cxx                             |    4 -
 vcl/qa/cppunit/BackendTest.cxx                   |    6 ++
 vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx |    4 +
 vcl/qa/cppunit/outdev.cxx                        |    4 +
 vcl/quartz/salgdi.cxx                            |    8 ---
 7 files changed, 41 insertions(+), 38 deletions(-)

New commits:
commit 0c36f364b14aacd0eeb53087ae2fce54402dc741
Author:     Thorsten Wagner <thorsten.wagner.4 at gmail.com>
AuthorDate: Sun Feb 21 01:34:54 2021 +0100
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Tue Feb 23 08:22:05 2021 +0100

    tdf#138122 Detect window scaling for multi display configurations on macOS
    
    (1) Activate window scaling when at least one retina display is connected
    
    (2) Remove environment variable VCL_MACOS_FORCE_WINDOW_SCALING
    
    (3) Disable related unit tests unless bitmap scaling has been implemented
    
    Change-Id: I218119a21e319e22bf17c609608724fce180f000
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111267
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h
index 69b735787bdc..ce68b75b0b06 100644
--- a/vcl/inc/quartz/salgdi.h
+++ b/vcl/inc/quartz/salgdi.h
@@ -174,7 +174,6 @@ class AquaSalGraphics : public SalGraphics
 #ifdef MACOSX
     /// is this a window graphics
     bool                                    mbWindow;
-    bool                                    mbWindowScaling;
 
 #else // IOS
 
@@ -196,7 +195,7 @@ public:
     void                    copyResolution( AquaSalGraphics& );
     void                    updateResolution();
 
-    float                   GetWindowScaling();
+    static float            GetWindowScaling();
     void                    SetWindowGraphics( AquaSalFrame* pFrame );
     bool                    IsWindowGraphics()      const   { return mbWindow; }
     void                    SetPrinterGraphics(CGContextRef, sal_Int32 nRealDPIX, sal_Int32 nRealDPIY);
diff --git a/vcl/osx/salgdiutils.cxx b/vcl/osx/salgdiutils.cxx
index 01626d348999..f3ddd946f699 100644
--- a/vcl/osx/salgdiutils.cxx
+++ b/vcl/osx/salgdiutils.cxx
@@ -35,37 +35,35 @@
 #include <osx/salframe.h>
 #include <osx/saldata.hxx>
 
-float AquaSalGraphics::GetWindowScaling()
-{
-    float fScale = 1.0f;
-
-#ifdef MACOSX
-
-    // Window scaling independent from main display may be forced by setting VCL_MACOS_FORCE_WINDOW_SCALING environment variable
-    // whose setting is stored in mbWindowScaling. After implementation of full support of scaled displays window scaling will be
-    // set to 2.0f for macOS as default. This will allow moving of windows between non retina and retina displays without blurry
-    // text and graphics.
+// TODO: Scale will be set to 2.0f as default after implementation of full scaled display support . This will allow moving of
+// windows between non retina and retina displays without blurry text and graphics. Static variables have to be removed thereafter.
 
-    // TODO: After implementation of full support of scaled displays code has to be modified to set a scaling of 2.0f as default.
-
-    if (mbWindowScaling)
-    {
-        fScale = 2.0f;
-        return fScale;
-    }
+// Currently scaled display support is not implemented for bitmaps. This will cause a slight performance degradation on displays
+// with single precision. To preserve performance for now, window scaling is only activated if at least one display with double
+// precision is present. Moving windows between displays is then possible without blurry text and graphics too. Adapting window
+// scaling when displays are added while application is running is not supported.
 
-#endif
+static bool  bWindowScaling = false;
+static float fWindowScale = 1.0f;
 
-    AquaSalFrame *pSalFrame = mpFrame;
-    if (!pSalFrame)
-        pSalFrame = static_cast<AquaSalFrame *>(GetSalData()->mpInstance->anyFrame());
-    if (pSalFrame)
+float AquaSalGraphics::GetWindowScaling()
+{
+    if (!bWindowScaling)
     {
-        NSWindow *pNSWindow = pSalFrame->getNSWindow();
-        if (pNSWindow)
-            fScale = [pNSWindow backingScaleFactor];
+        NSArray *aScreens = [NSScreen screens];
+        if (aScreens != nullptr)
+        {
+            int nScreens = [aScreens count];
+            for (int i = 0; i < nScreens; i++)
+            {
+                float fScale = [[aScreens objectAtIndex:i] backingScaleFactor];
+                if (fScale > fWindowScale)
+                  fWindowScale = fScale;
+            }
+            bWindowScaling = true;
+        }
     }
-    return fScale;
+    return fWindowScale;
 }
 
 void AquaSalGraphics::SetWindowGraphics( AquaSalFrame* pFrame )
diff --git a/vcl/osx/salmacos.cxx b/vcl/osx/salmacos.cxx
index 0f41dd9e8c4a..f6403dea2725 100644
--- a/vcl/osx/salmacos.cxx
+++ b/vcl/osx/salmacos.cxx
@@ -19,7 +19,7 @@
 
 // This file contains the macOS-specific versions of the functions which were touched in the commit
 // to fix tdf#138122. The iOS-specific versions of these functions are kept (for now, when this
-// comment is written) as they were before that commit in vcl/isx/salios.cxx.
+// comment is written) as they were before that commit in vcl/ios/salios.cxx.
 
 #include <sal/config.h>
 #include <sal/log.hxx>
@@ -331,7 +331,7 @@ bool AquaSalVirtualDevice::SetSize(tools::Long nDX, tools::Long nDY)
 
     mnWidth = nDX;
     mnHeight = nDY;
-    fScale = mpGraphics->GetWindowScaling();
+    fScale = AquaSalGraphics::GetWindowScaling();
     CGColorSpaceRef aColorSpace;
     uint32_t nFlags;
     if (mnBitmapDepth && (mnBitmapDepth < 16))
diff --git a/vcl/qa/cppunit/BackendTest.cxx b/vcl/qa/cppunit/BackendTest.cxx
index 4a32a50b6a92..56796f8b68c3 100644
--- a/vcl/qa/cppunit/BackendTest.cxx
+++ b/vcl/qa/cppunit/BackendTest.cxx
@@ -898,10 +898,16 @@ public:
     CPPUNIT_TEST(testRadialGradient);
     CPPUNIT_TEST(testRadialGradientOfs);
 
+// TODO: Following unit tests are not executed for macOS unless bitmap scaling is implemented
+#ifndef MACOSX
     CPPUNIT_TEST(testDrawBlendExtended);
     CPPUNIT_TEST(testDrawAlphaBitmapMirrored);
+#endif
 
+// TODO: Following unit test is not executed for macOS unless bitmap scaling is implemented
+#ifndef MACOSX
     CPPUNIT_TEST(testTdf124848);
+#endif
     CPPUNIT_TEST(testTdf136171);
 
     CPPUNIT_TEST_SUITE_END();
diff --git a/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx b/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx
index a4852438f6f3..127c0201bd78 100644
--- a/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx
+++ b/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx
@@ -49,8 +49,12 @@ public:
     CPPUNIT_TEST_SUITE(BitmapRenderTest);
     CPPUNIT_TEST(testTdf104141);
     CPPUNIT_TEST(testTdf113918);
+
+// TODO: Following unit tests are not executed for macOS unless bitmap scaling is implemented
+#ifndef MACOSX
     CPPUNIT_TEST(testDrawAlphaBitmapEx);
     CPPUNIT_TEST(testAlphaVirtualDevice);
+#endif
     CPPUNIT_TEST(testTdf116888);
 
     CPPUNIT_TEST_SUITE_END();
diff --git a/vcl/qa/cppunit/outdev.cxx b/vcl/qa/cppunit/outdev.cxx
index ed026820520e..9a7ef2c064e8 100644
--- a/vcl/qa/cppunit/outdev.cxx
+++ b/vcl/qa/cppunit/outdev.cxx
@@ -41,7 +41,11 @@ public:
     void testRTLGuard();
 
     CPPUNIT_TEST_SUITE(VclOutdevTest);
+
+// TODO: Following unit tests are not executed for macOS unless bitmap scaling is implemented
+#ifndef MACOSX
     CPPUNIT_TEST(testVirtualDevice);
+#endif
     CPPUNIT_TEST(testUseAfterDispose);
     CPPUNIT_TEST(testPrinterBackgroundColor);
     CPPUNIT_TEST(testWindowBackgroundColor);
diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx
index 8dd9ec9222ad..ae6a40cfd4e2 100644
--- a/vcl/quartz/salgdi.cxx
+++ b/vcl/quartz/salgdi.cxx
@@ -205,14 +205,6 @@ AquaSalGraphics::AquaSalGraphics()
     , mbVirDev( false )
 #ifdef MACOSX
     , mbWindow( false )
-
-    // Window scaling independent from main display may be forced by setting VCL_MACOS_FORCE_WINDOW_SCALING environment variable. If
-    // unset window scaling from main display will be used. After implementation of full support of scaled displays window scaling
-    // will be set to 2.0f for macOS as default.
-
-    // TODO: After implementation of full support of scaled displays VCL_FORCE_WINDOW_SCALING control has to be removed.
-
-    , mbWindowScaling( getenv("VCL_MACOS_FORCE_WINDOW_SCALING") )
 #else
     , mbForeignContext( false )
 #endif


More information about the Libreoffice-commits mailing list