From 16b629cf08f93e27e52816c761eeb3b5c128647b Mon Sep 17 00:00:00 2001 From: Patrick Luby Date: Sat, 23 Nov 2024 17:18:57 -0500 Subject: [PATCH] tdf#157312 and tdf#163945 Lower Skia flush timer priority on macOS On macOS, flushing with Skia/Metal is noticeably slower than with Skia/Raster. So lower the flush timer priority to TaskPriority::POST_PAINT so that the flush timer runs less frequently but each pass copies a more up-to-date offscreen surface. Unfortunately, lowering the priority causes tdf#163734 to reoccur. When a dockable window is dragged by its titlebar, a rectangle may be drawn in its parent window. However, the Skia flush timer doesn't run until after the mouse button has been released (probably due to lowering of the Skia flush timer's priority to fix tdf#163734). So run the parent frame's Skia flush timer immediately to display the rectangle. Change-Id: I289eab85a087cb76a751dc6b777342b8dee49e1c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177190 Reviewed-by: Patrick Luby Tested-by: Jenkins --- vcl/osx/salframeview.mm | 19 +++++++++++++++++++ vcl/skia/gdiimpl.cxx | 22 ++++++++++++---------- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/vcl/osx/salframeview.mm b/vcl/osx/salframeview.mm index b5a2d682e34c..ceab3c872fc4 100644 --- a/vcl/osx/salframeview.mm +++ b/vcl/osx/salframeview.mm @@ -440,6 +440,25 @@ static bool isMouseScrollWheelEvent( NSEvent *pEvent ) { mpFrame->UpdateFrameGeometry(); mpFrame->CallCallback( SalEvent::Move, nullptr ); + +#if HAVE_FEATURE_SKIA + // tdf#163734 Flush parent frame when Skia is enabled + // When a dockable window is dragged by its titlebar, a rectangle + // may be drawn in its parent window. However, the Skia flush + // timer doesn't run until after the mouse button has been + // released (probably due to lowering of the Skia flush timer's + // priority to fix tdf#163734). So run the parent frame's Skia + // flush timer immediately to display the rectangle. + if ( SkiaHelper::isVCLSkiaEnabled() && + mpFrame->mbShown && mpFrame->mpParent && + AquaSalFrame::isAlive( mpFrame->mpParent ) && + mpFrame->mpParent->mbShown ) + { + AquaSalGraphics* pGraphics = mpFrame->mpParent->mpGraphics; + if ( pGraphics ) + pGraphics->Flush(); + } +#endif } } diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx index 815c52b119f2..579a2d98d7fa 100644 --- a/vcl/skia/gdiimpl.cxx +++ b/vcl/skia/gdiimpl.cxx @@ -269,16 +269,18 @@ public: { mpGraphics->performFlush(); Stop(); - // tdf#163945 Lower priority of Skia flush timer - // Commit f4c2c7c79cfe4464ac596afda37b8904d06969db fixed tdf#157312 - // by lowering the timer priority to TaskPriority::POST_PAINT. But - // it caused tdf#163734 so it was reverted to TaskPriority::HIGHEST - // in commit 5a38e4f9798c5ff247aa57581adf2671485627fd. - // While reverting to TaskPriority::HIGHEST did not cause tdf#157312 - // to reoccur, it did cause tdf#163945 so set the timer priority to - // TaskPriority::HIGH_IDLE. This priority appears to be low enough to - // fix tdf#16394 without causing tdf#163734 to reoccur. - SetPriority(TaskPriority::HIGH_IDLE); +#ifdef MACOSX + // tdf#157312 and tdf#163945 Lower Skia flush timer priority on macOS + // On macOS, flushing with Skia/Metal is noticeably slower than + // with Skia/Raster. So lower the flush timer priority to + // TaskPriority::POST_PAINT so that the flush timer runs less + // frequently but each pass copies a more up-to-date offscreen + // surface. + // TODO: fix tdf#163734 on macOS + SetPriority(TaskPriority::POST_PAINT); +#else + SetPriority(TaskPriority::HIGHEST); +#endif } };