blob: 44bfc9be2a0604a04f344dc88f5b8fdae10180aa [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
41#define ANDROID_NATIVE_MAKE_CONSTANT(a,b,c,d) \
42 (((unsigned)(a)<<24)|((unsigned)(b)<<16)|((unsigned)(c)<<8)|(unsigned)(d))
43
44#define ANDROID_NATIVE_WINDOW_MAGIC \
45 ANDROID_NATIVE_MAKE_CONSTANT('_','w','n','d')
46
47#define ANDROID_NATIVE_BUFFER_MAGIC \
48 ANDROID_NATIVE_MAKE_CONSTANT('_','b','f','r')
49
50// ---------------------------------------------------------------------------
51
Jamie Gennis22aec572012-06-13 16:43:06 -070052// This #define may be used to conditionally compile device-specific code to
53// support either the prior ANativeWindow interface, which did not pass libsync
54// fences around, or the new interface that does. This #define is only present
55// when the ANativeWindow interface does include libsync support.
56#define ANDROID_NATIVE_WINDOW_HAS_SYNC 1
57
58// ---------------------------------------------------------------------------
59
Iliyan Malchev0ab886b2011-05-01 14:07:43 -070060typedef const native_handle_t* buffer_handle_t;
61
62// ---------------------------------------------------------------------------
63
64typedef struct android_native_rect_t
65{
66 int32_t left;
67 int32_t top;
68 int32_t right;
69 int32_t bottom;
70} android_native_rect_t;
71
72// ---------------------------------------------------------------------------
73
74typedef struct android_native_base_t
75{
76 /* a magic value defined by the actual EGL native type */
77 int magic;
78
79 /* the sizeof() of the actual EGL native type */
80 int version;
81
82 void* reserved[4];
83
84 /* reference-counting interface */
85 void (*incRef)(struct android_native_base_t* base);
86 void (*decRef)(struct android_native_base_t* base);
87} android_native_base_t;
88
89typedef struct ANativeWindowBuffer
90{
91#ifdef __cplusplus
92 ANativeWindowBuffer() {
93 common.magic = ANDROID_NATIVE_BUFFER_MAGIC;
94 common.version = sizeof(ANativeWindowBuffer);
95 memset(common.reserved, 0, sizeof(common.reserved));
96 }
97
98 // Implement the methods that sp<ANativeWindowBuffer> expects so that it
99 // can be used to automatically refcount ANativeWindowBuffer's.
Mark Salyzyn48878422014-05-22 16:08:52 -0700100 void incStrong(const void* /*id*/) const {
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700101 common.incRef(const_cast<android_native_base_t*>(&common));
102 }
Mark Salyzyn48878422014-05-22 16:08:52 -0700103 void decStrong(const void* /*id*/) const {
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700104 common.decRef(const_cast<android_native_base_t*>(&common));
105 }
106#endif
107
108 struct android_native_base_t common;
109
110 int width;
111 int height;
112 int stride;
113 int format;
114 int usage;
115
116 void* reserved[2];
117
118 buffer_handle_t handle;
119
120 void* reserved_proc[8];
121} ANativeWindowBuffer_t;
122
123// Old typedef for backwards compatibility.
124typedef ANativeWindowBuffer_t android_native_buffer_t;
125
126// ---------------------------------------------------------------------------
127
128/* attributes queriable with query() */
129enum {
130 NATIVE_WINDOW_WIDTH = 0,
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700131 NATIVE_WINDOW_HEIGHT = 1,
132 NATIVE_WINDOW_FORMAT = 2,
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700133
134 /* The minimum number of buffers that must remain un-dequeued after a buffer
135 * has been queued. This value applies only if set_buffer_count was used to
136 * override the number of buffers and if a buffer has since been queued.
137 * Users of the set_buffer_count ANativeWindow method should query this
138 * value before calling set_buffer_count. If it is necessary to have N
139 * buffers simultaneously dequeued as part of the steady-state operation,
140 * and this query returns M then N+M buffers should be requested via
141 * native_window_set_buffer_count.
142 *
143 * Note that this value does NOT apply until a single buffer has been
144 * queued. In particular this means that it is possible to:
145 *
146 * 1. Query M = min undequeued buffers
147 * 2. Set the buffer count to N + M
148 * 3. Dequeue all N + M buffers
149 * 4. Cancel M buffers
150 * 5. Queue, dequeue, queue, dequeue, ad infinitum
151 */
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700152 NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS = 3,
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700153
154 /* Check whether queueBuffer operations on the ANativeWindow send the buffer
155 * to the window compositor. The query sets the returned 'value' argument
156 * to 1 if the ANativeWindow DOES send queued buffers directly to the window
157 * compositor and 0 if the buffers do not go directly to the window
158 * compositor.
159 *
160 * This can be used to determine whether protected buffer content should be
161 * sent to the ANativeWindow. Note, however, that a result of 1 does NOT
162 * indicate that queued buffers will be protected from applications or users
163 * capturing their contents. If that behavior is desired then some other
164 * mechanism (e.g. the GRALLOC_USAGE_PROTECTED flag) should be used in
165 * conjunction with this query.
166 */
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700167 NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER = 4,
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700168
169 /* Get the concrete type of a ANativeWindow. See below for the list of
170 * possible return values.
171 *
172 * This query should not be used outside the Android framework and will
173 * likely be removed in the near future.
174 */
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700175 NATIVE_WINDOW_CONCRETE_TYPE = 5,
Mathias Agopian51009162011-07-19 15:59:15 -0700176
177
178 /*
Michael I. Goldafcdef62012-04-09 18:21:13 -0700179 * Default width and height of ANativeWindow buffers, these are the
180 * dimensions of the window buffers irrespective of the
181 * NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS call and match the native window
Jamie Gennisaa3f4c32012-04-17 19:37:48 -0700182 * size unless overridden by NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS.
Mathias Agopian51009162011-07-19 15:59:15 -0700183 */
184 NATIVE_WINDOW_DEFAULT_WIDTH = 6,
185 NATIVE_WINDOW_DEFAULT_HEIGHT = 7,
186
187 /*
188 * transformation that will most-likely be applied to buffers. This is only
189 * a hint, the actual transformation applied might be different.
190 *
191 * INTENDED USE:
192 *
193 * The transform hint can be used by a producer, for instance the GLES
194 * driver, to pre-rotate the rendering such that the final transformation
195 * in the composer is identity. This can be very useful when used in
196 * conjunction with the h/w composer HAL, in situations where it
197 * cannot handle arbitrary rotations.
198 *
199 * 1. Before dequeuing a buffer, the GL driver (or any other ANW client)
200 * queries the ANW for NATIVE_WINDOW_TRANSFORM_HINT.
201 *
202 * 2. The GL driver overrides the width and height of the ANW to
203 * account for NATIVE_WINDOW_TRANSFORM_HINT. This is done by querying
204 * NATIVE_WINDOW_DEFAULT_{WIDTH | HEIGHT}, swapping the dimensions
205 * according to NATIVE_WINDOW_TRANSFORM_HINT and calling
206 * native_window_set_buffers_dimensions().
207 *
208 * 3. The GL driver dequeues a buffer of the new pre-rotated size.
209 *
210 * 4. The GL driver renders to the buffer such that the image is
211 * already transformed, that is applying NATIVE_WINDOW_TRANSFORM_HINT
212 * to the rendering.
213 *
214 * 5. The GL driver calls native_window_set_transform to apply
215 * inverse transformation to the buffer it just rendered.
216 * In order to do this, the GL driver needs
217 * to calculate the inverse of NATIVE_WINDOW_TRANSFORM_HINT, this is
218 * done easily:
219 *
220 * int hintTransform, inverseTransform;
221 * query(..., NATIVE_WINDOW_TRANSFORM_HINT, &hintTransform);
222 * inverseTransform = hintTransform;
223 * if (hintTransform & HAL_TRANSFORM_ROT_90)
224 * inverseTransform ^= HAL_TRANSFORM_ROT_180;
225 *
226 *
227 * 6. The GL driver queues the pre-transformed buffer.
228 *
229 * 7. The composer combines the buffer transform with the display
230 * transform. If the buffer transform happens to cancel out the
231 * display transform then no rotation is needed.
232 *
233 */
234 NATIVE_WINDOW_TRANSFORM_HINT = 8,
Jamie Gennisaa3f4c32012-04-17 19:37:48 -0700235
236 /*
237 * Boolean that indicates whether the consumer is running more than
238 * one buffer behind the producer.
239 */
Eino-Ville Talvalaf88a5b42013-07-30 14:07:08 -0700240 NATIVE_WINDOW_CONSUMER_RUNNING_BEHIND = 9,
241
242 /*
243 * The consumer gralloc usage bits currently set by the consumer.
244 * The values are defined in hardware/libhardware/include/gralloc.h.
245 */
Ruben Brunka5e65d82014-06-27 16:15:18 -0700246 NATIVE_WINDOW_CONSUMER_USAGE_BITS = 10,
247
248 /**
249 * Transformation that will by applied to buffers by the hwcomposer.
250 * This must not be set or checked by producer endpoints, and will
251 * disable the transform hint set in SurfaceFlinger (see
252 * NATIVE_WINDOW_TRANSFORM_HINT).
253 *
254 * INTENDED USE:
255 * Temporary - Please do not use this. This is intended only to be used
256 * by the camera's LEGACY mode.
257 *
258 * In situations where a SurfaceFlinger client wishes to set a transform
259 * that is not visible to the producer, and will always be applied in the
260 * hardware composer, the client can set this flag with
261 * native_window_set_buffers_sticky_transform. This can be used to rotate
262 * and flip buffers consumed by hardware composer without actually changing
263 * the aspect ratio of the buffers produced.
264 */
265 NATIVE_WINDOW_STICKY_TRANSFORM = 11,
Eino-Ville Talvalab93343d2015-02-17 15:34:44 -0800266
267 /**
268 * The default data space for the buffers as set by the consumer.
269 * The values are defined in graphics.h.
270 */
Dan Stoza0a866ea2015-02-25 16:45:08 -0800271 NATIVE_WINDOW_DEFAULT_DATASPACE = 12,
272
273 /*
274 * Returns the age of the contents of the most recently dequeued buffer as
275 * the number of frames that have elapsed since it was last queued. For
276 * example, if the window is double-buffered, the age of any given buffer in
277 * steady state will be 2. If the dequeued buffer has never been queued, its
278 * age will be 0.
279 */
280 NATIVE_WINDOW_BUFFER_AGE = 13,
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700281};
282
Jamie Gennisfb1ee572012-04-17 19:37:48 -0700283/* Valid operations for the (*perform)() hook.
284 *
285 * Values marked as 'deprecated' are supported, but have been superceded by
286 * other functionality.
287 *
288 * Values marked as 'private' should be considered private to the framework.
289 * HAL implementation code with access to an ANativeWindow should not use these,
290 * as it may not interact properly with the framework's use of the
291 * ANativeWindow.
292 */
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700293enum {
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700294 NATIVE_WINDOW_SET_USAGE = 0,
Mathias Agopian8ad54522011-07-29 17:52:36 -0700295 NATIVE_WINDOW_CONNECT = 1, /* deprecated */
296 NATIVE_WINDOW_DISCONNECT = 2, /* deprecated */
Jamie Gennisfb1ee572012-04-17 19:37:48 -0700297 NATIVE_WINDOW_SET_CROP = 3, /* private */
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700298 NATIVE_WINDOW_SET_BUFFER_COUNT = 4,
299 NATIVE_WINDOW_SET_BUFFERS_GEOMETRY = 5, /* deprecated */
300 NATIVE_WINDOW_SET_BUFFERS_TRANSFORM = 6,
301 NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP = 7,
302 NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS = 8,
303 NATIVE_WINDOW_SET_BUFFERS_FORMAT = 9,
Jamie Gennisfb1ee572012-04-17 19:37:48 -0700304 NATIVE_WINDOW_SET_SCALING_MODE = 10, /* private */
Mathias Agopianae3736a2011-07-13 18:40:38 -0700305 NATIVE_WINDOW_LOCK = 11, /* private */
306 NATIVE_WINDOW_UNLOCK_AND_POST = 12, /* private */
Mathias Agopian8ad54522011-07-29 17:52:36 -0700307 NATIVE_WINDOW_API_CONNECT = 13, /* private */
308 NATIVE_WINDOW_API_DISCONNECT = 14, /* private */
Michael I. Goldafcdef62012-04-09 18:21:13 -0700309 NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS = 15, /* private */
Jamie Gennisd21113a2012-05-03 14:21:24 -0700310 NATIVE_WINDOW_SET_POST_TRANSFORM_CROP = 16, /* private */
Ruben Brunka5e65d82014-06-27 16:15:18 -0700311 NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM = 17,/* private */
Rachadd6d4c612014-07-29 18:03:21 -0700312 NATIVE_WINDOW_SET_SIDEBAND_STREAM = 18,
Dan Stoza238ec982015-03-23 10:43:14 -0700313 NATIVE_WINDOW_SET_BUFFERS_DATASPACE = 19,
314 NATIVE_WINDOW_SET_SURFACE_DAMAGE = 20, /* private */
Pablo Ceballos248e7712016-03-17 15:42:21 -0700315 NATIVE_WINDOW_SET_SHARED_BUFFER_MODE = 21,
Pablo Ceballos3daa5742016-01-15 13:31:14 -0800316 NATIVE_WINDOW_SET_AUTO_REFRESH = 22,
Pablo Ceballosc2efc322016-05-31 11:06:03 -0700317 NATIVE_WINDOW_GET_FRAME_TIMESTAMPS = 23,
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700318};
319
Mathias Agopian8ad54522011-07-29 17:52:36 -0700320/* parameter for NATIVE_WINDOW_[API_][DIS]CONNECT */
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700321enum {
Jamie Gennis5423e9e2011-07-12 13:53:42 -0700322 /* Buffers will be queued by EGL via eglSwapBuffers after being filled using
323 * OpenGL ES.
324 */
325 NATIVE_WINDOW_API_EGL = 1,
326
327 /* Buffers will be queued after being filled using the CPU
328 */
329 NATIVE_WINDOW_API_CPU = 2,
330
331 /* Buffers will be queued by Stagefright after being filled by a video
332 * decoder. The video decoder can either be a software or hardware decoder.
333 */
334 NATIVE_WINDOW_API_MEDIA = 3,
335
336 /* Buffers will be queued by the the camera HAL.
337 */
338 NATIVE_WINDOW_API_CAMERA = 4,
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700339};
340
341/* parameter for NATIVE_WINDOW_SET_BUFFERS_TRANSFORM */
342enum {
343 /* flip source image horizontally */
344 NATIVE_WINDOW_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H ,
345 /* flip source image vertically */
346 NATIVE_WINDOW_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V,
Mathias Agopian96675ed2013-09-17 23:48:54 -0700347 /* rotate source image 90 degrees clock-wise, and is applied after TRANSFORM_FLIP_{H|V} */
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700348 NATIVE_WINDOW_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90,
349 /* rotate source image 180 degrees */
350 NATIVE_WINDOW_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180,
351 /* rotate source image 270 degrees clock-wise */
352 NATIVE_WINDOW_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270,
Mathias Agopian96675ed2013-09-17 23:48:54 -0700353 /* transforms source by the inverse transform of the screen it is displayed onto. This
354 * transform is applied last */
355 NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY = 0x08
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700356};
357
Robert Carrf3954fb2015-12-17 11:31:11 -0800358/* parameter for NATIVE_WINDOW_SET_SCALING_MODE
359 * keep in sync with Surface.java in frameworks/base */
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700360enum {
361 /* the window content is not updated (frozen) until a buffer of
362 * the window size is received (enqueued)
363 */
364 NATIVE_WINDOW_SCALING_MODE_FREEZE = 0,
365 /* the buffer is scaled in both dimensions to match the window size */
366 NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW = 1,
Daniel Lam29392a42012-04-11 18:19:46 -0700367 /* the buffer is scaled uniformly such that the smaller dimension
368 * of the buffer matches the window size (cropping in the process)
369 */
370 NATIVE_WINDOW_SCALING_MODE_SCALE_CROP = 2,
Jamie Gennisd21113a2012-05-03 14:21:24 -0700371 /* the window is clipped to the size of the buffer's crop rectangle; pixels
372 * outside the crop rectangle are treated as if they are completely
373 * transparent.
374 */
375 NATIVE_WINDOW_SCALING_MODE_NO_SCALE_CROP = 3,
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700376};
377
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700378/* values returned by the NATIVE_WINDOW_CONCRETE_TYPE query */
379enum {
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700380 NATIVE_WINDOW_FRAMEBUFFER = 0, /* FramebufferNativeWindow */
381 NATIVE_WINDOW_SURFACE = 1, /* Surface */
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700382};
383
384/* parameter for NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP
385 *
386 * Special timestamp value to indicate that timestamps should be auto-generated
387 * by the native window when queueBuffer is called. This is equal to INT64_MIN,
388 * defined directly to avoid problems with C99/C++ inclusion of stdint.h.
389 */
390static const int64_t NATIVE_WINDOW_TIMESTAMP_AUTO = (-9223372036854775807LL-1);
391
392struct ANativeWindow
393{
394#ifdef __cplusplus
395 ANativeWindow()
396 : flags(0), minSwapInterval(0), maxSwapInterval(0), xdpi(0), ydpi(0)
397 {
398 common.magic = ANDROID_NATIVE_WINDOW_MAGIC;
399 common.version = sizeof(ANativeWindow);
400 memset(common.reserved, 0, sizeof(common.reserved));
401 }
402
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700403 /* Implement the methods that sp<ANativeWindow> expects so that it
404 can be used to automatically refcount ANativeWindow's. */
Mark Salyzyn48878422014-05-22 16:08:52 -0700405 void incStrong(const void* /*id*/) const {
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700406 common.incRef(const_cast<android_native_base_t*>(&common));
407 }
Mark Salyzyn48878422014-05-22 16:08:52 -0700408 void decStrong(const void* /*id*/) const {
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700409 common.decRef(const_cast<android_native_base_t*>(&common));
410 }
411#endif
412
413 struct android_native_base_t common;
414
415 /* flags describing some attributes of this surface or its updater */
416 const uint32_t flags;
417
418 /* min swap interval supported by this updated */
419 const int minSwapInterval;
420
421 /* max swap interval supported by this updated */
422 const int maxSwapInterval;
423
424 /* horizontal and vertical resolution in DPI */
425 const float xdpi;
426 const float ydpi;
427
428 /* Some storage reserved for the OEM's driver. */
429 intptr_t oem[4];
430
431 /*
432 * Set the swap interval for this surface.
433 *
434 * Returns 0 on success or -errno on error.
435 */
436 int (*setSwapInterval)(struct ANativeWindow* window,
437 int interval);
438
439 /*
Jesse Hall7cd3e0a2011-12-12 10:32:55 -0800440 * Hook called by EGL to acquire a buffer. After this call, the buffer
441 * is not locked, so its content cannot be modified. This call may block if
442 * no buffers are available.
443 *
444 * The window holds a reference to the buffer between dequeueBuffer and
445 * either queueBuffer or cancelBuffer, so clients only need their own
446 * reference if they might use the buffer after queueing or canceling it.
447 * Holding a reference to a buffer after queueing or canceling it is only
448 * allowed if a specific buffer count has been set.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700449 *
450 * Returns 0 on success or -errno on error.
Jamie Gennis22aec572012-06-13 16:43:06 -0700451 *
452 * XXX: This function is deprecated. It will continue to work for some
453 * time for binary compatibility, but the new dequeueBuffer function that
454 * outputs a fence file descriptor should be used in its place.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700455 */
Jamie Gennis22aec572012-06-13 16:43:06 -0700456 int (*dequeueBuffer_DEPRECATED)(struct ANativeWindow* window,
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700457 struct ANativeWindowBuffer** buffer);
458
459 /*
460 * hook called by EGL to lock a buffer. This MUST be called before modifying
461 * the content of a buffer. The buffer must have been acquired with
462 * dequeueBuffer first.
463 *
464 * Returns 0 on success or -errno on error.
Jamie Gennis22aec572012-06-13 16:43:06 -0700465 *
466 * XXX: This function is deprecated. It will continue to work for some
467 * time for binary compatibility, but it is essentially a no-op, and calls
468 * to it should be removed.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700469 */
Jamie Gennis22aec572012-06-13 16:43:06 -0700470 int (*lockBuffer_DEPRECATED)(struct ANativeWindow* window,
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700471 struct ANativeWindowBuffer* buffer);
Jamie Gennis22aec572012-06-13 16:43:06 -0700472
Jesse Hall7cd3e0a2011-12-12 10:32:55 -0800473 /*
474 * Hook called by EGL when modifications to the render buffer are done.
475 * This unlocks and post the buffer.
476 *
477 * The window holds a reference to the buffer between dequeueBuffer and
478 * either queueBuffer or cancelBuffer, so clients only need their own
479 * reference if they might use the buffer after queueing or canceling it.
480 * Holding a reference to a buffer after queueing or canceling it is only
481 * allowed if a specific buffer count has been set.
482 *
483 * Buffers MUST be queued in the same order than they were dequeued.
484 *
485 * Returns 0 on success or -errno on error.
Jamie Gennis22aec572012-06-13 16:43:06 -0700486 *
487 * XXX: This function is deprecated. It will continue to work for some
488 * time for binary compatibility, but the new queueBuffer function that
489 * takes a fence file descriptor should be used in its place (pass a value
490 * of -1 for the fence file descriptor if there is no valid one to pass).
Jesse Hall7cd3e0a2011-12-12 10:32:55 -0800491 */
Jamie Gennis22aec572012-06-13 16:43:06 -0700492 int (*queueBuffer_DEPRECATED)(struct ANativeWindow* window,
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700493 struct ANativeWindowBuffer* buffer);
494
495 /*
496 * hook used to retrieve information about the native window.
497 *
498 * Returns 0 on success or -errno on error.
499 */
500 int (*query)(const struct ANativeWindow* window,
501 int what, int* value);
502
503 /*
504 * hook used to perform various operations on the surface.
505 * (*perform)() is a generic mechanism to add functionality to
506 * ANativeWindow while keeping backward binary compatibility.
507 *
508 * DO NOT CALL THIS HOOK DIRECTLY. Instead, use the helper functions
509 * defined below.
510 *
Dan Stoza238ec982015-03-23 10:43:14 -0700511 * (*perform)() returns -ENOENT if the 'what' parameter is not supported
512 * by the surface's implementation.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700513 *
Dan Stoza238ec982015-03-23 10:43:14 -0700514 * See above for a list of valid operations, such as
515 * NATIVE_WINDOW_SET_USAGE or NATIVE_WINDOW_CONNECT
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700516 */
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700517 int (*perform)(struct ANativeWindow* window,
518 int operation, ... );
519
520 /*
Jesse Hall7cd3e0a2011-12-12 10:32:55 -0800521 * Hook used to cancel a buffer that has been dequeued.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700522 * No synchronization is performed between dequeue() and cancel(), so
523 * either external synchronization is needed, or these functions must be
524 * called from the same thread.
Jesse Hall7cd3e0a2011-12-12 10:32:55 -0800525 *
526 * The window holds a reference to the buffer between dequeueBuffer and
527 * either queueBuffer or cancelBuffer, so clients only need their own
528 * reference if they might use the buffer after queueing or canceling it.
529 * Holding a reference to a buffer after queueing or canceling it is only
530 * allowed if a specific buffer count has been set.
Jamie Gennis22aec572012-06-13 16:43:06 -0700531 *
532 * XXX: This function is deprecated. It will continue to work for some
533 * time for binary compatibility, but the new cancelBuffer function that
534 * takes a fence file descriptor should be used in its place (pass a value
535 * of -1 for the fence file descriptor if there is no valid one to pass).
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700536 */
Jamie Gennis22aec572012-06-13 16:43:06 -0700537 int (*cancelBuffer_DEPRECATED)(struct ANativeWindow* window,
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700538 struct ANativeWindowBuffer* buffer);
539
Jamie Gennis22aec572012-06-13 16:43:06 -0700540 /*
541 * Hook called by EGL to acquire a buffer. This call may block if no
542 * buffers are available.
543 *
544 * The window holds a reference to the buffer between dequeueBuffer and
545 * either queueBuffer or cancelBuffer, so clients only need their own
546 * reference if they might use the buffer after queueing or canceling it.
547 * Holding a reference to a buffer after queueing or canceling it is only
548 * allowed if a specific buffer count has been set.
549 *
550 * The libsync fence file descriptor returned in the int pointed to by the
551 * fenceFd argument will refer to the fence that must signal before the
552 * dequeued buffer may be written to. A value of -1 indicates that the
553 * caller may access the buffer immediately without waiting on a fence. If
554 * a valid file descriptor is returned (i.e. any value except -1) then the
555 * caller is responsible for closing the file descriptor.
556 *
557 * Returns 0 on success or -errno on error.
558 */
559 int (*dequeueBuffer)(struct ANativeWindow* window,
560 struct ANativeWindowBuffer** buffer, int* fenceFd);
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700561
Jamie Gennis22aec572012-06-13 16:43:06 -0700562 /*
563 * Hook called by EGL when modifications to the render buffer are done.
564 * This unlocks and post the buffer.
565 *
566 * The window holds a reference to the buffer between dequeueBuffer and
567 * either queueBuffer or cancelBuffer, so clients only need their own
568 * reference if they might use the buffer after queueing or canceling it.
569 * Holding a reference to a buffer after queueing or canceling it is only
570 * allowed if a specific buffer count has been set.
571 *
572 * The fenceFd argument specifies a libsync fence file descriptor for a
573 * fence that must signal before the buffer can be accessed. If the buffer
574 * can be accessed immediately then a value of -1 should be used. The
575 * caller must not use the file descriptor after it is passed to
576 * queueBuffer, and the ANativeWindow implementation is responsible for
577 * closing it.
578 *
579 * Returns 0 on success or -errno on error.
580 */
581 int (*queueBuffer)(struct ANativeWindow* window,
582 struct ANativeWindowBuffer* buffer, int fenceFd);
583
584 /*
585 * Hook used to cancel a buffer that has been dequeued.
586 * No synchronization is performed between dequeue() and cancel(), so
587 * either external synchronization is needed, or these functions must be
588 * called from the same thread.
589 *
590 * The window holds a reference to the buffer between dequeueBuffer and
591 * either queueBuffer or cancelBuffer, so clients only need their own
592 * reference if they might use the buffer after queueing or canceling it.
593 * Holding a reference to a buffer after queueing or canceling it is only
594 * allowed if a specific buffer count has been set.
595 *
596 * The fenceFd argument specifies a libsync fence file decsriptor for a
597 * fence that must signal before the buffer can be accessed. If the buffer
598 * can be accessed immediately then a value of -1 should be used.
599 *
600 * Note that if the client has not waited on the fence that was returned
601 * from dequeueBuffer, that same fence should be passed to cancelBuffer to
602 * ensure that future uses of the buffer are preceded by a wait on that
603 * fence. The caller must not use the file descriptor after it is passed
604 * to cancelBuffer, and the ANativeWindow implementation is responsible for
605 * closing it.
606 *
607 * Returns 0 on success or -errno on error.
608 */
609 int (*cancelBuffer)(struct ANativeWindow* window,
610 struct ANativeWindowBuffer* buffer, int fenceFd);
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700611};
612
613 /* Backwards compatibility: use ANativeWindow (struct ANativeWindow in C).
614 * android_native_window_t is deprecated.
615 */
616typedef struct ANativeWindow ANativeWindow;
Mark Salyzyn289e1112014-05-23 12:31:42 -0700617typedef struct ANativeWindow android_native_window_t __deprecated;
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700618
619/*
620 * native_window_set_usage(..., usage)
621 * Sets the intended usage flags for the next buffers
622 * acquired with (*lockBuffer)() and on.
623 * By default (if this function is never called), a usage of
624 * GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE
625 * is assumed.
626 * Calling this function will usually cause following buffers to be
627 * reallocated.
628 */
629
630static inline int native_window_set_usage(
631 struct ANativeWindow* window, int usage)
632{
633 return window->perform(window, NATIVE_WINDOW_SET_USAGE, usage);
634}
635
Mathias Agopian8ad54522011-07-29 17:52:36 -0700636/* deprecated. Always returns 0. Don't call. */
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700637static inline int native_window_connect(
Ian Rogersde8b9832014-06-27 16:38:01 -0700638 struct ANativeWindow* window __UNUSED, int api __UNUSED) __deprecated;
Mark Salyzyn289e1112014-05-23 12:31:42 -0700639
640static inline int native_window_connect(
Ian Rogersde8b9832014-06-27 16:38:01 -0700641 struct ANativeWindow* window __UNUSED, int api __UNUSED) {
Mathias Agopian319f4e22011-08-03 11:26:38 -0700642 return 0;
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700643}
644
Mathias Agopian8ad54522011-07-29 17:52:36 -0700645/* deprecated. Always returns 0. Don't call. */
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700646static inline int native_window_disconnect(
Ian Rogersde8b9832014-06-27 16:38:01 -0700647 struct ANativeWindow* window __UNUSED, int api __UNUSED) __deprecated;
Mark Salyzyn289e1112014-05-23 12:31:42 -0700648
649static inline int native_window_disconnect(
Ian Rogersde8b9832014-06-27 16:38:01 -0700650 struct ANativeWindow* window __UNUSED, int api __UNUSED) {
Mathias Agopian319f4e22011-08-03 11:26:38 -0700651 return 0;
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700652}
653
654/*
655 * native_window_set_crop(..., crop)
656 * Sets which region of the next queued buffers needs to be considered.
Jamie Gennisd21113a2012-05-03 14:21:24 -0700657 * Depending on the scaling mode, a buffer's crop region is scaled and/or
658 * cropped to match the surface's size. This function sets the crop in
659 * pre-transformed buffer pixel coordinates.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700660 *
661 * The specified crop region applies to all buffers queued after it is called.
662 *
Jamie Gennisd21113a2012-05-03 14:21:24 -0700663 * If 'crop' is NULL, subsequently queued buffers won't be cropped.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700664 *
Jamie Gennisd21113a2012-05-03 14:21:24 -0700665 * An error is returned if for instance the crop region is invalid, out of the
666 * buffer's bound or if the window is invalid.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700667 */
668static inline int native_window_set_crop(
669 struct ANativeWindow* window,
670 android_native_rect_t const * crop)
671{
672 return window->perform(window, NATIVE_WINDOW_SET_CROP, crop);
673}
674
675/*
Jamie Gennisd21113a2012-05-03 14:21:24 -0700676 * native_window_set_post_transform_crop(..., crop)
677 * Sets which region of the next queued buffers needs to be considered.
678 * Depending on the scaling mode, a buffer's crop region is scaled and/or
679 * cropped to match the surface's size. This function sets the crop in
680 * post-transformed pixel coordinates.
681 *
682 * The specified crop region applies to all buffers queued after it is called.
683 *
684 * If 'crop' is NULL, subsequently queued buffers won't be cropped.
685 *
686 * An error is returned if for instance the crop region is invalid, out of the
687 * buffer's bound or if the window is invalid.
688 */
689static inline int native_window_set_post_transform_crop(
690 struct ANativeWindow* window,
691 android_native_rect_t const * crop)
692{
693 return window->perform(window, NATIVE_WINDOW_SET_POST_TRANSFORM_CROP, crop);
694}
695
696/*
Jamie Gennisfb1ee572012-04-17 19:37:48 -0700697 * native_window_set_active_rect(..., active_rect)
Jamie Gennisfb1ee572012-04-17 19:37:48 -0700698 *
Jamie Gennis22aec572012-06-13 16:43:06 -0700699 * This function is deprecated and will be removed soon. For now it simply
Jamie Gennisd21113a2012-05-03 14:21:24 -0700700 * sets the post-transform crop for compatibility while multi-project commits
701 * get checked.
Jamie Gennisfb1ee572012-04-17 19:37:48 -0700702 */
703static inline int native_window_set_active_rect(
704 struct ANativeWindow* window,
Mark Salyzyn289e1112014-05-23 12:31:42 -0700705 android_native_rect_t const * active_rect) __deprecated;
706
707static inline int native_window_set_active_rect(
708 struct ANativeWindow* window,
Jamie Gennisfb1ee572012-04-17 19:37:48 -0700709 android_native_rect_t const * active_rect)
710{
Jamie Gennisd21113a2012-05-03 14:21:24 -0700711 return native_window_set_post_transform_crop(window, active_rect);
Jamie Gennisfb1ee572012-04-17 19:37:48 -0700712}
713
714/*
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700715 * native_window_set_buffer_count(..., count)
716 * Sets the number of buffers associated with this native window.
717 */
718static inline int native_window_set_buffer_count(
719 struct ANativeWindow* window,
720 size_t bufferCount)
721{
722 return window->perform(window, NATIVE_WINDOW_SET_BUFFER_COUNT, bufferCount);
723}
724
725/*
726 * native_window_set_buffers_geometry(..., int w, int h, int format)
Jamie Gennis208ec5e2011-07-07 11:51:48 -0700727 * All buffers dequeued after this call will have the dimensions and format
728 * specified. A successful call to this function has the same effect as calling
729 * native_window_set_buffers_size and native_window_set_buffers_format.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700730 *
Jamie Gennis208ec5e2011-07-07 11:51:48 -0700731 * XXX: This function is deprecated. The native_window_set_buffers_dimensions
732 * and native_window_set_buffers_format functions should be used instead.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700733 */
734static inline int native_window_set_buffers_geometry(
735 struct ANativeWindow* window,
Mark Salyzyn289e1112014-05-23 12:31:42 -0700736 int w, int h, int format) __deprecated;
737
738static inline int native_window_set_buffers_geometry(
739 struct ANativeWindow* window,
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700740 int w, int h, int format)
741{
742 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_GEOMETRY,
743 w, h, format);
744}
745
746/*
Jamie Gennis208ec5e2011-07-07 11:51:48 -0700747 * native_window_set_buffers_dimensions(..., int w, int h)
748 * All buffers dequeued after this call will have the dimensions specified.
Michael I. Goldafcdef62012-04-09 18:21:13 -0700749 * In particular, all buffers will have a fixed-size, independent from the
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700750 * native-window size. They will be scaled according to the scaling mode
751 * (see native_window_set_scaling_mode) upon window composition.
Jamie Gennis208ec5e2011-07-07 11:51:48 -0700752 *
753 * If w and h are 0, the normal behavior is restored. That is, dequeued buffers
754 * following this call will be sized to match the window's size.
755 *
756 * Calling this function will reset the window crop to a NULL value, which
757 * disables cropping of the buffers.
758 */
759static inline int native_window_set_buffers_dimensions(
760 struct ANativeWindow* window,
761 int w, int h)
762{
763 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS,
764 w, h);
765}
766
767/*
Michael I. Goldafcdef62012-04-09 18:21:13 -0700768 * native_window_set_buffers_user_dimensions(..., int w, int h)
769 *
770 * Sets the user buffer size for the window, which overrides the
771 * window's size. All buffers dequeued after this call will have the
772 * dimensions specified unless overridden by
773 * native_window_set_buffers_dimensions. All buffers will have a
774 * fixed-size, independent from the native-window size. They will be
775 * scaled according to the scaling mode (see
776 * native_window_set_scaling_mode) upon window composition.
777 *
778 * If w and h are 0, the normal behavior is restored. That is, the
779 * default buffer size will match the windows's size.
780 *
781 * Calling this function will reset the window crop to a NULL value, which
782 * disables cropping of the buffers.
783 */
784static inline int native_window_set_buffers_user_dimensions(
785 struct ANativeWindow* window,
786 int w, int h)
787{
788 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS,
789 w, h);
790}
791
792/*
Jamie Gennis208ec5e2011-07-07 11:51:48 -0700793 * native_window_set_buffers_format(..., int format)
794 * All buffers dequeued after this call will have the format specified.
795 *
796 * If the specified format is 0, the default buffer format will be used.
797 */
798static inline int native_window_set_buffers_format(
799 struct ANativeWindow* window,
800 int format)
801{
802 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_FORMAT, format);
803}
804
805/*
Eino-Ville Talvalab93343d2015-02-17 15:34:44 -0800806 * native_window_set_buffers_data_space(..., int dataSpace)
807 * All buffers queued after this call will be associated with the dataSpace
808 * parameter specified.
809 *
810 * dataSpace specifies additional information about the buffer that's dependent
811 * on the buffer format and the endpoints. For example, it can be used to convey
812 * the color space of the image data in the buffer, or it can be used to
813 * indicate that the buffers contain depth measurement data instead of color
814 * images. The default dataSpace is 0, HAL_DATASPACE_UNKNOWN, unless it has been
815 * overridden by the consumer.
816 */
817static inline int native_window_set_buffers_data_space(
818 struct ANativeWindow* window,
819 android_dataspace_t dataSpace)
820{
821 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DATASPACE,
822 dataSpace);
823}
824
825/*
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700826 * native_window_set_buffers_transform(..., int transform)
827 * All buffers queued after this call will be displayed transformed according
828 * to the transform parameter specified.
829 */
830static inline int native_window_set_buffers_transform(
831 struct ANativeWindow* window,
832 int transform)
833{
834 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TRANSFORM,
835 transform);
836}
837
838/*
Ruben Brunka5e65d82014-06-27 16:15:18 -0700839 * native_window_set_buffers_sticky_transform(..., int transform)
840 * All buffers queued after this call will be displayed transformed according
841 * to the transform parameter specified applied on top of the regular buffer
842 * transform. Setting this transform will disable the transform hint.
843 *
844 * Temporary - This is only intended to be used by the LEGACY camera mode, do
845 * not use this for anything else.
846 */
847static inline int native_window_set_buffers_sticky_transform(
848 struct ANativeWindow* window,
849 int transform)
850{
851 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM,
852 transform);
853}
854
855/*
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700856 * native_window_set_buffers_timestamp(..., int64_t timestamp)
857 * All buffers queued after this call will be associated with the timestamp
858 * parameter specified. If the timestamp is set to NATIVE_WINDOW_TIMESTAMP_AUTO
859 * (the default), timestamps will be generated automatically when queueBuffer is
Glenn Kastenc322f672011-06-27 10:42:39 -0700860 * called. The timestamp is measured in nanoseconds, and is normally monotonically
861 * increasing. The timestamp should be unaffected by time-of-day adjustments,
862 * and for a camera should be strictly monotonic but for a media player may be
863 * reset when the position is set.
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700864 */
865static inline int native_window_set_buffers_timestamp(
866 struct ANativeWindow* window,
867 int64_t timestamp)
868{
869 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP,
870 timestamp);
871}
872
Mathias Agopian42cc1ed2011-07-13 15:49:58 -0700873/*
874 * native_window_set_scaling_mode(..., int mode)
875 * All buffers queued after this call will be associated with the scaling mode
876 * specified.
877 */
878static inline int native_window_set_scaling_mode(
879 struct ANativeWindow* window,
880 int mode)
881{
882 return window->perform(window, NATIVE_WINDOW_SET_SCALING_MODE,
883 mode);
884}
885
Mathias Agopian8ad54522011-07-29 17:52:36 -0700886/*
887 * native_window_api_connect(..., int api)
888 * connects an API to this window. only one API can be connected at a time.
889 * Returns -EINVAL if for some reason the window cannot be connected, which
890 * can happen if it's connected to some other API.
891 */
892static inline int native_window_api_connect(
893 struct ANativeWindow* window, int api)
894{
Mathias Agopian319f4e22011-08-03 11:26:38 -0700895 return window->perform(window, NATIVE_WINDOW_API_CONNECT, api);
Mathias Agopian8ad54522011-07-29 17:52:36 -0700896}
897
898/*
899 * native_window_api_disconnect(..., int api)
900 * disconnect the API from this window.
901 * An error is returned if for instance the window wasn't connected in the
902 * first place.
903 */
904static inline int native_window_api_disconnect(
905 struct ANativeWindow* window, int api)
906{
Mathias Agopian319f4e22011-08-03 11:26:38 -0700907 return window->perform(window, NATIVE_WINDOW_API_DISCONNECT, api);
Mathias Agopian8ad54522011-07-29 17:52:36 -0700908}
909
Jamie Gennis22aec572012-06-13 16:43:06 -0700910/*
911 * native_window_dequeue_buffer_and_wait(...)
912 * Dequeue a buffer and wait on the fence associated with that buffer. The
913 * buffer may safely be accessed immediately upon this function returning. An
914 * error is returned if either of the dequeue or the wait operations fail.
915 */
916static inline int native_window_dequeue_buffer_and_wait(ANativeWindow *anw,
917 struct ANativeWindowBuffer** anb) {
Jesse Hallbc930ed2012-10-01 13:48:36 -0700918 return anw->dequeueBuffer_DEPRECATED(anw, anb);
Jamie Gennis22aec572012-06-13 16:43:06 -0700919}
920
Rachadd6d4c612014-07-29 18:03:21 -0700921/*
922 * native_window_set_sideband_stream(..., native_handle_t*)
923 * Attach a sideband buffer stream to a native window.
924 */
925static inline int native_window_set_sideband_stream(
926 struct ANativeWindow* window,
927 native_handle_t* sidebandHandle)
928{
929 return window->perform(window, NATIVE_WINDOW_SET_SIDEBAND_STREAM,
930 sidebandHandle);
931}
Mathias Agopian8ad54522011-07-29 17:52:36 -0700932
Dan Stoza238ec982015-03-23 10:43:14 -0700933/*
934 * native_window_set_surface_damage(..., android_native_rect_t* rects, int numRects)
935 * Set the surface damage (i.e., the region of the surface that has changed
936 * since the previous frame). The damage set by this call will be reset (to the
937 * default of full-surface damage) after calling queue, so this must be called
938 * prior to every frame with damage that does not cover the whole surface if the
939 * caller desires downstream consumers to use this optimization.
940 *
941 * The damage region is specified as an array of rectangles, with the important
942 * caveat that the origin of the surface is considered to be the bottom-left
943 * corner, as in OpenGL ES.
944 *
945 * If numRects is set to 0, rects may be NULL, and the surface damage will be
946 * set to the full surface (the same as if this function had not been called for
947 * this frame).
948 */
949static inline int native_window_set_surface_damage(
950 struct ANativeWindow* window,
951 const android_native_rect_t* rects, size_t numRects)
952{
953 return window->perform(window, NATIVE_WINDOW_SET_SURFACE_DAMAGE,
954 rects, numRects);
955}
956
Pablo Ceballos923d27f2015-10-19 10:24:42 -0700957/*
Pablo Ceballos248e7712016-03-17 15:42:21 -0700958 * native_window_set_shared_buffer_mode(..., bool sharedBufferMode)
959 * Enable/disable shared buffer mode
Pablo Ceballos923d27f2015-10-19 10:24:42 -0700960 */
Pablo Ceballos248e7712016-03-17 15:42:21 -0700961static inline int native_window_set_shared_buffer_mode(
Pablo Ceballos923d27f2015-10-19 10:24:42 -0700962 struct ANativeWindow* window,
Pablo Ceballos248e7712016-03-17 15:42:21 -0700963 bool sharedBufferMode)
Pablo Ceballos923d27f2015-10-19 10:24:42 -0700964{
Pablo Ceballos248e7712016-03-17 15:42:21 -0700965 return window->perform(window, NATIVE_WINDOW_SET_SHARED_BUFFER_MODE,
966 sharedBufferMode);
Pablo Ceballos923d27f2015-10-19 10:24:42 -0700967}
968
Pablo Ceballos3daa5742016-01-15 13:31:14 -0800969/*
970 * native_window_set_auto_refresh(..., autoRefresh)
Pablo Ceballos248e7712016-03-17 15:42:21 -0700971 * Enable/disable auto refresh when in shared buffer mode
Pablo Ceballos3daa5742016-01-15 13:31:14 -0800972 */
973static inline int native_window_set_auto_refresh(
974 struct ANativeWindow* window,
975 bool autoRefresh)
976{
977 return window->perform(window, NATIVE_WINDOW_SET_AUTO_REFRESH, autoRefresh);
978}
979
Pablo Ceballosc2efc322016-05-31 11:06:03 -0700980static inline int native_window_get_frame_timestamps(
981 struct ANativeWindow* window, uint32_t framesAgo,
982 int64_t* outPostedTime, int64_t* outAcquireTime,
983 int64_t* outRefreshStartTime, int64_t* outGlCompositionDoneTime,
984 int64_t* outDisplayRetireTime, int64_t* outReleaseTime)
985{
986 return window->perform(window, NATIVE_WINDOW_GET_FRAME_TIMESTAMPS,
987 framesAgo, outPostedTime, outAcquireTime, outRefreshStartTime,
988 outGlCompositionDoneTime, outDisplayRetireTime, outReleaseTime);
989}
990
991
Iliyan Malchev0ab886b2011-05-01 14:07:43 -0700992__END_DECLS
993
tedbo1ffdb382011-05-24 00:55:33 -0700994#endif /* SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H */