Search in sources :

Example 1 with BitmapFramePreparationStrategy

use of com.facebook.fresco.animation.bitmap.preparation.BitmapFramePreparationStrategy in project fresco by facebook.

the class ExperimentalBitmapAnimationDrawableFactory method createAnimationBackend.

private AnimationBackend createAnimationBackend(AnimatedImageResult animatedImageResult, @Nullable Bitmap.Config animatedBitmapConig) {
    AnimatedDrawableBackend animatedDrawableBackend = createAnimatedDrawableBackend(animatedImageResult);
    BitmapFrameCache bitmapFrameCache = createBitmapFrameCache(animatedImageResult);
    BitmapFrameRenderer bitmapFrameRenderer = new AnimatedDrawableBackendFrameRenderer(bitmapFrameCache, animatedDrawableBackend);
    int numberOfFramesToPrefetch = mNumberOfFramesToPrepareSupplier.get();
    BitmapFramePreparationStrategy bitmapFramePreparationStrategy = null;
    BitmapFramePreparer bitmapFramePreparer = null;
    if (numberOfFramesToPrefetch > 0) {
        bitmapFramePreparationStrategy = new FixedNumberBitmapFramePreparationStrategy(numberOfFramesToPrefetch);
        bitmapFramePreparer = createBitmapFramePreparer(bitmapFrameRenderer, animatedBitmapConig);
    }
    BitmapAnimationBackend bitmapAnimationBackend = new BitmapAnimationBackend(mPlatformBitmapFactory, bitmapFrameCache, new AnimatedDrawableBackendAnimationInformation(animatedDrawableBackend), bitmapFrameRenderer, bitmapFramePreparationStrategy, bitmapFramePreparer);
    return AnimationBackendDelegateWithInactivityCheck.createForBackend(bitmapAnimationBackend, mMonotonicClock, mScheduledExecutorServiceForUiThread);
}
Also used : AnimatedDrawableBackend(com.facebook.imagepipeline.animated.base.AnimatedDrawableBackend) AnimatedDrawableBackendFrameRenderer(com.facebook.fresco.animation.bitmap.wrapper.AnimatedDrawableBackendFrameRenderer) AnimatedDrawableBackendAnimationInformation(com.facebook.fresco.animation.bitmap.wrapper.AnimatedDrawableBackendAnimationInformation) BitmapFramePreparationStrategy(com.facebook.fresco.animation.bitmap.preparation.BitmapFramePreparationStrategy) FixedNumberBitmapFramePreparationStrategy(com.facebook.fresco.animation.bitmap.preparation.FixedNumberBitmapFramePreparationStrategy) BitmapAnimationBackend(com.facebook.fresco.animation.bitmap.BitmapAnimationBackend) BitmapFrameCache(com.facebook.fresco.animation.bitmap.BitmapFrameCache) BitmapFrameRenderer(com.facebook.fresco.animation.bitmap.BitmapFrameRenderer) BitmapFramePreparer(com.facebook.fresco.animation.bitmap.preparation.BitmapFramePreparer) DefaultBitmapFramePreparer(com.facebook.fresco.animation.bitmap.preparation.DefaultBitmapFramePreparer) FixedNumberBitmapFramePreparationStrategy(com.facebook.fresco.animation.bitmap.preparation.FixedNumberBitmapFramePreparationStrategy)

Example 2 with BitmapFramePreparationStrategy

use of com.facebook.fresco.animation.bitmap.preparation.BitmapFramePreparationStrategy in project fresco by facebook.

the class ExampleBitmapAnimationFactory method createColorBitmapAnimationBackend.

