SF Bounds caching 1/3: Defer calls that use layer bounds until the cached bounds are available.
End goal is to calculate the bounds once in the surface flinger loop. The bounds are invalidated
if the visible region changes. The first step is to defer any functions that use the cache to after
the bounds is calculated.
- Defer updating display dirty region when latching buffers.
- Defer updating cursor and input flinger until all the buffers have been latched.
- Recompute visible regions if transformToDisplayInverse flag changes
Test: go/wm-smoke
Test: atest -a libinput_tests inputflinger_tests SurfaceFlinger_test libsurfaceflinger_unittest SurfaceParcelable_test libgui_test
Change-Id: Ife6e0f06939d9f4fb051b68cb2b1c9f5bd180b57
diff --git a/services/surfaceflinger/BufferLayer.h b/services/surfaceflinger/BufferLayer.h
index 8158d6c..ba7431f 100644
--- a/services/surfaceflinger/BufferLayer.h
+++ b/services/surfaceflinger/BufferLayer.h
@@ -99,8 +99,8 @@
// If there was a GL composition step rendering the previous frame, then
// releaseFence will be populated with a native fence that fires when
// composition has completed.
- Region latchBuffer(bool& recomputeVisibleRegions, nsecs_t latchTime,
- const sp<Fence>& releaseFence) override;
+ bool latchBuffer(bool& recomputeVisibleRegions, nsecs_t latchTime,
+ const sp<Fence>& releaseFence) override;
bool isBufferLatched() const override { return mRefreshPending; }
@@ -137,7 +137,8 @@
virtual bool getAutoRefresh() const = 0;
virtual bool getSidebandStreamChanged() const = 0;
- virtual std::optional<Region> latchSidebandStream(bool& recomputeVisibleRegions) = 0;
+ // Latch sideband stream and returns true if the dirty region should be updated.
+ virtual bool latchSidebandStream(bool& recomputeVisibleRegions) = 0;
virtual bool hasFrameUpdate() const = 0;
@@ -179,6 +180,8 @@
uint32_t mCurrentScalingMode{NATIVE_WINDOW_SCALING_MODE_FREEZE};
+ bool mTransformToDisplayInverse{false};
+
// main thread.
bool mBufferLatched{false}; // TODO: Use mActiveBuffer?