Remove old GIF code (#25636)

Summary:
[After we migrated to new GIF implementation](https://github.com/facebook/react-native/pull/24822), we can remove old implementation now.

## Changelog

[iOS] [Deprecated] - Remove old GIF code
Pull Request resolved: https://github.com/facebook/react-native/pull/25636

Test Plan: GIF still works.

Reviewed By: shergin

Differential Revision: D16280044

Pulled By: osdnk

fbshipit-source-id: 00979280e6c17c93859ce886dd563b0d185c84aa
This commit is contained in:
zhongwuzw
2019-07-23 07:04:34 -07:00
committed by Facebook Github Bot
parent 84f5ebe4f9
commit cf77067f0c
4 changed files with 5 additions and 36 deletions
-2
View File
@@ -52,8 +52,6 @@ typedef dispatch_block_t RCTImageLoaderCancellationBlock;
@interface UIImage (React)
@property (nonatomic, copy) CAKeyframeAnimation *reactKeyframeAnimation;
/**
* Memory bytes of the image with the default calculation of static image or GIF. Custom calculations of decoded bytes can be assigned manually.
*/
+1 -18
View File
@@ -22,27 +22,12 @@
static NSInteger RCTImageBytesForImage(UIImage *image)
{
CAKeyframeAnimation *keyFrameAnimation = [image reactKeyframeAnimation];
NSInteger singleImageBytes = image.size.width * image.size.height * image.scale * image.scale * 4;
if (keyFrameAnimation) {
return keyFrameAnimation.values.count * singleImageBytes;
} else {
return image.images ? image.images.count * singleImageBytes : singleImageBytes;
}
return image.images ? image.images.count * singleImageBytes : singleImageBytes;
}
@implementation UIImage (React)
- (CAKeyframeAnimation *)reactKeyframeAnimation
{
return objc_getAssociatedObject(self, _cmd);
}
- (void)setReactKeyframeAnimation:(CAKeyframeAnimation *)reactKeyframeAnimation
{
objc_setAssociatedObject(self, @selector(reactKeyframeAnimation), reactKeyframeAnimation, OBJC_ASSOCIATION_COPY_NONATOMIC);
}
- (NSInteger)reactDecodedImageBytes
{
NSNumber *imageBytes = objc_getAssociatedObject(self, _cmd);
@@ -280,11 +265,9 @@ static UIImage *RCTResizeImageIfNeeded(UIImage *image,
CGSizeEqualToSize(image.size, size)) {
return image;
}
CAKeyframeAnimation *animation = image.reactKeyframeAnimation;
CGRect targetSize = RCTTargetRect(image.size, size, scale, resizeMode);
CGAffineTransform transform = RCTTransformFromTargetRect(image.size, targetSize);
image = RCTTransformImage(image, size, scale, transform);
image.reactKeyframeAnimation = animation;
return image;
}
+1 -13
View File
@@ -224,7 +224,6 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame)
- (void)clearImage
{
[self cancelImageLoad];
[_imageView.layer removeAnimationForKey:@"contents"];
self.image = nil;
_imageSource = nil;
}
@@ -363,18 +362,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame)
self->_pendingImageSource = nil;
}
[self->_imageView.layer removeAnimationForKey:@"contents"];
if (image.reactKeyframeAnimation) {
CGImageRef posterImageRef = (__bridge CGImageRef)[image.reactKeyframeAnimation.values firstObject];
if (!posterImageRef) {
return;
}
// Apply renderingMode to animated image.
self->_imageView.image = [[UIImage imageWithCGImage:posterImageRef] imageWithRenderingMode:self->_renderingMode];
[self->_imageView.layer addAnimation:image.reactKeyframeAnimation forKey:@"contents"];
} else {
self.image = image;
}
self.image = image;
if (isPartialLoad) {
if (self->_onPartialLoad) {
+3 -3
View File
@@ -85,11 +85,11 @@ static NSUInteger RCTDeviceFreeMemory() {
if (self.image == image) {
return;
}
[self stop];
[self resetAnimatedImage];
if ([image respondsToSelector:@selector(animatedImageFrameAtIndex:)]) {
[self stop];
[self resetAnimatedImage];
NSUInteger animatedImageFrameCount = ((UIImage<RCTAnimatedImage> *)image).animatedImageFrameCount;
// In case frame count is 0, there is no reason to continue.