Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eb0ffeda authored by Winson Chung's avatar Winson Chung Committed by Automerger Merge Worker
Browse files

Merge "Lazy initialize the choreographer" into sc-dev am: cacddc52 am: d04e504e

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14455898

Change-Id: I745f564d3efe5664df6f6d9b93f8784f35dbf5ec
parents e29c8c0c d04e504e
Loading
Loading
Loading
Loading
+4 −2
Original line number Original line Diff line number Diff line
@@ -49,7 +49,7 @@ public class FrameProtoTracer<P, S extends P, T extends P, R>
    private final TraceBuffer<P, S, T> mBuffer;
    private final TraceBuffer<P, S, T> mBuffer;
    private final File mTraceFile;
    private final File mTraceFile;
    private final ProtoTraceParams<P, S, T, R> mParams;
    private final ProtoTraceParams<P, S, T, R> mParams;
    private final Choreographer mChoreographer;
    private Choreographer mChoreographer;
    private final Queue<T> mPool = new LinkedList<>();
    private final Queue<T> mPool = new LinkedList<>();
    private final ArrayList<ProtoTraceable<R>> mTraceables = new ArrayList<>();
    private final ArrayList<ProtoTraceable<R>> mTraceables = new ArrayList<>();
    private final ArrayList<ProtoTraceable<R>> mTmpTraceables = new ArrayList<>();
    private final ArrayList<ProtoTraceable<R>> mTmpTraceables = new ArrayList<>();
@@ -94,7 +94,6 @@ public class FrameProtoTracer<P, S extends P, T extends P, R>
            }
            }
        });
        });
        mTraceFile = params.getTraceFile();
        mTraceFile = params.getTraceFile();
        mChoreographer = Choreographer.getMainThreadInstance();
    }
    }


    public void start() {
    public void start() {
@@ -140,6 +139,9 @@ public class FrameProtoTracer<P, S extends P, T extends P, R>
        }
        }


        // Schedule an update on the next frame
        // Schedule an update on the next frame
        if (mChoreographer == null) {
            mChoreographer = Choreographer.getMainThreadInstance();
        }
        mChoreographer.postFrameCallback(this);
        mChoreographer.postFrameCallback(this);
        mFrameScheduled = true;
        mFrameScheduled = true;
    }
    }