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 22 __BEGIN_DECLS 23 24 struct ASurfaceControl; 25 struct ASurfaceControlStats; 26 27 typedef struct ASurfaceControlStats ASurfaceControlStats; 28 29 /** 30 * Callback to be notified when surface stats for a specific surface control are available. 31 */ 32 typedef void (*ASurfaceControl_SurfaceStatsListener)(void* context, 33 ASurfaceControl* control, ASurfaceControlStats* stats); 34 35 /** 36 * Registers a callback to be invoked when surface stats from a specific surface are available. 37 * 38 * \param context Optional context provided by the client that is passed into 39 * the callback. 40 * 41 * \param control The surface to retrieve callbacks for. 42 * 43 * \param func The callback to be invoked when surface stats are available. 44 */ 45 void ASurfaceControl_registerSurfaceStatsListener(ASurfaceControl* control, void* context, 46 ASurfaceControl_SurfaceStatsListener func); 47 48 /** 49 * Unregisters a callback to be invoked when surface stats from a specific surface are available. 50 * 51 * \param context The context passed into ASurfaceControl_registerSurfaceStatsListener 52 * 53 * \param func The callback passed into ASurfaceControl_registerSurfaceStatsListener 54 */ 55 void ASurfaceControl_unregisterSurfaceStatsListener(void* context, 56 ASurfaceControl_SurfaceStatsListener func); 57 58 /** 59 * Returns the timestamp of when the buffer was acquired for a specific frame with frame number 60 * obtained from ASurfaceControlStats_getFrameNumber. 61 */ 62 int64_t ASurfaceControlStats_getAcquireTime(ASurfaceControlStats* stats); 63 64 /** 65 * Returns the frame number of the surface stats object passed into the callback. 66 */ 67 uint64_t ASurfaceControlStats_getFrameNumber(ASurfaceControlStats* stats); 68 69 __END_DECLS 70 71 #endif //ANDROID_PRIVATE_NATIVE_SURFACE_CONTROL_H 72