public static BitmapAnimationBackend createColorBitmapAnimationBackend(final int[] colors, final int animationDurationMs, final BitmapFrameCache bitmapFrameCache) {
    final PlatformBitmapFactory platformBitmapFactory = Fresco.getImagePipelineFactory().getPlatformBitmapFactory();
    final BitmapFrameRenderer bitmapFrameRenderer = new ColorAndFrameNumberRenderer(colors);
    final AnimationInformation animationInformation = new ColorListAnimationInformation(colors, animationDurationMs);
    final ExecutorService executorServiceForFramePreparer = new DefaultSerialExecutorService(new DefaultExecutorSupplier(1).forDecode());
    final BitmapFramePreparationStrategy framePreparationStrategy = new FixedNumberBitmapFramePreparationStrategy(NUMBER_OF_FRAMES_TO_PREPARE);
    final BitmapFramePreparer bitmapFramePreparer = new DefaultBitmapFramePreparer(platformBitmapFactory, bitmapFrameRenderer, Bitmap.Config.ARGB_8888, executorServiceForFramePreparer);
    BitmapAnimationBackend bitmapAnimationBackend = new BitmapAnimationBackend(platformBitmapFactory, bitmapFrameCache, animationInformation, bitmapFrameRenderer, framePreparationStrategy, bitmapFramePreparer);
    bitmapAnimationBackend.setFrameListener(new DebugBitmapAnimationFrameListener());
    return bitmapAnimationBackend;
}
Also used : DefaultSerialExecutorService(com.facebook.common.executors.DefaultSerialExecutorService) PlatformBitmapFactory(com.facebook.imagepipeline.bitmaps.PlatformBitmapFactory) DefaultExecutorSupplier(com.facebook.imagepipeline.core.DefaultExecutorSupplier) DefaultBitmapFramePreparer(com.facebook.fresco.animation.bitmap.preparation.DefaultBitmapFramePreparer) AnimationInformation(com.facebook.fresco.animation.backend.AnimationInformation) FixedNumberBitmapFramePreparationStrategy(com.facebook.fresco.animation.bitmap.preparation.FixedNumberBitmapFramePreparationStrategy) DefaultSerialExecutorService(com.facebook.common.executors.DefaultSerialExecutorService) ExecutorService(java.util.concurrent.ExecutorService) BitmapFramePreparationStrategy(com.facebook.fresco.animation.bitmap.preparation.BitmapFramePreparationStrategy) FixedNumberBitmapFramePreparationStrategy(com.facebook.fresco.animation.bitmap.preparation.FixedNumberBitmapFramePreparationStrategy) BitmapAnimationBackend(com.facebook.fresco.animation.bitmap.BitmapAnimationBackend) BitmapFrameRenderer(com.facebook.fresco.animation.bitmap.BitmapFrameRenderer) BitmapFramePreparer(com.facebook.fresco.animation.bitmap.preparation.BitmapFramePreparer) DefaultBitmapFramePreparer(com.facebook.fresco.animation.bitmap.preparation.DefaultBitmapFramePreparer)

Aggregations

BitmapAnimationBackend (com.facebook.fresco.animation.bitmap.BitmapAnimationBackend)2 BitmapFrameRenderer (com.facebook.fresco.animation.bitmap.BitmapFrameRenderer)2 BitmapFramePreparationStrategy (com.facebook.fresco.animation.bitmap.preparation.BitmapFramePreparationStrategy)2 BitmapFramePreparer (com.facebook.fresco.animation.bitmap.preparation.BitmapFramePreparer)2 DefaultBitmapFramePreparer (com.facebook.fresco.animation.bitmap.preparation.DefaultBitmapFramePreparer)2 FixedNumberBitmapFramePreparationStrategy (com.facebook.fresco.animation.bitmap.preparation.FixedNumberBitmapFramePreparationStrategy)2 DefaultSerialExecutorService (com.facebook.common.executors.DefaultSerialExecutorService)1 AnimationInformation (com.facebook.fresco.animation.backend.AnimationInformation)1 BitmapFrameCache (com.facebook.fresco.animation.bitmap.BitmapFrameCache)1 AnimatedDrawableBackendAnimationInformation (com.facebook.fresco.animation.bitmap.wrapper.AnimatedDrawableBackendAnimationInformation)1 AnimatedDrawableBackendFrameRenderer (com.facebook.fresco.animation.bitmap.wrapper.AnimatedDrawableBackendFrameRenderer)1 AnimatedDrawableBackend (com.facebook.imagepipeline.animated.base.AnimatedDrawableBackend)1 PlatformBitmapFactory (com.facebook.imagepipeline.bitmaps.PlatformBitmapFactory)1 DefaultExecutorSupplier (com.facebook.imagepipeline.core.DefaultExecutorSupplier)1 ExecutorService (java.util.concurrent.ExecutorService)1