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();
}
}
diff --git a/services/surfaceflinger/DisplayHardware/PowerAdvisor.h b/services/surfaceflinger/DisplayHardware/PowerAdvisor.h
index 95eb0e2..f2d0766 100644
--- a/services/surfaceflinger/DisplayHardware/PowerAdvisor.h
+++ b/services/surfaceflinger/DisplayHardware/PowerAdvisor.h
@@ -25,14 +25,20 @@
#include "DisplayIdentification.h"
namespace android {
+
+class SurfaceFlinger;
+
namespace Hwc2 {
class PowerAdvisor {
public:
virtual ~PowerAdvisor();
+ // Initializes resources that cannot be initialized on construction
+ virtual void init() = 0;
virtual void onBootFinished() = 0;
virtual void setExpensiveRenderingExpected(DisplayId displayId, bool expected) = 0;
+ virtual bool isUsingExpensiveRendering() = 0;
virtual void notifyDisplayUpdateImminent() = 0;
};
@@ -50,11 +56,13 @@
virtual bool notifyDisplayUpdateImminent() = 0;
};
- PowerAdvisor();
+ PowerAdvisor(SurfaceFlinger& flinger);
~PowerAdvisor() override;
+ void init() override;
void onBootFinished() override;
void setExpensiveRenderingExpected(DisplayId displayId, bool expected) override;
+ bool isUsingExpensiveRendering() override { return mNotifiedExpensiveRendering; }
void notifyDisplayUpdateImminent() override;
private:
@@ -67,9 +75,10 @@
std::unordered_set<DisplayId> mExpensiveDisplays;
bool mNotifiedExpensiveRendering = false;
- const bool mUseUpdateImminentTimer;
+ SurfaceFlinger& mFlinger;
+ const bool mUseScreenUpdateTimer;
std::atomic_bool mSendUpdateImminent = true;
- scheduler::OneShotTimer mUpdateImminentTimer;
+ scheduler::OneShotTimer mScreenUpdateTimer;
};
} // namespace impl