Enable animated gif playback on Mac (#724)
* enable gif for mac Summary: I verify that it works for Zeratul as well. It also works regardless turbo module is enabled or not. Test Plan: |{F369886201}|{F369889196}| Reviewers: skyle Reviewed By: skyle Subscribers: zackargyle Differential Revision: https://phabricator.intern.facebook.com/D26272145 Tasks: T82742678 Signature: 26272145:1612513052:520a8b0b3ab4b211c953b3225c6c96ffb8a29fc5 * bypass setImage logic when it is Mac Summary: as titled Test Plan: {F370138978} {F370139033} Reviewers: skyle Reviewed By: skyle Subscribers: zackargyle Differential Revision: https://phabricator.intern.facebook.com/D26288169 Signature: 26288169:1612565769:8f779fe01614e3399ac3e484853bb61246210ff4 * address PR comments * address PR comments 1 Co-authored-by: Mo Wang <mowang@fb.com>
This commit is contained in:
Родитель
d3bc15d494
Коммит
068ed05f32
|
@ -42,14 +42,14 @@
|
|||
|
||||
_imageSource = imageSource;
|
||||
|
||||
#if TARGET_OS_OSX // [TODO(macOS ISS#2323203)
|
||||
self = [super initWithData:data];
|
||||
#else // ]TODO(macOS ISS#2323203)
|
||||
// grab image at the first index
|
||||
UIImage *image = [self animatedImageFrameAtIndex:0];
|
||||
if (!image) {
|
||||
return nil;
|
||||
}
|
||||
#if TARGET_OS_OSX // [TODO(macOS ISS#2323203)
|
||||
self = [image copy];
|
||||
#else // ]TODO(macOS ISS#2323203)
|
||||
self = [super initWithCGImage:image.CGImage scale:MAX(scale, 1) orientation:image.imageOrientation];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveMemoryWarning:) name:UIApplicationDidReceiveMemoryWarningNotification object:nil];
|
||||
|
|
|
@ -89,10 +89,10 @@ static NSUInteger RCTDeviceFreeMemory() {
|
|||
return;
|
||||
}
|
||||
|
||||
#if !TARGET_OS_OSX // TODO(macOS ISS#2323203)
|
||||
#if TARGET_OS_OSX
|
||||
[super setImage:image];
|
||||
#else // TODO(macOS ISS#2323203)
|
||||
[self stop];
|
||||
#endif // TODO(macOS ISS#2323203)
|
||||
|
||||
[self resetAnimatedImage];
|
||||
|
||||
if ([image respondsToSelector:@selector(animatedImageFrameAtIndex:)]) {
|
||||
|
@ -116,19 +116,18 @@ static NSUInteger RCTDeviceFreeMemory() {
|
|||
self.frameBuffer[@(self.currentFrameIndex)] = self.currentFrame;
|
||||
dispatch_semaphore_signal(self.lock);
|
||||
|
||||
#if !TARGET_OS_OSX // TODO(macOS ISS#2323203)
|
||||
// Calculate max buffer size
|
||||
[self calculateMaxBufferCount];
|
||||
|
||||
if ([self paused]) {
|
||||
[self start];
|
||||
}
|
||||
#endif // TODO(macOS ISS#2323203)
|
||||
|
||||
[self.layer setNeedsDisplay];
|
||||
} else {
|
||||
super.image = image;
|
||||
}
|
||||
#endif // TODO(macOS ISS#2323203)
|
||||
}
|
||||
|
||||
#pragma mark - Private
|
||||
|
|
|
@ -842,7 +842,7 @@ exports.examples = [
|
|||
/>
|
||||
);
|
||||
},
|
||||
platform: 'ios',
|
||||
platform: ['ios', 'macos'], // TODO(OSS Candidate ISS#2710739)
|
||||
},
|
||||
{
|
||||
title: 'Base64 image',
|
||||
|
|
Загрузка…
Ссылка в новой задаче