blob: f439705495b36d1d64413016490fa10717a5b5d7 [file] [log] [blame]
Iliyan Malchev0ab886b2011-05-01 14:07:43 -07001/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H
18#define SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H
19
Jamie Gennis22aec572012-06-13 16:43:06 -070020#include <cutils/native_handle.h>
Jesse Hallbc930ed2012-10-01 13:48:36 -070021#include <errno.h>
Jamie Gennis22aec572012-06-13 16:43:06 -070022#include <limits.h>
Iliyan Malchev0ab886b2011-05-01 14:07:43 -070023#include <stdint.h>
Mathias Agopianc958a7f2012-02-25 21:13:36 -080024#include <string.h>
Iliyan Malchev0ab886b2011-05-01 14:07:43 -070025#include <sys/cdefs.h>
26#include <system/graphics.h>
Jamie Gennis22aec572012-06-13 16:43:06 -070027#include <unistd.h>
Pablo Ceballos923d27f2015-10-19 10:24:42 -070028#include <stdbool.h>
Iliyan Malchev0ab886b2011-05-01 14:07:43 -070029
Ian Rogersde8b9832014-06-27 16:38:01 -070030#ifndef __UNUSED
31#define __UNUSED __attribute__((__unused__))
Mark Salyzyn48878422014-05-22 16:08:52 -070032#endif
Mark Salyzyn289e1112014-05-23 12:31:42 -070033#ifndef __deprecated
34#define __deprecated __attribute__((__deprecated__))
35#endif
Mark Salyzyn48878422014-05-22 16:08:52 -070036
Iliyan Malchev0ab886b2011-05-01 14:07:43 -070037__BEGIN_DECLS
38
39/*****************************************************************************/
40
Colin Cross7c7990e2016-09-15 18:04:04 -070041#ifdef __cplusplus
42#define ANDROID_NATIVE_UNSIGNED_CAST(x) static_cast<unsigned int>(x)
43#else
44#define ANDROID_NATIVE_UNSIGNED_CAST(x) ((unsigned int)(x))
45#endif
46
Iliyan Malchev0ab886b2011-05-01 14:07:43 -070047#define ANDROID_NATIVE_MAKE_CONSTANT(a,b,c,d) \
Colin Cross7c7990e2016-09-15 18:04:04 -070048 ((ANDROID_NATIVE_UNSIGNED_CAST(a) << 24) | \
49 (ANDROID_NATIVE_UNSIGNED_CAST(b) << 16) | \
50 (ANDROID_NATIVE_UNSIGNED_CAST(c) << 8) | \
51 (ANDROID_NATIVE_UNSIGNED_CAST(d)))
Iliyan Malchev0ab886b2011-05-01 14:07:43 -070052
53#define ANDROID_NATIVE_WINDOW_MAGIC \
54 ANDROID_NATIVE_MAKE_CONSTANT('_','w','n','d')
55
56#define ANDROID_NATIVE_BUFFER_MAGIC \
57 ANDROID_NATIVE_MAKE_CONSTANT('_','b','f','r')
58
59// ---------------------------------------------------------------------------
60
Jamie Gennis22aec572012-06-13 16:43:06 -070061// This #define may be used to conditionally compile device-specific code to
62// support either the prior ANativeWindow interface, which did not pass libsync
63// fences around, or the new interface that does. This #define is only present
64// when the ANativeWindow interface does include libsync support.
65#define ANDROID_NATIVE_WINDOW_HAS_SYNC 1
66
67// ---------------------------------------------------------------------------
68
Iliyan Malchev0ab886b2011-05-01 14:07:43 -070069typedef const native_handle_t* buffer_handle_t;
70
71// ---------------------------------------------------------------------------
72
73typedef struct android_native_rect_t
74{
75 int32_t left;
76 int32_t top;
77 int32_t right;
78 int32_t bottom;
79} android_native_rect_t;
80
81// ---------------------------------------------------------------------------
82
83typedef struct android_native_base_t
84{
85 /* a magic value defined by the actual EGL native type */
86 int magic;
87
88 /* the sizeof() of the actual EGL native type */
89 int version;
90
91 void* reserved[4];
92
93 /* reference-counting interface */
94 void (*incRef)(struct android_native_base_t* base);
95 void (*decRef)(struct android_native_base_t* base);
96} android_native_base_t;
97
98typedef struct ANativeWindowBuffer
99{
100#ifdef __cplusplus
101 ANativeWindowBuffer() {
102 common.magic = ANDROID_NATIVE_BUFFER_MAGIC;
103 common.version = sizeof(ANativeWindowBuffer);
104 memset(common.reserved, 0, sizeof(common.reserved));
105 }
106
107 // Implement the methods that sp<ANativeWindowBuffer> expects so that it
108 // can be used to automatically refcount ANativeWindowBuffer's.
Mark Salyzyn48878422014-05-22 16:08:52 -0700109 void incStrong(const void* /*id*/) const {
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700110 common.incRef(const_cast<android_native_base_t*>(&common));
111 }
Mark Salyzyn48878422014-05-22 16:08:52 -0700112 void decStrong(const void* /*id*/) const {
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700113 common.decRef(const_cast<android_native_base_t*>(&common));
114 }
115#endif
116
117 struct android_native_base_t common;
118
119 int width;
120 int height;
121 int stride;
122 int format;
123 int usage;
124
125 void* reserved[2];
126
127 buffer_handle_t handle;
128
129 void* reserved_proc[8];
130} ANativeWindowBuffer_t;
131
132// Old typedef for backwards compatibility.
133typedef ANativeWindowBuffer_t android_native_buffer_t;
134
135// ---------------------------------------------------------------------------
136
137/* attributes queriable with query() */
138enum {
139 NATIVE_WINDOW_WIDTH = 0,
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700140 NATIVE_WINDOW_HEIGHT = 1,
141 NATIVE_WINDOW_FORMAT = 2,
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700142
143 /* The minimum number of buffers that must remain un-dequeued after a buffer
144 * has been queued. This value applies only if set_buffer_count was used to
145 * override the number of buffers and if a buffer has since been queued.
146 * Users of the set_buffer_count ANativeWindow method should query this
147 * value before calling set_buffer_count. If it is necessary to have N
148 * buffers simultaneously dequeued as part of the steady-state operation,
149 * and this query returns M then N+M buffers should be requested via
150 * native_window_set_buffer_count.
151 *
152 * Note that this value does NOT apply until a single buffer has been
153 * queued. In particular this means that it is possible to:
154 *
155 * 1. Query M = min undequeued buffers
156 * 2. Set the buffer count to N + M
157 * 3. Dequeue all N + M buffers
158 * 4. Cancel M buffers
159 * 5. Queue, dequeue, queue, dequeue, ad infinitum
160 */
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700161 NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS = 3,
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700162
163 /* Check whether queueBuffer operations on the ANativeWindow send the buffer
164 * to the window compositor. The query sets the returned 'value' argument
165 * to 1 if the ANativeWindow DOES send queued buffers directly to the window
166 * compositor and 0 if the buffers do not go directly to the window
167 * compositor.
168 *
169 * This can be used to determine whether protected buffer content should be
170 * sent to the ANativeWindow. Note, however, that a result of 1 does NOT
171 * indicate that queued buffers will be protected from applications or users
172 * capturing their contents. If that behavior is desired then some other
173 * mechanism (e.g. the GRALLOC_USAGE_PROTECTED flag) should be used in
174 * conjunction with this query.
175 */
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700176 NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER = 4,
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700177
178 /* Get the concrete type of a ANativeWindow. See below for the list of
179 * possible return values.
180 *
181 * This query should not be used outside the Android framework and will
182 * likely be removed in the near future.
183 */
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700184 NATIVE_WINDOW_CONCRETE_TYPE = 5,
Mathias Agopian51009162011-07-19 15:59:15 -0700185
186
187 /*
Michael I. Goldafcdef62012-04-09 18:21:13 -0700188 * Default width and height of ANativeWindow buffers, these are the
189 * dimensions of the window buffers irrespective of the
190 * NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS call and match the native window
Jamie Gennisaa3f4c32012-04-17 19:37:48 -0700191 * size unless overridden by NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS.
Mathias Agopian51009162011-07-19 15:59:15 -0700192 */
193 NATIVE_WINDOW_DEFAULT_WIDTH = 6,
194 NATIVE_WINDOW_DEFAULT_HEIGHT = 7,
195
196 /*
197 * transformation that will most-likely be applied to buffers. This is only
198 * a hint, the actual transformation applied might be different.
199 *
200 * INTENDED USE:
201 *
202 * The transform hint can be used by a producer, for instance the GLES
203 * driver, to pre-rotate the rendering such that the final transformation
204 * in the composer is identity. This can be very useful when used in
205 * conjunction with the h/w composer HAL, in situations where it
206 * cannot handle arbitrary rotations.
207 *
208 * 1. Before dequeuing a buffer, the GL driver (or any other ANW client)
209 * queries the ANW for NATIVE_WINDOW_TRANSFORM_HINT.
210 *
211 * 2. The GL driver overrides the width and height of the ANW to
212 * account for NATIVE_WINDOW_TRANSFORM_HINT. This is done by querying
213 * NATIVE_WINDOW_DEFAULT_{WIDTH | HEIGHT}, swapping the dimensions
214 * according to NATIVE_WINDOW_TRANSFORM_HINT and calling
215 * native_window_set_buffers_dimensions().
216 *
217 * 3. The GL driver dequeues a buffer of the new pre-rotated size.
218 *
219 * 4. The GL driver renders to the buffer such that the image is
220 * already transformed, that is applying NATIVE_WINDOW_TRANSFORM_HINT
221 * to the rendering.
222 *
223 * 5. The GL driver calls native_window_set_transform to apply
224 * inverse transformation to the buffer it just rendered.
225 * In order to do this, the GL driver needs
226 * to calculate the inverse of NATIVE_WINDOW_TRANSFORM_HINT, this is
227 * done easily:
228 *
229 * int hintTransform, inverseTransform;
230 * query(..., NATIVE_WINDOW_TRANSFORM_HINT, &hintTransform);
231 * inverseTransform = hintTransform;
232 * if (hintTransform & HAL_TRANSFORM_ROT_90)
233 * inverseTransform ^= HAL_TRANSFORM_ROT_180;
234 *
235 *
236 * 6. The GL driver queues the pre-transformed buffer.
237 *
238 * 7. The composer combines the buffer transform with the display
239 * transform. If the buffer transform happens to cancel out the
240 * display transform then no rotation is needed.
241 *
242 */
243 NATIVE_WINDOW_TRANSFORM_HINT = 8,
Jamie Gennisaa3f4c32012-04-17 19:37:48 -0700244
245 /*
246 * Boolean that indicates whether the consumer is running more than
247 * one buffer behind the producer.
248 */
Eino-Ville Talvalaf88a5b42013-07-30 14:07:08 -0700249 NATIVE_WINDOW_CONSUMER_RUNNING_BEHIND = 9,
250
251 /*
252 * The consumer gralloc usage bits currently set by the consumer.
253 * The values are defined in hardware/libhardware/include/gralloc.h.
254 */
Ruben Brunka5e65d82014-06-27 16:15:18 -0700255 NATIVE_WINDOW_CONSUMER_USAGE_BITS = 10,
256
257 /**
258 * Transformation that will by applied to buffers by the hwcomposer.
259 * This must not be set or checked by producer endpoints, and will
260 * disable the transform hint set in SurfaceFlinger (see
261 * NATIVE_WINDOW_TRANSFORM_HINT).
262 *
263 * INTENDED USE:
264 * Temporary - Please do not use this. This is intended only to be used
265 * by the camera's LEGACY mode.
266 *
267 * In situations where a SurfaceFlinger client wishes to set a transform
268 * that is not visible to the producer, and will always be applied in the
269 * hardware composer, the client can set this flag with
270 * native_window_set_buffers_sticky_transform. This can be used to rotate
271 * and flip buffers consumed by hardware composer without actually changing
272 * the aspect ratio of the buffers produced.
273 */
274 NATIVE_WINDOW_STICKY_TRANSFORM = 11,
Eino-Ville Talvalab93343d2015-02-17 15:34:44 -0800275
276 /**
277 * The default data space for the buffers as set by the consumer.
278 * The values are defined in graphics.h.
279 */
Dan Stoza0a866ea2015-02-25 16:45:08 -0800280 NATIVE_WINDOW_DEFAULT_DATASPACE = 12,
281
282 /*
283 * Returns the age of the contents of the most recently dequeued buffer as
284 * the number of frames that have elapsed since it was last queued. For
285 * example, if the window is double-buffered, the age of any given buffer in
286 * steady state will be 2. If the dequeued buffer has never been queued, its
287 * age will be 0.
288 */
289 NATIVE_WINDOW_BUFFER_AGE = 13,
Dan Stoza94ededa2016-07-01 14:02:08 -0700290
291 /*
292 * Returns the duration of the last dequeueBuffer call in microseconds
293 */
294 NATIVE_WINDOW_LAST_DEQUEUE_DURATION = 14,
295
296 /*
297 * Returns the duration of the last queueBuffer call in microseconds
298 */
299 NATIVE_WINDOW_LAST_QUEUE_DURATION = 15,
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700300};
301
Jamie Gennisfb1ee572012-04-17 19:37:48 -0700302/* Valid operations for the (*perform)() hook.
303 *
304 * Values marked as 'deprecated' are supported, but have been superceded by
305 * other functionality.
306 *
307 * Values marked as 'private' should be considered private to the framework.
308 * HAL implementation code with access to an ANativeWindow should not use these,
309 * as it may not interact properly with the framework's use of the
310 * ANativeWindow.
311 */
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700312enum {
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700313 NATIVE_WINDOW_SET_USAGE = 0,
Mathias Agopian8ad54522011-07-29 17:52:36 -0700314 NATIVE_WINDOW_CONNECT = 1, /* deprecated */
315 NATIVE_WINDOW_DISCONNECT = 2, /* deprecated */
Jamie Gennisfb1ee572012-04-17 19:37:48 -0700316 NATIVE_WINDOW_SET_CROP = 3, /* private */
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700317 NATIVE_WINDOW_SET_BUFFER_COUNT = 4,
318 NATIVE_WINDOW_SET_BUFFERS_GEOMETRY = 5, /* deprecated */
319 NATIVE_WINDOW_SET_BUFFERS_TRANSFORM = 6,
320 NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP = 7,
321 NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS = 8,
322 NATIVE_WINDOW_SET_BUFFERS_FORMAT = 9,
Jamie Gennisfb1ee572012-04-17 19:37:48 -0700323 NATIVE_WINDOW_SET_SCALING_MODE = 10, /* private */
Mathias Agopianae3736a2011-07-13 18:40:38 -0700324 NATIVE_WINDOW_LOCK = 11, /* private */
325 NATIVE_WINDOW_UNLOCK_AND_POST = 12, /* private */
Mathias Agopian8ad54522011-07-29 17:52:36 -0700326 NATIVE_WINDOW_API_CONNECT = 13, /* private */
327 NATIVE_WINDOW_API_DISCONNECT = 14, /* private */
Michael I. Goldafcdef62012-04-09 18:21:13 -0700328 NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS = 15, /* private */
Jamie Gennisd21113a2012-05-03 14:21:24 -0700329 NATIVE_WINDOW_SET_POST_TRANSFORM_CROP = 16, /* private */
Ruben Brunka5e65d82014-06-27 16:15:18 -0700330 NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM = 17,/* private */
Rachadd6d4c612014-07-29 18:03:21 -0700331 NATIVE_WINDOW_SET_SIDEBAND_STREAM = 18,
Dan Stoza238ec982015-03-23 10:43:14 -0700332 NATIVE_WINDOW_SET_BUFFERS_DATASPACE = 19,
333 NATIVE_WINDOW_SET_SURFACE_DAMAGE = 20, /* private */
Pablo Ceballos248e7712016-03-17 15:42:21 -0700334 NATIVE_WINDOW_SET_SHARED_BUFFER_MODE = 21,
Pablo Ceballos3daa5742016-01-15 13:31:14 -0800335 NATIVE_WINDOW_SET_AUTO_REFRESH = 22,
Pablo Ceballosc2efc322016-05-31 11:06:03 -0700336 NATIVE_WINDOW_GET_FRAME_TIMESTAMPS = 23,
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700337};
338
Mathias Agopian8ad54522011-07-29 17:52:36 -0700339/* parameter for NATIVE_WINDOW_[API_][DIS]CONNECT */
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700340enum {
Jamie Gennis5423e9e2011-07-12 13:53:42 -0700341 /* Buffers will be queued by EGL via eglSwapBuffers after being filled using
342 * OpenGL ES.
343 */
344 NATIVE_WINDOW_API_EGL = 1,
345
346 /* Buffers will be queued after being filled using the CPU
347 */
348 NATIVE_WINDOW_API_CPU = 2,
349
350 /* Buffers will be queued by Stagefright after being filled by a video
351 * decoder. The video decoder can either be a software or hardware decoder.
352 */
353 NATIVE_WINDOW_API_MEDIA = 3,
354
355 /* Buffers will be queued by the the camera HAL.
356 */
357 NATIVE_WINDOW_API_CAMERA = 4,
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700358};
359
360/* parameter for NATIVE_WINDOW_SET_BUFFERS_TRANSFORM */
361enum {
362 /* flip source image horizontally */
363 NATIVE_WINDOW_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H ,
364 /* flip source image vertically */
365 NATIVE_WINDOW_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V,
Mathias Agopian96675ed2013-09-17 23:48:54 -0700366 /* rotate source image 90 degrees clock-wise, and is applied after TRANSFORM_FLIP_{H|V} */
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700367 NATIVE_WINDOW_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90,
368 /* rotate source image 180 degrees */
369 NATIVE_WINDOW_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180,
370 /* rotate source image 270 degrees clock-wise */
371 NATIVE_WINDOW_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270,
Mathias Agopian96675ed2013-09-17 23:48:54 -0700372 /* transforms source by the inverse transform of the screen it is displayed onto. This
373 * transform is applied last */
374 NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY = 0x08
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700375};
376
Robert Carrf3954fb2015-12-17 11:31:11 -0800377/* parameter for NATIVE_WINDOW_SET_SCALING_MODE
378 * keep in sync with Surface.java in frameworks/base */
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700379enum {
380 /* the window content is not updated (frozen) until a buffer of
381 * the window size is received (enqueued)
382 */
383 NATIVE_WINDOW_SCALING_MODE_FREEZE = 0,
384 /* the buffer is scaled in both dimensions to match the window size */
385 NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW = 1,
Daniel Lam29392a42012-04-11 18:19:46 -0700386 /* the buffer is scaled uniformly such that the smaller dimension
387 * of the buffer matches the window size (cropping in the process)
388 */
389 NATIVE_WINDOW_SCALING_MODE_SCALE_CROP = 2,
Jamie Gennisd21113a2012-05-03 14:21:24 -0700390 /* the window is clipped to the size of the buffer's crop rectangle; pixels
391 * outside the crop rectangle are treated as if they are completely
392 * transparent.
393 */
394 NATIVE_WINDOW_SCALING_MODE_NO_SCALE_CROP = 3,
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700395};
396
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700397/* values returned by the NATIVE_WINDOW_CONCRETE_TYPE query */
398enum {
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700399 NATIVE_WINDOW_FRAMEBUFFER = 0, /* FramebufferNativeWindow */
400 NATIVE_WINDOW_SURFACE = 1, /* Surface */
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700401};
402
403/* parameter for NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP
404 *
405 * Special timestamp value to indicate that timestamps should be auto-generated
406 * by the native window when queueBuffer is called. This is equal to INT64_MIN,
407 * defined directly to avoid problems with C99/C++ inclusion of stdint.h.
408 */
409static const int64_t NATIVE_WINDOW_TIMESTAMP_AUTO = (-9223372036854775807LL-1);
410
411struct ANativeWindow
412{
413#ifdef __cplusplus
414 ANativeWindow()
415 : flags(0), minSwapInterval(0), maxSwapInterval(0), xdpi(0), ydpi(0)
416 {
417 common.magic = ANDROID_NATIVE_WINDOW_MAGIC;
418 common.version = sizeof(ANativeWindow);
419 memset(common.reserved, 0, sizeof(common.reserved));
420 }
421
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700422 /* Implement the methods that sp<ANativeWindow> expects so that it
423 can be used to automatically refcount ANativeWindow's. */
Mark Salyzyn48878422014-05-22 16:08:52 -0700424 void incStrong(const void* /*id*/) const {
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700425 common.incRef(const_cast<android_native_base_t*>(&common));
426 }
Mark Salyzyn48878422014-05-22 16:08:52 -0700427 void decStrong(const void* /*id*/) const {
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700428 common.decRef(const_cast<android_native_base_t*>(&common));
429 }
430#endif
431
432 struct android_native_base_t common;
433
434 /* flags describing some attributes of this surface or its updater */
435 const uint32_t flags;
436
437 /* min swap interval supported by this updated */
438 const int minSwapInterval;
439
440 /* max swap interval supported by this updated */
441 const int maxSwapInterval;
442
443 /* horizontal and vertical resolution in DPI */
444 const float xdpi;
445 const float ydpi;
446
447 /* Some storage reserved for the OEM's driver. */
448 intptr_t oem[4];
449
450 /*
451 * Set the swap interval for this surface.
452 *
453 * Returns 0 on success or -errno on error.
454 */
455 int (*setSwapInterval)(struct ANativeWindow* window,
456 int interval);
457
458 /*
Jesse Hall7cd3e0a2011-12-12 10:32:55 -0800459 * Hook called by EGL to acquire a buffer. After this call, the buffer
460 * is not locked, so its content cannot be modified. This call may block if
461 * no buffers are available.
462 *
463 * The window holds a reference to the buffer between dequeueBuffer and
464 * either queueBuffer or cancelBuffer, so clients only need their own
465 * reference if they might use the buffer after queueing or canceling it.
466 * Holding a reference to a buffer after queueing or canceling it is only
467 * allowed if a specific buffer count has been set.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700468 *
469 * Returns 0 on success or -errno on error.
Jamie Gennis22aec572012-06-13 16:43:06 -0700470 *
471 * XXX: This function is deprecated. It will continue to work for some
472 * time for binary compatibility, but the new dequeueBuffer function that
473 * outputs a fence file descriptor should be used in its place.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700474 */
Jamie Gennis22aec572012-06-13 16:43:06 -0700475 int (*dequeueBuffer_DEPRECATED)(struct ANativeWindow* window,
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700476 struct ANativeWindowBuffer** buffer);
477
478 /*
479 * hook called by EGL to lock a buffer. This MUST be called before modifying
480 * the content of a buffer. The buffer must have been acquired with
481 * dequeueBuffer first.
482 *
483 * Returns 0 on success or -errno on error.
Jamie Gennis22aec572012-06-13 16:43:06 -0700484 *
485 * XXX: This function is deprecated. It will continue to work for some
486 * time for binary compatibility, but it is essentially a no-op, and calls
487 * to it should be removed.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700488 */
Jamie Gennis22aec572012-06-13 16:43:06 -0700489 int (*lockBuffer_DEPRECATED)(struct ANativeWindow* window,
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700490 struct ANativeWindowBuffer* buffer);
Jamie Gennis22aec572012-06-13 16:43:06 -0700491
Jesse Hall7cd3e0a2011-12-12 10:32:55 -0800492 /*
493 * Hook called by EGL when modifications to the render buffer are done.
494 * This unlocks and post the buffer.
495 *
496 * The window holds a reference to the buffer between dequeueBuffer and
497 * either queueBuffer or cancelBuffer, so clients only need their own
498 * reference if they might use the buffer after queueing or canceling it.
499 * Holding a reference to a buffer after queueing or canceling it is only
500 * allowed if a specific buffer count has been set.
501 *
502 * Buffers MUST be queued in the same order than they were dequeued.
503 *
504 * Returns 0 on success or -errno on error.
Jamie Gennis22aec572012-06-13 16:43:06 -0700505 *
506 * XXX: This function is deprecated. It will continue to work for some
507 * time for binary compatibility, but the new queueBuffer function that
508 * takes a fence file descriptor should be used in its place (pass a value
509 * of -1 for the fence file descriptor if there is no valid one to pass).
Jesse Hall7cd3e0a2011-12-12 10:32:55 -0800510 */
Jamie Gennis22aec572012-06-13 16:43:06 -0700511 int (*queueBuffer_DEPRECATED)(struct ANativeWindow* window,
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700512 struct ANativeWindowBuffer* buffer);
513
514 /*
515 * hook used to retrieve information about the native window.
516 *
517 * Returns 0 on success or -errno on error.
518 */
519 int (*query)(const struct ANativeWindow* window,
520 int what, int* value);
521
522 /*
523 * hook used to perform various operations on the surface.
524 * (*perform)() is a generic mechanism to add functionality to
525 * ANativeWindow while keeping backward binary compatibility.
526 *
527 * DO NOT CALL THIS HOOK DIRECTLY. Instead, use the helper functions
528 * defined below.
529 *
Dan Stoza238ec982015-03-23 10:43:14 -0700530 * (*perform)() returns -ENOENT if the 'what' parameter is not supported
531 * by the surface's implementation.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700532 *
Dan Stoza238ec982015-03-23 10:43:14 -0700533 * See above for a list of valid operations, such as
534 * NATIVE_WINDOW_SET_USAGE or NATIVE_WINDOW_CONNECT
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700535 */
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700536 int (*perform)(struct ANativeWindow* window,
537 int operation, ... );
538
539 /*
Jesse Hall7cd3e0a2011-12-12 10:32:55 -0800540 * Hook used to cancel a buffer that has been dequeued.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700541 * No synchronization is performed between dequeue() and cancel(), so
542 * either external synchronization is needed, or these functions must be
543 * called from the same thread.
Jesse Hall7cd3e0a2011-12-12 10:32:55 -0800544 *
545 * The window holds a reference to the buffer between dequeueBuffer and
546 * either queueBuffer or cancelBuffer, so clients only need their own
547 * reference if they might use the buffer after queueing or canceling it.
548 * Holding a reference to a buffer after queueing or canceling it is only
549 * allowed if a specific buffer count has been set.
Jamie Gennis22aec572012-06-13 16:43:06 -0700550 *
551 * XXX: This function is deprecated. It will continue to work for some
552 * time for binary compatibility, but the new cancelBuffer function that
553 * takes a fence file descriptor should be used in its place (pass a value
554 * of -1 for the fence file descriptor if there is no valid one to pass).
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700555 */
Jamie Gennis22aec572012-06-13 16:43:06 -0700556 int (*cancelBuffer_DEPRECATED)(struct ANativeWindow* window,
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700557 struct ANativeWindowBuffer* buffer);
558
Jamie Gennis22aec572012-06-13 16:43:06 -0700559 /*
560 * Hook called by EGL to acquire a buffer. This call may block if no
561 * buffers are available.
562 *
563 * The window holds a reference to the buffer between dequeueBuffer and
564 * either queueBuffer or cancelBuffer, so clients only need their own
565 * reference if they might use the buffer after queueing or canceling it.
566 * Holding a reference to a buffer after queueing or canceling it is only
567 * allowed if a specific buffer count has been set.
568 *
569 * The libsync fence file descriptor returned in the int pointed to by the
570 * fenceFd argument will refer to the fence that must signal before the
571 * dequeued buffer may be written to. A value of -1 indicates that the
572 * caller may access the buffer immediately without waiting on a fence. If
573 * a valid file descriptor is returned (i.e. any value except -1) then the
574 * caller is responsible for closing the file descriptor.
575 *
576 * Returns 0 on success or -errno on error.
577 */
578 int (*dequeueBuffer)(struct ANativeWindow* window,
579 struct ANativeWindowBuffer** buffer, int* fenceFd);
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700580
Jamie Gennis22aec572012-06-13 16:43:06 -0700581 /*
582 * Hook called by EGL when modifications to the render buffer are done.
583 * This unlocks and post the buffer.
584 *
585 * The window holds a reference to the buffer between dequeueBuffer and
586 * either queueBuffer or cancelBuffer, so clients only need their own
587 * reference if they might use the buffer after queueing or canceling it.
588 * Holding a reference to a buffer after queueing or canceling it is only
589 * allowed if a specific buffer count has been set.
590 *
591 * The fenceFd argument specifies a libsync fence file descriptor for a
592 * fence that must signal before the buffer can be accessed. If the buffer
593 * can be accessed immediately then a value of -1 should be used. The
594 * caller must not use the file descriptor after it is passed to
595 * queueBuffer, and the ANativeWindow implementation is responsible for
596 * closing it.
597 *
598 * Returns 0 on success or -errno on error.
599 */
600 int (*queueBuffer)(struct ANativeWindow* window,
601 struct ANativeWindowBuffer* buffer, int fenceFd);
602
603 /*
604 * Hook used to cancel a buffer that has been dequeued.
605 * No synchronization is performed between dequeue() and cancel(), so
606 * either external synchronization is needed, or these functions must be
607 * called from the same thread.
608 *
609 * The window holds a reference to the buffer between dequeueBuffer and
610 * either queueBuffer or cancelBuffer, so clients only need their own
611 * reference if they might use the buffer after queueing or canceling it.
612 * Holding a reference to a buffer after queueing or canceling it is only
613 * allowed if a specific buffer count has been set.
614 *
615 * The fenceFd argument specifies a libsync fence file decsriptor for a
616 * fence that must signal before the buffer can be accessed. If the buffer
617 * can be accessed immediately then a value of -1 should be used.
618 *
619 * Note that if the client has not waited on the fence that was returned
620 * from dequeueBuffer, that same fence should be passed to cancelBuffer to
621 * ensure that future uses of the buffer are preceded by a wait on that
622 * fence. The caller must not use the file descriptor after it is passed
623 * to cancelBuffer, and the ANativeWindow implementation is responsible for
624 * closing it.
625 *
626 * Returns 0 on success or -errno on error.
627 */
628 int (*cancelBuffer)(struct ANativeWindow* window,
629 struct ANativeWindowBuffer* buffer, int fenceFd);
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700630};
631
632 /* Backwards compatibility: use ANativeWindow (struct ANativeWindow in C).
633 * android_native_window_t is deprecated.
634 */
635typedef struct ANativeWindow ANativeWindow;
Mark Salyzyn289e1112014-05-23 12:31:42 -0700636typedef struct ANativeWindow android_native_window_t __deprecated;
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700637
638/*
639 * native_window_set_usage(..., usage)
640 * Sets the intended usage flags for the next buffers
641 * acquired with (*lockBuffer)() and on.
642 * By default (if this function is never called), a usage of
643 * GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE
644 * is assumed.
645 * Calling this function will usually cause following buffers to be
646 * reallocated.
647 */
648
649static inline int native_window_set_usage(
650 struct ANativeWindow* window, int usage)
651{
652 return window->perform(window, NATIVE_WINDOW_SET_USAGE, usage);
653}
654
Mathias Agopian8ad54522011-07-29 17:52:36 -0700655/* deprecated. Always returns 0. Don't call. */
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700656static inline int native_window_connect(
Ian Rogersde8b9832014-06-27 16:38:01 -0700657 struct ANativeWindow* window __UNUSED, int api __UNUSED) __deprecated;
Mark Salyzyn289e1112014-05-23 12:31:42 -0700658
659static inline int native_window_connect(
Ian Rogersde8b9832014-06-27 16:38:01 -0700660 struct ANativeWindow* window __UNUSED, int api __UNUSED) {
Mathias Agopian319f4e22011-08-03 11:26:38 -0700661 return 0;
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700662}
663
Mathias Agopian8ad54522011-07-29 17:52:36 -0700664/* deprecated. Always returns 0. Don't call. */
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700665static inline int native_window_disconnect(
Ian Rogersde8b9832014-06-27 16:38:01 -0700666 struct ANativeWindow* window __UNUSED, int api __UNUSED) __deprecated;
Mark Salyzyn289e1112014-05-23 12:31:42 -0700667
668static inline int native_window_disconnect(
Ian Rogersde8b9832014-06-27 16:38:01 -0700669 struct ANativeWindow* window __UNUSED, int api __UNUSED) {
Mathias Agopian319f4e22011-08-03 11:26:38 -0700670 return 0;
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700671}
672
673/*
674 * native_window_set_crop(..., crop)
675 * Sets which region of the next queued buffers needs to be considered.
Jamie Gennisd21113a2012-05-03 14:21:24 -0700676 * Depending on the scaling mode, a buffer's crop region is scaled and/or
677 * cropped to match the surface's size. This function sets the crop in
678 * pre-transformed buffer pixel coordinates.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700679 *
680 * The specified crop region applies to all buffers queued after it is called.
681 *
Jamie Gennisd21113a2012-05-03 14:21:24 -0700682 * If 'crop' is NULL, subsequently queued buffers won't be cropped.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700683 *
Jamie Gennisd21113a2012-05-03 14:21:24 -0700684 * An error is returned if for instance the crop region is invalid, out of the
685 * buffer's bound or if the window is invalid.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700686 */
687static inline int native_window_set_crop(
688 struct ANativeWindow* window,
689 android_native_rect_t const * crop)
690{
691 return window->perform(window, NATIVE_WINDOW_SET_CROP, crop);
692}
693
694/*
Jamie Gennisd21113a2012-05-03 14:21:24 -0700695 * native_window_set_post_transform_crop(..., crop)
696 * Sets which region of the next queued buffers needs to be considered.
697 * Depending on the scaling mode, a buffer's crop region is scaled and/or
698 * cropped to match the surface's size. This function sets the crop in
699 * post-transformed pixel coordinates.
700 *
701 * The specified crop region applies to all buffers queued after it is called.
702 *
703 * If 'crop' is NULL, subsequently queued buffers won't be cropped.
704 *
705 * An error is returned if for instance the crop region is invalid, out of the
706 * buffer's bound or if the window is invalid.
707 */
708static inline int native_window_set_post_transform_crop(
709 struct ANativeWindow* window,
710 android_native_rect_t const * crop)
711{
712 return window->perform(window, NATIVE_WINDOW_SET_POST_TRANSFORM_CROP, crop);
713}
714
715/*
Jamie Gennisfb1ee572012-04-17 19:37:48 -0700716 * native_window_set_active_rect(..., active_rect)
Jamie Gennisfb1ee572012-04-17 19:37:48 -0700717 *
Jamie Gennis22aec572012-06-13 16:43:06 -0700718 * This function is deprecated and will be removed soon. For now it simply
Jamie Gennisd21113a2012-05-03 14:21:24 -0700719 * sets the post-transform crop for compatibility while multi-project commits
720 * get checked.
Jamie Gennisfb1ee572012-04-17 19:37:48 -0700721 */
722static inline int native_window_set_active_rect(
723 struct ANativeWindow* window,
Mark Salyzyn289e1112014-05-23 12:31:42 -0700724 android_native_rect_t const * active_rect) __deprecated;
725
726static inline int native_window_set_active_rect(
727 struct ANativeWindow* window,
Jamie Gennisfb1ee572012-04-17 19:37:48 -0700728 android_native_rect_t const * active_rect)
729{
Jamie Gennisd21113a2012-05-03 14:21:24 -0700730 return native_window_set_post_transform_crop(window, active_rect);
Jamie Gennisfb1ee572012-04-17 19:37:48 -0700731}
732
733/*
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700734 * native_window_set_buffer_count(..., count)
735 * Sets the number of buffers associated with this native window.
736 */
737static inline int native_window_set_buffer_count(
738 struct ANativeWindow* window,
739 size_t bufferCount)
740{
741 return window->perform(window, NATIVE_WINDOW_SET_BUFFER_COUNT, bufferCount);
742}
743
744/*
745 * native_window_set_buffers_geometry(..., int w, int h, int format)
Jamie Gennis208ec5e2011-07-07 11:51:48 -0700746 * All buffers dequeued after this call will have the dimensions and format
747 * specified. A successful call to this function has the same effect as calling
748 * native_window_set_buffers_size and native_window_set_buffers_format.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700749 *
Jamie Gennis208ec5e2011-07-07 11:51:48 -0700750 * XXX: This function is deprecated. The native_window_set_buffers_dimensions
751 * and native_window_set_buffers_format functions should be used instead.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700752 */
753static inline int native_window_set_buffers_geometry(
754 struct ANativeWindow* window,
Mark Salyzyn289e1112014-05-23 12:31:42 -0700755 int w, int h, int format) __deprecated;
756
757static inline int native_window_set_buffers_geometry(
758 struct ANativeWindow* window,
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700759 int w, int h, int format)
760{
761 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_GEOMETRY,
762 w, h, format);
763}
764
765/*
Jamie Gennis208ec5e2011-07-07 11:51:48 -0700766 * native_window_set_buffers_dimensions(..., int w, int h)
767 * All buffers dequeued after this call will have the dimensions specified.
Michael I. Goldafcdef62012-04-09 18:21:13 -0700768 * In particular, all buffers will have a fixed-size, independent from the
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700769 * native-window size. They will be scaled according to the scaling mode
770 * (see native_window_set_scaling_mode) upon window composition.
Jamie Gennis208ec5e2011-07-07 11:51:48 -0700771 *
772 * If w and h are 0, the normal behavior is restored. That is, dequeued buffers
773 * following this call will be sized to match the window's size.
774 *
775 * Calling this function will reset the window crop to a NULL value, which
776 * disables cropping of the buffers.
777 */
778static inline int native_window_set_buffers_dimensions(
779 struct ANativeWindow* window,
780 int w, int h)
781{
782 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS,
783 w, h);
784}
785
786/*
Michael I. Goldafcdef62012-04-09 18:21:13 -0700787 * native_window_set_buffers_user_dimensions(..., int w, int h)
788 *
789 * Sets the user buffer size for the window, which overrides the
790 * window's size. All buffers dequeued after this call will have the
791 * dimensions specified unless overridden by
792 * native_window_set_buffers_dimensions. All buffers will have a
793 * fixed-size, independent from the native-window size. They will be
794 * scaled according to the scaling mode (see
795 * native_window_set_scaling_mode) upon window composition.
796 *
797 * If w and h are 0, the normal behavior is restored. That is, the
798 * default buffer size will match the windows's size.
799 *
800 * Calling this function will reset the window crop to a NULL value, which
801 * disables cropping of the buffers.
802 */
803static inline int native_window_set_buffers_user_dimensions(
804 struct ANativeWindow* window,
805 int w, int h)
806{
807 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS,
808 w, h);
809}
810
811/*
Jamie Gennis208ec5e2011-07-07 11:51:48 -0700812 * native_window_set_buffers_format(..., int format)
813 * All buffers dequeued after this call will have the format specified.
814 *
815 * If the specified format is 0, the default buffer format will be used.
816 */
817static inline int native_window_set_buffers_format(
818 struct ANativeWindow* window,
819 int format)
820{
821 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_FORMAT, format);
822}
823
824/*
Eino-Ville Talvalab93343d2015-02-17 15:34:44 -0800825 * native_window_set_buffers_data_space(..., int dataSpace)
826 * All buffers queued after this call will be associated with the dataSpace
827 * parameter specified.
828 *
829 * dataSpace specifies additional information about the buffer that's dependent
830 * on the buffer format and the endpoints. For example, it can be used to convey
831 * the color space of the image data in the buffer, or it can be used to
832 * indicate that the buffers contain depth measurement data instead of color
833 * images. The default dataSpace is 0, HAL_DATASPACE_UNKNOWN, unless it has been
834 * overridden by the consumer.
835 */
836static inline int native_window_set_buffers_data_space(
837 struct ANativeWindow* window,
838 android_dataspace_t dataSpace)
839{
840 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DATASPACE,
841 dataSpace);
842}
843
844/*
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700845 * native_window_set_buffers_transform(..., int transform)
846 * All buffers queued after this call will be displayed transformed according
847 * to the transform parameter specified.
848 */
849static inline int native_window_set_buffers_transform(
850 struct ANativeWindow* window,
851 int transform)
852{
853 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TRANSFORM,
854 transform);
855}
856
857/*
Ruben Brunka5e65d82014-06-27 16:15:18 -0700858 * native_window_set_buffers_sticky_transform(..., int transform)
859 * All buffers queued after this call will be displayed transformed according
860 * to the transform parameter specified applied on top of the regular buffer
861 * transform. Setting this transform will disable the transform hint.
862 *
863 * Temporary - This is only intended to be used by the LEGACY camera mode, do
864 * not use this for anything else.
865 */
866static inline int native_window_set_buffers_sticky_transform(
867 struct ANativeWindow* window,
868 int transform)
869{
870 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM,
871 transform);
872}
873
874/*
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700875 * native_window_set_buffers_timestamp(..., int64_t timestamp)
876 * All buffers queued after this call will be associated with the timestamp
877 * parameter specified. If the timestamp is set to NATIVE_WINDOW_TIMESTAMP_AUTO
878 * (the default), timestamps will be generated automatically when queueBuffer is
Glenn Kastenc322f672011-06-27 10:42:39 -0700879 * called. The timestamp is measured in nanoseconds, and is normally monotonically
880 * increasing. The timestamp should be unaffected by time-of-day adjustments,
881 * and for a camera should be strictly monotonic but for a media player may be
882 * reset when the position is set.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700883 */
884static inline int native_window_set_buffers_timestamp(
885 struct ANativeWindow* window,
886 int64_t timestamp)
887{
888 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP,
889 timestamp);
890}
891
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700892/*
893 * native_window_set_scaling_mode(..., int mode)
894 * All buffers queued after this call will be associated with the scaling mode
895 * specified.
896 */
897static inline int native_window_set_scaling_mode(
898 struct ANativeWindow* window,
899 int mode)
900{
901 return window->perform(window, NATIVE_WINDOW_SET_SCALING_MODE,
902 mode);
903}
904
Mathias Agopian8ad54522011-07-29 17:52:36 -0700905/*
906 * native_window_api_connect(..., int api)
907 * connects an API to this window. only one API can be connected at a time.
908 * Returns -EINVAL if for some reason the window cannot be connected, which
909 * can happen if it's connected to some other API.
910 */
911static inline int native_window_api_connect(
912 struct ANativeWindow* window, int api)
913{
Mathias Agopian319f4e22011-08-03 11:26:38 -0700914 return window->perform(window, NATIVE_WINDOW_API_CONNECT, api);
Mathias Agopian8ad54522011-07-29 17:52:36 -0700915}
916
917/*
918 * native_window_api_disconnect(..., int api)
919 * disconnect the API from this window.
920 * An error is returned if for instance the window wasn't connected in the
921 * first place.
922 */
923static inline int native_window_api_disconnect(
924 struct ANativeWindow* window, int api)
925{
Mathias Agopian319f4e22011-08-03 11:26:38 -0700926 return window->perform(window, NATIVE_WINDOW_API_DISCONNECT, api);
Mathias Agopian8ad54522011-07-29 17:52:36 -0700927}
928
Jamie Gennis22aec572012-06-13 16:43:06 -0700929/*
930 * native_window_dequeue_buffer_and_wait(...)
931 * Dequeue a buffer and wait on the fence associated with that buffer. The
932 * buffer may safely be accessed immediately upon this function returning. An
933 * error is returned if either of the dequeue or the wait operations fail.
934 */
935static inline int native_window_dequeue_buffer_and_wait(ANativeWindow *anw,
936 struct ANativeWindowBuffer** anb) {
Jesse Hallbc930ed2012-10-01 13:48:36 -0700937 return anw->dequeueBuffer_DEPRECATED(anw, anb);
Jamie Gennis22aec572012-06-13 16:43:06 -0700938}
939
Rachadd6d4c612014-07-29 18:03:21 -0700940/*
941 * native_window_set_sideband_stream(..., native_handle_t*)
942 * Attach a sideband buffer stream to a native window.
943 */
944static inline int native_window_set_sideband_stream(
945 struct ANativeWindow* window,
946 native_handle_t* sidebandHandle)
947{
948 return window->perform(window, NATIVE_WINDOW_SET_SIDEBAND_STREAM,
949 sidebandHandle);
950}
Mathias Agopian8ad54522011-07-29 17:52:36 -0700951
Dan Stoza238ec982015-03-23 10:43:14 -0700952/*
953 * native_window_set_surface_damage(..., android_native_rect_t* rects, int numRects)
954 * Set the surface damage (i.e., the region of the surface that has changed
955 * since the previous frame). The damage set by this call will be reset (to the
956 * default of full-surface damage) after calling queue, so this must be called
957 * prior to every frame with damage that does not cover the whole surface if the
958 * caller desires downstream consumers to use this optimization.
959 *
960 * The damage region is specified as an array of rectangles, with the important
961 * caveat that the origin of the surface is considered to be the bottom-left
962 * corner, as in OpenGL ES.
963 *
964 * If numRects is set to 0, rects may be NULL, and the surface damage will be
965 * set to the full surface (the same as if this function had not been called for
966 * this frame).
967 */
968static inline int native_window_set_surface_damage(
969 struct ANativeWindow* window,
970 const android_native_rect_t* rects, size_t numRects)
971{
972 return window->perform(window, NATIVE_WINDOW_SET_SURFACE_DAMAGE,
973 rects, numRects);
974}
975
Pablo Ceballos923d27f2015-10-19 10:24:42 -0700976/*
Pablo Ceballos248e7712016-03-17 15:42:21 -0700977 * native_window_set_shared_buffer_mode(..., bool sharedBufferMode)
978 * Enable/disable shared buffer mode
Pablo Ceballos923d27f2015-10-19 10:24:42 -0700979 */
Pablo Ceballos248e7712016-03-17 15:42:21 -0700980static inline int native_window_set_shared_buffer_mode(
Pablo Ceballos923d27f2015-10-19 10:24:42 -0700981 struct ANativeWindow* window,
Pablo Ceballos248e7712016-03-17 15:42:21 -0700982 bool sharedBufferMode)
Pablo Ceballos923d27f2015-10-19 10:24:42 -0700983{
Pablo Ceballos248e7712016-03-17 15:42:21 -0700984 return window->perform(window, NATIVE_WINDOW_SET_SHARED_BUFFER_MODE,
985 sharedBufferMode);
Pablo Ceballos923d27f2015-10-19 10:24:42 -0700986}
987
Pablo Ceballos3daa5742016-01-15 13:31:14 -0800988/*
989 * native_window_set_auto_refresh(..., autoRefresh)
Pablo Ceballos248e7712016-03-17 15:42:21 -0700990 * Enable/disable auto refresh when in shared buffer mode
Pablo Ceballos3daa5742016-01-15 13:31:14 -0800991 */
992static inline int native_window_set_auto_refresh(
993 struct ANativeWindow* window,
994 bool autoRefresh)
995{
996 return window->perform(window, NATIVE_WINDOW_SET_AUTO_REFRESH, autoRefresh);
997}
998
Pablo Ceballosc2efc322016-05-31 11:06:03 -0700999static inline int native_window_get_frame_timestamps(
1000 struct ANativeWindow* window, uint32_t framesAgo,
1001 int64_t* outPostedTime, int64_t* outAcquireTime,
1002 int64_t* outRefreshStartTime, int64_t* outGlCompositionDoneTime,
1003 int64_t* outDisplayRetireTime, int64_t* outReleaseTime)
1004{
1005 return window->perform(window, NATIVE_WINDOW_GET_FRAME_TIMESTAMPS,
1006 framesAgo, outPostedTime, outAcquireTime, outRefreshStartTime,
1007 outGlCompositionDoneTime, outDisplayRetireTime, outReleaseTime);
1008}
1009
1010
Iliyan Malchev0ab886b2011-05-01 14:07:43 -07001011__END_DECLS
1012
tedbo1ffdb382011-05-24 00:55:33 -07001013#endif /* SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H */