From f708d04b6825ece0e0c0dcbb8d9f81beefa5161f Mon Sep 17 00:00:00 2001 From: Xiao-Yong Jin Date: Tue, 18 Jun 2019 21:12:33 -0500 Subject: [PATCH 1/2] devdraw: cocoa metal screen adds a delayed update The immediate display of the screen sometimes miss the update from the CPU side memory. No obvious synchronization mechanism is available. In order to make sure the screen updates properly, we set needsDisplay again after a minimal delay to ensure a second screen update. --- src/cmd/devdraw/cocoa-screen-metal.m | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/cmd/devdraw/cocoa-screen-metal.m b/src/cmd/devdraw/cocoa-screen-metal.m index 959df59bf..1588992f0 100644 --- a/src/cmd/devdraw/cocoa-screen-metal.m +++ b/src/cmd/devdraw/cocoa-screen-metal.m @@ -212,12 +212,19 @@ + (void)callkicklabel:(NSString *)s + (void)callsetNeedsDisplayInRect:(NSValue *)v { NSRect r; + dispatch_time_t time; r = [v rectValue]; LOG(@"callsetNeedsDisplayInRect(%g, %g, %g, %g)", r.origin.x, r.origin.y, r.size.width, r.size.height); r = [win convertRectFromBacking:r]; LOG(@"setNeedsDisplayInRect(%g, %g, %g, %g)", r.origin.x, r.origin.y, r.size.width, r.size.height); [layer setNeedsDisplayInRect:r]; + + time = dispatch_time(DISPATCH_TIME_NOW, 8 * NSEC_PER_MSEC); + dispatch_after(time, dispatch_get_main_queue(), ^(void){ + [layer setNeedsDisplayInRect:r]; + }); + [myContent enlargeLastInputRect:r]; } From f92bb8f53c3aee84afefd0e7be18c42ad63023c4 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 19 Jun 2019 14:32:20 -0400 Subject: [PATCH 2/2] Update cocoa-screen-metal.m --- src/cmd/devdraw/cocoa-screen-metal.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/devdraw/cocoa-screen-metal.m b/src/cmd/devdraw/cocoa-screen-metal.m index 1588992f0..984ede033 100644 --- a/src/cmd/devdraw/cocoa-screen-metal.m +++ b/src/cmd/devdraw/cocoa-screen-metal.m @@ -220,7 +220,7 @@ + (void)callsetNeedsDisplayInRect:(NSValue *)v LOG(@"setNeedsDisplayInRect(%g, %g, %g, %g)", r.origin.x, r.origin.y, r.size.width, r.size.height); [layer setNeedsDisplayInRect:r]; - time = dispatch_time(DISPATCH_TIME_NOW, 8 * NSEC_PER_MSEC); + time = dispatch_time(DISPATCH_TIME_NOW, 16 * NSEC_PER_MSEC); dispatch_after(time, dispatch_get_main_queue(), ^(void){ [layer setNeedsDisplayInRect:r]; });