Skip to content

Commit

Permalink
Push From Landun: update SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
libpag-pag committed Nov 3, 2023
1 parent 84e59a0 commit e919889
Show file tree
Hide file tree
Showing 19 changed files with 135 additions and 355 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,6 @@ PAG_API @interface PAGDecoder : NSObject
*/
- (float)frameRate;

/**
* Returns true if the frame at the given index has changed since the last copyFrameTo(),
* readFrameTo(), or frameAtIndex() call. The caller should skip the corresponding call if
* the frame has not changed.
*/
- (BOOL)checkFrameChanged:(int)index;

/**
* Copies pixels of the image frame at the given index to the specified memory address. The format
* of the copied pixels is in the BGRA color type with the premultiplied alpha type. Returns false
Expand All @@ -88,13 +81,6 @@ PAG_API @interface PAGDecoder : NSObject
*/
- (BOOL)copyFrameTo:(void*)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;

/**
* Returns the image frame at the specified index. Note that this method must be called while the
* app is not in the background. Otherwise, it may return nil because the GPU code may not be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ PAG_API @interface PAGFile : PAGComposition
*/
+ (PAGFile*)Load:(NSString*)path;

/**
* Asynchronously load a PAG file from the specific path, a block with PAGFile will be called
* when loading is complete.
*/
+ (void)LoadAsync:(NSString*)path completionBlock:(void (^)(PAGFile*))callback;

/**
* Load a pag file from byte data, return null if the bytes is empty or it's not a valid pag file.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,27 @@ NS_ASSUME_NONNULL_BEGIN

@optional
/**
* Notifies the beginning of the animation. It can be called from either the UI thread or the thread
* that calls the play method.
* Notifies the beginning of the animation.
*/
- (void)onAnimationStart:(PAGImageView*)pagView;

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

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

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

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

Expand Down Expand Up @@ -107,21 +104,6 @@ PAG_API @interface PAGImageView : UIImageView
*/
- (BOOL)setPath:(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*))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
maxFrameRate:(float)maxFrameRate
completionBlock:(void (^)(PAGFile*))callback;

/**
* If set to true, the PAGImageView loads all image frames into the memory, which will significantly
* increase the rendering performance but may cost lots of additional memory. Use it when you prefer
Expand All @@ -148,20 +130,14 @@ PAG_API @interface PAGImageView : UIImageView
- (void)setRenderScale:(float)scale;

/**
* The total number of times the animation is set to play. The default is 1, which means the
* animation will play only once. If the repeat count is set to 0 or a negative value, the
* animation will play infinity times.
*/
- (int)repeatCount;

/**
* Set the number of times the animation to play.
* Set the number of times the animation will repeat. The default is 1, which means the animation
* will play only once. 0 means the animation will play infinity times.
*/
- (void)setRepeatCount:(int)repeatCount;

/**
* 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.
* such as start, repeat, and end.
*/
- (void)addListener:(id<PAGImageViewListener>)listener;

Expand Down Expand Up @@ -192,16 +168,13 @@ PAG_API @interface PAGImageView : UIImageView
- (UIImage*)currentImage;

/**
* Starts to play the animation from the current position. Calling the play() method when the
* animation is already playing has no effect. The play() method does not alter the animation's
* current position. However, if the animation previously reached its end, it will restart from
* the beginning.
* Starts to play the animation.
*/
- (void)play;

/**
* Cancels the animation at the current position. Calling the play() method can resume the animation
* from the last paused position.
* Pauses the animation at the current playing position. Calling the play method can resume the
* animation from the last paused playing position.
*/
- (void)pause;

Expand All @@ -211,10 +184,10 @@ PAG_API @interface PAGImageView : UIImageView
- (BOOL)isPlaying;

/**
* Call this method to render current position immediately. Note that all the changes previously
* made to the PAGImageView will only take effect after this method is called. If the play() method
* is already called, there is no need to call it manually since it will be automatically called
* every frame. Returns true if the content has changed.
* Renders the current image frame immediately. Note that all the changes previously made to the
* PAGImageView will only take effect after this method is called. If the play() method is already
* called, there is no need to call it manually since it will be automatically called every frame.
* Returns true if the content has changed.
*/
- (BOOL)flush;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ PAG_API @interface PAGLayer : NSObject
- (PAGLayer*)trackMatteLayer;

/**
* Returns a rectangle int pixels that defines the original area of the layer, which is not
* transformed by the matrix.
* Returns a rectangle that defines the original area of the layer, which is not transformed by the
* matrix.
*/
- (CGRect)getBounds;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,6 @@ PAG_API @interface PAGPlayer : NSObject
*/
- (void)setCacheEnabled:(BOOL)value;

/**
* If set to true, PAG will cache the associated rendering data into a disk file, such as the
* decoded image frames of video compositions. This can help reduce memory usage and improve
* rendering performance.
*/
- (BOOL)useDiskCache;

/**
* Set the value of useDiskCache property.
*/
- (void)setUseDiskCache:(BOOL)value;

/**
* This value defines the scale factor for internal graphics caches, ranges from 0.0 to 1.0. The
* scale factors less than 1.0 may result in blurred output, but it can reduce the usage of graphics
Expand Down Expand Up @@ -161,8 +149,8 @@ PAG_API @interface PAGPlayer : NSObject
- (BOOL)flush;

/**
* Returns a rectangle in pixels that defines the displaying area of the specified layer, which is
* in the coordinate of the PAGSurface.
* Returns a rectangle that defines the displaying area of the specified layer, which is in the
* coordinate of the PAGSurface.
*/
- (CGRect)getBounds:(PAGLayer*)pagLayer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,13 @@ PAG_API @interface PAGSurface : NSObject
+ (PAGSurface*)FromCVPixelBuffer:(CVPixelBufferRef)pixelBuffer context:(EAGLContext*)eaglContext;

/**
* [Deprecated](Please use [PAGSurface MakeOffscreen] instead)
* Creates an offscreen PAGSurface of the specified size for pixel reading.
* [Deprecated] Please use MakeOffscreen:size instead.
*/
+ (PAGSurface*)MakeFromGPU:(CGSize)size
DEPRECATED_MSG_ATTRIBUTE("Please use [PAGSurface MakeOffscreen] instead.");
+ (PAGSurface*)MakeFromGPU:(CGSize)size;

/**
* Creates an offscreen PAGSurface of the specified size for pixel reading.
* Creates a offscreen PAGSurface of specified size. PAGSurface internally creates a CVPixelBuffer
* which can be accessed by [PAGSurface getCVPixelBuffer] after the first [PAGPLayer flush].
*/
+ (PAGSurface*)MakeOffscreen:(CGSize)size;

Expand All @@ -61,12 +60,12 @@ PAG_API @interface PAGSurface : NSObject
- (int)width;

/**
* The height of the surface in pixels.
* The height of surface in pixels.
*/
- (int)height;

/**
* Update the size of the surface, and reset the internal surface.
* Update the size of surface, and reset the internal surface.
*/
- (void)updateSize;

Expand All @@ -82,8 +81,8 @@ PAG_API @interface PAGSurface : NSObject
- (void)freeCache;

/**
* Returns the internal CVPixelBuffer object associated with this PAGSurface, returns nil if the
* PAGSurface is created by [PAGSurface FromLayer], or the app is running in the simulator.
* Returns the internal CVPixelBuffer object associated with this PAGSurface, returns nil if this
* PAGSurface is created by [PAGSurface FromLayer].
*/
- (CVPixelBufferRef)getCVPixelBuffer;

Expand Down
Loading

0 comments on commit e919889

Please sign in to comment.