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 17 package com.android.internal.graphics; 18 19 import android.animation.AnimationHandler.AnimationFrameCallbackProvider; 20 import android.view.Choreographer; 21 22 /** 23 * Provider of timing pulse that uses SurfaceFlinger Vsync Choreographer for frame callbacks. 24 * 25 * @hide 26 * @deprecated See b/222698397 - use vsync IDs instead. 27 */ 28 // TODO(b/222698397): remove getSfInstance/this class usage and use vsyncId for transactions 29 @Deprecated 30 public final class SfVsyncFrameCallbackProvider implements AnimationFrameCallbackProvider { 31 32 private final Choreographer mChoreographer; 33 SfVsyncFrameCallbackProvider()34 public SfVsyncFrameCallbackProvider() { 35 mChoreographer = Choreographer.getSfInstance(); 36 } 37 SfVsyncFrameCallbackProvider(Choreographer choreographer)38 public SfVsyncFrameCallbackProvider(Choreographer choreographer) { 39 mChoreographer = choreographer; 40 } 41 42 @Override postFrameCallback(Choreographer.FrameCallback callback)43 public void postFrameCallback(Choreographer.FrameCallback callback) { 44 mChoreographer.postFrameCallback(callback); 45 } 46 47 @Override postCommitCallback(Runnable runnable)48 public void postCommitCallback(Runnable runnable) { 49 mChoreographer.postCallback(Choreographer.CALLBACK_COMMIT, runnable, null); 50 } 51 52 @Override getFrameTime()53 public long getFrameTime() { 54 return mChoreographer.getFrameTime(); 55 } 56 57 @Override getFrameDelay()58 public long getFrameDelay() { 59 return Choreographer.getFrameDelay(); 60 } 61 62 @Override setFrameDelay(long delay)63 public void setFrameDelay(long delay) { 64 Choreographer.setFrameDelay(delay); 65 } 66 } 67