blob: 138926e55b2221739c9c67ec978ea32c8a443e9e [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
Rachel Leec0d38fc2023-01-06 14:46:10 -080022#include <android/choreographer.h>
23
Jorim Jaggif51775d2021-01-14 23:44:15 +010024__BEGIN_DECLS
25
26struct ASurfaceControl;
27struct ASurfaceControlStats;
28
29typedef struct ASurfaceControlStats ASurfaceControlStats;
30
31/**
32 * Callback to be notified when surface stats for a specific surface control are available.
33 */
Pablo Gamitoac8e5612021-09-06 16:26:07 +000034typedef void (*ASurfaceControl_SurfaceStatsListener)(void* context, int32_t id,
35 ASurfaceControlStats* stats);
Jorim Jaggif51775d2021-01-14 23:44:15 +010036
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 Gamito577b72b2021-08-31 15:20:46 +000047void ASurfaceControl_registerSurfaceStatsListener(ASurfaceControl* control, int32_t id, void* context,
Jorim Jaggif51775d2021-01-14 23:44:15 +010048 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 */
57void ASurfaceControl_unregisterSurfaceStatsListener(void* context,
58 ASurfaceControl_SurfaceStatsListener func);
59
60/**
Rachel Leec0d38fc2023-01-06 14:46:10 -080061 * 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 */
65AChoreographer* ASurfaceControl_getChoreographer(ASurfaceControl* surfaceControl);
66
67/**
Jorim Jaggif51775d2021-01-14 23:44:15 +010068 * Returns the timestamp of when the buffer was acquired for a specific frame with frame number
69 * obtained from ASurfaceControlStats_getFrameNumber.
70 */
71int64_t ASurfaceControlStats_getAcquireTime(ASurfaceControlStats* stats);
72
73/**
74 * Returns the frame number of the surface stats object passed into the callback.
75 */
76uint64_t ASurfaceControlStats_getFrameNumber(ASurfaceControlStats* stats);
77
78__END_DECLS
79
80#endif //ANDROID_PRIVATE_NATIVE_SURFACE_CONTROL_H