| Mathias Agopian | a6c0e20 | 2017-03-20 15:48:44 -0700 | [diff] [blame] | 1 | /* | 
 | 2 |  * Copyright (C) 2011 The Android Open Source Project | 
 | 3 |  * | 
 | 4 |  * Licensed under the Apache License, Version 2.0 (the "License"); | 
 | 5 |  * you may not use this file except in compliance with the License. | 
 | 6 |  * You may obtain a copy of the License at | 
 | 7 |  * | 
 | 8 |  *      http://www.apache.org/licenses/LICENSE-2.0 | 
 | 9 |  * | 
 | 10 |  * Unless required by applicable law or agreed to in writing, software | 
 | 11 |  * distributed under the License is distributed on an "AS IS" BASIS, | 
 | 12 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
 | 13 |  * See the License for the specific language governing permissions and | 
 | 14 |  * limitations under the License. | 
 | 15 |  */ | 
 | 16 |  | 
 | 17 | /************************************************************************************************* | 
 | 18 |  * | 
 | 19 |  * IMPORTANT: | 
 | 20 |  * | 
 | 21 |  * There is an old copy of this file in system/core/include/system/window.h, which exists only | 
 | 22 |  * for backward source compatibility. | 
 | 23 |  * But there are binaries out there as well, so this version of window.h must stay binary | 
 | 24 |  * backward compatible with the one found in system/core. | 
 | 25 |  * | 
 | 26 |  * | 
 | 27 |  * Source compatibility is also required for now, because this is how we're handling the | 
 | 28 |  * transition from system/core/include (global include path) to nativewindow/include. | 
 | 29 |  * | 
 | 30 |  *************************************************************************************************/ | 
 | 31 |  | 
 | 32 | #pragma once | 
 | 33 |  | 
 | 34 | #include <cutils/native_handle.h> | 
 | 35 | #include <errno.h> | 
 | 36 | #include <limits.h> | 
 | 37 | #include <stdint.h> | 
 | 38 | #include <string.h> | 
 | 39 | #include <sys/cdefs.h> | 
 | 40 | #include <system/graphics.h> | 
 | 41 | #include <unistd.h> | 
 | 42 | #include <stdbool.h> | 
 | 43 |  | 
 | 44 | // system/window.h is a superset of the vndk | 
 | 45 | #include <vndk/window.h> | 
 | 46 |  | 
 | 47 |  | 
 | 48 | #ifndef __UNUSED | 
 | 49 | #define __UNUSED __attribute__((__unused__)) | 
 | 50 | #endif | 
 | 51 | #ifndef __deprecated | 
 | 52 | #define __deprecated __attribute__((__deprecated__)) | 
 | 53 | #endif | 
 | 54 |  | 
 | 55 | __BEGIN_DECLS | 
 | 56 |  | 
 | 57 | /*****************************************************************************/ | 
 | 58 |  | 
| Mathias Agopian | 000879a | 2017-03-20 18:07:26 -0700 | [diff] [blame] | 59 | #define ANDROID_NATIVE_WINDOW_MAGIC     ANDROID_NATIVE_MAKE_CONSTANT('_','w','n','d') | 
| Mathias Agopian | a6c0e20 | 2017-03-20 15:48:44 -0700 | [diff] [blame] | 60 |  | 
 | 61 | // --------------------------------------------------------------------------- | 
 | 62 |  | 
