ASurfaceTransaction: Add setEnableBackpressure

Expose the flag to the NDK. See source comment for discussion.

Bug: 177458703
Test: Need new CTS
Change-Id: Iab60a537268aa2d42175eca3658ea190045c8bdd
diff --git a/include/android/surface_control.h b/include/android/surface_control.h
index c17f822..a8b9466 100644
--- a/include/android/surface_control.h
+++ b/include/android/surface_control.h
@@ -464,6 +464,35 @@
                                       int8_t compatibility, bool shouldBeSeamless)
                                       __INTRODUCED_IN(31);
 
+/**
+ * Indicate whether to enable backpressure for buffer submission to a given SurfaceControl.
+ *
+ * By default backpressure is disabled, which means submitting a buffer prior to receiving
+ * a callback for the previous buffer could lead to that buffer being "dropped". In cases
+ * where you are selecting for latency, this may be a desirable behavior! We had a new buffer
+ * ready, why shouldn't we show it?
+ *
+ * When back pressure is enabled, each buffer will be required to be presented
+ * before it is released and the callback delivered
+ * (absent the whole SurfaceControl being removed).
+ *
+ * Most apps are likely to have some sort of backpressure internally, e.g. you are
+ * waiting on the callback from frame N-2 before starting frame N. In high refresh
+ * rate scenarios there may not be much time between SurfaceFlinger completing frame
+ * N-1 (and therefore releasing buffer N-2) and beginning frame N. This means
+ * your app may not have enough time to respond in the callback. Using this flag
+ * and pushing buffers earlier for server side queuing will be advantageous
+ * in such cases.
+ *
+ * \param transaction The transaction in which to make the change.
+ * \param surface_control The ASurfaceControl on which to control buffer backpressure behavior.
+ * \param enableBackPressure Whether to enable back pressure.
+ */
+void ASurfaceTransaction_setEnableBackPressure(ASurfaceTransaction* transaction,
+                                               ASurfaceControl* surface_control,
+                                               bool enableBackPressure)
+                                               __INTRODUCED_IN(31);
+
 __END_DECLS
 
 #endif // ANDROID_SURFACE_CONTROL_H