Path: blob/21.2-virgl/include/android_stub/system/window.h
4547 views
/*1* Copyright (C) 2011 The Android Open Source Project2*3* Licensed under the Apache License, Version 2.0 (the "License");4* you may not use this file except in compliance with the License.5* You may obtain a copy of the License at6*7* http://www.apache.org/licenses/LICENSE-2.08*9* Unless required by applicable law or agreed to in writing, software10* distributed under the License is distributed on an "AS IS" BASIS,11* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12* See the License for the specific language governing permissions and13* limitations under the License.14*/1516/*****************************************************************************17*****************************************************************************18**** ****19**** FOR BUILDING WITH ANDROID NOUGAT (7.0, 7.1) AND BELOW. ****20**** ****21**** THIS FILE EXISTS ONLY FOR BACKWARD SOURCE COMPATIBILITY. ****22**** ****23**** DO NOT ADD TO THIS FILE. ****24**** ****25*****************************************************************************26*****************************************************************************/2728#ifndef SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H29#define SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H3031#include <cutils/native_handle.h>32#include <errno.h>33#include <limits.h>34#include <stdint.h>35#include <string.h>36#include <sys/cdefs.h>37#include <system/graphics.h>38#include <unistd.h>39#include <stdbool.h>4041#ifndef __UNUSED42#define __UNUSED __attribute__((__unused__))43#endif44#ifndef __deprecated45#define __deprecated __attribute__((__deprecated__))46#endif4748__BEGIN_DECLS4950/*****************************************************************************/5152#define ANDROID_NATIVE_MAKE_CONSTANT(a,b,c,d) \53(((unsigned)(a)<<24)|((unsigned)(b)<<16)|((unsigned)(c)<<8)|(unsigned)(d))5455#define ANDROID_NATIVE_WINDOW_MAGIC \56ANDROID_NATIVE_MAKE_CONSTANT('_','w','n','d')5758#define ANDROID_NATIVE_BUFFER_MAGIC \59ANDROID_NATIVE_MAKE_CONSTANT('_','b','f','r')6061// ---------------------------------------------------------------------------6263// This #define may be used to conditionally compile device-specific code to64// support either the prior ANativeWindow interface, which did not pass libsync65// fences around, or the new interface that does. This #define is only present66// when the ANativeWindow interface does include libsync support.67#define ANDROID_NATIVE_WINDOW_HAS_SYNC 16869// ---------------------------------------------------------------------------7071typedef const native_handle_t* buffer_handle_t;7273// ---------------------------------------------------------------------------7475typedef struct android_native_rect_t76{77int32_t left;78int32_t top;79int32_t right;80int32_t bottom;81} android_native_rect_t;8283// ---------------------------------------------------------------------------8485typedef struct android_native_base_t86{87/* a magic value defined by the actual EGL native type */88int magic;8990/* the sizeof() of the actual EGL native type */91int version;9293void* reserved[4];9495/* reference-counting interface */96void (*incRef)(struct android_native_base_t* base);97void (*decRef)(struct android_native_base_t* base);98} android_native_base_t;99100typedef struct ANativeWindowBuffer101{102#ifdef __cplusplus103ANativeWindowBuffer() {104common.magic = ANDROID_NATIVE_BUFFER_MAGIC;105common.version = sizeof(ANativeWindowBuffer);106memset(common.reserved, 0, sizeof(common.reserved));107}108109// Implement the methods that sp<ANativeWindowBuffer> expects so that it110// can be used to automatically refcount ANativeWindowBuffer's.111void incStrong(const void* /*id*/) const {112common.incRef(const_cast<android_native_base_t*>(&common));113}114void decStrong(const void* /*id*/) const {115common.decRef(const_cast<android_native_base_t*>(&common));116}117#endif118119struct android_native_base_t common;120121int width;122int height;123int stride;124int format;125int usage;126127void* reserved[2];128129buffer_handle_t handle;130131void* reserved_proc[8];132} ANativeWindowBuffer_t;133134// Old typedef for backwards compatibility.135typedef ANativeWindowBuffer_t android_native_buffer_t;136137// ---------------------------------------------------------------------------138139/* attributes queriable with query() */140enum {141NATIVE_WINDOW_WIDTH = 0,142NATIVE_WINDOW_HEIGHT = 1,143NATIVE_WINDOW_FORMAT = 2,144145/* The minimum number of buffers that must remain un-dequeued after a buffer146* has been queued. This value applies only if set_buffer_count was used to147* override the number of buffers and if a buffer has since been queued.148* Users of the set_buffer_count ANativeWindow method should query this149* value before calling set_buffer_count. If it is necessary to have N150* buffers simultaneously dequeued as part of the steady-state operation,151* and this query returns M then N+M buffers should be requested via152* native_window_set_buffer_count.153*154* Note that this value does NOT apply until a single buffer has been155* queued. In particular this means that it is possible to:156*157* 1. Query M = min undequeued buffers158* 2. Set the buffer count to N + M159* 3. Dequeue all N + M buffers160* 4. Cancel M buffers161* 5. Queue, dequeue, queue, dequeue, ad infinitum162*/163NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS = 3,164165/* Check whether queueBuffer operations on the ANativeWindow send the buffer166* to the window compositor. The query sets the returned 'value' argument167* to 1 if the ANativeWindow DOES send queued buffers directly to the window168* compositor and 0 if the buffers do not go directly to the window169* compositor.170*171* This can be used to determine whether protected buffer content should be172* sent to the ANativeWindow. Note, however, that a result of 1 does NOT173* indicate that queued buffers will be protected from applications or users174* capturing their contents. If that behavior is desired then some other175* mechanism (e.g. the GRALLOC_USAGE_PROTECTED flag) should be used in176* conjunction with this query.177*/178NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER = 4,179180/* Get the concrete type of a ANativeWindow. See below for the list of181* possible return values.182*183* This query should not be used outside the Android framework and will184* likely be removed in the near future.185*/186NATIVE_WINDOW_CONCRETE_TYPE = 5,187188189/*190* Default width and height of ANativeWindow buffers, these are the191* dimensions of the window buffers irrespective of the192* NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS call and match the native window193* size unless overridden by NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS.194*/195NATIVE_WINDOW_DEFAULT_WIDTH = 6,196NATIVE_WINDOW_DEFAULT_HEIGHT = 7,197198/*199* transformation that will most-likely be applied to buffers. This is only200* a hint, the actual transformation applied might be different.201*202* INTENDED USE:203*204* The transform hint can be used by a producer, for instance the GLES205* driver, to pre-rotate the rendering such that the final transformation206* in the composer is identity. This can be very useful when used in207* conjunction with the h/w composer HAL, in situations where it208* cannot handle arbitrary rotations.209*210* 1. Before dequeuing a buffer, the GL driver (or any other ANW client)211* queries the ANW for NATIVE_WINDOW_TRANSFORM_HINT.212*213* 2. The GL driver overrides the width and height of the ANW to214* account for NATIVE_WINDOW_TRANSFORM_HINT. This is done by querying215* NATIVE_WINDOW_DEFAULT_{WIDTH | HEIGHT}, swapping the dimensions216* according to NATIVE_WINDOW_TRANSFORM_HINT and calling217* native_window_set_buffers_dimensions().218*219* 3. The GL driver dequeues a buffer of the new pre-rotated size.220*221* 4. The GL driver renders to the buffer such that the image is222* already transformed, that is applying NATIVE_WINDOW_TRANSFORM_HINT223* to the rendering.224*225* 5. The GL driver calls native_window_set_transform to apply226* inverse transformation to the buffer it just rendered.227* In order to do this, the GL driver needs228* to calculate the inverse of NATIVE_WINDOW_TRANSFORM_HINT, this is229* done easily:230*231* int hintTransform, inverseTransform;232* query(..., NATIVE_WINDOW_TRANSFORM_HINT, &hintTransform);233* inverseTransform = hintTransform;234* if (hintTransform & HAL_TRANSFORM_ROT_90)235* inverseTransform ^= HAL_TRANSFORM_ROT_180;236*237*238* 6. The GL driver queues the pre-transformed buffer.239*240* 7. The composer combines the buffer transform with the display241* transform. If the buffer transform happens to cancel out the242* display transform then no rotation is needed.243*244*/245NATIVE_WINDOW_TRANSFORM_HINT = 8,246247/*248* Boolean that indicates whether the consumer is running more than249* one buffer behind the producer.250*/251NATIVE_WINDOW_CONSUMER_RUNNING_BEHIND = 9,252253/*254* The consumer gralloc usage bits currently set by the consumer.255* The values are defined in hardware/libhardware/include/gralloc.h.256*/257NATIVE_WINDOW_CONSUMER_USAGE_BITS = 10,258259/**260* Transformation that will by applied to buffers by the hwcomposer.261* This must not be set or checked by producer endpoints, and will262* disable the transform hint set in SurfaceFlinger (see263* NATIVE_WINDOW_TRANSFORM_HINT).264*265* INTENDED USE:266* Temporary - Please do not use this. This is intended only to be used267* by the camera's LEGACY mode.268*269* In situations where a SurfaceFlinger client wishes to set a transform270* that is not visible to the producer, and will always be applied in the271* hardware composer, the client can set this flag with272* native_window_set_buffers_sticky_transform. This can be used to rotate273* and flip buffers consumed by hardware composer without actually changing274* the aspect ratio of the buffers produced.275*/276NATIVE_WINDOW_STICKY_TRANSFORM = 11,277278/**279* The default data space for the buffers as set by the consumer.280* The values are defined in graphics.h.281*/282NATIVE_WINDOW_DEFAULT_DATASPACE = 12,283284/*285* Returns the age of the contents of the most recently dequeued buffer as286* the number of frames that have elapsed since it was last queued. For287* example, if the window is double-buffered, the age of any given buffer in288* steady state will be 2. If the dequeued buffer has never been queued, its289* age will be 0.290*/291NATIVE_WINDOW_BUFFER_AGE = 13,292};293294/* Valid operations for the (*perform)() hook.295*296* Values marked as 'deprecated' are supported, but have been superceded by297* other functionality.298*299* Values marked as 'private' should be considered private to the framework.300* HAL implementation code with access to an ANativeWindow should not use these,301* as it may not interact properly with the framework's use of the302* ANativeWindow.303*/304enum {305NATIVE_WINDOW_SET_USAGE = 0,306NATIVE_WINDOW_CONNECT = 1, /* deprecated */307NATIVE_WINDOW_DISCONNECT = 2, /* deprecated */308NATIVE_WINDOW_SET_CROP = 3, /* private */309NATIVE_WINDOW_SET_BUFFER_COUNT = 4,310NATIVE_WINDOW_SET_BUFFERS_GEOMETRY = 5, /* deprecated */311NATIVE_WINDOW_SET_BUFFERS_TRANSFORM = 6,312NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP = 7,313NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS = 8,314NATIVE_WINDOW_SET_BUFFERS_FORMAT = 9,315NATIVE_WINDOW_SET_SCALING_MODE = 10, /* private */316NATIVE_WINDOW_LOCK = 11, /* private */317NATIVE_WINDOW_UNLOCK_AND_POST = 12, /* private */318NATIVE_WINDOW_API_CONNECT = 13, /* private */319NATIVE_WINDOW_API_DISCONNECT = 14, /* private */320NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS = 15, /* private */321NATIVE_WINDOW_SET_POST_TRANSFORM_CROP = 16, /* private */322NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM = 17,/* private */323NATIVE_WINDOW_SET_SIDEBAND_STREAM = 18,324NATIVE_WINDOW_SET_BUFFERS_DATASPACE = 19,325NATIVE_WINDOW_SET_SURFACE_DAMAGE = 20, /* private */326NATIVE_WINDOW_SET_SHARED_BUFFER_MODE = 21,327NATIVE_WINDOW_SET_AUTO_REFRESH = 22,328};329330/* parameter for NATIVE_WINDOW_[API_][DIS]CONNECT */331enum {332/* Buffers will be queued by EGL via eglSwapBuffers after being filled using333* OpenGL ES.334*/335NATIVE_WINDOW_API_EGL = 1,336337/* Buffers will be queued after being filled using the CPU338*/339NATIVE_WINDOW_API_CPU = 2,340341/* Buffers will be queued by Stagefright after being filled by a video342* decoder. The video decoder can either be a software or hardware decoder.343*/344NATIVE_WINDOW_API_MEDIA = 3,345346/* Buffers will be queued by the the camera HAL.347*/348NATIVE_WINDOW_API_CAMERA = 4,349};350351/* parameter for NATIVE_WINDOW_SET_BUFFERS_TRANSFORM */352enum {353/* flip source image horizontally */354NATIVE_WINDOW_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H ,355/* flip source image vertically */356NATIVE_WINDOW_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V,357/* rotate source image 90 degrees clock-wise, and is applied after TRANSFORM_FLIP_{H|V} */358NATIVE_WINDOW_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90,359/* rotate source image 180 degrees */360NATIVE_WINDOW_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180,361/* rotate source image 270 degrees clock-wise */362NATIVE_WINDOW_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270,363/* transforms source by the inverse transform of the screen it is displayed onto. This364* transform is applied last */365NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY = 0x08366};367368/* parameter for NATIVE_WINDOW_SET_SCALING_MODE369* keep in sync with Surface.java in frameworks/base */370enum {371/* the window content is not updated (frozen) until a buffer of372* the window size is received (enqueued)373*/374NATIVE_WINDOW_SCALING_MODE_FREEZE = 0,375/* the buffer is scaled in both dimensions to match the window size */376NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW = 1,377/* the buffer is scaled uniformly such that the smaller dimension378* of the buffer matches the window size (cropping in the process)379*/380NATIVE_WINDOW_SCALING_MODE_SCALE_CROP = 2,381/* the window is clipped to the size of the buffer's crop rectangle; pixels382* outside the crop rectangle are treated as if they are completely383* transparent.384*/385NATIVE_WINDOW_SCALING_MODE_NO_SCALE_CROP = 3,386};387388/* values returned by the NATIVE_WINDOW_CONCRETE_TYPE query */389enum {390NATIVE_WINDOW_FRAMEBUFFER = 0, /* FramebufferNativeWindow */391NATIVE_WINDOW_SURFACE = 1, /* Surface */392};393394/* parameter for NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP395*396* Special timestamp value to indicate that timestamps should be auto-generated397* by the native window when queueBuffer is called. This is equal to INT64_MIN,398* defined directly to avoid problems with C99/C++ inclusion of stdint.h.399*/400static const int64_t NATIVE_WINDOW_TIMESTAMP_AUTO = (-9223372036854775807LL-1);401402struct ANativeWindow403{404#ifdef __cplusplus405ANativeWindow()406: flags(0), minSwapInterval(0), maxSwapInterval(0), xdpi(0), ydpi(0)407{408common.magic = ANDROID_NATIVE_WINDOW_MAGIC;409common.version = sizeof(ANativeWindow);410memset(common.reserved, 0, sizeof(common.reserved));411}412413/* Implement the methods that sp<ANativeWindow> expects so that it414can be used to automatically refcount ANativeWindow's. */415void incStrong(const void* /*id*/) const {416common.incRef(const_cast<android_native_base_t*>(&common));417}418void decStrong(const void* /*id*/) const {419common.decRef(const_cast<android_native_base_t*>(&common));420}421#endif422423struct android_native_base_t common;424425/* flags describing some attributes of this surface or its updater */426const uint32_t flags;427428/* min swap interval supported by this updated */429const int minSwapInterval;430431/* max swap interval supported by this updated */432const int maxSwapInterval;433434/* horizontal and vertical resolution in DPI */435const float xdpi;436const float ydpi;437438/* Some storage reserved for the OEM's driver. */439intptr_t oem[4];440441/*442* Set the swap interval for this surface.443*444* Returns 0 on success or -errno on error.445*/446int (*setSwapInterval)(struct ANativeWindow* window,447int interval);448449/*450* Hook called by EGL to acquire a buffer. After this call, the buffer451* is not locked, so its content cannot be modified. This call may block if452* no buffers are available.453*454* The window holds a reference to the buffer between dequeueBuffer and455* either queueBuffer or cancelBuffer, so clients only need their own456* reference if they might use the buffer after queueing or canceling it.457* Holding a reference to a buffer after queueing or canceling it is only458* allowed if a specific buffer count has been set.459*460* Returns 0 on success or -errno on error.461*462* XXX: This function is deprecated. It will continue to work for some463* time for binary compatibility, but the new dequeueBuffer function that464* outputs a fence file descriptor should be used in its place.465*/466int (*dequeueBuffer_DEPRECATED)(struct ANativeWindow* window,467struct ANativeWindowBuffer** buffer);468469/*470* hook called by EGL to lock a buffer. This MUST be called before modifying471* the content of a buffer. The buffer must have been acquired with472* dequeueBuffer first.473*474* Returns 0 on success or -errno on error.475*476* XXX: This function is deprecated. It will continue to work for some477* time for binary compatibility, but it is essentially a no-op, and calls478* to it should be removed.479*/480int (*lockBuffer_DEPRECATED)(struct ANativeWindow* window,481struct ANativeWindowBuffer* buffer);482483/*484* Hook called by EGL when modifications to the render buffer are done.485* This unlocks and post the buffer.486*487* The window holds a reference to the buffer between dequeueBuffer and488* either queueBuffer or cancelBuffer, so clients only need their own489* reference if they might use the buffer after queueing or canceling it.490* Holding a reference to a buffer after queueing or canceling it is only491* allowed if a specific buffer count has been set.492*493* Buffers MUST be queued in the same order than they were dequeued.494*495* Returns 0 on success or -errno on error.496*497* XXX: This function is deprecated. It will continue to work for some498* time for binary compatibility, but the new queueBuffer function that499* takes a fence file descriptor should be used in its place (pass a value500* of -1 for the fence file descriptor if there is no valid one to pass).501*/502int (*queueBuffer_DEPRECATED)(struct ANativeWindow* window,503struct ANativeWindowBuffer* buffer);504505/*506* hook used to retrieve information about the native window.507*508* Returns 0 on success or -errno on error.509*/510int (*query)(const struct ANativeWindow* window,511int what, int* value);512513/*514* hook used to perform various operations on the surface.515* (*perform)() is a generic mechanism to add functionality to516* ANativeWindow while keeping backward binary compatibility.517*518* DO NOT CALL THIS HOOK DIRECTLY. Instead, use the helper functions519* defined below.520*521* (*perform)() returns -ENOENT if the 'what' parameter is not supported522* by the surface's implementation.523*524* See above for a list of valid operations, such as525* NATIVE_WINDOW_SET_USAGE or NATIVE_WINDOW_CONNECT526*/527int (*perform)(struct ANativeWindow* window,528int operation, ... );529530/*531* Hook used to cancel a buffer that has been dequeued.532* No synchronization is performed between dequeue() and cancel(), so533* either external synchronization is needed, or these functions must be534* called from the same thread.535*536* The window holds a reference to the buffer between dequeueBuffer and537* either queueBuffer or cancelBuffer, so clients only need their own538* reference if they might use the buffer after queueing or canceling it.539* Holding a reference to a buffer after queueing or canceling it is only540* allowed if a specific buffer count has been set.541*542* XXX: This function is deprecated. It will continue to work for some543* time for binary compatibility, but the new cancelBuffer function that544* takes a fence file descriptor should be used in its place (pass a value545* of -1 for the fence file descriptor if there is no valid one to pass).546*/547int (*cancelBuffer_DEPRECATED)(struct ANativeWindow* window,548struct ANativeWindowBuffer* buffer);549550/*551* Hook called by EGL to acquire a buffer. This call may block if no552* buffers are available.553*554* The window holds a reference to the buffer between dequeueBuffer and555* either queueBuffer or cancelBuffer, so clients only need their own556* reference if they might use the buffer after queueing or canceling it.557* Holding a reference to a buffer after queueing or canceling it is only558* allowed if a specific buffer count has been set.559*560* The libsync fence file descriptor returned in the int pointed to by the561* fenceFd argument will refer to the fence that must signal before the562* dequeued buffer may be written to. A value of -1 indicates that the563* caller may access the buffer immediately without waiting on a fence. If564* a valid file descriptor is returned (i.e. any value except -1) then the565* caller is responsible for closing the file descriptor.566*567* Returns 0 on success or -errno on error.568*/569int (*dequeueBuffer)(struct ANativeWindow* window,570struct ANativeWindowBuffer** buffer, int* fenceFd);571572/*573* Hook called by EGL when modifications to the render buffer are done.574* This unlocks and post the buffer.575*576* The window holds a reference to the buffer between dequeueBuffer and577* either queueBuffer or cancelBuffer, so clients only need their own578* reference if they might use the buffer after queueing or canceling it.579* Holding a reference to a buffer after queueing or canceling it is only580* allowed if a specific buffer count has been set.581*582* The fenceFd argument specifies a libsync fence file descriptor for a583* fence that must signal before the buffer can be accessed. If the buffer584* can be accessed immediately then a value of -1 should be used. The585* caller must not use the file descriptor after it is passed to586* queueBuffer, and the ANativeWindow implementation is responsible for587* closing it.588*589* Returns 0 on success or -errno on error.590*/591int (*queueBuffer)(struct ANativeWindow* window,592struct ANativeWindowBuffer* buffer, int fenceFd);593594/*595* Hook used to cancel a buffer that has been dequeued.596* No synchronization is performed between dequeue() and cancel(), so597* either external synchronization is needed, or these functions must be598* called from the same thread.599*600* The window holds a reference to the buffer between dequeueBuffer and601* either queueBuffer or cancelBuffer, so clients only need their own602* reference if they might use the buffer after queueing or canceling it.603* Holding a reference to a buffer after queueing or canceling it is only604* allowed if a specific buffer count has been set.605*606* The fenceFd argument specifies a libsync fence file decsriptor for a607* fence that must signal before the buffer can be accessed. If the buffer608* can be accessed immediately then a value of -1 should be used.609*610* Note that if the client has not waited on the fence that was returned611* from dequeueBuffer, that same fence should be passed to cancelBuffer to612* ensure that future uses of the buffer are preceded by a wait on that613* fence. The caller must not use the file descriptor after it is passed614* to cancelBuffer, and the ANativeWindow implementation is responsible for615* closing it.616*617* Returns 0 on success or -errno on error.618*/619int (*cancelBuffer)(struct ANativeWindow* window,620struct ANativeWindowBuffer* buffer, int fenceFd);621};622623/* Backwards compatibility: use ANativeWindow (struct ANativeWindow in C).624* android_native_window_t is deprecated.625*/626typedef struct ANativeWindow ANativeWindow;627typedef struct ANativeWindow android_native_window_t __deprecated;628629/*630* native_window_set_usage(..., usage)631* Sets the intended usage flags for the next buffers632* acquired with (*lockBuffer)() and on.633* By default (if this function is never called), a usage of634* GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE635* is assumed.636* Calling this function will usually cause following buffers to be637* reallocated.638*/639640static inline int native_window_set_usage(641struct ANativeWindow* window, int usage)642{643return window->perform(window, NATIVE_WINDOW_SET_USAGE, usage);644}645646/* deprecated. Always returns 0. Don't call. */647static inline int native_window_connect(648struct ANativeWindow* window __UNUSED, int api __UNUSED) __deprecated;649650static inline int native_window_connect(651struct ANativeWindow* window __UNUSED, int api __UNUSED) {652return 0;653}654655/* deprecated. Always returns 0. Don't call. */656static inline int native_window_disconnect(657struct ANativeWindow* window __UNUSED, int api __UNUSED) __deprecated;658659static inline int native_window_disconnect(660struct ANativeWindow* window __UNUSED, int api __UNUSED) {661return 0;662}663664/*665* native_window_set_crop(..., crop)666* Sets which region of the next queued buffers needs to be considered.667* Depending on the scaling mode, a buffer's crop region is scaled and/or668* cropped to match the surface's size. This function sets the crop in669* pre-transformed buffer pixel coordinates.670*671* The specified crop region applies to all buffers queued after it is called.672*673* If 'crop' is NULL, subsequently queued buffers won't be cropped.674*675* An error is returned if for instance the crop region is invalid, out of the676* buffer's bound or if the window is invalid.677*/678static inline int native_window_set_crop(679struct ANativeWindow* window,680android_native_rect_t const * crop)681{682return window->perform(window, NATIVE_WINDOW_SET_CROP, crop);683}684685/*686* native_window_set_post_transform_crop(..., crop)687* Sets which region of the next queued buffers needs to be considered.688* Depending on the scaling mode, a buffer's crop region is scaled and/or689* cropped to match the surface's size. This function sets the crop in690* post-transformed pixel coordinates.691*692* The specified crop region applies to all buffers queued after it is called.693*694* If 'crop' is NULL, subsequently queued buffers won't be cropped.695*696* An error is returned if for instance the crop region is invalid, out of the697* buffer's bound or if the window is invalid.698*/699static inline int native_window_set_post_transform_crop(700struct ANativeWindow* window,701android_native_rect_t const * crop)702{703return window->perform(window, NATIVE_WINDOW_SET_POST_TRANSFORM_CROP, crop);704}705706/*707* native_window_set_active_rect(..., active_rect)708*709* This function is deprecated and will be removed soon. For now it simply710* sets the post-transform crop for compatibility while multi-project commits711* get checked.712*/713static inline int native_window_set_active_rect(714struct ANativeWindow* window,715android_native_rect_t const * active_rect) __deprecated;716717static inline int native_window_set_active_rect(718struct ANativeWindow* window,719android_native_rect_t const * active_rect)720{721return native_window_set_post_transform_crop(window, active_rect);722}723724/*725* native_window_set_buffer_count(..., count)726* Sets the number of buffers associated with this native window.727*/728static inline int native_window_set_buffer_count(729struct ANativeWindow* window,730size_t bufferCount)731{732return window->perform(window, NATIVE_WINDOW_SET_BUFFER_COUNT, bufferCount);733}734735/*736* native_window_set_buffers_geometry(..., int w, int h, int format)737* All buffers dequeued after this call will have the dimensions and format738* specified. A successful call to this function has the same effect as calling739* native_window_set_buffers_size and native_window_set_buffers_format.740*741* XXX: This function is deprecated. The native_window_set_buffers_dimensions742* and native_window_set_buffers_format functions should be used instead.743*/744static inline int native_window_set_buffers_geometry(745struct ANativeWindow* window,746int w, int h, int format) __deprecated;747748static inline int native_window_set_buffers_geometry(749struct ANativeWindow* window,750int w, int h, int format)751{752return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_GEOMETRY,753w, h, format);754}755756/*757* native_window_set_buffers_dimensions(..., int w, int h)758* All buffers dequeued after this call will have the dimensions specified.759* In particular, all buffers will have a fixed-size, independent from the760* native-window size. They will be scaled according to the scaling mode761* (see native_window_set_scaling_mode) upon window composition.762*763* If w and h are 0, the normal behavior is restored. That is, dequeued buffers764* following this call will be sized to match the window's size.765*766* Calling this function will reset the window crop to a NULL value, which767* disables cropping of the buffers.768*/769static inline int native_window_set_buffers_dimensions(770struct ANativeWindow* window,771int w, int h)772{773return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS,774w, h);775}776777/*778* native_window_set_buffers_user_dimensions(..., int w, int h)779*780* Sets the user buffer size for the window, which overrides the781* window's size. All buffers dequeued after this call will have the782* dimensions specified unless overridden by783* native_window_set_buffers_dimensions. All buffers will have a784* fixed-size, independent from the native-window size. They will be785* scaled according to the scaling mode (see786* native_window_set_scaling_mode) upon window composition.787*788* If w and h are 0, the normal behavior is restored. That is, the789* default buffer size will match the windows's size.790*791* Calling this function will reset the window crop to a NULL value, which792* disables cropping of the buffers.793*/794static inline int native_window_set_buffers_user_dimensions(795struct ANativeWindow* window,796int w, int h)797{798return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS,799w, h);800}801802/*803* native_window_set_buffers_format(..., int format)804* All buffers dequeued after this call will have the format specified.805*806* If the specified format is 0, the default buffer format will be used.807*/808static inline int native_window_set_buffers_format(809struct ANativeWindow* window,810int format)811{812return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_FORMAT, format);813}814815/*816* native_window_set_buffers_data_space(..., int dataSpace)817* All buffers queued after this call will be associated with the dataSpace818* parameter specified.819*820* dataSpace specifies additional information about the buffer that's dependent821* on the buffer format and the endpoints. For example, it can be used to convey822* the color space of the image data in the buffer, or it can be used to823* indicate that the buffers contain depth measurement data instead of color824* images. The default dataSpace is 0, HAL_DATASPACE_UNKNOWN, unless it has been825* overridden by the consumer.826*/827static inline int native_window_set_buffers_data_space(828struct ANativeWindow* window,829android_dataspace_t dataSpace)830{831return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DATASPACE,832dataSpace);833}834835/*836* native_window_set_buffers_transform(..., int transform)837* All buffers queued after this call will be displayed transformed according838* to the transform parameter specified.839*/840static inline int native_window_set_buffers_transform(841struct ANativeWindow* window,842int transform)843{844return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TRANSFORM,845transform);846}847848/*849* native_window_set_buffers_sticky_transform(..., int transform)850* All buffers queued after this call will be displayed transformed according851* to the transform parameter specified applied on top of the regular buffer852* transform. Setting this transform will disable the transform hint.853*854* Temporary - This is only intended to be used by the LEGACY camera mode, do855* not use this for anything else.856*/857static inline int native_window_set_buffers_sticky_transform(858struct ANativeWindow* window,859int transform)860{861return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM,862transform);863}864865/*866* native_window_set_buffers_timestamp(..., int64_t timestamp)867* All buffers queued after this call will be associated with the timestamp868* parameter specified. If the timestamp is set to NATIVE_WINDOW_TIMESTAMP_AUTO869* (the default), timestamps will be generated automatically when queueBuffer is870* called. The timestamp is measured in nanoseconds, and is normally monotonically871* increasing. The timestamp should be unaffected by time-of-day adjustments,872* and for a camera should be strictly monotonic but for a media player may be873* reset when the position is set.874*/875static inline int native_window_set_buffers_timestamp(876struct ANativeWindow* window,877int64_t timestamp)878{879return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP,880timestamp);881}882883/*884* native_window_set_scaling_mode(..., int mode)885* All buffers queued after this call will be associated with the scaling mode886* specified.887*/888static inline int native_window_set_scaling_mode(889struct ANativeWindow* window,890int mode)891{892return window->perform(window, NATIVE_WINDOW_SET_SCALING_MODE,893mode);894}895896/*897* native_window_api_connect(..., int api)898* connects an API to this window. only one API can be connected at a time.899* Returns -EINVAL if for some reason the window cannot be connected, which900* can happen if it's connected to some other API.901*/902static inline int native_window_api_connect(903struct ANativeWindow* window, int api)904{905return window->perform(window, NATIVE_WINDOW_API_CONNECT, api);906}907908/*909* native_window_api_disconnect(..., int api)910* disconnect the API from this window.911* An error is returned if for instance the window wasn't connected in the912* first place.913*/914static inline int native_window_api_disconnect(915struct ANativeWindow* window, int api)916{917return window->perform(window, NATIVE_WINDOW_API_DISCONNECT, api);918}919920/*921* native_window_dequeue_buffer_and_wait(...)922* Dequeue a buffer and wait on the fence associated with that buffer. The923* buffer may safely be accessed immediately upon this function returning. An924* error is returned if either of the dequeue or the wait operations fail.925*/926static inline int native_window_dequeue_buffer_and_wait(ANativeWindow *anw,927struct ANativeWindowBuffer** anb) {928return anw->dequeueBuffer_DEPRECATED(anw, anb);929}930931/*932* native_window_set_sideband_stream(..., native_handle_t*)933* Attach a sideband buffer stream to a native window.934*/935static inline int native_window_set_sideband_stream(936struct ANativeWindow* window,937native_handle_t* sidebandHandle)938{939return window->perform(window, NATIVE_WINDOW_SET_SIDEBAND_STREAM,940sidebandHandle);941}942943/*944* native_window_set_surface_damage(..., android_native_rect_t* rects, int numRects)945* Set the surface damage (i.e., the region of the surface that has changed946* since the previous frame). The damage set by this call will be reset (to the947* default of full-surface damage) after calling queue, so this must be called948* prior to every frame with damage that does not cover the whole surface if the949* caller desires downstream consumers to use this optimization.950*951* The damage region is specified as an array of rectangles, with the important952* caveat that the origin of the surface is considered to be the bottom-left953* corner, as in OpenGL ES.954*955* If numRects is set to 0, rects may be NULL, and the surface damage will be956* set to the full surface (the same as if this function had not been called for957* this frame).958*/959static inline int native_window_set_surface_damage(960struct ANativeWindow* window,961const android_native_rect_t* rects, size_t numRects)962{963return window->perform(window, NATIVE_WINDOW_SET_SURFACE_DAMAGE,964rects, numRects);965}966967/*968* native_window_set_shared_buffer_mode(..., bool sharedBufferMode)969* Enable/disable shared buffer mode970*/971static inline int native_window_set_shared_buffer_mode(972struct ANativeWindow* window,973bool sharedBufferMode)974{975return window->perform(window, NATIVE_WINDOW_SET_SHARED_BUFFER_MODE,976sharedBufferMode);977}978979/*980* native_window_set_auto_refresh(..., autoRefresh)981* Enable/disable auto refresh when in shared buffer mode982*/983static inline int native_window_set_auto_refresh(984struct ANativeWindow* window,985bool autoRefresh)986{987return window->perform(window, NATIVE_WINDOW_SET_AUTO_REFRESH, autoRefresh);988}989990__END_DECLS991992#endif /* SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H */993994995