-
- All Implemented Interfaces:
-
com.facebook.imagepipeline.animated.base.AnimatedDrawableBackend
public class AnimatedDrawableBackendImpl implements AnimatedDrawableBackend
An AnimatedDrawableBackend that renders AnimatedImage.
-
-
Constructor Summary
Constructors Constructor Description AnimatedDrawableBackendImpl(AnimatedDrawableUtil animatedDrawableUtil, AnimatedImageResult animatedImageResult, Rect bounds, boolean downscaleFrameToDrawableDimensions)
-
Method Summary
Modifier and Type Method Description AnimatedImageResultgetAnimatedImageResult()Gets the original result of the decode. intgetDurationMs()Gets the duration of the animation. intgetFrameCount()Gets the number of frames in the animation. intgetLoopCount()Gets the number of loops to run the animation for. intgetWidth()Gets the width of the image. intgetHeight()Gets the height of the image. intgetRenderedWidth()Gets the rendered width of the image. intgetRenderedHeight()Gets the rendered height of the image. AnimatedDrawableFrameInfogetFrameInfo(int frameNumber)Gets info about the specified frame. intgetFrameForTimestampMs(int timestampMs)Gets the frame index for specified timestamp. intgetTimestampMsForFrame(int frameNumber)Gets the timestamp relative to the first frame that this frame number starts at. intgetDurationMsForFrame(int frameNumber)Gets the duration of the specified frame. intgetFrameForPreview()Gets the frame number to use for the preview frame. AnimatedDrawableBackendforNewBounds(@Nullable() Rect bounds)Creates a new AnimatedDrawableBackend with the same parameters but with a new bounds. synchronized intgetMemoryUsage()Gets the number of bytes currently used by the backend for caching (for debugging) CloseableReference<Bitmap>getPreDecodedFrame(int frameNumber)Gets a pre-decoded frame. booleanhasPreDecodedFrame(int index)Gets whether it has the decoded frame. voidrenderFrame(int frameNumber, Canvas canvas)Renders the specified frame onto the canvas. voidrenderDeltas(int frameNumber, Canvas canvas)Renders the specified frame onto the canvas. synchronized voiddropCaches()Instructs the backend to drop its caches. -
-
Constructor Detail
-
AnimatedDrawableBackendImpl
AnimatedDrawableBackendImpl(AnimatedDrawableUtil animatedDrawableUtil, AnimatedImageResult animatedImageResult, Rect bounds, boolean downscaleFrameToDrawableDimensions)
-
-
Method Detail
-
getAnimatedImageResult
AnimatedImageResult getAnimatedImageResult()
Gets the original result of the decode.
-
getDurationMs
int getDurationMs()
Gets the duration of the animation.
-
getFrameCount
int getFrameCount()
Gets the number of frames in the animation.
-
getLoopCount
int getLoopCount()
Gets the number of loops to run the animation for.
-
getWidth
int getWidth()
Gets the width of the image.
-
getHeight
int getHeight()
Gets the height of the image.
-
getRenderedWidth
int getRenderedWidth()
Gets the rendered width of the image. This may be smaller than the underlying image width ifthe image is being rendered to a small bounds or to reduce memory requirements.
-
getRenderedHeight
int getRenderedHeight()
Gets the rendered height of the image. This may be smaller than the underlying image height ifthe image is being rendered to a small bounds or to reduce memory requirements.
-
getFrameInfo
AnimatedDrawableFrameInfo getFrameInfo(int frameNumber)
Gets info about the specified frame.
- Parameters:
frameNumber- the frame number (0-based)
-
getFrameForTimestampMs
int getFrameForTimestampMs(int timestampMs)
Gets the frame index for specified timestamp.
- Parameters:
timestampMs- the timestamp
-
getTimestampMsForFrame
int getTimestampMsForFrame(int frameNumber)
Gets the timestamp relative to the first frame that this frame number starts at.
- Parameters:
frameNumber- the frame number
-
getDurationMsForFrame
int getDurationMsForFrame(int frameNumber)
Gets the duration of the specified frame.
- Parameters:
frameNumber- the frame number
-
getFrameForPreview
int getFrameForPreview()
Gets the frame number to use for the preview frame.
-
forNewBounds
AnimatedDrawableBackend forNewBounds(@Nullable() Rect bounds)
Creates a new AnimatedDrawableBackend with the same parameters but with a new bounds.
- Parameters:
bounds- the bounds
-
getMemoryUsage
synchronized int getMemoryUsage()
Gets the number of bytes currently used by the backend for caching (for debugging)
-
getPreDecodedFrame
@Nullable() CloseableReference<Bitmap> getPreDecodedFrame(int frameNumber)
Gets a pre-decoded frame. This will only return non-null if the
{@code ImageDecodeOptions}wereconfigured to decode all frames at decode time.- Parameters:
frameNumber- the index of the frame to get
-
hasPreDecodedFrame
boolean hasPreDecodedFrame(int index)
Gets whether it has the decoded frame. This will only return true if the
{@code * ImageDecodeOptions}were configured to decode all frames at decode time.
-
renderFrame
void renderFrame(int frameNumber, Canvas canvas)
Renders the specified frame onto the canvas.
- Parameters:
frameNumber- the frame number (0-based)canvas- the canvas to render onto
-
renderDeltas
void renderDeltas(int frameNumber, Canvas canvas)
Renders the specified frame onto the canvas. The idea is the same than renderFrame(...) withthis differences: 1) Creates a new bitmap on each call. This allows to not block threads. 2)Blend is applied here
- Parameters:
frameNumber- the frame number (0-based)canvas- the canvas to render onto
-
dropCaches
synchronized void dropCaches()
Instructs the backend to drop its caches.
-
-
-
-