Loading services/surfaceflinger/DisplayHardware/PowerAdvisor.cpp +13 −10 Original line number Original line Diff line number Diff line Loading @@ -64,9 +64,10 @@ using scheduler::OneShotTimer; PowerAdvisor::~PowerAdvisor() = default; PowerAdvisor::~PowerAdvisor() = default; namespace { namespace { int32_t getUpdateTimeout() { std::chrono::milliseconds getUpdateTimeout() { // Default to a timeout of 80ms if nothing else is specified // Default to a timeout of 80ms if nothing else is specified static int32_t timeout = sysprop::display_update_imminent_timeout_ms(80); static std::chrono::milliseconds timeout = std::chrono::milliseconds(sysprop::display_update_imminent_timeout_ms(80)); return timeout; return timeout; } } Loading @@ -81,21 +82,23 @@ void traceExpensiveRendering(bool enabled) { } // namespace } // namespace PowerAdvisor::PowerAdvisor(SurfaceFlinger& flinger) : mFlinger(flinger) { PowerAdvisor::PowerAdvisor(SurfaceFlinger& flinger) : mFlinger(flinger) { if (getUpdateTimeout()) { if (getUpdateTimeout() > 0ms) { mScreenUpdateTimer.emplace("UpdateImminentTimer", mScreenUpdateTimer.emplace("UpdateImminentTimer", getUpdateTimeout(), OneShotTimer::Interval(getUpdateTimeout()), /* resetCallback */ nullptr, /* resetCallback */ nullptr, /* timeoutCallback */ /* timeoutCallback */ [this] { [this] { const nsecs_t timeSinceLastUpdate = while (true) { systemTime() - mLastScreenUpdatedTime.load(); auto timeSinceLastUpdate = std::chrono::nanoseconds( if (timeSinceLastUpdate < getUpdateTimeout()) { systemTime() - mLastScreenUpdatedTime.load()); if (timeSinceLastUpdate >= getUpdateTimeout()) { break; } // We may try to disable expensive rendering and allow // We may try to disable expensive rendering and allow // for sending DISPLAY_UPDATE_IMMINENT hints too early if // for sending DISPLAY_UPDATE_IMMINENT hints too early if // we idled very shortly after updating the screen, so // we idled very shortly after updating the screen, so // make sure we wait enough time. // make sure we wait enough time. std::this_thread::sleep_for(std::chrono::nanoseconds( std::this_thread::sleep_for(getUpdateTimeout() - getUpdateTimeout() - timeSinceLastUpdate)); timeSinceLastUpdate); } } mSendUpdateImminent.store(true); mSendUpdateImminent.store(true); mFlinger.disableExpensiveRendering(); mFlinger.disableExpensiveRendering(); Loading Loading
services/surfaceflinger/DisplayHardware/PowerAdvisor.cpp +13 −10 Original line number Original line Diff line number Diff line Loading @@ -64,9 +64,10 @@ using scheduler::OneShotTimer; PowerAdvisor::~PowerAdvisor() = default; PowerAdvisor::~PowerAdvisor() = default; namespace { namespace { int32_t getUpdateTimeout() { std::chrono::milliseconds getUpdateTimeout() { // Default to a timeout of 80ms if nothing else is specified // Default to a timeout of 80ms if nothing else is specified static int32_t timeout = sysprop::display_update_imminent_timeout_ms(80); static std::chrono::milliseconds timeout = std::chrono::milliseconds(sysprop::display_update_imminent_timeout_ms(80)); return timeout; return timeout; } } Loading @@ -81,21 +82,23 @@ void traceExpensiveRendering(bool enabled) { } // namespace } // namespace PowerAdvisor::PowerAdvisor(SurfaceFlinger& flinger) : mFlinger(flinger) { PowerAdvisor::PowerAdvisor(SurfaceFlinger& flinger) : mFlinger(flinger) { if (getUpdateTimeout()) { if (getUpdateTimeout() > 0ms) { mScreenUpdateTimer.emplace("UpdateImminentTimer", mScreenUpdateTimer.emplace("UpdateImminentTimer", getUpdateTimeout(), OneShotTimer::Interval(getUpdateTimeout()), /* resetCallback */ nullptr, /* resetCallback */ nullptr, /* timeoutCallback */ /* timeoutCallback */ [this] { [this] { const nsecs_t timeSinceLastUpdate = while (true) { systemTime() - mLastScreenUpdatedTime.load(); auto timeSinceLastUpdate = std::chrono::nanoseconds( if (timeSinceLastUpdate < getUpdateTimeout()) { systemTime() - mLastScreenUpdatedTime.load()); if (timeSinceLastUpdate >= getUpdateTimeout()) { break; } // We may try to disable expensive rendering and allow // We may try to disable expensive rendering and allow // for sending DISPLAY_UPDATE_IMMINENT hints too early if // for sending DISPLAY_UPDATE_IMMINENT hints too early if // we idled very shortly after updating the screen, so // we idled very shortly after updating the screen, so // make sure we wait enough time. // make sure we wait enough time. std::this_thread::sleep_for(std::chrono::nanoseconds( std::this_thread::sleep_for(getUpdateTimeout() - getUpdateTimeout() - timeSinceLastUpdate)); timeSinceLastUpdate); } } mSendUpdateImminent.store(true); mSendUpdateImminent.store(true); mFlinger.disableExpensiveRendering(); mFlinger.disableExpensiveRendering(); Loading