Alec Mouri | cc44522 | 2019-10-22 10:19:17 -0700 | [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 | |
Alec Mouri | 271de04 | 2020-04-27 22:38:19 -0700 | [diff] [blame] | 17 | #include <android-base/thread_annotations.h> |
Huihong Luo | 1b0c49f | 2022-03-15 19:18:21 -0700 | [diff] [blame] | 18 | #include <android/gui/ISurfaceComposer.h> |
Rachel Lee | 273c18c | 2022-12-13 14:35:07 -0800 | [diff] [blame] | 19 | #include <gui/Choreographer.h> |
Orion Hodson | e53587b | 2021-02-02 15:33:33 +0000 | [diff] [blame] | 20 | #include <jni.h> |
Alec Mouri | 271de04 | 2020-04-27 22:38:19 -0700 | [diff] [blame] | 21 | #include <private/android/choreographer.h> |
Alec Mouri | cc44522 | 2019-10-22 10:19:17 -0700 | [diff] [blame] | 22 | #include <utils/Looper.h> |
Alec Mouri | cc44522 | 2019-10-22 10:19:17 -0700 | [diff] [blame] | 23 | #include <utils/Timers.h> |
| 24 | |
Alec Mouri | 60aee1c | 2019-10-28 16:18:59 -0700 | [diff] [blame] | 25 | #include <cinttypes> |
Alec Mouri | 271de04 | 2020-04-27 22:38:19 -0700 | [diff] [blame] | 26 | #include <mutex> |
Alec Mouri | 60aee1c | 2019-10-28 16:18:59 -0700 | [diff] [blame] | 27 | #include <optional> |
| 28 | #include <queue> |
| 29 | #include <thread> |
| 30 | |
Rachel Lee | ace701c | 2022-10-05 10:23:47 -0700 | [diff] [blame] | 31 | #undef LOG_TAG |
| 32 | #define LOG_TAG "AChoreographer" |
Alec Mouri | cc44522 | 2019-10-22 10:19:17 -0700 | [diff] [blame] | 33 | |
Alec Mouri | 50a931d | 2019-11-19 16:23:59 -0800 | [diff] [blame] | 34 | using namespace android; |
Alec Mouri | cc44522 | 2019-10-22 10:19:17 -0700 | [diff] [blame] | 35 | |
| 36 | static inline Choreographer* AChoreographer_to_Choreographer(AChoreographer* choreographer) { |
| 37 | return reinterpret_cast<Choreographer*>(choreographer); |
| 38 | } |
| 39 | |
Ady Abraham | 74e1756 | 2020-08-24 18:18:19 -0700 | [diff] [blame] | 40 | static inline const Choreographer* AChoreographer_to_Choreographer( |
| 41 | const AChoreographer* choreographer) { |
| 42 | return reinterpret_cast<const Choreographer*>(choreographer); |
| 43 | } |
| 44 | |
Rachel Lee | 4879d81 | 2021-08-25 11:50:11 -0700 | [diff] [blame] | 45 | static inline const ChoreographerFrameCallbackDataImpl* |
| 46 | AChoreographerFrameCallbackData_to_ChoreographerFrameCallbackDataImpl( |
| 47 | const AChoreographerFrameCallbackData* data) { |
| 48 | return reinterpret_cast<const ChoreographerFrameCallbackDataImpl*>(data); |
| 49 | } |
| 50 | |
Alec Mouri | 271de04 | 2020-04-27 22:38:19 -0700 | [diff] [blame] | 51 | // Glue for private C api |
| 52 | namespace android { |
Rachel Lee | ace701c | 2022-10-05 10:23:47 -0700 | [diff] [blame] | 53 | void AChoreographer_signalRefreshRateCallbacks(nsecs_t vsyncPeriod) { |
| 54 | Choreographer::signalRefreshRateCallbacks(vsyncPeriod); |
Alec Mouri | 271de04 | 2020-04-27 22:38:19 -0700 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | void AChoreographer_initJVM(JNIEnv* env) { |
Rachel Lee | ace701c | 2022-10-05 10:23:47 -0700 | [diff] [blame] | 58 | Choreographer::initJVM(env); |
Alec Mouri | 271de04 | 2020-04-27 22:38:19 -0700 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | AChoreographer* AChoreographer_routeGetInstance() { |
| 62 | return AChoreographer_getInstance(); |
| 63 | } |
| 64 | void AChoreographer_routePostFrameCallback(AChoreographer* choreographer, |
| 65 | AChoreographer_frameCallback callback, void* data) { |
Jiyong Park | 8cdf076 | 2020-08-13 20:21:57 +0900 | [diff] [blame] | 66 | #pragma clang diagnostic push |
| 67 | #pragma clang diagnostic ignored "-Wdeprecated-declarations" |
Alec Mouri | 271de04 | 2020-04-27 22:38:19 -0700 | [diff] [blame] | 68 | return AChoreographer_postFrameCallback(choreographer, callback, data); |
Jiyong Park | 8cdf076 | 2020-08-13 20:21:57 +0900 | [diff] [blame] | 69 | #pragma clang diagnostic pop |
Alec Mouri | 271de04 | 2020-04-27 22:38:19 -0700 | [diff] [blame] | 70 | } |
| 71 | void AChoreographer_routePostFrameCallbackDelayed(AChoreographer* choreographer, |
| 72 | AChoreographer_frameCallback callback, void* data, |
| 73 | long delayMillis) { |
Jiyong Park | 8cdf076 | 2020-08-13 20:21:57 +0900 | [diff] [blame] | 74 | #pragma clang diagnostic push |
| 75 | #pragma clang diagnostic ignored "-Wdeprecated-declarations" |
Alec Mouri | 271de04 | 2020-04-27 22:38:19 -0700 | [diff] [blame] | 76 | return AChoreographer_postFrameCallbackDelayed(choreographer, callback, data, delayMillis); |
Jiyong Park | 8cdf076 | 2020-08-13 20:21:57 +0900 | [diff] [blame] | 77 | #pragma clang diagnostic pop |
Alec Mouri | 271de04 | 2020-04-27 22:38:19 -0700 | [diff] [blame] | 78 | } |
| 79 | void AChoreographer_routePostFrameCallback64(AChoreographer* choreographer, |
| 80 | AChoreographer_frameCallback64 callback, void* data) { |
| 81 | return AChoreographer_postFrameCallback64(choreographer, callback, data); |
| 82 | } |
| 83 | void AChoreographer_routePostFrameCallbackDelayed64(AChoreographer* choreographer, |
| 84 | AChoreographer_frameCallback64 callback, |
| 85 | void* data, uint32_t delayMillis) { |
| 86 | return AChoreographer_postFrameCallbackDelayed64(choreographer, callback, data, delayMillis); |
| 87 | } |
Rachel Lee | f4dc39f | 2022-02-15 18:30:59 -0800 | [diff] [blame] | 88 | void AChoreographer_routePostVsyncCallback(AChoreographer* choreographer, |
| 89 | AChoreographer_vsyncCallback callback, void* data) { |
| 90 | return AChoreographer_postVsyncCallback(choreographer, callback, data); |
Rachel Lee | 4879d81 | 2021-08-25 11:50:11 -0700 | [diff] [blame] | 91 | } |
Alec Mouri | 271de04 | 2020-04-27 22:38:19 -0700 | [diff] [blame] | 92 | void AChoreographer_routeRegisterRefreshRateCallback(AChoreographer* choreographer, |
| 93 | AChoreographer_refreshRateCallback callback, |
| 94 | void* data) { |
| 95 | return AChoreographer_registerRefreshRateCallback(choreographer, callback, data); |
| 96 | } |
| 97 | void AChoreographer_routeUnregisterRefreshRateCallback(AChoreographer* choreographer, |
| 98 | AChoreographer_refreshRateCallback callback, |
| 99 | void* data) { |
| 100 | return AChoreographer_unregisterRefreshRateCallback(choreographer, callback, data); |
| 101 | } |
Rachel Lee | 4879d81 | 2021-08-25 11:50:11 -0700 | [diff] [blame] | 102 | int64_t AChoreographerFrameCallbackData_routeGetFrameTimeNanos( |
| 103 | const AChoreographerFrameCallbackData* data) { |
| 104 | return AChoreographerFrameCallbackData_getFrameTimeNanos(data); |
| 105 | } |
| 106 | size_t AChoreographerFrameCallbackData_routeGetFrameTimelinesLength( |
| 107 | const AChoreographerFrameCallbackData* data) { |
| 108 | return AChoreographerFrameCallbackData_getFrameTimelinesLength(data); |
| 109 | } |
| 110 | size_t AChoreographerFrameCallbackData_routeGetPreferredFrameTimelineIndex( |
| 111 | const AChoreographerFrameCallbackData* data) { |
| 112 | return AChoreographerFrameCallbackData_getPreferredFrameTimelineIndex(data); |
| 113 | } |
Rachel Lee | 1fb2ddc | 2022-01-12 14:33:07 -0800 | [diff] [blame] | 114 | AVsyncId AChoreographerFrameCallbackData_routeGetFrameTimelineVsyncId( |
Rachel Lee | 4879d81 | 2021-08-25 11:50:11 -0700 | [diff] [blame] | 115 | const AChoreographerFrameCallbackData* data, size_t index) { |
| 116 | return AChoreographerFrameCallbackData_getFrameTimelineVsyncId(data, index); |
| 117 | } |
Rachel Lee | f4dc39f | 2022-02-15 18:30:59 -0800 | [diff] [blame] | 118 | int64_t AChoreographerFrameCallbackData_routeGetFrameTimelineExpectedPresentationTimeNanos( |
Rachel Lee | 4879d81 | 2021-08-25 11:50:11 -0700 | [diff] [blame] | 119 | const AChoreographerFrameCallbackData* data, size_t index) { |
Rachel Lee | f4dc39f | 2022-02-15 18:30:59 -0800 | [diff] [blame] | 120 | return AChoreographerFrameCallbackData_getFrameTimelineExpectedPresentationTimeNanos(data, |
| 121 | index); |
Rachel Lee | 4879d81 | 2021-08-25 11:50:11 -0700 | [diff] [blame] | 122 | } |
Rachel Lee | 2825fa2 | 2022-01-12 17:35:16 -0800 | [diff] [blame] | 123 | int64_t AChoreographerFrameCallbackData_routeGetFrameTimelineDeadlineNanos( |
Rachel Lee | 4879d81 | 2021-08-25 11:50:11 -0700 | [diff] [blame] | 124 | const AChoreographerFrameCallbackData* data, size_t index) { |
Rachel Lee | 2825fa2 | 2022-01-12 17:35:16 -0800 | [diff] [blame] | 125 | return AChoreographerFrameCallbackData_getFrameTimelineDeadlineNanos(data, index); |
Rachel Lee | 4879d81 | 2021-08-25 11:50:11 -0700 | [diff] [blame] | 126 | } |
Alec Mouri | 271de04 | 2020-04-27 22:38:19 -0700 | [diff] [blame] | 127 | |
Jorim Jaggi | c0086af | 2021-02-12 18:18:11 +0100 | [diff] [blame] | 128 | int64_t AChoreographer_getFrameInterval(const AChoreographer* choreographer) { |
| 129 | return AChoreographer_to_Choreographer(choreographer)->getFrameInterval(); |
| 130 | } |
| 131 | |
Rachel Lee | 103a58a | 2022-02-22 15:51:05 -0800 | [diff] [blame] | 132 | int64_t AChoreographer_getStartTimeNanosForVsyncId(AVsyncId vsyncId) { |
Rachel Lee | ace701c | 2022-10-05 10:23:47 -0700 | [diff] [blame] | 133 | return Choreographer::getStartTimeNanosForVsyncId(vsyncId); |
Rachel Lee | 103a58a | 2022-02-22 15:51:05 -0800 | [diff] [blame] | 134 | } |
| 135 | |
Alec Mouri | 271de04 | 2020-04-27 22:38:19 -0700 | [diff] [blame] | 136 | } // namespace android |
| 137 | |
| 138 | /* Glue for the NDK interface */ |
| 139 | |
Alec Mouri | cc44522 | 2019-10-22 10:19:17 -0700 | [diff] [blame] | 140 | static inline AChoreographer* Choreographer_to_AChoreographer(Choreographer* choreographer) { |
| 141 | return reinterpret_cast<AChoreographer*>(choreographer); |
| 142 | } |
| 143 | |
| 144 | AChoreographer* AChoreographer_getInstance() { |
| 145 | return Choreographer_to_AChoreographer(Choreographer::getForThread()); |
| 146 | } |
| 147 | |
| 148 | void AChoreographer_postFrameCallback(AChoreographer* choreographer, |
Rachel Lee | 4879d81 | 2021-08-25 11:50:11 -0700 | [diff] [blame] | 149 | AChoreographer_frameCallback callback, void* data) { |
| 150 | AChoreographer_to_Choreographer(choreographer) |
Chavi Weingarten | 475c413 | 2024-02-29 15:56:15 +0000 | [diff] [blame] | 151 | ->postFrameCallbackDelayed(callback, nullptr, nullptr, data, 0, CALLBACK_ANIMATION); |
Alec Mouri | cc44522 | 2019-10-22 10:19:17 -0700 | [diff] [blame] | 152 | } |
| 153 | void AChoreographer_postFrameCallbackDelayed(AChoreographer* choreographer, |
Rachel Lee | 4879d81 | 2021-08-25 11:50:11 -0700 | [diff] [blame] | 154 | AChoreographer_frameCallback callback, void* data, |
| 155 | long delayMillis) { |
| 156 | AChoreographer_to_Choreographer(choreographer) |
Chavi Weingarten | 475c413 | 2024-02-29 15:56:15 +0000 | [diff] [blame] | 157 | ->postFrameCallbackDelayed(callback, nullptr, nullptr, data, ms2ns(delayMillis), |
| 158 | CALLBACK_ANIMATION); |
Rachel Lee | 4879d81 | 2021-08-25 11:50:11 -0700 | [diff] [blame] | 159 | } |
Rachel Lee | f4dc39f | 2022-02-15 18:30:59 -0800 | [diff] [blame] | 160 | void AChoreographer_postVsyncCallback(AChoreographer* choreographer, |
| 161 | AChoreographer_vsyncCallback callback, void* data) { |
Rachel Lee | 4879d81 | 2021-08-25 11:50:11 -0700 | [diff] [blame] | 162 | AChoreographer_to_Choreographer(choreographer) |
Chavi Weingarten | 475c413 | 2024-02-29 15:56:15 +0000 | [diff] [blame] | 163 | ->postFrameCallbackDelayed(nullptr, nullptr, callback, data, 0, CALLBACK_ANIMATION); |
Alec Mouri | cc44522 | 2019-10-22 10:19:17 -0700 | [diff] [blame] | 164 | } |
| 165 | void AChoreographer_postFrameCallback64(AChoreographer* choreographer, |
Rachel Lee | 4879d81 | 2021-08-25 11:50:11 -0700 | [diff] [blame] | 166 | AChoreographer_frameCallback64 callback, void* data) { |
| 167 | AChoreographer_to_Choreographer(choreographer) |
Chavi Weingarten | 475c413 | 2024-02-29 15:56:15 +0000 | [diff] [blame] | 168 | ->postFrameCallbackDelayed(nullptr, callback, nullptr, data, 0, CALLBACK_ANIMATION); |
Alec Mouri | cc44522 | 2019-10-22 10:19:17 -0700 | [diff] [blame] | 169 | } |
| 170 | void AChoreographer_postFrameCallbackDelayed64(AChoreographer* choreographer, |
Rachel Lee | 4879d81 | 2021-08-25 11:50:11 -0700 | [diff] [blame] | 171 | AChoreographer_frameCallback64 callback, void* data, |
| 172 | uint32_t delayMillis) { |
| 173 | AChoreographer_to_Choreographer(choreographer) |
Chavi Weingarten | 475c413 | 2024-02-29 15:56:15 +0000 | [diff] [blame] | 174 | ->postFrameCallbackDelayed(nullptr, callback, nullptr, data, ms2ns(delayMillis), |
| 175 | CALLBACK_ANIMATION); |
Alec Mouri | cc44522 | 2019-10-22 10:19:17 -0700 | [diff] [blame] | 176 | } |
Alec Mouri | 60aee1c | 2019-10-28 16:18:59 -0700 | [diff] [blame] | 177 | void AChoreographer_registerRefreshRateCallback(AChoreographer* choreographer, |
| 178 | AChoreographer_refreshRateCallback callback, |
| 179 | void* data) { |
| 180 | AChoreographer_to_Choreographer(choreographer)->registerRefreshRateCallback(callback, data); |
| 181 | } |
| 182 | void AChoreographer_unregisterRefreshRateCallback(AChoreographer* choreographer, |
Alec Mouri | 33682e9 | 2020-01-10 15:11:15 -0800 | [diff] [blame] | 183 | AChoreographer_refreshRateCallback callback, |
| 184 | void* data) { |
| 185 | AChoreographer_to_Choreographer(choreographer)->unregisterRefreshRateCallback(callback, data); |
Alec Mouri | 60aee1c | 2019-10-28 16:18:59 -0700 | [diff] [blame] | 186 | } |
Alec Mouri | 50a931d | 2019-11-19 16:23:59 -0800 | [diff] [blame] | 187 | |
Rachel Lee | 4879d81 | 2021-08-25 11:50:11 -0700 | [diff] [blame] | 188 | int64_t AChoreographerFrameCallbackData_getFrameTimeNanos( |
| 189 | const AChoreographerFrameCallbackData* data) { |
| 190 | const ChoreographerFrameCallbackDataImpl* frameCallbackData = |
| 191 | AChoreographerFrameCallbackData_to_ChoreographerFrameCallbackDataImpl(data); |
| 192 | LOG_ALWAYS_FATAL_IF(!frameCallbackData->choreographer->inCallback(), |
| 193 | "Data is only valid in callback"); |
| 194 | return frameCallbackData->frameTimeNanos; |
| 195 | } |
| 196 | size_t AChoreographerFrameCallbackData_getFrameTimelinesLength( |
| 197 | const AChoreographerFrameCallbackData* data) { |
| 198 | const ChoreographerFrameCallbackDataImpl* frameCallbackData = |
| 199 | AChoreographerFrameCallbackData_to_ChoreographerFrameCallbackDataImpl(data); |
| 200 | LOG_ALWAYS_FATAL_IF(!frameCallbackData->choreographer->inCallback(), |
| 201 | "Data is only valid in callback"); |
Rachel Lee | 0655a91 | 2023-04-20 19:54:18 -0700 | [diff] [blame] | 202 | return frameCallbackData->vsyncEventData.frameTimelinesLength; |
Rachel Lee | 4879d81 | 2021-08-25 11:50:11 -0700 | [diff] [blame] | 203 | } |
| 204 | size_t AChoreographerFrameCallbackData_getPreferredFrameTimelineIndex( |
| 205 | const AChoreographerFrameCallbackData* data) { |
| 206 | const ChoreographerFrameCallbackDataImpl* frameCallbackData = |
| 207 | AChoreographerFrameCallbackData_to_ChoreographerFrameCallbackDataImpl(data); |
| 208 | LOG_ALWAYS_FATAL_IF(!frameCallbackData->choreographer->inCallback(), |
| 209 | "Data is only valid in callback"); |
Rachel Lee | b9c5a77 | 2022-02-04 21:17:37 -0800 | [diff] [blame] | 210 | return frameCallbackData->vsyncEventData.preferredFrameTimelineIndex; |
Rachel Lee | 4879d81 | 2021-08-25 11:50:11 -0700 | [diff] [blame] | 211 | } |
Rachel Lee | 1fb2ddc | 2022-01-12 14:33:07 -0800 | [diff] [blame] | 212 | AVsyncId AChoreographerFrameCallbackData_getFrameTimelineVsyncId( |
Rachel Lee | 4879d81 | 2021-08-25 11:50:11 -0700 | [diff] [blame] | 213 | const AChoreographerFrameCallbackData* data, size_t index) { |
| 214 | const ChoreographerFrameCallbackDataImpl* frameCallbackData = |
| 215 | AChoreographerFrameCallbackData_to_ChoreographerFrameCallbackDataImpl(data); |
| 216 | LOG_ALWAYS_FATAL_IF(!frameCallbackData->choreographer->inCallback(), |
| 217 | "Data is only valid in callback"); |
Rachel Lee | 40aef42 | 2023-04-25 14:35:47 -0700 | [diff] [blame] | 218 | LOG_ALWAYS_FATAL_IF(index >= VsyncEventData::kFrameTimelinesCapacity, "Index out of bounds"); |
Rachel Lee | b9c5a77 | 2022-02-04 21:17:37 -0800 | [diff] [blame] | 219 | return frameCallbackData->vsyncEventData.frameTimelines[index].vsyncId; |
Rachel Lee | 4879d81 | 2021-08-25 11:50:11 -0700 | [diff] [blame] | 220 | } |
Rachel Lee | f4dc39f | 2022-02-15 18:30:59 -0800 | [diff] [blame] | 221 | int64_t AChoreographerFrameCallbackData_getFrameTimelineExpectedPresentationTimeNanos( |
Rachel Lee | 4879d81 | 2021-08-25 11:50:11 -0700 | [diff] [blame] | 222 | const AChoreographerFrameCallbackData* data, size_t index) { |
| 223 | const ChoreographerFrameCallbackDataImpl* frameCallbackData = |
| 224 | AChoreographerFrameCallbackData_to_ChoreographerFrameCallbackDataImpl(data); |
| 225 | LOG_ALWAYS_FATAL_IF(!frameCallbackData->choreographer->inCallback(), |
| 226 | "Data is only valid in callback"); |
Rachel Lee | 40aef42 | 2023-04-25 14:35:47 -0700 | [diff] [blame] | 227 | LOG_ALWAYS_FATAL_IF(index >= VsyncEventData::kFrameTimelinesCapacity, "Index out of bounds"); |
Rachel Lee | b9c5a77 | 2022-02-04 21:17:37 -0800 | [diff] [blame] | 228 | return frameCallbackData->vsyncEventData.frameTimelines[index].expectedPresentationTime; |
Rachel Lee | 4879d81 | 2021-08-25 11:50:11 -0700 | [diff] [blame] | 229 | } |
Rachel Lee | 2825fa2 | 2022-01-12 17:35:16 -0800 | [diff] [blame] | 230 | int64_t AChoreographerFrameCallbackData_getFrameTimelineDeadlineNanos( |
Rachel Lee | 4879d81 | 2021-08-25 11:50:11 -0700 | [diff] [blame] | 231 | const AChoreographerFrameCallbackData* data, size_t index) { |
| 232 | const ChoreographerFrameCallbackDataImpl* frameCallbackData = |
| 233 | AChoreographerFrameCallbackData_to_ChoreographerFrameCallbackDataImpl(data); |
| 234 | LOG_ALWAYS_FATAL_IF(!frameCallbackData->choreographer->inCallback(), |
| 235 | "Data is only valid in callback"); |
Rachel Lee | 40aef42 | 2023-04-25 14:35:47 -0700 | [diff] [blame] | 236 | LOG_ALWAYS_FATAL_IF(index >= VsyncEventData::kFrameTimelinesCapacity, "Index out of bounds"); |
Rachel Lee | b9c5a77 | 2022-02-04 21:17:37 -0800 | [diff] [blame] | 237 | return frameCallbackData->vsyncEventData.frameTimelines[index].deadlineTimestamp; |
Rachel Lee | 4879d81 | 2021-08-25 11:50:11 -0700 | [diff] [blame] | 238 | } |
| 239 | |
Alec Mouri | 50a931d | 2019-11-19 16:23:59 -0800 | [diff] [blame] | 240 | AChoreographer* AChoreographer_create() { |
| 241 | Choreographer* choreographer = new Choreographer(nullptr); |
| 242 | status_t result = choreographer->initialize(); |
| 243 | if (result != OK) { |
| 244 | ALOGW("Failed to initialize"); |
| 245 | return nullptr; |
| 246 | } |
| 247 | return Choreographer_to_AChoreographer(choreographer); |
| 248 | } |
| 249 | |
| 250 | void AChoreographer_destroy(AChoreographer* choreographer) { |
| 251 | if (choreographer == nullptr) { |
| 252 | return; |
| 253 | } |
| 254 | |
| 255 | delete AChoreographer_to_Choreographer(choreographer); |
| 256 | } |
| 257 | |
Alec Mouri | 921b277 | 2020-02-05 19:03:28 -0800 | [diff] [blame] | 258 | int AChoreographer_getFd(const AChoreographer* choreographer) { |
Alec Mouri | 50a931d | 2019-11-19 16:23:59 -0800 | [diff] [blame] | 259 | return AChoreographer_to_Choreographer(choreographer)->getFd(); |
| 260 | } |
| 261 | |
| 262 | void AChoreographer_handlePendingEvents(AChoreographer* choreographer, void* data) { |
| 263 | // Pass dummy fd and events args to handleEvent, since the underlying |
| 264 | // DisplayEventDispatcher doesn't need them outside of validating that a |
| 265 | // Looper instance didn't break, but these args circumvent those checks. |
Alec Mouri | 271de04 | 2020-04-27 22:38:19 -0700 | [diff] [blame] | 266 | Choreographer* impl = AChoreographer_to_Choreographer(choreographer); |
| 267 | impl->handleEvent(-1, Looper::EVENT_INPUT, data); |
Alec Mouri | 50a931d | 2019-11-19 16:23:59 -0800 | [diff] [blame] | 268 | } |