654 lines
29 KiB
Java
654 lines
29 KiB
Java
package com.airbnb.lottie.model.layer;
|
|
|
|
import android.graphics.BlurMaskFilter;
|
|
import android.graphics.Canvas;
|
|
import android.graphics.Matrix;
|
|
import android.graphics.Paint;
|
|
import android.graphics.Path;
|
|
import android.graphics.PorterDuff;
|
|
import android.graphics.PorterDuffXfermode;
|
|
import android.graphics.RectF;
|
|
import android.os.Build;
|
|
import com.airbnb.lottie.L;
|
|
import com.airbnb.lottie.LottieComposition;
|
|
import com.airbnb.lottie.LottieDrawable;
|
|
import com.airbnb.lottie.animation.LPaint;
|
|
import com.airbnb.lottie.animation.content.Content;
|
|
import com.airbnb.lottie.animation.content.DrawingContent;
|
|
import com.airbnb.lottie.animation.keyframe.BaseKeyframeAnimation;
|
|
import com.airbnb.lottie.animation.keyframe.FloatKeyframeAnimation;
|
|
import com.airbnb.lottie.animation.keyframe.MaskKeyframeAnimation;
|
|
import com.airbnb.lottie.animation.keyframe.TransformKeyframeAnimation;
|
|
import com.airbnb.lottie.model.KeyPath;
|
|
import com.airbnb.lottie.model.KeyPathElement;
|
|
import com.airbnb.lottie.model.content.BlurEffect;
|
|
import com.airbnb.lottie.model.content.Mask;
|
|
import com.airbnb.lottie.model.content.ShapeData;
|
|
import com.airbnb.lottie.model.layer.Layer;
|
|
import com.airbnb.lottie.parser.DropShadowEffect;
|
|
import com.airbnb.lottie.utils.Logger;
|
|
import com.airbnb.lottie.utils.Utils;
|
|
import com.airbnb.lottie.value.LottieValueCallback;
|
|
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
|
|
import java.util.ArrayList;
|
|
import java.util.Collections;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
|
|
/* loaded from: classes.dex */
|
|
public abstract class BaseLayer implements DrawingContent, BaseKeyframeAnimation.AnimationListener, KeyPathElement {
|
|
private static final int CLIP_SAVE_FLAG = 2;
|
|
private static final int CLIP_TO_LAYER_SAVE_FLAG = 16;
|
|
private static final int MATRIX_SAVE_FLAG = 1;
|
|
private static final int SAVE_FLAGS = 19;
|
|
private final List<BaseKeyframeAnimation<?, ?>> animations;
|
|
BlurMaskFilter blurMaskFilter;
|
|
float blurMaskFilterRadius;
|
|
final Matrix boundsMatrix;
|
|
private final RectF canvasBounds;
|
|
private final Paint clearPaint;
|
|
private final String drawTraceName;
|
|
private FloatKeyframeAnimation inOutAnimation;
|
|
final Layer layerModel;
|
|
final LottieDrawable lottieDrawable;
|
|
private MaskKeyframeAnimation mask;
|
|
private final RectF maskBoundsRect;
|
|
private final RectF matteBoundsRect;
|
|
private BaseLayer matteLayer;
|
|
private final Paint mattePaint;
|
|
private boolean outlineMasksAndMattes;
|
|
private Paint outlineMasksAndMattesPaint;
|
|
private BaseLayer parentLayer;
|
|
private List<BaseLayer> parentLayers;
|
|
private final RectF rect;
|
|
private final RectF tempMaskBoundsRect;
|
|
final TransformKeyframeAnimation transform;
|
|
private boolean visible;
|
|
private final Path path = new Path();
|
|
private final Matrix matrix = new Matrix();
|
|
private final Matrix canvasMatrix = new Matrix();
|
|
private final Paint contentPaint = new LPaint(1);
|
|
private final Paint dstInPaint = new LPaint(1, PorterDuff.Mode.DST_IN);
|
|
private final Paint dstOutPaint = new LPaint(1, PorterDuff.Mode.DST_OUT);
|
|
|
|
abstract void drawLayer(Canvas canvas, Matrix matrix, int i);
|
|
|
|
void resolveChildKeyPath(KeyPath keyPath, int i, List<KeyPath> list, KeyPath keyPath2) {
|
|
}
|
|
|
|
@Override // com.airbnb.lottie.animation.content.Content
|
|
public void setContents(List<Content> list, List<Content> list2) {
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public static BaseLayer forModel(CompositionLayer compositionLayer, Layer layer, LottieDrawable lottieDrawable, LottieComposition lottieComposition) {
|
|
switch (AnonymousClass1.$SwitchMap$com$airbnb$lottie$model$layer$Layer$LayerType[layer.getLayerType().ordinal()]) {
|
|
case 1:
|
|
return new ShapeLayer(lottieDrawable, layer, compositionLayer);
|
|
case 2:
|
|
return new CompositionLayer(lottieDrawable, layer, lottieComposition.getPrecomps(layer.getRefId()), lottieComposition);
|
|
case 3:
|
|
return new SolidLayer(lottieDrawable, layer);
|
|
case 4:
|
|
return new ImageLayer(lottieDrawable, layer);
|
|
case 5:
|
|
return new NullLayer(lottieDrawable, layer);
|
|
case 6:
|
|
return new TextLayer(lottieDrawable, layer);
|
|
default:
|
|
StringBuilder sb = new StringBuilder("Unknown layer type ");
|
|
sb.append(layer.getLayerType());
|
|
Logger.warning(sb.toString());
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public BaseLayer(LottieDrawable lottieDrawable, Layer layer) {
|
|
LPaint lPaint = new LPaint(1);
|
|
this.mattePaint = lPaint;
|
|
this.clearPaint = new LPaint(PorterDuff.Mode.CLEAR);
|
|
this.rect = new RectF();
|
|
this.canvasBounds = new RectF();
|
|
this.maskBoundsRect = new RectF();
|
|
this.matteBoundsRect = new RectF();
|
|
this.tempMaskBoundsRect = new RectF();
|
|
this.boundsMatrix = new Matrix();
|
|
this.animations = new ArrayList();
|
|
this.visible = true;
|
|
this.blurMaskFilterRadius = BitmapDescriptorFactory.HUE_RED;
|
|
this.lottieDrawable = lottieDrawable;
|
|
this.layerModel = layer;
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append(layer.getName());
|
|
sb.append("#draw");
|
|
this.drawTraceName = sb.toString();
|
|
if (layer.getMatteType() == Layer.MatteType.INVERT) {
|
|
lPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT));
|
|
} else {
|
|
lPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
|
|
}
|
|
TransformKeyframeAnimation createAnimation = layer.getTransform().createAnimation();
|
|
this.transform = createAnimation;
|
|
createAnimation.addListener(this);
|
|
if (layer.getMasks() != null && !layer.getMasks().isEmpty()) {
|
|
MaskKeyframeAnimation maskKeyframeAnimation = new MaskKeyframeAnimation(layer.getMasks());
|
|
this.mask = maskKeyframeAnimation;
|
|
Iterator<BaseKeyframeAnimation<ShapeData, Path>> it = maskKeyframeAnimation.getMaskAnimations().iterator();
|
|
while (it.hasNext()) {
|
|
it.next().addUpdateListener(this);
|
|
}
|
|
for (BaseKeyframeAnimation<Integer, Integer> baseKeyframeAnimation : this.mask.getOpacityAnimations()) {
|
|
addAnimation(baseKeyframeAnimation);
|
|
baseKeyframeAnimation.addUpdateListener(this);
|
|
}
|
|
}
|
|
setupInOutAnimations();
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public void setOutlineMasksAndMattes(boolean z) {
|
|
if (z && this.outlineMasksAndMattesPaint == null) {
|
|
this.outlineMasksAndMattesPaint = new LPaint();
|
|
}
|
|
this.outlineMasksAndMattes = z;
|
|
}
|
|
|
|
@Override // com.airbnb.lottie.animation.keyframe.BaseKeyframeAnimation.AnimationListener
|
|
public void onValueChanged() {
|
|
invalidateSelf();
|
|
}
|
|
|
|
private void setupInOutAnimations() {
|
|
if (!this.layerModel.getInOutKeyframes().isEmpty()) {
|
|
FloatKeyframeAnimation floatKeyframeAnimation = new FloatKeyframeAnimation(this.layerModel.getInOutKeyframes());
|
|
this.inOutAnimation = floatKeyframeAnimation;
|
|
floatKeyframeAnimation.setIsDiscrete();
|
|
this.inOutAnimation.addUpdateListener(new BaseKeyframeAnimation.AnimationListener(this) { // from class: com.airbnb.lottie.model.layer.BaseLayer$$ExternalSyntheticLambda0
|
|
public final BaseLayer f$0;
|
|
|
|
@Override // com.airbnb.lottie.animation.keyframe.BaseKeyframeAnimation.AnimationListener
|
|
public final void onValueChanged() {
|
|
this.f$0.m37xf49bd987();
|
|
}
|
|
|
|
{
|
|
this.f$0 = this;
|
|
}
|
|
});
|
|
setVisible(this.inOutAnimation.getValue().floatValue() == 1.0f);
|
|
addAnimation(this.inOutAnimation);
|
|
return;
|
|
}
|
|
setVisible(true);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* renamed from: lambda$setupInOutAnimations$0$com-airbnb-lottie-model-layer-BaseLayer, reason: not valid java name */
|
|
public /* synthetic */ void m37xf49bd987() {
|
|
setVisible(this.inOutAnimation.getFloatValue() == 1.0f);
|
|
}
|
|
|
|
private void invalidateSelf() {
|
|
this.lottieDrawable.invalidateSelf();
|
|
}
|
|
|
|
public void addAnimation(BaseKeyframeAnimation<?, ?> baseKeyframeAnimation) {
|
|
if (baseKeyframeAnimation == null) {
|
|
return;
|
|
}
|
|
this.animations.add(baseKeyframeAnimation);
|
|
}
|
|
|
|
public void removeAnimation(BaseKeyframeAnimation<?, ?> baseKeyframeAnimation) {
|
|
this.animations.remove(baseKeyframeAnimation);
|
|
}
|
|
|
|
@Override // com.airbnb.lottie.animation.content.DrawingContent
|
|
public void getBounds(RectF rectF, Matrix matrix, boolean z) {
|
|
this.rect.set(BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED);
|
|
buildParentLayerListIfNeeded();
|
|
this.boundsMatrix.set(matrix);
|
|
if (z) {
|
|
List<BaseLayer> list = this.parentLayers;
|
|
if (list != null) {
|
|
for (int size = list.size() - 1; size >= 0; size--) {
|
|
this.boundsMatrix.preConcat(this.parentLayers.get(size).transform.getMatrix());
|
|
}
|
|
} else {
|
|
BaseLayer baseLayer = this.parentLayer;
|
|
if (baseLayer != null) {
|
|
this.boundsMatrix.preConcat(baseLayer.transform.getMatrix());
|
|
}
|
|
}
|
|
}
|
|
this.boundsMatrix.preConcat(this.transform.getMatrix());
|
|
}
|
|
|
|
@Override // com.airbnb.lottie.animation.content.DrawingContent
|
|
public void draw(Canvas canvas, Matrix matrix, int i) {
|
|
Paint paint;
|
|
L.beginSection(this.drawTraceName);
|
|
if (!this.visible || this.layerModel.isHidden()) {
|
|
L.endSection(this.drawTraceName);
|
|
return;
|
|
}
|
|
buildParentLayerListIfNeeded();
|
|
L.beginSection("Layer#parentMatrix");
|
|
this.matrix.reset();
|
|
this.matrix.set(matrix);
|
|
for (int size = this.parentLayers.size() - 1; size >= 0; size--) {
|
|
this.matrix.preConcat(this.parentLayers.get(size).transform.getMatrix());
|
|
}
|
|
L.endSection("Layer#parentMatrix");
|
|
int intValue = (int) ((((i / 255.0f) * (this.transform.getOpacity() == null ? 100 : this.transform.getOpacity().getValue().intValue())) / 100.0f) * 255.0f);
|
|
if (!hasMatteOnThisLayer() && !hasMasksOnThisLayer()) {
|
|
this.matrix.preConcat(this.transform.getMatrix());
|
|
L.beginSection("Layer#drawLayer");
|
|
drawLayer(canvas, this.matrix, intValue);
|
|
L.endSection("Layer#drawLayer");
|
|
recordRenderTime(L.endSection(this.drawTraceName));
|
|
return;
|
|
}
|
|
L.beginSection("Layer#computeBounds");
|
|
getBounds(this.rect, this.matrix, false);
|
|
intersectBoundsWithMatte(this.rect, matrix);
|
|
this.matrix.preConcat(this.transform.getMatrix());
|
|
intersectBoundsWithMask(this.rect, this.matrix);
|
|
this.canvasBounds.set(BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED, canvas.getWidth(), canvas.getHeight());
|
|
canvas.getMatrix(this.canvasMatrix);
|
|
if (!this.canvasMatrix.isIdentity()) {
|
|
Matrix matrix2 = this.canvasMatrix;
|
|
matrix2.invert(matrix2);
|
|
this.canvasMatrix.mapRect(this.canvasBounds);
|
|
}
|
|
if (!this.rect.intersect(this.canvasBounds)) {
|
|
this.rect.set(BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED);
|
|
}
|
|
L.endSection("Layer#computeBounds");
|
|
if (this.rect.width() >= 1.0f && this.rect.height() >= 1.0f) {
|
|
L.beginSection("Layer#saveLayer");
|
|
this.contentPaint.setAlpha(255);
|
|
Utils.saveLayerCompat(canvas, this.rect, this.contentPaint);
|
|
L.endSection("Layer#saveLayer");
|
|
clearCanvas(canvas);
|
|
L.beginSection("Layer#drawLayer");
|
|
drawLayer(canvas, this.matrix, intValue);
|
|
L.endSection("Layer#drawLayer");
|
|
if (hasMasksOnThisLayer()) {
|
|
applyMasks(canvas, this.matrix);
|
|
}
|
|
if (hasMatteOnThisLayer()) {
|
|
L.beginSection("Layer#drawMatte");
|
|
L.beginSection("Layer#saveLayer");
|
|
Utils.saveLayerCompat(canvas, this.rect, this.mattePaint, 19);
|
|
L.endSection("Layer#saveLayer");
|
|
clearCanvas(canvas);
|
|
this.matteLayer.draw(canvas, matrix, intValue);
|
|
L.beginSection("Layer#restoreLayer");
|
|
canvas.restore();
|
|
L.endSection("Layer#restoreLayer");
|
|
L.endSection("Layer#drawMatte");
|
|
}
|
|
L.beginSection("Layer#restoreLayer");
|
|
canvas.restore();
|
|
L.endSection("Layer#restoreLayer");
|
|
}
|
|
if (this.outlineMasksAndMattes && (paint = this.outlineMasksAndMattesPaint) != null) {
|
|
paint.setStyle(Paint.Style.STROKE);
|
|
this.outlineMasksAndMattesPaint.setColor(-251901);
|
|
this.outlineMasksAndMattesPaint.setStrokeWidth(4.0f);
|
|
canvas.drawRect(this.rect, this.outlineMasksAndMattesPaint);
|
|
this.outlineMasksAndMattesPaint.setStyle(Paint.Style.FILL);
|
|
this.outlineMasksAndMattesPaint.setColor(1357638635);
|
|
canvas.drawRect(this.rect, this.outlineMasksAndMattesPaint);
|
|
}
|
|
recordRenderTime(L.endSection(this.drawTraceName));
|
|
}
|
|
|
|
private void recordRenderTime(float f) {
|
|
this.lottieDrawable.getComposition().getPerformanceTracker().recordRenderTime(this.layerModel.getName(), f);
|
|
}
|
|
|
|
private void clearCanvas(Canvas canvas) {
|
|
L.beginSection("Layer#clearLayer");
|
|
canvas.drawRect(this.rect.left - 1.0f, this.rect.top - 1.0f, this.rect.right + 1.0f, this.rect.bottom + 1.0f, this.clearPaint);
|
|
L.endSection("Layer#clearLayer");
|
|
}
|
|
|
|
private void intersectBoundsWithMask(RectF rectF, Matrix matrix) {
|
|
this.maskBoundsRect.set(BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED);
|
|
if (hasMasksOnThisLayer()) {
|
|
int size = this.mask.getMasks().size();
|
|
for (int i = 0; i < size; i++) {
|
|
Mask mask = this.mask.getMasks().get(i);
|
|
Path value = this.mask.getMaskAnimations().get(i).getValue();
|
|
if (value != null) {
|
|
this.path.set(value);
|
|
this.path.transform(matrix);
|
|
int i2 = AnonymousClass1.$SwitchMap$com$airbnb$lottie$model$content$Mask$MaskMode[mask.getMaskMode().ordinal()];
|
|
if (i2 == 1 || i2 == 2) {
|
|
return;
|
|
}
|
|
if ((i2 == 3 || i2 == 4) && mask.isInverted()) {
|
|
return;
|
|
}
|
|
this.path.computeBounds(this.tempMaskBoundsRect, false);
|
|
if (i == 0) {
|
|
this.maskBoundsRect.set(this.tempMaskBoundsRect);
|
|
} else {
|
|
RectF rectF2 = this.maskBoundsRect;
|
|
rectF2.set(Math.min(rectF2.left, this.tempMaskBoundsRect.left), Math.min(this.maskBoundsRect.top, this.tempMaskBoundsRect.top), Math.max(this.maskBoundsRect.right, this.tempMaskBoundsRect.right), Math.max(this.maskBoundsRect.bottom, this.tempMaskBoundsRect.bottom));
|
|
}
|
|
}
|
|
}
|
|
if (rectF.intersect(this.maskBoundsRect)) {
|
|
return;
|
|
}
|
|
rectF.set(BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED);
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* renamed from: com.airbnb.lottie.model.layer.BaseLayer$1, reason: invalid class name */
|
|
/* loaded from: classes.dex */
|
|
public static /* synthetic */ class AnonymousClass1 {
|
|
static final int[] $SwitchMap$com$airbnb$lottie$model$content$Mask$MaskMode;
|
|
static final int[] $SwitchMap$com$airbnb$lottie$model$layer$Layer$LayerType;
|
|
|
|
static {
|
|
int[] iArr = new int[Mask.MaskMode.values().length];
|
|
$SwitchMap$com$airbnb$lottie$model$content$Mask$MaskMode = iArr;
|
|
try {
|
|
iArr[Mask.MaskMode.MASK_MODE_NONE.ordinal()] = 1;
|
|
} catch (NoSuchFieldError unused) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$airbnb$lottie$model$content$Mask$MaskMode[Mask.MaskMode.MASK_MODE_SUBTRACT.ordinal()] = 2;
|
|
} catch (NoSuchFieldError unused2) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$airbnb$lottie$model$content$Mask$MaskMode[Mask.MaskMode.MASK_MODE_INTERSECT.ordinal()] = 3;
|
|
} catch (NoSuchFieldError unused3) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$airbnb$lottie$model$content$Mask$MaskMode[Mask.MaskMode.MASK_MODE_ADD.ordinal()] = 4;
|
|
} catch (NoSuchFieldError unused4) {
|
|
}
|
|
int[] iArr2 = new int[Layer.LayerType.values().length];
|
|
$SwitchMap$com$airbnb$lottie$model$layer$Layer$LayerType = iArr2;
|
|
try {
|
|
iArr2[Layer.LayerType.SHAPE.ordinal()] = 1;
|
|
} catch (NoSuchFieldError unused5) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$airbnb$lottie$model$layer$Layer$LayerType[Layer.LayerType.PRE_COMP.ordinal()] = 2;
|
|
} catch (NoSuchFieldError unused6) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$airbnb$lottie$model$layer$Layer$LayerType[Layer.LayerType.SOLID.ordinal()] = 3;
|
|
} catch (NoSuchFieldError unused7) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$airbnb$lottie$model$layer$Layer$LayerType[Layer.LayerType.IMAGE.ordinal()] = 4;
|
|
} catch (NoSuchFieldError unused8) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$airbnb$lottie$model$layer$Layer$LayerType[Layer.LayerType.NULL.ordinal()] = 5;
|
|
} catch (NoSuchFieldError unused9) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$airbnb$lottie$model$layer$Layer$LayerType[Layer.LayerType.TEXT.ordinal()] = 6;
|
|
} catch (NoSuchFieldError unused10) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$airbnb$lottie$model$layer$Layer$LayerType[Layer.LayerType.UNKNOWN.ordinal()] = 7;
|
|
} catch (NoSuchFieldError unused11) {
|
|
}
|
|
}
|
|
}
|
|
|
|
private void intersectBoundsWithMatte(RectF rectF, Matrix matrix) {
|
|
if (hasMatteOnThisLayer() && this.layerModel.getMatteType() != Layer.MatteType.INVERT) {
|
|
this.matteBoundsRect.set(BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED);
|
|
this.matteLayer.getBounds(this.matteBoundsRect, matrix, true);
|
|
if (rectF.intersect(this.matteBoundsRect)) {
|
|
return;
|
|
}
|
|
rectF.set(BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED);
|
|
}
|
|
}
|
|
|
|
private void applyMasks(Canvas canvas, Matrix matrix) {
|
|
L.beginSection("Layer#saveLayer");
|
|
Utils.saveLayerCompat(canvas, this.rect, this.dstInPaint, 19);
|
|
if (Build.VERSION.SDK_INT < 28) {
|
|
clearCanvas(canvas);
|
|
}
|
|
L.endSection("Layer#saveLayer");
|
|
for (int i = 0; i < this.mask.getMasks().size(); i++) {
|
|
Mask mask = this.mask.getMasks().get(i);
|
|
BaseKeyframeAnimation<ShapeData, Path> baseKeyframeAnimation = this.mask.getMaskAnimations().get(i);
|
|
BaseKeyframeAnimation<Integer, Integer> baseKeyframeAnimation2 = this.mask.getOpacityAnimations().get(i);
|
|
int i2 = AnonymousClass1.$SwitchMap$com$airbnb$lottie$model$content$Mask$MaskMode[mask.getMaskMode().ordinal()];
|
|
if (i2 != 1) {
|
|
if (i2 == 2) {
|
|
if (i == 0) {
|
|
this.contentPaint.setColor(-16777216);
|
|
this.contentPaint.setAlpha(255);
|
|
canvas.drawRect(this.rect, this.contentPaint);
|
|
}
|
|
if (mask.isInverted()) {
|
|
applyInvertedSubtractMask(canvas, matrix, baseKeyframeAnimation, baseKeyframeAnimation2);
|
|
} else {
|
|
applySubtractMask(canvas, matrix, baseKeyframeAnimation);
|
|
}
|
|
} else if (i2 != 3) {
|
|
if (i2 == 4) {
|
|
if (mask.isInverted()) {
|
|
applyInvertedAddMask(canvas, matrix, baseKeyframeAnimation, baseKeyframeAnimation2);
|
|
} else {
|
|
applyAddMask(canvas, matrix, baseKeyframeAnimation, baseKeyframeAnimation2);
|
|
}
|
|
}
|
|
} else if (mask.isInverted()) {
|
|
applyInvertedIntersectMask(canvas, matrix, baseKeyframeAnimation, baseKeyframeAnimation2);
|
|
} else {
|
|
applyIntersectMask(canvas, matrix, baseKeyframeAnimation, baseKeyframeAnimation2);
|
|
}
|
|
} else if (areAllMasksNone()) {
|
|
this.contentPaint.setAlpha(255);
|
|
canvas.drawRect(this.rect, this.contentPaint);
|
|
}
|
|
}
|
|
L.beginSection("Layer#restoreLayer");
|
|
canvas.restore();
|
|
L.endSection("Layer#restoreLayer");
|
|
}
|
|
|
|
private boolean areAllMasksNone() {
|
|
if (this.mask.getMaskAnimations().isEmpty()) {
|
|
return false;
|
|
}
|
|
for (int i = 0; i < this.mask.getMasks().size(); i++) {
|
|
if (this.mask.getMasks().get(i).getMaskMode() != Mask.MaskMode.MASK_MODE_NONE) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private void applyAddMask(Canvas canvas, Matrix matrix, BaseKeyframeAnimation<ShapeData, Path> baseKeyframeAnimation, BaseKeyframeAnimation<Integer, Integer> baseKeyframeAnimation2) {
|
|
this.path.set(baseKeyframeAnimation.getValue());
|
|
this.path.transform(matrix);
|
|
this.contentPaint.setAlpha((int) (baseKeyframeAnimation2.getValue().intValue() * 2.55f));
|
|
canvas.drawPath(this.path, this.contentPaint);
|
|
}
|
|
|
|
private void applyInvertedAddMask(Canvas canvas, Matrix matrix, BaseKeyframeAnimation<ShapeData, Path> baseKeyframeAnimation, BaseKeyframeAnimation<Integer, Integer> baseKeyframeAnimation2) {
|
|
Utils.saveLayerCompat(canvas, this.rect, this.contentPaint);
|
|
canvas.drawRect(this.rect, this.contentPaint);
|
|
this.path.set(baseKeyframeAnimation.getValue());
|
|
this.path.transform(matrix);
|
|
this.contentPaint.setAlpha((int) (baseKeyframeAnimation2.getValue().intValue() * 2.55f));
|
|
canvas.drawPath(this.path, this.dstOutPaint);
|
|
canvas.restore();
|
|
}
|
|
|
|
private void applySubtractMask(Canvas canvas, Matrix matrix, BaseKeyframeAnimation<ShapeData, Path> baseKeyframeAnimation) {
|
|
this.path.set(baseKeyframeAnimation.getValue());
|
|
this.path.transform(matrix);
|
|
canvas.drawPath(this.path, this.dstOutPaint);
|
|
}
|
|
|
|
private void applyInvertedSubtractMask(Canvas canvas, Matrix matrix, BaseKeyframeAnimation<ShapeData, Path> baseKeyframeAnimation, BaseKeyframeAnimation<Integer, Integer> baseKeyframeAnimation2) {
|
|
Utils.saveLayerCompat(canvas, this.rect, this.dstOutPaint);
|
|
canvas.drawRect(this.rect, this.contentPaint);
|
|
this.dstOutPaint.setAlpha((int) (baseKeyframeAnimation2.getValue().intValue() * 2.55f));
|
|
this.path.set(baseKeyframeAnimation.getValue());
|
|
this.path.transform(matrix);
|
|
canvas.drawPath(this.path, this.dstOutPaint);
|
|
canvas.restore();
|
|
}
|
|
|
|
private void applyIntersectMask(Canvas canvas, Matrix matrix, BaseKeyframeAnimation<ShapeData, Path> baseKeyframeAnimation, BaseKeyframeAnimation<Integer, Integer> baseKeyframeAnimation2) {
|
|
Utils.saveLayerCompat(canvas, this.rect, this.dstInPaint);
|
|
this.path.set(baseKeyframeAnimation.getValue());
|
|
this.path.transform(matrix);
|
|
this.contentPaint.setAlpha((int) (baseKeyframeAnimation2.getValue().intValue() * 2.55f));
|
|
canvas.drawPath(this.path, this.contentPaint);
|
|
canvas.restore();
|
|
}
|
|
|
|
private void applyInvertedIntersectMask(Canvas canvas, Matrix matrix, BaseKeyframeAnimation<ShapeData, Path> baseKeyframeAnimation, BaseKeyframeAnimation<Integer, Integer> baseKeyframeAnimation2) {
|
|
Utils.saveLayerCompat(canvas, this.rect, this.dstInPaint);
|
|
canvas.drawRect(this.rect, this.contentPaint);
|
|
this.dstOutPaint.setAlpha((int) (baseKeyframeAnimation2.getValue().intValue() * 2.55f));
|
|
this.path.set(baseKeyframeAnimation.getValue());
|
|
this.path.transform(matrix);
|
|
canvas.drawPath(this.path, this.dstOutPaint);
|
|
canvas.restore();
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public boolean hasMasksOnThisLayer() {
|
|
MaskKeyframeAnimation maskKeyframeAnimation = this.mask;
|
|
return (maskKeyframeAnimation == null || maskKeyframeAnimation.getMaskAnimations().isEmpty()) ? false : true;
|
|
}
|
|
|
|
private void setVisible(boolean z) {
|
|
if (z != this.visible) {
|
|
this.visible = z;
|
|
invalidateSelf();
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public void setProgress(float f) {
|
|
this.transform.setProgress(f);
|
|
if (this.mask != null) {
|
|
for (int i = 0; i < this.mask.getMaskAnimations().size(); i++) {
|
|
this.mask.getMaskAnimations().get(i).setProgress(f);
|
|
}
|
|
}
|
|
FloatKeyframeAnimation floatKeyframeAnimation = this.inOutAnimation;
|
|
if (floatKeyframeAnimation != null) {
|
|
floatKeyframeAnimation.setProgress(f);
|
|
}
|
|
BaseLayer baseLayer = this.matteLayer;
|
|
if (baseLayer != null) {
|
|
baseLayer.setProgress(f);
|
|
}
|
|
for (int i2 = 0; i2 < this.animations.size(); i2++) {
|
|
this.animations.get(i2).setProgress(f);
|
|
}
|
|
}
|
|
|
|
private void buildParentLayerListIfNeeded() {
|
|
if (this.parentLayers != null) {
|
|
return;
|
|
}
|
|
if (this.parentLayer == null) {
|
|
this.parentLayers = Collections.emptyList();
|
|
return;
|
|
}
|
|
this.parentLayers = new ArrayList();
|
|
for (BaseLayer baseLayer = this.parentLayer; baseLayer != null; baseLayer = baseLayer.parentLayer) {
|
|
this.parentLayers.add(baseLayer);
|
|
}
|
|
}
|
|
|
|
@Override // com.airbnb.lottie.animation.content.Content
|
|
public String getName() {
|
|
return this.layerModel.getName();
|
|
}
|
|
|
|
public BlurEffect getBlurEffect() {
|
|
return this.layerModel.getBlurEffect();
|
|
}
|
|
|
|
public BlurMaskFilter getBlurMaskFilter(float f) {
|
|
if (this.blurMaskFilterRadius == f) {
|
|
return this.blurMaskFilter;
|
|
}
|
|
BlurMaskFilter blurMaskFilter = new BlurMaskFilter(f / 2.0f, BlurMaskFilter.Blur.NORMAL);
|
|
this.blurMaskFilter = blurMaskFilter;
|
|
this.blurMaskFilterRadius = f;
|
|
return blurMaskFilter;
|
|
}
|
|
|
|
public DropShadowEffect getDropShadowEffect() {
|
|
return this.layerModel.getDropShadowEffect();
|
|
}
|
|
|
|
@Override // com.airbnb.lottie.model.KeyPathElement
|
|
public void resolveKeyPath(KeyPath keyPath, int i, List<KeyPath> list, KeyPath keyPath2) {
|
|
BaseLayer baseLayer = this.matteLayer;
|
|
if (baseLayer != null) {
|
|
KeyPath addKey = keyPath2.addKey(baseLayer.getName());
|
|
if (keyPath.fullyResolvesTo(this.matteLayer.getName(), i)) {
|
|
list.add(addKey.resolve(this.matteLayer));
|
|
}
|
|
if (keyPath.propagateToChildren(getName(), i)) {
|
|
this.matteLayer.resolveChildKeyPath(keyPath, keyPath.incrementDepthBy(this.matteLayer.getName(), i) + i, list, addKey);
|
|
}
|
|
}
|
|
if (keyPath.matches(getName(), i)) {
|
|
if (!"__container".equals(getName())) {
|
|
keyPath2 = keyPath2.addKey(getName());
|
|
if (keyPath.fullyResolvesTo(getName(), i)) {
|
|
list.add(keyPath2.resolve(this));
|
|
}
|
|
}
|
|
if (keyPath.propagateToChildren(getName(), i)) {
|
|
resolveChildKeyPath(keyPath, i + keyPath.incrementDepthBy(getName(), i), list, keyPath2);
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // com.airbnb.lottie.model.KeyPathElement
|
|
public <T> void addValueCallback(T t, LottieValueCallback<T> lottieValueCallback) {
|
|
this.transform.applyValueCallback(t, lottieValueCallback);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public void setParentLayer(BaseLayer baseLayer) {
|
|
this.parentLayer = baseLayer;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public void setMatteLayer(BaseLayer baseLayer) {
|
|
this.matteLayer = baseLayer;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public boolean hasMatteOnThisLayer() {
|
|
return this.matteLayer != null;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public Layer getLayerModel() {
|
|
return this.layerModel;
|
|
}
|
|
}
|