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 | |
Marissa Wall | 3ff826c | 2019-02-07 11:58:25 -0800 | [diff] [blame] | 31 | #include <android/data_space.h> |
Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 32 | #include <android/hardware_buffer.h> |
Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 33 | #include <android/hdr_metadata.h> |
Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 34 | #include <android/native_window.h> |
| 35 | |
| 36 | __BEGIN_DECLS |
| 37 | |
Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 38 | struct ASurfaceControl; |
| 39 | |
| 40 | /** |
Elliott Hughes | 733bf99 | 2019-03-08 11:25:28 -0800 | [diff] [blame] | 41 | * 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] | 42 | * composition to the system compositor. ASurfaceControl represents a content node in |
Elliott Hughes | 733bf99 | 2019-03-08 11:25:28 -0800 | [diff] [blame] | 43 | * this hierarchy. |
Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 44 | */ |
| 45 | typedef struct ASurfaceControl ASurfaceControl; |
| 46 | |
Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 47 | /** |
Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 48 | * Creates an ASurfaceControl with either ANativeWindow or an ASurfaceControl as its parent. |
| 49 | * |debug_name| is a debug name associated with this surface. It can be used to |
| 50 | * identify this surface in the SurfaceFlinger's layer tree. It must not be |
| 51 | * null. |
| 52 | * |
| 53 | * The caller takes ownership of the ASurfaceControl returned and must release it |
| 54 | * using ASurfaceControl_release below. |
Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 55 | * |
| 56 | * Available since API level 29. |
Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 57 | */ |
| 58 | ASurfaceControl* ASurfaceControl_createFromWindow(ANativeWindow* parent, const char* debug_name) |
| 59 | __INTRODUCED_IN(29); |
| 60 | |
Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 61 | /** |
| 62 | * See ASurfaceControl_createFromWindow. |
| 63 | * |
| 64 | * Available since API level 29. |
| 65 | */ |
Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 66 | ASurfaceControl* ASurfaceControl_create(ASurfaceControl* parent, const char* debug_name) |
| 67 | __INTRODUCED_IN(29); |
| 68 | |
| 69 | /** |
Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 70 | * Releases the |surface_control| object. After releasing the ASurfaceControl the caller no longer |
| 71 | * has ownership of the AsurfaceControl. The surface and it's children may remain on display as long |
| 72 | * as their parent remains on display. |
Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 73 | * |
| 74 | * Available since API level 29. |
Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 75 | */ |
Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 76 | void ASurfaceControl_release(ASurfaceControl* surface_control) __INTRODUCED_IN(29); |
Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 77 | |
| 78 | struct ASurfaceTransaction; |
| 79 | |
| 80 | /** |
| 81 | * ASurfaceTransaction is a collection of updates to the surface tree that must |
| 82 | * be applied atomically. |
| 83 | */ |
| 84 | typedef struct ASurfaceTransaction ASurfaceTransaction; |
| 85 | |
| 86 | /** |
| 87 | * The caller takes ownership of the transaction and must release it using |
| 88 | * ASurfaceControl_delete below. |
Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 89 | * |
| 90 | * Available since API level 29. |
Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 91 | */ |
| 92 | ASurfaceTransaction* ASurfaceTransaction_create() __INTRODUCED_IN(29); |
| 93 | |
| 94 | /** |
| 95 | * Destroys the |transaction| object. |
Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 96 | * |
| 97 | * Available since API level 29. |
Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 98 | */ |
| 99 | void ASurfaceTransaction_delete(ASurfaceTransaction* transaction) __INTRODUCED_IN(29); |
| 100 | |
| 101 | /** |
| 102 | * Applies the updates accumulated in |transaction|. |
| 103 | * |
| 104 | * Note that the transaction is guaranteed to be applied atomically. The |
| 105 | * transactions which are applied on the same thread are also guaranteed to be |
| 106 | * applied in order. |
Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 107 | * |
| 108 | * Available since API level 29. |
Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 109 | */ |
| 110 | void ASurfaceTransaction_apply(ASurfaceTransaction* transaction) __INTRODUCED_IN(29); |
| 111 | |
| 112 | /** |
Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 113 | * An opaque handle returned during a callback that can be used to query general stats and stats for |
| 114 | * surfaces which were either removed or for which buffers were updated after this transaction was |
| 115 | * applied. |
| 116 | */ |
| 117 | typedef struct ASurfaceTransactionStats ASurfaceTransactionStats; |
| 118 | |
| 119 | /** |
Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 120 | * Since the transactions are applied asynchronously, the |
| 121 | * ASurfaceTransaction_OnComplete callback can be used to be notified when a frame |
| 122 | * including the updates in a transaction was presented. |
| 123 | * |
| 124 | * |context| is the optional context provided by the client that is passed into |
| 125 | * the callback. |
Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 126 | * |
Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 127 | * |stats| is an opaque handle that can be passed to ASurfaceTransactionStats functions to query |
Elliott Hughes | 733bf99 | 2019-03-08 11:25:28 -0800 | [diff] [blame] | 128 | * information about the transaction. The handle is only valid during the callback. |
Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 129 | * |
| 130 | * THREADING |
| 131 | * The transaction completed callback can be invoked on any thread. |
Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 132 | * |
| 133 | * Available since API level 29. |
Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 134 | */ |
Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 135 | typedef void (*ASurfaceTransaction_OnComplete)(void* context, ASurfaceTransactionStats* stats) |
| 136 | __INTRODUCED_IN(29); |
| 137 | |
| 138 | /** |
| 139 | * Returns the timestamp of when the frame was latched by the framework. Once a frame is |
| 140 | * latched by the framework, it is presented at the following hardware vsync. |
Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 141 | * |
| 142 | * Available since API level 29. |
Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 143 | */ |
| 144 | int64_t ASurfaceTransactionStats_getLatchTime(ASurfaceTransactionStats* surface_transaction_stats) |
| 145 | __INTRODUCED_IN(29); |
| 146 | |
| 147 | /** |
| 148 | * Returns a sync fence that signals when the transaction has been presented. |
| 149 | * 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] | 150 | * 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] | 151 | * |
| 152 | * Available since API level 29. |
Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 153 | */ |
| 154 | int ASurfaceTransactionStats_getPresentFenceFd(ASurfaceTransactionStats* surface_transaction_stats) |
| 155 | __INTRODUCED_IN(29); |
| 156 | |
| 157 | /** |
| 158 | * |outASurfaceControls| returns an array of ASurfaceControl pointers that were updated during the |
| 159 | * transaction. Stats for the surfaces can be queried through ASurfaceTransactionStats functions. |
| 160 | * When the client is done using the array, it must release it by calling |
| 161 | * ASurfaceTransactionStats_releaseASurfaceControls. |
| 162 | * |
Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 163 | * Available since API level 29. |
| 164 | * |
Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 165 | * |outASurfaceControlsSize| returns the size of the ASurfaceControls array. |
| 166 | */ |
| 167 | void ASurfaceTransactionStats_getASurfaceControls(ASurfaceTransactionStats* surface_transaction_stats, |
| 168 | ASurfaceControl*** outASurfaceControls, |
| 169 | size_t* outASurfaceControlsSize) |
| 170 | __INTRODUCED_IN(29); |
| 171 | /** |
| 172 | * Releases the array of ASurfaceControls that were returned by |
| 173 | * ASurfaceTransactionStats_getASurfaceControls. |
Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 174 | * |
| 175 | * Available since API level 29. |
Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 176 | */ |
| 177 | void ASurfaceTransactionStats_releaseASurfaceControls(ASurfaceControl** surface_controls) |
| 178 | __INTRODUCED_IN(29); |
| 179 | |
| 180 | /** |
| 181 | * Returns the timestamp of when the CURRENT buffer was acquired. A buffer is considered |
| 182 | * acquired when its acquire_fence_fd has signaled. A buffer cannot be latched or presented until |
| 183 | * 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] | 184 | * |
| 185 | * Available since API level 29. |
Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 186 | */ |
| 187 | int64_t ASurfaceTransactionStats_getAcquireTime(ASurfaceTransactionStats* surface_transaction_stats, |
| 188 | ASurfaceControl* surface_control) |
| 189 | __INTRODUCED_IN(29); |
| 190 | |
| 191 | /** |
| 192 | * The returns the fence used to signal the release of the PREVIOUS buffer set on |
| 193 | * this surface. If this fence is valid (>=0), the PREVIOUS buffer has not yet been released and the |
| 194 | * fence will signal when the PREVIOUS buffer has been released. If the fence is -1 , the PREVIOUS |
| 195 | * buffer is already released. The recipient of the callback takes ownership of the |
| 196 | * previousReleaseFenceFd and is responsible for closing it. |
| 197 | * |
| 198 | * Each time a buffer is set through ASurfaceTransaction_setBuffer()/_setCachedBuffer() on a |
| 199 | * transaction which is applied, the framework takes a ref on this buffer. The framework treats the |
| 200 | * addition of a buffer to a particular surface as a unique ref. When a transaction updates or |
| 201 | * removes a buffer from a surface, or removes the surface itself from the tree, this ref is |
| 202 | * guaranteed to be released in the OnComplete callback for this transaction. The |
| 203 | * ASurfaceControlStats provided in the callback for this surface may contain an optional fence |
| 204 | * which must be signaled before the ref is assumed to be released. |
| 205 | * |
| 206 | * The client must ensure that all pending refs on a buffer are released before attempting to reuse |
| 207 | * this buffer, otherwise synchronization errors may occur. |
Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 208 | * |
| 209 | * Available since API level 29. |
Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 210 | */ |
| 211 | int ASurfaceTransactionStats_getPreviousReleaseFenceFd( |
| 212 | ASurfaceTransactionStats* surface_transaction_stats, |
| 213 | ASurfaceControl* surface_control) |
| 214 | __INTRODUCED_IN(29); |
Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 215 | |
| 216 | /** |
| 217 | * Sets the callback that will be invoked when the updates from this transaction |
| 218 | * are presented. For details on the callback semantics and data, see the |
| 219 | * comments on the ASurfaceTransaction_OnComplete declaration above. |
Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 220 | * |
| 221 | * Available since API level 29. |
Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 222 | */ |
| 223 | void ASurfaceTransaction_setOnComplete(ASurfaceTransaction* transaction, void* context, |
| 224 | ASurfaceTransaction_OnComplete func) __INTRODUCED_IN(29); |
| 225 | |
Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 226 | /** |
| 227 | * Reparents the |surface_control| from its old parent to the |new_parent| surface control. |
| 228 | * Any children of the* reparented |surface_control| will remain children of the |surface_control|. |
| 229 | * |
| 230 | * The |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] | 231 | * |
| 232 | * Available since API level 29. |
Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 233 | */ |
| 234 | void ASurfaceTransaction_reparent(ASurfaceTransaction* transaction, |
| 235 | ASurfaceControl* surface_control, ASurfaceControl* new_parent) |
| 236 | __INTRODUCED_IN(29); |
| 237 | |
Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 238 | /* Parameter for ASurfaceTransaction_setVisibility */ |
| 239 | enum { |
| 240 | ASURFACE_TRANSACTION_VISIBILITY_HIDE = 0, |
| 241 | ASURFACE_TRANSACTION_VISIBILITY_SHOW = 1, |
| 242 | }; |
| 243 | /** |
| 244 | * Updates the visibility of |surface_control|. If show is set to |
| 245 | * ASURFACE_TRANSACTION_VISIBILITY_HIDE, the |surface_control| and all surfaces in its subtree will |
| 246 | * be hidden. |
Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 247 | * |
| 248 | * Available since API level 29. |
Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 249 | */ |
| 250 | void ASurfaceTransaction_setVisibility(ASurfaceTransaction* transaction, |
| 251 | ASurfaceControl* surface_control, int8_t visibility) |
| 252 | __INTRODUCED_IN(29); |
| 253 | |
| 254 | /** |
| 255 | * Updates the z order index for |surface_control|. Note that the z order for a surface |
| 256 | * is relative to other surfaces which are siblings of this surface. The behavior of sibilings with |
| 257 | * the same z order is undefined. |
| 258 | * |
| 259 | * 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] | 260 | * |
| 261 | * Available since API level 29. |
Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 262 | */ |
| 263 | void ASurfaceTransaction_setZOrder(ASurfaceTransaction* transaction, |
| 264 | ASurfaceControl* surface_control, int32_t z_order) |
| 265 | __INTRODUCED_IN(29); |
| 266 | |
| 267 | /** |
| 268 | * Updates the AHardwareBuffer displayed for |surface_control|. If not -1, the |
Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 269 | * 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] | 270 | * for the buffer is complete and the buffer can be safely read. |
| 271 | * |
Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 272 | * The frameworks takes ownership of the |acquire_fence_fd| passed and is responsible |
Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 273 | * for closing it. |
Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 274 | * |
| 275 | * Available since API level 29. |
Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 276 | */ |
| 277 | void ASurfaceTransaction_setBuffer(ASurfaceTransaction* transaction, |
| 278 | ASurfaceControl* surface_control, AHardwareBuffer* buffer, |
Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 279 | int acquire_fence_fd = -1) __INTRODUCED_IN(29); |
Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 280 | |
| 281 | /** |
Valerie Hau | ed54efa | 2019-01-11 20:03:14 -0800 | [diff] [blame] | 282 | * Updates the color for |surface_control|. This will make the background color for the |
| 283 | * ASurfaceControl visible in transparent regions of the surface. Colors |r|, |g|, |
| 284 | * and |b| must be within the range that is valid for |dataspace|. |dataspace| and |alpha| |
| 285 | * will be the dataspace and alpha set for the background color layer. |
Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 286 | * |
| 287 | * Available since API level 29. |
Valerie Hau | ed54efa | 2019-01-11 20:03:14 -0800 | [diff] [blame] | 288 | */ |
| 289 | void ASurfaceTransaction_setColor(ASurfaceTransaction* transaction, |
| 290 | ASurfaceControl* surface_control, float r, float g, float b, |
| 291 | float alpha, ADataSpace dataspace) |
| 292 | __INTRODUCED_IN(29); |
| 293 | |
| 294 | /** |
Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 295 | * |source| the sub-rect within the buffer's content to be rendered inside the surface's area |
| 296 | * The surface's source rect is clipped by the bounds of its current buffer. The source rect's width |
| 297 | * and height must be > 0. |
| 298 | * |
| 299 | * |destination| specifies the rect in the parent's space where this surface will be drawn. The post |
| 300 | * source rect bounds are scaled to fit the destination rect. The surface's destination rect is |
| 301 | * clipped by the bounds of its parent. The destination rect's width and height must be > 0. |
| 302 | * |
| 303 | * |transform| the transform applied after the source rect is applied to the buffer. This parameter |
| 304 | * should be set to 0 for no transform. To specify a transfrom use the NATIVE_WINDOW_TRANSFORM_* |
| 305 | * enum. |
Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 306 | * |
| 307 | * Available since API level 29. |
Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 308 | */ |
| 309 | void ASurfaceTransaction_setGeometry(ASurfaceTransaction* transaction, |
| 310 | ASurfaceControl* surface_control, const ARect& source, |
| 311 | const ARect& destination, int32_t transform) |
| 312 | __INTRODUCED_IN(29); |
| 313 | |
| 314 | |
| 315 | /* Parameter for ASurfaceTransaction_setBufferTransparency */ |
| 316 | enum { |
| 317 | ASURFACE_TRANSACTION_TRANSPARENCY_TRANSPARENT = 0, |
| 318 | ASURFACE_TRANSACTION_TRANSPARENCY_TRANSLUCENT = 1, |
| 319 | ASURFACE_TRANSACTION_TRANSPARENCY_OPAQUE = 2, |
| 320 | }; |
| 321 | /** |
| 322 | * Updates whether the content for the buffer associated with this surface is |
| 323 | * completely opaque. If true, every pixel of content inside the buffer must be |
| 324 | * opaque or visual errors can occur. |
Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 325 | * |
| 326 | * Available since API level 29. |
Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 327 | */ |
| 328 | void ASurfaceTransaction_setBufferTransparency(ASurfaceTransaction* transaction, |
Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 329 | ASurfaceControl* surface_control, |
| 330 | int8_t transparency) |
| 331 | __INTRODUCED_IN(29); |
Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 332 | |
| 333 | /** |
| 334 | * Updates the region for the content on this surface updated in this |
| 335 | * transaction. If unspecified, the complete surface is assumed to be damaged. |
Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 336 | * |
| 337 | * Available since API level 29. |
Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 338 | */ |
| 339 | void ASurfaceTransaction_setDamageRegion(ASurfaceTransaction* transaction, |
| 340 | ASurfaceControl* surface_control, const ARect rects[], |
| 341 | uint32_t count) __INTRODUCED_IN(29); |
| 342 | |
Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 343 | /** |
| 344 | * Specifies a desiredPresentTime for the transaction. The framework will try to present |
| 345 | * the transaction at or after the time specified. |
| 346 | * |
| 347 | * Transactions will not be presented until all of their acquire fences have signaled even if the |
| 348 | * app requests an earlier present time. |
| 349 | * |
| 350 | * If an earlier transaction has a desired present time of x, and a later transaction has a desired |
| 351 | * 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] | 352 | * |
| 353 | * Available since API level 29. |
Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 354 | */ |
| 355 | void ASurfaceTransaction_setDesiredPresentTime(ASurfaceTransaction* transaction, |
| 356 | int64_t desiredPresentTime) __INTRODUCED_IN(29); |
| 357 | |
| 358 | /** |
| 359 | * Sets the alpha for the buffer. It uses a premultiplied blending. |
| 360 | * |
| 361 | * The |alpha| must be between 0.0 and 1.0. |
Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 362 | * |
| 363 | * Available since API level 29. |
Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 364 | */ |
| 365 | void ASurfaceTransaction_setBufferAlpha(ASurfaceTransaction* transaction, |
| 366 | ASurfaceControl* surface_control, float alpha) |
| 367 | __INTRODUCED_IN(29); |
| 368 | |
Marissa Wall | 3ff826c | 2019-02-07 11:58:25 -0800 | [diff] [blame] | 369 | /** |
| 370 | * Sets the data space of the surface_control's buffers. |
| 371 | * |
| 372 | * 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] | 373 | * |
| 374 | * Available since API level 29. |
Marissa Wall | 3ff826c | 2019-02-07 11:58:25 -0800 | [diff] [blame] | 375 | */ |
| 376 | void ASurfaceTransaction_setBufferDataSpace(ASurfaceTransaction* transaction, |
| 377 | ASurfaceControl* surface_control, ADataSpace data_space) |
| 378 | __INTRODUCED_IN(29); |
| 379 | |
Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 380 | /* |
| 381 | * SMPTE ST 2086 "Mastering Display Color Volume" static metadata |
| 382 | * |
| 383 | * When |metadata| is set to null, the framework does not use any smpte2086 metadata when rendering |
| 384 | * the surface's buffer. |
Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 385 | * |
| 386 | * Available since API level 29. |
Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 387 | */ |
| 388 | void ASurfaceTransaction_setHdrMetadata_smpte2086(ASurfaceTransaction* transaction, |
| 389 | ASurfaceControl* surface_control, |
| 390 | struct AHdrMetadata_smpte2086* metadata) |
| 391 | __INTRODUCED_IN(29); |
| 392 | |
| 393 | /* |
| 394 | * Sets the CTA 861.3 "HDR Static Metadata Extension" static metadata on a surface. |
| 395 | * |
| 396 | * When |metadata| is set to null, the framework does not use any cta861.3 metadata when rendering |
| 397 | * the surface's buffer. |
Elliott Hughes | 3d70e53 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 398 | * |
| 399 | * Available since API level 29. |
Marissa Wall | 80d94ad | 2019-01-18 16:04:36 -0800 | [diff] [blame] | 400 | */ |
| 401 | void ASurfaceTransaction_setHdrMetadata_cta861_3(ASurfaceTransaction* transaction, |
| 402 | ASurfaceControl* surface_control, |
| 403 | struct AHdrMetadata_cta861_3* metadata) |
| 404 | __INTRODUCED_IN(29); |
| 405 | |
Steven Thomas | 15b6f9c | 2020-03-26 13:44:28 -0700 | [diff] [blame] | 406 | /** |
Steven Thomas | 6d88a48 | 2019-12-02 22:00:47 -0800 | [diff] [blame] | 407 | * Sets the intended frame rate for |surface_control|. |
| 408 | * |
| 409 | * On devices that are capable of running the display at different refresh rates, the system may |
| 410 | * choose a display refresh rate to better match this surface's frame rate. Usage of this API won't |
| 411 | * directly affect the application's frame production pipeline. However, because the system may |
| 412 | * change the display refresh rate, calls to this function may result in changes to Choreographer |
| 413 | * callback timings, and changes to the time interval at which the system releases buffers back to |
| 414 | * the application. |
| 415 | * |
Steven Thomas | 9bb0f07 | 2020-01-23 16:37:13 -0800 | [diff] [blame] | 416 | * |frameRate| is the intended frame rate of this surface, in frames per second. 0 is a special |
| 417 | * value that indicates the app will accept the system's choice for the display frame rate, which is |
Steven Thomas | 15b6f9c | 2020-03-26 13:44:28 -0700 | [diff] [blame] | 418 | * the default behavior if this function isn't called. The frameRate param does <em>not</em> need to |
| 419 | * be a valid refresh rate for this device's display - e.g., it's fine to pass 30fps to a device |
| 420 | * that can only run the display at 60fps. |
Steven Thomas | 6d88a48 | 2019-12-02 22:00:47 -0800 | [diff] [blame] | 421 | * |
Steven Thomas | 62a4cf8 | 2020-01-31 12:04:03 -0800 | [diff] [blame] | 422 | * |compatibility| The frame rate compatibility of this surface. The compatibility value may |
| 423 | * influence the system's choice of display frame rate. To specify a compatibility use the |
| 424 | * ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_* enum. |
| 425 | * |
Steven Thomas | 6d88a48 | 2019-12-02 22:00:47 -0800 | [diff] [blame] | 426 | * Available since API level 30. |
| 427 | */ |
| 428 | void ASurfaceTransaction_setFrameRate(ASurfaceTransaction* transaction, |
Steven Thomas | 62a4cf8 | 2020-01-31 12:04:03 -0800 | [diff] [blame] | 429 | ASurfaceControl* surface_control, float frameRate, |
| 430 | int8_t compatibility) __INTRODUCED_IN(30); |
Steven Thomas | 6d88a48 | 2019-12-02 22:00:47 -0800 | [diff] [blame] | 431 | |
Marissa Wall | 53da7e3 | 2018-09-25 15:59:38 -0700 | [diff] [blame] | 432 | __END_DECLS |
| 433 | |
| 434 | #endif // ANDROID_SURFACE_CONTROL_H |