blob: a7eaf87b9e50e68766fed05e80d76071193c0acd [file] [log] [blame]
Alec Mouri671d0f52019-09-05 13:59:19 -07001/*
2 * Copyright 2019 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#pragma once
18
Alec Mouri46170512019-11-20 11:04:55 -080019#include <android/data_space.h>
20#include <android/hardware_buffer.h>
Alec Mouri671d0f52019-09-05 13:59:19 -070021#include <inttypes.h>
22
Alec Mourid9ff3272019-11-19 16:23:59 -080023// TODO: the intention of these apis is to be stable - hence they are defined in
24// an apex directory. But because they don't yet need to be stable, hold off on
25// making them stable until a Mainline module needs them.
26// __BEGIN_DECLS
27
28namespace android {
Alec Mouri671d0f52019-09-05 13:59:19 -070029
30/**
31 * Opaque handle for a native display
32 */
33typedef struct ADisplay ADisplay;
34
35/**
36 * Enum describing the possible types of a display
37 */
38enum ADisplayType {
39 /**
40 * A display that is the internal, or "primary" display for a device.
41 */
42 DISPLAY_TYPE_INTERNAL = 0,
43
44 /**
45 * A display that is externally connected for a device.
46 */
47 DISPLAY_TYPE_EXTERNAL = 1,
48};
49
50/**
51 * Opaque handle for display metadata
52 */
53typedef struct ADisplayConfig ADisplayConfig;
54
55/**
56 * Acquires a list of display handles. Memory is allocated for the list and is
57 * owned by the caller. The caller is responsible for freeing this memory by
58 * calling ADisplayList_release.
59 *
60 * Returns the size of the returned list on success.
61 * Returns -errno on error.
62 */
63int ADisplay_acquirePhysicalDisplays(ADisplay*** outDisplays);
64
65/**
66 * Releases a list of display handles created by
67 * ADisplayList_acquirePhysicalDisplays.
68 */
69void ADisplay_release(ADisplay** displays);
70
71/**
72 * Queries the maximum supported fps for the given display.
73 */
74float ADisplay_getMaxSupportedFps(ADisplay* display);
75
76/**
77 * Queries the display's type.
78 */
79ADisplayType ADisplay_getDisplayType(ADisplay* display);
80
81/**
Alec Mouri46170512019-11-20 11:04:55 -080082 * Queries the display's preferred WCG format
83 */
84void ADisplay_getPreferredWideColorFormat(ADisplay* display, ADataSpace* outDataspace,
85 AHardwareBuffer_Format* outPixelFormat);
86
87/**
Alec Mouri671d0f52019-09-05 13:59:19 -070088 * Gets the current display configuration for the given display.
89 *
90 * Memory is *not* allocated for the caller. As such, the returned output
91 * configuration's lifetime will not be longer than the ADisplay* passed to this
92 * function - if ADisplay_release is called destroying the ADisplay object then
93 * it is invalid to access the ADisplayConfig returned here.
94 *
95 * Note that the current display configuration can change. Listening to updates
96 * to the current display configuration should be done via Choreographer. If
97 * such an update is observed, then this method should be recalled to get the
98 * new current configuration.
99 *
100 * Returns OK on success, -errno on failure.
101 */
102int ADisplay_getCurrentConfig(ADisplay* display, ADisplayConfig** outConfig);
103
104/**
105 * Queries the density for a given display configuration.
106 */
107float ADisplayConfig_getDensity(ADisplayConfig* config);
108
109/**
110 * Queries the width in pixels for a given display configuration.
111 */
112int32_t ADisplayConfig_getWidth(ADisplayConfig* config);
113
114/**
115 * Queries the height in pixels for a given display configuration.
116 */
117int32_t ADisplayConfig_getHeight(ADisplayConfig* config);
118
119/**
120 * Queries the display refresh rate for a given display configuration.
121 */
122float ADisplayConfig_getFps(ADisplayConfig* config);
123
124/**
125 * Queries the vsync offset from which the system compositor is scheduled to
126 * run. If a vsync occurs at time T, and the compositor runs at time T + S, then
127 * this returns S in nanoseconds.
128 */
129int64_t ADisplayConfig_getCompositorOffsetNanos(ADisplayConfig* config);
130
131/**
132 * Queries the vsync offset from which applications are scheduled to run. If a
133 * vsync occurs at time T, and applications run at time T + S, then this returns
134 * S in nanoseconds.
135 */
136int64_t ADisplayConfig_getAppVsyncOffsetNanos(ADisplayConfig* config);
137
Alec Mourid9ff3272019-11-19 16:23:59 -0800138} // namespace android
139// __END_DECLS