window.h revision 6b376713907086c9642e7b7e66e51ddfa531b003
1a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/*
2a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Copyright (C) 2011 The Android Open Source Project
3a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *
4a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Licensed under the Apache License, Version 2.0 (the "License");
5a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * you may not use this file except in compliance with the License.
6a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * You may obtain a copy of the License at
7a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *
8a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *      http://www.apache.org/licenses/LICENSE-2.0
9a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *
10a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Unless required by applicable law or agreed to in writing, software
11a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * distributed under the License is distributed on an "AS IS" BASIS,
12a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * See the License for the specific language governing permissions and
14a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * limitations under the License.
15a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */
16a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
17a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/*************************************************************************************************
18a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *
19a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * IMPORTANT:
20a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *
21a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * There is an old copy of this file in system/core/include/system/window.h, which exists only
22a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * for backward source compatibility.
23a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * But there are binaries out there as well, so this version of window.h must stay binary
24a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * backward compatible with the one found in system/core.
25a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *
26a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *
27a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Source compatibility is also required for now, because this is how we're handling the
28a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * transition from system/core/include (global include path) to nativewindow/include.
29a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *
30a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *************************************************************************************************/
31a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
32a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#pragma once
33a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
34a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#include <cutils/native_handle.h>
35a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#include <errno.h>
36a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#include <limits.h>
37a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#include <stdint.h>
38a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#include <string.h>
39a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#include <sys/cdefs.h>
40a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#include <system/graphics.h>
41a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#include <unistd.h>
42a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#include <stdbool.h>
43a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
44a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian// system/window.h is a superset of the vndk
45a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#include <vndk/window.h>
46a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
47a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
48a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#ifndef __UNUSED
49a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#define __UNUSED __attribute__((__unused__))
50a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#endif
51a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#ifndef __deprecated
52a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#define __deprecated __attribute__((__deprecated__))
53a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#endif
54a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
55a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian__BEGIN_DECLS
56a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
57a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/*****************************************************************************/
58a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
59000879a0eb2156727a2221e42d04b6f3e150aa79Mathias Agopian#define ANDROID_NATIVE_WINDOW_MAGIC     ANDROID_NATIVE_MAKE_CONSTANT('_','w','n','d')
60a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
61a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian// ---------------------------------------------------------------------------
62a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
63a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopiantypedef const native_handle_t* buffer_handle_t;
64a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
65a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian// ---------------------------------------------------------------------------
66a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
67a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopiantypedef struct android_native_rect_t
68a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{
69a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    int32_t left;
70a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    int32_t top;
71a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    int32_t right;
72a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    int32_t bottom;
73a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian} android_native_rect_t;
74a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
75a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian// ---------------------------------------------------------------------------
76a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
77a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian// Old typedef for backwards compatibility.
78a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopiantypedef ANativeWindowBuffer_t android_native_buffer_t;
79a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
80a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian// ---------------------------------------------------------------------------
81a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
82a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* attributes queriable with query() */
83a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianenum {
84a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_WIDTH     = 0,
85a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_HEIGHT    = 1,
86a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_FORMAT    = 2,
87a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
88000879a0eb2156727a2221e42d04b6f3e150aa79Mathias Agopian    /* see ANativeWindowQuery in vndk/window.h */
89000879a0eb2156727a2221e42d04b6f3e150aa79Mathias Agopian    NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS = ANATIVEWINDOW_QUERY_MIN_UNDEQUEUED_BUFFERS,
90a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
91a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /* Check whether queueBuffer operations on the ANativeWindow send the buffer
92a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * to the window compositor.  The query sets the returned 'value' argument
93a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * to 1 if the ANativeWindow DOES send queued buffers directly to the window
94a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * compositor and 0 if the buffers do not go directly to the window
95a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * compositor.
96a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
97a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * This can be used to determine whether protected buffer content should be
98a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * sent to the ANativeWindow.  Note, however, that a result of 1 does NOT
99a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * indicate that queued buffers will be protected from applications or users
100a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * capturing their contents.  If that behavior is desired then some other
101a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * mechanism (e.g. the GRALLOC_USAGE_PROTECTED flag) should be used in
102a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * conjunction with this query.
103a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     */
104a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER = 4,
105a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
106a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /* Get the concrete type of a ANativeWindow.  See below for the list of
107a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * possible return values.
108a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
109a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * This query should not be used outside the Android framework and will
110a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * likely be removed in the near future.
111a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     */
112a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_CONCRETE_TYPE = 5,
113a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
114a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
115a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /*
116a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Default width and height of ANativeWindow buffers, these are the
117a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * dimensions of the window buffers irrespective of the
118a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS call and match the native window
119a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * size unless overridden by NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS.
120a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     */
121000879a0eb2156727a2221e42d04b6f3e150aa79Mathias Agopian    NATIVE_WINDOW_DEFAULT_WIDTH = ANATIVEWINDOW_QUERY_DEFAULT_WIDTH,
122000879a0eb2156727a2221e42d04b6f3e150aa79Mathias Agopian    NATIVE_WINDOW_DEFAULT_HEIGHT = ANATIVEWINDOW_QUERY_DEFAULT_HEIGHT,
123a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
124000879a0eb2156727a2221e42d04b6f3e150aa79Mathias Agopian    /* see ANativeWindowQuery in vndk/window.h */
125000879a0eb2156727a2221e42d04b6f3e150aa79Mathias Agopian    NATIVE_WINDOW_TRANSFORM_HINT = ANATIVEWINDOW_QUERY_TRANSFORM_HINT,
126a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
127a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /*
128a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Boolean that indicates whether the consumer is running more than
129a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * one buffer behind the producer.
130a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     */
131a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_CONSUMER_RUNNING_BEHIND = 9,
132a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
133a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /*
134a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * The consumer gralloc usage bits currently set by the consumer.
135a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * The values are defined in hardware/libhardware/include/gralloc.h.
136a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     */
137a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_CONSUMER_USAGE_BITS = 10,
138a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
139a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /**
140a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Transformation that will by applied to buffers by the hwcomposer.
141a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * This must not be set or checked by producer endpoints, and will
142a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * disable the transform hint set in SurfaceFlinger (see
143a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * NATIVE_WINDOW_TRANSFORM_HINT).
144a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
145a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * INTENDED USE:
146a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Temporary - Please do not use this.  This is intended only to be used
147a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * by the camera's LEGACY mode.
148a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
149a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * In situations where a SurfaceFlinger client wishes to set a transform
150a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * that is not visible to the producer, and will always be applied in the
151a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * hardware composer, the client can set this flag with
152a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * native_window_set_buffers_sticky_transform.  This can be used to rotate
153a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * and flip buffers consumed by hardware composer without actually changing
154a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * the aspect ratio of the buffers produced.
155a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     */
156a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_STICKY_TRANSFORM = 11,
157a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
158a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /**
159a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * The default data space for the buffers as set by the consumer.
160a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * The values are defined in graphics.h.
161a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     */
162a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_DEFAULT_DATASPACE = 12,
163a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
164000879a0eb2156727a2221e42d04b6f3e150aa79Mathias Agopian    /* see ANativeWindowQuery in vndk/window.h */
165000879a0eb2156727a2221e42d04b6f3e150aa79Mathias Agopian    NATIVE_WINDOW_BUFFER_AGE = ANATIVEWINDOW_QUERY_BUFFER_AGE,
166a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
167a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /*
168a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Returns the duration of the last dequeueBuffer call in microseconds
169a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     */
170a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_LAST_DEQUEUE_DURATION = 14,
171a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
172a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /*
173a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Returns the duration of the last queueBuffer call in microseconds
174a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     */
175a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_LAST_QUEUE_DURATION = 15,
176a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
177a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /*
178a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Returns the number of image layers that the ANativeWindow buffer
179a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * contains. By default this is 1, unless a buffer is explicitly allocated
180a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * to contain multiple layers.
181a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     */
182a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_LAYER_COUNT = 16,
183a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
184a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /*
185a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Returns 1 if the native window is valid, 0 otherwise. native window is valid
186a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * if it is safe (i.e. no crash will occur) to call any method on it.
187a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     */
188a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_IS_VALID = 17,
1896b376713907086c9642e7b7e66e51ddfa531b003Brian Anderson
1906b376713907086c9642e7b7e66e51ddfa531b003Brian Anderson    /*
1916b376713907086c9642e7b7e66e51ddfa531b003Brian Anderson     * Returns 1 if NATIVE_WINDOW_GET_FRAME_TIMESTAMPS will return display
1926b376713907086c9642e7b7e66e51ddfa531b003Brian Anderson     * present info, 0 if it won't.
1936b376713907086c9642e7b7e66e51ddfa531b003Brian Anderson     */
1946b376713907086c9642e7b7e66e51ddfa531b003Brian Anderson    NATIVE_WINDOW_FRAME_TIMESTAMPS_SUPPORTS_PRESENT = 18,
195a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian};
196a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
197a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* Valid operations for the (*perform)() hook.
198a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *
199a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Values marked as 'deprecated' are supported, but have been superceded by
200a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * other functionality.
201a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *
202a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Values marked as 'private' should be considered private to the framework.
203a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * HAL implementation code with access to an ANativeWindow should not use these,
204a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * as it may not interact properly with the framework's use of the
205a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * ANativeWindow.
206a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */
207a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianenum {
208a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian// clang-format off
209a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_SET_USAGE                 =  0,
210a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_CONNECT                   =  1,   /* deprecated */
211a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_DISCONNECT                =  2,   /* deprecated */
212a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_SET_CROP                  =  3,   /* private */
213a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_SET_BUFFER_COUNT          =  4,
214a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_SET_BUFFERS_GEOMETRY      =  5,   /* deprecated */
215a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_SET_BUFFERS_TRANSFORM     =  6,
216a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP     =  7,
217a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS    =  8,
218a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_SET_BUFFERS_FORMAT        =  9,
219a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_SET_SCALING_MODE          = 10,   /* private */
220a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_LOCK                      = 11,   /* private */
221a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_UNLOCK_AND_POST           = 12,   /* private */
222a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_API_CONNECT               = 13,   /* private */
223a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_API_DISCONNECT            = 14,   /* private */
224a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS = 15, /* private */
225a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_SET_POST_TRANSFORM_CROP   = 16,   /* private */
226a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM = 17,/* private */
227a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_SET_SIDEBAND_STREAM       = 18,
228a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_SET_BUFFERS_DATASPACE     = 19,
229a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_SET_SURFACE_DAMAGE        = 20,   /* private */
230a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_SET_SHARED_BUFFER_MODE    = 21,
231a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_SET_AUTO_REFRESH          = 22,
232a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_GET_REFRESH_CYCLE_DURATION= 23,
233a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_GET_NEXT_FRAME_ID         = 24,
234a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_ENABLE_FRAME_TIMESTAMPS   = 25,
235a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_GET_COMPOSITOR_TIMING     = 26,
236a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_GET_FRAME_TIMESTAMPS      = 27,
237a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_GET_WIDE_COLOR_SUPPORT    = 28,
238a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_GET_HDR_SUPPORT           = 29,
239a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian// clang-format on
240a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian};
241a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
242a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* parameter for NATIVE_WINDOW_[API_][DIS]CONNECT */
243a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianenum {
244a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /* Buffers will be queued by EGL via eglSwapBuffers after being filled using
245a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * OpenGL ES.
246a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     */
247a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_API_EGL = 1,
248a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
249a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /* Buffers will be queued after being filled using the CPU
250a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     */
251a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_API_CPU = 2,
252a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
253a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /* Buffers will be queued by Stagefright after being filled by a video
254a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * decoder.  The video decoder can either be a software or hardware decoder.
255a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     */
256a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_API_MEDIA = 3,
257a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
258a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /* Buffers will be queued by the the camera HAL.
259a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     */
260a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_API_CAMERA = 4,
261a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian};
262a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
263a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* parameter for NATIVE_WINDOW_SET_BUFFERS_TRANSFORM */
264a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianenum {
265a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /* flip source image horizontally */
266a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H ,
267a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /* flip source image vertically */
268a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V,
269a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /* rotate source image 90 degrees clock-wise, and is applied after TRANSFORM_FLIP_{H|V} */
270a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90,
271a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /* rotate source image 180 degrees */
272a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180,
273a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /* rotate source image 270 degrees clock-wise */
274a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270,
275a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /* transforms source by the inverse transform of the screen it is displayed onto. This
276a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * transform is applied last */
277a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY = 0x08
278a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian};
279a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
280a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* parameter for NATIVE_WINDOW_SET_SCALING_MODE
281a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * keep in sync with Surface.java in frameworks/base */
282a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianenum {
283a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /* the window content is not updated (frozen) until a buffer of
284a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * the window size is received (enqueued)
285a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     */
286a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_SCALING_MODE_FREEZE           = 0,
287a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /* the buffer is scaled in both dimensions to match the window size */
288a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW  = 1,
289a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /* the buffer is scaled uniformly such that the smaller dimension
290a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * of the buffer matches the window size (cropping in the process)
291a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     */
292a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_SCALING_MODE_SCALE_CROP       = 2,
293a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /* the window is clipped to the size of the buffer's crop rectangle; pixels
294a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * outside the crop rectangle are treated as if they are completely
295a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * transparent.
296a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     */
297a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_SCALING_MODE_NO_SCALE_CROP    = 3,
298a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian};
299a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
300a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* values returned by the NATIVE_WINDOW_CONCRETE_TYPE query */
301a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianenum {
302a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_FRAMEBUFFER               = 0, /* FramebufferNativeWindow */
303a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_SURFACE                   = 1, /* Surface */
304a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian};
305a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
306a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* parameter for NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP
307a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *
308a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Special timestamp value to indicate that timestamps should be auto-generated
309a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * by the native window when queueBuffer is called.  This is equal to INT64_MIN,
310a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * defined directly to avoid problems with C99/C++ inclusion of stdint.h.
311a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */
312a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic const int64_t NATIVE_WINDOW_TIMESTAMP_AUTO = (-9223372036854775807LL-1);
313a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
314a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstruct ANativeWindow
315a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{
316a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#ifdef __cplusplus
317a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    ANativeWindow()
318a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        : flags(0), minSwapInterval(0), maxSwapInterval(0), xdpi(0), ydpi(0)
319a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    {
320a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        common.magic = ANDROID_NATIVE_WINDOW_MAGIC;
321a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        common.version = sizeof(ANativeWindow);
322a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        memset(common.reserved, 0, sizeof(common.reserved));
323a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    }
324a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
325a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /* Implement the methods that sp<ANativeWindow> expects so that it
326a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian       can be used to automatically refcount ANativeWindow's. */
327a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    void incStrong(const void* /*id*/) const {
328a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        common.incRef(const_cast<android_native_base_t*>(&common));
329a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    }
330a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    void decStrong(const void* /*id*/) const {
331a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        common.decRef(const_cast<android_native_base_t*>(&common));
332a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    }
333a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#endif
334a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
335a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    struct android_native_base_t common;
336a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
337a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /* flags describing some attributes of this surface or its updater */
338a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    const uint32_t flags;
339a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
340a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /* min swap interval supported by this updated */
341a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    const int   minSwapInterval;
342a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
343a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /* max swap interval supported by this updated */
344a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    const int   maxSwapInterval;
345a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
346a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /* horizontal and vertical resolution in DPI */
347a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    const float xdpi;
348a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    const float ydpi;
349a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
350a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /* Some storage reserved for the OEM's driver. */
351a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    intptr_t    oem[4];
352a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
353a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /*
354a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Set the swap interval for this surface.
355a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
356a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Returns 0 on success or -errno on error.
357a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     */
358a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    int     (*setSwapInterval)(struct ANativeWindow* window,
359a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian                int interval);
360a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
361a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /*
362a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Hook called by EGL to acquire a buffer. After this call, the buffer
363a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * is not locked, so its content cannot be modified. This call may block if
364a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * no buffers are available.
365a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
366a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * The window holds a reference to the buffer between dequeueBuffer and
367a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * either queueBuffer or cancelBuffer, so clients only need their own
368a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * reference if they might use the buffer after queueing or canceling it.
369a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Holding a reference to a buffer after queueing or canceling it is only
370a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * allowed if a specific buffer count has been set.
371a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
372a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Returns 0 on success or -errno on error.
373a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
374a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * XXX: This function is deprecated.  It will continue to work for some
375a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * time for binary compatibility, but the new dequeueBuffer function that
376a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * outputs a fence file descriptor should be used in its place.
377a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     */
378a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    int     (*dequeueBuffer_DEPRECATED)(struct ANativeWindow* window,
379a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian                struct ANativeWindowBuffer** buffer);
380a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
381a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /*
382a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * hook called by EGL to lock a buffer. This MUST be called before modifying
383a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * the content of a buffer. The buffer must have been acquired with
384a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * dequeueBuffer first.
385a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
386a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Returns 0 on success or -errno on error.
387a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
388a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * XXX: This function is deprecated.  It will continue to work for some
389a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * time for binary compatibility, but it is essentially a no-op, and calls
390a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * to it should be removed.
391a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     */
392a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    int     (*lockBuffer_DEPRECATED)(struct ANativeWindow* window,
393a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian                struct ANativeWindowBuffer* buffer);
394a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
395a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /*
396a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Hook called by EGL when modifications to the render buffer are done.
397a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * This unlocks and post the buffer.
398a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
399a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * The window holds a reference to the buffer between dequeueBuffer and
400a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * either queueBuffer or cancelBuffer, so clients only need their own
401a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * reference if they might use the buffer after queueing or canceling it.
402a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Holding a reference to a buffer after queueing or canceling it is only
403a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * allowed if a specific buffer count has been set.
404a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
405a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Buffers MUST be queued in the same order than they were dequeued.
406a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
407a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Returns 0 on success or -errno on error.
408a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
409a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * XXX: This function is deprecated.  It will continue to work for some
410a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * time for binary compatibility, but the new queueBuffer function that
411a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * takes a fence file descriptor should be used in its place (pass a value
412a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * of -1 for the fence file descriptor if there is no valid one to pass).
413a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     */
414a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    int     (*queueBuffer_DEPRECATED)(struct ANativeWindow* window,
415a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian                struct ANativeWindowBuffer* buffer);
416a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
417a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /*
418a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * hook used to retrieve information about the native window.
419a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
420a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Returns 0 on success or -errno on error.
421a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     */
422a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    int     (*query)(const struct ANativeWindow* window,
423a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian                int what, int* value);
424a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
425a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /*
426a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * hook used to perform various operations on the surface.
427a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * (*perform)() is a generic mechanism to add functionality to
428a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * ANativeWindow while keeping backward binary compatibility.
429a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
430a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * DO NOT CALL THIS HOOK DIRECTLY.  Instead, use the helper functions
431a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * defined below.
432a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
433a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * (*perform)() returns -ENOENT if the 'what' parameter is not supported
434a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * by the surface's implementation.
435a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
436a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * See above for a list of valid operations, such as
437a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * NATIVE_WINDOW_SET_USAGE or NATIVE_WINDOW_CONNECT
438a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     */
439a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    int     (*perform)(struct ANativeWindow* window,
440a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian                int operation, ... );
441a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
442a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /*
443a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Hook used to cancel a buffer that has been dequeued.
444a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * No synchronization is performed between dequeue() and cancel(), so
445a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * either external synchronization is needed, or these functions must be
446a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * called from the same thread.
447a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
448a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * The window holds a reference to the buffer between dequeueBuffer and
449a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * either queueBuffer or cancelBuffer, so clients only need their own
450a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * reference if they might use the buffer after queueing or canceling it.
451a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Holding a reference to a buffer after queueing or canceling it is only
452a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * allowed if a specific buffer count has been set.
453a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
454a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * XXX: This function is deprecated.  It will continue to work for some
455a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * time for binary compatibility, but the new cancelBuffer function that
456a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * takes a fence file descriptor should be used in its place (pass a value
457a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * of -1 for the fence file descriptor if there is no valid one to pass).
458a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     */
459a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    int     (*cancelBuffer_DEPRECATED)(struct ANativeWindow* window,
460a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian                struct ANativeWindowBuffer* buffer);
461a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
462a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /*
463a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Hook called by EGL to acquire a buffer. This call may block if no
464a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * buffers are available.
465a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
466a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * The window holds a reference to the buffer between dequeueBuffer and
467a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * either queueBuffer or cancelBuffer, so clients only need their own
468a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * reference if they might use the buffer after queueing or canceling it.
469a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Holding a reference to a buffer after queueing or canceling it is only
470a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * allowed if a specific buffer count has been set.
471a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
472a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * The libsync fence file descriptor returned in the int pointed to by the
473a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * fenceFd argument will refer to the fence that must signal before the
474a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * dequeued buffer may be written to.  A value of -1 indicates that the
475a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * caller may access the buffer immediately without waiting on a fence.  If
476a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * a valid file descriptor is returned (i.e. any value except -1) then the
477a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * caller is responsible for closing the file descriptor.
478a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
479a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Returns 0 on success or -errno on error.
480a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     */
481a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    int     (*dequeueBuffer)(struct ANativeWindow* window,
482a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian                struct ANativeWindowBuffer** buffer, int* fenceFd);
483a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
484a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /*
485a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Hook called by EGL when modifications to the render buffer are done.
486a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * This unlocks and post the buffer.
487a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
488a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * The window holds a reference to the buffer between dequeueBuffer and
489a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * either queueBuffer or cancelBuffer, so clients only need their own
490a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * reference if they might use the buffer after queueing or canceling it.
491a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Holding a reference to a buffer after queueing or canceling it is only
492a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * allowed if a specific buffer count has been set.
493a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
494a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * The fenceFd argument specifies a libsync fence file descriptor for a
495a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * fence that must signal before the buffer can be accessed.  If the buffer
496a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * can be accessed immediately then a value of -1 should be used.  The
497a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * caller must not use the file descriptor after it is passed to
498a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * queueBuffer, and the ANativeWindow implementation is responsible for
499a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * closing it.
500a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
501a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Returns 0 on success or -errno on error.
502a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     */
503a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    int     (*queueBuffer)(struct ANativeWindow* window,
504a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian                struct ANativeWindowBuffer* buffer, int fenceFd);
505a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
506a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /*
507a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Hook used to cancel a buffer that has been dequeued.
508a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * No synchronization is performed between dequeue() and cancel(), so
509a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * either external synchronization is needed, or these functions must be
510a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * called from the same thread.
511a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
512a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * The window holds a reference to the buffer between dequeueBuffer and
513a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * either queueBuffer or cancelBuffer, so clients only need their own
514a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * reference if they might use the buffer after queueing or canceling it.
515a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Holding a reference to a buffer after queueing or canceling it is only
516a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * allowed if a specific buffer count has been set.
517a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
518a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * The fenceFd argument specifies a libsync fence file decsriptor for a
519a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * fence that must signal before the buffer can be accessed.  If the buffer
520a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * can be accessed immediately then a value of -1 should be used.
521a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
522a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Note that if the client has not waited on the fence that was returned
523a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * from dequeueBuffer, that same fence should be passed to cancelBuffer to
524a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * ensure that future uses of the buffer are preceded by a wait on that
525a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * fence.  The caller must not use the file descriptor after it is passed
526a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * to cancelBuffer, and the ANativeWindow implementation is responsible for
527a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * closing it.
528a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
529a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Returns 0 on success or -errno on error.
530a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     */
531a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    int     (*cancelBuffer)(struct ANativeWindow* window,
532a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian                struct ANativeWindowBuffer* buffer, int fenceFd);
533a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian};
534a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
535a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* Backwards compatibility: use ANativeWindow (struct ANativeWindow in C).
536a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian  * android_native_window_t is deprecated.
537a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian  */
538a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopiantypedef struct ANativeWindow ANativeWindow;
539a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopiantypedef struct ANativeWindow android_native_window_t __deprecated;
540a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
541a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/*
542a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *  native_window_set_usage(..., usage)
543a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *  Sets the intended usage flags for the next buffers
544a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *  acquired with (*lockBuffer)() and on.
545a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *  By default (if this function is never called), a usage of
546a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *      GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE
547a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *  is assumed.
548a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *  Calling this function will usually cause following buffers to be
549a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *  reallocated.
550a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */
551a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
552a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_set_usage(
553a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        struct ANativeWindow* window, int usage)
554a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{
555a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    return window->perform(window, NATIVE_WINDOW_SET_USAGE, usage);
556a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian}
557a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
558a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* deprecated. Always returns 0. Don't call. */
559a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_connect(
560a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        struct ANativeWindow* window __UNUSED, int api __UNUSED) __deprecated;
561a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
562a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_connect(
563a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        struct ANativeWindow* window __UNUSED, int api __UNUSED) {
564a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    return 0;
565a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian}
566a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
567a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* deprecated. Always returns 0. Don't call. */
568a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_disconnect(
569a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        struct ANativeWindow* window __UNUSED, int api __UNUSED) __deprecated;
570a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
571a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_disconnect(
572a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        struct ANativeWindow* window __UNUSED, int api __UNUSED) {
573a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    return 0;
574a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian}
575a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
576a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/*
577a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_set_crop(..., crop)
578a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Sets which region of the next queued buffers needs to be considered.
579a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Depending on the scaling mode, a buffer's crop region is scaled and/or
580a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * cropped to match the surface's size.  This function sets the crop in
581a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * pre-transformed buffer pixel coordinates.
582a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *
583a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * The specified crop region applies to all buffers queued after it is called.
584a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *
585a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * If 'crop' is NULL, subsequently queued buffers won't be cropped.
586a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *
587a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * An error is returned if for instance the crop region is invalid, out of the
588a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * buffer's bound or if the window is invalid.
589a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */
590a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_set_crop(
591a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        struct ANativeWindow* window,
592a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        android_native_rect_t const * crop)
593a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{
594a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    return window->perform(window, NATIVE_WINDOW_SET_CROP, crop);
595a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian}
596a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
597a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/*
598a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_set_post_transform_crop(..., crop)
599a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Sets which region of the next queued buffers needs to be considered.
600a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Depending on the scaling mode, a buffer's crop region is scaled and/or
601a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * cropped to match the surface's size.  This function sets the crop in
602a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * post-transformed pixel coordinates.
603a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *
604a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * The specified crop region applies to all buffers queued after it is called.
605a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *
606a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * If 'crop' is NULL, subsequently queued buffers won't be cropped.
607a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *
608a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * An error is returned if for instance the crop region is invalid, out of the
609a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * buffer's bound or if the window is invalid.
610a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */
611a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_set_post_transform_crop(
612a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        struct ANativeWindow* window,
613a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        android_native_rect_t const * crop)
614a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{
615a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    return window->perform(window, NATIVE_WINDOW_SET_POST_TRANSFORM_CROP, crop);
616a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian}
617a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
618a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/*
619a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_set_active_rect(..., active_rect)
620a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *
621a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * This function is deprecated and will be removed soon.  For now it simply
622a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * sets the post-transform crop for compatibility while multi-project commits
623a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * get checked.
624a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */
625a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_set_active_rect(
626a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        struct ANativeWindow* window,
627a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        android_native_rect_t const * active_rect) __deprecated;
628a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
629a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_set_active_rect(
630a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        struct ANativeWindow* window,
631a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        android_native_rect_t const * active_rect)
632a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{
633a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    return native_window_set_post_transform_crop(window, active_rect);
634a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian}
635a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
636a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/*
637a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_set_buffer_count(..., count)
638a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Sets the number of buffers associated with this native window.
639a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */
640a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_set_buffer_count(
641a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        struct ANativeWindow* window,
642a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        size_t bufferCount)
643a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{
644a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    return window->perform(window, NATIVE_WINDOW_SET_BUFFER_COUNT, bufferCount);
645a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian}
646a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
647a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/*
648a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_set_buffers_geometry(..., int w, int h, int format)
649a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * All buffers dequeued after this call will have the dimensions and format
650a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * specified.  A successful call to this function has the same effect as calling
651a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_set_buffers_size and native_window_set_buffers_format.
652a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *
653a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * XXX: This function is deprecated.  The native_window_set_buffers_dimensions
654a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * and native_window_set_buffers_format functions should be used instead.
655a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */
656a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_set_buffers_geometry(
657a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        struct ANativeWindow* window,
658a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        int w, int h, int format) __deprecated;
659a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
660a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_set_buffers_geometry(
661a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        struct ANativeWindow* window,
662a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        int w, int h, int format)
663a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{
664a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_GEOMETRY,
665a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian            w, h, format);
666a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian}
667a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
668a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/*
669a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_set_buffers_dimensions(..., int w, int h)
670a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * All buffers dequeued after this call will have the dimensions specified.
671a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * In particular, all buffers will have a fixed-size, independent from the
672a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native-window size. They will be scaled according to the scaling mode
673a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * (see native_window_set_scaling_mode) upon window composition.
674a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *
675a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * If w and h are 0, the normal behavior is restored. That is, dequeued buffers
676a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * following this call will be sized to match the window's size.
677a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *
678a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Calling this function will reset the window crop to a NULL value, which
679a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * disables cropping of the buffers.
680a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */
681a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_set_buffers_dimensions(
682a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        struct ANativeWindow* window,
683a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        int w, int h)
684a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{
685a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS,
686a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian            w, h);
687a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian}
688a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
689a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/*
690a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_set_buffers_user_dimensions(..., int w, int h)
691a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *
692a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Sets the user buffer size for the window, which overrides the
693a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * window's size.  All buffers dequeued after this call will have the
694a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * dimensions specified unless overridden by
695a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_set_buffers_dimensions.  All buffers will have a
696a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * fixed-size, independent from the native-window size. They will be
697a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * scaled according to the scaling mode (see
698a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_set_scaling_mode) upon window composition.
699a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *
700a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * If w and h are 0, the normal behavior is restored. That is, the
701a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * default buffer size will match the windows's size.
702a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *
703a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Calling this function will reset the window crop to a NULL value, which
704a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * disables cropping of the buffers.
705a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */
706a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_set_buffers_user_dimensions(
707a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        struct ANativeWindow* window,
708a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        int w, int h)
709a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{
710a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS,
711a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian            w, h);
712a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian}
713a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
714a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/*
715a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_set_buffers_format(..., int format)
716a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * All buffers dequeued after this call will have the format specified.
717a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *
718a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * If the specified format is 0, the default buffer format will be used.
719a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */
720a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_set_buffers_format(
721a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        struct ANativeWindow* window,
722a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        int format)
723a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{
724a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_FORMAT, format);
725a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian}
726a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
727a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/*
728a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_set_buffers_data_space(..., int dataSpace)
729a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * All buffers queued after this call will be associated with the dataSpace
730a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * parameter specified.
731a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *
732a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * dataSpace specifies additional information about the buffer that's dependent
733a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * on the buffer format and the endpoints. For example, it can be used to convey
734a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * the color space of the image data in the buffer, or it can be used to
735a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * indicate that the buffers contain depth measurement data instead of color
736a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * images.  The default dataSpace is 0, HAL_DATASPACE_UNKNOWN, unless it has been
737a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * overridden by the consumer.
738a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */
739a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_set_buffers_data_space(
740a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        struct ANativeWindow* window,
741a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        android_dataspace_t dataSpace)
742a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{
743a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DATASPACE,
744a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian            dataSpace);
745a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian}
746a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
747a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/*
748a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_set_buffers_transform(..., int transform)
749a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * All buffers queued after this call will be displayed transformed according
750a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * to the transform parameter specified.
751a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */
752a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_set_buffers_transform(
753a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        struct ANativeWindow* window,
754a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        int transform)
755a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{
756a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TRANSFORM,
757a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian            transform);
758a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian}
759a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
760a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/*
761a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_set_buffers_sticky_transform(..., int transform)
762a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * All buffers queued after this call will be displayed transformed according
763a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * to the transform parameter specified applied on top of the regular buffer
764a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * transform.  Setting this transform will disable the transform hint.
765a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *
766a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Temporary - This is only intended to be used by the LEGACY camera mode, do
767a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *   not use this for anything else.
768a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */
769a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_set_buffers_sticky_transform(
770a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        struct ANativeWindow* window,
771a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        int transform)
772a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{
773a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM,
774a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian            transform);
775a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian}
776a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
777a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/*
778a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_set_buffers_timestamp(..., int64_t timestamp)
779a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * All buffers queued after this call will be associated with the timestamp
780a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * parameter specified. If the timestamp is set to NATIVE_WINDOW_TIMESTAMP_AUTO
781a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * (the default), timestamps will be generated automatically when queueBuffer is
782a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * called. The timestamp is measured in nanoseconds, and is normally monotonically
783a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * increasing. The timestamp should be unaffected by time-of-day adjustments,
784a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * and for a camera should be strictly monotonic but for a media player may be
785a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * reset when the position is set.
786a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */
787a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_set_buffers_timestamp(
788a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        struct ANativeWindow* window,
789a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        int64_t timestamp)
790a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{
791a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP,
792a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian            timestamp);
793a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian}
794a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
795a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/*
796a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_set_scaling_mode(..., int mode)
797a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * All buffers queued after this call will be associated with the scaling mode
798a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * specified.
799a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */
800a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_set_scaling_mode(
801a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        struct ANativeWindow* window,
802a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        int mode)
803a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{
804a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    return window->perform(window, NATIVE_WINDOW_SET_SCALING_MODE,
805a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian            mode);
806a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian}
807a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
808a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/*
809a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_api_connect(..., int api)
810a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * connects an API to this window. only one API can be connected at a time.
811a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Returns -EINVAL if for some reason the window cannot be connected, which
812a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * can happen if it's connected to some other API.
813a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */
814a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_api_connect(
815a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        struct ANativeWindow* window, int api)
816a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{
817a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    return window->perform(window, NATIVE_WINDOW_API_CONNECT, api);
818a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian}
819a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
820a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/*
821a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_api_disconnect(..., int api)
822a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * disconnect the API from this window.
823a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * An error is returned if for instance the window wasn't connected in the
824a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * first place.
825a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */
826a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_api_disconnect(
827a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        struct ANativeWindow* window, int api)
828a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{
829a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    return window->perform(window, NATIVE_WINDOW_API_DISCONNECT, api);
830a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian}
831a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
832a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/*
833a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_dequeue_buffer_and_wait(...)
834a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Dequeue a buffer and wait on the fence associated with that buffer.  The
835a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * buffer may safely be accessed immediately upon this function returning.  An
836a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * error is returned if either of the dequeue or the wait operations fail.
837a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */
838a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_dequeue_buffer_and_wait(ANativeWindow *anw,
839a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        struct ANativeWindowBuffer** anb) {
840a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    return anw->dequeueBuffer_DEPRECATED(anw, anb);
841a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian}
842a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
843a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/*
844a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_set_sideband_stream(..., native_handle_t*)
845a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Attach a sideband buffer stream to a native window.
846a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */
847a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_set_sideband_stream(
848a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        struct ANativeWindow* window,
849a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        native_handle_t* sidebandHandle)
850a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{
851a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    return window->perform(window, NATIVE_WINDOW_SET_SIDEBAND_STREAM,
852a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian            sidebandHandle);
853a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian}
854a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
855a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/*
856a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_set_surface_damage(..., android_native_rect_t* rects, int numRects)
857a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Set the surface damage (i.e., the region of the surface that has changed
858a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * since the previous frame). The damage set by this call will be reset (to the
859a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * default of full-surface damage) after calling queue, so this must be called
860a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * prior to every frame with damage that does not cover the whole surface if the
861a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * caller desires downstream consumers to use this optimization.
862a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *
863a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * The damage region is specified as an array of rectangles, with the important
864a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * caveat that the origin of the surface is considered to be the bottom-left
865a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * corner, as in OpenGL ES.
866a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *
867a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * If numRects is set to 0, rects may be NULL, and the surface damage will be
868a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * set to the full surface (the same as if this function had not been called for
869a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * this frame).
870a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */
871a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_set_surface_damage(
872a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        struct ANativeWindow* window,
873a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        const android_native_rect_t* rects, size_t numRects)
874a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{
875a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    return window->perform(window, NATIVE_WINDOW_SET_SURFACE_DAMAGE,
876a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian            rects, numRects);
877a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian}
878a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
879a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/*
880a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_set_shared_buffer_mode(..., bool sharedBufferMode)
881a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Enable/disable shared buffer mode
882a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */
883a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_set_shared_buffer_mode(
884a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        struct ANativeWindow* window,
885a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        bool sharedBufferMode)
886a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{
887a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    return window->perform(window, NATIVE_WINDOW_SET_SHARED_BUFFER_MODE,
888a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian            sharedBufferMode);
889a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian}
890a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
891a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/*
892a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_set_auto_refresh(..., autoRefresh)
893a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Enable/disable auto refresh when in shared buffer mode
894a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */
895a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_set_auto_refresh(
896a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        struct ANativeWindow* window,
897a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        bool autoRefresh)
898a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{
899a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    return window->perform(window, NATIVE_WINDOW_SET_AUTO_REFRESH, autoRefresh);
900a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian}
901a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
902a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_get_refresh_cycle_duration(
903a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        struct ANativeWindow* window,
904a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        int64_t* outRefreshDuration)
905a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{
906a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    return window->perform(window, NATIVE_WINDOW_GET_REFRESH_CYCLE_DURATION,
907a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian            outRefreshDuration);
908a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian}
909a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
910a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_get_next_frame_id(
911a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        struct ANativeWindow* window, uint64_t* frameId)
912a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{
913a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    return window->perform(window, NATIVE_WINDOW_GET_NEXT_FRAME_ID, frameId);
914a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian}
915a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
916a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_enable_frame_timestamps(
917a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        struct ANativeWindow* window, bool enable)
918a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{
919a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    return window->perform(window, NATIVE_WINDOW_ENABLE_FRAME_TIMESTAMPS,
920a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian            enable);
921a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian}
922a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
923a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_get_compositor_timing(
924a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        struct ANativeWindow* window,
925a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        int64_t* compositeDeadline, int64_t* compositeInterval,
926a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        int64_t* compositeToPresentLatency)
927a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{
928a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    return window->perform(window, NATIVE_WINDOW_GET_COMPOSITOR_TIMING,
929a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian            compositeDeadline, compositeInterval, compositeToPresentLatency);
930a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian}
931a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
932a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_get_frame_timestamps(
933a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        struct ANativeWindow* window, uint64_t frameId,
934a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        int64_t* outRequestedPresentTime, int64_t* outAcquireTime,
935a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        int64_t* outLatchTime, int64_t* outFirstRefreshStartTime,
936a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        int64_t* outLastRefreshStartTime, int64_t* outGpuCompositionDoneTime,
937a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        int64_t* outDisplayPresentTime, int64_t* outDequeueReadyTime,
938a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        int64_t* outReleaseTime)
939a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{
940a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    return window->perform(window, NATIVE_WINDOW_GET_FRAME_TIMESTAMPS,
941a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian            frameId, outRequestedPresentTime, outAcquireTime, outLatchTime,
942a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian            outFirstRefreshStartTime, outLastRefreshStartTime,
943a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian            outGpuCompositionDoneTime, outDisplayPresentTime,
944a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian            outDequeueReadyTime, outReleaseTime);
945a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian}
946a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
947a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_get_wide_color_support(
948a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    struct ANativeWindow* window, bool* outSupport) {
949a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian  return window->perform(window, NATIVE_WINDOW_GET_WIDE_COLOR_SUPPORT,
950a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian                         outSupport);
951a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian}
952a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
953a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_get_hdr_support(struct ANativeWindow* window,
954a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian                                                bool* outSupport) {
955a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian  return window->perform(window, NATIVE_WINDOW_GET_HDR_SUPPORT, outSupport);
956a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian}
957a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
958a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian__END_DECLS
959