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