Loading services/surfaceflinger/BufferLayer.cpp +4 −1 Original line number Diff line number Diff line Loading @@ -97,8 +97,11 @@ bool BufferLayer::isOpaque(const Layer::State& s) const { } bool BufferLayer::isVisible() const { return !(isHiddenByPolicy()) && getAlpha() > 0.0f && bool visible = !(isHiddenByPolicy()) && getAlpha() > 0.0f && (mActiveBuffer != nullptr || mSidebandStream != nullptr); mFlinger->mScheduler->setLayerVisibility(mSchedulerLayerHandle, visible); return visible; } bool BufferLayer::isFixedSize() const { Loading services/surfaceflinger/BufferQueueLayer.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -443,7 +443,8 @@ void BufferQueueLayer::onFrameAvailable(const BufferItem& item) { { // Autolock scope if (mFlinger->mUseSmart90ForVideo) { const nsecs_t presentTime = item.mIsAutoTimestamp ? 0 : item.mTimestamp; mFlinger->mScheduler->addLayerPresentTime(mSchedulerLayerHandle, presentTime); mFlinger->mScheduler->addLayerPresentTimeAndHDR(mSchedulerLayerHandle, presentTime, item.mHdrMetadata.validTypes != 0); } Mutex::Autolock lock(mQueueItemLock); Loading services/surfaceflinger/BufferStateLayer.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -227,7 +227,8 @@ bool BufferStateLayer::setBuffer(const sp<GraphicBuffer>& buffer, nsecs_t postTi if (mFlinger->mUseSmart90ForVideo) { const nsecs_t presentTime = (mDesiredPresentTime == -1) ? 0 : mDesiredPresentTime; mFlinger->mScheduler->addLayerPresentTime(mSchedulerLayerHandle, presentTime); mFlinger->mScheduler->addLayerPresentTimeAndHDR(mSchedulerLayerHandle, presentTime, mCurrentState.hdrMetadata.validTypes != 0); } return true; Loading services/surfaceflinger/Scheduler/LayerHistory.cpp +35 −4 Original line number Diff line number Diff line Loading @@ -67,7 +67,8 @@ void LayerHistory::destroyLayer(const int64_t id) { } } void LayerHistory::insert(const std::unique_ptr<LayerHandle>& layerHandle, nsecs_t presentTime) { void LayerHistory::insert(const std::unique_ptr<LayerHandle>& layerHandle, nsecs_t presentTime, bool isHdr) { std::shared_ptr<LayerInfo> layerInfo; { std::lock_guard lock(mLock); Loading @@ -88,9 +89,36 @@ void LayerHistory::insert(const std::unique_ptr<LayerHandle>& layerHandle, nsecs } } layerInfo->setLastPresentTime(presentTime); layerInfo->setHDRContent(isHdr); } float LayerHistory::getDesiredRefreshRate() { void LayerHistory::setVisibility(const std::unique_ptr<LayerHandle>& layerHandle, bool visible) { std::shared_ptr<LayerInfo> layerInfo; { std::lock_guard lock(mLock); auto layerInfoIterator = mInactiveLayerInfos.find(layerHandle->mId); if (layerInfoIterator != mInactiveLayerInfos.end()) { layerInfo = layerInfoIterator->second; if (visible) { mInactiveLayerInfos.erase(layerInfoIterator); mActiveLayerInfos.insert({layerHandle->mId, layerInfo}); } } else { layerInfoIterator = mActiveLayerInfos.find(layerHandle->mId); if (layerInfoIterator != mActiveLayerInfos.end()) { layerInfo = layerInfoIterator->second; } else { ALOGW("Inserting information about layer that is not registered: %" PRId64, layerHandle->mId); return; } } } layerInfo->setVisibility(visible); } std::pair<float, bool> LayerHistory::getDesiredRefreshRateAndHDR() { bool isHDR = false; float newRefreshRate = 0.f; std::lock_guard lock(mLock); Loading @@ -108,12 +136,13 @@ float LayerHistory::getDesiredRefreshRate() { if (layerInfo->isRecentlyActive() && layerRefreshRate > newRefreshRate) { newRefreshRate = layerRefreshRate; } isHDR |= layerInfo->getHDRContent(); } if (mTraceEnabled) { ALOGD("LayerHistory DesiredRefreshRate: %.2f", newRefreshRate); } return newRefreshRate; return {newRefreshRate, isHDR}; } void LayerHistory::removeIrrelevantLayers() { Loading @@ -122,7 +151,9 @@ void LayerHistory::removeIrrelevantLayers() { auto it = mActiveLayerInfos.begin(); while (it != mActiveLayerInfos.end()) { // If last updated was before the obsolete time, remove it. if (it->second->getLastUpdatedTime() < obsoleteEpsilon) { // Keep HDR layer around as long as they are visible. if (!it->second->isVisible() || (!it->second->getHDRContent() && it->second->getLastUpdatedTime() < obsoleteEpsilon)) { // erase() function returns the iterator of the next // to last deleted element. if (mTraceEnabled) { Loading services/surfaceflinger/Scheduler/LayerHistory.h +5 −2 Original line number Diff line number Diff line Loading @@ -56,10 +56,13 @@ public: std::unique_ptr<LayerHandle> createLayer(const std::string name, float maxRefreshRate); // Method for inserting layers and their requested present time into the unordered map. void insert(const std::unique_ptr<LayerHandle>& layerHandle, nsecs_t presentTime); void insert(const std::unique_ptr<LayerHandle>& layerHandle, nsecs_t presentTime, bool isHdr); // Method for setting layer visibility void setVisibility(const std::unique_ptr<LayerHandle>& layerHandle, bool visible); // Returns the desired refresh rate, which is a max refresh rate of all the current // layers. See go/content-fps-detection-in-scheduler for more information. float getDesiredRefreshRate(); std::pair<float, bool> getDesiredRefreshRateAndHDR(); // Removes the handle and the object from the map. void destroyLayer(const int64_t id); Loading Loading
services/surfaceflinger/BufferLayer.cpp +4 −1 Original line number Diff line number Diff line Loading @@ -97,8 +97,11 @@ bool BufferLayer::isOpaque(const Layer::State& s) const { } bool BufferLayer::isVisible() const { return !(isHiddenByPolicy()) && getAlpha() > 0.0f && bool visible = !(isHiddenByPolicy()) && getAlpha() > 0.0f && (mActiveBuffer != nullptr || mSidebandStream != nullptr); mFlinger->mScheduler->setLayerVisibility(mSchedulerLayerHandle, visible); return visible; } bool BufferLayer::isFixedSize() const { Loading
services/surfaceflinger/BufferQueueLayer.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -443,7 +443,8 @@ void BufferQueueLayer::onFrameAvailable(const BufferItem& item) { { // Autolock scope if (mFlinger->mUseSmart90ForVideo) { const nsecs_t presentTime = item.mIsAutoTimestamp ? 0 : item.mTimestamp; mFlinger->mScheduler->addLayerPresentTime(mSchedulerLayerHandle, presentTime); mFlinger->mScheduler->addLayerPresentTimeAndHDR(mSchedulerLayerHandle, presentTime, item.mHdrMetadata.validTypes != 0); } Mutex::Autolock lock(mQueueItemLock); Loading
services/surfaceflinger/BufferStateLayer.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -227,7 +227,8 @@ bool BufferStateLayer::setBuffer(const sp<GraphicBuffer>& buffer, nsecs_t postTi if (mFlinger->mUseSmart90ForVideo) { const nsecs_t presentTime = (mDesiredPresentTime == -1) ? 0 : mDesiredPresentTime; mFlinger->mScheduler->addLayerPresentTime(mSchedulerLayerHandle, presentTime); mFlinger->mScheduler->addLayerPresentTimeAndHDR(mSchedulerLayerHandle, presentTime, mCurrentState.hdrMetadata.validTypes != 0); } return true; Loading
services/surfaceflinger/Scheduler/LayerHistory.cpp +35 −4 Original line number Diff line number Diff line Loading @@ -67,7 +67,8 @@ void LayerHistory::destroyLayer(const int64_t id) { } } void LayerHistory::insert(const std::unique_ptr<LayerHandle>& layerHandle, nsecs_t presentTime) { void LayerHistory::insert(const std::unique_ptr<LayerHandle>& layerHandle, nsecs_t presentTime, bool isHdr) { std::shared_ptr<LayerInfo> layerInfo; { std::lock_guard lock(mLock); Loading @@ -88,9 +89,36 @@ void LayerHistory::insert(const std::unique_ptr<LayerHandle>& layerHandle, nsecs } } layerInfo->setLastPresentTime(presentTime); layerInfo->setHDRContent(isHdr); } float LayerHistory::getDesiredRefreshRate() { void LayerHistory::setVisibility(const std::unique_ptr<LayerHandle>& layerHandle, bool visible) { std::shared_ptr<LayerInfo> layerInfo; { std::lock_guard lock(mLock); auto layerInfoIterator = mInactiveLayerInfos.find(layerHandle->mId); if (layerInfoIterator != mInactiveLayerInfos.end()) { layerInfo = layerInfoIterator->second; if (visible) { mInactiveLayerInfos.erase(layerInfoIterator); mActiveLayerInfos.insert({layerHandle->mId, layerInfo}); } } else { layerInfoIterator = mActiveLayerInfos.find(layerHandle->mId); if (layerInfoIterator != mActiveLayerInfos.end()) { layerInfo = layerInfoIterator->second; } else { ALOGW("Inserting information about layer that is not registered: %" PRId64, layerHandle->mId); return; } } } layerInfo->setVisibility(visible); } std::pair<float, bool> LayerHistory::getDesiredRefreshRateAndHDR() { bool isHDR = false; float newRefreshRate = 0.f; std::lock_guard lock(mLock); Loading @@ -108,12 +136,13 @@ float LayerHistory::getDesiredRefreshRate() { if (layerInfo->isRecentlyActive() && layerRefreshRate > newRefreshRate) { newRefreshRate = layerRefreshRate; } isHDR |= layerInfo->getHDRContent(); } if (mTraceEnabled) { ALOGD("LayerHistory DesiredRefreshRate: %.2f", newRefreshRate); } return newRefreshRate; return {newRefreshRate, isHDR}; } void LayerHistory::removeIrrelevantLayers() { Loading @@ -122,7 +151,9 @@ void LayerHistory::removeIrrelevantLayers() { auto it = mActiveLayerInfos.begin(); while (it != mActiveLayerInfos.end()) { // If last updated was before the obsolete time, remove it. if (it->second->getLastUpdatedTime() < obsoleteEpsilon) { // Keep HDR layer around as long as they are visible. if (!it->second->isVisible() || (!it->second->getHDRContent() && it->second->getLastUpdatedTime() < obsoleteEpsilon)) { // erase() function returns the iterator of the next // to last deleted element. if (mTraceEnabled) { Loading
services/surfaceflinger/Scheduler/LayerHistory.h +5 −2 Original line number Diff line number Diff line Loading @@ -56,10 +56,13 @@ public: std::unique_ptr<LayerHandle> createLayer(const std::string name, float maxRefreshRate); // Method for inserting layers and their requested present time into the unordered map. void insert(const std::unique_ptr<LayerHandle>& layerHandle, nsecs_t presentTime); void insert(const std::unique_ptr<LayerHandle>& layerHandle, nsecs_t presentTime, bool isHdr); // Method for setting layer visibility void setVisibility(const std::unique_ptr<LayerHandle>& layerHandle, bool visible); // Returns the desired refresh rate, which is a max refresh rate of all the current // layers. See go/content-fps-detection-in-scheduler for more information. float getDesiredRefreshRate(); std::pair<float, bool> getDesiredRefreshRateAndHDR(); // Removes the handle and the object from the map. void destroyLayer(const int64_t id); Loading