1*38e8c45fSAndroid Build Coastguard Worker /* 2*38e8c45fSAndroid Build Coastguard Worker * Copyright 2018 The Android Open Source Project 3*38e8c45fSAndroid Build Coastguard Worker * 4*38e8c45fSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*38e8c45fSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*38e8c45fSAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*38e8c45fSAndroid Build Coastguard Worker * 8*38e8c45fSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*38e8c45fSAndroid Build Coastguard Worker * 10*38e8c45fSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*38e8c45fSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*38e8c45fSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*38e8c45fSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*38e8c45fSAndroid Build Coastguard Worker * limitations under the License. 15*38e8c45fSAndroid Build Coastguard Worker */ 16*38e8c45fSAndroid Build Coastguard Worker 17*38e8c45fSAndroid Build Coastguard Worker /** 18*38e8c45fSAndroid Build Coastguard Worker * @addtogroup NativeActivity Native Activity 19*38e8c45fSAndroid Build Coastguard Worker * @{ 20*38e8c45fSAndroid Build Coastguard Worker */ 21*38e8c45fSAndroid Build Coastguard Worker 22*38e8c45fSAndroid Build Coastguard Worker /** 23*38e8c45fSAndroid Build Coastguard Worker * @file surface_control.h 24*38e8c45fSAndroid Build Coastguard Worker */ 25*38e8c45fSAndroid Build Coastguard Worker 26*38e8c45fSAndroid Build Coastguard Worker #ifndef ANDROID_SURFACE_CONTROL_H 27*38e8c45fSAndroid Build Coastguard Worker #define ANDROID_SURFACE_CONTROL_H 28*38e8c45fSAndroid Build Coastguard Worker 29*38e8c45fSAndroid Build Coastguard Worker #include <sys/cdefs.h> 30*38e8c45fSAndroid Build Coastguard Worker 31*38e8c45fSAndroid Build Coastguard Worker #include <android/display_luts.h> 32*38e8c45fSAndroid Build Coastguard Worker #include <android/choreographer.h> 33*38e8c45fSAndroid Build Coastguard Worker #include <android/data_space.h> 34*38e8c45fSAndroid Build Coastguard Worker #include <android/hardware_buffer.h> 35*38e8c45fSAndroid Build Coastguard Worker #include <android/hdr_metadata.h> 36*38e8c45fSAndroid Build Coastguard Worker #include <android/native_window.h> 37*38e8c45fSAndroid Build Coastguard Worker 38*38e8c45fSAndroid Build Coastguard Worker __BEGIN_DECLS 39*38e8c45fSAndroid Build Coastguard Worker 40*38e8c45fSAndroid Build Coastguard Worker struct ASurfaceControl; 41*38e8c45fSAndroid Build Coastguard Worker 42*38e8c45fSAndroid Build Coastguard Worker /** 43*38e8c45fSAndroid Build Coastguard Worker * The SurfaceControl API can be used to provide a hierarchy of surfaces for 44*38e8c45fSAndroid Build Coastguard Worker * composition to the system compositor. ASurfaceControl represents a content node in 45*38e8c45fSAndroid Build Coastguard Worker * this hierarchy. 46*38e8c45fSAndroid Build Coastguard Worker */ 47*38e8c45fSAndroid Build Coastguard Worker typedef struct ASurfaceControl ASurfaceControl; 48*38e8c45fSAndroid Build Coastguard Worker 49*38e8c45fSAndroid Build Coastguard Worker /** 50*38e8c45fSAndroid Build Coastguard Worker * Creates an ASurfaceControl with either ANativeWindow or an ASurfaceControl as its parent. 51*38e8c45fSAndroid Build Coastguard Worker * \a debug_name is a debug name associated with this surface. It can be used to 52*38e8c45fSAndroid Build Coastguard Worker * identify this surface in the SurfaceFlinger's layer tree. It must not be 53*38e8c45fSAndroid Build Coastguard Worker * null. 54*38e8c45fSAndroid Build Coastguard Worker * 55*38e8c45fSAndroid Build Coastguard Worker * The caller takes ownership of the ASurfaceControl returned and must release it 56*38e8c45fSAndroid Build Coastguard Worker * using ASurfaceControl_release below. 57*38e8c45fSAndroid Build Coastguard Worker * 58*38e8c45fSAndroid Build Coastguard Worker * By default the \a ASurfaceControl will be visible and display any buffer submitted. In 59*38e8c45fSAndroid Build Coastguard Worker * addition, the default buffer submission control may release and not display all buffers 60*38e8c45fSAndroid Build Coastguard Worker * that are submitted before receiving a callback for the previous buffer. See 61*38e8c45fSAndroid Build Coastguard Worker * \a ASurfaceTransaction_setVisibility and \a ASurfaceTransaction_setEnableBackPressure to 62*38e8c45fSAndroid Build Coastguard Worker * change the default behaviors after creation. 63*38e8c45fSAndroid Build Coastguard Worker * 64*38e8c45fSAndroid Build Coastguard Worker * Available since API level 29. 65*38e8c45fSAndroid Build Coastguard Worker */ 66*38e8c45fSAndroid Build Coastguard Worker ASurfaceControl* _Nullable ASurfaceControl_createFromWindow(ANativeWindow* _Nonnull parent, 67*38e8c45fSAndroid Build Coastguard Worker const char* _Nonnull debug_name) 68*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(29); 69*38e8c45fSAndroid Build Coastguard Worker 70*38e8c45fSAndroid Build Coastguard Worker /** 71*38e8c45fSAndroid Build Coastguard Worker * See ASurfaceControl_createFromWindow. 72*38e8c45fSAndroid Build Coastguard Worker * 73*38e8c45fSAndroid Build Coastguard Worker * Available since API level 29. 74*38e8c45fSAndroid Build Coastguard Worker */ 75*38e8c45fSAndroid Build Coastguard Worker ASurfaceControl* _Nullable ASurfaceControl_create(ASurfaceControl* _Nonnull parent, 76*38e8c45fSAndroid Build Coastguard Worker const char* _Nonnull debug_name) 77*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(29); 78*38e8c45fSAndroid Build Coastguard Worker 79*38e8c45fSAndroid Build Coastguard Worker /** 80*38e8c45fSAndroid Build Coastguard Worker * Acquires a reference on the given ASurfaceControl object. This prevents the object 81*38e8c45fSAndroid Build Coastguard Worker * from being deleted until the reference is removed. 82*38e8c45fSAndroid Build Coastguard Worker * 83*38e8c45fSAndroid Build Coastguard Worker * To release the reference, use the ASurfaceControl_release function. 84*38e8c45fSAndroid Build Coastguard Worker * 85*38e8c45fSAndroid Build Coastguard Worker * Available since API level 31. 86*38e8c45fSAndroid Build Coastguard Worker */ 87*38e8c45fSAndroid Build Coastguard Worker void ASurfaceControl_acquire(ASurfaceControl* _Nonnull surface_control) __INTRODUCED_IN(31); 88*38e8c45fSAndroid Build Coastguard Worker 89*38e8c45fSAndroid Build Coastguard Worker /** 90*38e8c45fSAndroid Build Coastguard Worker * Removes a reference that was previously acquired with one of the following functions: 91*38e8c45fSAndroid Build Coastguard Worker * ASurfaceControl_createFromWindow 92*38e8c45fSAndroid Build Coastguard Worker * ASurfaceControl_create 93*38e8c45fSAndroid Build Coastguard Worker * ANativeWindow_acquire 94*38e8c45fSAndroid Build Coastguard Worker * The surface and its children may remain on display as long as their parent remains on display. 95*38e8c45fSAndroid Build Coastguard Worker * 96*38e8c45fSAndroid Build Coastguard Worker * Available since API level 29. 97*38e8c45fSAndroid Build Coastguard Worker */ 98*38e8c45fSAndroid Build Coastguard Worker void ASurfaceControl_release(ASurfaceControl* _Nonnull surface_control) __INTRODUCED_IN(29); 99*38e8c45fSAndroid Build Coastguard Worker 100*38e8c45fSAndroid Build Coastguard Worker struct ASurfaceTransaction; 101*38e8c45fSAndroid Build Coastguard Worker 102*38e8c45fSAndroid Build Coastguard Worker /** 103*38e8c45fSAndroid Build Coastguard Worker * ASurfaceTransaction is a collection of updates to the surface tree that must 104*38e8c45fSAndroid Build Coastguard Worker * be applied atomically. 105*38e8c45fSAndroid Build Coastguard Worker */ 106*38e8c45fSAndroid Build Coastguard Worker typedef struct ASurfaceTransaction ASurfaceTransaction; 107*38e8c45fSAndroid Build Coastguard Worker 108*38e8c45fSAndroid Build Coastguard Worker /** 109*38e8c45fSAndroid Build Coastguard Worker * The caller takes ownership of the transaction and must release it using 110*38e8c45fSAndroid Build Coastguard Worker * ASurfaceTransaction_delete() below. 111*38e8c45fSAndroid Build Coastguard Worker * 112*38e8c45fSAndroid Build Coastguard Worker * Available since API level 29. 113*38e8c45fSAndroid Build Coastguard Worker */ 114*38e8c45fSAndroid Build Coastguard Worker ASurfaceTransaction* _Nonnull ASurfaceTransaction_create() __INTRODUCED_IN(29); 115*38e8c45fSAndroid Build Coastguard Worker 116*38e8c45fSAndroid Build Coastguard Worker /** 117*38e8c45fSAndroid Build Coastguard Worker * Destroys the \a transaction object. 118*38e8c45fSAndroid Build Coastguard Worker * 119*38e8c45fSAndroid Build Coastguard Worker * Available since API level 29. 120*38e8c45fSAndroid Build Coastguard Worker */ 121*38e8c45fSAndroid Build Coastguard Worker void ASurfaceTransaction_delete(ASurfaceTransaction* _Nullable transaction) __INTRODUCED_IN(29); 122*38e8c45fSAndroid Build Coastguard Worker 123*38e8c45fSAndroid Build Coastguard Worker /** 124*38e8c45fSAndroid Build Coastguard Worker * Applies the updates accumulated in \a transaction. 125*38e8c45fSAndroid Build Coastguard Worker * 126*38e8c45fSAndroid Build Coastguard Worker * Note that the transaction is guaranteed to be applied atomically. The 127*38e8c45fSAndroid Build Coastguard Worker * transactions which are applied on the same thread are also guaranteed to be 128*38e8c45fSAndroid Build Coastguard Worker * applied in order. 129*38e8c45fSAndroid Build Coastguard Worker * 130*38e8c45fSAndroid Build Coastguard Worker * Available since API level 29. 131*38e8c45fSAndroid Build Coastguard Worker */ 132*38e8c45fSAndroid Build Coastguard Worker void ASurfaceTransaction_apply(ASurfaceTransaction* _Nonnull transaction) __INTRODUCED_IN(29); 133*38e8c45fSAndroid Build Coastguard Worker 134*38e8c45fSAndroid Build Coastguard Worker /** 135*38e8c45fSAndroid Build Coastguard Worker * An opaque handle returned during a callback that can be used to query general stats and stats for 136*38e8c45fSAndroid Build Coastguard Worker * surfaces which were either removed or for which buffers were updated after this transaction was 137*38e8c45fSAndroid Build Coastguard Worker * applied. 138*38e8c45fSAndroid Build Coastguard Worker */ 139*38e8c45fSAndroid Build Coastguard Worker typedef struct ASurfaceTransactionStats ASurfaceTransactionStats; 140*38e8c45fSAndroid Build Coastguard Worker 141*38e8c45fSAndroid Build Coastguard Worker /** 142*38e8c45fSAndroid Build Coastguard Worker * Since the transactions are applied asynchronously, the 143*38e8c45fSAndroid Build Coastguard Worker * ASurfaceTransaction_OnComplete callback can be used to be notified when a frame 144*38e8c45fSAndroid Build Coastguard Worker * including the updates in a transaction was presented. 145*38e8c45fSAndroid Build Coastguard Worker * 146*38e8c45fSAndroid Build Coastguard Worker * Buffers which are replaced or removed from the scene in the transaction invoking 147*38e8c45fSAndroid Build Coastguard Worker * this callback may be reused after this point. 148*38e8c45fSAndroid Build Coastguard Worker * 149*38e8c45fSAndroid Build Coastguard Worker * Starting with API level 36, prefer using \a ASurfaceTransaction_OnBufferRelease to listen 150*38e8c45fSAndroid Build Coastguard Worker * to when a buffer is ready to be reused. 151*38e8c45fSAndroid Build Coastguard Worker * 152*38e8c45fSAndroid Build Coastguard Worker * \param context Optional context provided by the client that is passed into 153*38e8c45fSAndroid Build Coastguard Worker * the callback. 154*38e8c45fSAndroid Build Coastguard Worker * 155*38e8c45fSAndroid Build Coastguard Worker * \param stats Opaque handle that can be passed to ASurfaceTransactionStats functions to query 156*38e8c45fSAndroid Build Coastguard Worker * information about the transaction. The handle is only valid during the callback. 157*38e8c45fSAndroid Build Coastguard Worker * 158*38e8c45fSAndroid Build Coastguard Worker * THREADING 159*38e8c45fSAndroid Build Coastguard Worker * The transaction completed callback can be invoked on any thread. 160*38e8c45fSAndroid Build Coastguard Worker */ 161*38e8c45fSAndroid Build Coastguard Worker typedef void (*ASurfaceTransaction_OnComplete)(void* _Null_unspecified context, 162*38e8c45fSAndroid Build Coastguard Worker ASurfaceTransactionStats* _Nonnull stats); 163*38e8c45fSAndroid Build Coastguard Worker 164*38e8c45fSAndroid Build Coastguard Worker /** 165*38e8c45fSAndroid Build Coastguard Worker * The ASurfaceTransaction_OnCommit callback is invoked when transaction is applied and the updates 166*38e8c45fSAndroid Build Coastguard Worker * are ready to be presented. This callback will be invoked before the 167*38e8c45fSAndroid Build Coastguard Worker * ASurfaceTransaction_OnComplete callback. 168*38e8c45fSAndroid Build Coastguard Worker * 169*38e8c45fSAndroid Build Coastguard Worker * This callback does not mean buffers have been released! It simply means that any new 170*38e8c45fSAndroid Build Coastguard Worker * transactions applied will not overwrite the transaction for which we are receiving 171*38e8c45fSAndroid Build Coastguard Worker * a callback and instead will be included in the next frame. If you are trying to avoid 172*38e8c45fSAndroid Build Coastguard Worker * dropping frames (overwriting transactions), and unable to use timestamps (Which provide 173*38e8c45fSAndroid Build Coastguard Worker * a more efficient solution), then this method provides a method to pace your transaction 174*38e8c45fSAndroid Build Coastguard Worker * application. 175*38e8c45fSAndroid Build Coastguard Worker * 176*38e8c45fSAndroid Build Coastguard Worker * \param context Optional context provided by the client that is passed into the callback. 177*38e8c45fSAndroid Build Coastguard Worker * 178*38e8c45fSAndroid Build Coastguard Worker * \param stats Opaque handle that can be passed to ASurfaceTransactionStats functions to query 179*38e8c45fSAndroid Build Coastguard Worker * information about the transaction. The handle is only valid during the callback. 180*38e8c45fSAndroid Build Coastguard Worker * Present and release fences are not available for this callback. Querying them using 181*38e8c45fSAndroid Build Coastguard Worker * ASurfaceTransactionStats_getPresentFenceFd and ASurfaceTransactionStats_getPreviousReleaseFenceFd 182*38e8c45fSAndroid Build Coastguard Worker * will result in failure. 183*38e8c45fSAndroid Build Coastguard Worker * 184*38e8c45fSAndroid Build Coastguard Worker * THREADING 185*38e8c45fSAndroid Build Coastguard Worker * The transaction committed callback can be invoked on any thread. 186*38e8c45fSAndroid Build Coastguard Worker */ 187*38e8c45fSAndroid Build Coastguard Worker typedef void (*ASurfaceTransaction_OnCommit)(void* _Null_unspecified context, 188*38e8c45fSAndroid Build Coastguard Worker ASurfaceTransactionStats* _Nonnull stats); 189*38e8c45fSAndroid Build Coastguard Worker 190*38e8c45fSAndroid Build Coastguard Worker /** 191*38e8c45fSAndroid Build Coastguard Worker * The ASurfaceTransaction_OnBufferRelease callback is invoked when a buffer that was passed in 192*38e8c45fSAndroid Build Coastguard Worker * ASurfaceTransaction_setBuffer is ready to be reused. 193*38e8c45fSAndroid Build Coastguard Worker * 194*38e8c45fSAndroid Build Coastguard Worker * This callback is guaranteed to be invoked if ASurfaceTransaction_setBuffer is called with a non 195*38e8c45fSAndroid Build Coastguard Worker * null buffer. If the buffer in the transaction is replaced via another call to 196*38e8c45fSAndroid Build Coastguard Worker * ASurfaceTransaction_setBuffer, the callback will be invoked immediately. Otherwise the callback 197*38e8c45fSAndroid Build Coastguard Worker * will be invoked before the ASurfaceTransaction_OnComplete callback after the buffer was 198*38e8c45fSAndroid Build Coastguard Worker * presented. 199*38e8c45fSAndroid Build Coastguard Worker * 200*38e8c45fSAndroid Build Coastguard Worker * If this callback is set, caller should not release the buffer using the 201*38e8c45fSAndroid Build Coastguard Worker * ASurfaceTransaction_OnComplete. 202*38e8c45fSAndroid Build Coastguard Worker * 203*38e8c45fSAndroid Build Coastguard Worker * \param context Optional context provided by the client that is passed into the callback. 204*38e8c45fSAndroid Build Coastguard Worker * 205*38e8c45fSAndroid Build Coastguard Worker * \param release_fence_fd Returns the fence file descriptor used to signal the release of buffer 206*38e8c45fSAndroid Build Coastguard Worker * associated with this callback. If this fence is valid (>=0), the buffer has not yet been released 207*38e8c45fSAndroid Build Coastguard Worker * and the fence will signal when the buffer has been released. If the fence is -1 , the buffer is 208*38e8c45fSAndroid Build Coastguard Worker * already released. The recipient of the callback takes ownership of the fence fd and is 209*38e8c45fSAndroid Build Coastguard Worker * responsible for closing it. 210*38e8c45fSAndroid Build Coastguard Worker * 211*38e8c45fSAndroid Build Coastguard Worker * THREADING 212*38e8c45fSAndroid Build Coastguard Worker * The callback can be invoked on any thread. 213*38e8c45fSAndroid Build Coastguard Worker */ 214*38e8c45fSAndroid Build Coastguard Worker typedef void (*ASurfaceTransaction_OnBufferRelease)(void* _Null_unspecified context, 215*38e8c45fSAndroid Build Coastguard Worker int release_fence_fd); 216*38e8c45fSAndroid Build Coastguard Worker 217*38e8c45fSAndroid Build Coastguard Worker /** 218*38e8c45fSAndroid Build Coastguard Worker * Returns the timestamp of when the frame was latched by the framework. Once a frame is 219*38e8c45fSAndroid Build Coastguard Worker * latched by the framework, it is presented at the following hardware vsync. 220*38e8c45fSAndroid Build Coastguard Worker * 221*38e8c45fSAndroid Build Coastguard Worker * Available since API level 29. 222*38e8c45fSAndroid Build Coastguard Worker */ 223*38e8c45fSAndroid Build Coastguard Worker int64_t ASurfaceTransactionStats_getLatchTime( 224*38e8c45fSAndroid Build Coastguard Worker ASurfaceTransactionStats* _Nonnull surface_transaction_stats) __INTRODUCED_IN(29); 225*38e8c45fSAndroid Build Coastguard Worker 226*38e8c45fSAndroid Build Coastguard Worker /** 227*38e8c45fSAndroid Build Coastguard Worker * Returns a sync fence that signals when the transaction has been presented. 228*38e8c45fSAndroid Build Coastguard Worker * The recipient of the callback takes ownership of the fence and is responsible for closing 229*38e8c45fSAndroid Build Coastguard Worker * it. If a device does not support present fences, a -1 will be returned. 230*38e8c45fSAndroid Build Coastguard Worker * 231*38e8c45fSAndroid Build Coastguard Worker * This query is not valid for ASurfaceTransaction_OnCommit callback. 232*38e8c45fSAndroid Build Coastguard Worker * 233*38e8c45fSAndroid Build Coastguard Worker * Available since API level 29. 234*38e8c45fSAndroid Build Coastguard Worker */ 235*38e8c45fSAndroid Build Coastguard Worker int ASurfaceTransactionStats_getPresentFenceFd( 236*38e8c45fSAndroid Build Coastguard Worker ASurfaceTransactionStats* _Nonnull surface_transaction_stats) __INTRODUCED_IN(29); 237*38e8c45fSAndroid Build Coastguard Worker 238*38e8c45fSAndroid Build Coastguard Worker /** 239*38e8c45fSAndroid Build Coastguard Worker * \a outASurfaceControls returns an array of ASurfaceControl pointers that were updated during the 240*38e8c45fSAndroid Build Coastguard Worker * transaction. Stats for the surfaces can be queried through ASurfaceTransactionStats functions. 241*38e8c45fSAndroid Build Coastguard Worker * When the client is done using the array, it must release it by calling 242*38e8c45fSAndroid Build Coastguard Worker * ASurfaceTransactionStats_releaseASurfaceControls. 243*38e8c45fSAndroid Build Coastguard Worker * 244*38e8c45fSAndroid Build Coastguard Worker * Available since API level 29. 245*38e8c45fSAndroid Build Coastguard Worker * 246*38e8c45fSAndroid Build Coastguard Worker * \a outASurfaceControlsSize returns the size of the ASurfaceControls array. 247*38e8c45fSAndroid Build Coastguard Worker */ 248*38e8c45fSAndroid Build Coastguard Worker void ASurfaceTransactionStats_getASurfaceControls( 249*38e8c45fSAndroid Build Coastguard Worker ASurfaceTransactionStats* _Nonnull surface_transaction_stats, 250*38e8c45fSAndroid Build Coastguard Worker ASurfaceControl* _Nullable* _Nullable* _Nonnull outASurfaceControls, 251*38e8c45fSAndroid Build Coastguard Worker size_t* _Nonnull outASurfaceControlsSize) __INTRODUCED_IN(29); 252*38e8c45fSAndroid Build Coastguard Worker /** 253*38e8c45fSAndroid Build Coastguard Worker * Releases the array of ASurfaceControls that were returned by 254*38e8c45fSAndroid Build Coastguard Worker * ASurfaceTransactionStats_getASurfaceControls(). 255*38e8c45fSAndroid Build Coastguard Worker * 256*38e8c45fSAndroid Build Coastguard Worker * Available since API level 29. 257*38e8c45fSAndroid Build Coastguard Worker */ 258*38e8c45fSAndroid Build Coastguard Worker void ASurfaceTransactionStats_releaseASurfaceControls( 259*38e8c45fSAndroid Build Coastguard Worker ASurfaceControl* _Nonnull* _Nonnull surface_controls) __INTRODUCED_IN(29); 260*38e8c45fSAndroid Build Coastguard Worker 261*38e8c45fSAndroid Build Coastguard Worker /** 262*38e8c45fSAndroid Build Coastguard Worker * Returns the timestamp of when the CURRENT buffer was acquired. A buffer is considered 263*38e8c45fSAndroid Build Coastguard Worker * acquired when its acquire_fence_fd has signaled. A buffer cannot be latched or presented until 264*38e8c45fSAndroid Build Coastguard Worker * it is acquired. If no acquire_fence_fd was provided, this timestamp will be set to -1. 265*38e8c45fSAndroid Build Coastguard Worker * 266*38e8c45fSAndroid Build Coastguard Worker * Available since API level 29. 267*38e8c45fSAndroid Build Coastguard Worker * 268*38e8c45fSAndroid Build Coastguard Worker * @deprecated This may return SIGNAL_PENDING because the stats can arrive before the acquire 269*38e8c45fSAndroid Build Coastguard Worker * fence has signaled, depending on internal timing differences. Therefore the caller should 270*38e8c45fSAndroid Build Coastguard Worker * use the acquire fence passed in to setBuffer and query the signal time. 271*38e8c45fSAndroid Build Coastguard Worker */ 272*38e8c45fSAndroid Build Coastguard Worker int64_t ASurfaceTransactionStats_getAcquireTime( 273*38e8c45fSAndroid Build Coastguard Worker ASurfaceTransactionStats* _Nonnull surface_transaction_stats, 274*38e8c45fSAndroid Build Coastguard Worker ASurfaceControl* _Nonnull surface_control) __INTRODUCED_IN(29); 275*38e8c45fSAndroid Build Coastguard Worker 276*38e8c45fSAndroid Build Coastguard Worker /** 277*38e8c45fSAndroid Build Coastguard Worker * The returns the fence used to signal the release of the PREVIOUS buffer set on 278*38e8c45fSAndroid Build Coastguard Worker * this surface. If this fence is valid (>=0), the PREVIOUS buffer has not yet been released and the 279*38e8c45fSAndroid Build Coastguard Worker * fence will signal when the PREVIOUS buffer has been released. If the fence is -1, the PREVIOUS 280*38e8c45fSAndroid Build Coastguard Worker * buffer is already released. The recipient of the callback takes ownership of the 281*38e8c45fSAndroid Build Coastguard Worker * previousReleaseFenceFd and is responsible for closing it. 282*38e8c45fSAndroid Build Coastguard Worker * 283*38e8c45fSAndroid Build Coastguard Worker * Each time a buffer is set through ASurfaceTransaction_setBuffer() on a transaction 284*38e8c45fSAndroid Build Coastguard Worker * which is applied, the framework takes a ref on this buffer. The framework treats the 285*38e8c45fSAndroid Build Coastguard Worker * addition of a buffer to a particular surface as a unique ref. When a transaction updates or 286*38e8c45fSAndroid Build Coastguard Worker * removes a buffer from a surface, or removes the surface itself from the tree, this ref is 287*38e8c45fSAndroid Build Coastguard Worker * guaranteed to be released in the OnComplete callback for this transaction. The 288*38e8c45fSAndroid Build Coastguard Worker * ASurfaceControlStats provided in the callback for this surface may contain an optional fence 289*38e8c45fSAndroid Build Coastguard Worker * which must be signaled before the ref is assumed to be released. 290*38e8c45fSAndroid Build Coastguard Worker * 291*38e8c45fSAndroid Build Coastguard Worker * The client must ensure that all pending refs on a buffer are released before attempting to reuse 292*38e8c45fSAndroid Build Coastguard Worker * this buffer, otherwise synchronization errors may occur. 293*38e8c45fSAndroid Build Coastguard Worker * 294*38e8c45fSAndroid Build Coastguard Worker * This query is not valid for ASurfaceTransaction_OnCommit callback. 295*38e8c45fSAndroid Build Coastguard Worker * 296*38e8c45fSAndroid Build Coastguard Worker * Available since API level 29. 297*38e8c45fSAndroid Build Coastguard Worker */ 298*38e8c45fSAndroid Build Coastguard Worker int ASurfaceTransactionStats_getPreviousReleaseFenceFd( 299*38e8c45fSAndroid Build Coastguard Worker ASurfaceTransactionStats* _Nonnull surface_transaction_stats, 300*38e8c45fSAndroid Build Coastguard Worker ASurfaceControl* _Nonnull surface_control) __INTRODUCED_IN(29); 301*38e8c45fSAndroid Build Coastguard Worker 302*38e8c45fSAndroid Build Coastguard Worker /** 303*38e8c45fSAndroid Build Coastguard Worker * Sets the callback that will be invoked when the updates from this transaction 304*38e8c45fSAndroid Build Coastguard Worker * are presented. For details on the callback semantics and data, see the 305*38e8c45fSAndroid Build Coastguard Worker * comments on the ASurfaceTransaction_OnComplete declaration above. 306*38e8c45fSAndroid Build Coastguard Worker * 307*38e8c45fSAndroid Build Coastguard Worker * Available since API level 29. 308*38e8c45fSAndroid Build Coastguard Worker */ 309*38e8c45fSAndroid Build Coastguard Worker void ASurfaceTransaction_setOnComplete(ASurfaceTransaction* _Nonnull transaction, 310*38e8c45fSAndroid Build Coastguard Worker void* _Null_unspecified context, 311*38e8c45fSAndroid Build Coastguard Worker ASurfaceTransaction_OnComplete _Nonnull func) 312*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(29); 313*38e8c45fSAndroid Build Coastguard Worker 314*38e8c45fSAndroid Build Coastguard Worker /** 315*38e8c45fSAndroid Build Coastguard Worker * Sets the callback that will be invoked when the updates from this transaction are applied and are 316*38e8c45fSAndroid Build Coastguard Worker * ready to be presented. This callback will be invoked before the ASurfaceTransaction_OnComplete 317*38e8c45fSAndroid Build Coastguard Worker * callback. 318*38e8c45fSAndroid Build Coastguard Worker * 319*38e8c45fSAndroid Build Coastguard Worker * Available since API level 31. 320*38e8c45fSAndroid Build Coastguard Worker */ 321*38e8c45fSAndroid Build Coastguard Worker void ASurfaceTransaction_setOnCommit(ASurfaceTransaction* _Nonnull transaction, 322*38e8c45fSAndroid Build Coastguard Worker void* _Null_unspecified context, 323*38e8c45fSAndroid Build Coastguard Worker ASurfaceTransaction_OnCommit _Nonnull func) 324*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(31); 325*38e8c45fSAndroid Build Coastguard Worker 326*38e8c45fSAndroid Build Coastguard Worker /** 327*38e8c45fSAndroid Build Coastguard Worker * Reparents the \a surface_control from its old parent to the \a new_parent surface control. 328*38e8c45fSAndroid Build Coastguard Worker * Any children of the reparented \a surface_control will remain children of the \a surface_control. 329*38e8c45fSAndroid Build Coastguard Worker * 330*38e8c45fSAndroid Build Coastguard Worker * The \a new_parent can be null. Surface controls with a null parent do not appear on the display. 331*38e8c45fSAndroid Build Coastguard Worker * 332*38e8c45fSAndroid Build Coastguard Worker * Available since API level 29. 333*38e8c45fSAndroid Build Coastguard Worker */ 334*38e8c45fSAndroid Build Coastguard Worker void ASurfaceTransaction_reparent(ASurfaceTransaction* _Nonnull transaction, 335*38e8c45fSAndroid Build Coastguard Worker ASurfaceControl* _Nonnull surface_control, 336*38e8c45fSAndroid Build Coastguard Worker ASurfaceControl* _Nullable new_parent) __INTRODUCED_IN(29); 337*38e8c45fSAndroid Build Coastguard Worker 338*38e8c45fSAndroid Build Coastguard Worker /** 339*38e8c45fSAndroid Build Coastguard Worker * Parameter for ASurfaceTransaction_setVisibility(). 340*38e8c45fSAndroid Build Coastguard Worker */ 341*38e8c45fSAndroid Build Coastguard Worker enum ASurfaceTransactionVisibility : int8_t { 342*38e8c45fSAndroid Build Coastguard Worker ASURFACE_TRANSACTION_VISIBILITY_HIDE = 0, 343*38e8c45fSAndroid Build Coastguard Worker ASURFACE_TRANSACTION_VISIBILITY_SHOW = 1, 344*38e8c45fSAndroid Build Coastguard Worker }; 345*38e8c45fSAndroid Build Coastguard Worker /** 346*38e8c45fSAndroid Build Coastguard Worker * Updates the visibility of \a surface_control. If show is set to 347*38e8c45fSAndroid Build Coastguard Worker * ASURFACE_TRANSACTION_VISIBILITY_HIDE, the \a surface_control and all surfaces in its subtree will 348*38e8c45fSAndroid Build Coastguard Worker * be hidden. 349*38e8c45fSAndroid Build Coastguard Worker * 350*38e8c45fSAndroid Build Coastguard Worker * Available since API level 29. 351*38e8c45fSAndroid Build Coastguard Worker */ 352*38e8c45fSAndroid Build Coastguard Worker void ASurfaceTransaction_setVisibility(ASurfaceTransaction* _Nonnull transaction, 353*38e8c45fSAndroid Build Coastguard Worker ASurfaceControl* _Nonnull surface_control, 354*38e8c45fSAndroid Build Coastguard Worker enum ASurfaceTransactionVisibility visibility) 355*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(29); 356*38e8c45fSAndroid Build Coastguard Worker 357*38e8c45fSAndroid Build Coastguard Worker /** 358*38e8c45fSAndroid Build Coastguard Worker * Updates the z order index for \a surface_control. Note that the z order for a surface 359*38e8c45fSAndroid Build Coastguard Worker * is relative to other surfaces which are siblings of this surface. The behavior of sibilings with 360*38e8c45fSAndroid Build Coastguard Worker * the same z order is undefined. 361*38e8c45fSAndroid Build Coastguard Worker * 362*38e8c45fSAndroid Build Coastguard Worker * Z orders may be from MIN_INT32 to MAX_INT32. A layer's default z order index is 0. 363*38e8c45fSAndroid Build Coastguard Worker * 364*38e8c45fSAndroid Build Coastguard Worker * Available since API level 29. 365*38e8c45fSAndroid Build Coastguard Worker */ 366*38e8c45fSAndroid Build Coastguard Worker void ASurfaceTransaction_setZOrder(ASurfaceTransaction* _Nonnull transaction, 367*38e8c45fSAndroid Build Coastguard Worker ASurfaceControl* _Nonnull surface_control, int32_t z_order) 368*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(29); 369*38e8c45fSAndroid Build Coastguard Worker 370*38e8c45fSAndroid Build Coastguard Worker /** 371*38e8c45fSAndroid Build Coastguard Worker * Updates the AHardwareBuffer displayed for \a surface_control. If not -1, the 372*38e8c45fSAndroid Build Coastguard Worker * acquire_fence_fd should be a file descriptor that is signaled when all pending work 373*38e8c45fSAndroid Build Coastguard Worker * for the buffer is complete and the buffer can be safely read. 374*38e8c45fSAndroid Build Coastguard Worker * 375*38e8c45fSAndroid Build Coastguard Worker * The frameworks takes ownership of the \a acquire_fence_fd passed and is responsible 376*38e8c45fSAndroid Build Coastguard Worker * for closing it. 377*38e8c45fSAndroid Build Coastguard Worker * 378*38e8c45fSAndroid Build Coastguard Worker * Note that the buffer must be allocated with AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE 379*38e8c45fSAndroid Build Coastguard Worker * as the surface control might be composited using the GPU. 380*38e8c45fSAndroid Build Coastguard Worker * 381*38e8c45fSAndroid Build Coastguard Worker * Starting with API level 36, prefer using \a ASurfaceTransaction_setBufferWithRelease to 382*38e8c45fSAndroid Build Coastguard Worker * set a buffer and a callback which will be invoked when the buffer is ready to be reused. 383*38e8c45fSAndroid Build Coastguard Worker * 384*38e8c45fSAndroid Build Coastguard Worker * Available since API level 29. 385*38e8c45fSAndroid Build Coastguard Worker */ 386*38e8c45fSAndroid Build Coastguard Worker void ASurfaceTransaction_setBuffer(ASurfaceTransaction* _Nonnull transaction, 387*38e8c45fSAndroid Build Coastguard Worker ASurfaceControl* _Nonnull surface_control, 388*38e8c45fSAndroid Build Coastguard Worker AHardwareBuffer* _Nonnull buffer, int acquire_fence_fd) 389*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(29); 390*38e8c45fSAndroid Build Coastguard Worker 391*38e8c45fSAndroid Build Coastguard Worker /** 392*38e8c45fSAndroid Build Coastguard Worker * Updates the AHardwareBuffer displayed for \a surface_control. If not -1, the 393*38e8c45fSAndroid Build Coastguard Worker * acquire_fence_fd should be a file descriptor that is signaled when all pending work 394*38e8c45fSAndroid Build Coastguard Worker * for the buffer is complete and the buffer can be safely read. 395*38e8c45fSAndroid Build Coastguard Worker * 396*38e8c45fSAndroid Build Coastguard Worker * The frameworks takes ownership of the \a acquire_fence_fd passed and is responsible 397*38e8c45fSAndroid Build Coastguard Worker * for closing it. 398*38e8c45fSAndroid Build Coastguard Worker * 399*38e8c45fSAndroid Build Coastguard Worker * Note that the buffer must be allocated with AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE 400*38e8c45fSAndroid Build Coastguard Worker * as the surface control might be composited using the GPU. 401*38e8c45fSAndroid Build Coastguard Worker * 402*38e8c45fSAndroid Build Coastguard Worker * When the buffer is ready to be reused, the ASurfaceTransaction_OnBufferRelease 403*38e8c45fSAndroid Build Coastguard Worker * callback will be invoked. If the buffer is null, the callback will not be invoked. 404*38e8c45fSAndroid Build Coastguard Worker * 405*38e8c45fSAndroid Build Coastguard Worker * Available since API level 36. 406*38e8c45fSAndroid Build Coastguard Worker */ 407*38e8c45fSAndroid Build Coastguard Worker void ASurfaceTransaction_setBufferWithRelease(ASurfaceTransaction* _Nonnull transaction, 408*38e8c45fSAndroid Build Coastguard Worker ASurfaceControl* _Nonnull surface_control, 409*38e8c45fSAndroid Build Coastguard Worker AHardwareBuffer* _Nonnull buffer, 410*38e8c45fSAndroid Build Coastguard Worker int acquire_fence_fd, void* _Null_unspecified context, 411*38e8c45fSAndroid Build Coastguard Worker ASurfaceTransaction_OnBufferRelease _Nonnull func) 412*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(36); 413*38e8c45fSAndroid Build Coastguard Worker 414*38e8c45fSAndroid Build Coastguard Worker /** 415*38e8c45fSAndroid Build Coastguard Worker * Updates the color for \a surface_control. This will make the background color for the 416*38e8c45fSAndroid Build Coastguard Worker * ASurfaceControl visible in transparent regions of the surface. Colors \a r, \a g, 417*38e8c45fSAndroid Build Coastguard Worker * and \a b must be within the range that is valid for \a dataspace. \a dataspace and \a alpha 418*38e8c45fSAndroid Build Coastguard Worker * will be the dataspace and alpha set for the background color layer. 419*38e8c45fSAndroid Build Coastguard Worker * 420*38e8c45fSAndroid Build Coastguard Worker * Available since API level 29. 421*38e8c45fSAndroid Build Coastguard Worker */ 422*38e8c45fSAndroid Build Coastguard Worker void ASurfaceTransaction_setColor(ASurfaceTransaction* _Nonnull transaction, 423*38e8c45fSAndroid Build Coastguard Worker ASurfaceControl* _Nonnull surface_control, float r, float g, 424*38e8c45fSAndroid Build Coastguard Worker float b, float alpha, enum ADataSpace dataspace) 425*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(29); 426*38e8c45fSAndroid Build Coastguard Worker 427*38e8c45fSAndroid Build Coastguard Worker // These APIs (setGeometry and setCrop) were originally written in a 428*38e8c45fSAndroid Build Coastguard Worker // C-incompatible form using references instead of pointers, and the OS shipped 429*38e8c45fSAndroid Build Coastguard Worker // that version for years before it was noticed. Fortunately the compiled code 430*38e8c45fSAndroid Build Coastguard Worker // for callers is the same regardless of whether it's a pointer or a reference, 431*38e8c45fSAndroid Build Coastguard Worker // so we can declare this as a nonnull pointer for C and keep the existing C++ 432*38e8c45fSAndroid Build Coastguard Worker // decl and definition. 433*38e8c45fSAndroid Build Coastguard Worker // 434*38e8c45fSAndroid Build Coastguard Worker // We could alternatively change the decl and the definition to both be a 435*38e8c45fSAndroid Build Coastguard Worker // pointer (with an inline definition using references to preserve source compat 436*38e8c45fSAndroid Build Coastguard Worker // for existing C++ callers), but that requires changing the definition of an 437*38e8c45fSAndroid Build Coastguard Worker // API that has been in the OS for years. It's theoretically a safe change, but 438*38e8c45fSAndroid Build Coastguard Worker // without being able to prove it that's a very big risk to take. By keeping the 439*38e8c45fSAndroid Build Coastguard Worker // C-compatibility hack in the header, we can be sure that we haven't changed 440*38e8c45fSAndroid Build Coastguard Worker // anything for existing callers. By definition there were no C users of the 441*38e8c45fSAndroid Build Coastguard Worker // reference-based decl; if there were any C callers of the API at all, they were 442*38e8c45fSAndroid Build Coastguard Worker // using the same workaround that is now used below. 443*38e8c45fSAndroid Build Coastguard Worker // 444*38e8c45fSAndroid Build Coastguard Worker // Even if this workaround turns out to not work for C, there's no permanent 445*38e8c45fSAndroid Build Coastguard Worker // damage done to the platform (unlike if we were to change the definition). At 446*38e8c45fSAndroid Build Coastguard Worker // worst it continues to work for C++ (since the preprocessed header as seen by 447*38e8c45fSAndroid Build Coastguard Worker // C++ hasn't changed, nor has the definition) and continues to not work for C. 448*38e8c45fSAndroid Build Coastguard Worker 449*38e8c45fSAndroid Build Coastguard Worker /** 450*38e8c45fSAndroid Build Coastguard Worker * \param source The sub-rect within the buffer's content to be rendered inside the surface's area 451*38e8c45fSAndroid Build Coastguard Worker * The surface's source rect is clipped by the bounds of its current buffer. The source rect's width 452*38e8c45fSAndroid Build Coastguard Worker * and height must be > 0. 453*38e8c45fSAndroid Build Coastguard Worker * 454*38e8c45fSAndroid Build Coastguard Worker * \param destination Specifies the rect in the parent's space where this surface will be drawn. The 455*38e8c45fSAndroid Build Coastguard Worker * post source rect bounds are scaled to fit the destination rect. The surface's destination rect is 456*38e8c45fSAndroid Build Coastguard Worker * clipped by the bounds of its parent. The destination rect's width and height must be > 0. 457*38e8c45fSAndroid Build Coastguard Worker * 458*38e8c45fSAndroid Build Coastguard Worker * \param transform The transform applied after the source rect is applied to the buffer. This 459*38e8c45fSAndroid Build Coastguard Worker * parameter should be set to 0 for no transform. To specify a transform use the 460*38e8c45fSAndroid Build Coastguard Worker * NATIVE_WINDOW_TRANSFORM_* enum. 461*38e8c45fSAndroid Build Coastguard Worker * 462*38e8c45fSAndroid Build Coastguard Worker * Available since API level 29. 463*38e8c45fSAndroid Build Coastguard Worker * 464*38e8c45fSAndroid Build Coastguard Worker * @deprecated Use setCrop, setPosition, setBufferTransform, and setScale instead. Those functions 465*38e8c45fSAndroid Build Coastguard Worker * provide well defined behavior and allows for more control by the apps. It also allows the caller 466*38e8c45fSAndroid Build Coastguard Worker * to set different properties at different times, instead of having to specify all the desired 467*38e8c45fSAndroid Build Coastguard Worker * properties at once. 468*38e8c45fSAndroid Build Coastguard Worker */ 469*38e8c45fSAndroid Build Coastguard Worker void ASurfaceTransaction_setGeometry(ASurfaceTransaction* _Nonnull transaction, 470*38e8c45fSAndroid Build Coastguard Worker ASurfaceControl* _Nonnull surface_control, 471*38e8c45fSAndroid Build Coastguard Worker #if defined(__cplusplus) 472*38e8c45fSAndroid Build Coastguard Worker const ARect& source, const ARect& destination, 473*38e8c45fSAndroid Build Coastguard Worker #else 474*38e8c45fSAndroid Build Coastguard Worker const ARect* _Nonnull source, 475*38e8c45fSAndroid Build Coastguard Worker const ARect* _Nonnull destination, 476*38e8c45fSAndroid Build Coastguard Worker #endif 477*38e8c45fSAndroid Build Coastguard Worker int32_t transform) __INTRODUCED_IN(29); 478*38e8c45fSAndroid Build Coastguard Worker 479*38e8c45fSAndroid Build Coastguard Worker /** 480*38e8c45fSAndroid Build Coastguard Worker * Bounds the surface and its children to the bounds specified. The crop and buffer size will be 481*38e8c45fSAndroid Build Coastguard Worker * used to determine the bounds of the surface. If no crop is specified and the surface has no 482*38e8c45fSAndroid Build Coastguard Worker * buffer, the surface bounds is only constrained by the size of its parent bounds. 483*38e8c45fSAndroid Build Coastguard Worker * 484*38e8c45fSAndroid Build Coastguard Worker * \param crop The bounds of the crop to apply. 485*38e8c45fSAndroid Build Coastguard Worker * 486*38e8c45fSAndroid Build Coastguard Worker * Available since API level 31. 487*38e8c45fSAndroid Build Coastguard Worker */ 488*38e8c45fSAndroid Build Coastguard Worker void ASurfaceTransaction_setCrop(ASurfaceTransaction* _Nonnull transaction, 489*38e8c45fSAndroid Build Coastguard Worker ASurfaceControl* _Nonnull surface_control, 490*38e8c45fSAndroid Build Coastguard Worker #if defined(__cplusplus) 491*38e8c45fSAndroid Build Coastguard Worker const ARect& crop) 492*38e8c45fSAndroid Build Coastguard Worker #else 493*38e8c45fSAndroid Build Coastguard Worker const ARect* _Nonnull crop) 494*38e8c45fSAndroid Build Coastguard Worker #endif 495*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(31); 496*38e8c45fSAndroid Build Coastguard Worker 497*38e8c45fSAndroid Build Coastguard Worker /** 498*38e8c45fSAndroid Build Coastguard Worker * Specifies the position in the parent's space where the surface will be drawn. 499*38e8c45fSAndroid Build Coastguard Worker * 500*38e8c45fSAndroid Build Coastguard Worker * \param x The x position to render the surface. 501*38e8c45fSAndroid Build Coastguard Worker * \param y The y position to render the surface. 502*38e8c45fSAndroid Build Coastguard Worker * 503*38e8c45fSAndroid Build Coastguard Worker * Available since API level 31. 504*38e8c45fSAndroid Build Coastguard Worker */ 505*38e8c45fSAndroid Build Coastguard Worker void ASurfaceTransaction_setPosition(ASurfaceTransaction* _Nonnull transaction, 506*38e8c45fSAndroid Build Coastguard Worker ASurfaceControl* _Nonnull surface_control, int32_t x, 507*38e8c45fSAndroid Build Coastguard Worker int32_t y) __INTRODUCED_IN(31); 508*38e8c45fSAndroid Build Coastguard Worker 509*38e8c45fSAndroid Build Coastguard Worker /** 510*38e8c45fSAndroid Build Coastguard Worker * \param transform The transform applied after the source rect is applied to the buffer. This 511*38e8c45fSAndroid Build Coastguard Worker * parameter should be set to 0 for no transform. To specify a transform use the 512*38e8c45fSAndroid Build Coastguard Worker * NATIVE_WINDOW_TRANSFORM_* enum. 513*38e8c45fSAndroid Build Coastguard Worker * 514*38e8c45fSAndroid Build Coastguard Worker * Available since API level 31. 515*38e8c45fSAndroid Build Coastguard Worker */ 516*38e8c45fSAndroid Build Coastguard Worker void ASurfaceTransaction_setBufferTransform(ASurfaceTransaction* _Nonnull transaction, 517*38e8c45fSAndroid Build Coastguard Worker ASurfaceControl* _Nonnull surface_control, 518*38e8c45fSAndroid Build Coastguard Worker int32_t transform) __INTRODUCED_IN(31); 519*38e8c45fSAndroid Build Coastguard Worker 520*38e8c45fSAndroid Build Coastguard Worker /** 521*38e8c45fSAndroid Build Coastguard Worker * Sets an x and y scale of a surface with (0, 0) as the centerpoint of the scale. 522*38e8c45fSAndroid Build Coastguard Worker * 523*38e8c45fSAndroid Build Coastguard Worker * \param xScale The scale in the x direction. Must be greater than 0. 524*38e8c45fSAndroid Build Coastguard Worker * \param yScale The scale in the y direction. Must be greater than 0. 525*38e8c45fSAndroid Build Coastguard Worker * 526*38e8c45fSAndroid Build Coastguard Worker * Available since API level 31. 527*38e8c45fSAndroid Build Coastguard Worker */ 528*38e8c45fSAndroid Build Coastguard Worker void ASurfaceTransaction_setScale(ASurfaceTransaction* _Nonnull transaction, 529*38e8c45fSAndroid Build Coastguard Worker ASurfaceControl* _Nonnull surface_control, float xScale, 530*38e8c45fSAndroid Build Coastguard Worker float yScale) __INTRODUCED_IN(31); 531*38e8c45fSAndroid Build Coastguard Worker /** 532*38e8c45fSAndroid Build Coastguard Worker * Parameter for ASurfaceTransaction_setBufferTransparency(). 533*38e8c45fSAndroid Build Coastguard Worker */ 534*38e8c45fSAndroid Build Coastguard Worker enum ASurfaceTransactionTransparency : int8_t { 535*38e8c45fSAndroid Build Coastguard Worker ASURFACE_TRANSACTION_TRANSPARENCY_TRANSPARENT = 0, 536*38e8c45fSAndroid Build Coastguard Worker ASURFACE_TRANSACTION_TRANSPARENCY_TRANSLUCENT = 1, 537*38e8c45fSAndroid Build Coastguard Worker ASURFACE_TRANSACTION_TRANSPARENCY_OPAQUE = 2, 538*38e8c45fSAndroid Build Coastguard Worker }; 539*38e8c45fSAndroid Build Coastguard Worker /** 540*38e8c45fSAndroid Build Coastguard Worker * Updates whether the content for the buffer associated with this surface is 541*38e8c45fSAndroid Build Coastguard Worker * completely opaque. If true, every pixel of content inside the buffer must be 542*38e8c45fSAndroid Build Coastguard Worker * opaque or visual errors can occur. 543*38e8c45fSAndroid Build Coastguard Worker * 544*38e8c45fSAndroid Build Coastguard Worker * Available since API level 29. 545*38e8c45fSAndroid Build Coastguard Worker */ 546*38e8c45fSAndroid Build Coastguard Worker void ASurfaceTransaction_setBufferTransparency(ASurfaceTransaction* _Nonnull transaction, 547*38e8c45fSAndroid Build Coastguard Worker ASurfaceControl* _Nonnull surface_control, 548*38e8c45fSAndroid Build Coastguard Worker enum ASurfaceTransactionTransparency transparency) 549*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(29); 550*38e8c45fSAndroid Build Coastguard Worker 551*38e8c45fSAndroid Build Coastguard Worker /** 552*38e8c45fSAndroid Build Coastguard Worker * Updates the region for the content on this surface updated in this 553*38e8c45fSAndroid Build Coastguard Worker * transaction. If unspecified, the complete surface is assumed to be damaged. 554*38e8c45fSAndroid Build Coastguard Worker * 555*38e8c45fSAndroid Build Coastguard Worker * Available since API level 29. 556*38e8c45fSAndroid Build Coastguard Worker */ 557*38e8c45fSAndroid Build Coastguard Worker void ASurfaceTransaction_setDamageRegion(ASurfaceTransaction* _Nonnull transaction, 558*38e8c45fSAndroid Build Coastguard Worker ASurfaceControl* _Nonnull surface_control, 559*38e8c45fSAndroid Build Coastguard Worker const ARect* _Nullable rects, uint32_t count) 560*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(29); 561*38e8c45fSAndroid Build Coastguard Worker 562*38e8c45fSAndroid Build Coastguard Worker /** 563*38e8c45fSAndroid Build Coastguard Worker * Specifies a desiredPresentTime for the transaction. The framework will try to present 564*38e8c45fSAndroid Build Coastguard Worker * the transaction at or after the time specified. 565*38e8c45fSAndroid Build Coastguard Worker * 566*38e8c45fSAndroid Build Coastguard Worker * Transactions will not be presented until all of their acquire fences have signaled even if the 567*38e8c45fSAndroid Build Coastguard Worker * app requests an earlier present time. 568*38e8c45fSAndroid Build Coastguard Worker * 569*38e8c45fSAndroid Build Coastguard Worker * If an earlier transaction has a desired present time of x, and a later transaction has a desired 570*38e8c45fSAndroid Build Coastguard Worker * present time that is before x, the later transaction will not preempt the earlier transaction. 571*38e8c45fSAndroid Build Coastguard Worker * 572*38e8c45fSAndroid Build Coastguard Worker * Available since API level 29. 573*38e8c45fSAndroid Build Coastguard Worker */ 574*38e8c45fSAndroid Build Coastguard Worker void ASurfaceTransaction_setDesiredPresentTime(ASurfaceTransaction* _Nonnull transaction, 575*38e8c45fSAndroid Build Coastguard Worker int64_t desiredPresentTime) __INTRODUCED_IN(29); 576*38e8c45fSAndroid Build Coastguard Worker 577*38e8c45fSAndroid Build Coastguard Worker /** 578*38e8c45fSAndroid Build Coastguard Worker * Sets the alpha for the buffer. It uses a premultiplied blending. 579*38e8c45fSAndroid Build Coastguard Worker * 580*38e8c45fSAndroid Build Coastguard Worker * The \a alpha must be between 0.0 and 1.0. 581*38e8c45fSAndroid Build Coastguard Worker * 582*38e8c45fSAndroid Build Coastguard Worker * Available since API level 29. 583*38e8c45fSAndroid Build Coastguard Worker */ 584*38e8c45fSAndroid Build Coastguard Worker void ASurfaceTransaction_setBufferAlpha(ASurfaceTransaction* _Nonnull transaction, 585*38e8c45fSAndroid Build Coastguard Worker ASurfaceControl* _Nonnull surface_control, float alpha) 586*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(29); 587*38e8c45fSAndroid Build Coastguard Worker 588*38e8c45fSAndroid Build Coastguard Worker /** 589*38e8c45fSAndroid Build Coastguard Worker * Sets the data space of the surface_control's buffers. 590*38e8c45fSAndroid Build Coastguard Worker * 591*38e8c45fSAndroid Build Coastguard Worker * If no data space is set, the surface control defaults to ADATASPACE_SRGB. 592*38e8c45fSAndroid Build Coastguard Worker * 593*38e8c45fSAndroid Build Coastguard Worker * Available since API level 29. 594*38e8c45fSAndroid Build Coastguard Worker */ 595*38e8c45fSAndroid Build Coastguard Worker void ASurfaceTransaction_setBufferDataSpace(ASurfaceTransaction* _Nonnull transaction, 596*38e8c45fSAndroid Build Coastguard Worker ASurfaceControl* _Nonnull surface_control, 597*38e8c45fSAndroid Build Coastguard Worker enum ADataSpace data_space) __INTRODUCED_IN(29); 598*38e8c45fSAndroid Build Coastguard Worker 599*38e8c45fSAndroid Build Coastguard Worker /** 600*38e8c45fSAndroid Build Coastguard Worker * SMPTE ST 2086 "Mastering Display Color Volume" static metadata 601*38e8c45fSAndroid Build Coastguard Worker * 602*38e8c45fSAndroid Build Coastguard Worker * When \a metadata is set to null, the framework does not use any smpte2086 metadata when rendering 603*38e8c45fSAndroid Build Coastguard Worker * the surface's buffer. 604*38e8c45fSAndroid Build Coastguard Worker * 605*38e8c45fSAndroid Build Coastguard Worker * Available since API level 29. 606*38e8c45fSAndroid Build Coastguard Worker */ 607*38e8c45fSAndroid Build Coastguard Worker void ASurfaceTransaction_setHdrMetadata_smpte2086(ASurfaceTransaction* _Nonnull transaction, 608*38e8c45fSAndroid Build Coastguard Worker ASurfaceControl* _Nonnull surface_control, 609*38e8c45fSAndroid Build Coastguard Worker struct AHdrMetadata_smpte2086* _Nullable metadata) 610*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(29); 611*38e8c45fSAndroid Build Coastguard Worker 612*38e8c45fSAndroid Build Coastguard Worker /** 613*38e8c45fSAndroid Build Coastguard Worker * Sets the CTA 861.3 "HDR Static Metadata Extension" static metadata on a surface. 614*38e8c45fSAndroid Build Coastguard Worker * 615*38e8c45fSAndroid Build Coastguard Worker * When \a metadata is set to null, the framework does not use any cta861.3 metadata when rendering 616*38e8c45fSAndroid Build Coastguard Worker * the surface's buffer. 617*38e8c45fSAndroid Build Coastguard Worker * 618*38e8c45fSAndroid Build Coastguard Worker * Available since API level 29. 619*38e8c45fSAndroid Build Coastguard Worker */ 620*38e8c45fSAndroid Build Coastguard Worker void ASurfaceTransaction_setHdrMetadata_cta861_3(ASurfaceTransaction* _Nonnull transaction, 621*38e8c45fSAndroid Build Coastguard Worker ASurfaceControl* _Nonnull surface_control, 622*38e8c45fSAndroid Build Coastguard Worker struct AHdrMetadata_cta861_3* _Nullable metadata) 623*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(29); 624*38e8c45fSAndroid Build Coastguard Worker 625*38e8c45fSAndroid Build Coastguard Worker /** 626*38e8c45fSAndroid Build Coastguard Worker * Sets the desired extended range brightness for the layer. This only applies for layers whose 627*38e8c45fSAndroid Build Coastguard Worker * dataspace has RANGE_EXTENDED set on it. See: ASurfaceTransaction_setDesiredHdrHeadroom, prefer 628*38e8c45fSAndroid Build Coastguard Worker * using this API for formats that encode an HDR/SDR ratio as part of generating the buffer. 629*38e8c45fSAndroid Build Coastguard Worker * 630*38e8c45fSAndroid Build Coastguard Worker * @param surface_control The layer whose extended range brightness is being specified 631*38e8c45fSAndroid Build Coastguard Worker * @param currentBufferRatio The current HDR/SDR ratio of the current buffer as represented as 632*38e8c45fSAndroid Build Coastguard Worker * peakHdrBrightnessInNits / targetSdrWhitePointInNits. For example if the 633*38e8c45fSAndroid Build Coastguard Worker * buffer was rendered with a target SDR whitepoint of 100nits and a max 634*38e8c45fSAndroid Build Coastguard Worker * display brightness of 200nits, this should be set to 2.0f. 635*38e8c45fSAndroid Build Coastguard Worker * 636*38e8c45fSAndroid Build Coastguard Worker * Default value is 1.0f. 637*38e8c45fSAndroid Build Coastguard Worker * 638*38e8c45fSAndroid Build Coastguard Worker * Transfer functions that encode their own brightness ranges, such as 639*38e8c45fSAndroid Build Coastguard Worker * HLG or PQ, should also set this to 1.0f and instead communicate 640*38e8c45fSAndroid Build Coastguard Worker * extended content brightness information via metadata such as CTA861_3 641*38e8c45fSAndroid Build Coastguard Worker * or SMPTE2086. 642*38e8c45fSAndroid Build Coastguard Worker * 643*38e8c45fSAndroid Build Coastguard Worker * Must be finite && >= 1.0f 644*38e8c45fSAndroid Build Coastguard Worker * 645*38e8c45fSAndroid Build Coastguard Worker * @param desiredRatio The desired HDR/SDR ratio as represented as peakHdrBrightnessInNits / 646*38e8c45fSAndroid Build Coastguard Worker * targetSdrWhitePointInNits. This can be used to communicate the max desired 647*38e8c45fSAndroid Build Coastguard Worker * brightness range. This is similar to the "max luminance" value in other 648*38e8c45fSAndroid Build Coastguard Worker * HDR metadata formats, but represented as a ratio of the target SDR whitepoint 649*38e8c45fSAndroid Build Coastguard Worker * to the max display brightness. The system may not be able to, or may choose 650*38e8c45fSAndroid Build Coastguard Worker * not to, deliver the requested range. 651*38e8c45fSAndroid Build Coastguard Worker * 652*38e8c45fSAndroid Build Coastguard Worker * While requesting a large desired ratio will result in the most 653*38e8c45fSAndroid Build Coastguard Worker * dynamic range, voluntarily reducing the requested range can help 654*38e8c45fSAndroid Build Coastguard Worker * improve battery life as well as can improve quality by ensuring 655*38e8c45fSAndroid Build Coastguard Worker * greater bit depth is allocated to the luminance range in use. 656*38e8c45fSAndroid Build Coastguard Worker * 657*38e8c45fSAndroid Build Coastguard Worker * Default value is 1.0f and indicates that extended range brightness 658*38e8c45fSAndroid Build Coastguard Worker * is not being used, so the resulting SDR or HDR behavior will be 659*38e8c45fSAndroid Build Coastguard Worker * determined entirely by the dataspace being used (ie, typically SDR 660*38e8c45fSAndroid Build Coastguard Worker * however PQ or HLG transfer functions will still result in HDR) 661*38e8c45fSAndroid Build Coastguard Worker * 662*38e8c45fSAndroid Build Coastguard Worker * When called after ASurfaceTransaction_setDesiredHdrHeadroom, the 663*38e8c45fSAndroid Build Coastguard Worker * desiredRatio will override the desiredHeadroom provided by 664*38e8c45fSAndroid Build Coastguard Worker * ASurfaceTransaction_setDesiredHdrHeadroom. Conversely, when called before 665*38e8c45fSAndroid Build Coastguard Worker * ASurfaceTransaction_setDesiredHdrHeadroom, the desiredHeadroom provided by 666*38e8c45fSAndroid Build Coastguard Worker *. ASurfaceTransaction_setDesiredHdrHeadroom will override the desiredRatio. 667*38e8c45fSAndroid Build Coastguard Worker * 668*38e8c45fSAndroid Build Coastguard Worker * Must be finite && >= 1.0f 669*38e8c45fSAndroid Build Coastguard Worker * 670*38e8c45fSAndroid Build Coastguard Worker * Available since API level 34. 671*38e8c45fSAndroid Build Coastguard Worker */ 672*38e8c45fSAndroid Build Coastguard Worker void ASurfaceTransaction_setExtendedRangeBrightness(ASurfaceTransaction* _Nonnull transaction, 673*38e8c45fSAndroid Build Coastguard Worker ASurfaceControl* _Nonnull surface_control, 674*38e8c45fSAndroid Build Coastguard Worker float currentBufferRatio, float desiredRatio) 675*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(__ANDROID_API_U__); 676*38e8c45fSAndroid Build Coastguard Worker 677*38e8c45fSAndroid Build Coastguard Worker /** 678*38e8c45fSAndroid Build Coastguard Worker * Sets the desired HDR headroom for the layer. See: ASurfaceTransaction_setExtendedRangeBrightness, 679*38e8c45fSAndroid Build Coastguard Worker * prefer using this API for formats that conform to HDR standards like HLG or HDR10, that do not 680*38e8c45fSAndroid Build Coastguard Worker * communicate a HDR/SDR ratio as part of generating the buffer. 681*38e8c45fSAndroid Build Coastguard Worker * 682*38e8c45fSAndroid Build Coastguard Worker * @param surface_control The layer whose desired HDR headroom is being specified 683*38e8c45fSAndroid Build Coastguard Worker * 684*38e8c45fSAndroid Build Coastguard Worker * @param desiredHeadroom The desired HDR/SDR ratio as represented as peakHdrBrightnessInNits / 685*38e8c45fSAndroid Build Coastguard Worker * targetSdrWhitePointInNits. This can be used to communicate the max 686*38e8c45fSAndroid Build Coastguard Worker * desired brightness range of the panel. The system may not be able to, or 687*38e8c45fSAndroid Build Coastguard Worker * may choose not to, deliver the requested range. 688*38e8c45fSAndroid Build Coastguard Worker * 689*38e8c45fSAndroid Build Coastguard Worker * While requesting a large desired ratio will result in the most 690*38e8c45fSAndroid Build Coastguard Worker * dynamic range, voluntarily reducing the requested range can help 691*38e8c45fSAndroid Build Coastguard Worker * improve battery life as well as can improve quality by ensuring 692*38e8c45fSAndroid Build Coastguard Worker * greater bit depth is allocated to the luminance range in use. 693*38e8c45fSAndroid Build Coastguard Worker * 694*38e8c45fSAndroid Build Coastguard Worker * Default value is 0.0f and indicates that the system will choose the best 695*38e8c45fSAndroid Build Coastguard Worker * headroom for this surface control's content. Typically, this means that 696*38e8c45fSAndroid Build Coastguard Worker * HLG/PQ encoded content will be displayed with some HDR headroom greater 697*38e8c45fSAndroid Build Coastguard Worker * than 1.0. 698*38e8c45fSAndroid Build Coastguard Worker * 699*38e8c45fSAndroid Build Coastguard Worker * When called after ASurfaceTransaction_setExtendedRangeBrightness, the 700*38e8c45fSAndroid Build Coastguard Worker * desiredHeadroom will override the desiredRatio provided by 701*38e8c45fSAndroid Build Coastguard Worker * ASurfaceTransaction_setExtendedRangeBrightness. Conversely, when called 702*38e8c45fSAndroid Build Coastguard Worker * before ASurfaceTransaction_setExtendedRangeBrightness, the desiredRatio 703*38e8c45fSAndroid Build Coastguard Worker * provided by ASurfaceTransaction_setExtendedRangeBrightness will override 704*38e8c45fSAndroid Build Coastguard Worker * the desiredHeadroom. 705*38e8c45fSAndroid Build Coastguard Worker * 706*38e8c45fSAndroid Build Coastguard Worker * Must be finite && >= 1.0f or 0.0f to indicate there is no desired 707*38e8c45fSAndroid Build Coastguard Worker * headroom. 708*38e8c45fSAndroid Build Coastguard Worker * 709*38e8c45fSAndroid Build Coastguard Worker * Available since API level 35. 710*38e8c45fSAndroid Build Coastguard Worker */ 711*38e8c45fSAndroid Build Coastguard Worker void ASurfaceTransaction_setDesiredHdrHeadroom(ASurfaceTransaction* _Nonnull transaction, 712*38e8c45fSAndroid Build Coastguard Worker ASurfaceControl* _Nonnull surface_control, 713*38e8c45fSAndroid Build Coastguard Worker float desiredHeadroom) 714*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(__ANDROID_API_V__); 715*38e8c45fSAndroid Build Coastguard Worker 716*38e8c45fSAndroid Build Coastguard Worker /** 717*38e8c45fSAndroid Build Coastguard Worker * Sets the Lut(s) to be applied for the layer. 718*38e8c45fSAndroid Build Coastguard Worker * 719*38e8c45fSAndroid Build Coastguard Worker * The function makes a deep copy of the provided `luts`. 720*38e8c45fSAndroid Build Coastguard Worker * Any modifications made to the `luts` object after calling this function 721*38e8c45fSAndroid Build Coastguard Worker * will not affect the Lut(s) applied to the layer. 722*38e8c45fSAndroid Build Coastguard Worker * 723*38e8c45fSAndroid Build Coastguard Worker * @param surface_control The layer where Lut(s) is being applied 724*38e8c45fSAndroid Build Coastguard Worker * @param luts The Lut(s) to be applied 725*38e8c45fSAndroid Build Coastguard Worker * 726*38e8c45fSAndroid Build Coastguard Worker * Available since API level 36. 727*38e8c45fSAndroid Build Coastguard Worker */ 728*38e8c45fSAndroid Build Coastguard Worker void ASurfaceTransaction_setLuts(ASurfaceTransaction* _Nonnull transaction, 729*38e8c45fSAndroid Build Coastguard Worker ASurfaceControl* _Nonnull surface_control, 730*38e8c45fSAndroid Build Coastguard Worker const struct ADisplayLuts* _Nullable luts) 731*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(36); 732*38e8c45fSAndroid Build Coastguard Worker 733*38e8c45fSAndroid Build Coastguard Worker /** 734*38e8c45fSAndroid Build Coastguard Worker * Same as ASurfaceTransaction_setFrameRateWithChangeStrategy(transaction, surface_control, 735*38e8c45fSAndroid Build Coastguard Worker * frameRate, compatibility, ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS). 736*38e8c45fSAndroid Build Coastguard Worker * 737*38e8c45fSAndroid Build Coastguard Worker * See ASurfaceTransaction_setFrameRateWithChangeStrategy(). 738*38e8c45fSAndroid Build Coastguard Worker * 739*38e8c45fSAndroid Build Coastguard Worker * Available since API level 30. 740*38e8c45fSAndroid Build Coastguard Worker */ 741*38e8c45fSAndroid Build Coastguard Worker void ASurfaceTransaction_setFrameRate(ASurfaceTransaction* _Nonnull transaction, 742*38e8c45fSAndroid Build Coastguard Worker ASurfaceControl* _Nonnull surface_control, float frameRate, 743*38e8c45fSAndroid Build Coastguard Worker int8_t compatibility) __INTRODUCED_IN(30); 744*38e8c45fSAndroid Build Coastguard Worker 745*38e8c45fSAndroid Build Coastguard Worker /** 746*38e8c45fSAndroid Build Coastguard Worker * Sets the intended frame rate for \a surface_control. 747*38e8c45fSAndroid Build Coastguard Worker * 748*38e8c45fSAndroid Build Coastguard Worker * On devices that are capable of running the display at different refresh rates, the system may 749*38e8c45fSAndroid Build Coastguard Worker * choose a display refresh rate to better match this surface's frame rate. Usage of this API won't 750*38e8c45fSAndroid Build Coastguard Worker * directly affect the application's frame production pipeline. However, because the system may 751*38e8c45fSAndroid Build Coastguard Worker * change the display refresh rate, calls to this function may result in changes to Choreographer 752*38e8c45fSAndroid Build Coastguard Worker * callback timings, and changes to the time interval at which the system releases buffers back to 753*38e8c45fSAndroid Build Coastguard Worker * the application. 754*38e8c45fSAndroid Build Coastguard Worker * 755*38e8c45fSAndroid Build Coastguard Worker * You can register for changes in the refresh rate using 756*38e8c45fSAndroid Build Coastguard Worker * \a AChoreographer_registerRefreshRateCallback. 757*38e8c45fSAndroid Build Coastguard Worker * 758*38e8c45fSAndroid Build Coastguard Worker * See ASurfaceTransaction_clearFrameRate(). 759*38e8c45fSAndroid Build Coastguard Worker * 760*38e8c45fSAndroid Build Coastguard Worker * \param frameRate is the intended frame rate of this surface, in frames per second. 0 is a special 761*38e8c45fSAndroid Build Coastguard Worker * value that indicates the app will accept the system's choice for the display frame rate, which is 762*38e8c45fSAndroid Build Coastguard Worker * the default behavior if this function isn't called. The frameRate param does <em>not</em> need to 763*38e8c45fSAndroid Build Coastguard Worker * be a valid refresh rate for this device's display - e.g., it's fine to pass 30fps to a device 764*38e8c45fSAndroid Build Coastguard Worker * that can only run the display at 60fps. 765*38e8c45fSAndroid Build Coastguard Worker * 766*38e8c45fSAndroid Build Coastguard Worker * \param compatibility The frame rate compatibility of this surface. The compatibility value may 767*38e8c45fSAndroid Build Coastguard Worker * influence the system's choice of display frame rate. To specify a compatibility use the 768*38e8c45fSAndroid Build Coastguard Worker * ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_* enum. This parameter is ignored when frameRate is 0. 769*38e8c45fSAndroid Build Coastguard Worker * 770*38e8c45fSAndroid Build Coastguard Worker * \param changeFrameRateStrategy Whether display refresh rate transitions caused by this 771*38e8c45fSAndroid Build Coastguard Worker * surface should be seamless. A seamless transition is one that doesn't have any visual 772*38e8c45fSAndroid Build Coastguard Worker * interruptions, such as a black screen for a second or two. See the 773*38e8c45fSAndroid Build Coastguard Worker * ANATIVEWINDOW_CHANGE_FRAME_RATE_* values. This parameter is ignored when frameRate is 0. 774*38e8c45fSAndroid Build Coastguard Worker * 775*38e8c45fSAndroid Build Coastguard Worker * Available since API level 31. 776*38e8c45fSAndroid Build Coastguard Worker */ 777*38e8c45fSAndroid Build Coastguard Worker void ASurfaceTransaction_setFrameRateWithChangeStrategy(ASurfaceTransaction* _Nonnull transaction, 778*38e8c45fSAndroid Build Coastguard Worker ASurfaceControl* _Nonnull surface_control, 779*38e8c45fSAndroid Build Coastguard Worker float frameRate, int8_t compatibility, 780*38e8c45fSAndroid Build Coastguard Worker int8_t changeFrameRateStrategy) 781*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(31); 782*38e8c45fSAndroid Build Coastguard Worker 783*38e8c45fSAndroid Build Coastguard Worker /** 784*38e8c45fSAndroid Build Coastguard Worker * Clears the frame rate which is set for \a surface_control. 785*38e8c45fSAndroid Build Coastguard Worker * 786*38e8c45fSAndroid Build Coastguard Worker * This is equivalent to calling 787*38e8c45fSAndroid Build Coastguard Worker * ASurfaceTransaction_setFrameRateWithChangeStrategy( 788*38e8c45fSAndroid Build Coastguard Worker * transaction, 0, compatibility, changeFrameRateStrategy). 789*38e8c45fSAndroid Build Coastguard Worker * 790*38e8c45fSAndroid Build Coastguard Worker * Usage of this API won't directly affect the application's frame production pipeline. However, 791*38e8c45fSAndroid Build Coastguard Worker * because the system may change the display refresh rate, calls to this function may result in 792*38e8c45fSAndroid Build Coastguard Worker * changes to Choreographer callback timings, and changes to the time interval at which the system 793*38e8c45fSAndroid Build Coastguard Worker * releases buffers back to the application. 794*38e8c45fSAndroid Build Coastguard Worker * 795*38e8c45fSAndroid Build Coastguard Worker * See ASurfaceTransaction_setFrameRateWithChangeStrategy() 796*38e8c45fSAndroid Build Coastguard Worker * 797*38e8c45fSAndroid Build Coastguard Worker * You can register for changes in the refresh rate using 798*38e8c45fSAndroid Build Coastguard Worker * \a AChoreographer_registerRefreshRateCallback. 799*38e8c45fSAndroid Build Coastguard Worker * 800*38e8c45fSAndroid Build Coastguard Worker * See ASurfaceTransaction_setFrameRateWithChangeStrategy(). 801*38e8c45fSAndroid Build Coastguard Worker * 802*38e8c45fSAndroid Build Coastguard Worker * Available since API level 34. 803*38e8c45fSAndroid Build Coastguard Worker */ 804*38e8c45fSAndroid Build Coastguard Worker void ASurfaceTransaction_clearFrameRate(ASurfaceTransaction* _Nonnull transaction, 805*38e8c45fSAndroid Build Coastguard Worker ASurfaceControl* _Nonnull surface_control) 806*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(__ANDROID_API_U__); 807*38e8c45fSAndroid Build Coastguard Worker 808*38e8c45fSAndroid Build Coastguard Worker /** 809*38e8c45fSAndroid Build Coastguard Worker * Indicate whether to enable backpressure for buffer submission to a given SurfaceControl. 810*38e8c45fSAndroid Build Coastguard Worker * 811*38e8c45fSAndroid Build Coastguard Worker * By default backpressure is disabled, which means submitting a buffer prior to receiving 812*38e8c45fSAndroid Build Coastguard Worker * a callback for the previous buffer could lead to that buffer being "dropped". In cases 813*38e8c45fSAndroid Build Coastguard Worker * where you are selecting for latency, this may be a desirable behavior! We had a new buffer 814*38e8c45fSAndroid Build Coastguard Worker * ready, why shouldn't we show it? 815*38e8c45fSAndroid Build Coastguard Worker * 816*38e8c45fSAndroid Build Coastguard Worker * When back pressure is enabled, each buffer will be required to be presented 817*38e8c45fSAndroid Build Coastguard Worker * before it is released and the callback delivered 818*38e8c45fSAndroid Build Coastguard Worker * (absent the whole SurfaceControl being removed). 819*38e8c45fSAndroid Build Coastguard Worker * 820*38e8c45fSAndroid Build Coastguard Worker * Most apps are likely to have some sort of backpressure internally, e.g. you are 821*38e8c45fSAndroid Build Coastguard Worker * waiting on the callback from frame N-2 before starting frame N. In high refresh 822*38e8c45fSAndroid Build Coastguard Worker * rate scenarios there may not be much time between SurfaceFlinger completing frame 823*38e8c45fSAndroid Build Coastguard Worker * N-1 (and therefore releasing buffer N-2) and beginning frame N. This means 824*38e8c45fSAndroid Build Coastguard Worker * your app may not have enough time to respond in the callback. Using this flag 825*38e8c45fSAndroid Build Coastguard Worker * and pushing buffers earlier for server side queuing will be advantageous 826*38e8c45fSAndroid Build Coastguard Worker * in such cases. 827*38e8c45fSAndroid Build Coastguard Worker * 828*38e8c45fSAndroid Build Coastguard Worker * Available since API level 31. 829*38e8c45fSAndroid Build Coastguard Worker * 830*38e8c45fSAndroid Build Coastguard Worker * \param transaction The transaction in which to make the change. 831*38e8c45fSAndroid Build Coastguard Worker * \param surface_control The ASurfaceControl on which to control buffer backpressure behavior. 832*38e8c45fSAndroid Build Coastguard Worker * \param enableBackPressure Whether to enable back pressure. 833*38e8c45fSAndroid Build Coastguard Worker */ 834*38e8c45fSAndroid Build Coastguard Worker void ASurfaceTransaction_setEnableBackPressure(ASurfaceTransaction* _Nonnull transaction, 835*38e8c45fSAndroid Build Coastguard Worker ASurfaceControl* _Nonnull surface_control, 836*38e8c45fSAndroid Build Coastguard Worker bool enableBackPressure) __INTRODUCED_IN(31); 837*38e8c45fSAndroid Build Coastguard Worker 838*38e8c45fSAndroid Build Coastguard Worker /** 839*38e8c45fSAndroid Build Coastguard Worker * Sets the frame timeline to use in SurfaceFlinger. 840*38e8c45fSAndroid Build Coastguard Worker * 841*38e8c45fSAndroid Build Coastguard Worker * A frame timeline should be chosen based on the frame deadline the application 842*38e8c45fSAndroid Build Coastguard Worker * can meet when rendering the frame and the application's desired presentation time. 843*38e8c45fSAndroid Build Coastguard Worker * By setting a frame timeline, SurfaceFlinger tries to present the frame at the corresponding 844*38e8c45fSAndroid Build Coastguard Worker * expected presentation time. 845*38e8c45fSAndroid Build Coastguard Worker * 846*38e8c45fSAndroid Build Coastguard Worker * To receive frame timelines, a callback must be posted to Choreographer using 847*38e8c45fSAndroid Build Coastguard Worker * AChoreographer_postVsyncCallback(). The \c vsyncId can then be extracted from the 848*38e8c45fSAndroid Build Coastguard Worker * callback payload using AChoreographerFrameCallbackData_getFrameTimelineVsyncId(). 849*38e8c45fSAndroid Build Coastguard Worker * 850*38e8c45fSAndroid Build Coastguard Worker * Available since API level 33. 851*38e8c45fSAndroid Build Coastguard Worker * 852*38e8c45fSAndroid Build Coastguard Worker * \param vsyncId The vsync ID received from AChoreographer, setting the frame's presentation target 853*38e8c45fSAndroid Build Coastguard Worker * to the corresponding expected presentation time and deadline from the frame to be rendered. A 854*38e8c45fSAndroid Build Coastguard Worker * stale or invalid value will be ignored. 855*38e8c45fSAndroid Build Coastguard Worker */ 856*38e8c45fSAndroid Build Coastguard Worker void ASurfaceTransaction_setFrameTimeline(ASurfaceTransaction* _Nonnull transaction, 857*38e8c45fSAndroid Build Coastguard Worker AVsyncId vsyncId) __INTRODUCED_IN(33); 858*38e8c45fSAndroid Build Coastguard Worker 859*38e8c45fSAndroid Build Coastguard Worker __END_DECLS 860*38e8c45fSAndroid Build Coastguard Worker 861*38e8c45fSAndroid Build Coastguard Worker #endif // ANDROID_SURFACE_CONTROL_H 862*38e8c45fSAndroid Build Coastguard Worker 863*38e8c45fSAndroid Build Coastguard Worker /** @} */ 864