2 * Copyright (C) 2011 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 /*************************************************************************************************
21 * There is an old copy of this file in system/core/include/system/window.h, which exists only
22 * for backward source compatibility.
23 * But there are binaries out there as well, so this version of window.h must stay binary
24 * backward compatible with the one found in system/core.
27 * Source compatibility is also required for now, because this is how we're handling the
28 * transition from system/core/include (global include path) to nativewindow/include.
30 *************************************************************************************************/
34 #include <cutils/native_handle.h>
39 #include <sys/cdefs.h>
40 #include <system/graphics.h>
44 // system/window.h is a superset of the vndk
45 #include <vndk/window.h>
49 #define __UNUSED __attribute__((__unused__))
52 #define __deprecated __attribute__((__deprecated__))
57 /*****************************************************************************/
59 #define ANDROID_NATIVE_WINDOW_MAGIC ANDROID_NATIVE_MAKE_CONSTANT('_','w','n','d')
61 // ---------------------------------------------------------------------------
63 /* attributes queriable with query() */
65 NATIVE_WINDOW_WIDTH
= 0,
66 NATIVE_WINDOW_HEIGHT
= 1,
67 NATIVE_WINDOW_FORMAT
= 2,
69 /* see ANativeWindowQuery in vndk/window.h */
70 NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS
= ANATIVEWINDOW_QUERY_MIN_UNDEQUEUED_BUFFERS
,
72 /* Check whether queueBuffer operations on the ANativeWindow send the buffer
73 * to the window compositor. The query sets the returned 'value' argument
74 * to 1 if the ANativeWindow DOES send queued buffers directly to the window
75 * compositor and 0 if the buffers do not go directly to the window
78 * This can be used to determine whether protected buffer content should be
79 * sent to the ANativeWindow. Note, however, that a result of 1 does NOT
80 * indicate that queued buffers will be protected from applications or users
81 * capturing their contents. If that behavior is desired then some other
82 * mechanism (e.g. the GRALLOC_USAGE_PROTECTED flag) should be used in
83 * conjunction with this query.
85 NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER
= 4,
87 /* Get the concrete type of a ANativeWindow. See below for the list of
88 * possible return values.
90 * This query should not be used outside the Android framework and will
91 * likely be removed in the near future.
93 NATIVE_WINDOW_CONCRETE_TYPE
= 5,
97 * Default width and height of ANativeWindow buffers, these are the
98 * dimensions of the window buffers irrespective of the
99 * NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS call and match the native window
100 * size unless overridden by NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS.
102 NATIVE_WINDOW_DEFAULT_WIDTH
= ANATIVEWINDOW_QUERY_DEFAULT_WIDTH
,
103 NATIVE_WINDOW_DEFAULT_HEIGHT
= ANATIVEWINDOW_QUERY_DEFAULT_HEIGHT
,
105 /* see ANativeWindowQuery in vndk/window.h */
106 NATIVE_WINDOW_TRANSFORM_HINT
= ANATIVEWINDOW_QUERY_TRANSFORM_HINT
,
109 * Boolean that indicates whether the consumer is running more than
110 * one buffer behind the producer.
112 NATIVE_WINDOW_CONSUMER_RUNNING_BEHIND
= 9,
115 * The consumer gralloc usage bits currently set by the consumer.
116 * The values are defined in hardware/libhardware/include/gralloc.h.
118 NATIVE_WINDOW_CONSUMER_USAGE_BITS
= 10, /* deprecated */
121 * Transformation that will by applied to buffers by the hwcomposer.
122 * This must not be set or checked by producer endpoints, and will
123 * disable the transform hint set in SurfaceFlinger (see
124 * NATIVE_WINDOW_TRANSFORM_HINT).
127 * Temporary - Please do not use this. This is intended only to be used
128 * by the camera's LEGACY mode.
130 * In situations where a SurfaceFlinger client wishes to set a transform
131 * that is not visible to the producer, and will always be applied in the
132 * hardware composer, the client can set this flag with
133 * native_window_set_buffers_sticky_transform. This can be used to rotate
134 * and flip buffers consumed by hardware composer without actually changing
135 * the aspect ratio of the buffers produced.
137 NATIVE_WINDOW_STICKY_TRANSFORM
= 11,
140 * The default data space for the buffers as set by the consumer.
141 * The values are defined in graphics.h.
143 NATIVE_WINDOW_DEFAULT_DATASPACE
= 12,
145 /* see ANativeWindowQuery in vndk/window.h */
146 NATIVE_WINDOW_BUFFER_AGE
= ANATIVEWINDOW_QUERY_BUFFER_AGE
,
149 * Returns the duration of the last dequeueBuffer call in microseconds
151 NATIVE_WINDOW_LAST_DEQUEUE_DURATION
= 14,
154 * Returns the duration of the last queueBuffer call in microseconds
156 NATIVE_WINDOW_LAST_QUEUE_DURATION
= 15,
159 * Returns the number of image layers that the ANativeWindow buffer
160 * contains. By default this is 1, unless a buffer is explicitly allocated
161 * to contain multiple layers.
163 NATIVE_WINDOW_LAYER_COUNT
= 16,
166 * Returns 1 if the native window is valid, 0 otherwise. native window is valid
167 * if it is safe (i.e. no crash will occur) to call any method on it.
169 NATIVE_WINDOW_IS_VALID
= 17,
172 * Returns 1 if NATIVE_WINDOW_GET_FRAME_TIMESTAMPS will return display
173 * present info, 0 if it won't.
175 NATIVE_WINDOW_FRAME_TIMESTAMPS_SUPPORTS_PRESENT
= 18,
178 * The consumer end is capable of handling protected buffers, i.e. buffer
179 * with GRALLOC_USAGE_PROTECTED usage bits on.
181 NATIVE_WINDOW_CONSUMER_IS_PROTECTED
= 19,
184 * Returns data space for the buffers.
186 NATIVE_WINDOW_DATASPACE
= 20,
189 * Returns maxBufferCount set by BufferQueueConsumer
191 NATIVE_WINDOW_MAX_BUFFER_COUNT
= 21,
194 /* Valid operations for the (*perform)() hook.
196 * Values marked as 'deprecated' are supported, but have been superceded by
197 * other functionality.
199 * Values marked as 'private' should be considered private to the framework.
200 * HAL implementation code with access to an ANativeWindow should not use these,
201 * as it may not interact properly with the framework's use of the
206 NATIVE_WINDOW_SET_USAGE
= 0, /* deprecated */
207 NATIVE_WINDOW_CONNECT
= 1, /* deprecated */
208 NATIVE_WINDOW_DISCONNECT
= 2, /* deprecated */
209 NATIVE_WINDOW_SET_CROP
= 3, /* private */
210 NATIVE_WINDOW_SET_BUFFER_COUNT
= 4,
211 NATIVE_WINDOW_SET_BUFFERS_GEOMETRY
= 5, /* deprecated */
212 NATIVE_WINDOW_SET_BUFFERS_TRANSFORM
= 6,
213 NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP
= 7,
214 NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS
= 8,
215 NATIVE_WINDOW_SET_BUFFERS_FORMAT
= 9,
216 NATIVE_WINDOW_SET_SCALING_MODE
= 10, /* private */
217 NATIVE_WINDOW_LOCK
= 11, /* private */
218 NATIVE_WINDOW_UNLOCK_AND_POST
= 12, /* private */
219 NATIVE_WINDOW_API_CONNECT
= 13, /* private */
220 NATIVE_WINDOW_API_DISCONNECT
= 14, /* private */
221 NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS
= 15, /* private */
222 NATIVE_WINDOW_SET_POST_TRANSFORM_CROP
= 16, /* deprecated, unimplemented */
223 NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM
= 17, /* private */
224 NATIVE_WINDOW_SET_SIDEBAND_STREAM
= 18,
225 NATIVE_WINDOW_SET_BUFFERS_DATASPACE
= 19,
226 NATIVE_WINDOW_SET_SURFACE_DAMAGE
= 20, /* private */
227 NATIVE_WINDOW_SET_SHARED_BUFFER_MODE
= 21,
228 NATIVE_WINDOW_SET_AUTO_REFRESH
= 22,
229 NATIVE_WINDOW_GET_REFRESH_CYCLE_DURATION
= 23,
230 NATIVE_WINDOW_GET_NEXT_FRAME_ID
= 24,
231 NATIVE_WINDOW_ENABLE_FRAME_TIMESTAMPS
= 25,
232 NATIVE_WINDOW_GET_COMPOSITOR_TIMING
= 26,
233 NATIVE_WINDOW_GET_FRAME_TIMESTAMPS
= 27,
234 NATIVE_WINDOW_GET_WIDE_COLOR_SUPPORT
= 28,
235 NATIVE_WINDOW_GET_HDR_SUPPORT
= 29,
236 NATIVE_WINDOW_SET_USAGE64
= 30,
237 NATIVE_WINDOW_GET_CONSUMER_USAGE64
= 31,
238 NATIVE_WINDOW_SET_BUFFERS_SMPTE2086_METADATA
= 32,
239 NATIVE_WINDOW_SET_BUFFERS_CTA861_3_METADATA
= 33,
240 NATIVE_WINDOW_SET_BUFFERS_HDR10_PLUS_METADATA
= 34,
244 /* parameter for NATIVE_WINDOW_[API_][DIS]CONNECT */
246 /* Buffers will be queued by EGL via eglSwapBuffers after being filled using
249 NATIVE_WINDOW_API_EGL
= 1,
251 /* Buffers will be queued after being filled using the CPU
253 NATIVE_WINDOW_API_CPU
= 2,
255 /* Buffers will be queued by Stagefright after being filled by a video
256 * decoder. The video decoder can either be a software or hardware decoder.
258 NATIVE_WINDOW_API_MEDIA
= 3,
260 /* Buffers will be queued by the the camera HAL.
262 NATIVE_WINDOW_API_CAMERA
= 4,
265 /* parameter for NATIVE_WINDOW_SET_BUFFERS_TRANSFORM */
267 /* flip source image horizontally */
268 NATIVE_WINDOW_TRANSFORM_FLIP_H
= HAL_TRANSFORM_FLIP_H
,
269 /* flip source image vertically */
270 NATIVE_WINDOW_TRANSFORM_FLIP_V
= HAL_TRANSFORM_FLIP_V
,
271 /* rotate source image 90 degrees clock-wise, and is applied after TRANSFORM_FLIP_{H|V} */
272 NATIVE_WINDOW_TRANSFORM_ROT_90
= HAL_TRANSFORM_ROT_90
,
273 /* rotate source image 180 degrees */
274 NATIVE_WINDOW_TRANSFORM_ROT_180
= HAL_TRANSFORM_ROT_180
,
275 /* rotate source image 270 degrees clock-wise */
276 NATIVE_WINDOW_TRANSFORM_ROT_270
= HAL_TRANSFORM_ROT_270
,
277 /* transforms source by the inverse transform of the screen it is displayed onto. This
278 * transform is applied last */
279 NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY
= 0x08
282 /* parameter for NATIVE_WINDOW_SET_SCALING_MODE
283 * keep in sync with Surface.java in frameworks/base */
285 /* the window content is not updated (frozen) until a buffer of
286 * the window size is received (enqueued)
288 NATIVE_WINDOW_SCALING_MODE_FREEZE
= 0,
289 /* the buffer is scaled in both dimensions to match the window size */
290 NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW
= 1,
291 /* the buffer is scaled uniformly such that the smaller dimension
292 * of the buffer matches the window size (cropping in the process)
294 NATIVE_WINDOW_SCALING_MODE_SCALE_CROP
= 2,
295 /* the window is clipped to the size of the buffer's crop rectangle; pixels
296 * outside the crop rectangle are treated as if they are completely
299 NATIVE_WINDOW_SCALING_MODE_NO_SCALE_CROP
= 3,
302 /* values returned by the NATIVE_WINDOW_CONCRETE_TYPE query */
304 NATIVE_WINDOW_FRAMEBUFFER
= 0, /* FramebufferNativeWindow */
305 NATIVE_WINDOW_SURFACE
= 1, /* Surface */
308 /* parameter for NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP
310 * Special timestamp value to indicate that timestamps should be auto-generated
311 * by the native window when queueBuffer is called. This is equal to INT64_MIN,
312 * defined directly to avoid problems with C99/C++ inclusion of stdint.h.
314 static const int64_t NATIVE_WINDOW_TIMESTAMP_AUTO
= (-9223372036854775807LL-1);
316 /* parameter for NATIVE_WINDOW_GET_FRAME_TIMESTAMPS
318 * Special timestamp value to indicate the timestamps aren't yet known or
319 * that they are invalid.
321 static const int64_t NATIVE_WINDOW_TIMESTAMP_PENDING
= -2;
322 static const int64_t NATIVE_WINDOW_TIMESTAMP_INVALID
= -1;
328 : flags(0), minSwapInterval(0), maxSwapInterval(0), xdpi(0), ydpi(0)
330 common
.magic
= ANDROID_NATIVE_WINDOW_MAGIC
;
331 common
.version
= sizeof(ANativeWindow
);
332 memset(common
.reserved
, 0, sizeof(common
.reserved
));
335 /* Implement the methods that sp<ANativeWindow> expects so that it
336 can be used to automatically refcount ANativeWindow's. */
337 void incStrong(const void* /*id*/) const {
338 common
.incRef(const_cast<android_native_base_t
*>(&common
));
340 void decStrong(const void* /*id*/) const {
341 common
.decRef(const_cast<android_native_base_t
*>(&common
));
345 struct android_native_base_t common
;
347 /* flags describing some attributes of this surface or its updater */
348 const uint32_t flags
;
350 /* min swap interval supported by this updated */
351 const int minSwapInterval
;
353 /* max swap interval supported by this updated */
354 const int maxSwapInterval
;
356 /* horizontal and vertical resolution in DPI */
360 /* Some storage reserved for the OEM's driver. */
364 * Set the swap interval for this surface.
366 * Returns 0 on success or -errno on error.
368 int (*setSwapInterval
)(struct ANativeWindow
* window
,
372 * Hook called by EGL to acquire a buffer. After this call, the buffer
373 * is not locked, so its content cannot be modified. This call may block if
374 * no buffers are available.
376 * The window holds a reference to the buffer between dequeueBuffer and
377 * either queueBuffer or cancelBuffer, so clients only need their own
378 * reference if they might use the buffer after queueing or canceling it.
379 * Holding a reference to a buffer after queueing or canceling it is only
380 * allowed if a specific buffer count has been set.
382 * Returns 0 on success or -errno on error.
384 * XXX: This function is deprecated. It will continue to work for some
385 * time for binary compatibility, but the new dequeueBuffer function that
386 * outputs a fence file descriptor should be used in its place.
388 int (*dequeueBuffer_DEPRECATED
)(struct ANativeWindow
* window
,
389 struct ANativeWindowBuffer
** buffer
);
392 * hook called by EGL to lock a buffer. This MUST be called before modifying
393 * the content of a buffer. The buffer must have been acquired with
394 * dequeueBuffer first.
396 * Returns 0 on success or -errno on error.
398 * XXX: This function is deprecated. It will continue to work for some
399 * time for binary compatibility, but it is essentially a no-op, and calls
400 * to it should be removed.
402 int (*lockBuffer_DEPRECATED
)(struct ANativeWindow
* window
,
403 struct ANativeWindowBuffer
* buffer
);
406 * Hook called by EGL when modifications to the render buffer are done.
407 * This unlocks and post the buffer.
409 * The window holds a reference to the buffer between dequeueBuffer and
410 * either queueBuffer or cancelBuffer, so clients only need their own
411 * reference if they might use the buffer after queueing or canceling it.
412 * Holding a reference to a buffer after queueing or canceling it is only
413 * allowed if a specific buffer count has been set.
415 * Buffers MUST be queued in the same order than they were dequeued.
417 * Returns 0 on success or -errno on error.
419 * XXX: This function is deprecated. It will continue to work for some
420 * time for binary compatibility, but the new queueBuffer function that
421 * takes a fence file descriptor should be used in its place (pass a value
422 * of -1 for the fence file descriptor if there is no valid one to pass).
424 int (*queueBuffer_DEPRECATED
)(struct ANativeWindow
* window
,
425 struct ANativeWindowBuffer
* buffer
);
428 * hook used to retrieve information about the native window.
430 * Returns 0 on success or -errno on error.
432 int (*query
)(const struct ANativeWindow
* window
,
433 int what
, int* value
);
436 * hook used to perform various operations on the surface.
437 * (*perform)() is a generic mechanism to add functionality to
438 * ANativeWindow while keeping backward binary compatibility.
440 * DO NOT CALL THIS HOOK DIRECTLY. Instead, use the helper functions
443 * (*perform)() returns -ENOENT if the 'what' parameter is not supported
444 * by the surface's implementation.
446 * See above for a list of valid operations, such as
447 * NATIVE_WINDOW_SET_USAGE or NATIVE_WINDOW_CONNECT
449 int (*perform
)(struct ANativeWindow
* window
,
450 int operation
, ... );
453 * Hook used to cancel a buffer that has been dequeued.
454 * No synchronization is performed between dequeue() and cancel(), so
455 * either external synchronization is needed, or these functions must be
456 * called from the same thread.
458 * The window holds a reference to the buffer between dequeueBuffer and
459 * either queueBuffer or cancelBuffer, so clients only need their own
460 * reference if they might use the buffer after queueing or canceling it.
461 * Holding a reference to a buffer after queueing or canceling it is only
462 * allowed if a specific buffer count has been set.
464 * XXX: This function is deprecated. It will continue to work for some
465 * time for binary compatibility, but the new cancelBuffer function that
466 * takes a fence file descriptor should be used in its place (pass a value
467 * of -1 for the fence file descriptor if there is no valid one to pass).
469 int (*cancelBuffer_DEPRECATED
)(struct ANativeWindow
* window
,
470 struct ANativeWindowBuffer
* buffer
);
473 * Hook called by EGL to acquire a buffer. This call may block if no
474 * buffers are available.
476 * The window holds a reference to the buffer between dequeueBuffer and
477 * either queueBuffer or cancelBuffer, so clients only need their own
478 * reference if they might use the buffer after queueing or canceling it.
479 * Holding a reference to a buffer after queueing or canceling it is only
480 * allowed if a specific buffer count has been set.
482 * The libsync fence file descriptor returned in the int pointed to by the
483 * fenceFd argument will refer to the fence that must signal before the
484 * dequeued buffer may be written to. A value of -1 indicates that the
485 * caller may access the buffer immediately without waiting on a fence. If
486 * a valid file descriptor is returned (i.e. any value except -1) then the
487 * caller is responsible for closing the file descriptor.
489 * Returns 0 on success or -errno on error.
491 int (*dequeueBuffer
)(struct ANativeWindow
* window
,
492 struct ANativeWindowBuffer
** buffer
, int* fenceFd
);
495 * Hook called by EGL when modifications to the render buffer are done.
496 * This unlocks and post the buffer.
498 * The window holds a reference to the buffer between dequeueBuffer and
499 * either queueBuffer or cancelBuffer, so clients only need their own
500 * reference if they might use the buffer after queueing or canceling it.
501 * Holding a reference to a buffer after queueing or canceling it is only
502 * allowed if a specific buffer count has been set.
504 * The fenceFd argument specifies a libsync fence file descriptor for a
505 * fence that must signal before the buffer can be accessed. If the buffer
506 * can be accessed immediately then a value of -1 should be used. The
507 * caller must not use the file descriptor after it is passed to
508 * queueBuffer, and the ANativeWindow implementation is responsible for
511 * Returns 0 on success or -errno on error.
513 int (*queueBuffer
)(struct ANativeWindow
* window
,
514 struct ANativeWindowBuffer
* buffer
, int fenceFd
);
517 * Hook used to cancel a buffer that has been dequeued.
518 * No synchronization is performed between dequeue() and cancel(), so
519 * either external synchronization is needed, or these functions must be
520 * called from the same thread.
522 * The window holds a reference to the buffer between dequeueBuffer and
523 * either queueBuffer or cancelBuffer, so clients only need their own
524 * reference if they might use the buffer after queueing or canceling it.
525 * Holding a reference to a buffer after queueing or canceling it is only
526 * allowed if a specific buffer count has been set.
528 * The fenceFd argument specifies a libsync fence file decsriptor for a
529 * fence that must signal before the buffer can be accessed. If the buffer
530 * can be accessed immediately then a value of -1 should be used.
532 * Note that if the client has not waited on the fence that was returned
533 * from dequeueBuffer, that same fence should be passed to cancelBuffer to
534 * ensure that future uses of the buffer are preceded by a wait on that
535 * fence. The caller must not use the file descriptor after it is passed
536 * to cancelBuffer, and the ANativeWindow implementation is responsible for
539 * Returns 0 on success or -errno on error.
541 int (*cancelBuffer
)(struct ANativeWindow
* window
,
542 struct ANativeWindowBuffer
* buffer
, int fenceFd
);
545 /* Backwards compatibility: use ANativeWindow (struct ANativeWindow in C).
546 * android_native_window_t is deprecated.
548 typedef struct ANativeWindow android_native_window_t __deprecated
;
551 * native_window_set_usage64(..., usage)
552 * Sets the intended usage flags for the next buffers
553 * acquired with (*lockBuffer)() and on.
555 * Valid usage flags are defined in android/hardware_buffer.h
556 * All AHARDWAREBUFFER_USAGE_* flags can be specified as needed.
558 * Calling this function will usually cause following buffers to be
561 static inline int native_window_set_usage(struct ANativeWindow
* window
, uint64_t usage
) {
562 return window
->perform(window
, NATIVE_WINDOW_SET_USAGE64
, usage
);
565 /* deprecated. Always returns 0. Don't call. */
566 static inline int native_window_connect(
567 struct ANativeWindow
* window __UNUSED
, int api __UNUSED
) __deprecated
;
569 static inline int native_window_connect(
570 struct ANativeWindow
* window __UNUSED
, int api __UNUSED
) {
574 /* deprecated. Always returns 0. Don't call. */
575 static inline int native_window_disconnect(
576 struct ANativeWindow
* window __UNUSED
, int api __UNUSED
) __deprecated
;
578 static inline int native_window_disconnect(
579 struct ANativeWindow
* window __UNUSED
, int api __UNUSED
) {
584 * native_window_set_crop(..., crop)
585 * Sets which region of the next queued buffers needs to be considered.
586 * Depending on the scaling mode, a buffer's crop region is scaled and/or
587 * cropped to match the surface's size. This function sets the crop in
588 * pre-transformed buffer pixel coordinates.
590 * The specified crop region applies to all buffers queued after it is called.
592 * If 'crop' is NULL, subsequently queued buffers won't be cropped.
594 * An error is returned if for instance the crop region is invalid, out of the
595 * buffer's bound or if the window is invalid.
597 static inline int native_window_set_crop(
598 struct ANativeWindow
* window
,
599 android_native_rect_t
const * crop
)
601 return window
->perform(window
, NATIVE_WINDOW_SET_CROP
, crop
);
605 * native_window_set_buffer_count(..., count)
606 * Sets the number of buffers associated with this native window.
608 static inline int native_window_set_buffer_count(
609 struct ANativeWindow
* window
,
612 return window
->perform(window
, NATIVE_WINDOW_SET_BUFFER_COUNT
, bufferCount
);
616 * native_window_set_buffers_geometry(..., int w, int h, int format)
617 * All buffers dequeued after this call will have the dimensions and format
618 * specified. A successful call to this function has the same effect as calling
619 * native_window_set_buffers_size and native_window_set_buffers_format.
621 * XXX: This function is deprecated. The native_window_set_buffers_dimensions
622 * and native_window_set_buffers_format functions should be used instead.
624 static inline int native_window_set_buffers_geometry(
625 struct ANativeWindow
* window
,
626 int w
, int h
, int format
) __deprecated
;
628 static inline int native_window_set_buffers_geometry(
629 struct ANativeWindow
* window
,
630 int w
, int h
, int format
)
632 return window
->perform(window
, NATIVE_WINDOW_SET_BUFFERS_GEOMETRY
,
637 * native_window_set_buffers_dimensions(..., int w, int h)
638 * All buffers dequeued after this call will have the dimensions specified.
639 * In particular, all buffers will have a fixed-size, independent from the
640 * native-window size. They will be scaled according to the scaling mode
641 * (see native_window_set_scaling_mode) upon window composition.
643 * If w and h are 0, the normal behavior is restored. That is, dequeued buffers
644 * following this call will be sized to match the window's size.
646 * Calling this function will reset the window crop to a NULL value, which
647 * disables cropping of the buffers.
649 static inline int native_window_set_buffers_dimensions(
650 struct ANativeWindow
* window
,
653 return window
->perform(window
, NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS
,
658 * native_window_set_buffers_user_dimensions(..., int w, int h)
660 * Sets the user buffer size for the window, which overrides the
661 * window's size. All buffers dequeued after this call will have the
662 * dimensions specified unless overridden by
663 * native_window_set_buffers_dimensions. All buffers will have a
664 * fixed-size, independent from the native-window size. They will be
665 * scaled according to the scaling mode (see
666 * native_window_set_scaling_mode) upon window composition.
668 * If w and h are 0, the normal behavior is restored. That is, the
669 * default buffer size will match the windows's size.
671 * Calling this function will reset the window crop to a NULL value, which
672 * disables cropping of the buffers.
674 static inline int native_window_set_buffers_user_dimensions(
675 struct ANativeWindow
* window
,
678 return window
->perform(window
, NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS
,
683 * native_window_set_buffers_format(..., int format)
684 * All buffers dequeued after this call will have the format specified.
686 * If the specified format is 0, the default buffer format will be used.
688 static inline int native_window_set_buffers_format(
689 struct ANativeWindow
* window
,
692 return window
->perform(window
, NATIVE_WINDOW_SET_BUFFERS_FORMAT
, format
);
696 * native_window_set_buffers_data_space(..., int dataSpace)
697 * All buffers queued after this call will be associated with the dataSpace
698 * parameter specified.
700 * dataSpace specifies additional information about the buffer that's dependent
701 * on the buffer format and the endpoints. For example, it can be used to convey
702 * the color space of the image data in the buffer, or it can be used to
703 * indicate that the buffers contain depth measurement data instead of color
704 * images. The default dataSpace is 0, HAL_DATASPACE_UNKNOWN, unless it has been
705 * overridden by the consumer.
707 static inline int native_window_set_buffers_data_space(
708 struct ANativeWindow
* window
,
709 android_dataspace_t dataSpace
)
711 return window
->perform(window
, NATIVE_WINDOW_SET_BUFFERS_DATASPACE
,
716 * native_window_set_buffers_smpte2086_metadata(..., metadata)
717 * All buffers queued after this call will be associated with the SMPTE
718 * ST.2086 metadata specified.
720 * metadata specifies additional information about the contents of the buffer
721 * that may affect how it's displayed. When it is nullptr, it means no such
722 * information is available. No SMPTE ST.2086 metadata is associated with the
723 * buffers by default.
725 static inline int native_window_set_buffers_smpte2086_metadata(
726 struct ANativeWindow
* window
,
727 const struct android_smpte2086_metadata
* metadata
)
729 return window
->perform(window
, NATIVE_WINDOW_SET_BUFFERS_SMPTE2086_METADATA
,
734 * native_window_set_buffers_cta861_3_metadata(..., metadata)
735 * All buffers queued after this call will be associated with the CTA-861.3
736 * metadata specified.
738 * metadata specifies additional information about the contents of the buffer
739 * that may affect how it's displayed. When it is nullptr, it means no such
740 * information is available. No CTA-861.3 metadata is associated with the
741 * buffers by default.
743 static inline int native_window_set_buffers_cta861_3_metadata(
744 struct ANativeWindow
* window
,
745 const struct android_cta861_3_metadata
* metadata
)
747 return window
->perform(window
, NATIVE_WINDOW_SET_BUFFERS_CTA861_3_METADATA
,
752 * native_window_set_buffers_hdr10_plus_metadata(..., metadata)
753 * All buffers queued after this call will be associated with the
754 * HDR10+ dynamic metadata specified.
756 * metadata specifies additional dynamic information about the
757 * contents of the buffer that may affect how it is displayed. When
758 * it is nullptr, it means no such information is available. No
759 * HDR10+ dynamic emtadata is associated with the buffers by default.
761 * Parameter "size" refers to the length of the metadata blob pointed to
762 * by parameter "data". The metadata blob will adhere to the HDR10+ SEI
765 static inline int native_window_set_buffers_hdr10_plus_metadata(struct ANativeWindow
* window
,
767 const uint8_t* metadata
) {
768 return window
->perform(window
, NATIVE_WINDOW_SET_BUFFERS_HDR10_PLUS_METADATA
, size
,
773 * native_window_set_buffers_transform(..., int transform)
774 * All buffers queued after this call will be displayed transformed according
775 * to the transform parameter specified.
777 static inline int native_window_set_buffers_transform(
778 struct ANativeWindow
* window
,
781 return window
->perform(window
, NATIVE_WINDOW_SET_BUFFERS_TRANSFORM
,
786 * native_window_set_buffers_sticky_transform(..., int transform)
787 * All buffers queued after this call will be displayed transformed according
788 * to the transform parameter specified applied on top of the regular buffer
789 * transform. Setting this transform will disable the transform hint.
791 * Temporary - This is only intended to be used by the LEGACY camera mode, do
792 * not use this for anything else.
794 static inline int native_window_set_buffers_sticky_transform(
795 struct ANativeWindow
* window
,
798 return window
->perform(window
, NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM
,
803 * native_window_set_buffers_timestamp(..., int64_t timestamp)
804 * All buffers queued after this call will be associated with the timestamp
805 * parameter specified. If the timestamp is set to NATIVE_WINDOW_TIMESTAMP_AUTO
806 * (the default), timestamps will be generated automatically when queueBuffer is
807 * called. The timestamp is measured in nanoseconds, and is normally monotonically
808 * increasing. The timestamp should be unaffected by time-of-day adjustments,
809 * and for a camera should be strictly monotonic but for a media player may be
810 * reset when the position is set.
812 static inline int native_window_set_buffers_timestamp(
813 struct ANativeWindow
* window
,
816 return window
->perform(window
, NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP
,
821 * native_window_set_scaling_mode(..., int mode)
822 * All buffers queued after this call will be associated with the scaling mode
825 static inline int native_window_set_scaling_mode(
826 struct ANativeWindow
* window
,
829 return window
->perform(window
, NATIVE_WINDOW_SET_SCALING_MODE
,
834 * native_window_api_connect(..., int api)
835 * connects an API to this window. only one API can be connected at a time.
836 * Returns -EINVAL if for some reason the window cannot be connected, which
837 * can happen if it's connected to some other API.
839 static inline int native_window_api_connect(
840 struct ANativeWindow
* window
, int api
)
842 return window
->perform(window
, NATIVE_WINDOW_API_CONNECT
, api
);
846 * native_window_api_disconnect(..., int api)
847 * disconnect the API from this window.
848 * An error is returned if for instance the window wasn't connected in the
851 static inline int native_window_api_disconnect(
852 struct ANativeWindow
* window
, int api
)
854 return window
->perform(window
, NATIVE_WINDOW_API_DISCONNECT
, api
);
858 * native_window_dequeue_buffer_and_wait(...)
859 * Dequeue a buffer and wait on the fence associated with that buffer. The
860 * buffer may safely be accessed immediately upon this function returning. An
861 * error is returned if either of the dequeue or the wait operations fail.
863 static inline int native_window_dequeue_buffer_and_wait(ANativeWindow
*anw
,
864 struct ANativeWindowBuffer
** anb
) {
865 return anw
->dequeueBuffer_DEPRECATED(anw
, anb
);
869 * native_window_set_sideband_stream(..., native_handle_t*)
870 * Attach a sideband buffer stream to a native window.
872 static inline int native_window_set_sideband_stream(
873 struct ANativeWindow
* window
,
874 native_handle_t
* sidebandHandle
)
876 return window
->perform(window
, NATIVE_WINDOW_SET_SIDEBAND_STREAM
,
881 * native_window_set_surface_damage(..., android_native_rect_t* rects, int numRects)
882 * Set the surface damage (i.e., the region of the surface that has changed
883 * since the previous frame). The damage set by this call will be reset (to the
884 * default of full-surface damage) after calling queue, so this must be called
885 * prior to every frame with damage that does not cover the whole surface if the
886 * caller desires downstream consumers to use this optimization.
888 * The damage region is specified as an array of rectangles, with the important
889 * caveat that the origin of the surface is considered to be the bottom-left
890 * corner, as in OpenGL ES.
892 * If numRects is set to 0, rects may be NULL, and the surface damage will be
893 * set to the full surface (the same as if this function had not been called for
896 static inline int native_window_set_surface_damage(
897 struct ANativeWindow
* window
,
898 const android_native_rect_t
* rects
, size_t numRects
)
900 return window
->perform(window
, NATIVE_WINDOW_SET_SURFACE_DAMAGE
,
905 * native_window_set_shared_buffer_mode(..., bool sharedBufferMode)
906 * Enable/disable shared buffer mode
908 static inline int native_window_set_shared_buffer_mode(
909 struct ANativeWindow
* window
,
910 bool sharedBufferMode
)
912 return window
->perform(window
, NATIVE_WINDOW_SET_SHARED_BUFFER_MODE
,
917 * native_window_set_auto_refresh(..., autoRefresh)
918 * Enable/disable auto refresh when in shared buffer mode
920 static inline int native_window_set_auto_refresh(
921 struct ANativeWindow
* window
,
924 return window
->perform(window
, NATIVE_WINDOW_SET_AUTO_REFRESH
, autoRefresh
);
927 static inline int native_window_get_refresh_cycle_duration(
928 struct ANativeWindow
* window
,
929 int64_t* outRefreshDuration
)
931 return window
->perform(window
, NATIVE_WINDOW_GET_REFRESH_CYCLE_DURATION
,
935 static inline int native_window_get_next_frame_id(
936 struct ANativeWindow
* window
, uint64_t* frameId
)
938 return window
->perform(window
, NATIVE_WINDOW_GET_NEXT_FRAME_ID
, frameId
);
941 static inline int native_window_enable_frame_timestamps(
942 struct ANativeWindow
* window
, bool enable
)
944 return window
->perform(window
, NATIVE_WINDOW_ENABLE_FRAME_TIMESTAMPS
,
948 static inline int native_window_get_compositor_timing(
949 struct ANativeWindow
* window
,
950 int64_t* compositeDeadline
, int64_t* compositeInterval
,
951 int64_t* compositeToPresentLatency
)
953 return window
->perform(window
, NATIVE_WINDOW_GET_COMPOSITOR_TIMING
,
954 compositeDeadline
, compositeInterval
, compositeToPresentLatency
);
957 static inline int native_window_get_frame_timestamps(
958 struct ANativeWindow
* window
, uint64_t frameId
,
959 int64_t* outRequestedPresentTime
, int64_t* outAcquireTime
,
960 int64_t* outLatchTime
, int64_t* outFirstRefreshStartTime
,
961 int64_t* outLastRefreshStartTime
, int64_t* outGpuCompositionDoneTime
,
962 int64_t* outDisplayPresentTime
, int64_t* outDequeueReadyTime
,
963 int64_t* outReleaseTime
)
965 return window
->perform(window
, NATIVE_WINDOW_GET_FRAME_TIMESTAMPS
,
966 frameId
, outRequestedPresentTime
, outAcquireTime
, outLatchTime
,
967 outFirstRefreshStartTime
, outLastRefreshStartTime
,
968 outGpuCompositionDoneTime
, outDisplayPresentTime
,
969 outDequeueReadyTime
, outReleaseTime
);
972 static inline int native_window_get_wide_color_support(
973 struct ANativeWindow
* window
, bool* outSupport
) {
974 return window
->perform(window
, NATIVE_WINDOW_GET_WIDE_COLOR_SUPPORT
,
978 static inline int native_window_get_hdr_support(struct ANativeWindow
* window
,
980 return window
->perform(window
, NATIVE_WINDOW_GET_HDR_SUPPORT
, outSupport
);
983 static inline int native_window_get_consumer_usage(struct ANativeWindow
* window
,
984 uint64_t* outUsage
) {
985 return window
->perform(window
, NATIVE_WINDOW_GET_CONSUMER_USAGE64
, outUsage
);