external/skia/macosmetal.patch.1 | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-)
New commits: commit 972ebe0655d5f7e5132e5d101f022299ce5be7ef Author: Patrick Luby <guibmac...@gmail.com> AuthorDate: Thu Dec 5 17:51:33 2024 -0500 Commit: Patrick Luby <guibomac...@gmail.com> CommitDate: Fri Dec 6 18:02:57 2024 +0100 Related: tdf#152703 Reuse existing CAMetalLayer to stop flicker When live resizing a window, replacing the CAMetalLayer with each resize event repaints the window's background which causes a noticeable flicker. So reuse any existing CAMetalLayer already assigned to the native view. Change-Id: I03bda5f0d40b84606b6602961e5f0d3b0dfcc6ba Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177921 Tested-by: Jenkins Reviewed-by: Patrick Luby <guibomac...@gmail.com> (cherry picked from commit cd983f0af4d0d2a187e30f070bc96241d362302f) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177984 diff --git a/external/skia/macosmetal.patch.1 b/external/skia/macosmetal.patch.1 index fbf6962340fc..48f7a2400421 100644 --- a/external/skia/macosmetal.patch.1 +++ b/external/skia/macosmetal.patch.1 @@ -70,7 +70,32 @@ diff -ur skia.org/tools/window/mac/GaneshMetalWindowContext_mac.mm skia/tools/wi #import <Cocoa/Cocoa.h> #import <QuartzCore/CAConstraintLayoutManager.h> -@@ -65,8 +67,7 @@ +@@ -52,7 +54,23 @@ + + SkASSERT(nil != fMainView); + +- fMetalLayer = [CAMetalLayer layer]; ++ // Related: tdf#152703 Reuse existing CAMetalLayer to stop flicker ++ // When live resizing a window, replacing the CAMetalLayer with each ++ // resize event repaints the window's background which causes a ++ // noticeable flicker. So reuse any existing CAMetalLayer already ++ // assigned to the native view. ++ BOOL reuseMetalLayer = NO; ++ if (fMainView.wantsLayer) ++ { ++ CALayer *pLayer = fMainView.layer; ++ if (pLayer && [pLayer isKindOfClass:[CAMetalLayer class]]) ++ { ++ fMetalLayer = (__bridge CAMetalLayer*)pLayer; ++ reuseMetalLayer = YES; ++ } ++ } ++ if (!reuseMetalLayer) ++ fMetalLayer = [CAMetalLayer layer]; + fMetalLayer.device = fShared->fDevice.get(); + fMetalLayer.pixelFormat = MTLPixelFormatBGRA8Unorm; + +@@ -65,10 +83,10 @@ fMetalLayer.autoresizingMask = kCALayerHeightSizable | kCALayerWidthSizable; fMetalLayer.contentsGravity = kCAGravityTopLeft; fMetalLayer.magnificationFilter = kCAFilterNearest; @@ -78,9 +103,13 @@ diff -ur skia.org/tools/window/mac/GaneshMetalWindowContext_mac.mm skia/tools/wi - fMetalLayer.colorspace = cs.CGColorSpace; + fMetalLayer.colorspace = CGColorSpaceCreateWithName(kCGColorSpaceSRGB); - fMainView.layer = fMetalLayer; +- fMainView.layer = fMetalLayer; ++ if (!reuseMetalLayer) ++ fMainView.layer = fMetalLayer; fMainView.wantsLayer = YES; -@@ -85,6 +86,18 @@ + + return true; +@@ -85,6 +103,18 @@ fMetalLayer.drawableSize = backingSize; fMetalLayer.contentsScale = backingScaleFactor; @@ -114,4 +143,3 @@ diff -ur skia.org/tools/window/mac/MacWindowInfo.h skia/tools/window/mac/MacWind +SK_API void ResetBackingScaleFactor(); } // namespace skwindow -