Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -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 | #ifndef SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H |
| 18 | #define SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H |
| 19 | |
Jamie Gennis | 22aec57 | 2012-06-13 16:43:06 -0700 | [diff] [blame] | 20 | #include <cutils/native_handle.h> |
Jesse Hall | bc930ed | 2012-10-01 13:48:36 -0700 | [diff] [blame] | 21 | #include <errno.h> |
Jamie Gennis | 22aec57 | 2012-06-13 16:43:06 -0700 | [diff] [blame] | 22 | #include <limits.h> |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 23 | #include <stdint.h> |
Mathias Agopian | c958a7f | 2012-02-25 21:13:36 -0800 | [diff] [blame] | 24 | #include <string.h> |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 25 | #include <sys/cdefs.h> |
| 26 | #include <system/graphics.h> |
Jamie Gennis | 22aec57 | 2012-06-13 16:43:06 -0700 | [diff] [blame] | 27 | #include <unistd.h> |
Pablo Ceballos | 923d27f | 2015-10-19 10:24:42 -0700 | [diff] [blame] | 28 | #include <stdbool.h> |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 29 | |
Ian Rogers | de8b983 | 2014-06-27 16:38:01 -0700 | [diff] [blame] | 30 | #ifndef __UNUSED |
| 31 | #define __UNUSED __attribute__((__unused__)) |
Mark Salyzyn | 4887842 | 2014-05-22 16:08:52 -0700 | [diff] [blame] | 32 | #endif |
Mark Salyzyn | 289e111 | 2014-05-23 12:31:42 -0700 | [diff] [blame] | 33 | #ifndef __deprecated |
| 34 | #define __deprecated __attribute__((__deprecated__)) |
| 35 | #endif |
Mark Salyzyn | 4887842 | 2014-05-22 16:08:52 -0700 | [diff] [blame] | 36 | |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 37 | __BEGIN_DECLS |
| 38 | |
| 39 | /*****************************************************************************/ |
| 40 | |
Colin Cross | 7c7990e | 2016-09-15 18:04:04 -0700 | [diff] [blame] | 41 | #ifdef __cplusplus |
| 42 | #define ANDROID_NATIVE_UNSIGNED_CAST(x) static_cast<unsigned int>(x) |
| 43 | #else |
| 44 | #define ANDROID_NATIVE_UNSIGNED_CAST(x) ((unsigned int)(x)) |
| 45 | #endif |
| 46 | |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 47 | #define ANDROID_NATIVE_MAKE_CONSTANT(a,b,c,d) \ |
Colin Cross | 7c7990e | 2016-09-15 18:04:04 -0700 | [diff] [blame] | 48 | ((ANDROID_NATIVE_UNSIGNED_CAST(a) << 24) | \ |
| 49 | (ANDROID_NATIVE_UNSIGNED_CAST(b) << 16) | \ |
| 50 | (ANDROID_NATIVE_UNSIGNED_CAST(c) << 8) | \ |
| 51 | (ANDROID_NATIVE_UNSIGNED_CAST(d))) |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 52 | |
| 53 | #define ANDROID_NATIVE_WINDOW_MAGIC \ |
| 54 | ANDROID_NATIVE_MAKE_CONSTANT('_','w','n','d') |
| 55 | |
| 56 | #define ANDROID_NATIVE_BUFFER_MAGIC \ |
| 57 | ANDROID_NATIVE_MAKE_CONSTANT('_','b','f','r') |
| 58 | |
| 59 | // --------------------------------------------------------------------------- |
| 60 | |
Jamie Gennis | 22aec57 | 2012-06-13 16:43:06 -0700 | [diff] [blame] | 61 | // This #define may be used to conditionally compile device-specific code to |
| 62 | // support either the prior ANativeWindow interface, which did not pass libsync |
| 63 | // fences around, or the new interface that does. This #define is only present |
| 64 | // when the ANativeWindow interface does include libsync support. |
| 65 | #define ANDROID_NATIVE_WINDOW_HAS_SYNC 1 |
| 66 | |
| 67 | // --------------------------------------------------------------------------- |
| 68 | |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 69 | typedef const native_handle_t* buffer_handle_t; |
| 70 | |
| 71 | // --------------------------------------------------------------------------- |
| 72 | |
| 73 | typedef struct android_native_rect_t |
| 74 | { |
| 75 | int32_t left; |
| 76 | int32_t top; |
| 77 | int32_t right; |
| 78 | int32_t bottom; |
| 79 | } android_native_rect_t; |
| 80 | |
| 81 | // --------------------------------------------------------------------------- |
| 82 | |
| 83 | typedef struct android_native_base_t |
| 84 | { |
| 85 | /* a magic value defined by the actual EGL native type */ |
| 86 | int magic; |
| 87 | |
| 88 | /* the sizeof() of the actual EGL native type */ |
| 89 | int version; |
| 90 | |
| 91 | void* reserved[4]; |
| 92 | |
| 93 | /* reference-counting interface */ |
| 94 | void (*incRef)(struct android_native_base_t* base); |
| 95 | void (*decRef)(struct android_native_base_t* base); |
| 96 | } android_native_base_t; |
| 97 | |
| 98 | typedef struct ANativeWindowBuffer |
| 99 | { |
| 100 | #ifdef __cplusplus |
| 101 | ANativeWindowBuffer() { |
| 102 | common.magic = ANDROID_NATIVE_BUFFER_MAGIC; |
| 103 | common.version = sizeof(ANativeWindowBuffer); |
| 104 | memset(common.reserved, 0, sizeof(common.reserved)); |
| 105 | } |
| 106 | |
| 107 | // Implement the methods that sp<ANativeWindowBuffer> expects so that it |
| 108 | // can be used to automatically refcount ANativeWindowBuffer's. |
Mark Salyzyn | 4887842 | 2014-05-22 16:08:52 -0700 | [diff] [blame] | 109 | void incStrong(const void* /*id*/) const { |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 110 | common.incRef(const_cast<android_native_base_t*>(&common)); |
| 111 | } |
Mark Salyzyn | 4887842 | 2014-05-22 16:08:52 -0700 | [diff] [blame] | 112 | void decStrong(const void* /*id*/) const { |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 113 | common.decRef(const_cast<android_native_base_t*>(&common)); |
| 114 | } |
| 115 | #endif |
| 116 | |
| 117 | struct android_native_base_t common; |
| 118 | |
| 119 | int width; |
| 120 | int height; |
| 121 | int stride; |
| 122 | int format; |
| 123 | int usage; |
Craig Donner | ce54b4d | 2016-10-19 18:07:17 -0700 | [diff] [blame] | 124 | uintptr_t layerCount; |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 125 | |
Craig Donner | ce54b4d | 2016-10-19 18:07:17 -0700 | [diff] [blame] | 126 | void* reserved[1]; |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 127 | |
| 128 | buffer_handle_t handle; |
| 129 | |
| 130 | void* reserved_proc[8]; |
| 131 | } ANativeWindowBuffer_t; |
| 132 | |
| 133 | // Old typedef for backwards compatibility. |
| 134 | typedef ANativeWindowBuffer_t android_native_buffer_t; |
| 135 | |
| 136 | // --------------------------------------------------------------------------- |
| 137 | |
| 138 | /* attributes queriable with query() */ |
| 139 | enum { |
| 140 | NATIVE_WINDOW_WIDTH = 0, |
Mathias Agopian | 42cc1ed | 2011-07-13 15:49:58 -0700 | [diff] [blame] | 141 | NATIVE_WINDOW_HEIGHT = 1, |
| 142 | NATIVE_WINDOW_FORMAT = 2, |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 143 | |
| 144 | /* The minimum number of buffers that must remain un-dequeued after a buffer |
| 145 | * has been queued. This value applies only if set_buffer_count was used to |
| 146 | * override the number of buffers and if a buffer has since been queued. |
| 147 | * Users of the set_buffer_count ANativeWindow method should query this |
| 148 | * value before calling set_buffer_count. If it is necessary to have N |
| 149 | * buffers simultaneously dequeued as part of the steady-state operation, |
| 150 | * and this query returns M then N+M buffers should be requested via |
| 151 | * native_window_set_buffer_count. |
| 152 | * |
| 153 | * Note that this value does NOT apply until a single buffer has been |
| 154 | * queued. In particular this means that it is possible to: |
| 155 | * |
| 156 | * 1. Query M = min undequeued buffers |
| 157 | * 2. Set the buffer count to N + M |
| 158 | * 3. Dequeue all N + M buffers |
| 159 | * 4. Cancel M buffers |
| 160 | * 5. Queue, dequeue, queue, dequeue, ad infinitum |
| 161 | */ |
Mathias Agopian | 42cc1ed | 2011-07-13 15:49:58 -0700 | [diff] [blame] | 162 | NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS = 3, |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 163 | |
| 164 | /* Check whether queueBuffer operations on the ANativeWindow send the buffer |
| 165 | * to the window compositor. The query sets the returned 'value' argument |
| 166 | * to 1 if the ANativeWindow DOES send queued buffers directly to the window |
| 167 | * compositor and 0 if the buffers do not go directly to the window |
| 168 | * compositor. |
| 169 | * |
| 170 | * This can be used to determine whether protected buffer content should be |
| 171 | * sent to the ANativeWindow. Note, however, that a result of 1 does NOT |
| 172 | * indicate that queued buffers will be protected from applications or users |
| 173 | * capturing their contents. If that behavior is desired then some other |
| 174 | * mechanism (e.g. the GRALLOC_USAGE_PROTECTED flag) should be used in |
| 175 | * conjunction with this query. |
| 176 | */ |
Mathias Agopian | 42cc1ed | 2011-07-13 15:49:58 -0700 | [diff] [blame] | 177 | NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER = 4, |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 178 | |
| 179 | /* Get the concrete type of a ANativeWindow. See below for the list of |
| 180 | * possible return values. |
| 181 | * |
| 182 | * This query should not be used outside the Android framework and will |
| 183 | * likely be removed in the near future. |
| 184 | */ |
Mathias Agopian | 42cc1ed | 2011-07-13 15:49:58 -0700 | [diff] [blame] | 185 | NATIVE_WINDOW_CONCRETE_TYPE = 5, |
Mathias Agopian | 5100916 | 2011-07-19 15:59:15 -0700 | [diff] [blame] | 186 | |
| 187 | |
| 188 | /* |
Michael I. Gold | afcdef6 | 2012-04-09 18:21:13 -0700 | [diff] [blame] | 189 | * Default width and height of ANativeWindow buffers, these are the |
| 190 | * dimensions of the window buffers irrespective of the |
| 191 | * NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS call and match the native window |
Jamie Gennis | aa3f4c3 | 2012-04-17 19:37:48 -0700 | [diff] [blame] | 192 | * size unless overridden by NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS. |
Mathias Agopian | 5100916 | 2011-07-19 15:59:15 -0700 | [diff] [blame] | 193 | */ |
| 194 | NATIVE_WINDOW_DEFAULT_WIDTH = 6, |
| 195 | NATIVE_WINDOW_DEFAULT_HEIGHT = 7, |
| 196 | |
| 197 | /* |
| 198 | * transformation that will most-likely be applied to buffers. This is only |
| 199 | * a hint, the actual transformation applied might be different. |
| 200 | * |
| 201 | * INTENDED USE: |
| 202 | * |
| 203 | * The transform hint can be used by a producer, for instance the GLES |
| 204 | * driver, to pre-rotate the rendering such that the final transformation |
| 205 | * in the composer is identity. This can be very useful when used in |
| 206 | * conjunction with the h/w composer HAL, in situations where it |
| 207 | * cannot handle arbitrary rotations. |
| 208 | * |
| 209 | * 1. Before dequeuing a buffer, the GL driver (or any other ANW client) |
| 210 | * queries the ANW for NATIVE_WINDOW_TRANSFORM_HINT. |
| 211 | * |
| 212 | * 2. The GL driver overrides the width and height of the ANW to |
| 213 | * account for NATIVE_WINDOW_TRANSFORM_HINT. This is done by querying |
| 214 | * NATIVE_WINDOW_DEFAULT_{WIDTH | HEIGHT}, swapping the dimensions |
| 215 | * according to NATIVE_WINDOW_TRANSFORM_HINT and calling |
| 216 | * native_window_set_buffers_dimensions(). |
| 217 | * |
| 218 | * 3. The GL driver dequeues a buffer of the new pre-rotated size. |
| 219 | * |
| 220 | * 4. The GL driver renders to the buffer such that the image is |
| 221 | * already transformed, that is applying NATIVE_WINDOW_TRANSFORM_HINT |
| 222 | * to the rendering. |
| 223 | * |
| 224 | * 5. The GL driver calls native_window_set_transform to apply |
| 225 | * inverse transformation to the buffer it just rendered. |
| 226 | * In order to do this, the GL driver needs |
| 227 | * to calculate the inverse of NATIVE_WINDOW_TRANSFORM_HINT, this is |
| 228 | * done easily: |
| 229 | * |
| 230 | * int hintTransform, inverseTransform; |
| 231 | * query(..., NATIVE_WINDOW_TRANSFORM_HINT, &hintTransform); |
| 232 | * inverseTransform = hintTransform; |
| 233 | * if (hintTransform & HAL_TRANSFORM_ROT_90) |
| 234 | * inverseTransform ^= HAL_TRANSFORM_ROT_180; |
| 235 | * |
| 236 | * |
| 237 | * 6. The GL driver queues the pre-transformed buffer. |
| 238 | * |
| 239 | * 7. The composer combines the buffer transform with the display |
| 240 | * transform. If the buffer transform happens to cancel out the |
| 241 | * display transform then no rotation is needed. |
| 242 | * |
| 243 | */ |
| 244 | NATIVE_WINDOW_TRANSFORM_HINT = 8, |
Jamie Gennis | aa3f4c3 | 2012-04-17 19:37:48 -0700 | [diff] [blame] | 245 | |
| 246 | /* |
| 247 | * Boolean that indicates whether the consumer is running more than |
| 248 | * one buffer behind the producer. |
| 249 | */ |
Eino-Ville Talvala | f88a5b4 | 2013-07-30 14:07:08 -0700 | [diff] [blame] | 250 | NATIVE_WINDOW_CONSUMER_RUNNING_BEHIND = 9, |
| 251 | |
| 252 | /* |
| 253 | * The consumer gralloc usage bits currently set by the consumer. |
| 254 | * The values are defined in hardware/libhardware/include/gralloc.h. |
| 255 | */ |
Ruben Brunk | a5e65d8 | 2014-06-27 16:15:18 -0700 | [diff] [blame] | 256 | NATIVE_WINDOW_CONSUMER_USAGE_BITS = 10, |
| 257 | |
| 258 | /** |
| 259 | * Transformation that will by applied to buffers by the hwcomposer. |
| 260 | * This must not be set or checked by producer endpoints, and will |
| 261 | * disable the transform hint set in SurfaceFlinger (see |
| 262 | * NATIVE_WINDOW_TRANSFORM_HINT). |
| 263 | * |
| 264 | * INTENDED USE: |
| 265 | * Temporary - Please do not use this. This is intended only to be used |
| 266 | * by the camera's LEGACY mode. |
| 267 | * |
| 268 | * In situations where a SurfaceFlinger client wishes to set a transform |
| 269 | * that is not visible to the producer, and will always be applied in the |
| 270 | * hardware composer, the client can set this flag with |
| 271 | * native_window_set_buffers_sticky_transform. This can be used to rotate |
| 272 | * and flip buffers consumed by hardware composer without actually changing |
| 273 | * the aspect ratio of the buffers produced. |
| 274 | */ |
| 275 | NATIVE_WINDOW_STICKY_TRANSFORM = 11, |
Eino-Ville Talvala | b93343d | 2015-02-17 15:34:44 -0800 | [diff] [blame] | 276 | |
| 277 | /** |
| 278 | * The default data space for the buffers as set by the consumer. |
| 279 | * The values are defined in graphics.h. |
| 280 | */ |
Dan Stoza | 0a866ea | 2015-02-25 16:45:08 -0800 | [diff] [blame] | 281 | NATIVE_WINDOW_DEFAULT_DATASPACE = 12, |
| 282 | |
| 283 | /* |
| 284 | * Returns the age of the contents of the most recently dequeued buffer as |
| 285 | * the number of frames that have elapsed since it was last queued. For |
| 286 | * example, if the window is double-buffered, the age of any given buffer in |
| 287 | * steady state will be 2. If the dequeued buffer has never been queued, its |
| 288 | * age will be 0. |
| 289 | */ |
| 290 | NATIVE_WINDOW_BUFFER_AGE = 13, |
Dan Stoza | 94ededa | 2016-07-01 14:02:08 -0700 | [diff] [blame] | 291 | |
| 292 | /* |
| 293 | * Returns the duration of the last dequeueBuffer call in microseconds |
| 294 | */ |
| 295 | NATIVE_WINDOW_LAST_DEQUEUE_DURATION = 14, |
| 296 | |
| 297 | /* |
| 298 | * Returns the duration of the last queueBuffer call in microseconds |
| 299 | */ |
| 300 | NATIVE_WINDOW_LAST_QUEUE_DURATION = 15, |
Craig Donner | ce54b4d | 2016-10-19 18:07:17 -0700 | [diff] [blame] | 301 | |
| 302 | /* |
| 303 | * Returns the number of image layers that the ANativeWindow buffer |
| 304 | * contains. By default this is 1, unless a buffer is explicitly allocated |
| 305 | * to contain multiple layers. |
| 306 | */ |
| 307 | NATIVE_WINDOW_LAYER_COUNT = 16, |
Brian Anderson | 43f232b | 2016-07-22 10:48:59 -0700 | [diff] [blame] | 308 | |
| 309 | /* |
| 310 | * Returns 1 if NATIVE_WINDOW_GET_FRAME_TIMESTAMPS will return display |
| 311 | * present info, 0 if it won't. |
| 312 | */ |
| 313 | NATIVE_WINDOW_FRAME_TIMESTAMPS_SUPPORTS_PRESENT = 17, |
| 314 | |
| 315 | /* |
| 316 | * Returns 1 if NATIVE_WINDOW_GET_FRAME_TIMESTAMPS will return display |
| 317 | * retire info, 0 if it won't. |
| 318 | */ |
| 319 | NATIVE_WINDOW_FRAME_TIMESTAMPS_SUPPORTS_RETIRE = 18, |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 320 | }; |
| 321 | |
Jamie Gennis | fb1ee57 | 2012-04-17 19:37:48 -0700 | [diff] [blame] | 322 | /* Valid operations for the (*perform)() hook. |
| 323 | * |
| 324 | * Values marked as 'deprecated' are supported, but have been superceded by |
| 325 | * other functionality. |
| 326 | * |
| 327 | * Values marked as 'private' should be considered private to the framework. |
| 328 | * HAL implementation code with access to an ANativeWindow should not use these, |
| 329 | * as it may not interact properly with the framework's use of the |
| 330 | * ANativeWindow. |
| 331 | */ |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 332 | enum { |
Courtney Goeltzenleuchter | fbef1c3 | 2017-02-02 11:05:49 -0700 | [diff] [blame] | 333 | // clang-format off |
Mathias Agopian | 42cc1ed | 2011-07-13 15:49:58 -0700 | [diff] [blame] | 334 | NATIVE_WINDOW_SET_USAGE = 0, |
Mathias Agopian | 8ad5452 | 2011-07-29 17:52:36 -0700 | [diff] [blame] | 335 | NATIVE_WINDOW_CONNECT = 1, /* deprecated */ |
| 336 | NATIVE_WINDOW_DISCONNECT = 2, /* deprecated */ |
Jamie Gennis | fb1ee57 | 2012-04-17 19:37:48 -0700 | [diff] [blame] | 337 | NATIVE_WINDOW_SET_CROP = 3, /* private */ |
Mathias Agopian | 42cc1ed | 2011-07-13 15:49:58 -0700 | [diff] [blame] | 338 | NATIVE_WINDOW_SET_BUFFER_COUNT = 4, |
| 339 | NATIVE_WINDOW_SET_BUFFERS_GEOMETRY = 5, /* deprecated */ |
| 340 | NATIVE_WINDOW_SET_BUFFERS_TRANSFORM = 6, |
| 341 | NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP = 7, |
| 342 | NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS = 8, |
| 343 | NATIVE_WINDOW_SET_BUFFERS_FORMAT = 9, |
Jamie Gennis | fb1ee57 | 2012-04-17 19:37:48 -0700 | [diff] [blame] | 344 | NATIVE_WINDOW_SET_SCALING_MODE = 10, /* private */ |
Mathias Agopian | ae3736a | 2011-07-13 18:40:38 -0700 | [diff] [blame] | 345 | NATIVE_WINDOW_LOCK = 11, /* private */ |
| 346 | NATIVE_WINDOW_UNLOCK_AND_POST = 12, /* private */ |
Mathias Agopian | 8ad5452 | 2011-07-29 17:52:36 -0700 | [diff] [blame] | 347 | NATIVE_WINDOW_API_CONNECT = 13, /* private */ |
| 348 | NATIVE_WINDOW_API_DISCONNECT = 14, /* private */ |
Michael I. Gold | afcdef6 | 2012-04-09 18:21:13 -0700 | [diff] [blame] | 349 | NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS = 15, /* private */ |
Jamie Gennis | d21113a | 2012-05-03 14:21:24 -0700 | [diff] [blame] | 350 | NATIVE_WINDOW_SET_POST_TRANSFORM_CROP = 16, /* private */ |
Ruben Brunk | a5e65d8 | 2014-06-27 16:15:18 -0700 | [diff] [blame] | 351 | NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM = 17,/* private */ |
Rachad | d6d4c61 | 2014-07-29 18:03:21 -0700 | [diff] [blame] | 352 | NATIVE_WINDOW_SET_SIDEBAND_STREAM = 18, |
Dan Stoza | 238ec98 | 2015-03-23 10:43:14 -0700 | [diff] [blame] | 353 | NATIVE_WINDOW_SET_BUFFERS_DATASPACE = 19, |
| 354 | NATIVE_WINDOW_SET_SURFACE_DAMAGE = 20, /* private */ |
Pablo Ceballos | 248e771 | 2016-03-17 15:42:21 -0700 | [diff] [blame] | 355 | NATIVE_WINDOW_SET_SHARED_BUFFER_MODE = 21, |
Pablo Ceballos | 3daa574 | 2016-01-15 13:31:14 -0800 | [diff] [blame] | 356 | NATIVE_WINDOW_SET_AUTO_REFRESH = 22, |
Brian Anderson | ad79a39 | 2016-12-08 12:03:49 -0800 | [diff] [blame] | 357 | NATIVE_WINDOW_GET_REFRESH_CYCLE_DURATION= 23, |
| 358 | NATIVE_WINDOW_GET_NEXT_FRAME_ID = 24, |
| 359 | NATIVE_WINDOW_ENABLE_FRAME_TIMESTAMPS = 25, |
| 360 | NATIVE_WINDOW_GET_COMPOSITOR_TIMING = 26, |
| 361 | NATIVE_WINDOW_GET_FRAME_TIMESTAMPS = 27, |
Courtney Goeltzenleuchter | fbef1c3 | 2017-02-02 11:05:49 -0700 | [diff] [blame] | 362 | NATIVE_WINDOW_GET_WIDE_COLOR_SUPPORT = 28, |
| 363 | NATIVE_WINDOW_GET_HDR_SUPPORT = 29, |
| 364 | // clang-format on |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 365 | }; |
| 366 | |
Mathias Agopian | 8ad5452 | 2011-07-29 17:52:36 -0700 | [diff] [blame] | 367 | /* parameter for NATIVE_WINDOW_[API_][DIS]CONNECT */ |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 368 | enum { |
Jamie Gennis | 5423e9e | 2011-07-12 13:53:42 -0700 | [diff] [blame] | 369 | /* Buffers will be queued by EGL via eglSwapBuffers after being filled using |
| 370 | * OpenGL ES. |
| 371 | */ |
| 372 | NATIVE_WINDOW_API_EGL = 1, |
| 373 | |
| 374 | /* Buffers will be queued after being filled using the CPU |
| 375 | */ |
| 376 | NATIVE_WINDOW_API_CPU = 2, |
| 377 | |
| 378 | /* Buffers will be queued by Stagefright after being filled by a video |
| 379 | * decoder. The video decoder can either be a software or hardware decoder. |
| 380 | */ |
| 381 | NATIVE_WINDOW_API_MEDIA = 3, |
| 382 | |
| 383 | /* Buffers will be queued by the the camera HAL. |
| 384 | */ |
| 385 | NATIVE_WINDOW_API_CAMERA = 4, |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 386 | }; |
| 387 | |
| 388 | /* parameter for NATIVE_WINDOW_SET_BUFFERS_TRANSFORM */ |
| 389 | enum { |
| 390 | /* flip source image horizontally */ |
| 391 | NATIVE_WINDOW_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H , |
| 392 | /* flip source image vertically */ |
| 393 | NATIVE_WINDOW_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V, |
Mathias Agopian | 96675ed | 2013-09-17 23:48:54 -0700 | [diff] [blame] | 394 | /* rotate source image 90 degrees clock-wise, and is applied after TRANSFORM_FLIP_{H|V} */ |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 395 | NATIVE_WINDOW_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90, |
| 396 | /* rotate source image 180 degrees */ |
| 397 | NATIVE_WINDOW_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180, |
| 398 | /* rotate source image 270 degrees clock-wise */ |
| 399 | NATIVE_WINDOW_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270, |
Mathias Agopian | 96675ed | 2013-09-17 23:48:54 -0700 | [diff] [blame] | 400 | /* transforms source by the inverse transform of the screen it is displayed onto. This |
| 401 | * transform is applied last */ |
| 402 | NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY = 0x08 |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 403 | }; |
| 404 | |
Robert Carr | f3954fb | 2015-12-17 11:31:11 -0800 | [diff] [blame] | 405 | /* parameter for NATIVE_WINDOW_SET_SCALING_MODE |
| 406 | * keep in sync with Surface.java in frameworks/base */ |
Mathias Agopian | 42cc1ed | 2011-07-13 15:49:58 -0700 | [diff] [blame] | 407 | enum { |
| 408 | /* the window content is not updated (frozen) until a buffer of |
| 409 | * the window size is received (enqueued) |
| 410 | */ |
| 411 | NATIVE_WINDOW_SCALING_MODE_FREEZE = 0, |
| 412 | /* the buffer is scaled in both dimensions to match the window size */ |
| 413 | NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW = 1, |
Daniel Lam | 29392a4 | 2012-04-11 18:19:46 -0700 | [diff] [blame] | 414 | /* the buffer is scaled uniformly such that the smaller dimension |
| 415 | * of the buffer matches the window size (cropping in the process) |
| 416 | */ |
| 417 | NATIVE_WINDOW_SCALING_MODE_SCALE_CROP = 2, |
Jamie Gennis | d21113a | 2012-05-03 14:21:24 -0700 | [diff] [blame] | 418 | /* the window is clipped to the size of the buffer's crop rectangle; pixels |
| 419 | * outside the crop rectangle are treated as if they are completely |
| 420 | * transparent. |
| 421 | */ |
| 422 | NATIVE_WINDOW_SCALING_MODE_NO_SCALE_CROP = 3, |
Mathias Agopian | 42cc1ed | 2011-07-13 15:49:58 -0700 | [diff] [blame] | 423 | }; |
| 424 | |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 425 | /* values returned by the NATIVE_WINDOW_CONCRETE_TYPE query */ |
| 426 | enum { |
Mathias Agopian | 42cc1ed | 2011-07-13 15:49:58 -0700 | [diff] [blame] | 427 | NATIVE_WINDOW_FRAMEBUFFER = 0, /* FramebufferNativeWindow */ |
| 428 | NATIVE_WINDOW_SURFACE = 1, /* Surface */ |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 429 | }; |
| 430 | |
| 431 | /* parameter for NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP |
| 432 | * |
| 433 | * Special timestamp value to indicate that timestamps should be auto-generated |
| 434 | * by the native window when queueBuffer is called. This is equal to INT64_MIN, |
| 435 | * defined directly to avoid problems with C99/C++ inclusion of stdint.h. |
| 436 | */ |
| 437 | static const int64_t NATIVE_WINDOW_TIMESTAMP_AUTO = (-9223372036854775807LL-1); |
| 438 | |
| 439 | struct ANativeWindow |
| 440 | { |
| 441 | #ifdef __cplusplus |
| 442 | ANativeWindow() |
| 443 | : flags(0), minSwapInterval(0), maxSwapInterval(0), xdpi(0), ydpi(0) |
| 444 | { |
| 445 | common.magic = ANDROID_NATIVE_WINDOW_MAGIC; |
| 446 | common.version = sizeof(ANativeWindow); |
| 447 | memset(common.reserved, 0, sizeof(common.reserved)); |
| 448 | } |
| 449 | |
Mathias Agopian | 42cc1ed | 2011-07-13 15:49:58 -0700 | [diff] [blame] | 450 | /* Implement the methods that sp<ANativeWindow> expects so that it |
| 451 | can be used to automatically refcount ANativeWindow's. */ |
Mark Salyzyn | 4887842 | 2014-05-22 16:08:52 -0700 | [diff] [blame] | 452 | void incStrong(const void* /*id*/) const { |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 453 | common.incRef(const_cast<android_native_base_t*>(&common)); |
| 454 | } |
Mark Salyzyn | 4887842 | 2014-05-22 16:08:52 -0700 | [diff] [blame] | 455 | void decStrong(const void* /*id*/) const { |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 456 | common.decRef(const_cast<android_native_base_t*>(&common)); |
| 457 | } |
| 458 | #endif |
| 459 | |
| 460 | struct android_native_base_t common; |
| 461 | |
| 462 | /* flags describing some attributes of this surface or its updater */ |
| 463 | const uint32_t flags; |
| 464 | |
| 465 | /* min swap interval supported by this updated */ |
| 466 | const int minSwapInterval; |
| 467 | |
| 468 | /* max swap interval supported by this updated */ |
| 469 | const int maxSwapInterval; |
| 470 | |
| 471 | /* horizontal and vertical resolution in DPI */ |
| 472 | const float xdpi; |
| 473 | const float ydpi; |
| 474 | |
| 475 | /* Some storage reserved for the OEM's driver. */ |
| 476 | intptr_t oem[4]; |
| 477 | |
| 478 | /* |
| 479 | * Set the swap interval for this surface. |
| 480 | * |
| 481 | * Returns 0 on success or -errno on error. |
| 482 | */ |
| 483 | int (*setSwapInterval)(struct ANativeWindow* window, |
| 484 | int interval); |
| 485 | |
| 486 | /* |
Jesse Hall | 7cd3e0a | 2011-12-12 10:32:55 -0800 | [diff] [blame] | 487 | * Hook called by EGL to acquire a buffer. After this call, the buffer |
| 488 | * is not locked, so its content cannot be modified. This call may block if |
| 489 | * no buffers are available. |
| 490 | * |
| 491 | * The window holds a reference to the buffer between dequeueBuffer and |
| 492 | * either queueBuffer or cancelBuffer, so clients only need their own |
| 493 | * reference if they might use the buffer after queueing or canceling it. |
| 494 | * Holding a reference to a buffer after queueing or canceling it is only |
| 495 | * allowed if a specific buffer count has been set. |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 496 | * |
| 497 | * Returns 0 on success or -errno on error. |
Jamie Gennis | 22aec57 | 2012-06-13 16:43:06 -0700 | [diff] [blame] | 498 | * |
| 499 | * XXX: This function is deprecated. It will continue to work for some |
| 500 | * time for binary compatibility, but the new dequeueBuffer function that |
| 501 | * outputs a fence file descriptor should be used in its place. |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 502 | */ |
Jamie Gennis | 22aec57 | 2012-06-13 16:43:06 -0700 | [diff] [blame] | 503 | int (*dequeueBuffer_DEPRECATED)(struct ANativeWindow* window, |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 504 | struct ANativeWindowBuffer** buffer); |
| 505 | |
| 506 | /* |
| 507 | * hook called by EGL to lock a buffer. This MUST be called before modifying |
| 508 | * the content of a buffer. The buffer must have been acquired with |
| 509 | * dequeueBuffer first. |
| 510 | * |
| 511 | * Returns 0 on success or -errno on error. |
Jamie Gennis | 22aec57 | 2012-06-13 16:43:06 -0700 | [diff] [blame] | 512 | * |
| 513 | * XXX: This function is deprecated. It will continue to work for some |
| 514 | * time for binary compatibility, but it is essentially a no-op, and calls |
| 515 | * to it should be removed. |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 516 | */ |
Jamie Gennis | 22aec57 | 2012-06-13 16:43:06 -0700 | [diff] [blame] | 517 | int (*lockBuffer_DEPRECATED)(struct ANativeWindow* window, |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 518 | struct ANativeWindowBuffer* buffer); |
Jamie Gennis | 22aec57 | 2012-06-13 16:43:06 -0700 | [diff] [blame] | 519 | |
Jesse Hall | 7cd3e0a | 2011-12-12 10:32:55 -0800 | [diff] [blame] | 520 | /* |
| 521 | * Hook called by EGL when modifications to the render buffer are done. |
| 522 | * This unlocks and post the buffer. |
| 523 | * |
| 524 | * The window holds a reference to the buffer between dequeueBuffer and |
| 525 | * either queueBuffer or cancelBuffer, so clients only need their own |
| 526 | * reference if they might use the buffer after queueing or canceling it. |
| 527 | * Holding a reference to a buffer after queueing or canceling it is only |
| 528 | * allowed if a specific buffer count has been set. |
| 529 | * |
| 530 | * Buffers MUST be queued in the same order than they were dequeued. |
| 531 | * |
| 532 | * Returns 0 on success or -errno on error. |
Jamie Gennis | 22aec57 | 2012-06-13 16:43:06 -0700 | [diff] [blame] | 533 | * |
| 534 | * XXX: This function is deprecated. It will continue to work for some |
| 535 | * time for binary compatibility, but the new queueBuffer function that |
| 536 | * takes a fence file descriptor should be used in its place (pass a value |
| 537 | * of -1 for the fence file descriptor if there is no valid one to pass). |
Jesse Hall | 7cd3e0a | 2011-12-12 10:32:55 -0800 | [diff] [blame] | 538 | */ |
Jamie Gennis | 22aec57 | 2012-06-13 16:43:06 -0700 | [diff] [blame] | 539 | int (*queueBuffer_DEPRECATED)(struct ANativeWindow* window, |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 540 | struct ANativeWindowBuffer* buffer); |
| 541 | |
| 542 | /* |
| 543 | * hook used to retrieve information about the native window. |
| 544 | * |
| 545 | * Returns 0 on success or -errno on error. |
| 546 | */ |
| 547 | int (*query)(const struct ANativeWindow* window, |
| 548 | int what, int* value); |
| 549 | |
| 550 | /* |
| 551 | * hook used to perform various operations on the surface. |
| 552 | * (*perform)() is a generic mechanism to add functionality to |
| 553 | * ANativeWindow while keeping backward binary compatibility. |
| 554 | * |
| 555 | * DO NOT CALL THIS HOOK DIRECTLY. Instead, use the helper functions |
| 556 | * defined below. |
| 557 | * |
Dan Stoza | 238ec98 | 2015-03-23 10:43:14 -0700 | [diff] [blame] | 558 | * (*perform)() returns -ENOENT if the 'what' parameter is not supported |
| 559 | * by the surface's implementation. |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 560 | * |
Dan Stoza | 238ec98 | 2015-03-23 10:43:14 -0700 | [diff] [blame] | 561 | * See above for a list of valid operations, such as |
| 562 | * NATIVE_WINDOW_SET_USAGE or NATIVE_WINDOW_CONNECT |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 563 | */ |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 564 | int (*perform)(struct ANativeWindow* window, |
| 565 | int operation, ... ); |
| 566 | |
| 567 | /* |
Jesse Hall | 7cd3e0a | 2011-12-12 10:32:55 -0800 | [diff] [blame] | 568 | * Hook used to cancel a buffer that has been dequeued. |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 569 | * No synchronization is performed between dequeue() and cancel(), so |
| 570 | * either external synchronization is needed, or these functions must be |
| 571 | * called from the same thread. |
Jesse Hall | 7cd3e0a | 2011-12-12 10:32:55 -0800 | [diff] [blame] | 572 | * |
| 573 | * The window holds a reference to the buffer between dequeueBuffer and |
| 574 | * either queueBuffer or cancelBuffer, so clients only need their own |
| 575 | * reference if they might use the buffer after queueing or canceling it. |
| 576 | * Holding a reference to a buffer after queueing or canceling it is only |
| 577 | * allowed if a specific buffer count has been set. |
Jamie Gennis | 22aec57 | 2012-06-13 16:43:06 -0700 | [diff] [blame] | 578 | * |
| 579 | * XXX: This function is deprecated. It will continue to work for some |
| 580 | * time for binary compatibility, but the new cancelBuffer function that |
| 581 | * takes a fence file descriptor should be used in its place (pass a value |
| 582 | * of -1 for the fence file descriptor if there is no valid one to pass). |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 583 | */ |
Jamie Gennis | 22aec57 | 2012-06-13 16:43:06 -0700 | [diff] [blame] | 584 | int (*cancelBuffer_DEPRECATED)(struct ANativeWindow* window, |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 585 | struct ANativeWindowBuffer* buffer); |
| 586 | |
Jamie Gennis | 22aec57 | 2012-06-13 16:43:06 -0700 | [diff] [blame] | 587 | /* |
| 588 | * Hook called by EGL to acquire a buffer. This call may block if no |
| 589 | * buffers are available. |
| 590 | * |
| 591 | * The window holds a reference to the buffer between dequeueBuffer and |
| 592 | * either queueBuffer or cancelBuffer, so clients only need their own |
| 593 | * reference if they might use the buffer after queueing or canceling it. |
| 594 | * Holding a reference to a buffer after queueing or canceling it is only |
| 595 | * allowed if a specific buffer count has been set. |
| 596 | * |
| 597 | * The libsync fence file descriptor returned in the int pointed to by the |
| 598 | * fenceFd argument will refer to the fence that must signal before the |
| 599 | * dequeued buffer may be written to. A value of -1 indicates that the |
| 600 | * caller may access the buffer immediately without waiting on a fence. If |
| 601 | * a valid file descriptor is returned (i.e. any value except -1) then the |
| 602 | * caller is responsible for closing the file descriptor. |
| 603 | * |
| 604 | * Returns 0 on success or -errno on error. |
| 605 | */ |
| 606 | int (*dequeueBuffer)(struct ANativeWindow* window, |
| 607 | struct ANativeWindowBuffer** buffer, int* fenceFd); |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 608 | |
Jamie Gennis | 22aec57 | 2012-06-13 16:43:06 -0700 | [diff] [blame] | 609 | /* |
| 610 | * Hook called by EGL when modifications to the render buffer are done. |
| 611 | * This unlocks and post the buffer. |
| 612 | * |
| 613 | * The window holds a reference to the buffer between dequeueBuffer and |
| 614 | * either queueBuffer or cancelBuffer, so clients only need their own |
| 615 | * reference if they might use the buffer after queueing or canceling it. |
| 616 | * Holding a reference to a buffer after queueing or canceling it is only |
| 617 | * allowed if a specific buffer count has been set. |
| 618 | * |
| 619 | * The fenceFd argument specifies a libsync fence file descriptor for a |
| 620 | * fence that must signal before the buffer can be accessed. If the buffer |
| 621 | * can be accessed immediately then a value of -1 should be used. The |
| 622 | * caller must not use the file descriptor after it is passed to |
| 623 | * queueBuffer, and the ANativeWindow implementation is responsible for |
| 624 | * closing it. |
| 625 | * |
| 626 | * Returns 0 on success or -errno on error. |
| 627 | */ |
| 628 | int (*queueBuffer)(struct ANativeWindow* window, |
| 629 | struct ANativeWindowBuffer* buffer, int fenceFd); |
| 630 | |
| 631 | /* |
| 632 | * Hook used to cancel a buffer that has been dequeued. |
| 633 | * No synchronization is performed between dequeue() and cancel(), so |
| 634 | * either external synchronization is needed, or these functions must be |
| 635 | * called from the same thread. |
| 636 | * |
| 637 | * The window holds a reference to the buffer between dequeueBuffer and |
| 638 | * either queueBuffer or cancelBuffer, so clients only need their own |
| 639 | * reference if they might use the buffer after queueing or canceling it. |
| 640 | * Holding a reference to a buffer after queueing or canceling it is only |
| 641 | * allowed if a specific buffer count has been set. |
| 642 | * |
| 643 | * The fenceFd argument specifies a libsync fence file decsriptor for a |
| 644 | * fence that must signal before the buffer can be accessed. If the buffer |
| 645 | * can be accessed immediately then a value of -1 should be used. |
| 646 | * |
| 647 | * Note that if the client has not waited on the fence that was returned |
| 648 | * from dequeueBuffer, that same fence should be passed to cancelBuffer to |
| 649 | * ensure that future uses of the buffer are preceded by a wait on that |
| 650 | * fence. The caller must not use the file descriptor after it is passed |
| 651 | * to cancelBuffer, and the ANativeWindow implementation is responsible for |
| 652 | * closing it. |
| 653 | * |
| 654 | * Returns 0 on success or -errno on error. |
| 655 | */ |
| 656 | int (*cancelBuffer)(struct ANativeWindow* window, |
| 657 | struct ANativeWindowBuffer* buffer, int fenceFd); |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 658 | }; |
| 659 | |
| 660 | /* Backwards compatibility: use ANativeWindow (struct ANativeWindow in C). |
| 661 | * android_native_window_t is deprecated. |
| 662 | */ |
| 663 | typedef struct ANativeWindow ANativeWindow; |
Mark Salyzyn | 289e111 | 2014-05-23 12:31:42 -0700 | [diff] [blame] | 664 | typedef struct ANativeWindow android_native_window_t __deprecated; |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 665 | |
| 666 | /* |
| 667 | * native_window_set_usage(..., usage) |
| 668 | * Sets the intended usage flags for the next buffers |
| 669 | * acquired with (*lockBuffer)() and on. |
| 670 | * By default (if this function is never called), a usage of |
| 671 | * GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE |
| 672 | * is assumed. |
| 673 | * Calling this function will usually cause following buffers to be |
| 674 | * reallocated. |
| 675 | */ |
| 676 | |
| 677 | static inline int native_window_set_usage( |
| 678 | struct ANativeWindow* window, int usage) |
| 679 | { |
| 680 | return window->perform(window, NATIVE_WINDOW_SET_USAGE, usage); |
| 681 | } |
| 682 | |
Mathias Agopian | 8ad5452 | 2011-07-29 17:52:36 -0700 | [diff] [blame] | 683 | /* deprecated. Always returns 0. Don't call. */ |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 684 | static inline int native_window_connect( |
Ian Rogers | de8b983 | 2014-06-27 16:38:01 -0700 | [diff] [blame] | 685 | struct ANativeWindow* window __UNUSED, int api __UNUSED) __deprecated; |
Mark Salyzyn | 289e111 | 2014-05-23 12:31:42 -0700 | [diff] [blame] | 686 | |
| 687 | static inline int native_window_connect( |
Ian Rogers | de8b983 | 2014-06-27 16:38:01 -0700 | [diff] [blame] | 688 | struct ANativeWindow* window __UNUSED, int api __UNUSED) { |
Mathias Agopian | 319f4e2 | 2011-08-03 11:26:38 -0700 | [diff] [blame] | 689 | return 0; |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 690 | } |
| 691 | |
Mathias Agopian | 8ad5452 | 2011-07-29 17:52:36 -0700 | [diff] [blame] | 692 | /* deprecated. Always returns 0. Don't call. */ |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 693 | static inline int native_window_disconnect( |
Ian Rogers | de8b983 | 2014-06-27 16:38:01 -0700 | [diff] [blame] | 694 | struct ANativeWindow* window __UNUSED, int api __UNUSED) __deprecated; |
Mark Salyzyn | 289e111 | 2014-05-23 12:31:42 -0700 | [diff] [blame] | 695 | |
| 696 | static inline int native_window_disconnect( |
Ian Rogers | de8b983 | 2014-06-27 16:38:01 -0700 | [diff] [blame] | 697 | struct ANativeWindow* window __UNUSED, int api __UNUSED) { |
Mathias Agopian | 319f4e2 | 2011-08-03 11:26:38 -0700 | [diff] [blame] | 698 | return 0; |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 699 | } |
| 700 | |
| 701 | /* |
| 702 | * native_window_set_crop(..., crop) |
| 703 | * Sets which region of the next queued buffers needs to be considered. |
Jamie Gennis | d21113a | 2012-05-03 14:21:24 -0700 | [diff] [blame] | 704 | * Depending on the scaling mode, a buffer's crop region is scaled and/or |
| 705 | * cropped to match the surface's size. This function sets the crop in |
| 706 | * pre-transformed buffer pixel coordinates. |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 707 | * |
| 708 | * The specified crop region applies to all buffers queued after it is called. |
| 709 | * |
Jamie Gennis | d21113a | 2012-05-03 14:21:24 -0700 | [diff] [blame] | 710 | * If 'crop' is NULL, subsequently queued buffers won't be cropped. |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 711 | * |
Jamie Gennis | d21113a | 2012-05-03 14:21:24 -0700 | [diff] [blame] | 712 | * An error is returned if for instance the crop region is invalid, out of the |
| 713 | * buffer's bound or if the window is invalid. |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 714 | */ |
| 715 | static inline int native_window_set_crop( |
| 716 | struct ANativeWindow* window, |
| 717 | android_native_rect_t const * crop) |
| 718 | { |
| 719 | return window->perform(window, NATIVE_WINDOW_SET_CROP, crop); |
| 720 | } |
| 721 | |
| 722 | /* |
Jamie Gennis | d21113a | 2012-05-03 14:21:24 -0700 | [diff] [blame] | 723 | * native_window_set_post_transform_crop(..., crop) |
| 724 | * Sets which region of the next queued buffers needs to be considered. |
| 725 | * Depending on the scaling mode, a buffer's crop region is scaled and/or |
| 726 | * cropped to match the surface's size. This function sets the crop in |
| 727 | * post-transformed pixel coordinates. |
| 728 | * |
| 729 | * The specified crop region applies to all buffers queued after it is called. |
| 730 | * |
| 731 | * If 'crop' is NULL, subsequently queued buffers won't be cropped. |
| 732 | * |
| 733 | * An error is returned if for instance the crop region is invalid, out of the |
| 734 | * buffer's bound or if the window is invalid. |
| 735 | */ |
| 736 | static inline int native_window_set_post_transform_crop( |
| 737 | struct ANativeWindow* window, |
| 738 | android_native_rect_t const * crop) |
| 739 | { |
| 740 | return window->perform(window, NATIVE_WINDOW_SET_POST_TRANSFORM_CROP, crop); |
| 741 | } |
| 742 | |
| 743 | /* |
Jamie Gennis | fb1ee57 | 2012-04-17 19:37:48 -0700 | [diff] [blame] | 744 | * native_window_set_active_rect(..., active_rect) |
Jamie Gennis | fb1ee57 | 2012-04-17 19:37:48 -0700 | [diff] [blame] | 745 | * |
Jamie Gennis | 22aec57 | 2012-06-13 16:43:06 -0700 | [diff] [blame] | 746 | * This function is deprecated and will be removed soon. For now it simply |
Jamie Gennis | d21113a | 2012-05-03 14:21:24 -0700 | [diff] [blame] | 747 | * sets the post-transform crop for compatibility while multi-project commits |
| 748 | * get checked. |
Jamie Gennis | fb1ee57 | 2012-04-17 19:37:48 -0700 | [diff] [blame] | 749 | */ |
| 750 | static inline int native_window_set_active_rect( |
| 751 | struct ANativeWindow* window, |
Mark Salyzyn | 289e111 | 2014-05-23 12:31:42 -0700 | [diff] [blame] | 752 | android_native_rect_t const * active_rect) __deprecated; |
| 753 | |
| 754 | static inline int native_window_set_active_rect( |
| 755 | struct ANativeWindow* window, |
Jamie Gennis | fb1ee57 | 2012-04-17 19:37:48 -0700 | [diff] [blame] | 756 | android_native_rect_t const * active_rect) |
| 757 | { |
Jamie Gennis | d21113a | 2012-05-03 14:21:24 -0700 | [diff] [blame] | 758 | return native_window_set_post_transform_crop(window, active_rect); |
Jamie Gennis | fb1ee57 | 2012-04-17 19:37:48 -0700 | [diff] [blame] | 759 | } |
| 760 | |
| 761 | /* |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 762 | * native_window_set_buffer_count(..., count) |
| 763 | * Sets the number of buffers associated with this native window. |
| 764 | */ |
| 765 | static inline int native_window_set_buffer_count( |
| 766 | struct ANativeWindow* window, |
| 767 | size_t bufferCount) |
| 768 | { |
| 769 | return window->perform(window, NATIVE_WINDOW_SET_BUFFER_COUNT, bufferCount); |
| 770 | } |
| 771 | |
| 772 | /* |
| 773 | * native_window_set_buffers_geometry(..., int w, int h, int format) |
Jamie Gennis | 208ec5e | 2011-07-07 11:51:48 -0700 | [diff] [blame] | 774 | * All buffers dequeued after this call will have the dimensions and format |
| 775 | * specified. A successful call to this function has the same effect as calling |
| 776 | * native_window_set_buffers_size and native_window_set_buffers_format. |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 777 | * |
Jamie Gennis | 208ec5e | 2011-07-07 11:51:48 -0700 | [diff] [blame] | 778 | * XXX: This function is deprecated. The native_window_set_buffers_dimensions |
| 779 | * and native_window_set_buffers_format functions should be used instead. |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 780 | */ |
| 781 | static inline int native_window_set_buffers_geometry( |
| 782 | struct ANativeWindow* window, |
Mark Salyzyn | 289e111 | 2014-05-23 12:31:42 -0700 | [diff] [blame] | 783 | int w, int h, int format) __deprecated; |
| 784 | |
| 785 | static inline int native_window_set_buffers_geometry( |
| 786 | struct ANativeWindow* window, |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 787 | int w, int h, int format) |
| 788 | { |
| 789 | return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_GEOMETRY, |
| 790 | w, h, format); |
| 791 | } |
| 792 | |
| 793 | /* |
Jamie Gennis | 208ec5e | 2011-07-07 11:51:48 -0700 | [diff] [blame] | 794 | * native_window_set_buffers_dimensions(..., int w, int h) |
| 795 | * All buffers dequeued after this call will have the dimensions specified. |
Michael I. Gold | afcdef6 | 2012-04-09 18:21:13 -0700 | [diff] [blame] | 796 | * In particular, all buffers will have a fixed-size, independent from the |
Mathias Agopian | 42cc1ed | 2011-07-13 15:49:58 -0700 | [diff] [blame] | 797 | * native-window size. They will be scaled according to the scaling mode |
| 798 | * (see native_window_set_scaling_mode) upon window composition. |
Jamie Gennis | 208ec5e | 2011-07-07 11:51:48 -0700 | [diff] [blame] | 799 | * |
| 800 | * If w and h are 0, the normal behavior is restored. That is, dequeued buffers |
| 801 | * following this call will be sized to match the window's size. |
| 802 | * |
| 803 | * Calling this function will reset the window crop to a NULL value, which |
| 804 | * disables cropping of the buffers. |
| 805 | */ |
| 806 | static inline int native_window_set_buffers_dimensions( |
| 807 | struct ANativeWindow* window, |
| 808 | int w, int h) |
| 809 | { |
| 810 | return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS, |
| 811 | w, h); |
| 812 | } |
| 813 | |
| 814 | /* |
Michael I. Gold | afcdef6 | 2012-04-09 18:21:13 -0700 | [diff] [blame] | 815 | * native_window_set_buffers_user_dimensions(..., int w, int h) |
| 816 | * |
| 817 | * Sets the user buffer size for the window, which overrides the |
| 818 | * window's size. All buffers dequeued after this call will have the |
| 819 | * dimensions specified unless overridden by |
| 820 | * native_window_set_buffers_dimensions. All buffers will have a |
| 821 | * fixed-size, independent from the native-window size. They will be |
| 822 | * scaled according to the scaling mode (see |
| 823 | * native_window_set_scaling_mode) upon window composition. |
| 824 | * |
| 825 | * If w and h are 0, the normal behavior is restored. That is, the |
| 826 | * default buffer size will match the windows's size. |
| 827 | * |
| 828 | * Calling this function will reset the window crop to a NULL value, which |
| 829 | * disables cropping of the buffers. |
| 830 | */ |
| 831 | static inline int native_window_set_buffers_user_dimensions( |
| 832 | struct ANativeWindow* window, |
| 833 | int w, int h) |
| 834 | { |
| 835 | return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS, |
| 836 | w, h); |
| 837 | } |
| 838 | |
| 839 | /* |
Jamie Gennis | 208ec5e | 2011-07-07 11:51:48 -0700 | [diff] [blame] | 840 | * native_window_set_buffers_format(..., int format) |
| 841 | * All buffers dequeued after this call will have the format specified. |
| 842 | * |
| 843 | * If the specified format is 0, the default buffer format will be used. |
| 844 | */ |
| 845 | static inline int native_window_set_buffers_format( |
| 846 | struct ANativeWindow* window, |
| 847 | int format) |
| 848 | { |
| 849 | return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_FORMAT, format); |
| 850 | } |
| 851 | |
| 852 | /* |
Eino-Ville Talvala | b93343d | 2015-02-17 15:34:44 -0800 | [diff] [blame] | 853 | * native_window_set_buffers_data_space(..., int dataSpace) |
| 854 | * All buffers queued after this call will be associated with the dataSpace |
| 855 | * parameter specified. |
| 856 | * |
| 857 | * dataSpace specifies additional information about the buffer that's dependent |
| 858 | * on the buffer format and the endpoints. For example, it can be used to convey |
| 859 | * the color space of the image data in the buffer, or it can be used to |
| 860 | * indicate that the buffers contain depth measurement data instead of color |
| 861 | * images. The default dataSpace is 0, HAL_DATASPACE_UNKNOWN, unless it has been |
| 862 | * overridden by the consumer. |
| 863 | */ |
| 864 | static inline int native_window_set_buffers_data_space( |
| 865 | struct ANativeWindow* window, |
| 866 | android_dataspace_t dataSpace) |
| 867 | { |
| 868 | return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DATASPACE, |
| 869 | dataSpace); |
| 870 | } |
| 871 | |
| 872 | /* |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 873 | * native_window_set_buffers_transform(..., int transform) |
| 874 | * All buffers queued after this call will be displayed transformed according |
| 875 | * to the transform parameter specified. |
| 876 | */ |
| 877 | static inline int native_window_set_buffers_transform( |
| 878 | struct ANativeWindow* window, |
| 879 | int transform) |
| 880 | { |
| 881 | return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TRANSFORM, |
| 882 | transform); |
| 883 | } |
| 884 | |
| 885 | /* |
Ruben Brunk | a5e65d8 | 2014-06-27 16:15:18 -0700 | [diff] [blame] | 886 | * native_window_set_buffers_sticky_transform(..., int transform) |
| 887 | * All buffers queued after this call will be displayed transformed according |
| 888 | * to the transform parameter specified applied on top of the regular buffer |
| 889 | * transform. Setting this transform will disable the transform hint. |
| 890 | * |
| 891 | * Temporary - This is only intended to be used by the LEGACY camera mode, do |
| 892 | * not use this for anything else. |
| 893 | */ |
| 894 | static inline int native_window_set_buffers_sticky_transform( |
| 895 | struct ANativeWindow* window, |
| 896 | int transform) |
| 897 | { |
| 898 | return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM, |
| 899 | transform); |
| 900 | } |
| 901 | |
| 902 | /* |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 903 | * native_window_set_buffers_timestamp(..., int64_t timestamp) |
| 904 | * All buffers queued after this call will be associated with the timestamp |
| 905 | * parameter specified. If the timestamp is set to NATIVE_WINDOW_TIMESTAMP_AUTO |
| 906 | * (the default), timestamps will be generated automatically when queueBuffer is |
Glenn Kasten | c322f67 | 2011-06-27 10:42:39 -0700 | [diff] [blame] | 907 | * called. The timestamp is measured in nanoseconds, and is normally monotonically |
| 908 | * increasing. The timestamp should be unaffected by time-of-day adjustments, |
| 909 | * and for a camera should be strictly monotonic but for a media player may be |
| 910 | * reset when the position is set. |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 911 | */ |
| 912 | static inline int native_window_set_buffers_timestamp( |
| 913 | struct ANativeWindow* window, |
| 914 | int64_t timestamp) |
| 915 | { |
| 916 | return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP, |
| 917 | timestamp); |
| 918 | } |
| 919 | |
Mathias Agopian | 42cc1ed | 2011-07-13 15:49:58 -0700 | [diff] [blame] | 920 | /* |
| 921 | * native_window_set_scaling_mode(..., int mode) |
| 922 | * All buffers queued after this call will be associated with the scaling mode |
| 923 | * specified. |
| 924 | */ |
| 925 | static inline int native_window_set_scaling_mode( |
| 926 | struct ANativeWindow* window, |
| 927 | int mode) |
| 928 | { |
| 929 | return window->perform(window, NATIVE_WINDOW_SET_SCALING_MODE, |
| 930 | mode); |
| 931 | } |
| 932 | |
Mathias Agopian | 8ad5452 | 2011-07-29 17:52:36 -0700 | [diff] [blame] | 933 | /* |
| 934 | * native_window_api_connect(..., int api) |
| 935 | * connects an API to this window. only one API can be connected at a time. |
| 936 | * Returns -EINVAL if for some reason the window cannot be connected, which |
| 937 | * can happen if it's connected to some other API. |
| 938 | */ |
| 939 | static inline int native_window_api_connect( |
| 940 | struct ANativeWindow* window, int api) |
| 941 | { |
Mathias Agopian | 319f4e2 | 2011-08-03 11:26:38 -0700 | [diff] [blame] | 942 | return window->perform(window, NATIVE_WINDOW_API_CONNECT, api); |
Mathias Agopian | 8ad5452 | 2011-07-29 17:52:36 -0700 | [diff] [blame] | 943 | } |
| 944 | |
| 945 | /* |
| 946 | * native_window_api_disconnect(..., int api) |
| 947 | * disconnect the API from this window. |
| 948 | * An error is returned if for instance the window wasn't connected in the |
| 949 | * first place. |
| 950 | */ |
| 951 | static inline int native_window_api_disconnect( |
| 952 | struct ANativeWindow* window, int api) |
| 953 | { |
Mathias Agopian | 319f4e2 | 2011-08-03 11:26:38 -0700 | [diff] [blame] | 954 | return window->perform(window, NATIVE_WINDOW_API_DISCONNECT, api); |
Mathias Agopian | 8ad5452 | 2011-07-29 17:52:36 -0700 | [diff] [blame] | 955 | } |
| 956 | |
Jamie Gennis | 22aec57 | 2012-06-13 16:43:06 -0700 | [diff] [blame] | 957 | /* |
| 958 | * native_window_dequeue_buffer_and_wait(...) |
| 959 | * Dequeue a buffer and wait on the fence associated with that buffer. The |
| 960 | * buffer may safely be accessed immediately upon this function returning. An |
| 961 | * error is returned if either of the dequeue or the wait operations fail. |
| 962 | */ |
| 963 | static inline int native_window_dequeue_buffer_and_wait(ANativeWindow *anw, |
| 964 | struct ANativeWindowBuffer** anb) { |
Jesse Hall | bc930ed | 2012-10-01 13:48:36 -0700 | [diff] [blame] | 965 | return anw->dequeueBuffer_DEPRECATED(anw, anb); |
Jamie Gennis | 22aec57 | 2012-06-13 16:43:06 -0700 | [diff] [blame] | 966 | } |
| 967 | |
Rachad | d6d4c61 | 2014-07-29 18:03:21 -0700 | [diff] [blame] | 968 | /* |
| 969 | * native_window_set_sideband_stream(..., native_handle_t*) |
| 970 | * Attach a sideband buffer stream to a native window. |
| 971 | */ |
| 972 | static inline int native_window_set_sideband_stream( |
| 973 | struct ANativeWindow* window, |
| 974 | native_handle_t* sidebandHandle) |
| 975 | { |
| 976 | return window->perform(window, NATIVE_WINDOW_SET_SIDEBAND_STREAM, |
| 977 | sidebandHandle); |
| 978 | } |
Mathias Agopian | 8ad5452 | 2011-07-29 17:52:36 -0700 | [diff] [blame] | 979 | |
Dan Stoza | 238ec98 | 2015-03-23 10:43:14 -0700 | [diff] [blame] | 980 | /* |
| 981 | * native_window_set_surface_damage(..., android_native_rect_t* rects, int numRects) |
| 982 | * Set the surface damage (i.e., the region of the surface that has changed |
| 983 | * since the previous frame). The damage set by this call will be reset (to the |
| 984 | * default of full-surface damage) after calling queue, so this must be called |
| 985 | * prior to every frame with damage that does not cover the whole surface if the |
| 986 | * caller desires downstream consumers to use this optimization. |
| 987 | * |
| 988 | * The damage region is specified as an array of rectangles, with the important |
| 989 | * caveat that the origin of the surface is considered to be the bottom-left |
| 990 | * corner, as in OpenGL ES. |
| 991 | * |
| 992 | * If numRects is set to 0, rects may be NULL, and the surface damage will be |
| 993 | * set to the full surface (the same as if this function had not been called for |
| 994 | * this frame). |
| 995 | */ |
| 996 | static inline int native_window_set_surface_damage( |
| 997 | struct ANativeWindow* window, |
| 998 | const android_native_rect_t* rects, size_t numRects) |
| 999 | { |
| 1000 | return window->perform(window, NATIVE_WINDOW_SET_SURFACE_DAMAGE, |
| 1001 | rects, numRects); |
| 1002 | } |
| 1003 | |
Pablo Ceballos | 923d27f | 2015-10-19 10:24:42 -0700 | [diff] [blame] | 1004 | /* |
Pablo Ceballos | 248e771 | 2016-03-17 15:42:21 -0700 | [diff] [blame] | 1005 | * native_window_set_shared_buffer_mode(..., bool sharedBufferMode) |
| 1006 | * Enable/disable shared buffer mode |
Pablo Ceballos | 923d27f | 2015-10-19 10:24:42 -0700 | [diff] [blame] | 1007 | */ |
Pablo Ceballos | 248e771 | 2016-03-17 15:42:21 -0700 | [diff] [blame] | 1008 | static inline int native_window_set_shared_buffer_mode( |
Pablo Ceballos | 923d27f | 2015-10-19 10:24:42 -0700 | [diff] [blame] | 1009 | struct ANativeWindow* window, |
Pablo Ceballos | 248e771 | 2016-03-17 15:42:21 -0700 | [diff] [blame] | 1010 | bool sharedBufferMode) |
Pablo Ceballos | 923d27f | 2015-10-19 10:24:42 -0700 | [diff] [blame] | 1011 | { |
Pablo Ceballos | 248e771 | 2016-03-17 15:42:21 -0700 | [diff] [blame] | 1012 | return window->perform(window, NATIVE_WINDOW_SET_SHARED_BUFFER_MODE, |
| 1013 | sharedBufferMode); |
Pablo Ceballos | 923d27f | 2015-10-19 10:24:42 -0700 | [diff] [blame] | 1014 | } |
| 1015 | |
Pablo Ceballos | 3daa574 | 2016-01-15 13:31:14 -0800 | [diff] [blame] | 1016 | /* |
| 1017 | * native_window_set_auto_refresh(..., autoRefresh) |
Pablo Ceballos | 248e771 | 2016-03-17 15:42:21 -0700 | [diff] [blame] | 1018 | * Enable/disable auto refresh when in shared buffer mode |
Pablo Ceballos | 3daa574 | 2016-01-15 13:31:14 -0800 | [diff] [blame] | 1019 | */ |
| 1020 | static inline int native_window_set_auto_refresh( |
| 1021 | struct ANativeWindow* window, |
| 1022 | bool autoRefresh) |
| 1023 | { |
| 1024 | return window->perform(window, NATIVE_WINDOW_SET_AUTO_REFRESH, autoRefresh); |
| 1025 | } |
| 1026 | |
Brian Anderson | ad79a39 | 2016-12-08 12:03:49 -0800 | [diff] [blame] | 1027 | static inline int native_window_get_refresh_cycle_duration( |
| 1028 | struct ANativeWindow* window, |
| 1029 | int64_t* outRefreshDuration) |
| 1030 | { |
| 1031 | return window->perform(window, NATIVE_WINDOW_GET_REFRESH_CYCLE_DURATION, |
| 1032 | outRefreshDuration); |
| 1033 | } |
| 1034 | |
Brian Anderson | d1dbcd6 | 2017-01-03 15:40:02 -0800 | [diff] [blame] | 1035 | static inline int native_window_get_next_frame_id( |
| 1036 | struct ANativeWindow* window, uint64_t* frameId) |
| 1037 | { |
| 1038 | return window->perform(window, NATIVE_WINDOW_GET_NEXT_FRAME_ID, frameId); |
| 1039 | } |
| 1040 | |
Brian Anderson | 77e53d9 | 2016-07-19 14:00:28 -0700 | [diff] [blame] | 1041 | static inline int native_window_enable_frame_timestamps( |
| 1042 | struct ANativeWindow* window, bool enable) |
| 1043 | { |
| 1044 | return window->perform(window, NATIVE_WINDOW_ENABLE_FRAME_TIMESTAMPS, |
| 1045 | enable); |
| 1046 | } |
| 1047 | |
Brian Anderson | ad79a39 | 2016-12-08 12:03:49 -0800 | [diff] [blame] | 1048 | static inline int native_window_get_compositor_timing( |
| 1049 | struct ANativeWindow* window, |
| 1050 | int64_t* compositeDeadline, int64_t* compositeInterval, |
| 1051 | int64_t* compositeToPresentLatency) |
| 1052 | { |
| 1053 | return window->perform(window, NATIVE_WINDOW_GET_COMPOSITOR_TIMING, |
| 1054 | compositeDeadline, compositeInterval, compositeToPresentLatency); |
| 1055 | } |
| 1056 | |
Pablo Ceballos | c2efc32 | 2016-05-31 11:06:03 -0700 | [diff] [blame] | 1057 | static inline int native_window_get_frame_timestamps( |
Brian Anderson | d1dbcd6 | 2017-01-03 15:40:02 -0800 | [diff] [blame] | 1058 | struct ANativeWindow* window, uint64_t frameId, |
Brian Anderson | 18f2903 | 2016-07-22 10:38:53 -0700 | [diff] [blame] | 1059 | int64_t* outRequestedPresentTime, int64_t* outAcquireTime, |
Brian Anderson | 6933088 | 2016-09-02 10:16:31 -0700 | [diff] [blame] | 1060 | int64_t* outLatchTime, int64_t* outFirstRefreshStartTime, |
Brian Anderson | b5ade03 | 2016-10-27 12:18:11 -0700 | [diff] [blame] | 1061 | int64_t* outLastRefreshStartTime, int64_t* outGpuCompositionDoneTime, |
Brian Anderson | 43f232b | 2016-07-22 10:48:59 -0700 | [diff] [blame] | 1062 | int64_t* outDisplayPresentTime, int64_t* outDisplayRetireTime, |
Brian Anderson | 6933088 | 2016-09-02 10:16:31 -0700 | [diff] [blame] | 1063 | int64_t* outDequeueReadyTime, int64_t* outReleaseTime) |
Pablo Ceballos | c2efc32 | 2016-05-31 11:06:03 -0700 | [diff] [blame] | 1064 | { |
| 1065 | return window->perform(window, NATIVE_WINDOW_GET_FRAME_TIMESTAMPS, |
Brian Anderson | d1dbcd6 | 2017-01-03 15:40:02 -0800 | [diff] [blame] | 1066 | frameId, outRequestedPresentTime, outAcquireTime, outLatchTime, |
Brian Anderson | 6933088 | 2016-09-02 10:16:31 -0700 | [diff] [blame] | 1067 | outFirstRefreshStartTime, outLastRefreshStartTime, |
Brian Anderson | b5ade03 | 2016-10-27 12:18:11 -0700 | [diff] [blame] | 1068 | outGpuCompositionDoneTime, outDisplayPresentTime, |
Brian Anderson | 6933088 | 2016-09-02 10:16:31 -0700 | [diff] [blame] | 1069 | outDisplayRetireTime, outDequeueReadyTime, outReleaseTime); |
Pablo Ceballos | c2efc32 | 2016-05-31 11:06:03 -0700 | [diff] [blame] | 1070 | } |
| 1071 | |
Courtney Goeltzenleuchter | fbef1c3 | 2017-02-02 11:05:49 -0700 | [diff] [blame] | 1072 | static inline int native_window_get_wide_color_support( |
| 1073 | struct ANativeWindow* window, bool* outSupport) { |
| 1074 | return window->perform(window, NATIVE_WINDOW_GET_WIDE_COLOR_SUPPORT, |
| 1075 | outSupport); |
| 1076 | } |
| 1077 | |
| 1078 | static inline int native_window_get_hdr_support(struct ANativeWindow* window, |
| 1079 | bool* outSupport) { |
| 1080 | return window->perform(window, NATIVE_WINDOW_GET_HDR_SUPPORT, outSupport); |
| 1081 | } |
Pablo Ceballos | c2efc32 | 2016-05-31 11:06:03 -0700 | [diff] [blame] | 1082 | |
Iliyan Malchev | 0ab886b | 2011-05-01 14:07:43 -0700 | [diff] [blame] | 1083 | __END_DECLS |
| 1084 | |
tedbo | 1ffdb38 | 2011-05-24 00:55:33 -0700 | [diff] [blame] | 1085 | #endif /* SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H */ |