| 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 |  | 
| Santos Cordon | 908d008 | 2019-02-20 18:08:02 +0000 | [diff] [blame] | 29 | #include <stdint.h> | 
| Michael Wright | fb911b2 | 2016-01-26 16:05:54 -0800 | [diff] [blame] | 30 | #include <sys/cdefs.h> | 
|  | 31 |  | 
| Michael Wright | f5eee40 | 2015-12-07 15:26:38 -0500 | [diff] [blame] | 32 | __BEGIN_DECLS | 
|  | 33 |  | 
|  | 34 | struct AChoreographer; | 
|  | 35 | typedef struct AChoreographer AChoreographer; | 
|  | 36 |  | 
|  | 37 | /** | 
|  | 38 | * Prototype of the function that is called when a new frame is being rendered. | 
|  | 39 | * It's passed the time that the frame is being rendered as nanoseconds in the | 
|  | 40 | * CLOCK_MONOTONIC time base, as well as the data pointer provided by the | 
|  | 41 | * application that registered a callback. All callbacks that run as part of | 
|  | 42 | * rendering a frame will observe the same frame time, so it should be used | 
|  | 43 | * whenever events need to be synchronized (e.g. animations). | 
|  | 44 | */ | 
|  | 45 | typedef void (*AChoreographer_frameCallback)(long frameTimeNanos, void* data); | 
|  | 46 |  | 
| Santos Cordon | 908d008 | 2019-02-20 18:08:02 +0000 | [diff] [blame] | 47 | /** | 
|  | 48 | * Prototype of the function that is called when a new frame is being rendered. | 
|  | 49 | * It's passed the time that the frame is being rendered as nanoseconds in the | 
|  | 50 | * CLOCK_MONOTONIC time base, as well as the data pointer provided by the | 
|  | 51 | * application that registered a callback. All callbacks that run as part of | 
|  | 52 | * rendering a frame will observe the same frame time, so it should be used | 
|  | 53 | * whenever events need to be synchronized (e.g. animations). | 
|  | 54 | */ | 
|  | 55 | typedef void (*AChoreographer_frameCallback64)(int64_t frameTimeNanos, void* data); | 
|  | 56 |  | 
| Ryan Prichard | 92b1ebe | 2018-07-19 20:32:19 -0700 | [diff] [blame] | 57 | #if __ANDROID_API__ >= 24 | 
|  | 58 |  | 
| Michael Wright | f5eee40 | 2015-12-07 15:26:38 -0500 | [diff] [blame] | 59 | /** | 
|  | 60 | * Get the AChoreographer instance for the current thread. This must be called | 
|  | 61 | * on an ALooper thread. | 
|  | 62 | */ | 
| Elliott Hughes | 9db409b | 2018-06-18 12:28:46 -0700 | [diff] [blame] | 63 | AChoreographer* AChoreographer_getInstance() __INTRODUCED_IN(24); | 
| Michael Wright | f5eee40 | 2015-12-07 15:26:38 -0500 | [diff] [blame] | 64 |  | 
|  | 65 | /** | 
| Santos Cordon | 908d008 | 2019-02-20 18:08:02 +0000 | [diff] [blame] | 66 | * Deprecated: Use AChoreographer_postFrameCallback64 instead. | 
| Michael Wright | f5eee40 | 2015-12-07 15:26:38 -0500 | [diff] [blame] | 67 | */ | 
|  | 68 | void AChoreographer_postFrameCallback(AChoreographer* choreographer, | 
| Santos Cordon | 908d008 | 2019-02-20 18:08:02 +0000 | [diff] [blame] | 69 | AChoreographer_frameCallback callback, void* data) __INTRODUCED_IN(24) __DEPRECATED_IN(29); | 
| Elliott Hughes | 9db409b | 2018-06-18 12:28:46 -0700 | [diff] [blame] | 70 |  | 
| Michael Wright | f5eee40 | 2015-12-07 15:26:38 -0500 | [diff] [blame] | 71 | /** | 
| Santos Cordon | 908d008 | 2019-02-20 18:08:02 +0000 | [diff] [blame] | 72 | * Deprecated: Use AChoreographer_postFrameCallbackDelayed64 instead. | 
| Michael Wright | f5eee40 | 2015-12-07 15:26:38 -0500 | [diff] [blame] | 73 | */ | 
|  | 74 | void AChoreographer_postFrameCallbackDelayed(AChoreographer* choreographer, | 
| Elliott Hughes | 9db409b | 2018-06-18 12:28:46 -0700 | [diff] [blame] | 75 | AChoreographer_frameCallback callback, void* data, | 
| Santos Cordon | 908d008 | 2019-02-20 18:08:02 +0000 | [diff] [blame] | 76 | long delayMillis) __INTRODUCED_IN(24) __DEPRECATED_IN(29); | 
| Dan Albert | 494ed55 | 2016-09-23 15:57:45 -0700 | [diff] [blame] | 77 |  | 
| Ryan Prichard | 92b1ebe | 2018-07-19 20:32:19 -0700 | [diff] [blame] | 78 | #endif /* __ANDROID_API__ >= 24 */ | 
|  | 79 |  | 
| Santos Cordon | 908d008 | 2019-02-20 18:08:02 +0000 | [diff] [blame] | 80 | #if __ANDROID_API__ >= 29 | 
|  | 81 |  | 
|  | 82 | /** | 
|  | 83 | * Power a callback to be run on the next frame.  The data pointer provided will | 
|  | 84 | * be passed to the callback function when it's called. | 
|  | 85 | */ | 
|  | 86 | void AChoreographer_postFrameCallback64(AChoreographer* chroreographer, | 
|  | 87 | AChoreographer_frameCallback64 callback, void* data) __INTRODUCED_IN(29); | 
|  | 88 |  | 
|  | 89 | /** | 
|  | 90 | * Post a callback to be run on the frame following the specified delay.  The | 
|  | 91 | * data pointer provided will be passed to the callback function when it's | 
|  | 92 | * called. | 
|  | 93 | */ | 
|  | 94 | void AChoreographer_postFrameCallbackDelayed64(AChoreographer* choreographer, | 
|  | 95 | AChoreographer_frameCallback64 callback, void* data, uint32_t delayMillis) __INTRODUCED_IN(29); | 
|  | 96 |  | 
|  | 97 | #endif /* __ANDROID_API__ >= 29 */ | 
|  | 98 |  | 
| Michael Wright | f5eee40 | 2015-12-07 15:26:38 -0500 | [diff] [blame] | 99 | __END_DECLS | 
|  | 100 |  | 
|  | 101 | #endif // ANDROID_CHOREOGRAPHER_H | 
|  | 102 |  | 
|  | 103 | /** @} */ |