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
/*****************************************************************************
18
*****************************************************************************
20
**** FOR BUILDING WITH ANDROID NOUGAT (7.0, 7.1) AND BELOW. ****
22
**** THIS FILE EXISTS ONLY FOR BACKWARD SOURCE COMPATIBILITY. ****
24
**** DO NOT ADD TO THIS FILE. ****
26
*****************************************************************************
27
*****************************************************************************/
29
#ifndef SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H
30
#define SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H
32
#include <cutils/native_handle.h>
37
#include <sys/cdefs.h>
38
#include <system/graphics.h>
43
#define __UNUSED __attribute__((__unused__))
46
#define __deprecated __attribute__((__deprecated__))
51
/*****************************************************************************/
53
#define ANDROID_NATIVE_MAKE_CONSTANT(a,b,c,d) \
54
(((unsigned)(a)<<24)|((unsigned)(b)<<16)|((unsigned)(c)<<8)|(unsigned)(d))
56
#define ANDROID_NATIVE_WINDOW_MAGIC \
57
ANDROID_NATIVE_MAKE_CONSTANT('_','w','n','d')
59
#define ANDROID_NATIVE_BUFFER_MAGIC \
60
ANDROID_NATIVE_MAKE_CONSTANT('_','b','f','r')
62
// ---------------------------------------------------------------------------
64
// This #define may be used to conditionally compile device-specific code to
65
// support either the prior ANativeWindow interface, which did not pass libsync
66
// fences around, or the new interface that does. This #define is only present
67
// when the ANativeWindow interface does include libsync support.
68
#define ANDROID_NATIVE_WINDOW_HAS_SYNC 1
70
// ---------------------------------------------------------------------------
72
typedef const native_handle_t* buffer_handle_t;
74
// ---------------------------------------------------------------------------
76
typedef struct android_native_rect_t
82
} android_native_rect_t;
84
// ---------------------------------------------------------------------------
86
typedef struct android_native_base_t
88
/* a magic value defined by the actual EGL native type */
91
/* the sizeof() of the actual EGL native type */
96
/* reference-counting interface */
97
void (*incRef)(struct android_native_base_t* base);
98
void (*decRef)(struct android_native_base_t* base);
99
} android_native_base_t;
101
typedef struct ANativeWindowBuffer
104
ANativeWindowBuffer() {
105
common.magic = ANDROID_NATIVE_BUFFER_MAGIC;
106
common.version = sizeof(ANativeWindowBuffer);
107
memset(common.reserved, 0, sizeof(common.reserved));
110
// Implement the methods that sp<ANativeWindowBuffer> expects so that it
111
// can be used to automatically refcount ANativeWindowBuffer's.
112
void incStrong(const void* /*id*/) const {
113
common.incRef(const_cast<android_native_base_t*>(&common));
115
void decStrong(const void* /*id*/) const {
116
common.decRef(const_cast<android_native_base_t*>(&common));
120
struct android_native_base_t common;
130
buffer_handle_t handle;
132
void* reserved_proc[8];
133
} ANativeWindowBuffer_t;
135
// Old typedef for backwards compatibility.
136
typedef ANativeWindowBuffer_t android_native_buffer_t;
138
// ---------------------------------------------------------------------------
140
/* attributes queriable with query() */
142
NATIVE_WINDOW_WIDTH = 0,
143
NATIVE_WINDOW_HEIGHT = 1,
144
NATIVE_WINDOW_FORMAT = 2,
146
/* The minimum number of buffers that must remain un-dequeued after a buffer
147
* has been queued. This value applies only if set_buffer_count was used to
148
* override the number of buffers and if a buffer has since been queued.
149
* Users of the set_buffer_count ANativeWindow method should query this
150
* value before calling set_buffer_count. If it is necessary to have N
151
* buffers simultaneously dequeued as part of the steady-state operation,
152
* and this query returns M then N+M buffers should be requested via
153
* native_window_set_buffer_count.
155
* Note that this value does NOT apply until a single buffer has been
156
* queued. In particular this means that it is possible to:
158
* 1. Query M = min undequeued buffers
159
* 2. Set the buffer count to N + M
160
* 3. Dequeue all N + M buffers
161
* 4. Cancel M buffers
162
* 5. Queue, dequeue, queue, dequeue, ad infinitum
164
NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS = 3,
166
/* Check whether queueBuffer operations on the ANativeWindow send the buffer
167
* to the window compositor. The query sets the returned 'value' argument
168
* to 1 if the ANativeWindow DOES send queued buffers directly to the window
169
* compositor and 0 if the buffers do not go directly to the window
172
* This can be used to determine whether protected buffer content should be
173
* sent to the ANativeWindow. Note, however, that a result of 1 does NOT
174
* indicate that queued buffers will be protected from applications or users
175
* capturing their contents. If that behavior is desired then some other
176
* mechanism (e.g. the GRALLOC_USAGE_PROTECTED flag) should be used in
177
* conjunction with this query.
179
NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER = 4,
181
/* Get the concrete type of a ANativeWindow. See below for the list of
182
* possible return values.
184
* This query should not be used outside the Android framework and will
185
* likely be removed in the near future.
187
NATIVE_WINDOW_CONCRETE_TYPE = 5,
191
* Default width and height of ANativeWindow buffers, these are the
192
* dimensions of the window buffers irrespective of the
193
* NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS call and match the native window
194
* size unless overridden by NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS.
196
NATIVE_WINDOW_DEFAULT_WIDTH = 6,
197
NATIVE_WINDOW_DEFAULT_HEIGHT = 7,
200
* transformation that will most-likely be applied to buffers. This is only
201
* a hint, the actual transformation applied might be different.
205
* The transform hint can be used by a producer, for instance the GLES
206
* driver, to pre-rotate the rendering such that the final transformation
207
* in the composer is identity. This can be very useful when used in
208
* conjunction with the h/w composer HAL, in situations where it
209
* cannot handle arbitrary rotations.
211
* 1. Before dequeuing a buffer, the GL driver (or any other ANW client)
212
* queries the ANW for NATIVE_WINDOW_TRANSFORM_HINT.
214
* 2. The GL driver overrides the width and height of the ANW to
215
* account for NATIVE_WINDOW_TRANSFORM_HINT. This is done by querying
216
* NATIVE_WINDOW_DEFAULT_{WIDTH | HEIGHT}, swapping the dimensions
217
* according to NATIVE_WINDOW_TRANSFORM_HINT and calling
218
* native_window_set_buffers_dimensions().
220
* 3. The GL driver dequeues a buffer of the new pre-rotated size.
222
* 4. The GL driver renders to the buffer such that the image is
223
* already transformed, that is applying NATIVE_WINDOW_TRANSFORM_HINT
226
* 5. The GL driver calls native_window_set_transform to apply
227
* inverse transformation to the buffer it just rendered.
228
* In order to do this, the GL driver needs
229
* to calculate the inverse of NATIVE_WINDOW_TRANSFORM_HINT, this is
232
* int hintTransform, inverseTransform;
233
* query(..., NATIVE_WINDOW_TRANSFORM_HINT, &hintTransform);
234
* inverseTransform = hintTransform;
235
* if (hintTransform & HAL_TRANSFORM_ROT_90)
236
* inverseTransform ^= HAL_TRANSFORM_ROT_180;
239
* 6. The GL driver queues the pre-transformed buffer.
241
* 7. The composer combines the buffer transform with the display
242
* transform. If the buffer transform happens to cancel out the
243
* display transform then no rotation is needed.
246
NATIVE_WINDOW_TRANSFORM_HINT = 8,
249
* Boolean that indicates whether the consumer is running more than
250
* one buffer behind the producer.
252
NATIVE_WINDOW_CONSUMER_RUNNING_BEHIND = 9,
255
* The consumer gralloc usage bits currently set by the consumer.
256
* The values are defined in hardware/libhardware/include/gralloc.h.
258
NATIVE_WINDOW_CONSUMER_USAGE_BITS = 10,
261
* Transformation that will by applied to buffers by the hwcomposer.
262
* This must not be set or checked by producer endpoints, and will
263
* disable the transform hint set in SurfaceFlinger (see
264
* NATIVE_WINDOW_TRANSFORM_HINT).
267
* Temporary - Please do not use this. This is intended only to be used
268
* by the camera's LEGACY mode.
270
* In situations where a SurfaceFlinger client wishes to set a transform
271
* that is not visible to the producer, and will always be applied in the
272
* hardware composer, the client can set this flag with
273
* native_window_set_buffers_sticky_transform. This can be used to rotate
274
* and flip buffers consumed by hardware composer without actually changing
275
* the aspect ratio of the buffers produced.
277
NATIVE_WINDOW_STICKY_TRANSFORM = 11,
280
* The default data space for the buffers as set by the consumer.
281
* The values are defined in graphics.h.
283
NATIVE_WINDOW_DEFAULT_DATASPACE = 12,
286
* Returns the age of the contents of the most recently dequeued buffer as
287
* the number of frames that have elapsed since it was last queued. For
288
* example, if the window is double-buffered, the age of any given buffer in
289
* steady state will be 2. If the dequeued buffer has never been queued, its
292
NATIVE_WINDOW_BUFFER_AGE = 13,
295
/* Valid operations for the (*perform)() hook.
297
* Values marked as 'deprecated' are supported, but have been superceded by
298
* other functionality.
300
* Values marked as 'private' should be considered private to the framework.
301
* HAL implementation code with access to an ANativeWindow should not use these,
302
* as it may not interact properly with the framework's use of the
306
NATIVE_WINDOW_SET_USAGE = 0,
307
NATIVE_WINDOW_CONNECT = 1, /* deprecated */
308
NATIVE_WINDOW_DISCONNECT = 2, /* deprecated */
309
NATIVE_WINDOW_SET_CROP = 3, /* private */
310
NATIVE_WINDOW_SET_BUFFER_COUNT = 4,
311
NATIVE_WINDOW_SET_BUFFERS_GEOMETRY = 5, /* deprecated */
312
NATIVE_WINDOW_SET_BUFFERS_TRANSFORM = 6,
313
NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP = 7,
314
NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS = 8,
315
NATIVE_WINDOW_SET_BUFFERS_FORMAT = 9,
316
NATIVE_WINDOW_SET_SCALING_MODE = 10, /* private */
317
NATIVE_WINDOW_LOCK = 11, /* private */
318
NATIVE_WINDOW_UNLOCK_AND_POST = 12, /* private */
319
NATIVE_WINDOW_API_CONNECT = 13, /* private */
320
NATIVE_WINDOW_API_DISCONNECT = 14, /* private */
321
NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS = 15, /* private */
322
NATIVE_WINDOW_SET_POST_TRANSFORM_CROP = 16, /* private */
323
NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM = 17,/* private */
324
NATIVE_WINDOW_SET_SIDEBAND_STREAM = 18,
325
NATIVE_WINDOW_SET_BUFFERS_DATASPACE = 19,
326
NATIVE_WINDOW_SET_SURFACE_DAMAGE = 20, /* private */
327
NATIVE_WINDOW_SET_SHARED_BUFFER_MODE = 21,
328
NATIVE_WINDOW_SET_AUTO_REFRESH = 22,
331
/* parameter for NATIVE_WINDOW_[API_][DIS]CONNECT */
333
/* Buffers will be queued by EGL via eglSwapBuffers after being filled using
336
NATIVE_WINDOW_API_EGL = 1,
338
/* Buffers will be queued after being filled using the CPU
340
NATIVE_WINDOW_API_CPU = 2,
342
/* Buffers will be queued by Stagefright after being filled by a video
343
* decoder. The video decoder can either be a software or hardware decoder.
345
NATIVE_WINDOW_API_MEDIA = 3,
347
/* Buffers will be queued by the the camera HAL.
349
NATIVE_WINDOW_API_CAMERA = 4,
352
/* parameter for NATIVE_WINDOW_SET_BUFFERS_TRANSFORM */
354
/* flip source image horizontally */
355
NATIVE_WINDOW_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H ,
356
/* flip source image vertically */
357
NATIVE_WINDOW_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V,
358
/* rotate source image 90 degrees clock-wise, and is applied after TRANSFORM_FLIP_{H|V} */
359
NATIVE_WINDOW_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90,
360
/* rotate source image 180 degrees */
361
NATIVE_WINDOW_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180,
362
/* rotate source image 270 degrees clock-wise */
363
NATIVE_WINDOW_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270,
364
/* transforms source by the inverse transform of the screen it is displayed onto. This
365
* transform is applied last */
366
NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY = 0x08
369
/* parameter for NATIVE_WINDOW_SET_SCALING_MODE
370
* keep in sync with Surface.java in frameworks/base */
372
/* the window content is not updated (frozen) until a buffer of
373
* the window size is received (enqueued)
375
NATIVE_WINDOW_SCALING_MODE_FREEZE = 0,
376
/* the buffer is scaled in both dimensions to match the window size */
377
NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW = 1,
378
/* the buffer is scaled uniformly such that the smaller dimension
379
* of the buffer matches the window size (cropping in the process)
381
NATIVE_WINDOW_SCALING_MODE_SCALE_CROP = 2,
382
/* the window is clipped to the size of the buffer's crop rectangle; pixels
383
* outside the crop rectangle are treated as if they are completely
386
NATIVE_WINDOW_SCALING_MODE_NO_SCALE_CROP = 3,
389
/* values returned by the NATIVE_WINDOW_CONCRETE_TYPE query */
391
NATIVE_WINDOW_FRAMEBUFFER = 0, /* FramebufferNativeWindow */
392
NATIVE_WINDOW_SURFACE = 1, /* Surface */
395
/* parameter for NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP
397
* Special timestamp value to indicate that timestamps should be auto-generated
398
* by the native window when queueBuffer is called. This is equal to INT64_MIN,
399
* defined directly to avoid problems with C99/C++ inclusion of stdint.h.
401
static const int64_t NATIVE_WINDOW_TIMESTAMP_AUTO = (-9223372036854775807LL-1);
407
: flags(0), minSwapInterval(0), maxSwapInterval(0), xdpi(0), ydpi(0)
409
common.magic = ANDROID_NATIVE_WINDOW_MAGIC;
410
common.version = sizeof(ANativeWindow);
411
memset(common.reserved, 0, sizeof(common.reserved));
414
/* Implement the methods that sp<ANativeWindow> expects so that it
415
can be used to automatically refcount ANativeWindow's. */
416
void incStrong(const void* /*id*/) const {
417
common.incRef(const_cast<android_native_base_t*>(&common));
419
void decStrong(const void* /*id*/) const {
420
common.decRef(const_cast<android_native_base_t*>(&common));
424
struct android_native_base_t common;
426
/* flags describing some attributes of this surface or its updater */
427
const uint32_t flags;
429
/* min swap interval supported by this updated */
430
const int minSwapInterval;
432
/* max swap interval supported by this updated */
433
const int maxSwapInterval;
435
/* horizontal and vertical resolution in DPI */
439
/* Some storage reserved for the OEM's driver. */
443
* Set the swap interval for this surface.
445
* Returns 0 on success or -errno on error.
447
int (*setSwapInterval)(struct ANativeWindow* window,
451
* Hook called by EGL to acquire a buffer. After this call, the buffer
452
* is not locked, so its content cannot be modified. This call may block if
453
* no buffers are available.
455
* The window holds a reference to the buffer between dequeueBuffer and
456
* either queueBuffer or cancelBuffer, so clients only need their own
457
* reference if they might use the buffer after queueing or canceling it.
458
* Holding a reference to a buffer after queueing or canceling it is only
459
* allowed if a specific buffer count has been set.
461
* Returns 0 on success or -errno on error.
463
* XXX: This function is deprecated. It will continue to work for some
464
* time for binary compatibility, but the new dequeueBuffer function that
465
* outputs a fence file descriptor should be used in its place.
467
int (*dequeueBuffer_DEPRECATED)(struct ANativeWindow* window,
468
struct ANativeWindowBuffer** buffer);
471
* hook called by EGL to lock a buffer. This MUST be called before modifying
472
* the content of a buffer. The buffer must have been acquired with
473
* dequeueBuffer first.
475
* Returns 0 on success or -errno on error.
477
* XXX: This function is deprecated. It will continue to work for some
478
* time for binary compatibility, but it is essentially a no-op, and calls
479
* to it should be removed.
481
int (*lockBuffer_DEPRECATED)(struct ANativeWindow* window,
482
struct ANativeWindowBuffer* buffer);
485
* Hook called by EGL when modifications to the render buffer are done.
486
* This unlocks and post the buffer.
488
* The window holds a reference to the buffer between dequeueBuffer and
489
* either queueBuffer or cancelBuffer, so clients only need their own
490
* reference if they might use the buffer after queueing or canceling it.
491
* Holding a reference to a buffer after queueing or canceling it is only
492
* allowed if a specific buffer count has been set.
494
* Buffers MUST be queued in the same order than they were dequeued.
496
* Returns 0 on success or -errno on error.
498
* XXX: This function is deprecated. It will continue to work for some
499
* time for binary compatibility, but the new queueBuffer function that
500
* takes a fence file descriptor should be used in its place (pass a value
501
* of -1 for the fence file descriptor if there is no valid one to pass).
503
int (*queueBuffer_DEPRECATED)(struct ANativeWindow* window,
504
struct ANativeWindowBuffer* buffer);
507
* hook used to retrieve information about the native window.
509
* Returns 0 on success or -errno on error.
511
int (*query)(const struct ANativeWindow* window,
512
int what, int* value);
515
* hook used to perform various operations on the surface.
516
* (*perform)() is a generic mechanism to add functionality to
517
* ANativeWindow while keeping backward binary compatibility.
519
* DO NOT CALL THIS HOOK DIRECTLY. Instead, use the helper functions
522
* (*perform)() returns -ENOENT if the 'what' parameter is not supported
523
* by the surface's implementation.
525
* See above for a list of valid operations, such as
526
* NATIVE_WINDOW_SET_USAGE or NATIVE_WINDOW_CONNECT
528
int (*perform)(struct ANativeWindow* window,
529
int operation, ... );
532
* Hook used to cancel a buffer that has been dequeued.
533
* No synchronization is performed between dequeue() and cancel(), so
534
* either external synchronization is needed, or these functions must be
535
* called from the same thread.
537
* The window holds a reference to the buffer between dequeueBuffer and
538
* either queueBuffer or cancelBuffer, so clients only need their own
539
* reference if they might use the buffer after queueing or canceling it.
540
* Holding a reference to a buffer after queueing or canceling it is only
541
* allowed if a specific buffer count has been set.
543
* XXX: This function is deprecated. It will continue to work for some
544
* time for binary compatibility, but the new cancelBuffer function that
545
* takes a fence file descriptor should be used in its place (pass a value
546
* of -1 for the fence file descriptor if there is no valid one to pass).
548
int (*cancelBuffer_DEPRECATED)(struct ANativeWindow* window,
549
struct ANativeWindowBuffer* buffer);
552
* Hook called by EGL to acquire a buffer. This call may block if no
553
* buffers are available.
555
* The window holds a reference to the buffer between dequeueBuffer and
556
* either queueBuffer or cancelBuffer, so clients only need their own
557
* reference if they might use the buffer after queueing or canceling it.
558
* Holding a reference to a buffer after queueing or canceling it is only
559
* allowed if a specific buffer count has been set.
561
* The libsync fence file descriptor returned in the int pointed to by the
562
* fenceFd argument will refer to the fence that must signal before the
563
* dequeued buffer may be written to. A value of -1 indicates that the
564
* caller may access the buffer immediately without waiting on a fence. If
565
* a valid file descriptor is returned (i.e. any value except -1) then the
566
* caller is responsible for closing the file descriptor.
568
* Returns 0 on success or -errno on error.
570
int (*dequeueBuffer)(struct ANativeWindow* window,
571
struct ANativeWindowBuffer** buffer, int* fenceFd);
574
* Hook called by EGL when modifications to the render buffer are done.
575
* This unlocks and post the buffer.
577
* The window holds a reference to the buffer between dequeueBuffer and
578
* either queueBuffer or cancelBuffer, so clients only need their own
579
* reference if they might use the buffer after queueing or canceling it.
580
* Holding a reference to a buffer after queueing or canceling it is only
581
* allowed if a specific buffer count has been set.
583
* The fenceFd argument specifies a libsync fence file descriptor for a
584
* fence that must signal before the buffer can be accessed. If the buffer
585
* can be accessed immediately then a value of -1 should be used. The
586
* caller must not use the file descriptor after it is passed to
587
* queueBuffer, and the ANativeWindow implementation is responsible for
590
* Returns 0 on success or -errno on error.
592
int (*queueBuffer)(struct ANativeWindow* window,
593
struct ANativeWindowBuffer* buffer, int fenceFd);
596
* Hook used to cancel a buffer that has been dequeued.
597
* No synchronization is performed between dequeue() and cancel(), so
598
* either external synchronization is needed, or these functions must be
599
* called from the same thread.
601
* The window holds a reference to the buffer between dequeueBuffer and
602
* either queueBuffer or cancelBuffer, so clients only need their own
603
* reference if they might use the buffer after queueing or canceling it.
604
* Holding a reference to a buffer after queueing or canceling it is only
605
* allowed if a specific buffer count has been set.
607
* The fenceFd argument specifies a libsync fence file decsriptor for a
608
* fence that must signal before the buffer can be accessed. If the buffer
609
* can be accessed immediately then a value of -1 should be used.
611
* Note that if the client has not waited on the fence that was returned
612
* from dequeueBuffer, that same fence should be passed to cancelBuffer to
613
* ensure that future uses of the buffer are preceded by a wait on that
614
* fence. The caller must not use the file descriptor after it is passed
615
* to cancelBuffer, and the ANativeWindow implementation is responsible for
618
* Returns 0 on success or -errno on error.
620
int (*cancelBuffer)(struct ANativeWindow* window,
621
struct ANativeWindowBuffer* buffer, int fenceFd);
624
/* Backwards compatibility: use ANativeWindow (struct ANativeWindow in C).
625
* android_native_window_t is deprecated.
627
typedef struct ANativeWindow ANativeWindow;
628
typedef struct ANativeWindow android_native_window_t __deprecated;
631
* native_window_set_usage(..., usage)
632
* Sets the intended usage flags for the next buffers
633
* acquired with (*lockBuffer)() and on.
634
* By default (if this function is never called), a usage of
635
* GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE
637
* Calling this function will usually cause following buffers to be
641
static inline int native_window_set_usage(
642
struct ANativeWindow* window, int usage)
644
return window->perform(window, NATIVE_WINDOW_SET_USAGE, usage);
647
/* deprecated. Always returns 0. Don't call. */
648
static inline int native_window_connect(
649
struct ANativeWindow* window __UNUSED, int api __UNUSED) __deprecated;
651
static inline int native_window_connect(
652
struct ANativeWindow* window __UNUSED, int api __UNUSED) {
656
/* deprecated. Always returns 0. Don't call. */
657
static inline int native_window_disconnect(
658
struct ANativeWindow* window __UNUSED, int api __UNUSED) __deprecated;
660
static inline int native_window_disconnect(
661
struct ANativeWindow* window __UNUSED, int api __UNUSED) {
666
* native_window_set_crop(..., crop)
667
* Sets which region of the next queued buffers needs to be considered.
668
* Depending on the scaling mode, a buffer's crop region is scaled and/or
669
* cropped to match the surface's size. This function sets the crop in
670
* pre-transformed buffer pixel coordinates.
672
* The specified crop region applies to all buffers queued after it is called.
674
* If 'crop' is NULL, subsequently queued buffers won't be cropped.
676
* An error is returned if for instance the crop region is invalid, out of the
677
* buffer's bound or if the window is invalid.
679
static inline int native_window_set_crop(
680
struct ANativeWindow* window,
681
android_native_rect_t const * crop)
683
return window->perform(window, NATIVE_WINDOW_SET_CROP, crop);
687
* native_window_set_post_transform_crop(..., crop)
688
* Sets which region of the next queued buffers needs to be considered.
689
* Depending on the scaling mode, a buffer's crop region is scaled and/or
690
* cropped to match the surface's size. This function sets the crop in
691
* post-transformed pixel coordinates.
693
* The specified crop region applies to all buffers queued after it is called.
695
* If 'crop' is NULL, subsequently queued buffers won't be cropped.
697
* An error is returned if for instance the crop region is invalid, out of the
698
* buffer's bound or if the window is invalid.
700
static inline int native_window_set_post_transform_crop(
701
struct ANativeWindow* window,
702
android_native_rect_t const * crop)
704
return window->perform(window, NATIVE_WINDOW_SET_POST_TRANSFORM_CROP, crop);
708
* native_window_set_active_rect(..., active_rect)
710
* This function is deprecated and will be removed soon. For now it simply
711
* sets the post-transform crop for compatibility while multi-project commits
714
static inline int native_window_set_active_rect(
715
struct ANativeWindow* window,
716
android_native_rect_t const * active_rect) __deprecated;
718
static inline int native_window_set_active_rect(
719
struct ANativeWindow* window,
720
android_native_rect_t const * active_rect)
722
return native_window_set_post_transform_crop(window, active_rect);
726
* native_window_set_buffer_count(..., count)
727
* Sets the number of buffers associated with this native window.
729
static inline int native_window_set_buffer_count(
730
struct ANativeWindow* window,
733
return window->perform(window, NATIVE_WINDOW_SET_BUFFER_COUNT, bufferCount);
737
* native_window_set_buffers_geometry(..., int w, int h, int format)
738
* All buffers dequeued after this call will have the dimensions and format
739
* specified. A successful call to this function has the same effect as calling
740
* native_window_set_buffers_size and native_window_set_buffers_format.
742
* XXX: This function is deprecated. The native_window_set_buffers_dimensions
743
* and native_window_set_buffers_format functions should be used instead.
745
static inline int native_window_set_buffers_geometry(
746
struct ANativeWindow* window,
747
int w, int h, int format) __deprecated;
749
static inline int native_window_set_buffers_geometry(
750
struct ANativeWindow* window,
751
int w, int h, int format)
753
return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_GEOMETRY,
758
* native_window_set_buffers_dimensions(..., int w, int h)
759
* All buffers dequeued after this call will have the dimensions specified.
760
* In particular, all buffers will have a fixed-size, independent from the
761
* native-window size. They will be scaled according to the scaling mode
762
* (see native_window_set_scaling_mode) upon window composition.
764
* If w and h are 0, the normal behavior is restored. That is, dequeued buffers
765
* following this call will be sized to match the window's size.
767
* Calling this function will reset the window crop to a NULL value, which
768
* disables cropping of the buffers.
770
static inline int native_window_set_buffers_dimensions(
771
struct ANativeWindow* window,
774
return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS,
779
* native_window_set_buffers_user_dimensions(..., int w, int h)
781
* Sets the user buffer size for the window, which overrides the
782
* window's size. All buffers dequeued after this call will have the
783
* dimensions specified unless overridden by
784
* native_window_set_buffers_dimensions. All buffers will have a
785
* fixed-size, independent from the native-window size. They will be
786
* scaled according to the scaling mode (see
787
* native_window_set_scaling_mode) upon window composition.
789
* If w and h are 0, the normal behavior is restored. That is, the
790
* default buffer size will match the windows's size.
792
* Calling this function will reset the window crop to a NULL value, which
793
* disables cropping of the buffers.
795
static inline int native_window_set_buffers_user_dimensions(
796
struct ANativeWindow* window,
799
return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS,
804
* native_window_set_buffers_format(..., int format)
805
* All buffers dequeued after this call will have the format specified.
807
* If the specified format is 0, the default buffer format will be used.
809
static inline int native_window_set_buffers_format(
810
struct ANativeWindow* window,
813
return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_FORMAT, format);
817
* native_window_set_buffers_data_space(..., int dataSpace)
818
* All buffers queued after this call will be associated with the dataSpace
819
* parameter specified.
821
* dataSpace specifies additional information about the buffer that's dependent
822
* on the buffer format and the endpoints. For example, it can be used to convey
823
* the color space of the image data in the buffer, or it can be used to
824
* indicate that the buffers contain depth measurement data instead of color
825
* images. The default dataSpace is 0, HAL_DATASPACE_UNKNOWN, unless it has been
826
* overridden by the consumer.
828
static inline int native_window_set_buffers_data_space(
829
struct ANativeWindow* window,
830
android_dataspace_t dataSpace)
832
return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DATASPACE,
837
* native_window_set_buffers_transform(..., int transform)
838
* All buffers queued after this call will be displayed transformed according
839
* to the transform parameter specified.
841
static inline int native_window_set_buffers_transform(
842
struct ANativeWindow* window,
845
return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TRANSFORM,
850
* native_window_set_buffers_sticky_transform(..., int transform)
851
* All buffers queued after this call will be displayed transformed according
852
* to the transform parameter specified applied on top of the regular buffer
853
* transform. Setting this transform will disable the transform hint.
855
* Temporary - This is only intended to be used by the LEGACY camera mode, do
856
* not use this for anything else.
858
static inline int native_window_set_buffers_sticky_transform(
859
struct ANativeWindow* window,
862
return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM,
867
* native_window_set_buffers_timestamp(..., int64_t timestamp)
868
* All buffers queued after this call will be associated with the timestamp
869
* parameter specified. If the timestamp is set to NATIVE_WINDOW_TIMESTAMP_AUTO
870
* (the default), timestamps will be generated automatically when queueBuffer is
871
* called. The timestamp is measured in nanoseconds, and is normally monotonically
872
* increasing. The timestamp should be unaffected by time-of-day adjustments,
873
* and for a camera should be strictly monotonic but for a media player may be
874
* reset when the position is set.
876
static inline int native_window_set_buffers_timestamp(
877
struct ANativeWindow* window,
880
return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP,
885
* native_window_set_scaling_mode(..., int mode)
886
* All buffers queued after this call will be associated with the scaling mode
889
static inline int native_window_set_scaling_mode(
890
struct ANativeWindow* window,
893
return window->perform(window, NATIVE_WINDOW_SET_SCALING_MODE,
898
* native_window_api_connect(..., int api)
899
* connects an API to this window. only one API can be connected at a time.
900
* Returns -EINVAL if for some reason the window cannot be connected, which
901
* can happen if it's connected to some other API.
903
static inline int native_window_api_connect(
904
struct ANativeWindow* window, int api)
906
return window->perform(window, NATIVE_WINDOW_API_CONNECT, api);
910
* native_window_api_disconnect(..., int api)
911
* disconnect the API from this window.
912
* An error is returned if for instance the window wasn't connected in the
915
static inline int native_window_api_disconnect(
916
struct ANativeWindow* window, int api)
918
return window->perform(window, NATIVE_WINDOW_API_DISCONNECT, api);
922
* native_window_dequeue_buffer_and_wait(...)
923
* Dequeue a buffer and wait on the fence associated with that buffer. The
924
* buffer may safely be accessed immediately upon this function returning. An
925
* error is returned if either of the dequeue or the wait operations fail.
927
static inline int native_window_dequeue_buffer_and_wait(ANativeWindow *anw,
928
struct ANativeWindowBuffer** anb) {
929
return anw->dequeueBuffer_DEPRECATED(anw, anb);
933
* native_window_set_sideband_stream(..., native_handle_t*)
934
* Attach a sideband buffer stream to a native window.
936
static inline int native_window_set_sideband_stream(
937
struct ANativeWindow* window,
938
native_handle_t* sidebandHandle)
940
return window->perform(window, NATIVE_WINDOW_SET_SIDEBAND_STREAM,
945
* native_window_set_surface_damage(..., android_native_rect_t* rects, int numRects)
946
* Set the surface damage (i.e., the region of the surface that has changed
947
* since the previous frame). The damage set by this call will be reset (to the
948
* default of full-surface damage) after calling queue, so this must be called
949
* prior to every frame with damage that does not cover the whole surface if the
950
* caller desires downstream consumers to use this optimization.
952
* The damage region is specified as an array of rectangles, with the important
953
* caveat that the origin of the surface is considered to be the bottom-left
954
* corner, as in OpenGL ES.
956
* If numRects is set to 0, rects may be NULL, and the surface damage will be
957
* set to the full surface (the same as if this function had not been called for
960
static inline int native_window_set_surface_damage(
961
struct ANativeWindow* window,
962
const android_native_rect_t* rects, size_t numRects)
964
return window->perform(window, NATIVE_WINDOW_SET_SURFACE_DAMAGE,
969
* native_window_set_shared_buffer_mode(..., bool sharedBufferMode)
970
* Enable/disable shared buffer mode
972
static inline int native_window_set_shared_buffer_mode(
973
struct ANativeWindow* window,
974
bool sharedBufferMode)
976
return window->perform(window, NATIVE_WINDOW_SET_SHARED_BUFFER_MODE,
981
* native_window_set_auto_refresh(..., autoRefresh)
982
* Enable/disable auto refresh when in shared buffer mode
984
static inline int native_window_set_auto_refresh(
985
struct ANativeWindow* window,
988
return window->perform(window, NATIVE_WINDOW_SET_AUTO_REFRESH, autoRefresh);
993
#endif /* SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H */