| Mathias Agopian | a6c0e20 | 2017-03-20 15:48:44 -0700 | [diff] [blame] | 63 | /* attributes queriable with query() */ | 
 | 64 | enum { | 
 | 65 |     NATIVE_WINDOW_WIDTH     = 0, | 
 | 66 |     NATIVE_WINDOW_HEIGHT    = 1, | 
 | 67 |     NATIVE_WINDOW_FORMAT    = 2, | 
 | 68 |  | 
| Mathias Agopian | 000879a | 2017-03-20 18:07:26 -0700 | [diff] [blame] | 69 |     /* see ANativeWindowQuery in vndk/window.h */ | 
 | 70 |     NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS = ANATIVEWINDOW_QUERY_MIN_UNDEQUEUED_BUFFERS, | 
| Mathias Agopian | a6c0e20 | 2017-03-20 15:48:44 -0700 | [diff] [blame] | 71 |  | 
 | 72 |     /* Check whether queueBuffer operations on the ANativeWindow send the buffer | 
 | 73 |      * to the window compositor.  The query sets the returned 'value' argument | 
 | 74 |      * to 1 if the ANativeWindow DOES send queued buffers directly to the window | 
 | 75 |      * compositor and 0 if the buffers do not go directly to the window | 
 | 76 |      * compositor. | 
 | 77 |      * | 
 | 78 |      * This can be used to determine whether protected buffer content should be | 
 | 79 |      * sent to the ANativeWindow.  Note, however, that a result of 1 does NOT | 
 | 80 |      * indicate that queued buffers will be protected from applications or users | 
 | 81 |      * capturing their contents.  If that behavior is desired then some other | 
 | 82 |      * mechanism (e.g. the GRALLOC_USAGE_PROTECTED flag) should be used in | 
 | 83 |      * conjunction with this query. | 
 | 84 |      */ | 
 | 85 |     NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER = 4, | 
 | 86 |  | 
 | 87 |     /* Get the concrete type of a ANativeWindow.  See below for the list of | 
 | 88 |      * possible return values. | 
 | 89 |      * | 
 | 90 |      * This query should not be used outside the Android framework and will | 
 | 91 |      * likely be removed in the near future. | 
 | 92 |      */ | 
 | 93 |     NATIVE_WINDOW_CONCRETE_TYPE = 5, | 
 | 94 |  | 
 | 95 |  | 
 | 96 |     /* | 
 | 97 |      * Default width and height of ANativeWindow buffers, these are the | 
 | 98 |      * dimensions of the window buffers irrespective of the | 
 | 99 |      * NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS call and match the native window | 
 | 100 |      * size unless overridden by NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS. | 
 | 101 |      */ | 
| Mathias Agopian | 000879a | 2017-03-20 18:07:26 -0700 | [diff] [blame] | 102 |     NATIVE_WINDOW_DEFAULT_WIDTH = ANATIVEWINDOW_QUERY_DEFAULT_WIDTH, | 
 | 103 |     NATIVE_WINDOW_DEFAULT_HEIGHT = ANATIVEWINDOW_QUERY_DEFAULT_HEIGHT, | 
| Mathias Agopian | a6c0e20 | 2017-03-20 15:48:44 -0700 | [diff] [blame] | 104 |  | 
| Mathias Agopian | 000879a | 2017-03-20 18:07:26 -0700 | [diff] [blame] | 105 |     /* see ANativeWindowQuery in vndk/window.h */ | 
 | 106 |     NATIVE_WINDOW_TRANSFORM_HINT = ANATIVEWINDOW_QUERY_TRANSFORM_HINT, | 
| Mathias Agopian | a6c0e20 | 2017-03-20 15:48:44 -0700 | [diff] [blame] | 107 |  | 
 | 108 |     /* | 
 | 109 |      * Boolean that indicates whether the consumer is running more than | 
 | 110 |      * one buffer behind the producer. | 
 | 111 |      */ | 
 | 112 |     NATIVE_WINDOW_CONSUMER_RUNNING_BEHIND = 9, | 
 | 113 |  | 
 | 114 |     /* | 
 | 115 |      * The consumer gralloc usage bits currently set by the consumer. | 
 | 116 |      * The values are defined in hardware/libhardware/include/gralloc.h. | 
 | 117 |      */ | 
| Chia-I Wu | e2786ea | 2017-08-07 10:36:08 -0700 | [diff] [blame] | 118 |     NATIVE_WINDOW_CONSUMER_USAGE_BITS = 10, /* deprecated */ | 
| Mathias Agopian | a6c0e20 | 2017-03-20 15:48:44 -0700 | [diff] [blame] | 119 |  | 
 | 120 |     /** | 
 | 121 |      * Transformation that will by applied to buffers by the hwcomposer. | 
 | 122 |      * This must not be set or checked by producer endpoints, and will | 
 | 123 |      * disable the transform hint set in SurfaceFlinger (see | 
 | 124 |      * NATIVE_WINDOW_TRANSFORM_HINT). | 
 | 125 |      * | 
 | 126 |      * INTENDED USE: | 
 | 127 |      * Temporary - Please do not use this.  This is intended only to be used | 
 | 128 |      * by the camera's LEGACY mode. | 
 | 129 |      * | 
 | 130 |      * In situations where a SurfaceFlinger client wishes to set a transform | 
 | 131 |      * that is not visible to the producer, and will always be applied in the | 
 | 132 |      * hardware composer, the client can set this flag with | 
 | 133 |      * native_window_set_buffers_sticky_transform.  This can be used to rotate | 
 | 134 |      * and flip buffers consumed by hardware composer without actually changing | 
 | 135 |      * the aspect ratio of the buffers produced. | 
 | 136 |      */ | 
 | 137 |     NATIVE_WINDOW_STICKY_TRANSFORM = 11, | 
 | 138 |  | 
 | 139 |     /** | 
 | 140 |      * The default data space for the buffers as set by the consumer. | 
 | 141 |      * The values are defined in graphics.h. | 
 | 142 |      */ | 
 | 143 |     NATIVE_WINDOW_DEFAULT_DATASPACE = 12, | 
 | 144 |  | 
| Mathias Agopian | 000879a | 2017-03-20 18:07:26 -0700 | [diff] [blame] | 145 |     /* see ANativeWindowQuery in vndk/window.h */ | 
 | 146 |     NATIVE_WINDOW_BUFFER_AGE = ANATIVEWINDOW_QUERY_BUFFER_AGE, | 
| Mathias Agopian | a6c0e20 | 2017-03-20 15:48:44 -0700 | [diff] [blame] | 147 |  | 
 | 148 |     /* | 
 | 149 |      * Returns the duration of the last dequeueBuffer call in microseconds | 
 | 150 |      */ | 
 | 151 |     NATIVE_WINDOW_LAST_DEQUEUE_DURATION = 14, | 
 | 152 |  | 
 | 153 |     /* | 
 | 154 |      * Returns the duration of the last queueBuffer call in microseconds | 
 | 155 |      */ | 
 | 156 |     NATIVE_WINDOW_LAST_QUEUE_DURATION = 15, | 
 | 157 |  | 
 | 158 |     /* | 
 | 159 |      * Returns the number of image layers that the ANativeWindow buffer | 
 | 160 |      * contains. By default this is 1, unless a buffer is explicitly allocated | 
 | 161 |      * to contain multiple layers. | 
 | 162 |      */ | 
 | 163 |     NATIVE_WINDOW_LAYER_COUNT = 16, | 
 | 164 |  | 
 | 165 |     /* | 
 | 166 |      * Returns 1 if the native window is valid, 0 otherwise. native window is valid | 
 | 167 |      * if it is safe (i.e. no crash will occur) to call any method on it. | 
 | 168 |      */ | 
 | 169 |     NATIVE_WINDOW_IS_VALID = 17, | 
| Brian Anderson | 6b37671 | 2017-04-04 10:51:39 -0700 | [diff] [blame] | 170 |  | 
 | 171 |     /* | 
 | 172 |      * Returns 1 if NATIVE_WINDOW_GET_FRAME_TIMESTAMPS will return display | 
 | 173 |      * present info, 0 if it won't. | 
 | 174 |      */ | 
 | 175 |     NATIVE_WINDOW_FRAME_TIMESTAMPS_SUPPORTS_PRESENT = 18, | 
| Jiwen 'Steve' Cai | 2041913 | 2017-04-21 18:49:53 -0700 | [diff] [blame] | 176 |  | 
 | 177 |     /* | 
 | 178 |      * The consumer end is capable of handling protected buffers, i.e. buffer | 
 | 179 |      * with GRALLOC_USAGE_PROTECTED usage bits on. | 
 | 180 |      */ | 
 | 181 |     NATIVE_WINDOW_CONSUMER_IS_PROTECTED = 19, | 
| Mathias Agopian | a6c0e20 | 2017-03-20 15:48:44 -0700 | [diff] [blame] | 182 | }; | 
 | 183 |  | 
 | 184 | /* Valid operations for the (*perform)() hook. | 
 | 185 |  * | 
 | 186 |  * Values marked as 'deprecated' are supported, but have been superceded by | 
 | 187 |  * other functionality. | 
 | 188 |  * | 
 | 189 |  * Values marked as 'private' should be considered private to the framework. | 
 | 190 |  * HAL implementation code with access to an ANativeWindow should not use these, | 
 | 191 |  * as it may not interact properly with the framework's use of the | 
 | 192 |  * ANativeWindow. | 
 | 193 |  */ | 
 | 194 | enum { | 
 | 195 | // clang-format off | 
| Mathias Agopian | cb496ac | 2017-05-22 14:21:00 -0700 | [diff] [blame] | 196 |     NATIVE_WINDOW_SET_USAGE                     =  0,   /* deprecated */ | 
 | 197 |     NATIVE_WINDOW_CONNECT                       =  1,   /* deprecated */ | 
 | 198 |     NATIVE_WINDOW_DISCONNECT                    =  2,   /* deprecated */ | 
 | 199 |     NATIVE_WINDOW_SET_CROP                      =  3,   /* private */ | 
 | 200 |     NATIVE_WINDOW_SET_BUFFER_COUNT              =  4, | 
 | 201 |     NATIVE_WINDOW_SET_BUFFERS_GEOMETRY          =  5,   /* deprecated */ | 
 | 202 |     NATIVE_WINDOW_SET_BUFFERS_TRANSFORM         =  6, | 
 | 203 |     NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP         =  7, | 
 | 204 |     NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS        =  8, | 
 | 205 |     NATIVE_WINDOW_SET_BUFFERS_FORMAT            =  9, | 
 | 206 |     NATIVE_WINDOW_SET_SCALING_MODE              = 10,   /* private */ | 
 | 207 |     NATIVE_WINDOW_LOCK                          = 11,   /* private */ | 
 | 208 |     NATIVE_WINDOW_UNLOCK_AND_POST               = 12,   /* private */ | 
 | 209 |     NATIVE_WINDOW_API_CONNECT                   = 13,   /* private */ | 
 | 210 |     NATIVE_WINDOW_API_DISCONNECT                = 14,   /* private */ | 
 | 211 |     NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS   = 15,   /* private */ | 
 | 212 |     NATIVE_WINDOW_SET_POST_TRANSFORM_CROP       = 16,   /* deprecated, unimplemented */ | 
 | 213 |     NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM  = 17,   /* private */ | 
 | 214 |     NATIVE_WINDOW_SET_SIDEBAND_STREAM           = 18, | 
 | 215 |     NATIVE_WINDOW_SET_BUFFERS_DATASPACE         = 19, | 
 | 216 |     NATIVE_WINDOW_SET_SURFACE_DAMAGE            = 20,   /* private */ | 
 | 217 |     NATIVE_WINDOW_SET_SHARED_BUFFER_MODE        = 21, | 
 | 218 |     NATIVE_WINDOW_SET_AUTO_REFRESH              = 22, | 
 | 219 |     NATIVE_WINDOW_GET_REFRESH_CYCLE_DURATION    = 23, | 
 | 220 |     NATIVE_WINDOW_GET_NEXT_FRAME_ID             = 24, | 
 | 221 |     NATIVE_WINDOW_ENABLE_FRAME_TIMESTAMPS       = 25, | 
 | 222 |     NATIVE_WINDOW_GET_COMPOSITOR_TIMING         = 26, | 
 | 223 |     NATIVE_WINDOW_GET_FRAME_TIMESTAMPS          = 27, | 
 | 224 |     NATIVE_WINDOW_GET_WIDE_COLOR_SUPPORT        = 28, | 
 | 225 |     NATIVE_WINDOW_GET_HDR_SUPPORT               = 29, | 
 | 226 |     NATIVE_WINDOW_SET_USAGE64                   = 30, | 
| Chia-I Wu | e2786ea | 2017-08-07 10:36:08 -0700 | [diff] [blame] | 227 |     NATIVE_WINDOW_GET_CONSUMER_USAGE64          = 31, | 
| Mathias Agopian | a6c0e20 | 2017-03-20 15:48:44 -0700 | [diff] [blame] | 228 | // clang-format on | 
 | 229 | }; | 
 | 230 |  | 
 | 231 | /* parameter for NATIVE_WINDOW_[API_][DIS]CONNECT */ | 
 | 232 | enum { | 
 | 233 |     /* Buffers will be queued by EGL via eglSwapBuffers after being filled using | 
 | 234 |      * OpenGL ES. | 
 | 235 |      */ | 
 | 236 |     NATIVE_WINDOW_API_EGL = 1, | 
 | 237 |  | 
 | 238 |     /* Buffers will be queued after being filled using the CPU | 
 | 239 |      */ | 
 | 240 |     NATIVE_WINDOW_API_CPU = 2, | 
 | 241 |  | 
 | 242 |     /* Buffers will be queued by Stagefright after being filled by a video | 
 | 243 |      * decoder.  The video decoder can either be a software or hardware decoder. | 
 | 244 |      */ | 
 | 245 |     NATIVE_WINDOW_API_MEDIA = 3, | 
 | 246 |  | 
 | 247 |     /* Buffers will be queued by the the camera HAL. | 
 | 248 |      */ | 
 | 249 |     NATIVE_WINDOW_API_CAMERA = 4, | 
 | 250 | }; | 
 | 251 |  | 
 | 252 | /* parameter for NATIVE_WINDOW_SET_BUFFERS_TRANSFORM */ | 
 | 253 | enum { | 
 | 254 |     /* flip source image horizontally */ | 
 | 255 |     NATIVE_WINDOW_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H , | 
 | 256 |     /* flip source image vertically */ | 
 | 257 |     NATIVE_WINDOW_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V, | 
 | 258 |     /* rotate source image 90 degrees clock-wise, and is applied after TRANSFORM_FLIP_{H|V} */ | 
 | 259 |     NATIVE_WINDOW_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90, | 
 | 260 |     /* rotate source image 180 degrees */ | 
 | 261 |     NATIVE_WINDOW_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180, | 
 | 262 |     /* rotate source image 270 degrees clock-wise */ | 
 | 263 |     NATIVE_WINDOW_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270, | 
 | 264 |     /* transforms source by the inverse transform of the screen it is displayed onto. This | 
 | 265 |      * transform is applied last */ | 
 | 266 |     NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY = 0x08 | 
 | 267 | }; | 
 | 268 |  | 
 | 269 | /* parameter for NATIVE_WINDOW_SET_SCALING_MODE | 
 | 270 |  * keep in sync with Surface.java in frameworks/base */ | 
 | 271 | enum { | 
 | 272 |     /* the window content is not updated (frozen) until a buffer of | 
 | 273 |      * the window size is received (enqueued) | 
 | 274 |      */ | 
 | 275 |     NATIVE_WINDOW_SCALING_MODE_FREEZE           = 0, | 
 | 276 |     /* the buffer is scaled in both dimensions to match the window size */ | 
 | 277 |     NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW  = 1, | 
 | 278 |     /* the buffer is scaled uniformly such that the smaller dimension | 
 | 279 |      * of the buffer matches the window size (cropping in the process) | 
 | 280 |      */ | 
 | 281 |     NATIVE_WINDOW_SCALING_MODE_SCALE_CROP       = 2, | 
 | 282 |     /* the window is clipped to the size of the buffer's crop rectangle; pixels | 
 | 283 |      * outside the crop rectangle are treated as if they are completely | 
 | 284 |      * transparent. | 
 | 285 |      */ | 
 | 286 |     NATIVE_WINDOW_SCALING_MODE_NO_SCALE_CROP    = 3, | 
 | 287 | }; | 
 | 288 |  | 
 | 289 | /* values returned by the NATIVE_WINDOW_CONCRETE_TYPE query */ | 
 | 290 | enum { | 
 | 291 |     NATIVE_WINDOW_FRAMEBUFFER               = 0, /* FramebufferNativeWindow */ | 
 | 292 |     NATIVE_WINDOW_SURFACE                   = 1, /* Surface */ | 
 | 293 | }; | 
 | 294 |  | 
 | 295 | /* parameter for NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP | 
 | 296 |  * | 
 | 297 |  * Special timestamp value to indicate that timestamps should be auto-generated | 
 | 298 |  * by the native window when queueBuffer is called.  This is equal to INT64_MIN, | 
 | 299 |  * defined directly to avoid problems with C99/C++ inclusion of stdint.h. | 
 | 300 |  */ | 
 | 301 | static const int64_t NATIVE_WINDOW_TIMESTAMP_AUTO = (-9223372036854775807LL-1); | 
 | 302 |  | 
