mirror of
https://github.com/TomHarte/CLK.git
synced 2024-07-05 10:28:58 +00:00
Made an attempt not to interrupt the display link queue too much when emulation is running slowly.
This commit is contained in:
parent
729fddea1c
commit
4595741ab0
@ -13,6 +13,7 @@
|
|||||||
@implementation CSOpenGLView {
|
@implementation CSOpenGLView {
|
||||||
CVDisplayLinkRef _displayLink;
|
CVDisplayLinkRef _displayLink;
|
||||||
uint32_t _updateIsOngoing;
|
uint32_t _updateIsOngoing;
|
||||||
|
int _missedFrames;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)prepareOpenGL
|
- (void)prepareOpenGL
|
||||||
@ -55,6 +56,7 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
|
|||||||
const uint32_t activityMask = 0x01;
|
const uint32_t activityMask = 0x01;
|
||||||
if(!OSAtomicTestAndSet(activityMask, &_updateIsOngoing))
|
if(!OSAtomicTestAndSet(activityMask, &_updateIsOngoing))
|
||||||
{
|
{
|
||||||
|
_missedFrames = 0;
|
||||||
CVTimeStamp time = *now;
|
CVTimeStamp time = *now;
|
||||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
|
||||||
[self.delegate openGLView:self didUpdateToTime:time];
|
[self.delegate openGLView:self didUpdateToTime:time];
|
||||||
@ -64,7 +66,14 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[self drawViewOnlyIfDirty:YES];
|
_missedFrames++;
|
||||||
|
if(_missedFrames == 10)
|
||||||
|
{
|
||||||
|
_missedFrames = 0;
|
||||||
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
|
||||||
|
[self drawViewOnlyIfDirty:YES];
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user