Search in sources :

Example 1 with CompositionLayer

use of com.airbnb.lottie.model.layer.CompositionLayer in project lottie-android by airbnb.

the class LottieDrawable method draw.

/**
 * To be used by lottie-compose only.
 */
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public void draw(Canvas canvas, Matrix matrix) {
    CompositionLayer compositionLayer = this.compositionLayer;
    LottieComposition composition = this.composition;
    if (compositionLayer == null || composition == null) {
        return;
    }
    if (useSoftwareRendering) {
        canvas.save();
        canvas.concat(matrix);
        renderAndDrawAsBitmap(canvas, compositionLayer);
        canvas.restore();
    } else {
        compositionLayer.draw(canvas, matrix, alpha);
    }
    isDirty = false;
}
Also used : CompositionLayer(com.airbnb.lottie.model.layer.CompositionLayer) RestrictTo(androidx.annotation.RestrictTo)

Example 2 with CompositionLayer

use of com.airbnb.lottie.model.layer.CompositionLayer in project lottie-android by airbnb.

the class LottieDrawable method buildCompositionLayer.

private void buildCompositionLayer() {
    LottieComposition composition = this.composition;
    if (composition == null) {
        return;
    }
    compositionLayer = new CompositionLayer(this, LayerParser.parse(composition), composition.getLayers(), composition);
    if (outlineMasksAndMattes) {
        compositionLayer.setOutlineMasksAndMattes(true);
    }
    compositionLayer.setClipToCompositionBounds(clipToCompositionBounds);
}
Also used : CompositionLayer(com.airbnb.lottie.model.layer.CompositionLayer)

Example 3 with CompositionLayer

use of com.airbnb.lottie.model.layer.CompositionLayer in project lottie-android by airbnb.

the class LottieDrawable method drawDirectlyToCanvas.

/**
 * Hardware accelerated render path.
 */
private void drawDirectlyToCanvas(Canvas canvas) {
    CompositionLayer compositionLayer = this.compositionLayer;
    LottieComposition composition = this.composition;
    if (compositionLayer == null || composition == null) {
        return;
    }
    renderingMatrix.reset();
    Rect bounds = getBounds();
    if (!bounds.isEmpty()) {
        // In fitXY mode, the scale doesn't take effect.
        float scaleX = bounds.width() / (float) composition.getBounds().width();
        float scaleY = bounds.height() / (float) composition.getBounds().height();
        renderingMatrix.preScale(scaleX, scaleY);
    }
    compositionLayer.draw(canvas, renderingMatrix, alpha);
}
Also used : CompositionLayer(com.airbnb.lottie.model.layer.CompositionLayer) Rect(android.graphics.Rect)

Example 4 with CompositionLayer

use of com.airbnb.lottie.model.layer.CompositionLayer in project lottie-android by airbnb.

the class LottieDrawable method setClipToCompositionBounds.

/**
 * Sets whether or not Lottie should clip to the original animation composition bounds.
 *
 * Defaults to true.
 */
public void setClipToCompositionBounds(boolean clipToCompositionBounds) {
    if (clipToCompositionBounds != this.clipToCompositionBounds) {
        this.clipToCompositionBounds = clipToCompositionBounds;
        CompositionLayer compositionLayer = this.compositionLayer;
        if (compositionLayer != null) {
            compositionLayer.setClipToCompositionBounds(clipToCompositionBounds);
        }
        invalidateSelf();
    }
}
Also used : CompositionLayer(com.airbnb.lottie.model.layer.CompositionLayer)

Aggregations

CompositionLayer (com.airbnb.lottie.model.layer.CompositionLayer)4 Rect (android.graphics.Rect)1 RestrictTo (androidx.annotation.RestrictTo)1