diff options
author | Patrick Luby <guibmacdev@gmail.com> | 2024-12-05 17:51:33 -0500 |
---|---|---|
committer | Christian Lohmaier <lohmaier+LibreOffice@googlemail.com> | 2024-12-11 12:11:22 +0100 |
commit | c76a22412630dcdef8bd2db363acb54d347d29ae (patch) | |
tree | 9cb010c7b99c5844ed07682b99a5b9f8844f609a | |
parent | 925d326f2f4f4b6ff756f334585b7fa314ad5a35 (diff) |
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 <guibomacdev@gmail.com>
(cherry picked from commit cd983f0af4d0d2a187e30f070bc96241d362302f)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177980
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
-rw-r--r-- | external/skia/macosmetal.patch.0 | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/external/skia/macosmetal.patch.0 b/external/skia/macosmetal.patch.0 index 3da9fc693fe9..63a3e0df8c04 100644 --- a/external/skia/macosmetal.patch.0 +++ b/external/skia/macosmetal.patch.0 @@ -89,7 +89,32 @@ using sk_app::DisplayParams; using sk_app::window_context_factory::MacWindowInfo; using sk_app::MetalWindowContext; -@@ -66,8 +68,7 @@ +@@ -53,7 +55,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; + +@@ -66,10 +84,10 @@ fMetalLayer.autoresizingMask = kCALayerHeightSizable | kCALayerWidthSizable; fMetalLayer.contentsGravity = kCAGravityTopLeft; fMetalLayer.magnificationFilter = kCAFilterNearest; @@ -97,9 +122,13 @@ - fMetalLayer.colorspace = cs.CGColorSpace; + fMetalLayer.colorspace = CGColorSpaceCreateWithName(kCGColorSpaceSRGB); - fMainView.layer = fMetalLayer; +- fMainView.layer = fMetalLayer; ++ if (!reuseMetalLayer) ++ fMainView.layer = fMetalLayer; fMainView.wantsLayer = YES; -@@ -86,6 +87,18 @@ + + return true; +@@ -86,6 +104,18 @@ fMetalLayer.drawableSize = backingSize; fMetalLayer.contentsScale = backingScaleFactor; |