Enable backpressure for BufferStateLayer
The default behaviour of buffer state layer is to drop older
buffers if there are newer buffers that are ready to be presented.
When emulating BufferQueue behavior via the adapter, we want
to queue up buffers without any present timestamps. To solve this,
we introduce a layer state flag to keep the buffer in the transaction
queue if there is already a buffer that is ready to be applied.
Test: atest SurfaceViewBufferTests:BufferPresentationTests
Bug: 176967609
Change-Id: I33f6347bd1c7a2d80dc4214e596bb864abe8c6bf
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index 359340e..357c4a4 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -207,7 +207,7 @@
// to achieve mirroring.
uint32_t layerStack;
- uint8_t flags;
+ uint32_t flags;
uint8_t reserved[2];
int32_t sequence; // changes when visible regions can change
bool modified;
@@ -425,7 +425,7 @@
virtual bool setBackgroundBlurRadius(int backgroundBlurRadius);
virtual bool setBlurRegions(const std::vector<BlurRegion>& effectRegions);
virtual bool setTransparentRegionHint(const Region& transparent);
- virtual bool setFlags(uint8_t flags, uint8_t mask);
+ virtual bool setFlags(uint32_t flags, uint32_t mask);
virtual bool setLayerStack(uint32_t layerStack);
virtual uint32_t getLayerStack() const;
virtual void deferTransactionUntil_legacy(const sp<IBinder>& barrierHandle,
@@ -906,6 +906,9 @@
bool mPendingHWCDestroy{false};
+ bool backpressureEnabled() { return mDrawingState.flags & layer_state_t::eEnableBackpressure; }
+ bool hasPendingBuffer() { return mCurrentState.buffer != mDrawingState.buffer; };
+
protected:
class SyncPoint {
public: