1 package com.airbnb.lottie; 2 3 /** 4 * **Note: this API is experimental and may changed.** 5 * <p/> 6 * When async updates are enabled, parts of animation updates will happen off of the main thread. 7 * <p/> 8 * At a high level, during the animation loop, there are two main code paths: 9 * 1. setProgress 10 * 2. draw 11 * <p/> 12 * setProgress is called on every frame when the internal animator updates or if you manually call setProgress. 13 * setProgress must then iterate through every single node in the animation (every shape, fill, mask, stroke, etc.) 14 * and call setProgress on it. When progress is set on a node, it will: 15 * 1. Call the dynamic property value callback if one has been set by you. 16 * 2. Recalculate what its own progress is. Various animation features like interpolators or time remapping 17 * will cause the progress value for a given node to be different than the top level progress. 18 * 3. If a node's progress has changed, it will call invalidate which will invalidate values that are 19 * cached and derived from that node's progress and then bubble up the invalidation to LottieDrawable 20 * to ensure that Android renders a new frame. 21 * <p/> 22 * draw is what actually draws your animation to a canvas. Many of Lottie's operations are completed or 23 * cached in the setProgress path. However, there are a few things (like parentMatrix) that Lottie only has access 24 * to in the draw path and it, of course, needs to actually execute the canvas operations to draw the animation. 25 * <p/> 26 * Without async updates, in a single main thread frame, Lottie will call setProgress immediately followed by draw. 27 * <p/> 28 * With async updates, Lottie will determine if the most recent setProgress is still close enough to be considered 29 * valid. An existing progress will be considered valid if it is within LottieDrawable.MAX_DELTA_MS_ASYNC_SET_PROGRESS 30 * milliseconds from the current actual progress. 31 * If the calculated progress is close enough, it will only execute draw. Once draw completes, it will schedule a 32 * setProgress to be run on a background thread immediately after draw finishes and it will likely complete well 33 * before the next frame starts. 34 * <p/> 35 * The background thread is created via LottieDrawable.setProgressExecutor. You can refer to it for the current default 36 * thread pool configuration. 37 */ 38 public enum AsyncUpdates { 39 /** 40 * Default value. 41 * <p/> 42 * This will default to DISABLED until this feature has had time to incubate. 43 * The behavior of AUTOMATIC may change over time. 44 */ 45 AUTOMATIC, 46 /** 47 * Use the async update path. Refer to the docs for {@link AsyncUpdates} for more details. 48 */ 49 ENABLED, 50 /** 51 * Do not use the async update path. Refer to the docs for {@link AsyncUpdates} for more details. 52 */ 53 DISABLED, 54 } 55