| Brian Anderson | dc96fdf | 2017-03-20 16:54:25 -0700 | [diff] [blame] | 303 | /* parameter for NATIVE_WINDOW_GET_FRAME_TIMESTAMPS | 
 | 304 |  * | 
 | 305 |  * Special timestamp value to indicate the timestamps aren't yet known or | 
 | 306 |  * that they are invalid. | 
 | 307 |  */ | 
 | 308 | static const int64_t NATIVE_WINDOW_TIMESTAMP_PENDING = -2; | 
 | 309 | static const int64_t NATIVE_WINDOW_TIMESTAMP_INVALID = -1; | 
 | 310 |  | 
| Mathias Agopian | a6c0e20 | 2017-03-20 15:48:44 -0700 | [diff] [blame] | 311 | struct ANativeWindow | 
 | 312 | { | 
 | 313 | #ifdef __cplusplus | 
 | 314 |     ANativeWindow() | 
 | 315 |         : flags(0), minSwapInterval(0), maxSwapInterval(0), xdpi(0), ydpi(0) | 
 | 316 |     { | 
 | 317 |         common.magic = ANDROID_NATIVE_WINDOW_MAGIC; | 
 | 318 |         common.version = sizeof(ANativeWindow); | 
 | 319 |         memset(common.reserved, 0, sizeof(common.reserved)); | 
 | 320 |     } | 
 | 321 |  | 
 | 322 |     /* Implement the methods that sp<ANativeWindow> expects so that it | 
 | 323 |        can be used to automatically refcount ANativeWindow's. */ | 
 | 324 |     void incStrong(const void* /*id*/) const { | 
 | 325 |         common.incRef(const_cast<android_native_base_t*>(&common)); | 
 | 326 |     } | 
 | 327 |     void decStrong(const void* /*id*/) const { | 
 | 328 |         common.decRef(const_cast<android_native_base_t*>(&common)); | 
 | 329 |     } | 
 | 330 | #endif | 
 | 331 |  | 
 | 332 |     struct android_native_base_t common; | 
 | 333 |  | 
 | 334 |     /* flags describing some attributes of this surface or its updater */ | 
 | 335 |     const uint32_t flags; | 
 | 336 |  | 
 | 337 |     /* min swap interval supported by this updated */ | 
 | 338 |     const int   minSwapInterval; | 
 | 339 |  | 
 | 340 |     /* max swap interval supported by this updated */ | 
 | 341 |     const int   maxSwapInterval; | 
 | 342 |  | 
 | 343 |     /* horizontal and vertical resolution in DPI */ | 
 | 344 |     const float xdpi; | 
 | 345 |     const float ydpi; | 
 | 346 |  | 
 | 347 |     /* Some storage reserved for the OEM's driver. */ | 
 | 348 |     intptr_t    oem[4]; | 
 | 349 |  | 
 | 350 |     /* | 
 | 351 |      * Set the swap interval for this surface. | 
 | 352 |      * | 
 | 353 |      * Returns 0 on success or -errno on error. | 
 | 354 |      */ | 
 | 355 |     int     (*setSwapInterval)(struct ANativeWindow* window, | 
 | 356 |                 int interval); | 
 | 357 |  | 
 | 358 |     /* | 
 | 359 |      * Hook called by EGL to acquire a buffer. After this call, the buffer | 
 | 360 |      * is not locked, so its content cannot be modified. This call may block if | 
 | 361 |      * no buffers are available. | 
 | 362 |      * | 
 | 363 |      * The window holds a reference to the buffer between dequeueBuffer and | 
 | 364 |      * either queueBuffer or cancelBuffer, so clients only need their own | 
 | 365 |      * reference if they might use the buffer after queueing or canceling it. | 
 | 366 |      * Holding a reference to a buffer after queueing or canceling it is only | 
 | 367 |      * allowed if a specific buffer count has been set. | 
 | 368 |      * | 
 | 369 |      * Returns 0 on success or -errno on error. | 
 | 370 |      * | 
 | 371 |      * XXX: This function is deprecated.  It will continue to work for some | 
 | 372 |      * time for binary compatibility, but the new dequeueBuffer function that | 
 | 373 |      * outputs a fence file descriptor should be used in its place. | 
 | 374 |      */ | 
 | 375 |     int     (*dequeueBuffer_DEPRECATED)(struct ANativeWindow* window, | 
 | 376 |                 struct ANativeWindowBuffer** buffer); | 
 | 377 |  | 
 | 378 |     /* | 
 | 379 |      * hook called by EGL to lock a buffer. This MUST be called before modifying | 
 | 380 |      * the content of a buffer. The buffer must have been acquired with | 
 | 381 |      * dequeueBuffer first. | 
 | 382 |      * | 
 | 383 |      * Returns 0 on success or -errno on error. | 
 | 384 |      * | 
 | 385 |      * XXX: This function is deprecated.  It will continue to work for some | 
 | 386 |      * time for binary compatibility, but it is essentially a no-op, and calls | 
 | 387 |      * to it should be removed. | 
 | 388 |      */ | 
 | 389 |     int     (*lockBuffer_DEPRECATED)(struct ANativeWindow* window, | 
 | 390 |                 struct ANativeWindowBuffer* buffer); | 
 | 391 |  | 
 | 392 |     /* | 
 | 393 |      * Hook called by EGL when modifications to the render buffer are done. | 
 | 394 |      * This unlocks and post the buffer. | 
 | 395 |      * | 
 | 396 |      * The window holds a reference to the buffer between dequeueBuffer and | 
 | 397 |      * either queueBuffer or cancelBuffer, so clients only need their own | 
 | 398 |      * reference if they might use the buffer after queueing or canceling it. | 
 | 399 |      * Holding a reference to a buffer after queueing or canceling it is only | 
 | 400 |      * allowed if a specific buffer count has been set. | 
 | 401 |      * | 
 | 402 |      * Buffers MUST be queued in the same order than they were dequeued. | 
 | 403 |      * | 
 | 404 |      * Returns 0 on success or -errno on error. | 
 | 405 |      * | 
 | 406 |      * XXX: This function is deprecated.  It will continue to work for some | 
 | 407 |      * time for binary compatibility, but the new queueBuffer function that | 
 | 408 |      * takes a fence file descriptor should be used in its place (pass a value | 
 | 409 |      * of -1 for the fence file descriptor if there is no valid one to pass). | 
 | 410 |      */ | 
 | 411 |     int     (*queueBuffer_DEPRECATED)(struct ANativeWindow* window, | 
 | 412 |                 struct ANativeWindowBuffer* buffer); | 
 | 413 |  | 
 | 414 |     /* | 
 | 415 |      * hook used to retrieve information about the native window. | 
 | 416 |      * | 
 | 417 |      * Returns 0 on success or -errno on error. | 
 | 418 |      */ | 
 | 419 |     int     (*query)(const struct ANativeWindow* window, | 
 | 420 |                 int what, int* value); | 
 | 421 |  | 
 | 422 |     /* | 
 | 423 |      * hook used to perform various operations on the surface. | 
 | 424 |      * (*perform)() is a generic mechanism to add functionality to | 
 | 425 |      * ANativeWindow while keeping backward binary compatibility. | 
 | 426 |      * | 
 | 427 |      * DO NOT CALL THIS HOOK DIRECTLY.  Instead, use the helper functions | 
 | 428 |      * defined below. | 
 | 429 |      * | 
 | 430 |      * (*perform)() returns -ENOENT if the 'what' parameter is not supported | 
 | 431 |      * by the surface's implementation. | 
 | 432 |      * | 
 | 433 |      * See above for a list of valid operations, such as | 
 | 434 |      * NATIVE_WINDOW_SET_USAGE or NATIVE_WINDOW_CONNECT | 
 | 435 |      */ | 
 | 436 |     int     (*perform)(struct ANativeWindow* window, | 
 | 437 |                 int operation, ... ); | 
 | 438 |  | 
 | 439 |     /* | 
 | 440 |      * Hook used to cancel a buffer that has been dequeued. | 
 | 441 |      * No synchronization is performed between dequeue() and cancel(), so | 
 | 442 |      * either external synchronization is needed, or these functions must be | 
 | 443 |      * called from the same thread. | 
 | 444 |      * | 
 | 445 |      * The window holds a reference to the buffer between dequeueBuffer and | 
 | 446 |      * either queueBuffer or cancelBuffer, so clients only need their own | 
 | 447 |      * reference if they might use the buffer after queueing or canceling it. | 
 | 448 |      * Holding a reference to a buffer after queueing or canceling it is only | 
 | 449 |      * allowed if a specific buffer count has been set. | 
 | 450 |      * | 
 | 451 |      * XXX: This function is deprecated.  It will continue to work for some | 
 | 452 |      * time for binary compatibility, but the new cancelBuffer function that | 
 | 453 |      * takes a fence file descriptor should be used in its place (pass a value | 
 | 454 |      * of -1 for the fence file descriptor if there is no valid one to pass). | 
 | 455 |      */ | 
 | 456 |     int     (*cancelBuffer_DEPRECATED)(struct ANativeWindow* window, | 
 | 457 |                 struct ANativeWindowBuffer* buffer); | 
 | 458 |  | 
 | 459 |     /* | 
 | 460 |      * Hook called by EGL to acquire a buffer. This call may block if no | 
 | 461 |      * buffers are available. | 
 | 462 |      * | 
 | 463 |      * The window holds a reference to the buffer between dequeueBuffer and | 
 | 464 |      * either queueBuffer or cancelBuffer, so clients only need their own | 
 | 465 |      * reference if they might use the buffer after queueing or canceling it. | 
 | 466 |      * Holding a reference to a buffer after queueing or canceling it is only | 
 | 467 |      * allowed if a specific buffer count has been set. | 
 | 468 |      * | 
 | 469 |      * The libsync fence file descriptor returned in the int pointed to by the | 
 | 470 |      * fenceFd argument will refer to the fence that must signal before the | 
 | 471 |      * dequeued buffer may be written to.  A value of -1 indicates that the | 
 | 472 |      * caller may access the buffer immediately without waiting on a fence.  If | 
 | 473 |      * a valid file descriptor is returned (i.e. any value except -1) then the | 
 | 474 |      * caller is responsible for closing the file descriptor. | 
 | 475 |      * | 
 | 476 |      * Returns 0 on success or -errno on error. | 
 | 477 |      */ | 
 | 478 |     int     (*dequeueBuffer)(struct ANativeWindow* window, | 
 | 479 |                 struct ANativeWindowBuffer** buffer, int* fenceFd); | 
 | 480 |  | 
 | 481 |     /* | 
 | 482 |      * Hook called by EGL when modifications to the render buffer are done. | 
 | 483 |      * This unlocks and post the buffer. | 
 | 484 |      * | 
 | 485 |      * The window holds a reference to the buffer between dequeueBuffer and | 
 | 486 |      * either queueBuffer or cancelBuffer, so clients only need their own | 
 | 487 |      * reference if they might use the buffer after queueing or canceling it. | 
 | 488 |      * Holding a reference to a buffer after queueing or canceling it is only | 
 | 489 |      * allowed if a specific buffer count has been set. | 
 | 490 |      * | 
 | 491 |      * The fenceFd argument specifies a libsync fence file descriptor for a | 
 | 492 |      * fence that must signal before the buffer can be accessed.  If the buffer | 
 | 493 |      * can be accessed immediately then a value of -1 should be used.  The | 
 | 494 |      * caller must not use the file descriptor after it is passed to | 
 | 495 |      * queueBuffer, and the ANativeWindow implementation is responsible for | 
 | 496 |      * closing it. | 
 | 497 |      * | 
 | 498 |      * Returns 0 on success or -errno on error. | 
 | 499 |      */ | 
 | 500 |     int     (*queueBuffer)(struct ANativeWindow* window, | 
 | 501 |                 struct ANativeWindowBuffer* buffer, int fenceFd); | 
 | 502 |  | 
 | 503 |     /* | 
 | 504 |      * Hook used to cancel a buffer that has been dequeued. | 
 | 505 |      * No synchronization is performed between dequeue() and cancel(), so | 
 | 506 |      * either external synchronization is needed, or these functions must be | 
 | 507 |      * called from the same thread. | 
 | 508 |      * | 
 | 509 |      * The window holds a reference to the buffer between dequeueBuffer and | 
 | 510 |      * either queueBuffer or cancelBuffer, so clients only need their own | 
 | 511 |      * reference if they might use the buffer after queueing or canceling it. | 
 | 512 |      * Holding a reference to a buffer after queueing or canceling it is only | 
 | 513 |      * allowed if a specific buffer count has been set. | 
 | 514 |      * | 
 | 515 |      * The fenceFd argument specifies a libsync fence file decsriptor for a | 
 | 516 |      * fence that must signal before the buffer can be accessed.  If the buffer | 
 | 517 |      * can be accessed immediately then a value of -1 should be used. | 
 | 518 |      * | 
 | 519 |      * Note that if the client has not waited on the fence that was returned | 
 | 520 |      * from dequeueBuffer, that same fence should be passed to cancelBuffer to | 
 | 521 |      * ensure that future uses of the buffer are preceded by a wait on that | 
 | 522 |      * fence.  The caller must not use the file descriptor after it is passed | 
 | 523 |      * to cancelBuffer, and the ANativeWindow implementation is responsible for | 
 | 524 |      * closing it. | 
 | 525 |      * | 
 | 526 |      * Returns 0 on success or -errno on error. | 
 | 527 |      */ | 
 | 528 |     int     (*cancelBuffer)(struct ANativeWindow* window, | 
 | 529 |                 struct ANativeWindowBuffer* buffer, int fenceFd); | 
 | 530 | }; | 
 | 531 |  | 
 | 532 |  /* Backwards compatibility: use ANativeWindow (struct ANativeWindow in C). | 
 | 533 |   * android_native_window_t is deprecated. | 
 | 534 |   */ | 
