| Michael Wright | f5eee40 | 2015-12-07 15:26:38 -0500 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright (C) 2015 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 | /** | 
|  | 18 | * @addtogroup Choreographer | 
|  | 19 | * @{ | 
|  | 20 | */ | 
|  | 21 |  | 
|  | 22 | /** | 
|  | 23 | * @file choreographer.h | 
|  | 24 | */ | 
|  | 25 |  | 
|  | 26 | #ifndef ANDROID_CHOREOGRAPHER_H | 
|  | 27 | #define ANDROID_CHOREOGRAPHER_H | 
|  | 28 |  | 
| Michael Wright | fb911b2 | 2016-01-26 16:05:54 -0800 | [diff] [blame] | 29 | #include <sys/cdefs.h> | 
|  | 30 |  | 
| Michael Wright | f5eee40 | 2015-12-07 15:26:38 -0500 | [diff] [blame] | 31 | __BEGIN_DECLS | 
|  | 32 |  | 
|  | 33 | struct AChoreographer; | 
|  | 34 | typedef struct AChoreographer AChoreographer; | 
|  | 35 |  | 
|  | 36 | /** | 
|  | 37 | * Prototype of the function that is called when a new frame is being rendered. | 
|  | 38 | * It's passed the time that the frame is being rendered as nanoseconds in the | 
|  | 39 | * CLOCK_MONOTONIC time base, as well as the data pointer provided by the | 
|  | 40 | * application that registered a callback. All callbacks that run as part of | 
|  | 41 | * rendering a frame will observe the same frame time, so it should be used | 
|  | 42 | * whenever events need to be synchronized (e.g. animations). | 
|  | 43 | */ | 
|  | 44 | typedef void (*AChoreographer_frameCallback)(long frameTimeNanos, void* data); | 
|  | 45 |  | 
|  | 46 | /** | 
|  | 47 | * Get the AChoreographer instance for the current thread. This must be called | 
|  | 48 | * on an ALooper thread. | 
|  | 49 | */ | 
| Elliott Hughes | c2fcafc | 2018-06-18 12:28:46 -0700 | [diff] [blame] | 50 | AChoreographer* AChoreographer_getInstance() __INTRODUCED_IN(24); | 
| Michael Wright | f5eee40 | 2015-12-07 15:26:38 -0500 | [diff] [blame] | 51 |  | 
|  | 52 | /** | 
|  | 53 | * Post a callback to be run on the next frame. The data pointer provided will | 
|  | 54 | * be passed to the callback function when it's called. | 
|  | 55 | */ | 
|  | 56 | void AChoreographer_postFrameCallback(AChoreographer* choreographer, | 
| Elliott Hughes | c2fcafc | 2018-06-18 12:28:46 -0700 | [diff] [blame] | 57 | AChoreographer_frameCallback callback, void* data) __INTRODUCED_IN(24); | 
|  | 58 |  | 
| Michael Wright | f5eee40 | 2015-12-07 15:26:38 -0500 | [diff] [blame] | 59 | /** | 
|  | 60 | * Post a callback to be run on the frame following the specified delay. The | 
|  | 61 | * data pointer provided will be passed to the callback function when it's | 
|  | 62 | * called. | 
|  | 63 | */ | 
|  | 64 | void AChoreographer_postFrameCallbackDelayed(AChoreographer* choreographer, | 
| Elliott Hughes | c2fcafc | 2018-06-18 12:28:46 -0700 | [diff] [blame] | 65 | AChoreographer_frameCallback callback, void* data, | 
|  | 66 | long delayMillis) __INTRODUCED_IN(24); | 
| Dan Albert | 494ed55 | 2016-09-23 15:57:45 -0700 | [diff] [blame] | 67 |  | 
| Michael Wright | f5eee40 | 2015-12-07 15:26:38 -0500 | [diff] [blame] | 68 | __END_DECLS | 
|  | 69 |  | 
|  | 70 | #endif // ANDROID_CHOREOGRAPHER_H | 
|  | 71 |  | 
|  | 72 | /** @} */ |