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:
@@ -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
|
||||||
|
Reference in New Issue
Block a user