PINAnimatedImageManager.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. //
  2. // PINAnimatedImageManager.h
  3. // Pods
  4. //
  5. // Created by Garrett Moon on 4/5/16.
  6. //
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import "PINAnimatedImage.h"
  10. #import "PINRemoteImageMacros.h"
  11. @class PINRemoteLock;
  12. @class PINSharedAnimatedImage;
  13. @class PINSharedAnimatedImageFile;
  14. typedef void(^PINAnimatedImageSharedReady)(PINImage *coverImage, PINSharedAnimatedImage *shared);
  15. typedef void(^PINAnimatedImageDecodedPath)(BOOL finished, NSString *path, NSError *error);
  16. @interface PINAnimatedImageManager : NSObject
  17. + (instancetype)sharedManager;
  18. + (NSString *)temporaryDirectory;
  19. + (NSString *)filePathWithTemporaryDirectory:(NSString *)temporaryDirectory UUID:(NSUUID *)UUID count:(NSUInteger)count;
  20. - (void)animatedPathForImageData:(NSData *)animatedImageData infoCompletion:(PINAnimatedImageSharedReady)infoCompletion completion:(PINAnimatedImageDecodedPath)completion;
  21. @end
  22. @interface PINSharedAnimatedImage : NSObject
  23. {
  24. PINRemoteLock *_coverImageLock;
  25. }
  26. //This is intentionally atomic. PINAnimatedImageManager must be able to add entries
  27. //and clients must be able to read them concurrently.
  28. @property (atomic, strong, readwrite) NSArray <PINSharedAnimatedImageFile *> *maps;
  29. @property (nonatomic, strong, readwrite) NSArray <PINAnimatedImageDecodedPath> *completions;
  30. @property (nonatomic, strong, readwrite) NSArray <PINAnimatedImageSharedReady> *infoCompletions;
  31. @property (nonatomic, weak, readwrite) PINImage *coverImage;
  32. //intentionally atomic
  33. @property (atomic, strong, readwrite) NSError *error;
  34. @property (atomic, assign, readwrite) PINAnimatedImageStatus status;
  35. - (void)setInfoProcessedWithCoverImage:(PINImage *)coverImage
  36. UUID:(NSUUID *)UUID
  37. durations:(Float32 *)durations
  38. totalDuration:(CFTimeInterval)totalDuration
  39. loopCount:(size_t)loopCount
  40. frameCount:(size_t)frameCount
  41. width:(size_t)width
  42. height:(size_t)height
  43. bitsPerPixel:(size_t)bitsPerPixel
  44. bitmapInfo:(CGBitmapInfo)bitmapInfo;
  45. @property (nonatomic, readonly) NSUUID *UUID;
  46. @property (nonatomic, readonly) Float32 *durations;
  47. @property (nonatomic, readonly) CFTimeInterval totalDuration;
  48. @property (nonatomic, readonly) size_t loopCount;
  49. @property (nonatomic, readonly) size_t frameCount;
  50. @property (nonatomic, readonly) size_t width;
  51. @property (nonatomic, readonly) size_t height;
  52. @property (nonatomic, readonly) size_t bitsPerPixel;
  53. @property (nonatomic, readonly) CGBitmapInfo bitmapInfo;
  54. @end
  55. @interface PINSharedAnimatedImageFile : NSObject
  56. {
  57. PINRemoteLock *_lock;
  58. }
  59. @property (nonatomic, strong, readonly) NSString *path;
  60. @property (nonatomic, assign, readonly) UInt32 frameCount;
  61. @property (nonatomic, weak, readonly) NSData *memoryMappedData;
  62. - (instancetype)initWithPath:(NSString *)path NS_DESIGNATED_INITIALIZER;
  63. @end