From 34047fa60a1fed0544a88eb19e56968fa71c6ef1 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 3 Mar 2019 14:49:20 -0500 Subject: [PATCH] Reintroduces proper locking of the OpenGL context in macOS. --- OSBindings/Mac/Clock Signal/Views/CSOpenGLView.m | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/OSBindings/Mac/Clock Signal/Views/CSOpenGLView.m b/OSBindings/Mac/Clock Signal/Views/CSOpenGLView.m index c00a2b15d..b56ad364e 100644 --- a/OSBindings/Mac/Clock Signal/Views/CSOpenGLView.m +++ b/OSBindings/Mac/Clock Signal/Views/CSOpenGLView.m @@ -52,16 +52,20 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt - (void)drawAtTime:(const CVTimeStamp *)now frequency:(double)frequency { - // Draw the display now regardless of other activity. - [self performWithGLContext:^{ - [self.delegate openGLViewRedraw:self event:CSOpenGLViewRedrawEventTimer]; - CGLFlushDrawable([[self openGLContext] CGLContextObj]); - }]; + [self redrawWithEvent:CSOpenGLViewRedrawEventTimer]; } - (void)drawRect:(NSRect)dirtyRect { - [self.delegate openGLViewRedraw:self event:CSOpenGLViewRedrawEventAppKit]; + [self redrawWithEvent:CSOpenGLViewRedrawEventAppKit]; +} + +- (void)redrawWithEvent:(CSOpenGLViewRedrawEvent)event +{ + [self performWithGLContext:^{ + [self.delegate openGLViewRedraw:self event:event]; + CGLFlushDrawable([[self openGLContext] CGLContextObj]); + }]; } - (void)invalidate