| Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright 2018 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 | * @addtogroup NativeActivity Native Activity | 
|  | 19 | * @{ | 
|  | 20 | */ | 
|  | 21 |  | 
|  | 22 | /** | 
|  | 23 | * @file surface_control.h | 
|  | 24 | */ | 
|  | 25 |  | 
|  | 26 | #ifndef ANDROID_SURFACE_CONTROL_H | 
|  | 27 | #define ANDROID_SURFACE_CONTROL_H | 
|  | 28 |  | 
|  | 29 | #include <sys/cdefs.h> | 
|  | 30 |  | 
| Rachel Lee | 1fb2ddc | 2022-01-12 14:33:07 -0800 | [diff] [blame] | 31 | #include <android/choreographer.h> | 
| Marissa Wall | 3ff826c | 2019-02-07 11:58:25 -0800 | [diff] [blame] | 32 | #include <android/data_space.h> | 
| Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 33 | #include <android/hardware_buffer.h> | 
| Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 34 | #include <android/hdr_metadata.h> | 
| Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 35 | #include <android/native_window.h> | 
|  | 36 |  | 
|  | 37 | __BEGIN_DECLS | 
|  | 38 |  | 
| Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 39 | struct ASurfaceControl; | 
|  | 40 |  | 
|  | 41 | /** | 
| Elliott Hughes | 733bf99 | 2019-03-08 11:25:28 -0800 | [diff] [blame] | 42 | * The SurfaceControl API can be used to provide a hierarchy of surfaces for | 
| Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 43 | * composition to the system compositor. ASurfaceControl represents a content node in | 
| Elliott Hughes | 733bf99 | 2019-03-08 11:25:28 -0800 | [diff] [blame] | 44 | * this hierarchy. | 
| Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 45 | */ | 
|  | 46 | typedef struct ASurfaceControl ASurfaceControl; | 
|  | 47 |  | 
| Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 48 | /** | 
| Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 49 | * Creates an ASurfaceControl with either ANativeWindow or an ASurfaceControl as its parent. | 
| Marin Shalamanov | 110c6bc | 2020-11-16 17:57:59 +0100 | [diff] [blame] | 50 | * \a debug_name is a debug name associated with this surface. It can be used to | 
| Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 51 | * identify this surface in the SurfaceFlinger's layer tree. It must not be | 
|  | 52 | * null. | 
|  | 53 | * | 
|  | 54 | * The caller takes ownership of the ASurfaceControl returned and must release it | 
|  | 55 | * using ASurfaceControl_release below. | 
| Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 56 | * | 
|  | 57 | * Available since API level 29. | 
| Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 58 | */ | 
|  | 59 | ASurfaceControl* ASurfaceControl_createFromWindow(ANativeWindow* parent, const char* debug_name) | 
|  | 60 | __INTRODUCED_IN(29); | 
|  | 61 |  | 
| Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 62 | /** | 
|  | 63 | * See ASurfaceControl_createFromWindow. | 
|  | 64 | * | 
|  | 65 | * Available since API level 29. | 
|  | 66 | */ | 
| Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 67 | ASurfaceControl* ASurfaceControl_create(ASurfaceControl* parent, const char* debug_name) | 
|  | 68 | __INTRODUCED_IN(29); | 
|  | 69 |  | 
|  | 70 | /** | 
| Huihong Luo | db5778e | 2021-01-28 14:48:59 -0800 | [diff] [blame] | 71 | * Acquires a reference on the given ASurfaceControl object.  This prevents the object | 
|  | 72 | * from being deleted until the reference is removed. | 
|  | 73 | * | 
|  | 74 | * To release the reference, use the ASurfaceControl_release function. | 
|  | 75 | * | 
|  | 76 | * Available since API level 31. | 
|  | 77 | */ | 
|  | 78 | void ASurfaceControl_acquire(ASurfaceControl* surface_control) __INTRODUCED_IN(31); | 
|  | 79 |  | 
|  | 80 | /** | 
|  | 81 | * Removes a reference that was previously acquired with one of the following functions: | 
|  | 82 | *   ASurfaceControl_createFromWindow | 
|  | 83 | *   ASurfaceControl_create | 
|  | 84 | *   ANativeWindow_acquire | 
|  | 85 | * The surface and its children may remain on display as long as their parent remains on display. | 
| Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 86 | * | 
|  | 87 | * Available since API level 29. | 
| Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 88 | */ | 
| Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 89 | void ASurfaceControl_release(ASurfaceControl* surface_control) __INTRODUCED_IN(29); | 
| Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 90 |  | 
|  | 91 | struct ASurfaceTransaction; | 
|  | 92 |  | 
|  | 93 | /** | 
|  | 94 | * ASurfaceTransaction is a collection of updates to the surface tree that must | 
|  | 95 | * be applied atomically. | 
|  | 96 | */ | 
|  | 97 | typedef struct ASurfaceTransaction ASurfaceTransaction; | 
|  | 98 |  | 
|  | 99 | /** | 
|  | 100 | * The caller takes ownership of the transaction and must release it using | 
| Marin Shalamanov | 110c6bc | 2020-11-16 17:57:59 +0100 | [diff] [blame] | 101 | * ASurfaceTransaction_delete() below. | 
| Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 102 | * | 
|  | 103 | * Available since API level 29. | 
| Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 104 | */ | 
|  | 105 | ASurfaceTransaction* ASurfaceTransaction_create() __INTRODUCED_IN(29); | 
|  | 106 |  | 
|  | 107 | /** | 
| Marin Shalamanov | 110c6bc | 2020-11-16 17:57:59 +0100 | [diff] [blame] | 108 | * Destroys the \a transaction object. | 
| Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 109 | * | 
|  | 110 | * Available since API level 29. | 
| Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 111 | */ | 
|  | 112 | void ASurfaceTransaction_delete(ASurfaceTransaction* transaction) __INTRODUCED_IN(29); | 
|  | 113 |  | 
|  | 114 | /** | 
| Marin Shalamanov | 110c6bc | 2020-11-16 17:57:59 +0100 | [diff] [blame] | 115 | * Applies the updates accumulated in \a transaction. | 
| Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 116 | * | 
|  | 117 | * Note that the transaction is guaranteed to be applied atomically. The | 
|  | 118 | * transactions which are applied on the same thread are also guaranteed to be | 
|  | 119 | * applied in order. | 
| Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 120 | * | 
|  | 121 | * Available since API level 29. | 
| Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 122 | */ | 
|  | 123 | void ASurfaceTransaction_apply(ASurfaceTransaction* transaction) __INTRODUCED_IN(29); | 
|  | 124 |  | 
|  | 125 | /** | 
| Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 126 | * An opaque handle returned during a callback that can be used to query general stats and stats for | 
|  | 127 | * surfaces which were either removed or for which buffers were updated after this transaction was | 
|  | 128 | * applied. | 
|  | 129 | */ | 
|  | 130 | typedef struct ASurfaceTransactionStats ASurfaceTransactionStats; | 
|  | 131 |  | 
|  | 132 | /** | 
| Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 133 | * Since the transactions are applied asynchronously, the | 
|  | 134 | * ASurfaceTransaction_OnComplete callback can be used to be notified when a frame | 
|  | 135 | * including the updates in a transaction was presented. | 
|  | 136 | * | 
| Robert Carr | 1108579 | 2021-05-12 14:35:35 -0700 | [diff] [blame] | 137 | * Buffers which are replaced or removed from the scene in the transaction invoking | 
|  | 138 | * this callback may be reused after this point. | 
|  | 139 | * | 
| Marin Shalamanov | 110c6bc | 2020-11-16 17:57:59 +0100 | [diff] [blame] | 140 | * \param context Optional context provided by the client that is passed into | 
| Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 141 | * the callback. | 
| Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 142 | * | 
| Marin Shalamanov | 110c6bc | 2020-11-16 17:57:59 +0100 | [diff] [blame] | 143 | * \param stats Opaque handle that can be passed to ASurfaceTransactionStats functions to query | 
| Elliott Hughes | 733bf99 | 2019-03-08 11:25:28 -0800 | [diff] [blame] | 144 | * information about the transaction. The handle is only valid during the callback. | 
| Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 145 | * | 
|  | 146 | * THREADING | 
|  | 147 | * The transaction completed callback can be invoked on any thread. | 
| Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 148 | * | 
|  | 149 | * Available since API level 29. | 
| Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 150 | */ | 
| Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 151 | typedef void (*ASurfaceTransaction_OnComplete)(void* context, ASurfaceTransactionStats* stats) | 
|  | 152 | __INTRODUCED_IN(29); | 
|  | 153 |  | 
| Vishnu Nair | fc46c1e | 2021-04-21 08:31:32 -0700 | [diff] [blame] | 154 |  | 
|  | 155 | /** | 
|  | 156 | * The ASurfaceTransaction_OnCommit callback is invoked when transaction is applied and the updates | 
|  | 157 | * are ready to be presented. This callback will be invoked before the | 
|  | 158 | * ASurfaceTransaction_OnComplete callback. | 
|  | 159 | * | 
| Robert Carr | 1108579 | 2021-05-12 14:35:35 -0700 | [diff] [blame] | 160 | * This callback does not mean buffers have been released! It simply means that any new | 
|  | 161 | * transactions applied will not overwrite the transaction for which we are receiving | 
|  | 162 | * a callback and instead will be included in the next frame. If you are trying to avoid | 
|  | 163 | * dropping frames (overwriting transactions), and unable to use timestamps (Which provide | 
|  | 164 | * a more efficient solution), then this method provides a method to pace your transaction | 
|  | 165 | * application. | 
|  | 166 | * | 
| Vishnu Nair | fc46c1e | 2021-04-21 08:31:32 -0700 | [diff] [blame] | 167 | * \param context Optional context provided by the client that is passed into the callback. | 
|  | 168 | * | 
|  | 169 | * \param stats Opaque handle that can be passed to ASurfaceTransactionStats functions to query | 
|  | 170 | * information about the transaction. The handle is only valid during the callback. | 
|  | 171 | * Present and release fences are not available for this callback. Querying them using | 
|  | 172 | * ASurfaceTransactionStats_getPresentFenceFd and ASurfaceTransactionStats_getPreviousReleaseFenceFd | 
|  | 173 | * will result in failure. | 
|  | 174 | * | 
|  | 175 | * THREADING | 
|  | 176 | * The transaction committed callback can be invoked on any thread. | 
|  | 177 | * | 
|  | 178 | * Available since API level 31. | 
|  | 179 | */ | 
|  | 180 | typedef void (*ASurfaceTransaction_OnCommit)(void* context, ASurfaceTransactionStats* stats) | 
|  | 181 | __INTRODUCED_IN(31); | 
|  | 182 |  | 
| Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 183 | /** | 
|  | 184 | * Returns the timestamp of when the frame was latched by the framework. Once a frame is | 
|  | 185 | * latched by the framework, it is presented at the following hardware vsync. | 
| Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 186 | * | 
|  | 187 | * Available since API level 29. | 
| Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 188 | */ | 
|  | 189 | int64_t ASurfaceTransactionStats_getLatchTime(ASurfaceTransactionStats* surface_transaction_stats) | 
|  | 190 | __INTRODUCED_IN(29); | 
|  | 191 |  | 
|  | 192 | /** | 
|  | 193 | * Returns a sync fence that signals when the transaction has been presented. | 
|  | 194 | * The recipient of the callback takes ownership of the fence and is responsible for closing | 
| Marissa Wall | 183c44c | 2019-04-08 12:58:50 -0700 | [diff] [blame] | 195 | * it. If a device does not support present fences, a -1 will be returned. | 
| Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 196 | * | 
| Vishnu Nair | fc46c1e | 2021-04-21 08:31:32 -0700 | [diff] [blame] | 197 | * This query is not valid for ASurfaceTransaction_OnCommit callback. | 
|  | 198 | * | 
| Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 199 | * Available since API level 29. | 
| Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 200 | */ | 
|  | 201 | int ASurfaceTransactionStats_getPresentFenceFd(ASurfaceTransactionStats* surface_transaction_stats) | 
|  | 202 | __INTRODUCED_IN(29); | 
|  | 203 |  | 
|  | 204 | /** | 
| Marin Shalamanov | 110c6bc | 2020-11-16 17:57:59 +0100 | [diff] [blame] | 205 | * \a outASurfaceControls returns an array of ASurfaceControl pointers that were updated during the | 
| Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 206 | * transaction. Stats for the surfaces can be queried through ASurfaceTransactionStats functions. | 
|  | 207 | * When the client is done using the array, it must release it by calling | 
|  | 208 | * ASurfaceTransactionStats_releaseASurfaceControls. | 
|  | 209 | * | 
| Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 210 | * Available since API level 29. | 
|  | 211 | * | 
| Marin Shalamanov | 110c6bc | 2020-11-16 17:57:59 +0100 | [diff] [blame] | 212 | * \a outASurfaceControlsSize returns the size of the ASurfaceControls array. | 
| Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 213 | */ | 
|  | 214 | void ASurfaceTransactionStats_getASurfaceControls(ASurfaceTransactionStats* surface_transaction_stats, | 
|  | 215 | ASurfaceControl*** outASurfaceControls, | 
|  | 216 | size_t* outASurfaceControlsSize) | 
|  | 217 | __INTRODUCED_IN(29); | 
|  | 218 | /** | 
|  | 219 | * Releases the array of ASurfaceControls that were returned by | 
| Marin Shalamanov | 110c6bc | 2020-11-16 17:57:59 +0100 | [diff] [blame] | 220 | * ASurfaceTransactionStats_getASurfaceControls(). | 
| Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 221 | * | 
|  | 222 | * Available since API level 29. | 
| Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 223 | */ | 
|  | 224 | void ASurfaceTransactionStats_releaseASurfaceControls(ASurfaceControl** surface_controls) | 
|  | 225 | __INTRODUCED_IN(29); | 
|  | 226 |  | 
|  | 227 | /** | 
|  | 228 | * Returns the timestamp of when the CURRENT buffer was acquired. A buffer is considered | 
|  | 229 | * acquired when its acquire_fence_fd has signaled. A buffer cannot be latched or presented until | 
|  | 230 | * it is acquired. If no acquire_fence_fd was provided, this timestamp will be set to -1. | 
| Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 231 | * | 
|  | 232 | * Available since API level 29. | 
| Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 233 | */ | 
|  | 234 | int64_t ASurfaceTransactionStats_getAcquireTime(ASurfaceTransactionStats* surface_transaction_stats, | 
|  | 235 | ASurfaceControl* surface_control) | 
|  | 236 | __INTRODUCED_IN(29); | 
|  | 237 |  | 
|  | 238 | /** | 
|  | 239 | * The returns the fence used to signal the release of the PREVIOUS buffer set on | 
|  | 240 | * this surface. If this fence is valid (>=0), the PREVIOUS buffer has not yet been released and the | 
|  | 241 | * fence will signal when the PREVIOUS buffer has been released. If the fence is -1 , the PREVIOUS | 
|  | 242 | * buffer is already released. The recipient of the callback takes ownership of the | 
|  | 243 | * previousReleaseFenceFd and is responsible for closing it. | 
|  | 244 | * | 
| Marin Shalamanov | 110c6bc | 2020-11-16 17:57:59 +0100 | [diff] [blame] | 245 | * Each time a buffer is set through ASurfaceTransaction_setBuffer() on a transaction | 
|  | 246 | * which is applied, the framework takes a ref on this buffer. The framework treats the | 
| Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 247 | * addition of a buffer to a particular surface as a unique ref. When a transaction updates or | 
|  | 248 | * removes a buffer from a surface, or removes the surface itself from the tree, this ref is | 
|  | 249 | * guaranteed to be released in the OnComplete callback for this transaction. The | 
|  | 250 | * ASurfaceControlStats provided in the callback for this surface may contain an optional fence | 
|  | 251 | * which must be signaled before the ref is assumed to be released. | 
|  | 252 | * | 
|  | 253 | * The client must ensure that all pending refs on a buffer are released before attempting to reuse | 
|  | 254 | * this buffer, otherwise synchronization errors may occur. | 
| Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 255 | * | 
| Vishnu Nair | fc46c1e | 2021-04-21 08:31:32 -0700 | [diff] [blame] | 256 | * This query is not valid for ASurfaceTransaction_OnCommit callback. | 
|  | 257 | * | 
| Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 258 | * Available since API level 29. | 
| Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 259 | */ | 
|  | 260 | int ASurfaceTransactionStats_getPreviousReleaseFenceFd( | 
|  | 261 | ASurfaceTransactionStats* surface_transaction_stats, | 
|  | 262 | ASurfaceControl* surface_control) | 
|  | 263 | __INTRODUCED_IN(29); | 
| Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 264 |  | 
|  | 265 | /** | 
|  | 266 | * Sets the callback that will be invoked when the updates from this transaction | 
|  | 267 | * are presented. For details on the callback semantics and data, see the | 
|  | 268 | * comments on the ASurfaceTransaction_OnComplete declaration above. | 
| Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 269 | * | 
|  | 270 | * Available since API level 29. | 
| Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 271 | */ | 
|  | 272 | void ASurfaceTransaction_setOnComplete(ASurfaceTransaction* transaction, void* context, | 
|  | 273 | ASurfaceTransaction_OnComplete func) __INTRODUCED_IN(29); | 
|  | 274 |  | 
| Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 275 | /** | 
| Vishnu Nair | fc46c1e | 2021-04-21 08:31:32 -0700 | [diff] [blame] | 276 | * Sets the callback that will be invoked when the updates from this transaction are applied and are | 
|  | 277 | * ready to be presented. This callback will be invoked before the ASurfaceTransaction_OnComplete | 
|  | 278 | * callback. | 
|  | 279 | * | 
|  | 280 | * Available since API level 31. | 
|  | 281 | */ | 
|  | 282 | void ASurfaceTransaction_setOnCommit(ASurfaceTransaction* transaction, void* context, | 
|  | 283 | ASurfaceTransaction_OnCommit func) __INTRODUCED_IN(31); | 
|  | 284 |  | 
|  | 285 | /** | 
| Marin Shalamanov | 110c6bc | 2020-11-16 17:57:59 +0100 | [diff] [blame] | 286 | * Reparents the \a surface_control from its old parent to the \a new_parent surface control. | 
|  | 287 | * Any children of the reparented \a surface_control will remain children of the \a surface_control. | 
| Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 288 | * | 
| Marin Shalamanov | 110c6bc | 2020-11-16 17:57:59 +0100 | [diff] [blame] | 289 | * The \a new_parent can be null. Surface controls with a null parent do not appear on the display. | 
| Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 290 | * | 
|  | 291 | * Available since API level 29. | 
| Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 292 | */ | 
|  | 293 | void ASurfaceTransaction_reparent(ASurfaceTransaction* transaction, | 
|  | 294 | ASurfaceControl* surface_control, ASurfaceControl* new_parent) | 
|  | 295 | __INTRODUCED_IN(29); | 
|  | 296 |  | 
| Marin Shalamanov | 110c6bc | 2020-11-16 17:57:59 +0100 | [diff] [blame] | 297 | /** | 
|  | 298 | * Parameter for ASurfaceTransaction_setVisibility(). | 
|  | 299 | */ | 
| Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 300 | enum { | 
|  | 301 | ASURFACE_TRANSACTION_VISIBILITY_HIDE = 0, | 
|  | 302 | ASURFACE_TRANSACTION_VISIBILITY_SHOW = 1, | 
|  | 303 | }; | 
|  | 304 | /** | 
| Marin Shalamanov | 110c6bc | 2020-11-16 17:57:59 +0100 | [diff] [blame] | 305 | * Updates the visibility of \a surface_control. If show is set to | 
|  | 306 | * ASURFACE_TRANSACTION_VISIBILITY_HIDE, the \a surface_control and all surfaces in its subtree will | 
| Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 307 | * be hidden. | 
| Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 308 | * | 
|  | 309 | * Available since API level 29. | 
| Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 310 | */ | 
|  | 311 | void ASurfaceTransaction_setVisibility(ASurfaceTransaction* transaction, | 
|  | 312 | ASurfaceControl* surface_control, int8_t visibility) | 
|  | 313 | __INTRODUCED_IN(29); | 
|  | 314 |  | 
|  | 315 | /** | 
| Marin Shalamanov | 110c6bc | 2020-11-16 17:57:59 +0100 | [diff] [blame] | 316 | * Updates the z order index for \a surface_control. Note that the z order for a surface | 
| Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 317 | * is relative to other surfaces which are siblings of this surface. The behavior of sibilings with | 
|  | 318 | * the same z order is undefined. | 
|  | 319 | * | 
|  | 320 | * Z orders may be from MIN_INT32 to MAX_INT32. A layer's default z order index is 0. | 
| Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 321 | * | 
|  | 322 | * Available since API level 29. | 
| Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 323 | */ | 
|  | 324 | void ASurfaceTransaction_setZOrder(ASurfaceTransaction* transaction, | 
|  | 325 | ASurfaceControl* surface_control, int32_t z_order) | 
|  | 326 | __INTRODUCED_IN(29); | 
|  | 327 |  | 
|  | 328 | /** | 
| Marin Shalamanov | 110c6bc | 2020-11-16 17:57:59 +0100 | [diff] [blame] | 329 | * Updates the AHardwareBuffer displayed for \a surface_control. If not -1, the | 
| Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 330 | * acquire_fence_fd should be a file descriptor that is signaled when all pending work | 
| Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 331 | * for the buffer is complete and the buffer can be safely read. | 
|  | 332 | * | 
| Marin Shalamanov | 110c6bc | 2020-11-16 17:57:59 +0100 | [diff] [blame] | 333 | * The frameworks takes ownership of the \a acquire_fence_fd passed and is responsible | 
| Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 334 | * for closing it. | 
| Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 335 | * | 
| Ady Abraham | 38605fc | 2021-03-29 20:33:42 +0000 | [diff] [blame] | 336 | * Note that the buffer must be allocated with AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE | 
|  | 337 | * as the surface control might be composited using the GPU. | 
|  | 338 | * | 
| Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 339 | * Available since API level 29. | 
| Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 340 | */ | 
|  | 341 | void ASurfaceTransaction_setBuffer(ASurfaceTransaction* transaction, | 
|  | 342 | ASurfaceControl* surface_control, AHardwareBuffer* buffer, | 
| Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 343 | int acquire_fence_fd = -1) __INTRODUCED_IN(29); | 
| Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 344 |  | 
|  | 345 | /** | 
| Marin Shalamanov | 110c6bc | 2020-11-16 17:57:59 +0100 | [diff] [blame] | 346 | * Updates the color for \a surface_control.  This will make the background color for the | 
|  | 347 | * ASurfaceControl visible in transparent regions of the surface.  Colors \a r, \a g, | 
|  | 348 | * and \a b must be within the range that is valid for \a dataspace.  \a dataspace and \a alpha | 
| Valerie Hau | ed54efa | 2019-01-11 20:03:14 -0800 | [diff] [blame] | 349 | * will be the dataspace and alpha set for the background color layer. | 
| Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 350 | * | 
|  | 351 | * Available since API level 29. | 
| Valerie Hau | ed54efa | 2019-01-11 20:03:14 -0800 | [diff] [blame] | 352 | */ | 
|  | 353 | void ASurfaceTransaction_setColor(ASurfaceTransaction* transaction, | 
|  | 354 | ASurfaceControl* surface_control, float r, float g, float b, | 
|  | 355 | float alpha, ADataSpace dataspace) | 
|  | 356 | __INTRODUCED_IN(29); | 
|  | 357 |  | 
|  | 358 | /** | 
| Marin Shalamanov | 110c6bc | 2020-11-16 17:57:59 +0100 | [diff] [blame] | 359 | * \param source The sub-rect within the buffer's content to be rendered inside the surface's area | 
| Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 360 | * The surface's source rect is clipped by the bounds of its current buffer. The source rect's width | 
|  | 361 | * and height must be > 0. | 
|  | 362 | * | 
| Marin Shalamanov | 110c6bc | 2020-11-16 17:57:59 +0100 | [diff] [blame] | 363 | * \param destination Specifies the rect in the parent's space where this surface will be drawn. The post | 
| Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 364 | * source rect bounds are scaled to fit the destination rect. The surface's destination rect is | 
|  | 365 | * clipped by the bounds of its parent. The destination rect's width and height must be > 0. | 
|  | 366 | * | 
| Marin Shalamanov | 110c6bc | 2020-11-16 17:57:59 +0100 | [diff] [blame] | 367 | * \param transform The transform applied after the source rect is applied to the buffer. This parameter | 
| Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 368 | * should be set to 0 for no transform. To specify a transfrom use the NATIVE_WINDOW_TRANSFORM_* | 
|  | 369 | * enum. | 
| Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 370 | * | 
|  | 371 | * Available since API level 29. | 
| chaviw | 1f5e740 | 2021-04-29 09:15:20 -0500 | [diff] [blame] | 372 | * | 
|  | 373 | * @deprecated Use setCrop, setPosition, setBufferTransform, and setScale instead. Those functions | 
|  | 374 | * provide well defined behavior and allows for more control by the apps. It also allows the caller | 
|  | 375 | * to set different properties at different times, instead of having to specify all the desired | 
|  | 376 | * properties at once. | 
| Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 377 | */ | 
|  | 378 | void ASurfaceTransaction_setGeometry(ASurfaceTransaction* transaction, | 
|  | 379 | ASurfaceControl* surface_control, const ARect& source, | 
|  | 380 | const ARect& destination, int32_t transform) | 
|  | 381 | __INTRODUCED_IN(29); | 
|  | 382 |  | 
| Vasiliy Telezhnikov | fb3ab5b | 2021-03-13 20:00:26 -0500 | [diff] [blame] | 383 | /** | 
| chaviw | be8d009 | 2021-03-29 18:49:46 -0500 | [diff] [blame] | 384 | * Bounds the surface and its children to the bounds specified. The crop and buffer size will be | 
|  | 385 | * used to determine the bounds of the surface. If no crop is specified and the surface has no | 
|  | 386 | * buffer, the surface bounds is only constrained by the size of its parent bounds. | 
|  | 387 | * | 
|  | 388 | * \param crop The bounds of the crop to apply. | 
| Vasiliy Telezhnikov | fb3ab5b | 2021-03-13 20:00:26 -0500 | [diff] [blame] | 389 | * | 
|  | 390 | * Available since API level 31. | 
|  | 391 | */ | 
| chaviw | be8d009 | 2021-03-29 18:49:46 -0500 | [diff] [blame] | 392 | void ASurfaceTransaction_setCrop(ASurfaceTransaction* transaction, | 
|  | 393 | ASurfaceControl* surface_control, const ARect& crop) | 
| Vasiliy Telezhnikov | fb3ab5b | 2021-03-13 20:00:26 -0500 | [diff] [blame] | 394 | __INTRODUCED_IN(31); | 
|  | 395 |  | 
|  | 396 | /** | 
| chaviw | be8d009 | 2021-03-29 18:49:46 -0500 | [diff] [blame] | 397 | * Specifies the position in the parent's space where the surface will be drawn. | 
|  | 398 | * | 
|  | 399 | * \param x The x position to render the surface. | 
|  | 400 | * \param y The y position to render the surface. | 
| Vasiliy Telezhnikov | fb3ab5b | 2021-03-13 20:00:26 -0500 | [diff] [blame] | 401 | * | 
|  | 402 | * Available since API level 31. | 
|  | 403 | */ | 
|  | 404 | void ASurfaceTransaction_setPosition(ASurfaceTransaction* transaction, | 
| chaviw | be8d009 | 2021-03-29 18:49:46 -0500 | [diff] [blame] | 405 | ASurfaceControl* surface_control, int32_t x, int32_t y) | 
| Vasiliy Telezhnikov | fb3ab5b | 2021-03-13 20:00:26 -0500 | [diff] [blame] | 406 | __INTRODUCED_IN(31); | 
|  | 407 |  | 
|  | 408 | /** | 
|  | 409 | * \param transform The transform applied after the source rect is applied to the buffer. This | 
| chaviw | be8d009 | 2021-03-29 18:49:46 -0500 | [diff] [blame] | 410 | * parameter should be set to 0 for no transform. To specify a transform use the | 
| Vasiliy Telezhnikov | fb3ab5b | 2021-03-13 20:00:26 -0500 | [diff] [blame] | 411 | * NATIVE_WINDOW_TRANSFORM_* enum. | 
|  | 412 | * | 
|  | 413 | * Available since API level 31. | 
|  | 414 | */ | 
| chaviw | be8d009 | 2021-03-29 18:49:46 -0500 | [diff] [blame] | 415 | void ASurfaceTransaction_setBufferTransform(ASurfaceTransaction* transaction, | 
| Vasiliy Telezhnikov | fb3ab5b | 2021-03-13 20:00:26 -0500 | [diff] [blame] | 416 | ASurfaceControl* surface_control, int32_t transform) | 
|  | 417 | __INTRODUCED_IN(31); | 
| Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 418 |  | 
| Marin Shalamanov | 110c6bc | 2020-11-16 17:57:59 +0100 | [diff] [blame] | 419 | /** | 
| chaviw | be8d009 | 2021-03-29 18:49:46 -0500 | [diff] [blame] | 420 | * Sets an x and y scale of a surface with (0, 0) as the centerpoint of the scale. | 
|  | 421 | * | 
|  | 422 | * \param xScale The scale in the x direction. Must be greater than 0. | 
|  | 423 | * \param yScale The scale in the y direction. Must be greater than 0. | 
|  | 424 | * | 
|  | 425 | * Available since API level 31. | 
|  | 426 | */ | 
|  | 427 | void ASurfaceTransaction_setScale(ASurfaceTransaction* transaction, | 
|  | 428 | ASurfaceControl* surface_control, float xScale, float yScale) | 
|  | 429 | __INTRODUCED_IN(31); | 
|  | 430 | /** | 
| Marin Shalamanov | 110c6bc | 2020-11-16 17:57:59 +0100 | [diff] [blame] | 431 | * Parameter for ASurfaceTransaction_setBufferTransparency(). | 
|  | 432 | */ | 
| Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 433 | enum { | 
|  | 434 | ASURFACE_TRANSACTION_TRANSPARENCY_TRANSPARENT = 0, | 
|  | 435 | ASURFACE_TRANSACTION_TRANSPARENCY_TRANSLUCENT = 1, | 
|  | 436 | ASURFACE_TRANSACTION_TRANSPARENCY_OPAQUE = 2, | 
|  | 437 | }; | 
|  | 438 | /** | 
|  | 439 | * Updates whether the content for the buffer associated with this surface is | 
|  | 440 | * completely opaque. If true, every pixel of content inside the buffer must be | 
|  | 441 | * opaque or visual errors can occur. | 
| Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 442 | * | 
|  | 443 | * Available since API level 29. | 
| Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 444 | */ | 
|  | 445 | void ASurfaceTransaction_setBufferTransparency(ASurfaceTransaction* transaction, | 
| Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 446 | ASurfaceControl* surface_control, | 
|  | 447 | int8_t transparency) | 
|  | 448 | __INTRODUCED_IN(29); | 
| Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 449 |  | 
|  | 450 | /** | 
|  | 451 | * Updates the region for the content on this surface updated in this | 
|  | 452 | * transaction. If unspecified, the complete surface is assumed to be damaged. | 
| Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 453 | * | 
|  | 454 | * Available since API level 29. | 
| Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 455 | */ | 
|  | 456 | void ASurfaceTransaction_setDamageRegion(ASurfaceTransaction* transaction, | 
|  | 457 | ASurfaceControl* surface_control, const ARect rects[], | 
|  | 458 | uint32_t count) __INTRODUCED_IN(29); | 
|  | 459 |  | 
| Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 460 | /** | 
|  | 461 | * Specifies a desiredPresentTime for the transaction. The framework will try to present | 
|  | 462 | * the transaction at or after the time specified. | 
|  | 463 | * | 
|  | 464 | * Transactions will not be presented until all of their acquire fences have signaled even if the | 
|  | 465 | * app requests an earlier present time. | 
|  | 466 | * | 
|  | 467 | * If an earlier transaction has a desired present time of x, and a later transaction has a desired | 
|  | 468 | * present time that is before x, the later transaction will not preempt the earlier transaction. | 
| Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 469 | * | 
|  | 470 | * Available since API level 29. | 
| Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 471 | */ | 
|  | 472 | void ASurfaceTransaction_setDesiredPresentTime(ASurfaceTransaction* transaction, | 
|  | 473 | int64_t desiredPresentTime) __INTRODUCED_IN(29); | 
|  | 474 |  | 
|  | 475 | /** | 
|  | 476 | * Sets the alpha for the buffer. It uses a premultiplied blending. | 
|  | 477 | * | 
| Marin Shalamanov | 110c6bc | 2020-11-16 17:57:59 +0100 | [diff] [blame] | 478 | * The \a alpha must be between 0.0 and 1.0. | 
| Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 479 | * | 
|  | 480 | * Available since API level 29. | 
| Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 481 | */ | 
|  | 482 | void ASurfaceTransaction_setBufferAlpha(ASurfaceTransaction* transaction, | 
|  | 483 | ASurfaceControl* surface_control, float alpha) | 
|  | 484 | __INTRODUCED_IN(29); | 
|  | 485 |  | 
| Marissa Wall | 3ff826c | 2019-02-07 11:58:25 -0800 | [diff] [blame] | 486 | /** | 
|  | 487 | * Sets the data space of the surface_control's buffers. | 
|  | 488 | * | 
|  | 489 | * If no data space is set, the surface control defaults to ADATASPACE_SRGB. | 
| Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 490 | * | 
|  | 491 | * Available since API level 29. | 
| Marissa Wall | 3ff826c | 2019-02-07 11:58:25 -0800 | [diff] [blame] | 492 | */ | 
|  | 493 | void ASurfaceTransaction_setBufferDataSpace(ASurfaceTransaction* transaction, | 
|  | 494 | ASurfaceControl* surface_control, ADataSpace data_space) | 
|  | 495 | __INTRODUCED_IN(29); | 
|  | 496 |  | 
| Marin Shalamanov | 110c6bc | 2020-11-16 17:57:59 +0100 | [diff] [blame] | 497 | /** | 
| Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 498 | * SMPTE ST 2086 "Mastering Display Color Volume" static metadata | 
|  | 499 | * | 
| Marin Shalamanov | 110c6bc | 2020-11-16 17:57:59 +0100 | [diff] [blame] | 500 | * When \a metadata is set to null, the framework does not use any smpte2086 metadata when rendering | 
| Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 501 | * the surface's buffer. | 
| Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 502 | * | 
|  | 503 | * Available since API level 29. | 
| Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 504 | */ | 
|  | 505 | void ASurfaceTransaction_setHdrMetadata_smpte2086(ASurfaceTransaction* transaction, | 
|  | 506 | ASurfaceControl* surface_control, | 
|  | 507 | struct AHdrMetadata_smpte2086* metadata) | 
|  | 508 | __INTRODUCED_IN(29); | 
|  | 509 |  | 
| Marin Shalamanov | 110c6bc | 2020-11-16 17:57:59 +0100 | [diff] [blame] | 510 | /** | 
| Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 511 | * Sets the CTA 861.3 "HDR Static Metadata Extension" static metadata on a surface. | 
|  | 512 | * | 
| Marin Shalamanov | 110c6bc | 2020-11-16 17:57:59 +0100 | [diff] [blame] | 513 | * When \a metadata is set to null, the framework does not use any cta861.3 metadata when rendering | 
| Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 514 | * the surface's buffer. | 
| Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 515 | * | 
|  | 516 | * Available since API level 29. | 
| Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 517 | */ | 
|  | 518 | void ASurfaceTransaction_setHdrMetadata_cta861_3(ASurfaceTransaction* transaction, | 
|  | 519 | ASurfaceControl* surface_control, | 
|  | 520 | struct AHdrMetadata_cta861_3* metadata) | 
|  | 521 | __INTRODUCED_IN(29); | 
|  | 522 |  | 
| Steven Thomas | 15b6f9c | 2020-03-26 13:44:28 -0700 | [diff] [blame] | 523 | /** | 
| Marin Shalamanov | c598677 | 2021-03-16 16:09:49 +0100 | [diff] [blame] | 524 | * Same as ASurfaceTransaction_setFrameRateWithChangeStrategy(transaction, surface_control, | 
|  | 525 | * frameRate, compatibility, ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS). | 
| Steven Thomas | 6d88a48 | 2019-12-02 22:00:47 -0800 | [diff] [blame] | 526 | * | 
| Marin Shalamanov | c598677 | 2021-03-16 16:09:49 +0100 | [diff] [blame] | 527 | * See ASurfaceTransaction_setFrameRateWithChangeStrategy(). | 
| Steven Thomas | 62a4cf8 | 2020-01-31 12:04:03 -0800 | [diff] [blame] | 528 | * | 
| Steven Thomas | 6d88a48 | 2019-12-02 22:00:47 -0800 | [diff] [blame] | 529 | * Available since API level 30. | 
|  | 530 | */ | 
|  | 531 | void ASurfaceTransaction_setFrameRate(ASurfaceTransaction* transaction, | 
| Steven Thomas | 62a4cf8 | 2020-01-31 12:04:03 -0800 | [diff] [blame] | 532 | ASurfaceControl* surface_control, float frameRate, | 
|  | 533 | int8_t compatibility) __INTRODUCED_IN(30); | 
| Steven Thomas | 6d88a48 | 2019-12-02 22:00:47 -0800 | [diff] [blame] | 534 |  | 
| Marin Shalamanov | 4608442 | 2020-10-13 12:33:42 +0200 | [diff] [blame] | 535 | /** | 
|  | 536 | * Sets the intended frame rate for \a surface_control. | 
|  | 537 | * | 
|  | 538 | * On devices that are capable of running the display at different refresh rates, the system may | 
|  | 539 | * choose a display refresh rate to better match this surface's frame rate. Usage of this API won't | 
|  | 540 | * directly affect the application's frame production pipeline. However, because the system may | 
|  | 541 | * change the display refresh rate, calls to this function may result in changes to Choreographer | 
|  | 542 | * callback timings, and changes to the time interval at which the system releases buffers back to | 
|  | 543 | * the application. | 
|  | 544 | * | 
| Marin Shalamanov | a308b9d | 2021-05-05 13:43:28 +0200 | [diff] [blame] | 545 | * You can register for changes in the refresh rate using | 
|  | 546 | * \a AChoreographer_registerRefreshRateCallback. | 
|  | 547 | * | 
| Marin Shalamanov | 4608442 | 2020-10-13 12:33:42 +0200 | [diff] [blame] | 548 | * \param frameRate is the intended frame rate of this surface, in frames per second. 0 is a special | 
|  | 549 | * value that indicates the app will accept the system's choice for the display frame rate, which is | 
|  | 550 | * the default behavior if this function isn't called. The frameRate param does <em>not</em> need to | 
|  | 551 | * be a valid refresh rate for this device's display - e.g., it's fine to pass 30fps to a device | 
|  | 552 | * that can only run the display at 60fps. | 
|  | 553 | * | 
|  | 554 | * \param compatibility The frame rate compatibility of this surface. The compatibility value may | 
|  | 555 | * influence the system's choice of display frame rate. To specify a compatibility use the | 
| Marin Shalamanov | 293ac2c | 2021-04-26 14:13:04 +0200 | [diff] [blame] | 556 | * ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_* enum. This parameter is ignored when frameRate is 0. | 
| Marin Shalamanov | 4608442 | 2020-10-13 12:33:42 +0200 | [diff] [blame] | 557 | * | 
| Marin Shalamanov | 293ac2c | 2021-04-26 14:13:04 +0200 | [diff] [blame] | 558 | * \param changeFrameRateStrategy Whether display refresh rate transitions caused by this | 
|  | 559 | * surface should be seamless. A seamless transition is one that doesn't have any visual | 
|  | 560 | * interruptions, such as a black screen for a second or two. See the | 
|  | 561 | * ANATIVEWINDOW_CHANGE_FRAME_RATE_* values. This parameter is ignored when frameRate is 0. | 
| Marin Shalamanov | 4608442 | 2020-10-13 12:33:42 +0200 | [diff] [blame] | 562 | * | 
|  | 563 | * Available since API level 31. | 
|  | 564 | */ | 
| Marin Shalamanov | c598677 | 2021-03-16 16:09:49 +0100 | [diff] [blame] | 565 | void ASurfaceTransaction_setFrameRateWithChangeStrategy(ASurfaceTransaction* transaction, | 
| Marin Shalamanov | 4608442 | 2020-10-13 12:33:42 +0200 | [diff] [blame] | 566 | ASurfaceControl* surface_control, float frameRate, | 
| Marin Shalamanov | c598677 | 2021-03-16 16:09:49 +0100 | [diff] [blame] | 567 | int8_t compatibility, int8_t changeFrameRateStrategy) | 
| Marin Shalamanov | 4608442 | 2020-10-13 12:33:42 +0200 | [diff] [blame] | 568 | __INTRODUCED_IN(31); | 
|  | 569 |  | 
| Robert Carr | f08168d | 2021-03-24 15:49:18 -0700 | [diff] [blame] | 570 | /** | 
|  | 571 | * Indicate whether to enable backpressure for buffer submission to a given SurfaceControl. | 
|  | 572 | * | 
|  | 573 | * By default backpressure is disabled, which means submitting a buffer prior to receiving | 
|  | 574 | * a callback for the previous buffer could lead to that buffer being "dropped". In cases | 
|  | 575 | * where you are selecting for latency, this may be a desirable behavior! We had a new buffer | 
|  | 576 | * ready, why shouldn't we show it? | 
|  | 577 | * | 
|  | 578 | * When back pressure is enabled, each buffer will be required to be presented | 
|  | 579 | * before it is released and the callback delivered | 
|  | 580 | * (absent the whole SurfaceControl being removed). | 
|  | 581 | * | 
|  | 582 | * Most apps are likely to have some sort of backpressure internally, e.g. you are | 
|  | 583 | * waiting on the callback from frame N-2 before starting frame N. In high refresh | 
|  | 584 | * rate scenarios there may not be much time between SurfaceFlinger completing frame | 
|  | 585 | * N-1 (and therefore releasing buffer N-2) and beginning frame N. This means | 
|  | 586 | * your app may not have enough time to respond in the callback. Using this flag | 
|  | 587 | * and pushing buffers earlier for server side queuing will be advantageous | 
|  | 588 | * in such cases. | 
|  | 589 | * | 
|  | 590 | * \param transaction The transaction in which to make the change. | 
|  | 591 | * \param surface_control The ASurfaceControl on which to control buffer backpressure behavior. | 
|  | 592 | * \param enableBackPressure Whether to enable back pressure. | 
|  | 593 | */ | 
|  | 594 | void ASurfaceTransaction_setEnableBackPressure(ASurfaceTransaction* transaction, | 
|  | 595 | ASurfaceControl* surface_control, | 
|  | 596 | bool enableBackPressure) | 
|  | 597 | __INTRODUCED_IN(31); | 
|  | 598 |  | 
| Rachel Lee | ed511ef | 2021-10-11 15:09:51 -0700 | [diff] [blame] | 599 | /** | 
| Rachel Lee | a4aba5d | 2022-08-23 14:37:59 -0700 | [diff] [blame] | 600 | * Sets the frame timeline to use in SurfaceFlinger. | 
| Rachel Lee | 1fb2ddc | 2022-01-12 14:33:07 -0800 | [diff] [blame] | 601 | * | 
| Rachel Lee | a4aba5d | 2022-08-23 14:37:59 -0700 | [diff] [blame] | 602 | * A frame timeline should be chosen based on the frame deadline the application | 
|  | 603 | * can meet when rendering the frame and the application's desired presentation time. | 
|  | 604 | * By setting a frame timeline, SurfaceFlinger tries to present the frame at the corresponding | 
|  | 605 | * expected presentation time. | 
| Rachel Lee | 1fb2ddc | 2022-01-12 14:33:07 -0800 | [diff] [blame] | 606 | * | 
|  | 607 | * To receive frame timelines, a callback must be posted to Choreographer using | 
| Rachel Lee | a4aba5d | 2022-08-23 14:37:59 -0700 | [diff] [blame] | 608 | * AChoreographer_postVsyncCallback(). The \c vsyncId can then be extracted from the | 
| Rachel Lee | 1fb2ddc | 2022-01-12 14:33:07 -0800 | [diff] [blame] | 609 | * callback payload using AChoreographerFrameCallbackData_getFrameTimelineVsyncId(). | 
| Rachel Lee | ed511ef | 2021-10-11 15:09:51 -0700 | [diff] [blame] | 610 | * | 
| Rachel Lee | a4aba5d | 2022-08-23 14:37:59 -0700 | [diff] [blame] | 611 | * \param vsyncId The vsync ID received from AChoreographer, setting the frame's presentation target | 
|  | 612 | * to the corresponding expected presentation time and deadline from the frame to be rendered. A | 
|  | 613 | * stale or invalid value will be ignored. | 
| Rachel Lee | ed511ef | 2021-10-11 15:09:51 -0700 | [diff] [blame] | 614 | */ | 
|  | 615 | void ASurfaceTransaction_setFrameTimeline(ASurfaceTransaction* transaction, | 
| Rachel Lee | 1fb2ddc | 2022-01-12 14:33:07 -0800 | [diff] [blame] | 616 | AVsyncId vsyncId) __INTRODUCED_IN(33); | 
| Rachel Lee | ed511ef | 2021-10-11 15:09:51 -0700 | [diff] [blame] | 617 |  | 
| Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 618 | __END_DECLS | 
|  | 619 |  | 
|  | 620 | #endif // ANDROID_SURFACE_CONTROL_H | 
| Marin Shalamanov | 574c58d | 2021-03-18 15:10:02 +0100 | [diff] [blame] | 621 |  | 
|  | 622 | /** @} */ |