Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a021bb0f authored by Rachel Lee's avatar Rachel Lee
Browse files

Logic for selection strategy "DoNotPropagate"

This logic is for the new FrameRateSelectionStrategy::DoNotPropagate.
The default behavior ("Self") is to propagate parent vote to children
that has no votes, but if a layer has "DoNotPropagate", it will not
propagate its vote to children.

Bug: 309687765
Test: atest libsurfaceflinger_unittest
Test: atest CtsSurfaceControlTestsStaging
Change-Id: I284b639f2b1902c5e9d3dcd08ceaf3f76b73451e
parent 43881b0f
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -1103,7 +1103,12 @@ enum {
enum {
    /**
     * Default value. The layer uses its own frame rate specifications, assuming it has any
     * specifications, instead of its parent's.
     * specifications, instead of its parent's. If it does not have its own frame rate
     * specifications, it will try to use its parent's.
     *
     * However, FRAME_RATE_SELECTION_STRATEGY_OVERRIDE_CHILDREN on an ancestor layer
     * supersedes this behavior, meaning that this layer will inherit the frame rate specifications
     * of that ancestor layer.
     */
    ANATIVEWINDOW_FRAME_RATE_SELECTION_STRATEGY_SELF = 0,

@@ -1114,6 +1119,14 @@ enum {
     * behavior for itself.
     */
    ANATIVEWINDOW_FRAME_RATE_SELECTION_STRATEGY_OVERRIDE_CHILDREN = 1,

    /**
     * The layer's frame rate specifications will never propagate to its descendant
     * layers.
     * FRAME_RATE_SELECTION_STRATEGY_OVERRIDE_CHILDREN on an ancestor layer supersedes
     * this behavior.
     */
    ANATIVEWINDOW_FRAME_RATE_SELECTION_STRATEGY_DO_NOT_PROPAGATE = 2,
};

static inline int native_window_set_frame_rate(struct ANativeWindow* window, float frameRate,
+14 −8
Original line number Diff line number Diff line
@@ -814,9 +814,12 @@ void LayerSnapshotBuilder::updateSnapshot(LayerSnapshot& snapshot, const Args& a
                RequestedLayerState::Changes::Hierarchy) ||
        snapshot.changes.any(RequestedLayerState::Changes::FrameRate |
                             RequestedLayerState::Changes::Hierarchy)) {
        bool shouldOverrideChildren = parentSnapshot.frameRateSelectionStrategy ==
        const bool shouldOverrideChildren = parentSnapshot.frameRateSelectionStrategy ==
                scheduler::LayerInfo::FrameRateSelectionStrategy::OverrideChildren;
        if (!requested.requestedFrameRate.isValid() || shouldOverrideChildren) {
        const bool propagationAllowed = parentSnapshot.frameRateSelectionStrategy !=
                scheduler::LayerInfo::FrameRateSelectionStrategy::DoNotPropagate;
        if ((!requested.requestedFrameRate.isValid() && propagationAllowed) ||
            shouldOverrideChildren) {
            snapshot.inheritedFrameRate = parentSnapshot.inheritedFrameRate;
        } else {
            snapshot.inheritedFrameRate = requested.requestedFrameRate;
@@ -828,12 +831,15 @@ void LayerSnapshotBuilder::updateSnapshot(LayerSnapshot& snapshot, const Args& a
    }

    if (forceUpdate || snapshot.clientChanges & layer_state_t::eFrameRateSelectionStrategyChanged) {
        if (parentSnapshot.frameRateSelectionStrategy ==
            scheduler::LayerInfo::FrameRateSelectionStrategy::OverrideChildren) {
            snapshot.frameRateSelectionStrategy =
                    scheduler::LayerInfo::FrameRateSelectionStrategy::OverrideChildren;
        } else {
            const auto strategy = scheduler::LayerInfo::convertFrameRateSelectionStrategy(
                    requested.frameRateSelectionStrategy);
        snapshot.frameRateSelectionStrategy =
                strategy == scheduler::LayerInfo::FrameRateSelectionStrategy::Self
                ? parentSnapshot.frameRateSelectionStrategy
                : strategy;
            snapshot.frameRateSelectionStrategy = strategy;
        }
    }

    if (forceUpdate || snapshot.clientChanges & layer_state_t::eFrameRateSelectionPriority) {
+6 −5
Original line number Diff line number Diff line
@@ -1273,14 +1273,15 @@ bool Layer::propagateFrameRateForLayerTree(FrameRate parentFrameRate, bool overr
    auto now = systemTime();
    *transactionNeeded |= setFrameRateForLayerTreeLegacy(frameRate, now);

    // The frame rate is propagated to the children
    // The frame rate is propagated to the children by default, but some properties may override it.
    bool childrenHaveFrameRate = false;
    const bool overrideChildrenFrameRate = overrideChildren || shouldOverrideChildrenFrameRate();
    const bool canPropagateFrameRate = shouldPropagateFrameRate() || overrideChildrenFrameRate;
    for (const sp<Layer>& child : mCurrentChildren) {
        childrenHaveFrameRate |=
                child->propagateFrameRateForLayerTree(frameRate,
                                                      overrideChildren ||
                                                              shouldOverrideChildrenFrameRate(),
                                                      transactionNeeded);
                child->propagateFrameRateForLayerTree(canPropagateFrameRate ? frameRate
                                                                            : FrameRate(),
                                                      overrideChildrenFrameRate, transactionNeeded);
    }

    // If we don't have a valid frame rate specification, but the children do, we set this
+5 −0
Original line number Diff line number Diff line
@@ -1178,6 +1178,11 @@ private:
                FrameRateSelectionStrategy::OverrideChildren;
    }

    bool shouldPropagateFrameRate() const {
        return getDrawingState().frameRateSelectionStrategy !=
                FrameRateSelectionStrategy::DoNotPropagate;
    }

    // Cached properties computed from drawing state
    // Effective transform taking into account parent transforms and any parent scaling, which is
    // a transform from the current layer coordinate space to display(screen) coordinate space.
+2 −0
Original line number Diff line number Diff line
@@ -530,6 +530,8 @@ LayerInfo::FrameRateSelectionStrategy LayerInfo::convertFrameRateSelectionStrate
            return FrameRateSelectionStrategy::Self;
        case ANATIVEWINDOW_FRAME_RATE_SELECTION_STRATEGY_OVERRIDE_CHILDREN:
            return FrameRateSelectionStrategy::OverrideChildren;
        case ANATIVEWINDOW_FRAME_RATE_SELECTION_STRATEGY_DO_NOT_PROPAGATE:
            return FrameRateSelectionStrategy::DoNotPropagate;
        default:
            LOG_ALWAYS_FATAL("Invalid frame rate selection strategy value %d", strategy);
            return FrameRateSelectionStrategy::Self;
Loading