Skip to content

Commit

Permalink
Remove parameter restrictions for PAGDecoder and PAGImageView on the …
Browse files Browse the repository at this point in the history
…iOS platform. (#2456)
  • Loading branch information
kevingpqi123 authored Sep 2, 2024
1 parent 97f920c commit eb1b41e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 29 deletions.
8 changes: 2 additions & 6 deletions src/platform/ios/PAGDecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
#import <UIKit/UIKit.h>
#import "PAGComposition.h"

NS_ASSUME_NONNULL_BEGIN

/**
* PAGDecoder provides a utility to read image frames directly from a PAGComposition, and caches the
* image frames as a sequence file on the disk, which may significantly speed up the reading process
Expand Down Expand Up @@ -86,14 +84,14 @@ PAG_API @interface PAGDecoder : NSObject
* if failed. Note that caller must ensure that the rowBytes stays the same throughout every copying
* call. Otherwise, it may return false.
*/
- (BOOL)copyFrameTo:(void*)pixels rowBytes:(size_t)rowBytes at:(NSInteger)index;
- (BOOL)copyFrameTo:(void* _Nonnull)pixels rowBytes:(size_t)rowBytes at:(NSInteger)index;

/**
* Reads pixels of the image frame at the given index into the specified CVPixelBuffer. Returns
* false if failed. Reading image frames into HardwareBuffer usually has better performance than
* reading into memory.
*/
- (BOOL)readFrame:(NSInteger)index to:(CVPixelBufferRef)pixelBuffer;
- (BOOL)readFrame:(NSInteger)index to:(CVPixelBufferRef _Nonnull)pixelBuffer;

/**
* Returns the image frame at the specified index. Note that this method must be called while the
Expand All @@ -103,5 +101,3 @@ PAG_API @interface PAGDecoder : NSObject
- (nullable UIImage*)frameAtIndex:(NSInteger)index;

@end

NS_ASSUME_NONNULL_END
35 changes: 16 additions & 19 deletions src/platform/ios/PAGImageView.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
#import <UIKit/UIKit.h>
#import "PAGComposition.h"

NS_ASSUME_NONNULL_BEGIN

@class PAGImageView;

@protocol PAGImageViewListener <NSObject>
Expand All @@ -30,29 +28,29 @@ NS_ASSUME_NONNULL_BEGIN
* Notifies the beginning of the animation. It can be called from either the UI thread or the thread
* that calls the play method.
*/
- (void)onAnimationStart:(PAGImageView*)pagView;
- (void)onAnimationStart:(PAGImageView* _Nonnull)pagView;

/**
* Notifies the end of the animation. It can only be called from the UI thread.
*/
- (void)onAnimationEnd:(PAGImageView*)pagView;
- (void)onAnimationEnd:(PAGImageView* _Nonnull)pagView;

/**
* Notifies the cancellation of the animation. It can be called from either the UI thread or the
* thread that calls the stop method.
*/
- (void)onAnimationCancel:(PAGImageView*)pagView;
- (void)onAnimationCancel:(PAGImageView* _Nonnull)pagView;

/**
* Notifies the repetition of the animation. It can only be called from the UI thread.
*/
- (void)onAnimationRepeat:(PAGImageView*)pagView;
- (void)onAnimationRepeat:(PAGImageView* _Nonnull)pagView;

/**
* Notifies another frame of the animation has occurred. It may be called from an arbitrary
* thread if the animation is running asynchronously.
*/
- (void)onAnimationUpdate:(PAGImageView*)pagView;
- (void)onAnimationUpdate:(PAGImageView* _Nonnull)pagView;

@end

Expand Down Expand Up @@ -82,14 +80,14 @@ PAG_API @interface PAGImageView : UIImageView
* composition is already added to another PAGImageView, it will be removed from the previous
* PAGImageView.
*/
- (void)setComposition:(PAGComposition*)newComposition;
- (void)setComposition:(nullable PAGComposition*)newComposition;

/**
* Sets a new PAGComposition and the maxFrameRate limit to the PAGImageView. Note: If the
* composition is already added to another PAGImageView, it will be removed from the previous
* PAGImageView.
*/
- (void)setComposition:(PAGComposition*)newComposition maxFrameRate:(float)maxFrameRate;
- (void)setComposition:(nullable PAGComposition*)newComposition maxFrameRate:(float)maxFrameRate;

/**
* Returns the file path set by the setPath() method.
Expand All @@ -100,27 +98,28 @@ PAG_API @interface PAGImageView : UIImageView
* Loads a pag file from the specified path, returns false if the file does not exist, or it is not
* a valid pag file.
*/
- (BOOL)setPath:(NSString*)path;
- (BOOL)setPath:(nullable NSString*)path;
/**
* Loads a pag file from the specified path with the maxFrameRate limit, returns false if the file
* does not exist, or it is not a valid pag file.
*/
- (BOOL)setPath:(NSString*)filePath maxFrameRate:(float)maxFrameRate;
- (BOOL)setPath:(nullable NSString*)filePath maxFrameRate:(float)maxFrameRate;

/**
* Asynchronously load a PAG file from the specific path, a block with PAGFile will be called
* when loading is complete. If loading fails, PAGFile will be set to nil.
*/
- (void)setPathAsync:(NSString*)filePath completionBlock:(void (^)(PAGFile* __nullable))callback;
- (void)setPathAsync:(nullable NSString*)filePath
completionBlock:(void (^_Nullable)(PAGFile* __nullable))callback;

/**
* Asynchronously load a PAG file from the specific path with the maxFrameRate limit, a block
* with PAGFile will be called when loading is complete. If loading fails, PAGFile will be set to
* nil.
*/
- (void)setPathAsync:(NSString*)filePath
- (void)setPathAsync:(nullable NSString*)filePath
maxFrameRate:(float)maxFrameRate
completionBlock:(void (^)(PAGFile* __nullable))callback;
completionBlock:(void (^_Nullable)(PAGFile* __nullable))callback;

/**
* If set to true, the PAGImageView loads all image frames into the memory, which will significantly
Expand Down Expand Up @@ -163,12 +162,12 @@ PAG_API @interface PAGImageView : UIImageView
* Adds a listener to the set of listeners that are sent events through the life of an animation,
* such as start, repeat, and end. PAGImageView only holds a weak reference to the listener.
*/
- (void)addListener:(id<PAGImageViewListener>)listener;
- (void)addListener:(nullable id<PAGImageViewListener>)listener;

/**
* Removes the specified listener from the set of listeners
*/
- (void)removeListener:(id<PAGImageViewListener>)listener;
- (void)removeListener:(nullable id<PAGImageViewListener>)listener;

/**
* Returns the current frame index the PAGImageView is rendering.
Expand All @@ -189,7 +188,7 @@ PAG_API @interface PAGImageView : UIImageView
/**
* Returns a UIImage capturing the contents of the current PAGImageView.
*/
- (UIImage*)currentImage;
- (nullable UIImage*)currentImage;

/**
* Starts to play the animation from the current position. Calling the play() method when the
Expand Down Expand Up @@ -219,5 +218,3 @@ PAG_API @interface PAGImageView : UIImageView
- (BOOL)flush;

@end

NS_ASSUME_NONNULL_END
4 changes: 0 additions & 4 deletions src/platform/ios/private/PAGContentVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@
#import "platform/cocoa/PAGComposition.h"
#import "platform/ios/PAGDecoder.h"

NS_ASSUME_NONNULL_BEGIN

@interface PAGContentVersion : NSObject
+ (NSInteger)Get:(PAGComposition*)pagComposition;

@end

NS_ASSUME_NONNULL_END

0 comments on commit eb1b41e

Please sign in to comment.