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;
}
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);
}
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);
}
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();
}
}
Aggregations