Early wake-up for transitions (1/2)
On some devices it's very likely that we fall into GL comp during
app transitions. However, SF offsets are chosen in a way such that
the time to finish a frame is just too tight to be completely jank
free when hitting GL composition in SurfaceFlinger. Thus, we
introduce the concept of a separate early offset, and wakeup
SurfaceFlinger at that time if we think that hitting GL comp is
likely, or we already hit GL comp in the last frame.
Test: Open app, check vsync offsets in systrace
Test: Open many dialogs/apps to fall into GPU comp.
Bug: 75985430
Change-Id: Ie17e30c4575359fa11bb8912f68dcafe3e569ddb
Merged-In: Ie17e30c4575359fa11bb8912f68dcafe3e569ddb
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index bbf681e..63560c4 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -101,7 +101,8 @@
SurfaceComposerClient::Transaction::Transaction(const Transaction& other) :
mForceSynchronous(other.mForceSynchronous),
mTransactionNestCount(other.mTransactionNestCount),
- mAnimation(other.mAnimation) {
+ mAnimation(other.mAnimation),
+ mEarlyWakeup(other.mEarlyWakeup) {
mDisplayStates = other.mDisplayStates;
mComposerStates = other.mComposerStates;
}
@@ -157,9 +158,13 @@
if (mAnimation) {
flags |= ISurfaceComposer::eAnimation;
}
+ if (mEarlyWakeup) {
+ flags |= ISurfaceComposer::eEarlyWakeup;
+ }
mForceSynchronous = false;
mAnimation = false;
+ mEarlyWakeup = false;
sf->setTransactionState(composerStates, displayStates, flags);
mStatus = NO_ERROR;
@@ -185,6 +190,10 @@
mAnimation = true;
}
+void SurfaceComposerClient::Transaction::setEarlyWakeup() {
+ mEarlyWakeup = true;
+}
+
layer_state_t* SurfaceComposerClient::Transaction::getLayerState(const sp<SurfaceControl>& sc) {
if (mComposerStates.count(sc) == 0) {
// we don't have it, add an initialized layer_state to our list
diff --git a/libs/gui/include/gui/ISurfaceComposer.h b/libs/gui/include/gui/ISurfaceComposer.h
index 3591090..e401572 100644
--- a/libs/gui/include/gui/ISurfaceComposer.h
+++ b/libs/gui/include/gui/ISurfaceComposer.h
@@ -61,6 +61,11 @@
enum {
eSynchronous = 0x01,
eAnimation = 0x02,
+
+ // Indicates that this transaction will likely result in a lot of layers being composed, and
+ // thus, SurfaceFlinger should wake-up earlier to avoid missing frame deadlines. In this
+ // case SurfaceFlinger will wake up at (sf vsync offset - debug.sf.early_phase_offset_ns)
+ eEarlyWakeup = 0x04
};
enum {
diff --git a/libs/gui/include/gui/SurfaceComposerClient.h b/libs/gui/include/gui/SurfaceComposerClient.h
index ffc22f6..377fe68 100644
--- a/libs/gui/include/gui/SurfaceComposerClient.h
+++ b/libs/gui/include/gui/SurfaceComposerClient.h
@@ -154,6 +154,7 @@
uint32_t mForceSynchronous = 0;
uint32_t mTransactionNestCount = 0;
bool mAnimation = false;
+ bool mEarlyWakeup = false;
int mStatus = NO_ERROR;
@@ -273,6 +274,7 @@
const Rect& displayRect);
void setDisplaySize(const sp<IBinder>& token, uint32_t width, uint32_t height);
void setAnimationTransaction();
+ void setEarlyWakeup();
};
status_t destroySurface(const sp<IBinder>& id);