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