Generalized image decoding and resizing logic

Summary:
public

Standardises the image decoding logic for all image sources, meaning we get the benefits of efficient downscaling of images from all sources, not just ALAssets.

Reviewed By: javache

Differential Revision: D2647083

fb-gh-sync-id: e41456f838e4c6ab709b1c1523f651a86ff6e623
This commit is contained in:
Nick Lockwood
2016-01-20 11:03:22 -08:00
committed by facebook-github-bot-5
parent 9b87e6c860
commit 21fcbbc32c
30 changed files with 510 additions and 379 deletions

View File

@@ -11,6 +11,7 @@
#import "RCTBridge.h"
#import "RCTURLRequestHandler.h"
#import "RCTResizeMode.h"
@class ALAssetsLibrary;
@@ -40,10 +41,20 @@ typedef void (^RCTImageLoaderCancellationBlock)(void);
- (RCTImageLoaderCancellationBlock)loadImageWithTag:(NSString *)imageTag
size:(CGSize)size
scale:(CGFloat)scale
resizeMode:(UIViewContentMode)resizeMode
resizeMode:(RCTResizeMode)resizeMode
progressBlock:(RCTImageLoaderProgressBlock)progressBlock
completionBlock:(RCTImageLoaderCompletionBlock)completionBlock;
/**
* Loads an image without clipping the result to fit - used by RCTImageView.
*/
- (RCTImageLoaderCancellationBlock)loadImageWithoutClipping:(NSString *)imageTag
size:(CGSize)size
scale:(CGFloat)scale
resizeMode:(RCTResizeMode)resizeMode
progressBlock:(RCTImageLoaderProgressBlock)progressBlock
completionBlock:(RCTImageLoaderCompletionBlock)completionBlock;
/**
* Finds an appropriate image decoder and passes the target size, scale and
* resizeMode for optimal image decoding. Can be called from any thread,
@@ -52,7 +63,7 @@ typedef void (^RCTImageLoaderCancellationBlock)(void);
- (RCTImageLoaderCancellationBlock)decodeImageData:(NSData *)imageData
size:(CGSize)size
scale:(CGFloat)scale
resizeMode:(UIViewContentMode)resizeMode
resizeMode:(RCTResizeMode)resizeMode
completionBlock:(RCTImageLoaderCompletionBlock)completionBlock;
/**
@@ -96,7 +107,7 @@ typedef void (^RCTImageLoaderCancellationBlock)(void);
- (RCTImageLoaderCancellationBlock)loadImageForURL:(NSURL *)imageURL
size:(CGSize)size
scale:(CGFloat)scale
resizeMode:(UIViewContentMode)resizeMode
resizeMode:(RCTResizeMode)resizeMode
progressHandler:(RCTImageLoaderProgressBlock)progressHandler
completionHandler:(RCTImageLoaderCompletionBlock)completionHandler;
@@ -134,7 +145,7 @@ typedef void (^RCTImageLoaderCancellationBlock)(void);
- (RCTImageLoaderCancellationBlock)decodeImageData:(NSData *)imageData
size:(CGSize)size
scale:(CGFloat)scale
resizeMode:(UIViewContentMode)resizeMode
resizeMode:(RCTResizeMode)resizeMode
completionHandler:(RCTImageLoaderCompletionBlock)completionHandler;
@optional