1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-08-09 05:25:01 +00:00

Added the simplest mechanism to decouple emulation from the display link queue.

This commit is contained in:
Thomas Harte
2016-03-19 22:53:37 -04:00
parent 9da7716c72
commit a546277f88

View File

@@ -12,6 +12,7 @@
@implementation CSOpenGLView { @implementation CSOpenGLView {
CVDisplayLinkRef _displayLink; CVDisplayLinkRef _displayLink;
uint32_t _updateIsOngoing;
} }
- (void)prepareOpenGL - (void)prepareOpenGL
@@ -51,9 +52,15 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
- (void)drawAtTime:(const CVTimeStamp *)now - (void)drawAtTime:(const CVTimeStamp *)now
{ {
NSLog(@"%0.4f", (double)now->videoTime / (double)now->videoTimeScale); const uint32_t activityMask = 0x01;
if(!OSAtomicTestAndSet(activityMask, &_updateIsOngoing))
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
[self.delegate openGLView:self didUpdateToTime:*now]; [self.delegate openGLView:self didUpdateToTime:*now];
[self drawViewOnlyIfDirty:YES]; [self drawViewOnlyIfDirty:YES];
OSAtomicTestAndClear(activityMask, &_updateIsOngoing);
});
}
} }
- (void)invalidate - (void)invalidate