| 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, | 
| Peiyong Lin | 654f87b | 2018-01-30 14:21:33 -0800 | [diff] [blame] | 182 |  | 
|  | 183 | /* | 
|  | 184 | * Returns data space for the buffers. | 
|  | 185 | */ | 
|  | 186 | NATIVE_WINDOW_DATASPACE = 20, | 
| Yiwei Zhang | dbd9615 | 2018-02-08 14:22:53 -0800 | [diff] [blame] | 187 |  | 
|  | 188 | /* | 
|  | 189 | * Returns maxBufferCount set by BufferQueueConsumer | 
|  | 190 | */ | 
|  | 191 | NATIVE_WINDOW_MAX_BUFFER_COUNT = 21, | 
| Mathias Agopian | a6c0e20 | 2017-03-20 15:48:44 -0700 | [diff] [blame] | 192 | }; | 
|  | 193 |  | 
|  | 194 | /* Valid operations for the (*perform)() hook. | 
|  | 195 | * | 
|  | 196 | * Values marked as 'deprecated' are supported, but have been superceded by | 
|  | 197 | * other functionality. | 
|  | 198 | * | 
|  | 199 | * Values marked as 'private' should be considered private to the framework. | 
|  | 200 | * HAL implementation code with access to an ANativeWindow should not use these, | 
|  | 201 | * as it may not interact properly with the framework's use of the | 
|  | 202 | * ANativeWindow. | 
|  | 203 | */ | 
|  | 204 | enum { | 
| Valerie Hau | a82679d | 2018-11-21 09:31:43 -0800 | [diff] [blame] | 205 | // clang-format off | 
| Yiwei Zhang | 538cedc | 2019-06-24 19:35:03 -0700 | [diff] [blame] | 206 | NATIVE_WINDOW_SET_USAGE                       =  0,   /* deprecated */ | 
|  | 207 | NATIVE_WINDOW_CONNECT                         =  1,   /* deprecated */ | 
|  | 208 | NATIVE_WINDOW_DISCONNECT                      =  2,   /* deprecated */ | 
|  | 209 | NATIVE_WINDOW_SET_CROP                        =  3,   /* private */ | 
|  | 210 | NATIVE_WINDOW_SET_BUFFER_COUNT                =  4, | 
|  | 211 | NATIVE_WINDOW_SET_BUFFERS_GEOMETRY            =  5,   /* deprecated */ | 
|  | 212 | NATIVE_WINDOW_SET_BUFFERS_TRANSFORM           =  6, | 
|  | 213 | NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP           =  7, | 
|  | 214 | NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS          =  8, | 
|  | 215 | NATIVE_WINDOW_SET_BUFFERS_FORMAT              =  9, | 
|  | 216 | NATIVE_WINDOW_SET_SCALING_MODE                = 10,   /* private */ | 
|  | 217 | NATIVE_WINDOW_LOCK                            = 11,   /* private */ | 
|  | 218 | NATIVE_WINDOW_UNLOCK_AND_POST                 = 12,   /* private */ | 
|  | 219 | NATIVE_WINDOW_API_CONNECT                     = 13,   /* private */ | 
|  | 220 | NATIVE_WINDOW_API_DISCONNECT                  = 14,   /* private */ | 
|  | 221 | NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS     = 15,   /* private */ | 
|  | 222 | NATIVE_WINDOW_SET_POST_TRANSFORM_CROP         = 16,   /* deprecated, unimplemented */ | 
|  | 223 | NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM    = 17,   /* private */ | 
|  | 224 | NATIVE_WINDOW_SET_SIDEBAND_STREAM             = 18, | 
|  | 225 | NATIVE_WINDOW_SET_BUFFERS_DATASPACE           = 19, | 
|  | 226 | NATIVE_WINDOW_SET_SURFACE_DAMAGE              = 20,   /* private */ | 
|  | 227 | NATIVE_WINDOW_SET_SHARED_BUFFER_MODE          = 21, | 
|  | 228 | NATIVE_WINDOW_SET_AUTO_REFRESH                = 22, | 
|  | 229 | NATIVE_WINDOW_GET_REFRESH_CYCLE_DURATION      = 23, | 
|  | 230 | NATIVE_WINDOW_GET_NEXT_FRAME_ID               = 24, | 
|  | 231 | NATIVE_WINDOW_ENABLE_FRAME_TIMESTAMPS         = 25, | 
|  | 232 | NATIVE_WINDOW_GET_COMPOSITOR_TIMING           = 26, | 
|  | 233 | NATIVE_WINDOW_GET_FRAME_TIMESTAMPS            = 27, | 
|  | 234 | NATIVE_WINDOW_GET_WIDE_COLOR_SUPPORT          = 28, | 
|  | 235 | NATIVE_WINDOW_GET_HDR_SUPPORT                 = 29, | 
|  | 236 | NATIVE_WINDOW_SET_USAGE64                     = 30, | 
|  | 237 | NATIVE_WINDOW_GET_CONSUMER_USAGE64            = 31, | 
|  | 238 | NATIVE_WINDOW_SET_BUFFERS_SMPTE2086_METADATA  = 32, | 
|  | 239 | NATIVE_WINDOW_SET_BUFFERS_CTA861_3_METADATA   = 33, | 
| Valerie Hau | a82679d | 2018-11-21 09:31:43 -0800 | [diff] [blame] | 240 | NATIVE_WINDOW_SET_BUFFERS_HDR10_PLUS_METADATA = 34, | 
| Yiwei Zhang | 538cedc | 2019-06-24 19:35:03 -0700 | [diff] [blame] | 241 | NATIVE_WINDOW_SET_AUTO_PREROTATION            = 35, | 
| Valerie Hau | a82679d | 2018-11-21 09:31:43 -0800 | [diff] [blame] | 242 | // clang-format on | 
| Mathias Agopian | a6c0e20 | 2017-03-20 15:48:44 -0700 | [diff] [blame] | 243 | }; | 
|  | 244 |  | 
|  | 245 | /* parameter for NATIVE_WINDOW_[API_][DIS]CONNECT */ | 
|  | 246 | enum { | 
|  | 247 | /* Buffers will be queued by EGL via eglSwapBuffers after being filled using | 
|  | 248 | * OpenGL ES. | 
|  | 249 | */ | 
|  | 250 | NATIVE_WINDOW_API_EGL = 1, | 
|  | 251 |  | 
|  | 252 | /* Buffers will be queued after being filled using the CPU | 
|  | 253 | */ | 
|  | 254 | NATIVE_WINDOW_API_CPU = 2, | 
|  | 255 |  | 
|  | 256 | /* Buffers will be queued by Stagefright after being filled by a video | 
|  | 257 | * decoder.  The video decoder can either be a software or hardware decoder. | 
|  | 258 | */ | 
|  | 259 | NATIVE_WINDOW_API_MEDIA = 3, | 
|  | 260 |  | 
|  | 261 | /* Buffers will be queued by the the camera HAL. | 
|  | 262 | */ | 
|  | 263 | NATIVE_WINDOW_API_CAMERA = 4, | 
|  | 264 | }; | 
|  | 265 |  | 
|  | 266 | /* parameter for NATIVE_WINDOW_SET_BUFFERS_TRANSFORM */ | 
|  | 267 | enum { | 
|  | 268 | /* flip source image horizontally */ | 
|  | 269 | NATIVE_WINDOW_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H , | 
|  | 270 | /* flip source image vertically */ | 
|  | 271 | NATIVE_WINDOW_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V, | 
|  | 272 | /* rotate source image 90 degrees clock-wise, and is applied after TRANSFORM_FLIP_{H|V} */ | 
|  | 273 | NATIVE_WINDOW_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90, | 
|  | 274 | /* rotate source image 180 degrees */ | 
|  | 275 | NATIVE_WINDOW_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180, | 
|  | 276 | /* rotate source image 270 degrees clock-wise */ | 
|  | 277 | NATIVE_WINDOW_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270, | 
|  | 278 | /* transforms source by the inverse transform of the screen it is displayed onto. This | 
|  | 279 | * transform is applied last */ | 
|  | 280 | NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY = 0x08 | 
|  | 281 | }; | 
|  | 282 |  | 
|  | 283 | /* parameter for NATIVE_WINDOW_SET_SCALING_MODE | 
|  | 284 | * keep in sync with Surface.java in frameworks/base */ | 
|  | 285 | enum { | 
|  | 286 | /* the window content is not updated (frozen) until a buffer of | 
|  | 287 | * the window size is received (enqueued) | 
|  | 288 | */ | 
|  | 289 | NATIVE_WINDOW_SCALING_MODE_FREEZE           = 0, | 
|  | 290 | /* the buffer is scaled in both dimensions to match the window size */ | 
|  | 291 | NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW  = 1, | 
|  | 292 | /* the buffer is scaled uniformly such that the smaller dimension | 
|  | 293 | * of the buffer matches the window size (cropping in the process) | 
|  | 294 | */ | 
|  | 295 | NATIVE_WINDOW_SCALING_MODE_SCALE_CROP       = 2, | 
|  | 296 | /* the window is clipped to the size of the buffer's crop rectangle; pixels | 
|  | 297 | * outside the crop rectangle are treated as if they are completely | 
|  | 298 | * transparent. | 
|  | 299 | */ | 
|  | 300 | NATIVE_WINDOW_SCALING_MODE_NO_SCALE_CROP    = 3, | 
|  | 301 | }; | 
|  | 302 |  | 
|  | 303 | /* values returned by the NATIVE_WINDOW_CONCRETE_TYPE query */ | 
|  | 304 | enum { | 
|  | 305 | NATIVE_WINDOW_FRAMEBUFFER               = 0, /* FramebufferNativeWindow */ | 
|  | 306 | NATIVE_WINDOW_SURFACE                   = 1, /* Surface */ | 
|  | 307 | }; | 
|  | 308 |  | 
|  | 309 | /* parameter for NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP | 
|  | 310 | * | 
|  | 311 | * Special timestamp value to indicate that timestamps should be auto-generated | 
|  | 312 | * by the native window when queueBuffer is called.  This is equal to INT64_MIN, | 
|  | 313 | * defined directly to avoid problems with C99/C++ inclusion of stdint.h. | 
|  | 314 | */ | 
|  | 315 | static const int64_t NATIVE_WINDOW_TIMESTAMP_AUTO = (-9223372036854775807LL-1); | 
|  | 316 |  | 
| Brian Anderson | dc96fdf | 2017-03-20 16:54:25 -0700 | [diff] [blame] | 317 | /* parameter for NATIVE_WINDOW_GET_FRAME_TIMESTAMPS | 
|  | 318 | * | 
|  | 319 | * Special timestamp value to indicate the timestamps aren't yet known or | 
|  | 320 | * that they are invalid. | 
|  | 321 | */ | 
|  | 322 | static const int64_t NATIVE_WINDOW_TIMESTAMP_PENDING = -2; | 
|  | 323 | static const int64_t NATIVE_WINDOW_TIMESTAMP_INVALID = -1; | 
|  | 324 |  | 
| Mathias Agopian | a6c0e20 | 2017-03-20 15:48:44 -0700 | [diff] [blame] | 325 | struct ANativeWindow | 
|  | 326 | { | 
|  | 327 | #ifdef __cplusplus | 
|  | 328 | ANativeWindow() | 
|  | 329 | : flags(0), minSwapInterval(0), maxSwapInterval(0), xdpi(0), ydpi(0) | 
|  | 330 | { | 
|  | 331 | common.magic = ANDROID_NATIVE_WINDOW_MAGIC; | 
|  | 332 | common.version = sizeof(ANativeWindow); | 
|  | 333 | memset(common.reserved, 0, sizeof(common.reserved)); | 
|  | 334 | } | 
|  | 335 |  | 
|  | 336 | /* Implement the methods that sp<ANativeWindow> expects so that it | 
|  | 337 | can be used to automatically refcount ANativeWindow's. */ | 
|  | 338 | void incStrong(const void* /*id*/) const { | 
|  | 339 | common.incRef(const_cast<android_native_base_t*>(&common)); | 
|  | 340 | } | 
|  | 341 | void decStrong(const void* /*id*/) const { | 
|  | 342 | common.decRef(const_cast<android_native_base_t*>(&common)); | 
|  | 343 | } | 
|  | 344 | #endif | 
|  | 345 |  | 
|  | 346 | struct android_native_base_t common; | 
|  | 347 |  | 
|  | 348 | /* flags describing some attributes of this surface or its updater */ | 
|  | 349 | const uint32_t flags; | 
|  | 350 |  | 
|  | 351 | /* min swap interval supported by this updated */ | 
|  | 352 | const int   minSwapInterval; | 
|  | 353 |  | 
|  | 354 | /* max swap interval supported by this updated */ | 
|  | 355 | const int   maxSwapInterval; | 
|  | 356 |  | 
|  | 357 | /* horizontal and vertical resolution in DPI */ | 
|  | 358 | const float xdpi; | 
|  | 359 | const float ydpi; | 
|  | 360 |  | 
|  | 361 | /* Some storage reserved for the OEM's driver. */ | 
|  | 362 | intptr_t    oem[4]; | 
|  | 363 |  | 
|  | 364 | /* | 
|  | 365 | * Set the swap interval for this surface. | 
|  | 366 | * | 
|  | 367 | * Returns 0 on success or -errno on error. | 
|  | 368 | */ | 
|  | 369 | int     (*setSwapInterval)(struct ANativeWindow* window, | 
|  | 370 | int interval); | 
|  | 371 |  | 
|  | 372 | /* | 
|  | 373 | * Hook called by EGL to acquire a buffer. After this call, the buffer | 
|  | 374 | * is not locked, so its content cannot be modified. This call may block if | 
|  | 375 | * no buffers are available. | 
|  | 376 | * | 
|  | 377 | * The window holds a reference to the buffer between dequeueBuffer and | 
|  | 378 | * either queueBuffer or cancelBuffer, so clients only need their own | 
|  | 379 | * reference if they might use the buffer after queueing or canceling it. | 
|  | 380 | * Holding a reference to a buffer after queueing or canceling it is only | 
|  | 381 | * allowed if a specific buffer count has been set. | 
|  | 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 the new dequeueBuffer function that | 
|  | 387 | * outputs a fence file descriptor should be used in its place. | 
|  | 388 | */ | 
|  | 389 | int     (*dequeueBuffer_DEPRECATED)(struct ANativeWindow* window, | 
|  | 390 | struct ANativeWindowBuffer** buffer); | 
|  | 391 |  | 
|  | 392 | /* | 
|  | 393 | * hook called by EGL to lock a buffer. This MUST be called before modifying | 
|  | 394 | * the content of a buffer. The buffer must have been acquired with | 
|  | 395 | * dequeueBuffer first. | 
|  | 396 | * | 
|  | 397 | * Returns 0 on success or -errno on error. | 
|  | 398 | * | 
|  | 399 | * XXX: This function is deprecated.  It will continue to work for some | 
|  | 400 | * time for binary compatibility, but it is essentially a no-op, and calls | 
|  | 401 | * to it should be removed. | 
|  | 402 | */ | 
|  | 403 | int     (*lockBuffer_DEPRECATED)(struct ANativeWindow* window, | 
|  | 404 | struct ANativeWindowBuffer* buffer); | 
|  | 405 |  | 
|  | 406 | /* | 
|  | 407 | * Hook called by EGL when modifications to the render buffer are done. | 
|  | 408 | * This unlocks and post the buffer. | 
|  | 409 | * | 
|  | 410 | * The window holds a reference to the buffer between dequeueBuffer and | 
|  | 411 | * either queueBuffer or cancelBuffer, so clients only need their own | 
|  | 412 | * reference if they might use the buffer after queueing or canceling it. | 
|  | 413 | * Holding a reference to a buffer after queueing or canceling it is only | 
|  | 414 | * allowed if a specific buffer count has been set. | 
|  | 415 | * | 
|  | 416 | * Buffers MUST be queued in the same order than they were dequeued. | 
|  | 417 | * | 
|  | 418 | * Returns 0 on success or -errno on error. | 
|  | 419 | * | 
|  | 420 | * XXX: This function is deprecated.  It will continue to work for some | 
|  | 421 | * time for binary compatibility, but the new queueBuffer function that | 
|  | 422 | * takes a fence file descriptor should be used in its place (pass a value | 
|  | 423 | * of -1 for the fence file descriptor if there is no valid one to pass). | 
|  | 424 | */ | 
|  | 425 | int     (*queueBuffer_DEPRECATED)(struct ANativeWindow* window, | 
|  | 426 | struct ANativeWindowBuffer* buffer); | 
|  | 427 |  | 
|  | 428 | /* | 
|  | 429 | * hook used to retrieve information about the native window. | 
|  | 430 | * | 
|  | 431 | * Returns 0 on success or -errno on error. | 
|  | 432 | */ | 
|  | 433 | int     (*query)(const struct ANativeWindow* window, | 
|  | 434 | int what, int* value); | 
|  | 435 |  | 
|  | 436 | /* | 
|  | 437 | * hook used to perform various operations on the surface. | 
|  | 438 | * (*perform)() is a generic mechanism to add functionality to | 
|  | 439 | * ANativeWindow while keeping backward binary compatibility. | 
|  | 440 | * | 
|  | 441 | * DO NOT CALL THIS HOOK DIRECTLY.  Instead, use the helper functions | 
|  | 442 | * defined below. | 
|  | 443 | * | 
|  | 444 | * (*perform)() returns -ENOENT if the 'what' parameter is not supported | 
|  | 445 | * by the surface's implementation. | 
|  | 446 | * | 
|  | 447 | * See above for a list of valid operations, such as | 
|  | 448 | * NATIVE_WINDOW_SET_USAGE or NATIVE_WINDOW_CONNECT | 
|  | 449 | */ | 
|  | 450 | int     (*perform)(struct ANativeWindow* window, | 
|  | 451 | int operation, ... ); | 
|  | 452 |  | 
|  | 453 | /* | 
|  | 454 | * Hook used to cancel a buffer that has been dequeued. | 
|  | 455 | * No synchronization is performed between dequeue() and cancel(), so | 
|  | 456 | * either external synchronization is needed, or these functions must be | 
|  | 457 | * called from the same thread. | 
|  | 458 | * | 
|  | 459 | * The window holds a reference to the buffer between dequeueBuffer and | 
|  | 460 | * either queueBuffer or cancelBuffer, so clients only need their own | 
|  | 461 | * reference if they might use the buffer after queueing or canceling it. | 
|  | 462 | * Holding a reference to a buffer after queueing or canceling it is only | 
|  | 463 | * allowed if a specific buffer count has been set. | 
|  | 464 | * | 
|  | 465 | * XXX: This function is deprecated.  It will continue to work for some | 
|  | 466 | * time for binary compatibility, but the new cancelBuffer function that | 
|  | 467 | * takes a fence file descriptor should be used in its place (pass a value | 
|  | 468 | * of -1 for the fence file descriptor if there is no valid one to pass). | 
|  | 469 | */ | 
|  | 470 | int     (*cancelBuffer_DEPRECATED)(struct ANativeWindow* window, | 
|  | 471 | struct ANativeWindowBuffer* buffer); | 
|  | 472 |  | 
|  | 473 | /* | 
|  | 474 | * Hook called by EGL to acquire a buffer. This call may block if no | 
|  | 475 | * buffers are available. | 
|  | 476 | * | 
|  | 477 | * The window holds a reference to the buffer between dequeueBuffer and | 
|  | 478 | * either queueBuffer or cancelBuffer, so clients only need their own | 
|  | 479 | * reference if they might use the buffer after queueing or canceling it. | 
|  | 480 | * Holding a reference to a buffer after queueing or canceling it is only | 
|  | 481 | * allowed if a specific buffer count has been set. | 
|  | 482 | * | 
|  | 483 | * The libsync fence file descriptor returned in the int pointed to by the | 
|  | 484 | * fenceFd argument will refer to the fence that must signal before the | 
|  | 485 | * dequeued buffer may be written to.  A value of -1 indicates that the | 
|  | 486 | * caller may access the buffer immediately without waiting on a fence.  If | 
|  | 487 | * a valid file descriptor is returned (i.e. any value except -1) then the | 
|  | 488 | * caller is responsible for closing the file descriptor. | 
|  | 489 | * | 
|  | 490 | * Returns 0 on success or -errno on error. | 
|  | 491 | */ | 
|  | 492 | int     (*dequeueBuffer)(struct ANativeWindow* window, | 
|  | 493 | struct ANativeWindowBuffer** buffer, int* fenceFd); | 
|  | 494 |  | 
|  | 495 | /* | 
|  | 496 | * Hook called by EGL when modifications to the render buffer are done. | 
|  | 497 | * This unlocks and post the buffer. | 
|  | 498 | * | 
|  | 499 | * The window holds a reference to the buffer between dequeueBuffer and | 
|  | 500 | * either queueBuffer or cancelBuffer, so clients only need their own | 
|  | 501 | * reference if they might use the buffer after queueing or canceling it. | 
|  | 502 | * Holding a reference to a buffer after queueing or canceling it is only | 
|  | 503 | * allowed if a specific buffer count has been set. | 
|  | 504 | * | 
|  | 505 | * The fenceFd argument specifies a libsync fence file descriptor for a | 
|  | 506 | * fence that must signal before the buffer can be accessed.  If the buffer | 
|  | 507 | * can be accessed immediately then a value of -1 should be used.  The | 
|  | 508 | * caller must not use the file descriptor after it is passed to | 
|  | 509 | * queueBuffer, and the ANativeWindow implementation is responsible for | 
|  | 510 | * closing it. | 
|  | 511 | * | 
|  | 512 | * Returns 0 on success or -errno on error. | 
|  | 513 | */ | 
|  | 514 | int     (*queueBuffer)(struct ANativeWindow* window, | 
|  | 515 | struct ANativeWindowBuffer* buffer, int fenceFd); | 
|  | 516 |  | 
|  | 517 | /* | 
|  | 518 | * Hook used to cancel a buffer that has been dequeued. | 
|  | 519 | * No synchronization is performed between dequeue() and cancel(), so | 
|  | 520 | * either external synchronization is needed, or these functions must be | 
|  | 521 | * called from the same thread. | 
|  | 522 | * | 
|  | 523 | * The window holds a reference to the buffer between dequeueBuffer and | 
|  | 524 | * either queueBuffer or cancelBuffer, so clients only need their own | 
|  | 525 | * reference if they might use the buffer after queueing or canceling it. | 
|  | 526 | * Holding a reference to a buffer after queueing or canceling it is only | 
|  | 527 | * allowed if a specific buffer count has been set. | 
|  | 528 | * | 
|  | 529 | * The fenceFd argument specifies a libsync fence file decsriptor for a | 
|  | 530 | * fence that must signal before the buffer can be accessed.  If the buffer | 
|  | 531 | * can be accessed immediately then a value of -1 should be used. | 
|  | 532 | * | 
|  | 533 | * Note that if the client has not waited on the fence that was returned | 
|  | 534 | * from dequeueBuffer, that same fence should be passed to cancelBuffer to | 
|  | 535 | * ensure that future uses of the buffer are preceded by a wait on that | 
|  | 536 | * fence.  The caller must not use the file descriptor after it is passed | 
|  | 537 | * to cancelBuffer, and the ANativeWindow implementation is responsible for | 
|  | 538 | * closing it. | 
|  | 539 | * | 
|  | 540 | * Returns 0 on success or -errno on error. | 
|  | 541 | */ | 
|  | 542 | int     (*cancelBuffer)(struct ANativeWindow* window, | 
|  | 543 | struct ANativeWindowBuffer* buffer, int fenceFd); | 
|  | 544 | }; | 
|  | 545 |  | 
|  | 546 | /* Backwards compatibility: use ANativeWindow (struct ANativeWindow in C). | 
|  | 547 | * android_native_window_t is deprecated. | 
|  | 548 | */ | 
| Mathias Agopian | a6c0e20 | 2017-03-20 15:48:44 -0700 | [diff] [blame] | 549 | typedef struct ANativeWindow android_native_window_t __deprecated; | 
|  | 550 |  | 
|  | 551 | /* | 
| Mathias Agopian | cb496ac | 2017-05-22 14:21:00 -0700 | [diff] [blame] | 552 | *  native_window_set_usage64(..., usage) | 
| Mathias Agopian | a6c0e20 | 2017-03-20 15:48:44 -0700 | [diff] [blame] | 553 | *  Sets the intended usage flags for the next buffers | 
|  | 554 | *  acquired with (*lockBuffer)() and on. | 
| Mathias Agopian | cb496ac | 2017-05-22 14:21:00 -0700 | [diff] [blame] | 555 | * | 
|  | 556 | *  Valid usage flags are defined in android/hardware_buffer.h | 
|  | 557 | *  All AHARDWAREBUFFER_USAGE_* flags can be specified as needed. | 
|  | 558 | * | 
| Mathias Agopian | a6c0e20 | 2017-03-20 15:48:44 -0700 | [diff] [blame] | 559 | *  Calling this function will usually cause following buffers to be | 
|  | 560 | *  reallocated. | 
|  | 561 | */ | 
| Mathias Agopian | cb496ac | 2017-05-22 14:21:00 -0700 | [diff] [blame] | 562 | static inline int native_window_set_usage(struct ANativeWindow* window, uint64_t usage) { | 
|  | 563 | return window->perform(window, NATIVE_WINDOW_SET_USAGE64, usage); | 
| Mathias Agopian | a6c0e20 | 2017-03-20 15:48:44 -0700 | [diff] [blame] | 564 | } | 
|  | 565 |  | 
|  | 566 | /* deprecated. Always returns 0. Don't call. */ | 
|  | 567 | static inline int native_window_connect( | 
|  | 568 | struct ANativeWindow* window __UNUSED, int api __UNUSED) __deprecated; | 
|  | 569 |  | 
|  | 570 | static inline int native_window_connect( | 
|  | 571 | struct ANativeWindow* window __UNUSED, int api __UNUSED) { | 
|  | 572 | return 0; | 
|  | 573 | } | 
|  | 574 |  | 
|  | 575 | /* deprecated. Always returns 0. Don't call. */ | 
|  | 576 | static inline int native_window_disconnect( | 
|  | 577 | struct ANativeWindow* window __UNUSED, int api __UNUSED) __deprecated; | 
|  | 578 |  | 
|  | 579 | static inline int native_window_disconnect( | 
|  | 580 | struct ANativeWindow* window __UNUSED, int api __UNUSED) { | 
|  | 581 | return 0; | 
|  | 582 | } | 
|  | 583 |  | 
|  | 584 | /* | 
|  | 585 | * native_window_set_crop(..., crop) | 
|  | 586 | * Sets which region of the next queued buffers needs to be considered. | 
|  | 587 | * Depending on the scaling mode, a buffer's crop region is scaled and/or | 
|  | 588 | * cropped to match the surface's size.  This function sets the crop in | 
|  | 589 | * pre-transformed buffer pixel coordinates. | 
|  | 590 | * | 
|  | 591 | * The specified crop region applies to all buffers queued after it is called. | 
|  | 592 | * | 
|  | 593 | * If 'crop' is NULL, subsequently queued buffers won't be cropped. | 
|  | 594 | * | 
|  | 595 | * An error is returned if for instance the crop region is invalid, out of the | 
|  | 596 | * buffer's bound or if the window is invalid. | 
|  | 597 | */ | 
|  | 598 | static inline int native_window_set_crop( | 
|  | 599 | struct ANativeWindow* window, | 
|  | 600 | android_native_rect_t const * crop) | 
|  | 601 | { | 
|  | 602 | return window->perform(window, NATIVE_WINDOW_SET_CROP, crop); | 
|  | 603 | } | 
|  | 604 |  | 
|  | 605 | /* | 
| Mathias Agopian | a6c0e20 | 2017-03-20 15:48:44 -0700 | [diff] [blame] | 606 | * native_window_set_buffer_count(..., count) | 
|  | 607 | * Sets the number of buffers associated with this native window. | 
|  | 608 | */ | 
|  | 609 | static inline int native_window_set_buffer_count( | 
|  | 610 | struct ANativeWindow* window, | 
|  | 611 | size_t bufferCount) | 
|  | 612 | { | 
|  | 613 | return window->perform(window, NATIVE_WINDOW_SET_BUFFER_COUNT, bufferCount); | 
|  | 614 | } | 
|  | 615 |  | 
|  | 616 | /* | 
|  | 617 | * native_window_set_buffers_geometry(..., int w, int h, int format) | 
|  | 618 | * All buffers dequeued after this call will have the dimensions and format | 
|  | 619 | * specified.  A successful call to this function has the same effect as calling | 
|  | 620 | * native_window_set_buffers_size and native_window_set_buffers_format. | 
|  | 621 | * | 
|  | 622 | * XXX: This function is deprecated.  The native_window_set_buffers_dimensions | 
|  | 623 | * and native_window_set_buffers_format functions should be used instead. | 
|  | 624 | */ | 
|  | 625 | static inline int native_window_set_buffers_geometry( | 
|  | 626 | struct ANativeWindow* window, | 
|  | 627 | int w, int h, int format) __deprecated; | 
|  | 628 |  | 
|  | 629 | static inline int native_window_set_buffers_geometry( | 
|  | 630 | struct ANativeWindow* window, | 
|  | 631 | int w, int h, int format) | 
|  | 632 | { | 
|  | 633 | return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_GEOMETRY, | 
|  | 634 | w, h, format); | 
|  | 635 | } | 
|  | 636 |  | 
|  | 637 | /* | 
|  | 638 | * native_window_set_buffers_dimensions(..., int w, int h) | 
|  | 639 | * All buffers dequeued after this call will have the dimensions specified. | 
|  | 640 | * In particular, all buffers will have a fixed-size, independent from the | 
|  | 641 | * native-window size. They will be scaled according to the scaling mode | 
|  | 642 | * (see native_window_set_scaling_mode) upon window composition. | 
|  | 643 | * | 
|  | 644 | * If w and h are 0, the normal behavior is restored. That is, dequeued buffers | 
|  | 645 | * following this call will be sized to match the window's size. | 
|  | 646 | * | 
|  | 647 | * Calling this function will reset the window crop to a NULL value, which | 
|  | 648 | * disables cropping of the buffers. | 
|  | 649 | */ | 
|  | 650 | static inline int native_window_set_buffers_dimensions( | 
|  | 651 | struct ANativeWindow* window, | 
|  | 652 | int w, int h) | 
|  | 653 | { | 
|  | 654 | return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS, | 
|  | 655 | w, h); | 
|  | 656 | } | 
|  | 657 |  | 
|  | 658 | /* | 
|  | 659 | * native_window_set_buffers_user_dimensions(..., int w, int h) | 
|  | 660 | * | 
|  | 661 | * Sets the user buffer size for the window, which overrides the | 
|  | 662 | * window's size.  All buffers dequeued after this call will have the | 
|  | 663 | * dimensions specified unless overridden by | 
|  | 664 | * native_window_set_buffers_dimensions.  All buffers will have a | 
|  | 665 | * fixed-size, independent from the native-window size. They will be | 
|  | 666 | * scaled according to the scaling mode (see | 
|  | 667 | * native_window_set_scaling_mode) upon window composition. | 
|  | 668 | * | 
|  | 669 | * If w and h are 0, the normal behavior is restored. That is, the | 
|  | 670 | * default buffer size will match the windows's size. | 
|  | 671 | * | 
|  | 672 | * Calling this function will reset the window crop to a NULL value, which | 
|  | 673 | * disables cropping of the buffers. | 
|  | 674 | */ | 
|  | 675 | static inline int native_window_set_buffers_user_dimensions( | 
|  | 676 | struct ANativeWindow* window, | 
|  | 677 | int w, int h) | 
|  | 678 | { | 
|  | 679 | return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS, | 
|  | 680 | w, h); | 
|  | 681 | } | 
|  | 682 |  | 
|  | 683 | /* | 
|  | 684 | * native_window_set_buffers_format(..., int format) | 
|  | 685 | * All buffers dequeued after this call will have the format specified. | 
|  | 686 | * | 
|  | 687 | * If the specified format is 0, the default buffer format will be used. | 
|  | 688 | */ | 
|  | 689 | static inline int native_window_set_buffers_format( | 
|  | 690 | struct ANativeWindow* window, | 
|  | 691 | int format) | 
|  | 692 | { | 
|  | 693 | return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_FORMAT, format); | 
|  | 694 | } | 
|  | 695 |  | 
|  | 696 | /* | 
|  | 697 | * native_window_set_buffers_data_space(..., int dataSpace) | 
|  | 698 | * All buffers queued after this call will be associated with the dataSpace | 
|  | 699 | * parameter specified. | 
|  | 700 | * | 
|  | 701 | * dataSpace specifies additional information about the buffer that's dependent | 
|  | 702 | * on the buffer format and the endpoints. For example, it can be used to convey | 
|  | 703 | * the color space of the image data in the buffer, or it can be used to | 
|  | 704 | * indicate that the buffers contain depth measurement data instead of color | 
|  | 705 | * images.  The default dataSpace is 0, HAL_DATASPACE_UNKNOWN, unless it has been | 
|  | 706 | * overridden by the consumer. | 
|  | 707 | */ | 
|  | 708 | static inline int native_window_set_buffers_data_space( | 
|  | 709 | struct ANativeWindow* window, | 
|  | 710 | android_dataspace_t dataSpace) | 
|  | 711 | { | 
|  | 712 | return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DATASPACE, | 
|  | 713 | dataSpace); | 
|  | 714 | } | 
|  | 715 |  | 
|  | 716 | /* | 
| Courtney Goeltzenleuchter | 9bad0d7 | 2017-12-19 12:34:34 -0700 | [diff] [blame] | 717 | * native_window_set_buffers_smpte2086_metadata(..., metadata) | 
|  | 718 | * All buffers queued after this call will be associated with the SMPTE | 
|  | 719 | * ST.2086 metadata specified. | 
|  | 720 | * | 
|  | 721 | * metadata specifies additional information about the contents of the buffer | 
|  | 722 | * that may affect how it's displayed.  When it is nullptr, it means no such | 
|  | 723 | * information is available.  No SMPTE ST.2086 metadata is associated with the | 
|  | 724 | * buffers by default. | 
|  | 725 | */ | 
|  | 726 | static inline int native_window_set_buffers_smpte2086_metadata( | 
|  | 727 | struct ANativeWindow* window, | 
|  | 728 | const struct android_smpte2086_metadata* metadata) | 
|  | 729 | { | 
|  | 730 | return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_SMPTE2086_METADATA, | 
|  | 731 | metadata); | 
|  | 732 | } | 
|  | 733 |  | 
|  | 734 | /* | 
|  | 735 | * native_window_set_buffers_cta861_3_metadata(..., metadata) | 
|  | 736 | * All buffers queued after this call will be associated with the CTA-861.3 | 
|  | 737 | * metadata specified. | 
|  | 738 | * | 
|  | 739 | * metadata specifies additional information about the contents of the buffer | 
|  | 740 | * that may affect how it's displayed.  When it is nullptr, it means no such | 
|  | 741 | * information is available.  No CTA-861.3 metadata is associated with the | 
|  | 742 | * buffers by default. | 
|  | 743 | */ | 
|  | 744 | static inline int native_window_set_buffers_cta861_3_metadata( | 
|  | 745 | struct ANativeWindow* window, | 
|  | 746 | const struct android_cta861_3_metadata* metadata) | 
|  | 747 | { | 
|  | 748 | return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_CTA861_3_METADATA, | 
|  | 749 | metadata); | 
|  | 750 | } | 
|  | 751 |  | 
|  | 752 | /* | 
| Valerie Hau | a82679d | 2018-11-21 09:31:43 -0800 | [diff] [blame] | 753 | * native_window_set_buffers_hdr10_plus_metadata(..., metadata) | 
|  | 754 | * All buffers queued after this call will be associated with the | 
|  | 755 | * HDR10+ dynamic metadata specified. | 
|  | 756 | * | 
|  | 757 | * metadata specifies additional dynamic information about the | 
|  | 758 | * contents of the buffer that may affect how it is displayed.  When | 
|  | 759 | * it is nullptr, it means no such information is available.  No | 
|  | 760 | * HDR10+ dynamic emtadata is associated with the buffers by default. | 
|  | 761 | * | 
|  | 762 | * Parameter "size" refers to the length of the metadata blob pointed to | 
|  | 763 | * by parameter "data".  The metadata blob will adhere to the HDR10+ SEI | 
|  | 764 | * message standard. | 
|  | 765 | */ | 
|  | 766 | static inline int native_window_set_buffers_hdr10_plus_metadata(struct ANativeWindow* window, | 
|  | 767 | const size_t size, | 
|  | 768 | const uint8_t* metadata) { | 
|  | 769 | return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_HDR10_PLUS_METADATA, size, | 
|  | 770 | metadata); | 
|  | 771 | } | 
|  | 772 |  | 
|  | 773 | /* | 
| Mathias Agopian | a6c0e20 | 2017-03-20 15:48:44 -0700 | [diff] [blame] | 774 | * native_window_set_buffers_transform(..., int transform) | 
|  | 775 | * All buffers queued after this call will be displayed transformed according | 
|  | 776 | * to the transform parameter specified. | 
|  | 777 | */ | 
|  | 778 | static inline int native_window_set_buffers_transform( | 
|  | 779 | struct ANativeWindow* window, | 
|  | 780 | int transform) | 
|  | 781 | { | 
|  | 782 | return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TRANSFORM, | 
|  | 783 | transform); | 
|  | 784 | } | 
|  | 785 |  | 
|  | 786 | /* | 
|  | 787 | * native_window_set_buffers_sticky_transform(..., int transform) | 
|  | 788 | * All buffers queued after this call will be displayed transformed according | 
|  | 789 | * to the transform parameter specified applied on top of the regular buffer | 
|  | 790 | * transform.  Setting this transform will disable the transform hint. | 
|  | 791 | * | 
|  | 792 | * Temporary - This is only intended to be used by the LEGACY camera mode, do | 
|  | 793 | *   not use this for anything else. | 
|  | 794 | */ | 
|  | 795 | static inline int native_window_set_buffers_sticky_transform( | 
|  | 796 | struct ANativeWindow* window, | 
|  | 797 | int transform) | 
|  | 798 | { | 
|  | 799 | return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM, | 
|  | 800 | transform); | 
|  | 801 | } | 
|  | 802 |  | 
|  | 803 | /* | 
|  | 804 | * native_window_set_buffers_timestamp(..., int64_t timestamp) | 
|  | 805 | * All buffers queued after this call will be associated with the timestamp | 
|  | 806 | * parameter specified. If the timestamp is set to NATIVE_WINDOW_TIMESTAMP_AUTO | 
|  | 807 | * (the default), timestamps will be generated automatically when queueBuffer is | 
|  | 808 | * called. The timestamp is measured in nanoseconds, and is normally monotonically | 
|  | 809 | * increasing. The timestamp should be unaffected by time-of-day adjustments, | 
|  | 810 | * and for a camera should be strictly monotonic but for a media player may be | 
|  | 811 | * reset when the position is set. | 
|  | 812 | */ | 
|  | 813 | static inline int native_window_set_buffers_timestamp( | 
|  | 814 | struct ANativeWindow* window, | 
|  | 815 | int64_t timestamp) | 
|  | 816 | { | 
|  | 817 | return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP, | 
|  | 818 | timestamp); | 
|  | 819 | } | 
|  | 820 |  | 
|  | 821 | /* | 
|  | 822 | * native_window_set_scaling_mode(..., int mode) | 
|  | 823 | * All buffers queued after this call will be associated with the scaling mode | 
|  | 824 | * specified. | 
|  | 825 | */ | 
|  | 826 | static inline int native_window_set_scaling_mode( | 
|  | 827 | struct ANativeWindow* window, | 
|  | 828 | int mode) | 
|  | 829 | { | 
|  | 830 | return window->perform(window, NATIVE_WINDOW_SET_SCALING_MODE, | 
|  | 831 | mode); | 
|  | 832 | } | 
|  | 833 |  | 
|  | 834 | /* | 
|  | 835 | * native_window_api_connect(..., int api) | 
|  | 836 | * connects an API to this window. only one API can be connected at a time. | 
|  | 837 | * Returns -EINVAL if for some reason the window cannot be connected, which | 
|  | 838 | * can happen if it's connected to some other API. | 
|  | 839 | */ | 
|  | 840 | static inline int native_window_api_connect( | 
|  | 841 | struct ANativeWindow* window, int api) | 
|  | 842 | { | 
|  | 843 | return window->perform(window, NATIVE_WINDOW_API_CONNECT, api); | 
|  | 844 | } | 
|  | 845 |  | 
|  | 846 | /* | 
|  | 847 | * native_window_api_disconnect(..., int api) | 
|  | 848 | * disconnect the API from this window. | 
|  | 849 | * An error is returned if for instance the window wasn't connected in the | 
|  | 850 | * first place. | 
|  | 851 | */ | 
|  | 852 | static inline int native_window_api_disconnect( | 
|  | 853 | struct ANativeWindow* window, int api) | 
|  | 854 | { | 
|  | 855 | return window->perform(window, NATIVE_WINDOW_API_DISCONNECT, api); | 
|  | 856 | } | 
|  | 857 |  | 
|  | 858 | /* | 
|  | 859 | * native_window_dequeue_buffer_and_wait(...) | 
|  | 860 | * Dequeue a buffer and wait on the fence associated with that buffer.  The | 
|  | 861 | * buffer may safely be accessed immediately upon this function returning.  An | 
|  | 862 | * error is returned if either of the dequeue or the wait operations fail. | 
|  | 863 | */ | 
|  | 864 | static inline int native_window_dequeue_buffer_and_wait(ANativeWindow *anw, | 
|  | 865 | struct ANativeWindowBuffer** anb) { | 
|  | 866 | return anw->dequeueBuffer_DEPRECATED(anw, anb); | 
|  | 867 | } | 
|  | 868 |  | 
|  | 869 | /* | 
|  | 870 | * native_window_set_sideband_stream(..., native_handle_t*) | 
|  | 871 | * Attach a sideband buffer stream to a native window. | 
|  | 872 | */ | 
|  | 873 | static inline int native_window_set_sideband_stream( | 
|  | 874 | struct ANativeWindow* window, | 
|  | 875 | native_handle_t* sidebandHandle) | 
|  | 876 | { | 
|  | 877 | return window->perform(window, NATIVE_WINDOW_SET_SIDEBAND_STREAM, | 
|  | 878 | sidebandHandle); | 
|  | 879 | } | 
|  | 880 |  | 
|  | 881 | /* | 
|  | 882 | * native_window_set_surface_damage(..., android_native_rect_t* rects, int numRects) | 
|  | 883 | * Set the surface damage (i.e., the region of the surface that has changed | 
|  | 884 | * since the previous frame). The damage set by this call will be reset (to the | 
|  | 885 | * default of full-surface damage) after calling queue, so this must be called | 
|  | 886 | * prior to every frame with damage that does not cover the whole surface if the | 
|  | 887 | * caller desires downstream consumers to use this optimization. | 
|  | 888 | * | 
|  | 889 | * The damage region is specified as an array of rectangles, with the important | 
|  | 890 | * caveat that the origin of the surface is considered to be the bottom-left | 
|  | 891 | * corner, as in OpenGL ES. | 
|  | 892 | * | 
|  | 893 | * If numRects is set to 0, rects may be NULL, and the surface damage will be | 
|  | 894 | * set to the full surface (the same as if this function had not been called for | 
|  | 895 | * this frame). | 
|  | 896 | */ | 
|  | 897 | static inline int native_window_set_surface_damage( | 
|  | 898 | struct ANativeWindow* window, | 
|  | 899 | const android_native_rect_t* rects, size_t numRects) | 
|  | 900 | { | 
|  | 901 | return window->perform(window, NATIVE_WINDOW_SET_SURFACE_DAMAGE, | 
|  | 902 | rects, numRects); | 
|  | 903 | } | 
|  | 904 |  | 
|  | 905 | /* | 
|  | 906 | * native_window_set_shared_buffer_mode(..., bool sharedBufferMode) | 
|  | 907 | * Enable/disable shared buffer mode | 
|  | 908 | */ | 
|  | 909 | static inline int native_window_set_shared_buffer_mode( | 
|  | 910 | struct ANativeWindow* window, | 
|  | 911 | bool sharedBufferMode) | 
|  | 912 | { | 
|  | 913 | return window->perform(window, NATIVE_WINDOW_SET_SHARED_BUFFER_MODE, | 
|  | 914 | sharedBufferMode); | 
|  | 915 | } | 
|  | 916 |  | 
|  | 917 | /* | 
|  | 918 | * native_window_set_auto_refresh(..., autoRefresh) | 
|  | 919 | * Enable/disable auto refresh when in shared buffer mode | 
|  | 920 | */ | 
|  | 921 | static inline int native_window_set_auto_refresh( | 
|  | 922 | struct ANativeWindow* window, | 
|  | 923 | bool autoRefresh) | 
|  | 924 | { | 
|  | 925 | return window->perform(window, NATIVE_WINDOW_SET_AUTO_REFRESH, autoRefresh); | 
|  | 926 | } | 
|  | 927 |  | 
|  | 928 | static inline int native_window_get_refresh_cycle_duration( | 
|  | 929 | struct ANativeWindow* window, | 
|  | 930 | int64_t* outRefreshDuration) | 
|  | 931 | { | 
|  | 932 | return window->perform(window, NATIVE_WINDOW_GET_REFRESH_CYCLE_DURATION, | 
|  | 933 | outRefreshDuration); | 
|  | 934 | } | 
|  | 935 |  | 
|  | 936 | static inline int native_window_get_next_frame_id( | 
|  | 937 | struct ANativeWindow* window, uint64_t* frameId) | 
|  | 938 | { | 
|  | 939 | return window->perform(window, NATIVE_WINDOW_GET_NEXT_FRAME_ID, frameId); | 
|  | 940 | } | 
|  | 941 |  | 
|  | 942 | static inline int native_window_enable_frame_timestamps( | 
|  | 943 | struct ANativeWindow* window, bool enable) | 
|  | 944 | { | 
|  | 945 | return window->perform(window, NATIVE_WINDOW_ENABLE_FRAME_TIMESTAMPS, | 
|  | 946 | enable); | 
|  | 947 | } | 
|  | 948 |  | 
|  | 949 | static inline int native_window_get_compositor_timing( | 
|  | 950 | struct ANativeWindow* window, | 
|  | 951 | int64_t* compositeDeadline, int64_t* compositeInterval, | 
|  | 952 | int64_t* compositeToPresentLatency) | 
|  | 953 | { | 
|  | 954 | return window->perform(window, NATIVE_WINDOW_GET_COMPOSITOR_TIMING, | 
|  | 955 | compositeDeadline, compositeInterval, compositeToPresentLatency); | 
|  | 956 | } | 
|  | 957 |  | 
|  | 958 | static inline int native_window_get_frame_timestamps( | 
|  | 959 | struct ANativeWindow* window, uint64_t frameId, | 
|  | 960 | int64_t* outRequestedPresentTime, int64_t* outAcquireTime, | 
|  | 961 | int64_t* outLatchTime, int64_t* outFirstRefreshStartTime, | 
|  | 962 | int64_t* outLastRefreshStartTime, int64_t* outGpuCompositionDoneTime, | 
|  | 963 | int64_t* outDisplayPresentTime, int64_t* outDequeueReadyTime, | 
|  | 964 | int64_t* outReleaseTime) | 
|  | 965 | { | 
|  | 966 | return window->perform(window, NATIVE_WINDOW_GET_FRAME_TIMESTAMPS, | 
|  | 967 | frameId, outRequestedPresentTime, outAcquireTime, outLatchTime, | 
|  | 968 | outFirstRefreshStartTime, outLastRefreshStartTime, | 
|  | 969 | outGpuCompositionDoneTime, outDisplayPresentTime, | 
|  | 970 | outDequeueReadyTime, outReleaseTime); | 
|  | 971 | } | 
|  | 972 |  | 
|  | 973 | static inline int native_window_get_wide_color_support( | 
|  | 974 | struct ANativeWindow* window, bool* outSupport) { | 
| Chia-I Wu | e2786ea | 2017-08-07 10:36:08 -0700 | [diff] [blame] | 975 | return window->perform(window, NATIVE_WINDOW_GET_WIDE_COLOR_SUPPORT, | 
|  | 976 | outSupport); | 
| Mathias Agopian | a6c0e20 | 2017-03-20 15:48:44 -0700 | [diff] [blame] | 977 | } | 
|  | 978 |  | 
|  | 979 | static inline int native_window_get_hdr_support(struct ANativeWindow* window, | 
|  | 980 | bool* outSupport) { | 
| Chia-I Wu | e2786ea | 2017-08-07 10:36:08 -0700 | [diff] [blame] | 981 | return window->perform(window, NATIVE_WINDOW_GET_HDR_SUPPORT, outSupport); | 
|  | 982 | } | 
|  | 983 |  | 
|  | 984 | static inline int native_window_get_consumer_usage(struct ANativeWindow* window, | 
|  | 985 | uint64_t* outUsage) { | 
|  | 986 | return window->perform(window, NATIVE_WINDOW_GET_CONSUMER_USAGE64, outUsage); | 
| Mathias Agopian | a6c0e20 | 2017-03-20 15:48:44 -0700 | [diff] [blame] | 987 | } | 
|  | 988 |  | 
| Yiwei Zhang | 538cedc | 2019-06-24 19:35:03 -0700 | [diff] [blame] | 989 | /* | 
|  | 990 | * native_window_set_auto_prerotation(..., autoPrerotation) | 
|  | 991 | * Enable/disable the auto prerotation at buffer allocation when the buffer size | 
|  | 992 | * is driven by the consumer. | 
|  | 993 | * | 
|  | 994 | * When buffer size is driven by the consumer and the transform hint specifies | 
|  | 995 | * a 90 or 270 degree rotation, if auto prerotation is enabled, the width and | 
|  | 996 | * height used for dequeueBuffer will be additionally swapped. | 
|  | 997 | */ | 
|  | 998 | static inline int native_window_set_auto_prerotation(struct ANativeWindow* window, | 
|  | 999 | bool autoPrerotation) { | 
|  | 1000 | return window->perform(window, NATIVE_WINDOW_SET_AUTO_PREROTATION, autoPrerotation); | 
|  | 1001 | } | 
|  | 1002 |  | 
| Mathias Agopian | a6c0e20 | 2017-03-20 15:48:44 -0700 | [diff] [blame] | 1003 | __END_DECLS |