99 lines
3.2 KiB
Java
99 lines
3.2 KiB
Java
package com.airbnb.lottie;
|
|
|
|
import com.airbnb.lottie.utils.MeanCalculator;
|
|
import java.util.ArrayList;
|
|
import java.util.Collections;
|
|
import java.util.Comparator;
|
|
import java.util.HashMap;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Set;
|
|
import o.uOF;
|
|
import o.wnv;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class PerformanceTracker {
|
|
private boolean enabled = false;
|
|
private final Set<FrameListener> frameListeners = new wnv();
|
|
private final Map<String, MeanCalculator> layerRenderTimes = new HashMap();
|
|
private final Comparator<uOF<String, Float>> floatComparator = new Comparator<uOF<String, Float>>(this) { // from class: com.airbnb.lottie.PerformanceTracker.1
|
|
final PerformanceTracker this$0;
|
|
|
|
{
|
|
this.this$0 = this;
|
|
}
|
|
|
|
@Override // java.util.Comparator
|
|
public int compare(uOF<String, Float> uof, uOF<String, Float> uof2) {
|
|
float floatValue = uof.b.floatValue();
|
|
float floatValue2 = uof2.b.floatValue();
|
|
if (floatValue2 > floatValue) {
|
|
return 1;
|
|
}
|
|
return floatValue > floatValue2 ? -1 : 0;
|
|
}
|
|
};
|
|
|
|
/* loaded from: classes.dex */
|
|
public interface FrameListener {
|
|
void onFrameRendered(float f);
|
|
}
|
|
|
|
public void recordRenderTime(String str, float f) {
|
|
if (this.enabled) {
|
|
MeanCalculator meanCalculator = this.layerRenderTimes.get(str);
|
|
if (meanCalculator == null) {
|
|
meanCalculator = new MeanCalculator();
|
|
this.layerRenderTimes.put(str, meanCalculator);
|
|
}
|
|
meanCalculator.add(f);
|
|
if (str.equals("__container")) {
|
|
Iterator<FrameListener> it = this.frameListeners.iterator();
|
|
while (it.hasNext()) {
|
|
it.next().onFrameRendered(f);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public void addFrameListener(FrameListener frameListener) {
|
|
this.frameListeners.add(frameListener);
|
|
}
|
|
|
|
public void removeFrameListener(FrameListener frameListener) {
|
|
this.frameListeners.remove(frameListener);
|
|
}
|
|
|
|
public void clearRenderTimes() {
|
|
this.layerRenderTimes.clear();
|
|
}
|
|
|
|
public void logRenderTimes() {
|
|
if (this.enabled) {
|
|
List<uOF<String, Float>> sortedRenderTimes = getSortedRenderTimes();
|
|
for (int i = 0; i < sortedRenderTimes.size(); i++) {
|
|
uOF<String, Float> uof = sortedRenderTimes.get(i);
|
|
new Object[]{uof.d, uof.b};
|
|
}
|
|
}
|
|
}
|
|
|
|
public List<uOF<String, Float>> getSortedRenderTimes() {
|
|
if (!this.enabled) {
|
|
return Collections.emptyList();
|
|
}
|
|
ArrayList arrayList = new ArrayList(this.layerRenderTimes.size());
|
|
for (Map.Entry<String, MeanCalculator> entry : this.layerRenderTimes.entrySet()) {
|
|
arrayList.add(new uOF(entry.getKey(), Float.valueOf(entry.getValue().getMean())));
|
|
}
|
|
Collections.sort(arrayList, this.floatComparator);
|
|
return arrayList;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public void setEnabled(boolean z) {
|
|
this.enabled = z;
|
|
}
|
|
}
|