fix frame buffer bug when display link is pause

This commit is contained in:
kinarob 2019-07-05 21:14:03 +08:00
parent 5df70628be
commit 7605053cf5
1 changed files with 12 additions and 1 deletions

View File

@ -459,11 +459,13 @@ static NSUInteger SDDeviceFreeMemory() {
- (void)stopAnimating
{
if (self.animatedImage) {
SD_LOCK(self.lock);
#if SD_MAC
CVDisplayLinkStop(_displayLink);
#else
_displayLink.paused = YES;
#endif
SD_UNLOCK(self.lock);
} else {
#if SD_UIKIT
[super stopAnimating];
@ -665,8 +667,17 @@ static NSUInteger SDDeviceFreeMemory() {
UIImage<SDAnimatedImage> *animatedImage = self.animatedImage;
NSOperation *operation = [NSBlockOperation blockOperationWithBlock:^{
UIImage *frame = [animatedImage animatedImageFrameAtIndex:fetchFrameIndex];
BOOL displayLinkIsPaused = NO;
SD_LOCK(self.lock);
self.frameBuffer[@(fetchFrameIndex)] = frame;
#if SD_MAC
displayLinkIsPaused = !CVDisplayLinkIsRunning(_displayLink);
#else
displayLinkIsPaused = _displayLink.isPaused;
#endif
if (!displayLinkIsPaused) {
self.frameBuffer[@(fetchFrameIndex)] = frame;
}
SD_UNLOCK(self.lock);
}];
[self.fetchQueue addOperation:operation];