aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/devdraw
diff options
context:
space:
mode:
authorXiao-Yong <xjin@anl.gov>2019-06-19 13:32:57 -0500
committerRuss Cox <rsc@swtch.com>2019-06-19 14:32:57 -0400
commite995a0c101863688d5f14649ae3de45a7c43789c (patch)
tree1f95b2ac4a7116cd6b13c6a560d4c90faed6ac8a /src/cmd/devdraw
parentd4e16c838ab2cccd97ad6e24fc290239666eaaac (diff)
downloadplan9port-e995a0c101863688d5f14649ae3de45a7c43789c.tar.gz
plan9port-e995a0c101863688d5f14649ae3de45a7c43789c.tar.bz2
plan9port-e995a0c101863688d5f14649ae3de45a7c43789c.zip
devdraw: cocoa metal screen adds a delayed update (#270)
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 16ms delay to ensure a second screen update.
Diffstat (limited to 'src/cmd/devdraw')
-rw-r--r--src/cmd/devdraw/cocoa-screen-metal.m7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/cmd/devdraw/cocoa-screen-metal.m b/src/cmd/devdraw/cocoa-screen-metal.m
index 959df59b..984ede03 100644
--- a/src/cmd/devdraw/cocoa-screen-metal.m
+++ b/src/cmd/devdraw/cocoa-screen-metal.m
@@ -212,12 +212,19 @@ threadmain(int argc, char **argv)
+ (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, 16 * NSEC_PER_MSEC);
+ dispatch_after(time, dispatch_get_main_queue(), ^(void){
+ [layer setNeedsDisplayInRect:r];
+ });
+
[myContent enlargeLastInputRect:r];
}