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,
1952041913a05b79b96c5c084f30bb8944049a976c8Jiwen 'Steve' Cai
1962041913a05b79b96c5c084f30bb8944049a976c8Jiwen 'Steve' Cai    /*
1972041913a05b79b96c5c084f30bb8944049a976c8Jiwen 'Steve' Cai     * The consumer end is capable of handling protected buffers, i.e. buffer
1982041913a05b79b96c5c084f30bb8944049a976c8Jiwen 'Steve' Cai     * with GRALLOC_USAGE_PROTECTED usage bits on.
1992041913a05b79b96c5c084f30bb8944049a976c8Jiwen 'Steve' Cai     */
2002041913a05b79b96c5c084f30bb8944049a976c8Jiwen 'Steve' Cai    NATIVE_WINDOW_CONSUMER_IS_PROTECTED = 19,
201a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian};
202a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
203a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* Valid operations for the (*perform)() hook.
204a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *
205a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Values marked as 'deprecated' are supported, but have been superceded by
206a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * other functionality.
207a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *
208a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Values marked as 'private' should be considered private to the framework.
209a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * HAL implementation code with access to an ANativeWindow should not use these,
210a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * as it may not interact properly with the framework's use of the
211a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * ANativeWindow.
212a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */
213a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianenum {
214a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian// clang-format off
215a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_SET_USAGE                 =  0,
216a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_CONNECT                   =  1,   /* deprecated */
217a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_DISCONNECT                =  2,   /* deprecated */
218a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_SET_CROP                  =  3,   /* private */
219a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_SET_BUFFER_COUNT          =  4,
220a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_SET_BUFFERS_GEOMETRY      =  5,   /* deprecated */
221a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_SET_BUFFERS_TRANSFORM     =  6,
222a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP     =  7,
223a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS    =  8,
224a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_SET_BUFFERS_FORMAT        =  9,
225a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_SET_SCALING_MODE          = 10,   /* private */
226a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_LOCK                      = 11,   /* private */
227a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_UNLOCK_AND_POST           = 12,   /* private */
228a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_API_CONNECT               = 13,   /* private */
229a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_API_DISCONNECT            = 14,   /* private */
230a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS = 15, /* private */
231a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_SET_POST_TRANSFORM_CROP   = 16,   /* private */
232a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM = 17,/* private */
233a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_SET_SIDEBAND_STREAM       = 18,
234a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_SET_BUFFERS_DATASPACE     = 19,
235a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_SET_SURFACE_DAMAGE        = 20,   /* private */
236a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_SET_SHARED_BUFFER_MODE    = 21,
237a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_SET_AUTO_REFRESH          = 22,
238a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_GET_REFRESH_CYCLE_DURATION= 23,
239a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_GET_NEXT_FRAME_ID         = 24,
240a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_ENABLE_FRAME_TIMESTAMPS   = 25,
241a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_GET_COMPOSITOR_TIMING     = 26,
242a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_GET_FRAME_TIMESTAMPS      = 27,
243a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_GET_WIDE_COLOR_SUPPORT    = 28,
244a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_GET_HDR_SUPPORT           = 29,
245a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian// clang-format on
246a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian};
247a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
248a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* parameter for NATIVE_WINDOW_[API_][DIS]CONNECT */
249a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianenum {
250a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /* Buffers will be queued by EGL via eglSwapBuffers after being filled using
251a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * OpenGL ES.
252a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     */
253a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_API_EGL = 1,
254a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
255a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /* Buffers will be queued after being filled using the CPU
256a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     */
257a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_API_CPU = 2,
258a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
259a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /* Buffers will be queued by Stagefright after being filled by a video
260a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * decoder.  The video decoder can either be a software or hardware decoder.
261a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     */
262a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_API_MEDIA = 3,
263a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
264a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /* Buffers will be queued by the the camera HAL.
265a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     */
266a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_API_CAMERA = 4,
267a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian};
268a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
269a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* parameter for NATIVE_WINDOW_SET_BUFFERS_TRANSFORM */
270a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianenum {
271a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /* flip source image horizontally */
272a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H ,
273a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /* flip source image vertically */
274a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V,
275a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /* rotate source image 90 degrees clock-wise, and is applied after TRANSFORM_FLIP_{H|V} */
276a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90,
277a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /* rotate source image 180 degrees */
278a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180,
279a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /* rotate source image 270 degrees clock-wise */
280a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270,
281a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /* transforms source by the inverse transform of the screen it is displayed onto. This
282a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * transform is applied last */
283a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY = 0x08
284a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian};
285a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
286a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* parameter for NATIVE_WINDOW_SET_SCALING_MODE
287a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * keep in sync with Surface.java in frameworks/base */
288a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianenum {
289a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /* the window content is not updated (frozen) until a buffer of
290a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * the window size is received (enqueued)
291a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     */
292a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_SCALING_MODE_FREEZE           = 0,
293a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /* the buffer is scaled in both dimensions to match the window size */
294a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW  = 1,
295a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /* the buffer is scaled uniformly such that the smaller dimension
296a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * of the buffer matches the window size (cropping in the process)
297a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     */
298a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_SCALING_MODE_SCALE_CROP       = 2,
299a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /* the window is clipped to the size of the buffer's crop rectangle; pixels
300a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * outside the crop rectangle are treated as if they are completely
301a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * transparent.
302a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     */
303a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_SCALING_MODE_NO_SCALE_CROP    = 3,
304a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian};
305a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
306a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* values returned by the NATIVE_WINDOW_CONCRETE_TYPE query */
307a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianenum {
308a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_FRAMEBUFFER               = 0, /* FramebufferNativeWindow */
309a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    NATIVE_WINDOW_SURFACE                   = 1, /* Surface */
310a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian};
311a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
312a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* parameter for NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP
313a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *
314a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Special timestamp value to indicate that timestamps should be auto-generated
315a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * by the native window when queueBuffer is called.  This is equal to INT64_MIN,
316a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * defined directly to avoid problems with C99/C++ inclusion of stdint.h.
317a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */
318a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic const int64_t NATIVE_WINDOW_TIMESTAMP_AUTO = (-9223372036854775807LL-1);
319a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
320dc96fdfa58260867c993fff78611220874753201Brian Anderson/* parameter for NATIVE_WINDOW_GET_FRAME_TIMESTAMPS
321dc96fdfa58260867c993fff78611220874753201Brian Anderson *
322dc96fdfa58260867c993fff78611220874753201Brian Anderson * Special timestamp value to indicate the timestamps aren't yet known or
323dc96fdfa58260867c993fff78611220874753201Brian Anderson * that they are invalid.
324dc96fdfa58260867c993fff78611220874753201Brian Anderson */
325dc96fdfa58260867c993fff78611220874753201Brian Andersonstatic const int64_t NATIVE_WINDOW_TIMESTAMP_PENDING = -2;
326dc96fdfa58260867c993fff78611220874753201Brian Andersonstatic const int64_t NATIVE_WINDOW_TIMESTAMP_INVALID = -1;
327dc96fdfa58260867c993fff78611220874753201Brian Anderson
328a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstruct ANativeWindow
329a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{
330a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#ifdef __cplusplus
331a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    ANativeWindow()
332a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        : flags(0), minSwapInterval(0), maxSwapInterval(0), xdpi(0), ydpi(0)
333a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    {
334a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        common.magic = ANDROID_NATIVE_WINDOW_MAGIC;
335a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        common.version = sizeof(ANativeWindow);
336a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        memset(common.reserved, 0, sizeof(common.reserved));
337a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    }
338a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
339a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /* Implement the methods that sp<ANativeWindow> expects so that it
340a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian       can be used to automatically refcount ANativeWindow's. */
341a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    void incStrong(const void* /*id*/) const {
342a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        common.incRef(const_cast<android_native_base_t*>(&common));
343a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    }
344a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    void decStrong(const void* /*id*/) const {
345a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        common.decRef(const_cast<android_native_base_t*>(&common));
346a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    }
347a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian#endif
348a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
349a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    struct android_native_base_t common;
350a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
351a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /* flags describing some attributes of this surface or its updater */
352a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    const uint32_t flags;
353a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
354a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /* min swap interval supported by this updated */
355a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    const int   minSwapInterval;
356a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
357a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /* max swap interval supported by this updated */
358a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    const int   maxSwapInterval;
359a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
360a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /* horizontal and vertical resolution in DPI */
361a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    const float xdpi;
362a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    const float ydpi;
363a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
364a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /* Some storage reserved for the OEM's driver. */
365a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    intptr_t    oem[4];
366a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
367a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /*
368a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Set the swap interval for this surface.
369a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
370a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Returns 0 on success or -errno on error.
371a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     */
372a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    int     (*setSwapInterval)(struct ANativeWindow* window,
373a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian                int interval);
374a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
375a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /*
376a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Hook called by EGL to acquire a buffer. After this call, the buffer
377a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * is not locked, so its content cannot be modified. This call may block if
378a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * no buffers are available.
379a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
380a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * The window holds a reference to the buffer between dequeueBuffer and
381a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * either queueBuffer or cancelBuffer, so clients only need their own
382a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * reference if they might use the buffer after queueing or canceling it.
383a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Holding a reference to a buffer after queueing or canceling it is only
384a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * allowed if a specific buffer count has been set.
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 the new dequeueBuffer function that
390a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * outputs a fence file descriptor should be used in its place.
391a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     */
392a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    int     (*dequeueBuffer_DEPRECATED)(struct ANativeWindow* window,
393a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian                struct ANativeWindowBuffer** buffer);
394a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
395a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /*
396a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * hook called by EGL to lock a buffer. This MUST be called before modifying
397a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * the content of a buffer. The buffer must have been acquired with
398a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * dequeueBuffer first.
399a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
400a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Returns 0 on success or -errno on error.
401a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
402a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * XXX: This function is deprecated.  It will continue to work for some
403a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * time for binary compatibility, but it is essentially a no-op, and calls
404a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * to it should be removed.
405a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     */
406a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    int     (*lockBuffer_DEPRECATED)(struct ANativeWindow* window,
407a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian                struct ANativeWindowBuffer* buffer);
408a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
409a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /*
410a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Hook called by EGL when modifications to the render buffer are done.
411a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * This unlocks and post the buffer.
412a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
413a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * The window holds a reference to the buffer between dequeueBuffer and
414a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * either queueBuffer or cancelBuffer, so clients only need their own
415a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * reference if they might use the buffer after queueing or canceling it.
416a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Holding a reference to a buffer after queueing or canceling it is only
417a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * allowed if a specific buffer count has been set.
418a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
419a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Buffers MUST be queued in the same order than they were dequeued.
420a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
421a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Returns 0 on success or -errno on error.
422a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
423a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * XXX: This function is deprecated.  It will continue to work for some
424a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * time for binary compatibility, but the new queueBuffer function that
425a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * takes a fence file descriptor should be used in its place (pass a value
426a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * of -1 for the fence file descriptor if there is no valid one to pass).
427a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     */
428a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    int     (*queueBuffer_DEPRECATED)(struct ANativeWindow* window,
429a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian                struct ANativeWindowBuffer* buffer);
430a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
431a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /*
432a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * hook used to retrieve information about the native window.
433a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
434a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Returns 0 on success or -errno on error.
435a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     */
436a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    int     (*query)(const struct ANativeWindow* window,
437a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian                int what, int* value);
438a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
439a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /*
440a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * hook used to perform various operations on the surface.
441a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * (*perform)() is a generic mechanism to add functionality to
442a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * ANativeWindow while keeping backward binary compatibility.
443a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
444a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * DO NOT CALL THIS HOOK DIRECTLY.  Instead, use the helper functions
445a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * defined below.
446a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
447a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * (*perform)() returns -ENOENT if the 'what' parameter is not supported
448a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * by the surface's implementation.
449a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
450a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * See above for a list of valid operations, such as
451a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * NATIVE_WINDOW_SET_USAGE or NATIVE_WINDOW_CONNECT
452a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     */
453a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    int     (*perform)(struct ANativeWindow* window,
454a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian                int operation, ... );
455a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
456a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /*
457a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Hook used to cancel a buffer that has been dequeued.
458a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * No synchronization is performed between dequeue() and cancel(), so
459a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * either external synchronization is needed, or these functions must be
460a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * called from the same thread.
461a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
462a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * The window holds a reference to the buffer between dequeueBuffer and
463a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * either queueBuffer or cancelBuffer, so clients only need their own
464a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * reference if they might use the buffer after queueing or canceling it.
465a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Holding a reference to a buffer after queueing or canceling it is only
466a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * allowed if a specific buffer count has been set.
467a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
468a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * XXX: This function is deprecated.  It will continue to work for some
469a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * time for binary compatibility, but the new cancelBuffer function that
470a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * takes a fence file descriptor should be used in its place (pass a value
471a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * of -1 for the fence file descriptor if there is no valid one to pass).
472a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     */
473a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    int     (*cancelBuffer_DEPRECATED)(struct ANativeWindow* window,
474a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian                struct ANativeWindowBuffer* buffer);
475a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
476a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /*
477a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Hook called by EGL to acquire a buffer. This call may block if no
478a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * buffers are available.
479a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
480a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * The window holds a reference to the buffer between dequeueBuffer and
481a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * either queueBuffer or cancelBuffer, so clients only need their own
482a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * reference if they might use the buffer after queueing or canceling it.
483a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Holding a reference to a buffer after queueing or canceling it is only
484a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * allowed if a specific buffer count has been set.
485a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
486a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * The libsync fence file descriptor returned in the int pointed to by the
487a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * fenceFd argument will refer to the fence that must signal before the
488a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * dequeued buffer may be written to.  A value of -1 indicates that the
489a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * caller may access the buffer immediately without waiting on a fence.  If
490a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * a valid file descriptor is returned (i.e. any value except -1) then the
491a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * caller is responsible for closing the file descriptor.
492a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
493a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Returns 0 on success or -errno on error.
494a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     */
495a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    int     (*dequeueBuffer)(struct ANativeWindow* window,
496a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian                struct ANativeWindowBuffer** buffer, int* fenceFd);
497a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
498a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /*
499a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Hook called by EGL when modifications to the render buffer are done.
500a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * This unlocks and post the buffer.
501a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
502a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * The window holds a reference to the buffer between dequeueBuffer and
503a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * either queueBuffer or cancelBuffer, so clients only need their own
504a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * reference if they might use the buffer after queueing or canceling it.
505a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Holding a reference to a buffer after queueing or canceling it is only
506a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * allowed if a specific buffer count has been set.
507a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
508a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * The fenceFd argument specifies a libsync fence file descriptor for a
509a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * fence that must signal before the buffer can be accessed.  If the buffer
510a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * can be accessed immediately then a value of -1 should be used.  The
511a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * caller must not use the file descriptor after it is passed to
512a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * queueBuffer, and the ANativeWindow implementation is responsible for
513a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * closing it.
514a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
515a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Returns 0 on success or -errno on error.
516a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     */
517a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    int     (*queueBuffer)(struct ANativeWindow* window,
518a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian                struct ANativeWindowBuffer* buffer, int fenceFd);
519a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
520a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    /*
521a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Hook used to cancel a buffer that has been dequeued.
522a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * No synchronization is performed between dequeue() and cancel(), so
523a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * either external synchronization is needed, or these functions must be
524a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * called from the same thread.
525a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
526a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * The window holds a reference to the buffer between dequeueBuffer and
527a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * either queueBuffer or cancelBuffer, so clients only need their own
528a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * reference if they might use the buffer after queueing or canceling it.
529a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Holding a reference to a buffer after queueing or canceling it is only
530a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * allowed if a specific buffer count has been set.
531a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
532a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * The fenceFd argument specifies a libsync fence file decsriptor for a
533a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * fence that must signal before the buffer can be accessed.  If the buffer
534a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * can be accessed immediately then a value of -1 should be used.
535a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
536a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Note that if the client has not waited on the fence that was returned
537a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * from dequeueBuffer, that same fence should be passed to cancelBuffer to
538a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * ensure that future uses of the buffer are preceded by a wait on that
539a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * fence.  The caller must not use the file descriptor after it is passed
540a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * to cancelBuffer, and the ANativeWindow implementation is responsible for
541a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * closing it.
542a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     *
543a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     * Returns 0 on success or -errno on error.
544a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian     */
545a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    int     (*cancelBuffer)(struct ANativeWindow* window,
546a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian                struct ANativeWindowBuffer* buffer, int fenceFd);
547a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian};
548a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
549a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian /* Backwards compatibility: use ANativeWindow (struct ANativeWindow in C).
550a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian  * android_native_window_t is deprecated.
551a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian  */
552a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopiantypedef struct ANativeWindow ANativeWindow;
553a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopiantypedef struct ANativeWindow android_native_window_t __deprecated;
554a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
555a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/*
556a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *  native_window_set_usage(..., usage)
557a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *  Sets the intended usage flags for the next buffers
558a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *  acquired with (*lockBuffer)() and on.
559a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *  By default (if this function is never called), a usage of
560a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *      GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE
561a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *  is assumed.
562a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *  Calling this function will usually cause following buffers to be
563a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *  reallocated.
564a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */
565a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
566a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_set_usage(
567a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        struct ANativeWindow* window, int usage)
568a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{
569a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    return window->perform(window, NATIVE_WINDOW_SET_USAGE, usage);
570a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian}
571a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
572a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* deprecated. Always returns 0. Don't call. */
573a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_connect(
574a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        struct ANativeWindow* window __UNUSED, int api __UNUSED) __deprecated;
575a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
576a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_connect(
577a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        struct ANativeWindow* window __UNUSED, int api __UNUSED) {
578a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    return 0;
579a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian}
580a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
581a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/* deprecated. Always returns 0. Don't call. */
582a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_disconnect(
583a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        struct ANativeWindow* window __UNUSED, int api __UNUSED) __deprecated;
584a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
585a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_disconnect(
586a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        struct ANativeWindow* window __UNUSED, int api __UNUSED) {
587a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian    return 0;
588a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian}
589a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian
590a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian/*
591a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * native_window_set_crop(..., crop)
592a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Sets which region of the next queued buffers needs to be considered.
593a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * Depending on the scaling mode, a buffer's crop region is scaled and/or
594a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * cropped to match the surface's size.  This function sets the crop in
595a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * pre-transformed buffer pixel coordinates.
596a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *
597a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * The specified crop region applies to all buffers queued after it is called.
598a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *
599a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * If 'crop' is NULL, subsequently queued buffers won't be cropped.
600a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian *
601a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * An error is returned if for instance the crop region is invalid, out of the
602a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian * buffer's bound or if the window is invalid.
603a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian */
604a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopianstatic inline int native_window_set_crop(
605a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        struct ANativeWindow* window,
606a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian        android_native_rect_t const * crop)
607a6c0e20ac89b1be29901a7200590bf7cb8b99f78Mathias Agopian{
608