mirror of
https://github.com/TextureGroup/Texture.git
synced 2026-04-07 19:17:39 +00:00
Updating to support animated WebP
This commit is contained in:
committed by
Garrett Moon
parent
c6e3dd7a5d
commit
01bb2afa6c
@@ -24,14 +24,20 @@
|
||||
#import <AsyncDisplayKit/ASThread.h>
|
||||
#import <AsyncDisplayKit/ASImageContainerProtocolCategories.h>
|
||||
|
||||
#if __has_include (<PINRemoteImage/PINAnimatedImage.h>)
|
||||
#if __has_include (<PINRemoteImage/PINGIFAnimatedImage.h>)
|
||||
#define PIN_ANIMATED_AVAILABLE 1
|
||||
#import <PINRemoteImage/PINAnimatedImage.h>
|
||||
#import <PINRemoteImage/PINCachedAnimatedImage.h>
|
||||
#import <PINRemoteImage/PINAlternateRepresentationProvider.h>
|
||||
#else
|
||||
#define PIN_ANIMATED_AVAILABLE 0
|
||||
#endif
|
||||
|
||||
#if __has_include(<webp/decode.h>)
|
||||
#define PIN_WEBP_AVAILABLE 1
|
||||
#else
|
||||
#define PIN_WEBP_AVAILABLE 0
|
||||
#endif
|
||||
|
||||
#import <PINRemoteImage/PINRemoteImageManager.h>
|
||||
#import <PINRemoteImage/NSData+ImageDetectors.h>
|
||||
#import <PINRemoteImage/PINRemoteImageCaching.h>
|
||||
@@ -42,35 +48,23 @@
|
||||
|
||||
@end
|
||||
|
||||
@interface PINAnimatedImage (ASPINRemoteImageDownloader) <ASAnimatedImageProtocol>
|
||||
@interface PINCachedAnimatedImage (ASPINRemoteImageDownloader) <ASAnimatedImageProtocol>
|
||||
|
||||
@end
|
||||
|
||||
@implementation PINAnimatedImage (ASPINRemoteImageDownloader)
|
||||
|
||||
- (void)setCoverImageReadyCallback:(void (^)(UIImage * _Nonnull))coverImageReadyCallback
|
||||
{
|
||||
self.infoCompletion = coverImageReadyCallback;
|
||||
}
|
||||
|
||||
- (void (^)(UIImage * _Nonnull))coverImageReadyCallback
|
||||
{
|
||||
return self.infoCompletion;
|
||||
}
|
||||
|
||||
- (void)setPlaybackReadyCallback:(dispatch_block_t)playbackReadyCallback
|
||||
{
|
||||
self.fileReady = playbackReadyCallback;
|
||||
}
|
||||
|
||||
- (dispatch_block_t)playbackReadyCallback
|
||||
{
|
||||
return self.fileReady;
|
||||
}
|
||||
@implementation PINCachedAnimatedImage (ASPINRemoteImageDownloader)
|
||||
|
||||
- (BOOL)isDataSupported:(NSData *)data
|
||||
{
|
||||
return [data pin_isGIF];
|
||||
if ([data pin_isGIF]) {
|
||||
return YES;
|
||||
}
|
||||
#if PIN_WEBP_AVAILABLE
|
||||
else if ([data pin_isAnimatedWebP]) {
|
||||
return YES;
|
||||
}
|
||||
#endif
|
||||
return NO;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -187,7 +181,7 @@ static ASPINRemoteImageDownloader *sharedDownloader = nil;
|
||||
#if PIN_ANIMATED_AVAILABLE
|
||||
- (nullable id <ASAnimatedImageProtocol>)animatedImageWithData:(NSData *)animatedImageData
|
||||
{
|
||||
return [[PINAnimatedImage alloc] initWithAnimatedImageData:animatedImageData];
|
||||
return [[PINCachedAnimatedImage alloc] initWithAnimatedImageData:animatedImageData];
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -365,6 +359,12 @@ static ASPINRemoteImageDownloader *sharedDownloader = nil;
|
||||
if ([data pin_isGIF]) {
|
||||
return data;
|
||||
}
|
||||
#if PIN_WEBP_AVAILABLE
|
||||
else if ([data pin_isAnimatedWebP]) {
|
||||
return data;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
return nil;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,9 @@
|
||||
// Do any additional setup after loading the view, typically from a nib.
|
||||
|
||||
ASNetworkImageNode *imageNode = [[ASNetworkImageNode alloc] init];
|
||||
imageNode.URL = [NSURL URLWithString:@"https://s-media-cache-ak0.pinimg.com/originals/07/44/38/074438e7c75034df2dcf37ba1057803e.gif"];
|
||||
// imageNode.URL = [NSURL URLWithString:@"https://s-media-cache-ak0.pinimg.com/originals/07/44/38/074438e7c75034df2dcf37ba1057803e.gif"];
|
||||
imageNode.URL = [NSURL URLWithString:@"https://storage.googleapis.com/downloads.webmproject.org/webp/images/dancing_banana2.lossless.webp"];
|
||||
// imageNode.URL = [NSURL URLWithString:@"https://res.cloudinary.com/demo/image/upload/fl_awebp/bored_animation.webp"];
|
||||
imageNode.frame = self.view.bounds;
|
||||
imageNode.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
||||
imageNode.contentMode = UIViewContentModeScaleAspectFit;
|
||||
|
||||
@@ -2,5 +2,8 @@ source 'https://github.com/CocoaPods/Specs.git'
|
||||
platform :ios, '8.0'
|
||||
target 'Sample' do
|
||||
pod 'Texture', :path => '../..'
|
||||
# DO NOT COMMIT!
|
||||
pod 'PINRemoteImage', :path => '~/Development/PINRemoteImage'
|
||||
pod 'PINRemoteImage/WebP', :path => '~/Development/PINRemoteImage'
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user