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

Commit 4c8073d8 authored by Rachel Lee's avatar Rachel Lee
Browse files

New selection strategy "DoNotPropagate"

Add 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. This can be used on ViewRootImpl to
avoid incorrectly propagating frame rate category "NoPreference" to
content SurfaceControls.

Bug: 309687765
Test: atest CtsSurfaceControlTestsStaging
Change-Id: Ibc869f2cc7d4c2822ecc757d44ccef01ea9574d4
parent 4d6f5374
Loading
Loading
Loading
Loading
+15 −3
Original line number Diff line number Diff line
@@ -860,13 +860,16 @@ public final class SurfaceControl implements Parcelable {
    @Retention(RetentionPolicy.SOURCE)
    @IntDef(prefix = {"FRAME_RATE_SELECTION_STRATEGY_"},
            value = {FRAME_RATE_SELECTION_STRATEGY_SELF,
                    FRAME_RATE_SELECTION_STRATEGY_OVERRIDE_CHILDREN})
                    FRAME_RATE_SELECTION_STRATEGY_OVERRIDE_CHILDREN,
                    FRAME_RATE_SELECTION_STRATEGY_DO_NOT_PROPAGATE})
    public @interface FrameRateSelectionStrategy {}

    // From window.h. Keep these in sync.
    /**
     * 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, {@link #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.
@@ -879,12 +882,21 @@ public final class SurfaceControl implements Parcelable {
     * layers.
     * The layer with this strategy has the {@link #FRAME_RATE_SELECTION_STRATEGY_SELF} behavior
     * for itself. This does mean that any parent or ancestor layer that also has the strategy
     * {@link FRAME_RATE_SELECTION_STRATEGY_OVERRIDE_CHILDREN} will override this layer's
     * {@link #FRAME_RATE_SELECTION_STRATEGY_OVERRIDE_CHILDREN} will override this layer's
     * frame rate specifications.
     * @hide
     */
    public static final int FRAME_RATE_SELECTION_STRATEGY_OVERRIDE_CHILDREN = 1;

    /**
     * The layer's frame rate specifications will never propagate to its descendant
     * layers.
     * {@link #FRAME_RATE_SELECTION_STRATEGY_OVERRIDE_CHILDREN} on an ancestor layer supersedes
     * this behavior.
     * @hide
     */
    public static final int FRAME_RATE_SELECTION_STRATEGY_DO_NOT_PROPAGATE = 2;

    /**
     * Builder class for {@link SurfaceControl} objects.
     *
+8 −2
Original line number Diff line number Diff line
@@ -710,9 +710,15 @@ public class GraphicsActivity extends Activity {
            float childFrameRate = Collections.max(frameRates);
            float parentFrameRate = childFrameRate / 2;
            int initialNumEvents = mModeChangedEvents.size();
            parent.setFrameRate(parentFrameRate);
            parent.setFrameRateSelectionStrategy(parentStrategy);

            // For DoNotPropagate case, we want to test that child gets default behavior
            if (parentStrategy == SurfaceControl.FRAME_RATE_SELECTION_STRATEGY_DO_NOT_PROPAGATE) {
                parent.setFrameRateCategory(Surface.FRAME_RATE_CATEGORY_NO_PREFERENCE);
            } else {
                parent.setFrameRate(parentFrameRate);
                child.setFrameRate(childFrameRate);
            }

            // Verify
            float expectedFrameRate =
+8 −0
Original line number Diff line number Diff line
@@ -124,4 +124,12 @@ public class SurfaceControlTest {
        activity.testSurfaceControlFrameRateSelectionStrategy(
                SurfaceControl.FRAME_RATE_SELECTION_STRATEGY_OVERRIDE_CHILDREN);
    }

    @Test
    public void testSurfaceControlFrameRateSelectionStrategyDoNotPropagate()
            throws InterruptedException {
        GraphicsActivity activity = mActivityRule.getActivity();
        activity.testSurfaceControlFrameRateSelectionStrategy(
                SurfaceControl.FRAME_RATE_SELECTION_STRATEGY_DO_NOT_PROPAGATE);
    }
}