blob: 49ab4dc94f5c1b870d3621d98f4e79a0a15c6d23 [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,
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700290};
291
Jamie Gennisfb1ee572012-04-17 19:37:48 -0700292/* Valid operations for the (*perform)() hook.
293 *
294 * Values marked as 'deprecated' are supported, but have been superceded by
295 * other functionality.
296 *
297 * Values marked as 'private' should be considered private to the framework.
298 * HAL implementation code with access to an ANativeWindow should not use these,
299 * as it may not interact properly with the framework's use of the
300 * ANativeWindow.
301 */
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700302enum {
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700303 NATIVE_WINDOW_SET_USAGE = 0,
Mathias Agopian8ad54522011-07-29 17:52:36 -0700304 NATIVE_WINDOW_CONNECT = 1, /* deprecated */
305 NATIVE_WINDOW_DISCONNECT = 2, /* deprecated */
Jamie Gennisfb1ee572012-04-17 19:37:48 -0700306 NATIVE_WINDOW_SET_CROP = 3, /* private */
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700307 NATIVE_WINDOW_SET_BUFFER_COUNT = 4,
308 NATIVE_WINDOW_SET_BUFFERS_GEOMETRY = 5, /* deprecated */
309 NATIVE_WINDOW_SET_BUFFERS_TRANSFORM = 6,
310 NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP = 7,
311 NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS = 8,
312 NATIVE_WINDOW_SET_BUFFERS_FORMAT = 9,
Jamie Gennisfb1ee572012-04-17 19:37:48 -0700313 NATIVE_WINDOW_SET_SCALING_MODE = 10, /* private */
Mathias Agopianae3736a2011-07-13 18:40:38 -0700314 NATIVE_WINDOW_LOCK = 11, /* private */
315 NATIVE_WINDOW_UNLOCK_AND_POST = 12, /* private */
Mathias Agopian8ad54522011-07-29 17:52:36 -0700316 NATIVE_WINDOW_API_CONNECT = 13, /* private */
317 NATIVE_WINDOW_API_DISCONNECT = 14, /* private */
Michael I. Goldafcdef62012-04-09 18:21:13 -0700318 NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS = 15, /* private */
Jamie Gennisd21113a2012-05-03 14:21:24 -0700319 NATIVE_WINDOW_SET_POST_TRANSFORM_CROP = 16, /* private */
Ruben Brunka5e65d82014-06-27 16:15:18 -0700320 NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM = 17,/* private */
Rachadd6d4c612014-07-29 18:03:21 -0700321 NATIVE_WINDOW_SET_SIDEBAND_STREAM = 18,
Dan Stoza238ec982015-03-23 10:43:14 -0700322 NATIVE_WINDOW_SET_BUFFERS_DATASPACE = 19,
323 NATIVE_WINDOW_SET_SURFACE_DAMAGE = 20, /* private */
Pablo Ceballos248e7712016-03-17 15:42:21 -0700324 NATIVE_WINDOW_SET_SHARED_BUFFER_MODE = 21,
Pablo Ceballos3daa5742016-01-15 13:31:14 -0800325 NATIVE_WINDOW_SET_AUTO_REFRESH = 22,
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700326};
327
Mathias Agopian8ad54522011-07-29 17:52:36 -0700328/* parameter for NATIVE_WINDOW_[API_][DIS]CONNECT */
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700329enum {
Jamie Gennis5423e9e2011-07-12 13:53:42 -0700330 /* Buffers will be queued by EGL via eglSwapBuffers after being filled using
331 * OpenGL ES.
332 */
333 NATIVE_WINDOW_API_EGL = 1,
334
335 /* Buffers will be queued after being filled using the CPU
336 */
337 NATIVE_WINDOW_API_CPU = 2,
338
339 /* Buffers will be queued by Stagefright after being filled by a video
340 * decoder. The video decoder can either be a software or hardware decoder.
341 */
342 NATIVE_WINDOW_API_MEDIA = 3,
343
344 /* Buffers will be queued by the the camera HAL.
345 */
346 NATIVE_WINDOW_API_CAMERA = 4,
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700347};
348
349/* parameter for NATIVE_WINDOW_SET_BUFFERS_TRANSFORM */
350enum {
351 /* flip source image horizontally */
352 NATIVE_WINDOW_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H ,
353 /* flip source image vertically */
354 NATIVE_WINDOW_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V,
Mathias Agopian96675ed2013-09-17 23:48:54 -0700355 /* rotate source image 90 degrees clock-wise, and is applied after TRANSFORM_FLIP_{H|V} */
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700356 NATIVE_WINDOW_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90,
357 /* rotate source image 180 degrees */
358 NATIVE_WINDOW_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180,
359 /* rotate source image 270 degrees clock-wise */
360 NATIVE_WINDOW_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270,
Mathias Agopian96675ed2013-09-17 23:48:54 -0700361 /* transforms source by the inverse transform of the screen it is displayed onto. This
362 * transform is applied last */
363 NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY = 0x08
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700364};
365
Robert Carrf3954fb2015-12-17 11:31:11 -0800366/* parameter for NATIVE_WINDOW_SET_SCALING_MODE
367 * keep in sync with Surface.java in frameworks/base */
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700368enum {
369 /* the window content is not updated (frozen) until a buffer of
370 * the window size is received (enqueued)
371 */
372 NATIVE_WINDOW_SCALING_MODE_FREEZE = 0,
373 /* the buffer is scaled in both dimensions to match the window size */
374 NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW = 1,
Daniel Lam29392a42012-04-11 18:19:46 -0700375 /* the buffer is scaled uniformly such that the smaller dimension
376 * of the buffer matches the window size (cropping in the process)
377 */
378 NATIVE_WINDOW_SCALING_MODE_SCALE_CROP = 2,
Jamie Gennisd21113a2012-05-03 14:21:24 -0700379 /* the window is clipped to the size of the buffer's crop rectangle; pixels
380 * outside the crop rectangle are treated as if they are completely
381 * transparent.
382 */
383 NATIVE_WINDOW_SCALING_MODE_NO_SCALE_CROP = 3,
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700384};
385
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700386/* values returned by the NATIVE_WINDOW_CONCRETE_TYPE query */
387enum {
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700388 NATIVE_WINDOW_FRAMEBUFFER = 0, /* FramebufferNativeWindow */
389 NATIVE_WINDOW_SURFACE = 1, /* Surface */
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700390};
391
392/* parameter for NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP
393 *
394 * Special timestamp value to indicate that timestamps should be auto-generated
395 * by the native window when queueBuffer is called. This is equal to INT64_MIN,
396 * defined directly to avoid problems with C99/C++ inclusion of stdint.h.
397 */
398static const int64_t NATIVE_WINDOW_TIMESTAMP_AUTO = (-9223372036854775807LL-1);
399
400struct ANativeWindow
401{
402#ifdef __cplusplus
403 ANativeWindow()
404 : flags(0), minSwapInterval(0), maxSwapInterval(0), xdpi(0), ydpi(0)
405 {
406 common.magic = ANDROID_NATIVE_WINDOW_MAGIC;
407 common.version = sizeof(ANativeWindow);
408 memset(common.reserved, 0, sizeof(common.reserved));
409 }
410
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700411 /* Implement the methods that sp<ANativeWindow> expects so that it
412 can be used to automatically refcount ANativeWindow's. */
Mark Salyzyn48878422014-05-22 16:08:52 -0700413 void incStrong(const void* /*id*/) const {
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700414 common.incRef(const_cast<android_native_base_t*>(&common));
415 }
Mark Salyzyn48878422014-05-22 16:08:52 -0700416 void decStrong(const void* /*id*/) const {
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700417 common.decRef(const_cast<android_native_base_t*>(&common));
418 }
419#endif
420
421 struct android_native_base_t common;
422
423 /* flags describing some attributes of this surface or its updater */
424 const uint32_t flags;
425
426 /* min swap interval supported by this updated */
427 const int minSwapInterval;
428
429 /* max swap interval supported by this updated */
430 const int maxSwapInterval;
431
432 /* horizontal and vertical resolution in DPI */
433 const float xdpi;
434 const float ydpi;
435
436 /* Some storage reserved for the OEM's driver. */
437 intptr_t oem[4];
438
439 /*
440 * Set the swap interval for this surface.
441 *
442 * Returns 0 on success or -errno on error.
443 */
444 int (*setSwapInterval)(struct ANativeWindow* window,
445 int interval);
446
447 /*
Jesse Hall7cd3e0a2011-12-12 10:32:55 -0800448 * Hook called by EGL to acquire a buffer. After this call, the buffer
449 * is not locked, so its content cannot be modified. This call may block if
450 * no buffers are available.
451 *
452 * The window holds a reference to the buffer between dequeueBuffer and
453 * either queueBuffer or cancelBuffer, so clients only need their own
454 * reference if they might use the buffer after queueing or canceling it.
455 * Holding a reference to a buffer after queueing or canceling it is only
456 * allowed if a specific buffer count has been set.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700457 *
458 * Returns 0 on success or -errno on error.
Jamie Gennis22aec572012-06-13 16:43:06 -0700459 *
460 * XXX: This function is deprecated. It will continue to work for some
461 * time for binary compatibility, but the new dequeueBuffer function that
462 * outputs a fence file descriptor should be used in its place.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700463 */
Jamie Gennis22aec572012-06-13 16:43:06 -0700464 int (*dequeueBuffer_DEPRECATED)(struct ANativeWindow* window,
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700465 struct ANativeWindowBuffer** buffer);
466
467 /*
468 * hook called by EGL to lock a buffer. This MUST be called before modifying
469 * the content of a buffer. The buffer must have been acquired with
470 * dequeueBuffer first.
471 *
472 * Returns 0 on success or -errno on error.
Jamie Gennis22aec572012-06-13 16:43:06 -0700473 *
474 * XXX: This function is deprecated. It will continue to work for some
475 * time for binary compatibility, but it is essentially a no-op, and calls
476 * to it should be removed.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700477 */
Jamie Gennis22aec572012-06-13 16:43:06 -0700478 int (*lockBuffer_DEPRECATED)(struct ANativeWindow* window,
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700479 struct ANativeWindowBuffer* buffer);
Jamie Gennis22aec572012-06-13 16:43:06 -0700480
Jesse Hall7cd3e0a2011-12-12 10:32:55 -0800481 /*
482 * Hook called by EGL when modifications to the render buffer are done.
483 * This unlocks and post the buffer.
484 *
485 * The window holds a reference to the buffer between dequeueBuffer and
486 * either queueBuffer or cancelBuffer, so clients only need their own
487 * reference if they might use the buffer after queueing or canceling it.
488 * Holding a reference to a buffer after queueing or canceling it is only
489 * allowed if a specific buffer count has been set.
490 *
491 * Buffers MUST be queued in the same order than they were dequeued.
492 *
493 * Returns 0 on success or -errno on error.
Jamie Gennis22aec572012-06-13 16:43:06 -0700494 *
495 * XXX: This function is deprecated. It will continue to work for some
496 * time for binary compatibility, but the new queueBuffer function that
497 * takes a fence file descriptor should be used in its place (pass a value
498 * of -1 for the fence file descriptor if there is no valid one to pass).
Jesse Hall7cd3e0a2011-12-12 10:32:55 -0800499 */
Jamie Gennis22aec572012-06-13 16:43:06 -0700500 int (*queueBuffer_DEPRECATED)(struct ANativeWindow* window,
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700501 struct ANativeWindowBuffer* buffer);
502
503 /*
504 * hook used to retrieve information about the native window.
505 *
506 * Returns 0 on success or -errno on error.
507 */
508 int (*query)(const struct ANativeWindow* window,
509 int what, int* value);
510
511 /*
512 * hook used to perform various operations on the surface.
513 * (*perform)() is a generic mechanism to add functionality to
514 * ANativeWindow while keeping backward binary compatibility.
515 *
516 * DO NOT CALL THIS HOOK DIRECTLY. Instead, use the helper functions
517 * defined below.
518 *
Dan Stoza238ec982015-03-23 10:43:14 -0700519 * (*perform)() returns -ENOENT if the 'what' parameter is not supported
520 * by the surface's implementation.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700521 *
Dan Stoza238ec982015-03-23 10:43:14 -0700522 * See above for a list of valid operations, such as
523 * NATIVE_WINDOW_SET_USAGE or NATIVE_WINDOW_CONNECT
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700524 */
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700525 int (*perform)(struct ANativeWindow* window,
526 int operation, ... );
527
528 /*
Jesse Hall7cd3e0a2011-12-12 10:32:55 -0800529 * Hook used to cancel a buffer that has been dequeued.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700530 * No synchronization is performed between dequeue() and cancel(), so
531 * either external synchronization is needed, or these functions must be
532 * called from the same thread.
Jesse Hall7cd3e0a2011-12-12 10:32:55 -0800533 *
534 * The window holds a reference to the buffer between dequeueBuffer and
535 * either queueBuffer or cancelBuffer, so clients only need their own
536 * reference if they might use the buffer after queueing or canceling it.
537 * Holding a reference to a buffer after queueing or canceling it is only
538 * allowed if a specific buffer count has been set.
Jamie Gennis22aec572012-06-13 16:43:06 -0700539 *
540 * XXX: This function is deprecated. It will continue to work for some
541 * time for binary compatibility, but the new cancelBuffer function that
542 * takes a fence file descriptor should be used in its place (pass a value
543 * of -1 for the fence file descriptor if there is no valid one to pass).
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700544 */
Jamie Gennis22aec572012-06-13 16:43:06 -0700545 int (*cancelBuffer_DEPRECATED)(struct ANativeWindow* window,
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700546 struct ANativeWindowBuffer* buffer);
547
Jamie Gennis22aec572012-06-13 16:43:06 -0700548 /*
549 * Hook called by EGL to acquire a buffer. This call may block if no
550 * buffers are available.
551 *
552 * The window holds a reference to the buffer between dequeueBuffer and
553 * either queueBuffer or cancelBuffer, so clients only need their own
554 * reference if they might use the buffer after queueing or canceling it.
555 * Holding a reference to a buffer after queueing or canceling it is only
556 * allowed if a specific buffer count has been set.
557 *
558 * The libsync fence file descriptor returned in the int pointed to by the
559 * fenceFd argument will refer to the fence that must signal before the
560 * dequeued buffer may be written to. A value of -1 indicates that the
561 * caller may access the buffer immediately without waiting on a fence. If
562 * a valid file descriptor is returned (i.e. any value except -1) then the
563 * caller is responsible for closing the file descriptor.
564 *
565 * Returns 0 on success or -errno on error.
566 */
567 int (*dequeueBuffer)(struct ANativeWindow* window,
568 struct ANativeWindowBuffer** buffer, int* fenceFd);
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700569
Jamie Gennis22aec572012-06-13 16:43:06 -0700570 /*
571 * Hook called by EGL when modifications to the render buffer are done.
572 * This unlocks and post the buffer.
573 *
574 * The window holds a reference to the buffer between dequeueBuffer and
575 * either queueBuffer or cancelBuffer, so clients only need their own
576 * reference if they might use the buffer after queueing or canceling it.
577 * Holding a reference to a buffer after queueing or canceling it is only
578 * allowed if a specific buffer count has been set.
579 *
580 * The fenceFd argument specifies a libsync fence file descriptor for a
581 * fence that must signal before the buffer can be accessed. If the buffer
582 * can be accessed immediately then a value of -1 should be used. The
583 * caller must not use the file descriptor after it is passed to
584 * queueBuffer, and the ANativeWindow implementation is responsible for
585 * closing it.
586 *
587 * Returns 0 on success or -errno on error.
588 */
589 int (*queueBuffer)(struct ANativeWindow* window,
590 struct ANativeWindowBuffer* buffer, int fenceFd);
591
592 /*
593 * Hook used to cancel a buffer that has been dequeued.
594 * No synchronization is performed between dequeue() and cancel(), so
595 * either external synchronization is needed, or these functions must be
596 * called from the same thread.
597 *
598 * The window holds a reference to the buffer between dequeueBuffer and
599 * either queueBuffer or cancelBuffer, so clients only need their own
600 * reference if they might use the buffer after queueing or canceling it.
601 * Holding a reference to a buffer after queueing or canceling it is only
602 * allowed if a specific buffer count has been set.
603 *
604 * The fenceFd argument specifies a libsync fence file decsriptor for a
605 * fence that must signal before the buffer can be accessed. If the buffer
606 * can be accessed immediately then a value of -1 should be used.
607 *
608 * Note that if the client has not waited on the fence that was returned
609 * from dequeueBuffer, that same fence should be passed to cancelBuffer to
610 * ensure that future uses of the buffer are preceded by a wait on that
611 * fence. The caller must not use the file descriptor after it is passed
612 * to cancelBuffer, and the ANativeWindow implementation is responsible for
613 * closing it.
614 *
615 * Returns 0 on success or -errno on error.
616 */
617 int (*cancelBuffer)(struct ANativeWindow* window,
618 struct ANativeWindowBuffer* buffer, int fenceFd);
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700619};
620
621 /* Backwards compatibility: use ANativeWindow (struct ANativeWindow in C).
622 * android_native_window_t is deprecated.
623 */
624typedef struct ANativeWindow ANativeWindow;
Mark Salyzyn289e1112014-05-23 12:31:42 -0700625typedef struct ANativeWindow android_native_window_t __deprecated;
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700626
627/*
628 * native_window_set_usage(..., usage)
629 * Sets the intended usage flags for the next buffers
630 * acquired with (*lockBuffer)() and on.
631 * By default (if this function is never called), a usage of
632 * GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE
633 * is assumed.
634 * Calling this function will usually cause following buffers to be
635 * reallocated.
636 */
637
638static inline int native_window_set_usage(
639 struct ANativeWindow* window, int usage)
640{
641 return window->perform(window, NATIVE_WINDOW_SET_USAGE, usage);
642}
643
Mathias Agopian8ad54522011-07-29 17:52:36 -0700644/* deprecated. Always returns 0. Don't call. */
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700645static inline int native_window_connect(
Ian Rogersde8b9832014-06-27 16:38:01 -0700646 struct ANativeWindow* window __UNUSED, int api __UNUSED) __deprecated;
Mark Salyzyn289e1112014-05-23 12:31:42 -0700647
648static inline int native_window_connect(
Ian Rogersde8b9832014-06-27 16:38:01 -0700649 struct ANativeWindow* window __UNUSED, int api __UNUSED) {
Mathias Agopian319f4e22011-08-03 11:26:38 -0700650 return 0;
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700651}
652
Mathias Agopian8ad54522011-07-29 17:52:36 -0700653/* deprecated. Always returns 0. Don't call. */
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700654static inline int native_window_disconnect(
Ian Rogersde8b9832014-06-27 16:38:01 -0700655 struct ANativeWindow* window __UNUSED, int api __UNUSED) __deprecated;
Mark Salyzyn289e1112014-05-23 12:31:42 -0700656
657static inline int native_window_disconnect(
Ian Rogersde8b9832014-06-27 16:38:01 -0700658 struct ANativeWindow* window __UNUSED, int api __UNUSED) {
Mathias Agopian319f4e22011-08-03 11:26:38 -0700659 return 0;
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700660}
661
662/*
663 * native_window_set_crop(..., crop)
664 * Sets which region of the next queued buffers needs to be considered.
Jamie Gennisd21113a2012-05-03 14:21:24 -0700665 * Depending on the scaling mode, a buffer's crop region is scaled and/or
666 * cropped to match the surface's size. This function sets the crop in
667 * pre-transformed buffer pixel coordinates.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700668 *
669 * The specified crop region applies to all buffers queued after it is called.
670 *
Jamie Gennisd21113a2012-05-03 14:21:24 -0700671 * If 'crop' is NULL, subsequently queued buffers won't be cropped.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700672 *
Jamie Gennisd21113a2012-05-03 14:21:24 -0700673 * An error is returned if for instance the crop region is invalid, out of the
674 * buffer's bound or if the window is invalid.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700675 */
676static inline int native_window_set_crop(
677 struct ANativeWindow* window,
678 android_native_rect_t const * crop)
679{
680 return window->perform(window, NATIVE_WINDOW_SET_CROP, crop);
681}
682
683/*
Jamie Gennisd21113a2012-05-03 14:21:24 -0700684 * native_window_set_post_transform_crop(..., crop)
685 * Sets which region of the next queued buffers needs to be considered.
686 * Depending on the scaling mode, a buffer's crop region is scaled and/or
687 * cropped to match the surface's size. This function sets the crop in
688 * post-transformed pixel coordinates.
689 *
690 * The specified crop region applies to all buffers queued after it is called.
691 *
692 * If 'crop' is NULL, subsequently queued buffers won't be cropped.
693 *
694 * An error is returned if for instance the crop region is invalid, out of the
695 * buffer's bound or if the window is invalid.
696 */
697static inline int native_window_set_post_transform_crop(
698 struct ANativeWindow* window,
699 android_native_rect_t const * crop)
700{
701 return window->perform(window, NATIVE_WINDOW_SET_POST_TRANSFORM_CROP, crop);
702}
703
704/*
Jamie Gennisfb1ee572012-04-17 19:37:48 -0700705 * native_window_set_active_rect(..., active_rect)
Jamie Gennisfb1ee572012-04-17 19:37:48 -0700706 *
Jamie Gennis22aec572012-06-13 16:43:06 -0700707 * This function is deprecated and will be removed soon. For now it simply
Jamie Gennisd21113a2012-05-03 14:21:24 -0700708 * sets the post-transform crop for compatibility while multi-project commits
709 * get checked.
Jamie Gennisfb1ee572012-04-17 19:37:48 -0700710 */
711static inline int native_window_set_active_rect(
712 struct ANativeWindow* window,
Mark Salyzyn289e1112014-05-23 12:31:42 -0700713 android_native_rect_t const * active_rect) __deprecated;
714
715static inline int native_window_set_active_rect(
716 struct ANativeWindow* window,
Jamie Gennisfb1ee572012-04-17 19:37:48 -0700717 android_native_rect_t const * active_rect)
718{
Jamie Gennisd21113a2012-05-03 14:21:24 -0700719 return native_window_set_post_transform_crop(window, active_rect);
Jamie Gennisfb1ee572012-04-17 19:37:48 -0700720}
721
722/*
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700723 * native_window_set_buffer_count(..., count)
724 * Sets the number of buffers associated with this native window.
725 */
726static inline int native_window_set_buffer_count(
727 struct ANativeWindow* window,
728 size_t bufferCount)
729{
730 return window->perform(window, NATIVE_WINDOW_SET_BUFFER_COUNT, bufferCount);
731}
732
733/*
734 * native_window_set_buffers_geometry(..., int w, int h, int format)
Jamie Gennis208ec5e2011-07-07 11:51:48 -0700735 * All buffers dequeued after this call will have the dimensions and format
736 * specified. A successful call to this function has the same effect as calling
737 * native_window_set_buffers_size and native_window_set_buffers_format.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700738 *
Jamie Gennis208ec5e2011-07-07 11:51:48 -0700739 * XXX: This function is deprecated. The native_window_set_buffers_dimensions
740 * and native_window_set_buffers_format functions should be used instead.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700741 */
742static inline int native_window_set_buffers_geometry(
743 struct ANativeWindow* window,
Mark Salyzyn289e1112014-05-23 12:31:42 -0700744 int w, int h, int format) __deprecated;
745
746static inline int native_window_set_buffers_geometry(
747 struct ANativeWindow* window,
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700748 int w, int h, int format)
749{
750 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_GEOMETRY,
751 w, h, format);
752}
753
754/*
Jamie Gennis208ec5e2011-07-07 11:51:48 -0700755 * native_window_set_buffers_dimensions(..., int w, int h)
756 * All buffers dequeued after this call will have the dimensions specified.
Michael I. Goldafcdef62012-04-09 18:21:13 -0700757 * In particular, all buffers will have a fixed-size, independent from the
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700758 * native-window size. They will be scaled according to the scaling mode
759 * (see native_window_set_scaling_mode) upon window composition.
Jamie Gennis208ec5e2011-07-07 11:51:48 -0700760 *
761 * If w and h are 0, the normal behavior is restored. That is, dequeued buffers
762 * following this call will be sized to match the window's size.
763 *
764 * Calling this function will reset the window crop to a NULL value, which
765 * disables cropping of the buffers.
766 */
767static inline int native_window_set_buffers_dimensions(
768 struct ANativeWindow* window,
769 int w, int h)
770{
771 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS,
772 w, h);
773}
774
775/*
Michael I. Goldafcdef62012-04-09 18:21:13 -0700776 * native_window_set_buffers_user_dimensions(..., int w, int h)
777 *
778 * Sets the user buffer size for the window, which overrides the
779 * window's size. All buffers dequeued after this call will have the
780 * dimensions specified unless overridden by
781 * native_window_set_buffers_dimensions. All buffers will have a
782 * fixed-size, independent from the native-window size. They will be
783 * scaled according to the scaling mode (see
784 * native_window_set_scaling_mode) upon window composition.
785 *
786 * If w and h are 0, the normal behavior is restored. That is, the
787 * default buffer size will match the windows's size.
788 *
789 * Calling this function will reset the window crop to a NULL value, which
790 * disables cropping of the buffers.
791 */
792static inline int native_window_set_buffers_user_dimensions(
793 struct ANativeWindow* window,
794 int w, int h)
795{
796 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS,
797 w, h);
798}
799
800/*
Jamie Gennis208ec5e2011-07-07 11:51:48 -0700801 * native_window_set_buffers_format(..., int format)
802 * All buffers dequeued after this call will have the format specified.
803 *
804 * If the specified format is 0, the default buffer format will be used.
805 */
806static inline int native_window_set_buffers_format(
807 struct ANativeWindow* window,
808 int format)
809{
810 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_FORMAT, format);
811}
812
813/*
Eino-Ville Talvalab93343d2015-02-17 15:34:44 -0800814 * native_window_set_buffers_data_space(..., int dataSpace)
815 * All buffers queued after this call will be associated with the dataSpace
816 * parameter specified.
817 *
818 * dataSpace specifies additional information about the buffer that's dependent
819 * on the buffer format and the endpoints. For example, it can be used to convey
820 * the color space of the image data in the buffer, or it can be used to
821 * indicate that the buffers contain depth measurement data instead of color
822 * images. The default dataSpace is 0, HAL_DATASPACE_UNKNOWN, unless it has been
823 * overridden by the consumer.
824 */
825static inline int native_window_set_buffers_data_space(
826 struct ANativeWindow* window,
827 android_dataspace_t dataSpace)
828{
829 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DATASPACE,
830 dataSpace);
831}
832
833/*
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700834 * native_window_set_buffers_transform(..., int transform)
835 * All buffers queued after this call will be displayed transformed according
836 * to the transform parameter specified.
837 */
838static inline int native_window_set_buffers_transform(
839 struct ANativeWindow* window,
840 int transform)
841{
842 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TRANSFORM,
843 transform);
844}
845
846/*
Ruben Brunka5e65d82014-06-27 16:15:18 -0700847 * native_window_set_buffers_sticky_transform(..., int transform)
848 * All buffers queued after this call will be displayed transformed according
849 * to the transform parameter specified applied on top of the regular buffer
850 * transform. Setting this transform will disable the transform hint.
851 *
852 * Temporary - This is only intended to be used by the LEGACY camera mode, do
853 * not use this for anything else.
854 */
855static inline int native_window_set_buffers_sticky_transform(
856 struct ANativeWindow* window,
857 int transform)
858{
859 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM,
860 transform);
861}
862
863/*
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700864 * native_window_set_buffers_timestamp(..., int64_t timestamp)
865 * All buffers queued after this call will be associated with the timestamp
866 * parameter specified. If the timestamp is set to NATIVE_WINDOW_TIMESTAMP_AUTO
867 * (the default), timestamps will be generated automatically when queueBuffer is
Glenn Kastenc322f672011-06-27 10:42:39 -0700868 * called. The timestamp is measured in nanoseconds, and is normally monotonically
869 * increasing. The timestamp should be unaffected by time-of-day adjustments,
870 * and for a camera should be strictly monotonic but for a media player may be
871 * reset when the position is set.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700872 */
873static inline int native_window_set_buffers_timestamp(
874 struct ANativeWindow* window,
875 int64_t timestamp)
876{
877 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP,
878 timestamp);
879}
880
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700881/*
882 * native_window_set_scaling_mode(..., int mode)
883 * All buffers queued after this call will be associated with the scaling mode
884 * specified.
885 */
886static inline int native_window_set_scaling_mode(
887 struct ANativeWindow* window,
888 int mode)
889{
890 return window->perform(window, NATIVE_WINDOW_SET_SCALING_MODE,
891 mode);
892}
893
Mathias Agopian8ad54522011-07-29 17:52:36 -0700894/*
895 * native_window_api_connect(..., int api)
896 * connects an API to this window. only one API can be connected at a time.
897 * Returns -EINVAL if for some reason the window cannot be connected, which
898 * can happen if it's connected to some other API.
899 */
900static inline int native_window_api_connect(
901 struct ANativeWindow* window, int api)
902{
Mathias Agopian319f4e22011-08-03 11:26:38 -0700903 return window->perform(window, NATIVE_WINDOW_API_CONNECT, api);
Mathias Agopian8ad54522011-07-29 17:52:36 -0700904}
905
906/*
907 * native_window_api_disconnect(..., int api)
908 * disconnect the API from this window.
909 * An error is returned if for instance the window wasn't connected in the
910 * first place.
911 */
912static inline int native_window_api_disconnect(
913 struct ANativeWindow* window, int api)
914{
Mathias Agopian319f4e22011-08-03 11:26:38 -0700915 return window->perform(window, NATIVE_WINDOW_API_DISCONNECT, api);
Mathias Agopian8ad54522011-07-29 17:52:36 -0700916}
917
Jamie Gennis22aec572012-06-13 16:43:06 -0700918/*
919 * native_window_dequeue_buffer_and_wait(...)
920 * Dequeue a buffer and wait on the fence associated with that buffer. The
921 * buffer may safely be accessed immediately upon this function returning. An
922 * error is returned if either of the dequeue or the wait operations fail.
923 */
924static inline int native_window_dequeue_buffer_and_wait(ANativeWindow *anw,
925 struct ANativeWindowBuffer** anb) {
Jesse Hallbc930ed2012-10-01 13:48:36 -0700926 return anw->dequeueBuffer_DEPRECATED(anw, anb);
Jamie Gennis22aec572012-06-13 16:43:06 -0700927}
928
Rachadd6d4c612014-07-29 18:03:21 -0700929/*
930 * native_window_set_sideband_stream(..., native_handle_t*)
931 * Attach a sideband buffer stream to a native window.
932 */
933static inline int native_window_set_sideband_stream(
934 struct ANativeWindow* window,
935 native_handle_t* sidebandHandle)
936{
937 return window->perform(window, NATIVE_WINDOW_SET_SIDEBAND_STREAM,
938 sidebandHandle);
939}
Mathias Agopian8ad54522011-07-29 17:52:36 -0700940
Dan Stoza238ec982015-03-23 10:43:14 -0700941/*
942 * native_window_set_surface_damage(..., android_native_rect_t* rects, int numRects)
943 * Set the surface damage (i.e., the region of the surface that has changed
944 * since the previous frame). The damage set by this call will be reset (to the
945 * default of full-surface damage) after calling queue, so this must be called
946 * prior to every frame with damage that does not cover the whole surface if the
947 * caller desires downstream consumers to use this optimization.
948 *
949 * The damage region is specified as an array of rectangles, with the important
950 * caveat that the origin of the surface is considered to be the bottom-left
951 * corner, as in OpenGL ES.
952 *
953 * If numRects is set to 0, rects may be NULL, and the surface damage will be
954 * set to the full surface (the same as if this function had not been called for
955 * this frame).
956 */
957static inline int native_window_set_surface_damage(
958 struct ANativeWindow* window,
959 const android_native_rect_t* rects, size_t numRects)
960{
961 return window->perform(window, NATIVE_WINDOW_SET_SURFACE_DAMAGE,
962 rects, numRects);
963}
964
Pablo Ceballos923d27f2015-10-19 10:24:42 -0700965/*
Pablo Ceballos248e7712016-03-17 15:42:21 -0700966 * native_window_set_shared_buffer_mode(..., bool sharedBufferMode)
967 * Enable/disable shared buffer mode
Pablo Ceballos923d27f2015-10-19 10:24:42 -0700968 */
Pablo Ceballos248e7712016-03-17 15:42:21 -0700969static inline int native_window_set_shared_buffer_mode(
Pablo Ceballos923d27f2015-10-19 10:24:42 -0700970 struct ANativeWindow* window,
Pablo Ceballos248e7712016-03-17 15:42:21 -0700971 bool sharedBufferMode)
Pablo Ceballos923d27f2015-10-19 10:24:42 -0700972{
Pablo Ceballos248e7712016-03-17 15:42:21 -0700973 return window->perform(window, NATIVE_WINDOW_SET_SHARED_BUFFER_MODE,
974 sharedBufferMode);
Pablo Ceballos923d27f2015-10-19 10:24:42 -0700975}
976
Pablo Ceballos3daa5742016-01-15 13:31:14 -0800977/*
978 * native_window_set_auto_refresh(..., autoRefresh)
Pablo Ceballos248e7712016-03-17 15:42:21 -0700979 * Enable/disable auto refresh when in shared buffer mode
Pablo Ceballos3daa5742016-01-15 13:31:14 -0800980 */
981static inline int native_window_set_auto_refresh(
982 struct ANativeWindow* window,
983 bool autoRefresh)
984{
985 return window->perform(window, NATIVE_WINDOW_SET_AUTO_REFRESH, autoRefresh);
986}
987
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700988__END_DECLS
989
tedbo1ffdb382011-05-24 00:55:33 -0700990#endif /* SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H */