vcl/inc/osx/salframe.h       |    6 +++
 vcl/osx/salframe.cxx         |   70 ++++++++++++++-----------------------------
 vcl/osx/salframeview.mm      |    6 +--
 vcl/osx/salnativewidgets.cxx |   10 ++++++
 4 files changed, 42 insertions(+), 50 deletions(-)

New commits:
commit 015774082f638c17208609a96aecf6a5b3f4bff8
Author:     Patrick Luby <guibmac...@gmail.com>
AuthorDate: Wed Dec 25 08:59:59 2024 -0500
Commit:     Adolfo Jayme Barrientos <fit...@ubuntu.com>
CommitDate: Thu Dec 26 09:21:56 2024 +0100

    tdf#164428 Skia/Metal needs flush after drawing progress bar
    
    Also, move much of the duplicate code in the two AquaSalFrame::Flush()
    methods into a new AquaSalFrame::doFlush() method.
    
    Change-Id: I59f597692b7d5bc3035181681b2af8349c9812b2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179376
    Reviewed-by: Patrick Luby <guibomac...@gmail.com>
    Tested-by: Jenkins
    Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com>

diff --git a/vcl/inc/osx/salframe.h b/vcl/inc/osx/salframe.h
index fa2a5bcb3cbb..ee7afe053cab 100644
--- a/vcl/inc/osx/salframe.h
+++ b/vcl/inc/osx/salframe.h
@@ -96,7 +96,9 @@ public:
     int                             mnBlinkCursorDelay;
 
     // tdf#155266 force flush after scrolling
-    bool                            mbForceFlush;
+    bool                            mbForceFlushScrolling;
+    // tdf#164428 force flush after drawing a progress bar
+    bool                            mbForceFlushProgressBar;
 
     // Is window in LibreOffice full screen mode
     bool                            mbInternalFullScreen;
@@ -225,6 +227,8 @@ private: // methods
 
     void doResetClipRegion();
 
+    bool doFlush();
+
 private: // data
     static AquaSalFrame*       s_pCaptureFrame;
 
diff --git a/vcl/osx/salframe.cxx b/vcl/osx/salframe.cxx
index 98ea5a72c718..4e1266234f1f 100644
--- a/vcl/osx/salframe.cxx
+++ b/vcl/osx/salframe.cxx
@@ -91,7 +91,8 @@ AquaSalFrame::AquaSalFrame( SalFrame* pParent, 
SalFrameStyleFlags salFrameStyle
     mrClippingPath( nullptr ),
     mnICOptions( InputContextFlags::NONE ),
     mnBlinkCursorDelay( nMinBlinkCursorDelay ),
-    mbForceFlush( false ),
+    mbForceFlushScrolling( false ),
+    mbForceFlushProgressBar( false ),
     mbInternalFullScreen( false ),
     maInternalFullScreenRestoreRect( NSZeroRect ),
     maInternalFullScreenExpectedRect( NSZeroRect ),
@@ -1107,15 +1108,6 @@ void AquaSalFrame::SetPointerPos( tools::Long nX, 
tools::Long nY )
     CGDisplayMoveCursorToPoint( mainDisplayID, aPoint );
 }
 
-static bool lcl_ShouldDisplayInsteadOFFlush()
-{
-    bool bRet = false;
-#if HAVE_FEATURE_SKIA
-    bRet = SkiaHelper::isVCLSkiaEnabled() && SkiaHelper::renderMethodToUse() 
!= SkiaHelper::RenderRaster;
-#endif
-    return bRet;
-}
-
 void AquaSalFrame::Flush()
 {
     if( !(mbGraphics && mpGraphics && mpNSView && mbShown) )
@@ -1128,36 +1120,8 @@ void AquaSalFrame::Flush()
     // outside of the application's event loop (e.g. IntroWindow)
     // nothing would trigger paint event handling
     // => fall back to synchronous painting
-    if( mbForceFlush || ImplGetSVData()->maAppData.mnDispatchLevel <= 0 )
-    {
-        mbForceFlush = false;
-
-        // Related: tdf#163945 don't directly flush graphics with Skia/Metal
-        // When dragging a selection box on an empty background in
-        // Impress and only with Skia/Metal, the selection box
-        // would not keep up with the pointer. The selection box
-        // would repaint sporadically or not at all if the pointer
-        // was dragged rapidly and the status bar was visible.
-        // Apparently, flushing a graphics doesn't actually do much
-        // of anything with Skia/Raster and Skia disabled so the
-        // selection box repaints without any noticeable delay.
-        // However, with Skia/Metal every flush of a graphics
-        // creates and queues a new CAMetalLayer drawable. During
-        // rapid dragging, this can lead to creating and queueing
-        // up to 200 drawables per second leaving no spare time for
-        // the Impress selection box painting timer to fire.
-        // So with Skia/Metal, throttle the rate of flushing by
-        // calling display on the view.
-        bool bDisplay = lcl_ShouldDisplayInsteadOFFlush();
-        if (!bDisplay)
-            mpGraphics->Flush();
-
-        // Related: tdf#155266 skip redisplay of the view when forcing flush
-        // It appears that calling -[NSView display] overwhelms some Intel Macs
-        // so only flush the graphics and skip immediate redisplay of the view.
-        if( bDisplay || ImplGetSVData()->maAppData.mnDispatchLevel <= 0 )
-            [mpNSView display];
-    }
+    if( doFlush() )
+        [mpNSView display];
 }
 
 void AquaSalFrame::Flush( const tools::Rectangle& rRect )
