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