| Mathias Agopian | a6c0e20 | 2017-03-20 15:48:44 -0700 | [diff] [blame] | 535 | typedef struct ANativeWindow android_native_window_t __deprecated; | 
 | 536 |  | 
 | 537 | /* | 
| Mathias Agopian | cb496ac | 2017-05-22 14:21:00 -0700 | [diff] [blame] | 538 |  *  native_window_set_usage64(..., usage) | 
| Mathias Agopian | a6c0e20 | 2017-03-20 15:48:44 -0700 | [diff] [blame] | 539 |  *  Sets the intended usage flags for the next buffers | 
 | 540 |  *  acquired with (*lockBuffer)() and on. | 
| Mathias Agopian | cb496ac | 2017-05-22 14:21:00 -0700 | [diff] [blame] | 541 |  * | 
 | 542 |  *  Valid usage flags are defined in android/hardware_buffer.h | 
 | 543 |  *  All AHARDWAREBUFFER_USAGE_* flags can be specified as needed. | 
 | 544 |  * | 
| Mathias Agopian | a6c0e20 | 2017-03-20 15:48:44 -0700 | [diff] [blame] | 545 |  *  Calling this function will usually cause following buffers to be | 
 | 546 |  *  reallocated. | 
 | 547 |  */ | 
| Mathias Agopian | cb496ac | 2017-05-22 14:21:00 -0700 | [diff] [blame] | 548 | static inline int native_window_set_usage(struct ANativeWindow* window, uint64_t usage) { | 
 | 549 |     return window->perform(window, NATIVE_WINDOW_SET_USAGE64, usage); | 
| Mathias Agopian | a6c0e20 | 2017-03-20 15:48:44 -0700 | [diff] [blame] | 550 | } | 
 | 551 |  | 
 | 552 | /* deprecated. Always returns 0. Don't call. */ | 
 | 553 | static inline int native_window_connect( | 
 | 554 |         struct ANativeWindow* window __UNUSED, int api __UNUSED) __deprecated; | 
 | 555 |  | 
 | 556 | static inline int native_window_connect( | 
 | 557 |         struct ANativeWindow* window __UNUSED, int api __UNUSED) { | 
 | 558 |     return 0; | 
 | 559 | } | 
 | 560 |  | 
 | 561 | /* deprecated. Always returns 0. Don't call. */ | 
 | 562 | static inline int native_window_disconnect( | 
 | 563 |         struct ANativeWindow* window __UNUSED, int api __UNUSED) __deprecated; | 
 | 564 |  | 
 | 565 | static inline int native_window_disconnect( | 
 | 566 |         struct ANativeWindow* window __UNUSED, int api __UNUSED) { | 
 | 567 |     return 0; | 
 | 568 | } | 
 | 569 |  | 
 | 570 | /* | 
 | 571 |  * native_window_set_crop(..., crop) | 
 | 572 |  * Sets which region of the next queued buffers needs to be considered. | 
 | 573 |  * Depending on the scaling mode, a buffer's crop region is scaled and/or | 
 | 574 |  * cropped to match the surface's size.  This function sets the crop in | 
 | 575 |  * pre-transformed buffer pixel coordinates. | 
 | 576 |  * | 
 | 577 |  * The specified crop region applies to all buffers queued after it is called. | 
 | 578 |  * | 
 | 579 |  * If 'crop' is NULL, subsequently queued buffers won't be cropped. | 
 | 580 |  * | 
 | 581 |  * An error is returned if for instance the crop region is invalid, out of the | 
 | 582 |  * buffer's bound or if the window is invalid. | 
 | 583 |  */ | 
 | 584 | static inline int native_window_set_crop( | 
 | 585 |         struct ANativeWindow* window, | 
 | 586 |         android_native_rect_t const * crop) | 
 | 587 | { | 
 | 588 |     return window->perform(window, NATIVE_WINDOW_SET_CROP, crop); | 
 | 589 | } | 
 | 590 |  | 
 | 591 | /* | 
| Mathias Agopian | a6c0e20 | 2017-03-20 15:48:44 -0700 | [diff] [blame] | 592 |  * native_window_set_buffer_count(..., count) | 
 | 593 |  * Sets the number of buffers associated with this native window. | 
 | 594 |  */ | 
 | 595 | static inline int native_window_set_buffer_count( | 
 | 596 |         struct ANativeWindow* window, | 
 | 597 |         size_t bufferCount) | 
 | 598 | { | 
 | 599 |     return window->perform(window, NATIVE_WINDOW_SET_BUFFER_COUNT, bufferCount); | 
 | 600 | } | 
 | 601 |  | 
 | 602 | /* | 
 | 603 |  * native_window_set_buffers_geometry(..., int w, int h, int format) | 
 | 604 |  * All buffers dequeued after this call will have the dimensions and format | 
 | 605 |  * specified.  A successful call to this function has the same effect as calling | 
 | 606 |  * native_window_set_buffers_size and native_window_set_buffers_format. | 
 | 607 |  * | 
 | 608 |  * XXX: This function is deprecated.  The native_window_set_buffers_dimensions | 
 | 609 |  * and native_window_set_buffers_format functions should be used instead. | 
 | 610 |  */ | 
 | 611 | static inline int native_window_set_buffers_geometry( | 
 | 612 |         struct ANativeWindow* window, | 
 | 613 |         int w, int h, int format) __deprecated; | 
 | 614 |  | 
 | 615 | static inline int native_window_set_buffers_geometry( | 
 | 616 |         struct ANativeWindow* window, | 
 | 617 |         int w, int h, int format) | 
 | 618 | { | 
 | 619 |     return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_GEOMETRY, | 
 | 620 |             w, h, format); | 
 | 621 | } | 
 | 622 |  | 
 | 623 | /* | 
 | 624 |  * native_window_set_buffers_dimensions(..., int w, int h) | 
 | 625 |  * All buffers dequeued after this call will have the dimensions specified. | 
 | 626 |  * In particular, all buffers will have a fixed-size, independent from the | 
 | 627 |  * native-window size. They will be scaled according to the scaling mode | 
 | 628 |  * (see native_window_set_scaling_mode) upon window composition. | 
 | 629 |  * | 
 | 630 |  * If w and h are 0, the normal behavior is restored. That is, dequeued buffers | 
 | 631 |  * following this call will be sized to match the window's size. | 
 | 632 |  * | 
 | 633 |  * Calling this function will reset the window crop to a NULL value, which | 
 | 634 |  * disables cropping of the buffers. | 
 | 635 |  */ | 
 | 636 | static inline int native_window_set_buffers_dimensions( | 
 | 637 |         struct ANativeWindow* window, | 
 | 638 |         int w, int h) | 
 | 639 | { | 
 | 640 |     return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS, | 
 | 641 |             w, h); | 
 | 642 | } | 
 | 643 |  | 
 | 644 | /* | 
 | 645 |  * native_window_set_buffers_user_dimensions(..., int w, int h) | 
 | 646 |  * | 
 | 647 |  * Sets the user buffer size for the window, which overrides the | 
 | 648 |  * window's size.  All buffers dequeued after this call will have the | 
 | 649 |  * dimensions specified unless overridden by | 
 | 650 |  * native_window_set_buffers_dimensions.  All buffers will have a | 
 | 651 |  * fixed-size, independent from the native-window size. They will be | 
 | 652 |  * scaled according to the scaling mode (see | 
 | 653 |  * native_window_set_scaling_mode) upon window composition. | 
 | 654 |  * | 
 | 655 |  * If w and h are 0, the normal behavior is restored. That is, the | 
 | 656 |  * default buffer size will match the windows's size. | 
 | 657 |  * | 
 | 658 |  * Calling this function will reset the window crop to a NULL value, which | 
 | 659 |  * disables cropping of the buffers. | 
 | 660 |  */ | 
 | 661 | static inline int native_window_set_buffers_user_dimensions( | 
 | 662 |         struct ANativeWindow* window, | 
 | 663 |         int w, int h) | 
 | 664 | { | 
 | 665 |     return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS, | 
 | 666 |             w, h); | 
 | 667 | } | 
 | 668 |  | 
 | 669 | /* | 
 | 670 |  * native_window_set_buffers_format(..., int format) | 
 | 671 |  * All buffers dequeued after this call will have the format specified. | 
 | 672 |  * | 
 | 673 |  * If the specified format is 0, the default buffer format will be used. | 
 | 674 |  */ | 
 | 675 | static inline int native_window_set_buffers_format( | 
 | 676 |         struct ANativeWindow* window, | 
 | 677 |         int format) | 
 | 678 | { | 
 | 679 |     return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_FORMAT, format); | 
 | 680 | } | 
 | 681 |  | 
 | 682 | /* | 
 | 683 |  * native_window_set_buffers_data_space(..., int dataSpace) | 
 | 684 |  * All buffers queued after this call will be associated with the dataSpace | 
 | 685 |  * parameter specified. | 
 | 686 |  * | 
 | 687 |  * dataSpace specifies additional information about the buffer that's dependent | 
 | 688 |  * on the buffer format and the endpoints. For example, it can be used to convey | 
 | 689 |  * the color space of the image data in the buffer, or it can be used to | 
 | 690 |  * indicate that the buffers contain depth measurement data instead of color | 
 | 691 |  * images.  The default dataSpace is 0, HAL_DATASPACE_UNKNOWN, unless it has been | 
 | 692 |  * overridden by the consumer. | 
 | 693 |  */ | 
 | 694 | static inline int native_window_set_buffers_data_space( | 
 | 695 |         struct ANativeWindow* window, | 
 | 696 |         android_dataspace_t dataSpace) | 
 | 697 | { | 
 | 698 |     return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DATASPACE, | 
 | 699 |             dataSpace); | 
 | 700 | } | 
 | 701 |  | 
 | 702 | /* | 
 | 703 |  * native_window_set_buffers_transform(..., int transform) | 
 | 704 |  * All buffers queued after this call will be displayed transformed according | 
 | 705 |  * to the transform parameter specified. | 
 | 706 |  */ | 
 | 707 | static inline int native_window_set_buffers_transform( | 
 | 708 |         struct ANativeWindow* window, | 
 | 709 |         int transform) | 
 | 710 | { | 
 | 711 |     return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TRANSFORM, | 
 | 712 |             transform); | 
 | 713 | } | 
 | 714 |  | 
 | 715 | /* | 
 | 716 |  * native_window_set_buffers_sticky_transform(..., int transform) | 
 | 717 |  * All buffers queued after this call will be displayed transformed according | 
 | 718 |  * to the transform parameter specified applied on top of the regular buffer | 
 | 719 |  * transform.  Setting this transform will disable the transform hint. | 
 | 720 |  * | 
 | 721 |  * Temporary - This is only intended to be used by the LEGACY camera mode, do | 
 | 722 |  *   not use this for anything else. | 
 | 723 |  */ | 
 | 724 | static inline int native_window_set_buffers_sticky_transform( | 
 | 725 |         struct ANativeWindow* window, | 
 | 726 |         int transform) | 
 | 727 | { | 
 | 728 |     return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM, | 
 | 729 |             transform); | 
 | 730 | } | 
 | 731 |  | 
 | 732 | /* | 
 | 733 |  * native_window_set_buffers_timestamp(..., int64_t timestamp) | 
 | 734 |  * All buffers queued after this call will be associated with the timestamp | 
 | 735 |  * parameter specified. If the timestamp is set to NATIVE_WINDOW_TIMESTAMP_AUTO | 
 | 736 |  * (the default), timestamps will be generated automatically when queueBuffer is | 
 | 737 |  * called. The timestamp is measured in nanoseconds, and is normally monotonically | 
 | 738 |  * increasing. The timestamp should be unaffected by time-of-day adjustments, | 
 | 739 |  * and for a camera should be strictly monotonic but for a media player may be | 
 | 740 |  * reset when the position is set. | 
 | 741 |  */ | 
 | 742 | static inline int native_window_set_buffers_timestamp( | 
 | 743 |         struct ANativeWindow* window, | 
 | 744 |         int64_t timestamp) | 
 | 745 | { | 
 | 746 |     return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP, | 
 | 747 |             timestamp); | 
 | 748 | } | 
 | 749 |  | 
 | 750 | /* | 
 | 751 |  * native_window_set_scaling_mode(..., int mode) | 
 | 752 |  * All buffers queued after this call will be associated with the scaling mode | 
 | 753 |  * specified. | 
 | 754 |  */ | 
 | 755 | static inline int native_window_set_scaling_mode( | 
 | 756 |         struct ANativeWindow* window, | 
 | 757 |         int mode) | 
 | 758 | { | 
 | 759 |     return window->perform(window, NATIVE_WINDOW_SET_SCALING_MODE, | 
 | 760 |             mode); | 
 | 761 | } | 
 | 762 |  | 
 | 763 | /* | 
 | 764 |  * native_window_api_connect(..., int api) | 
 | 765 |  * connects an API to this window. only one API can be connected at a time. | 
 | 766 |  * Returns -EINVAL if for some reason the window cannot be connected, which | 
 | 767 |  * can happen if it's connected to some other API. | 
 | 768 |  */ | 
 | 769 | static inline int native_window_api_connect( | 
 | 770 |         struct ANativeWindow* window, int api) | 
 | 771 | { | 
 | 772 |     return window->perform(window, NATIVE_WINDOW_API_CONNECT, api); | 
 | 773 | } | 
 | 774 |  | 
 | 775 | /* | 
 | 776 |  * native_window_api_disconnect(..., int api) | 
 | 777 |  * disconnect the API from this window. | 
 | 778 |  * An error is returned if for instance the window wasn't connected in the | 
 | 779 |  * first place. | 
 | 780 |  */ | 
 | 781 | static inline int native_window_api_disconnect( | 
 | 782 |         struct ANativeWindow* window, int api) | 
 | 783 | { | 
 | 784 |     return window->perform(window, NATIVE_WINDOW_API_DISCONNECT, api); | 
 | 785 | } | 
 | 786 |  | 
 | 787 | /* | 
 | 788 |  * native_window_dequeue_buffer_and_wait(...) | 
 | 789 |  * Dequeue a buffer and wait on the fence associated with that buffer.  The | 
 | 790 |  * buffer may safely be accessed immediately upon this function returning.  An | 
 | 791 |  * error is returned if either of the dequeue or the wait operations fail. | 
 | 792 |  */ | 
 | 793 | static inline int native_window_dequeue_buffer_and_wait(ANativeWindow *anw, | 
 | 794 |         struct ANativeWindowBuffer** anb) { | 
 | 795 |     return anw->dequeueBuffer_DEPRECATED(anw, anb); | 
 | 796 | } | 
 | 797 |  | 
 | 798 | /* | 
 | 799 |  * native_window_set_sideband_stream(..., native_handle_t*) | 
 | 800 |  * Attach a sideband buffer stream to a native window. | 
 | 801 |  */ | 
 | 802 | static inline int native_window_set_sideband_stream( | 
 | 803 |         struct ANativeWindow* window, | 
 | 804 |         native_handle_t* sidebandHandle) | 
 | 805 | { | 
 | 806 |     return window->perform(window, NATIVE_WINDOW_SET_SIDEBAND_STREAM, | 
 | 807 |             sidebandHandle); | 
 | 808 | } | 
 | 809 |  | 
 | 810 | /* | 
 | 811 |  * native_window_set_surface_damage(..., android_native_rect_t* rects, int numRects) | 
 | 812 |  * Set the surface damage (i.e., the region of the surface that has changed | 
 | 813 |  * since the previous frame). The damage set by this call will be reset (to the | 
 | 814 |  * default of full-surface damage) after calling queue, so this must be called | 
 | 815 |  * prior to every frame with damage that does not cover the whole surface if the | 
 | 816 |  * caller desires downstream consumers to use this optimization. | 
 | 817 |  * | 
 | 818 |  * The damage region is specified as an array of rectangles, with the important | 
 | 819 |  * caveat that the origin of the surface is considered to be the bottom-left | 
 | 820 |  * corner, as in OpenGL ES. | 
 | 821 |  * | 
 | 822 |  * If numRects is set to 0, rects may be NULL, and the surface damage will be | 
 | 823 |  * set to the full surface (the same as if this function had not been called for | 
 | 824 |  * this frame). | 
 | 825 |  */ | 
 | 826 | static inline int native_window_set_surface_damage( | 
 | 827 |         struct ANativeWindow* window, | 
 | 828 |         const android_native_rect_t* rects, size_t numRects) | 
 | 829 | { | 
 | 830 |     return window->perform(window, NATIVE_WINDOW_SET_SURFACE_DAMAGE, | 
 | 831 |             rects, numRects); | 
 | 832 | } | 
 | 833 |  | 
 | 834 | /* | 
 | 835 |  * native_window_set_shared_buffer_mode(..., bool sharedBufferMode) | 
 | 836 |  * Enable/disable shared buffer mode | 
 | 837 |  */ | 
 | 838 | static inline int native_window_set_shared_buffer_mode( | 
 | 839 |         struct ANativeWindow* window, | 
 | 840 |         bool sharedBufferMode) | 
 | 841 | { | 
 | 842 |     return window->perform(window, NATIVE_WINDOW_SET_SHARED_BUFFER_MODE, | 
 | 843 |             sharedBufferMode); | 
 | 844 | } | 
 | 845 |  | 
 | 846 | /* | 
 | 847 |  * native_window_set_auto_refresh(..., autoRefresh) | 
 | 848 |  * Enable/disable auto refresh when in shared buffer mode | 
 | 849 |  */ | 
 | 850 | static inline int native_window_set_auto_refresh( | 
 | 851 |         struct ANativeWindow* window, | 
 | 852 |         bool autoRefresh) | 
 | 853 | { | 
 | 854 |     return window->perform(window, NATIVE_WINDOW_SET_AUTO_REFRESH, autoRefresh); | 
 | 855 | } | 
 | 856 |  | 
 | 857 | static inline int native_window_get_refresh_cycle_duration( | 
 | 858 |         struct ANativeWindow* window, | 
 | 859 |         int64_t* outRefreshDuration) | 
 | 860 | { | 
 | 861 |     return window->perform(window, NATIVE_WINDOW_GET_REFRESH_CYCLE_DURATION, | 
 | 862 |             outRefreshDuration); | 
 | 863 | } | 
 | 864 |  | 
 | 865 | static inline int native_window_get_next_frame_id( | 
 | 866 |         struct ANativeWindow* window, uint64_t* frameId) | 
 | 867 | { | 
 | 868 |     return window->perform(window, NATIVE_WINDOW_GET_NEXT_FRAME_ID, frameId); | 
 | 869 | } | 
 | 870 |  | 
 | 871 | static inline int native_window_enable_frame_timestamps( | 
 | 872 |         struct ANativeWindow* window, bool enable) | 
 | 873 | { | 
 | 874 |     return window->perform(window, NATIVE_WINDOW_ENABLE_FRAME_TIMESTAMPS, | 
 | 875 |             enable); | 
 | 876 | } | 
 | 877 |  | 
 | 878 | static inline int native_window_get_compositor_timing( | 
 | 879 |         struct ANativeWindow* window, | 
 | 880 |         int64_t* compositeDeadline, int64_t* compositeInterval, | 
 | 881 |         int64_t* compositeToPresentLatency) | 
 | 882 | { | 
 | 883 |     return window->perform(window, NATIVE_WINDOW_GET_COMPOSITOR_TIMING, | 
 | 884 |             compositeDeadline, compositeInterval, compositeToPresentLatency); | 
 | 885 | } | 
 | 886 |  | 
 | 887 | static inline int native_window_get_frame_timestamps( | 
 | 888 |         struct ANativeWindow* window, uint64_t frameId, | 
 | 889 |         int64_t* outRequestedPresentTime, int64_t* outAcquireTime, | 
 | 890 |         int64_t* outLatchTime, int64_t* outFirstRefreshStartTime, | 
 | 891 |         int64_t* outLastRefreshStartTime, int64_t* outGpuCompositionDoneTime, | 
 | 892 |         int64_t* outDisplayPresentTime, int64_t* outDequeueReadyTime, | 
 | 893 |         int64_t* outReleaseTime) | 
 | 894 | { | 
 | 895 |     return window->perform(window, NATIVE_WINDOW_GET_FRAME_TIMESTAMPS, | 
 | 896 |             frameId, outRequestedPresentTime, outAcquireTime, outLatchTime, | 
 | 897 |             outFirstRefreshStartTime, outLastRefreshStartTime, | 
 | 898 |             outGpuCompositionDoneTime, outDisplayPresentTime, | 
 | 899 |             outDequeueReadyTime, outReleaseTime); | 
 | 900 | } | 
 | 901 |  | 
 | 902 | static inline int native_window_get_wide_color_support( | 
 | 903 |     struct ANativeWindow* window, bool* outSupport) { | 
| Chia-I Wu | e2786ea | 2017-08-07 10:36:08 -0700 | [diff] [blame] | 904 |     return window->perform(window, NATIVE_WINDOW_GET_WIDE_COLOR_SUPPORT, | 
 | 905 |             outSupport); | 
| Mathias Agopian | a6c0e20 | 2017-03-20 15:48:44 -0700 | [diff] [blame] | 906 | } | 
 | 907 |  | 
 | 908 | static inline int native_window_get_hdr_support(struct ANativeWindow* window, | 
 | 909 |                                                 bool* outSupport) { | 
| Chia-I Wu | e2786ea | 2017-08-07 10:36:08 -0700 | [diff] [blame] | 910 |     return window->perform(window, NATIVE_WINDOW_GET_HDR_SUPPORT, outSupport); | 
 | 911 | } | 
 | 912 |  | 
 | 913 | static inline int native_window_get_consumer_usage(struct ANativeWindow* window, | 
 | 914 |                                                    uint64_t* outUsage) { | 
 | 915 |     return window->perform(window, NATIVE_WINDOW_GET_CONSUMER_USAGE64, outUsage); | 
| Mathias Agopian | a6c0e20 | 2017-03-20 15:48:44 -0700 | [diff] [blame] | 916 | } | 
 | 917 |  | 
 | 918 | __END_DECLS |