blob: 7af452a78293f86e8191a98e71f8ab373cc08298 [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
19#include <inttypes.h>
20
21__BEGIN_DECLS
22
23/**
24 * Opaque handle for a native display
25 */
26typedef struct ADisplay ADisplay;
27
28/**
29 * Enum describing the possible types of a display
30 */
31enum ADisplayType {
32 /**
33 * A display that is the internal, or "primary" display for a device.
34 */
35 DISPLAY_TYPE_INTERNAL = 0,
36
37 /**
38 * A display that is externally connected for a device.
39 */
40 DISPLAY_TYPE_EXTERNAL = 1,
41};
42
43/**
44 * Opaque handle for display metadata
45 */
46typedef struct ADisplayConfig ADisplayConfig;
47
48/**
49 * Acquires a list of display handles. Memory is allocated for the list and is
50 * owned by the caller. The caller is responsible for freeing this memory by
51 * calling ADisplayList_release.
52 *
53 * Returns the size of the returned list on success.
54 * Returns -errno on error.
55 */
56int ADisplay_acquirePhysicalDisplays(ADisplay*** outDisplays);
57
58/**
59 * Releases a list of display handles created by
60 * ADisplayList_acquirePhysicalDisplays.
61 */
62void ADisplay_release(ADisplay** displays);
63
64/**
65 * Queries the maximum supported fps for the given display.
66 */
67float ADisplay_getMaxSupportedFps(ADisplay* display);
68
69/**
70 * Queries the display's type.
71 */
72ADisplayType ADisplay_getDisplayType(ADisplay* display);
73
74/**
75 * Gets the current display configuration for the given display.
76 *
77 * Memory is *not* allocated for the caller. As such, the returned output
78 * configuration's lifetime will not be longer than the ADisplay* passed to this
79 * function - if ADisplay_release is called destroying the ADisplay object then
80 * it is invalid to access the ADisplayConfig returned here.
81 *
82 * Note that the current display configuration can change. Listening to updates
83 * to the current display configuration should be done via Choreographer. If
84 * such an update is observed, then this method should be recalled to get the
85 * new current configuration.
86 *
87 * Returns OK on success, -errno on failure.
88 */
89int ADisplay_getCurrentConfig(ADisplay* display, ADisplayConfig** outConfig);
90
91/**
92 * Queries the density for a given display configuration.
93 */
94float ADisplayConfig_getDensity(ADisplayConfig* config);
95
96/**
97 * Queries the width in pixels for a given display configuration.
98 */
99int32_t ADisplayConfig_getWidth(ADisplayConfig* config);
100
101/**
102 * Queries the height in pixels for a given display configuration.
103 */
104int32_t ADisplayConfig_getHeight(ADisplayConfig* config);
105
106/**
107 * Queries the display refresh rate for a given display configuration.
108 */
109float ADisplayConfig_getFps(ADisplayConfig* config);
110
111/**
112 * Queries the vsync offset from which the system compositor is scheduled to
113 * run. If a vsync occurs at time T, and the compositor runs at time T + S, then
114 * this returns S in nanoseconds.
115 */
116int64_t ADisplayConfig_getCompositorOffsetNanos(ADisplayConfig* config);
117
118/**
119 * Queries the vsync offset from which applications are scheduled to run. If a
120 * vsync occurs at time T, and applications run at time T + S, then this returns
121 * S in nanoseconds.
122 */
123int64_t ADisplayConfig_getAppVsyncOffsetNanos(ADisplayConfig* config);
124
125__END_DECLS