michael@0: /* michael@0: * Copyright (C) 2011 The Android Open Source Project michael@0: * michael@0: * Licensed under the Apache License, Version 2.0 (the "License"); michael@0: * you may not use this file except in compliance with the License. michael@0: * You may obtain a copy of the License at michael@0: * michael@0: * http://www.apache.org/licenses/LICENSE-2.0 michael@0: * michael@0: * Unless required by applicable law or agreed to in writing, software michael@0: * distributed under the License is distributed on an "AS IS" BASIS, michael@0: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. michael@0: * See the License for the specific language governing permissions and michael@0: * limitations under the License. michael@0: */ michael@0: michael@0: #ifndef SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H michael@0: #define SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H michael@0: michael@0: #include michael@0: #include michael@0: #include michael@0: #include michael@0: michael@0: __BEGIN_DECLS michael@0: michael@0: /*****************************************************************************/ michael@0: michael@0: #define ANDROID_NATIVE_MAKE_CONSTANT(a,b,c,d) \ michael@0: (((unsigned)(a)<<24)|((unsigned)(b)<<16)|((unsigned)(c)<<8)|(unsigned)(d)) michael@0: michael@0: #define ANDROID_NATIVE_WINDOW_MAGIC \ michael@0: ANDROID_NATIVE_MAKE_CONSTANT('_','w','n','d') michael@0: michael@0: #define ANDROID_NATIVE_BUFFER_MAGIC \ michael@0: ANDROID_NATIVE_MAKE_CONSTANT('_','b','f','r') michael@0: michael@0: // --------------------------------------------------------------------------- michael@0: michael@0: typedef const native_handle_t* buffer_handle_t; michael@0: michael@0: // --------------------------------------------------------------------------- michael@0: michael@0: typedef struct android_native_rect_t michael@0: { michael@0: int32_t left; michael@0: int32_t top; michael@0: int32_t right; michael@0: int32_t bottom; michael@0: } android_native_rect_t; michael@0: michael@0: // --------------------------------------------------------------------------- michael@0: michael@0: typedef struct android_native_base_t michael@0: { michael@0: /* a magic value defined by the actual EGL native type */ michael@0: int magic; michael@0: michael@0: /* the sizeof() of the actual EGL native type */ michael@0: int version; michael@0: michael@0: void* reserved[4]; michael@0: michael@0: /* reference-counting interface */ michael@0: void (*incRef)(struct android_native_base_t* base); michael@0: void (*decRef)(struct android_native_base_t* base); michael@0: } android_native_base_t; michael@0: michael@0: typedef struct ANativeWindowBuffer michael@0: { michael@0: #ifdef __cplusplus michael@0: ANativeWindowBuffer() { michael@0: common.magic = ANDROID_NATIVE_BUFFER_MAGIC; michael@0: common.version = sizeof(ANativeWindowBuffer); michael@0: memset(common.reserved, 0, sizeof(common.reserved)); michael@0: } michael@0: michael@0: // Implement the methods that sp expects so that it michael@0: // can be used to automatically refcount ANativeWindowBuffer's. michael@0: void incStrong(const void* id) const { michael@0: common.incRef(const_cast(&common)); michael@0: } michael@0: void decStrong(const void* id) const { michael@0: common.decRef(const_cast(&common)); michael@0: } michael@0: #endif michael@0: michael@0: struct android_native_base_t common; michael@0: michael@0: int width; michael@0: int height; michael@0: int stride; michael@0: int format; michael@0: int usage; michael@0: michael@0: void* reserved[2]; michael@0: michael@0: buffer_handle_t handle; michael@0: michael@0: void* reserved_proc[8]; michael@0: } ANativeWindowBuffer_t; michael@0: michael@0: // Old typedef for backwards compatibility. michael@0: typedef ANativeWindowBuffer_t android_native_buffer_t; michael@0: michael@0: // --------------------------------------------------------------------------- michael@0: michael@0: /* attributes queriable with query() */ michael@0: enum { michael@0: NATIVE_WINDOW_WIDTH = 0, michael@0: NATIVE_WINDOW_HEIGHT = 1, michael@0: NATIVE_WINDOW_FORMAT = 2, michael@0: michael@0: /* The minimum number of buffers that must remain un-dequeued after a buffer michael@0: * has been queued. This value applies only if set_buffer_count was used to michael@0: * override the number of buffers and if a buffer has since been queued. michael@0: * Users of the set_buffer_count ANativeWindow method should query this michael@0: * value before calling set_buffer_count. If it is necessary to have N michael@0: * buffers simultaneously dequeued as part of the steady-state operation, michael@0: * and this query returns M then N+M buffers should be requested via michael@0: * native_window_set_buffer_count. michael@0: * michael@0: * Note that this value does NOT apply until a single buffer has been michael@0: * queued. In particular this means that it is possible to: michael@0: * michael@0: * 1. Query M = min undequeued buffers michael@0: * 2. Set the buffer count to N + M michael@0: * 3. Dequeue all N + M buffers michael@0: * 4. Cancel M buffers michael@0: * 5. Queue, dequeue, queue, dequeue, ad infinitum michael@0: */ michael@0: NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS = 3, michael@0: michael@0: /* Check whether queueBuffer operations on the ANativeWindow send the buffer michael@0: * to the window compositor. The query sets the returned 'value' argument michael@0: * to 1 if the ANativeWindow DOES send queued buffers directly to the window michael@0: * compositor and 0 if the buffers do not go directly to the window michael@0: * compositor. michael@0: * michael@0: * This can be used to determine whether protected buffer content should be michael@0: * sent to the ANativeWindow. Note, however, that a result of 1 does NOT michael@0: * indicate that queued buffers will be protected from applications or users michael@0: * capturing their contents. If that behavior is desired then some other michael@0: * mechanism (e.g. the GRALLOC_USAGE_PROTECTED flag) should be used in michael@0: * conjunction with this query. michael@0: */ michael@0: NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER = 4, michael@0: michael@0: /* Get the concrete type of a ANativeWindow. See below for the list of michael@0: * possible return values. michael@0: * michael@0: * This query should not be used outside the Android framework and will michael@0: * likely be removed in the near future. michael@0: */ michael@0: NATIVE_WINDOW_CONCRETE_TYPE = 5, michael@0: michael@0: michael@0: /* michael@0: * Default width and height of the ANativeWindow, these are the dimensions michael@0: * of the window irrespective of the NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS michael@0: * call. michael@0: */ michael@0: NATIVE_WINDOW_DEFAULT_WIDTH = 6, michael@0: NATIVE_WINDOW_DEFAULT_HEIGHT = 7, michael@0: michael@0: /* michael@0: * transformation that will most-likely be applied to buffers. This is only michael@0: * a hint, the actual transformation applied might be different. michael@0: * michael@0: * INTENDED USE: michael@0: * michael@0: * The transform hint can be used by a producer, for instance the GLES michael@0: * driver, to pre-rotate the rendering such that the final transformation michael@0: * in the composer is identity. This can be very useful when used in michael@0: * conjunction with the h/w composer HAL, in situations where it michael@0: * cannot handle arbitrary rotations. michael@0: * michael@0: * 1. Before dequeuing a buffer, the GL driver (or any other ANW client) michael@0: * queries the ANW for NATIVE_WINDOW_TRANSFORM_HINT. michael@0: * michael@0: * 2. The GL driver overrides the width and height of the ANW to michael@0: * account for NATIVE_WINDOW_TRANSFORM_HINT. This is done by querying michael@0: * NATIVE_WINDOW_DEFAULT_{WIDTH | HEIGHT}, swapping the dimensions michael@0: * according to NATIVE_WINDOW_TRANSFORM_HINT and calling michael@0: * native_window_set_buffers_dimensions(). michael@0: * michael@0: * 3. The GL driver dequeues a buffer of the new pre-rotated size. michael@0: * michael@0: * 4. The GL driver renders to the buffer such that the image is michael@0: * already transformed, that is applying NATIVE_WINDOW_TRANSFORM_HINT michael@0: * to the rendering. michael@0: * michael@0: * 5. The GL driver calls native_window_set_transform to apply michael@0: * inverse transformation to the buffer it just rendered. michael@0: * In order to do this, the GL driver needs michael@0: * to calculate the inverse of NATIVE_WINDOW_TRANSFORM_HINT, this is michael@0: * done easily: michael@0: * michael@0: * int hintTransform, inverseTransform; michael@0: * query(..., NATIVE_WINDOW_TRANSFORM_HINT, &hintTransform); michael@0: * inverseTransform = hintTransform; michael@0: * if (hintTransform & HAL_TRANSFORM_ROT_90) michael@0: * inverseTransform ^= HAL_TRANSFORM_ROT_180; michael@0: * michael@0: * michael@0: * 6. The GL driver queues the pre-transformed buffer. michael@0: * michael@0: * 7. The composer combines the buffer transform with the display michael@0: * transform. If the buffer transform happens to cancel out the michael@0: * display transform then no rotation is needed. michael@0: * michael@0: */ michael@0: NATIVE_WINDOW_TRANSFORM_HINT = 8, michael@0: }; michael@0: michael@0: /* valid operations for the (*perform)() hook */ michael@0: enum { michael@0: NATIVE_WINDOW_SET_USAGE = 0, michael@0: NATIVE_WINDOW_CONNECT = 1, /* deprecated */ michael@0: NATIVE_WINDOW_DISCONNECT = 2, /* deprecated */ michael@0: NATIVE_WINDOW_SET_CROP = 3, michael@0: NATIVE_WINDOW_SET_BUFFER_COUNT = 4, michael@0: NATIVE_WINDOW_SET_BUFFERS_GEOMETRY = 5, /* deprecated */ michael@0: NATIVE_WINDOW_SET_BUFFERS_TRANSFORM = 6, michael@0: NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP = 7, michael@0: NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS = 8, michael@0: NATIVE_WINDOW_SET_BUFFERS_FORMAT = 9, michael@0: NATIVE_WINDOW_SET_SCALING_MODE = 10, michael@0: NATIVE_WINDOW_LOCK = 11, /* private */ michael@0: NATIVE_WINDOW_UNLOCK_AND_POST = 12, /* private */ michael@0: NATIVE_WINDOW_API_CONNECT = 13, /* private */ michael@0: NATIVE_WINDOW_API_DISCONNECT = 14, /* private */ michael@0: }; michael@0: michael@0: /* parameter for NATIVE_WINDOW_[API_][DIS]CONNECT */ michael@0: enum { michael@0: /* Buffers will be queued by EGL via eglSwapBuffers after being filled using michael@0: * OpenGL ES. michael@0: */ michael@0: NATIVE_WINDOW_API_EGL = 1, michael@0: michael@0: /* Buffers will be queued after being filled using the CPU michael@0: */ michael@0: NATIVE_WINDOW_API_CPU = 2, michael@0: michael@0: /* Buffers will be queued by Stagefright after being filled by a video michael@0: * decoder. The video decoder can either be a software or hardware decoder. michael@0: */ michael@0: NATIVE_WINDOW_API_MEDIA = 3, michael@0: michael@0: /* Buffers will be queued by the the camera HAL. michael@0: */ michael@0: NATIVE_WINDOW_API_CAMERA = 4, michael@0: }; michael@0: michael@0: /* parameter for NATIVE_WINDOW_SET_BUFFERS_TRANSFORM */ michael@0: enum { michael@0: /* flip source image horizontally */ michael@0: NATIVE_WINDOW_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H , michael@0: /* flip source image vertically */ michael@0: NATIVE_WINDOW_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V, michael@0: /* rotate source image 90 degrees clock-wise */ michael@0: NATIVE_WINDOW_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90, michael@0: /* rotate source image 180 degrees */ michael@0: NATIVE_WINDOW_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180, michael@0: /* rotate source image 270 degrees clock-wise */ michael@0: NATIVE_WINDOW_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270, michael@0: }; michael@0: michael@0: /* parameter for NATIVE_WINDOW_SET_SCALING_MODE */ michael@0: enum { michael@0: /* the window content is not updated (frozen) until a buffer of michael@0: * the window size is received (enqueued) michael@0: */ michael@0: NATIVE_WINDOW_SCALING_MODE_FREEZE = 0, michael@0: /* the buffer is scaled in both dimensions to match the window size */ michael@0: NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW = 1, michael@0: }; michael@0: michael@0: /* values returned by the NATIVE_WINDOW_CONCRETE_TYPE query */ michael@0: enum { michael@0: NATIVE_WINDOW_FRAMEBUFFER = 0, /* FramebufferNativeWindow */ michael@0: NATIVE_WINDOW_SURFACE = 1, /* Surface */ michael@0: NATIVE_WINDOW_SURFACE_TEXTURE_CLIENT = 2, /* SurfaceTextureClient */ michael@0: }; michael@0: michael@0: /* parameter for NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP michael@0: * michael@0: * Special timestamp value to indicate that timestamps should be auto-generated michael@0: * by the native window when queueBuffer is called. This is equal to INT64_MIN, michael@0: * defined directly to avoid problems with C99/C++ inclusion of stdint.h. michael@0: */ michael@0: static const int64_t NATIVE_WINDOW_TIMESTAMP_AUTO = (-9223372036854775807LL-1); michael@0: michael@0: struct ANativeWindow michael@0: { michael@0: #ifdef __cplusplus michael@0: ANativeWindow() michael@0: : flags(0), minSwapInterval(0), maxSwapInterval(0), xdpi(0), ydpi(0) michael@0: { michael@0: common.magic = ANDROID_NATIVE_WINDOW_MAGIC; michael@0: common.version = sizeof(ANativeWindow); michael@0: memset(common.reserved, 0, sizeof(common.reserved)); michael@0: } michael@0: michael@0: /* Implement the methods that sp expects so that it michael@0: can be used to automatically refcount ANativeWindow's. */ michael@0: void incStrong(const void* id) const { michael@0: common.incRef(const_cast(&common)); michael@0: } michael@0: void decStrong(const void* id) const { michael@0: common.decRef(const_cast(&common)); michael@0: } michael@0: #endif michael@0: michael@0: struct android_native_base_t common; michael@0: michael@0: /* flags describing some attributes of this surface or its updater */ michael@0: const uint32_t flags; michael@0: michael@0: /* min swap interval supported by this updated */ michael@0: const int minSwapInterval; michael@0: michael@0: /* max swap interval supported by this updated */ michael@0: const int maxSwapInterval; michael@0: michael@0: /* horizontal and vertical resolution in DPI */ michael@0: const float xdpi; michael@0: const float ydpi; michael@0: michael@0: /* Some storage reserved for the OEM's driver. */ michael@0: intptr_t oem[4]; michael@0: michael@0: /* michael@0: * Set the swap interval for this surface. michael@0: * michael@0: * Returns 0 on success or -errno on error. michael@0: */ michael@0: int (*setSwapInterval)(struct ANativeWindow* window, michael@0: int interval); michael@0: michael@0: /* michael@0: * Hook called by EGL to acquire a buffer. After this call, the buffer michael@0: * is not locked, so its content cannot be modified. This call may block if michael@0: * no buffers are available. michael@0: * michael@0: * The window holds a reference to the buffer between dequeueBuffer and michael@0: * either queueBuffer or cancelBuffer, so clients only need their own michael@0: * reference if they might use the buffer after queueing or canceling it. michael@0: * Holding a reference to a buffer after queueing or canceling it is only michael@0: * allowed if a specific buffer count has been set. michael@0: * michael@0: * Returns 0 on success or -errno on error. michael@0: */ michael@0: int (*dequeueBuffer)(struct ANativeWindow* window, michael@0: struct ANativeWindowBuffer** buffer); michael@0: michael@0: /* michael@0: * hook called by EGL to lock a buffer. This MUST be called before modifying michael@0: * the content of a buffer. The buffer must have been acquired with michael@0: * dequeueBuffer first. michael@0: * michael@0: * Returns 0 on success or -errno on error. michael@0: */ michael@0: int (*lockBuffer)(struct ANativeWindow* window, michael@0: struct ANativeWindowBuffer* buffer); michael@0: /* michael@0: * Hook called by EGL when modifications to the render buffer are done. michael@0: * This unlocks and post the buffer. michael@0: * michael@0: * The window holds a reference to the buffer between dequeueBuffer and michael@0: * either queueBuffer or cancelBuffer, so clients only need their own michael@0: * reference if they might use the buffer after queueing or canceling it. michael@0: * Holding a reference to a buffer after queueing or canceling it is only michael@0: * allowed if a specific buffer count has been set. michael@0: * michael@0: * Buffers MUST be queued in the same order than they were dequeued. michael@0: * michael@0: * Returns 0 on success or -errno on error. michael@0: */ michael@0: int (*queueBuffer)(struct ANativeWindow* window, michael@0: struct ANativeWindowBuffer* buffer); michael@0: michael@0: /* michael@0: * hook used to retrieve information about the native window. michael@0: * michael@0: * Returns 0 on success or -errno on error. michael@0: */ michael@0: int (*query)(const struct ANativeWindow* window, michael@0: int what, int* value); michael@0: michael@0: /* michael@0: * hook used to perform various operations on the surface. michael@0: * (*perform)() is a generic mechanism to add functionality to michael@0: * ANativeWindow while keeping backward binary compatibility. michael@0: * michael@0: * DO NOT CALL THIS HOOK DIRECTLY. Instead, use the helper functions michael@0: * defined below. michael@0: * michael@0: * (*perform)() returns -ENOENT if the 'what' parameter is not supported michael@0: * by the surface's implementation. michael@0: * michael@0: * The valid operations are: michael@0: * NATIVE_WINDOW_SET_USAGE michael@0: * NATIVE_WINDOW_CONNECT (deprecated) michael@0: * NATIVE_WINDOW_DISCONNECT (deprecated) michael@0: * NATIVE_WINDOW_SET_CROP michael@0: * NATIVE_WINDOW_SET_BUFFER_COUNT michael@0: * NATIVE_WINDOW_SET_BUFFERS_GEOMETRY (deprecated) michael@0: * NATIVE_WINDOW_SET_BUFFERS_TRANSFORM michael@0: * NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP michael@0: * NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS michael@0: * NATIVE_WINDOW_SET_BUFFERS_FORMAT michael@0: * NATIVE_WINDOW_SET_SCALING_MODE michael@0: * NATIVE_WINDOW_LOCK (private) michael@0: * NATIVE_WINDOW_UNLOCK_AND_POST (private) michael@0: * NATIVE_WINDOW_API_CONNECT (private) michael@0: * NATIVE_WINDOW_API_DISCONNECT (private) michael@0: * michael@0: */ michael@0: michael@0: int (*perform)(struct ANativeWindow* window, michael@0: int operation, ... ); michael@0: michael@0: /* michael@0: * Hook used to cancel a buffer that has been dequeued. michael@0: * No synchronization is performed between dequeue() and cancel(), so michael@0: * either external synchronization is needed, or these functions must be michael@0: * called from the same thread. michael@0: * michael@0: * The window holds a reference to the buffer between dequeueBuffer and michael@0: * either queueBuffer or cancelBuffer, so clients only need their own michael@0: * reference if they might use the buffer after queueing or canceling it. michael@0: * Holding a reference to a buffer after queueing or canceling it is only michael@0: * allowed if a specific buffer count has been set. michael@0: */ michael@0: int (*cancelBuffer)(struct ANativeWindow* window, michael@0: struct ANativeWindowBuffer* buffer); michael@0: michael@0: michael@0: void* reserved_proc[2]; michael@0: }; michael@0: michael@0: /* Backwards compatibility: use ANativeWindow (struct ANativeWindow in C). michael@0: * android_native_window_t is deprecated. michael@0: */ michael@0: typedef struct ANativeWindow ANativeWindow; michael@0: typedef struct ANativeWindow android_native_window_t; michael@0: michael@0: /* michael@0: * native_window_set_usage(..., usage) michael@0: * Sets the intended usage flags for the next buffers michael@0: * acquired with (*lockBuffer)() and on. michael@0: * By default (if this function is never called), a usage of michael@0: * GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE michael@0: * is assumed. michael@0: * Calling this function will usually cause following buffers to be michael@0: * reallocated. michael@0: */ michael@0: michael@0: static inline int native_window_set_usage( michael@0: struct ANativeWindow* window, int usage) michael@0: { michael@0: return window->perform(window, NATIVE_WINDOW_SET_USAGE, usage); michael@0: } michael@0: michael@0: /* deprecated. Always returns 0. Don't call. */ michael@0: static inline int native_window_connect( michael@0: struct ANativeWindow* window, int api) { michael@0: return 0; michael@0: } michael@0: michael@0: /* deprecated. Always returns 0. Don't call. */ michael@0: static inline int native_window_disconnect( michael@0: struct ANativeWindow* window, int api) { michael@0: return 0; michael@0: } michael@0: michael@0: /* michael@0: * native_window_set_crop(..., crop) michael@0: * Sets which region of the next queued buffers needs to be considered. michael@0: * A buffer's crop region is scaled to match the surface's size. michael@0: * michael@0: * The specified crop region applies to all buffers queued after it is called. michael@0: * michael@0: * if 'crop' is NULL, subsequently queued buffers won't be cropped. michael@0: * michael@0: * An error is returned if for instance the crop region is invalid, michael@0: * out of the buffer's bound or if the window is invalid. michael@0: */ michael@0: static inline int native_window_set_crop( michael@0: struct ANativeWindow* window, michael@0: android_native_rect_t const * crop) michael@0: { michael@0: return window->perform(window, NATIVE_WINDOW_SET_CROP, crop); michael@0: } michael@0: michael@0: /* michael@0: * native_window_set_buffer_count(..., count) michael@0: * Sets the number of buffers associated with this native window. michael@0: */ michael@0: static inline int native_window_set_buffer_count( michael@0: struct ANativeWindow* window, michael@0: size_t bufferCount) michael@0: { michael@0: return window->perform(window, NATIVE_WINDOW_SET_BUFFER_COUNT, bufferCount); michael@0: } michael@0: michael@0: /* michael@0: * native_window_set_buffers_geometry(..., int w, int h, int format) michael@0: * All buffers dequeued after this call will have the dimensions and format michael@0: * specified. A successful call to this function has the same effect as calling michael@0: * native_window_set_buffers_size and native_window_set_buffers_format. michael@0: * michael@0: * XXX: This function is deprecated. The native_window_set_buffers_dimensions michael@0: * and native_window_set_buffers_format functions should be used instead. michael@0: */ michael@0: static inline int native_window_set_buffers_geometry( michael@0: struct ANativeWindow* window, michael@0: int w, int h, int format) michael@0: { michael@0: return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_GEOMETRY, michael@0: w, h, format); michael@0: } michael@0: michael@0: /* michael@0: * native_window_set_buffers_dimensions(..., int w, int h) michael@0: * All buffers dequeued after this call will have the dimensions specified. michael@0: * In particular, all buffers will have a fixed-size, independent form the michael@0: * native-window size. They will be scaled according to the scaling mode michael@0: * (see native_window_set_scaling_mode) upon window composition. michael@0: * michael@0: * If w and h are 0, the normal behavior is restored. That is, dequeued buffers michael@0: * following this call will be sized to match the window's size. michael@0: * michael@0: * Calling this function will reset the window crop to a NULL value, which michael@0: * disables cropping of the buffers. michael@0: */ michael@0: static inline int native_window_set_buffers_dimensions( michael@0: struct ANativeWindow* window, michael@0: int w, int h) michael@0: { michael@0: return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS, michael@0: w, h); michael@0: } michael@0: michael@0: /* michael@0: * native_window_set_buffers_format(..., int format) michael@0: * All buffers dequeued after this call will have the format specified. michael@0: * michael@0: * If the specified format is 0, the default buffer format will be used. michael@0: */ michael@0: static inline int native_window_set_buffers_format( michael@0: struct ANativeWindow* window, michael@0: int format) michael@0: { michael@0: return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_FORMAT, format); michael@0: } michael@0: michael@0: /* michael@0: * native_window_set_buffers_transform(..., int transform) michael@0: * All buffers queued after this call will be displayed transformed according michael@0: * to the transform parameter specified. michael@0: */ michael@0: static inline int native_window_set_buffers_transform( michael@0: struct ANativeWindow* window, michael@0: int transform) michael@0: { michael@0: return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TRANSFORM, michael@0: transform); michael@0: } michael@0: michael@0: /* michael@0: * native_window_set_buffers_timestamp(..., int64_t timestamp) michael@0: * All buffers queued after this call will be associated with the timestamp michael@0: * parameter specified. If the timestamp is set to NATIVE_WINDOW_TIMESTAMP_AUTO michael@0: * (the default), timestamps will be generated automatically when queueBuffer is michael@0: * called. The timestamp is measured in nanoseconds, and is normally monotonically michael@0: * increasing. The timestamp should be unaffected by time-of-day adjustments, michael@0: * and for a camera should be strictly monotonic but for a media player may be michael@0: * reset when the position is set. michael@0: */ michael@0: static inline int native_window_set_buffers_timestamp( michael@0: struct ANativeWindow* window, michael@0: int64_t timestamp) michael@0: { michael@0: return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP, michael@0: timestamp); michael@0: } michael@0: michael@0: /* michael@0: * native_window_set_scaling_mode(..., int mode) michael@0: * All buffers queued after this call will be associated with the scaling mode michael@0: * specified. michael@0: */ michael@0: static inline int native_window_set_scaling_mode( michael@0: struct ANativeWindow* window, michael@0: int mode) michael@0: { michael@0: return window->perform(window, NATIVE_WINDOW_SET_SCALING_MODE, michael@0: mode); michael@0: } michael@0: michael@0: michael@0: /* michael@0: * native_window_api_connect(..., int api) michael@0: * connects an API to this window. only one API can be connected at a time. michael@0: * Returns -EINVAL if for some reason the window cannot be connected, which michael@0: * can happen if it's connected to some other API. michael@0: */ michael@0: static inline int native_window_api_connect( michael@0: struct ANativeWindow* window, int api) michael@0: { michael@0: return window->perform(window, NATIVE_WINDOW_API_CONNECT, api); michael@0: } michael@0: michael@0: /* michael@0: * native_window_api_disconnect(..., int api) michael@0: * disconnect the API from this window. michael@0: * An error is returned if for instance the window wasn't connected in the michael@0: * first place. michael@0: */ michael@0: static inline int native_window_api_disconnect( michael@0: struct ANativeWindow* window, int api) michael@0: { michael@0: return window->perform(window, NATIVE_WINDOW_API_DISCONNECT, api); michael@0: } michael@0: michael@0: michael@0: __END_DECLS michael@0: michael@0: #endif /* SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H */