blob: 44324f8314c8507f90001ee5e6b0403229b556d6 [file] [log] [blame]
Jorim Jaggif51775d2021-01-14 23:44:15 +01001/*
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
24struct ASurfaceControl;
25struct ASurfaceControlStats;
26
27typedef struct ASurfaceControlStats ASurfaceControlStats;
28
29/**
30 * Callback to be notified when surface stats for a specific surface control are available.
31 */
32typedef void (*ASurfaceControl_SurfaceStatsListener)(void* context,
Pablo Gamito577b72b2021-08-31 15:20:46 +000033 ASurfaceControl* control, int32_t id, ASurfaceControlStats* stats);
Jorim Jaggif51775d2021-01-14 23:44:15 +010034
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 */
Pablo Gamito577b72b2021-08-31 15:20:46 +000045void ASurfaceControl_registerSurfaceStatsListener(ASurfaceControl* control, int32_t id, void* context,
Jorim Jaggif51775d2021-01-14 23:44:15 +010046 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 */
55void 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 */
62int64_t ASurfaceControlStats_getAcquireTime(ASurfaceControlStats* stats);
63
64/**
65 * Returns the frame number of the surface stats object passed into the callback.
66 */
67uint64_t ASurfaceControlStats_getFrameNumber(ASurfaceControlStats* stats);
68
69__END_DECLS
70
71#endif //ANDROID_PRIVATE_NATIVE_SURFACE_CONTROL_H