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 c8bd4d330fe4f8d1bae11cf64d596222b280bb8f 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:22:29 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/+/179377 Reviewed-by: Patrick Luby <guibomac...@gmail.com> Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com> Tested-by: Jenkins diff --git a/vcl/inc/osx/salframe.h b/vcl/inc/osx/salframe.h index 717e5f310178..36121c437896 100644 --- a/vcl/inc/osx/salframe.h +++ b/vcl/inc/osx/salframe.h @@ -98,7 +98,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; public: /** Constructor @@ -215,6 +217,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 bbce8d566dce..75f27080121c 100644 --- a/vcl/osx/salframe.cxx +++ b/vcl/osx/salframe.cxx @@ -90,7 +90,8 @@ AquaSalFrame::AquaSalFrame( SalFrame* pParent, SalFrameStyleFlags salFrameStyle mrClippingPath( nullptr ), mnICOptions( InputContextFlags::NONE ), mnBlinkCursorDelay( nMinBlinkCursorDelay ), - mbForceFlush( false ) + mbForceFlushScrolling( false ), + mbForceFlushProgressBar( false ) { mpParent = dynamic_cast<AquaSalFrame*>(pParent); @@ -1008,15 +1009,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) ) @@ -1029,36 +1021,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 ) @@ -1075,10 +1039,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 @@ -1095,16 +1065,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 40007e0fc38a..47e01a3ce857 100644 --- a/vcl/osx/salframeview.mm +++ b/vcl/osx/salframeview.mm @@ -971,7 +971,7 @@ static bool isMouseScrollWheelEvent( NSEvent *pEvent ) // tdf#155266 force flush after scrolling if (nButton == MOUSE_LEFT && nEvent == SalEvent::MouseMove) - mpFrame->mbForceFlush = true; + mpFrame->mbForceFlushScrolling = true; } } @@ -1214,7 +1214,7 @@ static bool isMouseScrollWheelEvent( NSEvent *pEvent ) } // tdf#155266 force flush after scrolling - mpFrame->mbForceFlush = true; + mpFrame->mbForceFlushScrolling = true; } } @@ -1294,7 +1294,7 @@ static bool isMouseScrollWheelEvent( NSEvent *pEvent ) } // 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 c2a861c1fcc5..ae0251d9bb32 100644 --- a/vcl/osx/salnativewidgets.cxx +++ b/vcl/osx/salnativewidgets.cxx @@ -35,6 +35,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: @@ -672,6 +676,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;