1/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.internal.graphics;
18
19import android.animation.AnimationHandler.AnimationFrameCallbackProvider;
20import android.view.Choreographer;
21
22/**
23 * Provider of timing pulse that uses SurfaceFlinger Vsync Choreographer for frame callbacks.
24 *
25 * @hide
26 */
27public final class SfVsyncFrameCallbackProvider implements AnimationFrameCallbackProvider {
28
29    private final Choreographer mChoreographer = Choreographer.getSfInstance();
30
31    @Override
32    public void postFrameCallback(Choreographer.FrameCallback callback) {
33        mChoreographer.postFrameCallback(callback);
34    }
35
36    @Override
37    public void postCommitCallback(Runnable runnable) {
38        mChoreographer.postCallback(Choreographer.CALLBACK_COMMIT, runnable, null);
39    }
40
41    @Override
42    public long getFrameTime() {
43        return mChoreographer.getFrameTime();
44    }
45
46    @Override
47    public long getFrameDelay() {
48        return Choreographer.getFrameDelay();
49    }
50
51    @Override
52    public void setFrameDelay(long delay) {
53        Choreographer.setFrameDelay(delay);
54    }
55}