@@ -1174,10 +1138,16 @@ void AquaSalFrame::Flush( const tools::Rectangle& rRect 
)
     // outside of the application's event loop (e.g. IntroWindow)
     // nothing would trigger paint event handling
     // => fall back to synchronous painting
-    if( mbForceFlush || ImplGetSVData()->maAppData.mnDispatchLevel <= 0 )
-    {
-        mbForceFlush = false;
+    if( doFlush() )
+        [mpNSView displayRect: aNSRect];
+}
 
+bool AquaSalFrame::doFlush()
+{
+    bool bRet = false;
+
+    if( mbForceFlushScrolling || mbForceFlushProgressBar || 
ImplGetSVData()->maAppData.mnDispatchLevel <= 0 )
+    {
         // Related: tdf#163945 don't directly flush graphics with Skia/Metal
         // When dragging a selection box on an empty background in
         // Impress and only with Skia/Metal, the selection box
@@ -1194,16 +1164,24 @@ void AquaSalFrame::Flush( const tools::Rectangle& rRect 
)
         // the Impress selection box painting timer to fire.
         // So with Skia/Metal, throttle the rate of flushing by
         // calling display on the view.
-        bool bDisplay = lcl_ShouldDisplayInsteadOFFlush();
+        bool bDisplay = false;
+#if HAVE_FEATURE_SKIA
+        // tdf#164428 Skia/Metal needs flush after drawing progress bar
+        bDisplay = !mbForceFlushProgressBar && SkiaHelper::isVCLSkiaEnabled() 
&& SkiaHelper::renderMethodToUse() != SkiaHelper::RenderRaster;
+#endif
         if (!bDisplay)
             mpGraphics->Flush();
 
         // Related: tdf#155266 skip redisplay of the view when forcing flush
         // It appears that calling -[NSView display] overwhelms some Intel Macs
         // so only flush the graphics and skip immediate redisplay of the view.
-        if( bDisplay || ImplGetSVData()->maAppData.mnDispatchLevel <= 0 )
-            [mpNSView displayRect: aNSRect];
+        bRet = bDisplay || ImplGetSVData()->maAppData.mnDispatchLevel <= 0;
+
+        mbForceFlushScrolling = false;
+        mbForceFlushProgressBar = false;
     }
+
+    return bRet;
 }
 
 void AquaSalFrame::SetInputContext( SalInputContext* pContext )
diff --git a/vcl/osx/salframeview.mm b/vcl/osx/salframeview.mm
index ad868d396d59..a5cb9270600b 100644
--- a/vcl/osx/salframeview.mm
+++ b/vcl/osx/salframeview.mm
@@ -1094,7 +1094,7 @@ static void updateMenuBarVisibility( const AquaSalFrame 
*pFrame )
 
         // tdf#155266 force flush after scrolling
         if (nButton == MOUSE_LEFT && nEvent == SalEvent::MouseMove)
-            mpFrame->mbForceFlush = true;
+            mpFrame->mbForceFlushScrolling = true;
     }
 }
 
@@ -1337,7 +1337,7 @@ static void updateMenuBarVisibility( const AquaSalFrame 
*pFrame )
         }
 
         // tdf#155266 force flush after scrolling
-        mpFrame->mbForceFlush = true;
+        mpFrame->mbForceFlushScrolling = true;
     }
 }
 
@@ -1417,7 +1417,7 @@ static void updateMenuBarVisibility( const AquaSalFrame 
*pFrame )
         }
 
         // tdf#155266 force flush after scrolling
-        mpFrame->mbForceFlush = true;
+        mpFrame->mbForceFlushScrolling = true;
     }
 }
 
diff --git a/vcl/osx/salnativewidgets.cxx b/vcl/osx/salnativewidgets.cxx
index d0ebad835f3d..07f26c51171a 100644
--- a/vcl/osx/salnativewidgets.cxx
+++ b/vcl/osx/salnativewidgets.cxx
@@ -36,6 +36,10 @@
 #include <Carbon/Carbon.h>
 #include <postmac.h>
 
+#if HAVE_FEATURE_SKIA
+#include <vcl/skia/SkiaHelper.hxx>
+#endif
+
 #include "cuidraw.hxx"
 
 // presentation of native widgets consists of two important methods:
@@ -694,6 +698,12 @@ bool 
AquaGraphicsBackendBase::performDrawNativeControl(ControlType nType,
 
                 [pBox release];
 
+#if HAVE_FEATURE_SKIA
+                // tdf#164428 Skia/Metal needs flush after drawing progress bar
+                if (SkiaHelper::isVCLSkiaEnabled() && 
SkiaHelper::renderMethodToUse() != SkiaHelper::RenderRaster)
+                    mpFrame->mbForceFlushProgressBar = true;
+#endif
+
                 bOK = true;
             }
             break;

Reply via email to