Disable expensive rendering during static screen
Locking the GPU frequency to a high value causes a power regression, so
when there's no screen updates we should disable expensive rendering -
previously expensive rendering would always be enabled if the previous
frame required expensive rendering.
Bug: 188625644
Test: Swipe to recents and monitor gpu clock info
Change-Id: Ie41fa6286e851c0390295672b399ce29419ea90b
diff --git a/services/surfaceflinger/DisplayHardware/PowerAdvisor.cpp b/services/surfaceflinger/DisplayHardware/PowerAdvisor.cpp
index 901e19a..1765caf 100644
--- a/services/surfaceflinger/DisplayHardware/PowerAdvisor.cpp
+++ b/services/surfaceflinger/DisplayHardware/PowerAdvisor.cpp
@@ -32,6 +32,7 @@
#include "../SurfaceFlingerProperties.h"
#include "PowerAdvisor.h"
+#include "SurfaceFlinger.h"
namespace android {
namespace Hwc2 {
@@ -61,14 +62,22 @@
} // namespace
-PowerAdvisor::PowerAdvisor()
- : mUseUpdateImminentTimer(getUpdateTimeout() > 0),
- mUpdateImminentTimer(
+PowerAdvisor::PowerAdvisor(SurfaceFlinger& flinger)
+ : mFlinger(flinger),
+ mUseScreenUpdateTimer(getUpdateTimeout() > 0),
+ mScreenUpdateTimer(
"UpdateImminentTimer", OneShotTimer::Interval(getUpdateTimeout()),
/* resetCallback */ [this] { mSendUpdateImminent.store(false); },
- /* timeoutCallback */ [this] { mSendUpdateImminent.store(true); }) {
- if (mUseUpdateImminentTimer) {
- mUpdateImminentTimer.start();
+ /* timeoutCallback */
+ [this] {
+ mSendUpdateImminent.store(true);
+ mFlinger.disableExpensiveRendering();
+ }) {}
+
+void PowerAdvisor::init() {
+ // Defer starting the screen update timer until SurfaceFlinger finishes construction.
+ if (mUseScreenUpdateTimer) {
+ mScreenUpdateTimer.start();
}
}
@@ -122,8 +131,8 @@
}
}
- if (mUseUpdateImminentTimer) {
- mUpdateImminentTimer.reset();
+ if (mUseScreenUpdateTimer) {
+ mScreenUpdateTimer.reset();
}
}