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