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.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