diff options
| -rw-r--r-- | services/surfaceflinger/FrontEnd/LayerSnapshot.h | 5 | ||||
| -rw-r--r-- | services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp | 66 | ||||
| -rw-r--r-- | services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.h | 4 |
3 files changed, 38 insertions, 37 deletions
diff --git a/services/surfaceflinger/FrontEnd/LayerSnapshot.h b/services/surfaceflinger/FrontEnd/LayerSnapshot.h index 1416872f95..1afcef9e44 100644 --- a/services/surfaceflinger/FrontEnd/LayerSnapshot.h +++ b/services/surfaceflinger/FrontEnd/LayerSnapshot.h @@ -41,10 +41,6 @@ struct RoundedCornerState { } }; -struct ChildState { - bool hasValidFrameRate = false; -}; - // LayerSnapshot stores Layer state used by CompositionEngine and RenderEngine. Composition // Engine uses a pointer to LayerSnapshot (as LayerFECompositionState*) and the LayerSettings // passed to Render Engine are created using properties stored on this struct. @@ -99,7 +95,6 @@ struct LayerSnapshot : public compositionengine::LayerFECompositionState { uint32_t touchCropId; gui::Uid uid = gui::Uid::INVALID; gui::Pid pid = gui::Pid::INVALID; - ChildState childState; enum class Reachablilty : uint32_t { // Can traverse the hierarchy from a root node and reach this snapshot Reachable, diff --git a/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp b/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp index 3a19d0b389..7e678b98fa 100644 --- a/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp +++ b/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp @@ -558,7 +558,7 @@ const LayerSnapshot& LayerSnapshotBuilder::updateSnapshotsInHierarchy( const LayerSnapshot& childSnapshot = updateSnapshotsInHierarchy(args, *childHierarchy, traversalPath, *snapshot, depth + 1); - updateChildState(*snapshot, childSnapshot, args); + updateFrameRateFromChildSnapshot(*snapshot, childSnapshot, args); } if (oldFrameRate == snapshot->frameRate) { @@ -666,36 +666,40 @@ void LayerSnapshotBuilder::updateRelativeState(LayerSnapshot& snapshot, } } -void LayerSnapshotBuilder::updateChildState(LayerSnapshot& snapshot, - const LayerSnapshot& childSnapshot, const Args& args) { - if (snapshot.childState.hasValidFrameRate) { +void LayerSnapshotBuilder::updateFrameRateFromChildSnapshot(LayerSnapshot& snapshot, + const LayerSnapshot& childSnapshot, + const Args& args) { + if (args.forceUpdate == ForceUpdateFlags::NONE && + !childSnapshot.changes.any(RequestedLayerState::Changes::FrameRate | + RequestedLayerState::Changes::Hierarchy)) { return; } - if (args.forceUpdate == ForceUpdateFlags::ALL || - childSnapshot.changes.test(RequestedLayerState::Changes::FrameRate)) { - // We return whether this layer ot its children has a vote. We ignore ExactOrMultiple votes - // for the same reason we are allowing touch boost for those layers. See - // RefreshRateSelector::rankFrameRates for details. - using FrameRateCompatibility = scheduler::LayerInfo::FrameRateCompatibility; - const auto layerVotedWithDefaultCompatibility = childSnapshot.frameRate.rate.isValid() && - childSnapshot.frameRate.type == FrameRateCompatibility::Default; - const auto layerVotedWithNoVote = - childSnapshot.frameRate.type == FrameRateCompatibility::NoVote; - const auto layerVotedWithExactCompatibility = childSnapshot.frameRate.rate.isValid() && - childSnapshot.frameRate.type == FrameRateCompatibility::Exact; - - snapshot.childState.hasValidFrameRate |= layerVotedWithDefaultCompatibility || - layerVotedWithNoVote || layerVotedWithExactCompatibility; - - // If we don't have a valid frame rate, but the children do, we set this - // layer as NoVote to allow the children to control the refresh rate - if (!snapshot.frameRate.rate.isValid() && - snapshot.frameRate.type != FrameRateCompatibility::NoVote && - snapshot.childState.hasValidFrameRate) { - snapshot.frameRate = - scheduler::LayerInfo::FrameRate(Fps(), FrameRateCompatibility::NoVote); - snapshot.changes |= childSnapshot.changes & RequestedLayerState::Changes::FrameRate; - } + + using FrameRateCompatibility = scheduler::LayerInfo::FrameRateCompatibility; + if (snapshot.frameRate.rate.isValid() || + snapshot.frameRate.type == FrameRateCompatibility::NoVote) { + // we already have a valid framerate. + return; + } + + // We return whether this layer or its children has a vote. We ignore ExactOrMultiple votes + // for the same reason we are allowing touch boost for those layers. See + // RefreshRateSelector::rankFrameRates for details. + const auto layerVotedWithDefaultCompatibility = childSnapshot.frameRate.rate.isValid() && + childSnapshot.frameRate.type == FrameRateCompatibility::Default; + const auto layerVotedWithNoVote = + childSnapshot.frameRate.type == FrameRateCompatibility::NoVote; + const auto layerVotedWithExactCompatibility = childSnapshot.frameRate.rate.isValid() && + childSnapshot.frameRate.type == FrameRateCompatibility::Exact; + + bool childHasValidFrameRate = layerVotedWithDefaultCompatibility || layerVotedWithNoVote || + layerVotedWithExactCompatibility; + + // If we don't have a valid frame rate, but the children do, we set this + // layer as NoVote to allow the children to control the refresh rate + if (childHasValidFrameRate) { + snapshot.frameRate = scheduler::LayerInfo::FrameRate(Fps(), FrameRateCompatibility::NoVote); + snapshot.changes |= RequestedLayerState::Changes::FrameRate; } } @@ -812,7 +816,9 @@ void LayerSnapshotBuilder::updateSnapshot(LayerSnapshot& snapshot, const Args& a } } - if (forceUpdate || snapshot.changes.any(RequestedLayerState::Changes::FrameRate)) { + if (forceUpdate || + snapshot.changes.any(RequestedLayerState::Changes::FrameRate | + RequestedLayerState::Changes::Hierarchy)) { snapshot.frameRate = (requested.requestedFrameRate.rate.isValid() || (requested.requestedFrameRate.type == scheduler::LayerInfo::FrameRateCompatibility::NoVote)) diff --git a/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.h b/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.h index c81a5d2b9e..d361605875 100644 --- a/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.h +++ b/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.h @@ -116,8 +116,8 @@ private: LayerSnapshot* createSnapshot(const LayerHierarchy::TraversalPath& id, const RequestedLayerState& layer, const LayerSnapshot& parentSnapshot); - void updateChildState(LayerSnapshot& snapshot, const LayerSnapshot& childSnapshot, - const Args& args); + void updateFrameRateFromChildSnapshot(LayerSnapshot& snapshot, + const LayerSnapshot& childSnapshot, const Args& args); void updateTouchableRegionCrop(const Args& args); std::unordered_map<LayerHierarchy::TraversalPath, LayerSnapshot*, |