summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Luby <guibmacdev@gmail.com>2024-12-05 17:51:33 -0500
committerMichael Stahl <michael.stahl@allotropia.de>2024-12-12 10:36:37 +0100
commit055029ef8c0c5936ff3faecbfe89fb58fcecefee (patch)
tree33f231567035c652a15291975cc2580d13564366
parent8218f94435c0fded31ab425c4ca696c9deda5296 (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/+/177983 Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com> Tested-by: Michael Stahl <michael.stahl@allotropia.de> Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
-rw-r--r--external/skia/macosmetal.patch.035
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;