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

Commit 58cc90d3 authored by Rachel Lee's avatar Rachel Lee
Browse files

Plumb new frameRateSelectionStrategy value

This new value will allow a parent layer to override the frame
rate specifications of all its descendants. This CL only plumbs the
value from Transaction to Layer.

Bug: 297418260
Test: atest CtsSurfaceControlTestsStaging
Test: atest libsurfaceflinger_unittest
Change-Id: Ibbda6ff6c143e931240178d89306822b4cce9669
parent 47adfcfd
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -84,6 +84,7 @@ layer_state_t::layer_state_t()
        changeFrameRateStrategy(ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS),
        defaultFrameRateCompatibility(ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT),
        frameRateCategory(ANATIVEWINDOW_FRAME_RATE_CATEGORY_DEFAULT),
        frameRateSelectionStrategy(ANATIVEWINDOW_FRAME_RATE_SELECTION_STRATEGY_SELF),
        fixedTransformHint(ui::Transform::ROT_INVALID),
        autoRefresh(false),
        isTrustedOverlay(false),
@@ -160,6 +161,7 @@ status_t layer_state_t::write(Parcel& output) const
    SAFE_PARCEL(output.writeByte, changeFrameRateStrategy);
    SAFE_PARCEL(output.writeByte, defaultFrameRateCompatibility);
    SAFE_PARCEL(output.writeByte, frameRateCategory);
    SAFE_PARCEL(output.writeByte, frameRateSelectionStrategy);
    SAFE_PARCEL(output.writeUint32, fixedTransformHint);
    SAFE_PARCEL(output.writeBool, autoRefresh);
    SAFE_PARCEL(output.writeBool, dimmingEnabled);
@@ -293,6 +295,7 @@ status_t layer_state_t::read(const Parcel& input)
    SAFE_PARCEL(input.readByte, &changeFrameRateStrategy);
    SAFE_PARCEL(input.readByte, &defaultFrameRateCompatibility);
    SAFE_PARCEL(input.readByte, &frameRateCategory);
    SAFE_PARCEL(input.readByte, &frameRateSelectionStrategy);
    SAFE_PARCEL(input.readUint32, &tmpUint32);
    fixedTransformHint = static_cast<ui::Transform::RotationFlags>(tmpUint32);
    SAFE_PARCEL(input.readBool, &autoRefresh);
@@ -666,6 +669,10 @@ void layer_state_t::merge(const layer_state_t& other) {
        what |= eFrameRateCategoryChanged;
        frameRateCategory = other.frameRateCategory;
    }
    if (other.what & eFrameRateSelectionStrategyChanged) {
        what |= eFrameRateSelectionStrategyChanged;
        frameRateSelectionStrategy = other.frameRateSelectionStrategy;
    }
    if (other.what & eFixedTransformHintChanged) {
        what |= eFixedTransformHintChanged;
        fixedTransformHint = other.fixedTransformHint;
@@ -777,6 +784,7 @@ uint64_t layer_state_t::diff(const layer_state_t& other) const {
    CHECK_DIFF3(diff, eFrameRateChanged, other, frameRate, frameRateCompatibility,
                changeFrameRateStrategy);
    CHECK_DIFF(diff, eFrameRateCategoryChanged, other, frameRateCategory);
    CHECK_DIFF(diff, eFrameRateSelectionStrategyChanged, other, frameRateSelectionStrategy);
    CHECK_DIFF(diff, eFixedTransformHintChanged, other, fixedTransformHint);
    CHECK_DIFF(diff, eAutoRefreshChanged, other, autoRefresh);
    CHECK_DIFF(diff, eTrustedOverlayChanged, other, isTrustedOverlay);
+13 −0
Original line number Diff line number Diff line
@@ -2104,6 +2104,19 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setFrame
    return *this;
}

SurfaceComposerClient::Transaction&
SurfaceComposerClient::Transaction::setFrameRateSelectionStrategy(const sp<SurfaceControl>& sc,
                                                                  int8_t strategy) {
    layer_state_t* s = getLayerState(sc);
    if (!s) {
        mStatus = BAD_INDEX;
        return *this;
    }
    s->what |= layer_state_t::eFrameRateSelectionStrategyChanged;
    s->frameRateSelectionStrategy = strategy;
    return *this;
}

SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setFixedTransformHint(
        const sp<SurfaceControl>& sc, int32_t fixedTransformHint) {
    layer_state_t* s = getLayerState(sc);
+5 −1
Original line number Diff line number Diff line
@@ -197,7 +197,7 @@ struct layer_state_t {
        eInputInfoChanged = 0x40000000,
        eCornerRadiusChanged = 0x80000000,
        eDestinationFrameChanged = 0x1'00000000,
        /* unused = 0x2'00000000, */
        eFrameRateSelectionStrategyChanged = 0x2'00000000,
        eBackgroundColorChanged = 0x4'00000000,
        eMetadataChanged = 0x8'00000000,
        eColorSpaceAgnosticChanged = 0x10'00000000,
@@ -268,6 +268,7 @@ struct layer_state_t {
            layer_state_t::eColorTransformChanged | layer_state_t::eCornerRadiusChanged |
            layer_state_t::eFlagsChanged | layer_state_t::eTrustedOverlayChanged |
            layer_state_t::eFrameRateChanged | layer_state_t::eFrameRateCategoryChanged |
            layer_state_t::eFrameRateSelectionStrategyChanged |
            layer_state_t::eFrameRateSelectionPriority | layer_state_t::eFixedTransformHintChanged;

    // Changes affecting data sent to input.
@@ -361,6 +362,9 @@ struct layer_state_t {
    // Frame rate category to suggest what frame rate range a surface should run.
    int8_t frameRateCategory;

    // Strategy of the layer for frame rate selection.
    int8_t frameRateSelectionStrategy;

    // Set by window manager indicating the layer and all its children are
    // in a different orientation than the display. The hint suggests that
    // the graphic producers should receive a transform hint as if the
+2 −0
Original line number Diff line number Diff line
@@ -687,6 +687,8 @@ public:

        Transaction& setFrameRateCategory(const sp<SurfaceControl>& sc, int8_t category);

        Transaction& setFrameRateSelectionStrategy(const sp<SurfaceControl>& sc, int8_t strategy);

        // Set by window manager indicating the layer and all its children are
        // in a different orientation than the display. The hint suggests that
        // the graphic producers should receive a transform hint as if the
+20 −0
Original line number Diff line number Diff line
@@ -1096,6 +1096,26 @@ enum {
    ANATIVEWINDOW_FRAME_RATE_CATEGORY_HIGH = 4
};

/*
 * Frame rate selection strategy values that can be used in
 * Transaction::setFrameRateSelectionStrategy.
 */
enum {
    /**
     * Default value. The layer uses its own frame rate specifications, assuming it has any
     * specifications, instead of its parent's.
     */
    ANATIVEWINDOW_FRAME_RATE_SELECTION_STRATEGY_SELF = 0,

    /**
     * The layer's frame rate specifications will propagate to and override those of its descendant
     * layers.
     * The layer with this strategy has the ANATIVEWINDOW_FRAME_RATE_SELECTION_STRATEGY_SELF
     * behavior for itself.
     */
    ANATIVEWINDOW_FRAME_RATE_SELECTION_STRATEGY_OVERRIDE_CHILDREN = 1,
};

static inline int native_window_set_frame_rate(struct ANativeWindow* window, float frameRate,
                                        int8_t compatibility, int8_t changeFrameRateStrategy) {
    return window->perform(window, NATIVE_WINDOW_SET_FRAME_RATE, (double)frameRate,
Loading