Jorim Jaggi | f51775d | 2021-01-14 23:44:15 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2021 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 | #ifndef ANDROID_PRIVATE_NATIVE_SURFACE_CONTROL_H |
| 18 | #define ANDROID_PRIVATE_NATIVE_SURFACE_CONTROL_H |
| 19 | |
| 20 | #include <stdint.h> |
| 21 | |
Rachel Lee | c0d38fc | 2023-01-06 14:46:10 -0800 | [diff] [blame] | 22 | #include <android/choreographer.h> |
| 23 | |
Jorim Jaggi | f51775d | 2021-01-14 23:44:15 +0100 | [diff] [blame] | 24 | __BEGIN_DECLS |
| 25 | |
| 26 | struct ASurfaceControl; |
| 27 | struct ASurfaceControlStats; |
| 28 | |
| 29 | typedef struct ASurfaceControlStats ASurfaceControlStats; |
| 30 | |
| 31 | /** |
| 32 | * Callback to be notified when surface stats for a specific surface control are available. |
| 33 | */ |
Pablo Gamito | ac8e561 | 2021-09-06 16:26:07 +0000 | [diff] [blame] | 34 | typedef void (*ASurfaceControl_SurfaceStatsListener)(void* context, int32_t id, |
| 35 | ASurfaceControlStats* stats); |
Jorim Jaggi | f51775d | 2021-01-14 23:44:15 +0100 | [diff] [blame] | 36 | |
| 37 | /** |
| 38 | * Registers a callback to be invoked when surface stats from a specific surface are available. |
| 39 | * |
| 40 | * \param context Optional context provided by the client that is passed into |
| 41 | * the callback. |
| 42 | * |
| 43 | * \param control The surface to retrieve callbacks for. |
| 44 | * |
| 45 | * \param func The callback to be invoked when surface stats are available. |
| 46 | */ |
Pablo Gamito | 577b72b | 2021-08-31 15:20:46 +0000 | [diff] [blame] | 47 | void ASurfaceControl_registerSurfaceStatsListener(ASurfaceControl* control, int32_t id, void* context, |
Jorim Jaggi | f51775d | 2021-01-14 23:44:15 +0100 | [diff] [blame] | 48 | ASurfaceControl_SurfaceStatsListener func); |
| 49 | |
| 50 | /** |
| 51 | * Unregisters a callback to be invoked when surface stats from a specific surface are available. |
| 52 | * |
| 53 | * \param context The context passed into ASurfaceControl_registerSurfaceStatsListener |
| 54 | * |
| 55 | * \param func The callback passed into ASurfaceControl_registerSurfaceStatsListener |
| 56 | */ |
| 57 | void ASurfaceControl_unregisterSurfaceStatsListener(void* context, |
| 58 | ASurfaceControl_SurfaceStatsListener func); |
| 59 | |
| 60 | /** |
Rachel Lee | c0d38fc | 2023-01-06 14:46:10 -0800 | [diff] [blame] | 61 | * Gets the attached AChoreographer instance from the given \c surfaceControl. If there is no |
| 62 | * choreographer associated with the surface control, then a new instance of choreographer is |
| 63 | * created. The new choreographer is associated with the current thread's Looper. |
| 64 | */ |
| 65 | AChoreographer* ASurfaceControl_getChoreographer(ASurfaceControl* surfaceControl); |
| 66 | |
| 67 | /** |
Jorim Jaggi | f51775d | 2021-01-14 23:44:15 +0100 | [diff] [blame] | 68 | * Returns the timestamp of when the buffer was acquired for a specific frame with frame number |
| 69 | * obtained from ASurfaceControlStats_getFrameNumber. |
| 70 | */ |
| 71 | int64_t ASurfaceControlStats_getAcquireTime(ASurfaceControlStats* stats); |
| 72 | |
| 73 | /** |
| 74 | * Returns the frame number of the surface stats object passed into the callback. |
| 75 | */ |
| 76 | uint64_t ASurfaceControlStats_getFrameNumber(ASurfaceControlStats* stats); |
| 77 | |
| 78 | __END_DECLS |
| 79 | |
| 80 | #endif //ANDROID_PRIVATE_NATIVE_SURFACE_CONTROL_H |