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

Commit 096227e9 authored by Andy Labrada's avatar Andy Labrada
Browse files

SurfaceFlinger: Remove usage of window types to implement policy

Native side for a new API, setFrameRateDefault, where policy implementation logic is made using setFrameRateDefault instead of checking window types. To test the implementation of this API, SurfaceFlinger property use_content_detection_for_refresh_rate should be set to 1.

Bug: 192291754
Test: atest LayerHistoryTest
Test: added logs and verified status bar window gets no vote, wallpaper gets min vote and other windows get heuristic vote when use_content_detection_for_refresh_rate is set to 1

Change-Id: I736ac1bd82644b1fd8164f3be33f086934d27487
parent 4aa4d392
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ layer_state_t::layer_state_t()
        frameRate(0.0f),
        frameRateCompatibility(ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT),
        changeFrameRateStrategy(ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS),
        defaultFrameRateCompatibility(ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT),
        fixedTransformHint(ui::Transform::ROT_INVALID),
        autoRefresh(false),
        isTrustedOverlay(false),
@@ -137,6 +138,7 @@ status_t layer_state_t::write(Parcel& output) const
    SAFE_PARCEL(output.writeFloat, frameRate);
    SAFE_PARCEL(output.writeByte, frameRateCompatibility);
    SAFE_PARCEL(output.writeByte, changeFrameRateStrategy);
    SAFE_PARCEL(output.writeByte, defaultFrameRateCompatibility);
    SAFE_PARCEL(output.writeUint32, fixedTransformHint);
    SAFE_PARCEL(output.writeBool, autoRefresh);
    SAFE_PARCEL(output.writeBool, dimmingEnabled);
@@ -257,6 +259,7 @@ status_t layer_state_t::read(const Parcel& input)
    SAFE_PARCEL(input.readFloat, &frameRate);
    SAFE_PARCEL(input.readByte, &frameRateCompatibility);
    SAFE_PARCEL(input.readByte, &changeFrameRateStrategy);
    SAFE_PARCEL(input.readByte, &defaultFrameRateCompatibility);
    SAFE_PARCEL(input.readUint32, &tmpUint32);
    fixedTransformHint = static_cast<ui::Transform::RotationFlags>(tmpUint32);
    SAFE_PARCEL(input.readBool, &autoRefresh);
@@ -573,6 +576,10 @@ void layer_state_t::merge(const layer_state_t& other) {
        borderWidth = other.borderWidth;
        borderColor = other.borderColor;
    }
    if (other.what & eDefaultFrameRateCompatibilityChanged) {
        what |= eDefaultFrameRateCompatibilityChanged;
        defaultFrameRateCompatibility = other.defaultFrameRateCompatibility;
    }
    if (other.what & eFrameRateSelectionPriority) {
        what |= eFrameRateSelectionPriority;
        frameRateSelectionPriority = other.frameRateSelectionPriority;
+13 −0
Original line number Diff line number Diff line
@@ -1841,6 +1841,19 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setFrame
    return *this;
}

SurfaceComposerClient::Transaction&
SurfaceComposerClient::Transaction::setDefaultFrameRateCompatibility(const sp<SurfaceControl>& sc,
                                                                     int8_t compatibility) {
    layer_state_t* s = getLayerState(sc);
    if (!s) {
        mStatus = BAD_INDEX;
        return *this;
    }
    s->what |= layer_state_t::eDefaultFrameRateCompatibilityChanged;
    s->defaultFrameRateCompatibility = compatibility;
    return *this;
}

SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setFixedTransformHint(
        const sp<SurfaceControl>& sc, int32_t fixedTransformHint) {
    layer_state_t* s = getLayerState(sc);
+4 −1
Original line number Diff line number Diff line
@@ -165,7 +165,7 @@ struct layer_state_t {
        eTransformToDisplayInverseChanged = 0x00080000,
        eCropChanged = 0x00100000,
        eBufferChanged = 0x00200000,
        /* unused 0x00400000, */
        eDefaultFrameRateCompatibilityChanged = 0x00400000,
        eDataspaceChanged = 0x00800000,
        eHdrMetadataChanged = 0x01000000,
        eSurfaceDamageRegionChanged = 0x02000000,
@@ -275,6 +275,9 @@ struct layer_state_t {
    int8_t frameRateCompatibility;
    int8_t changeFrameRateStrategy;

    // Default frame rate compatibility used to set the layer refresh rate votetype.
    int8_t defaultFrameRateCompatibility;

    // 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
+3 −0
Original line number Diff line number Diff line
@@ -583,6 +583,9 @@ public:
        Transaction& setFrameRate(const sp<SurfaceControl>& sc, float frameRate,
                                  int8_t compatibility, int8_t changeFrameRateStrategy);

        Transaction& setDefaultFrameRateCompatibility(const sp<SurfaceControl>& sc,
                                                      int8_t compatibility);

        // 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
+5 −0
Original line number Diff line number Diff line
@@ -1034,6 +1034,11 @@ enum {
     * This surface is ignored while choosing the refresh rate.
     */
    ANATIVEWINDOW_FRAME_RATE_NO_VOTE,

    /**
     * This surface will vote for the minimum refresh rate.
     */
    ANATIVEWINDOW_FRAME_RATE_MIN
};

static inline int native_window_set_frame_rate(struct ANativeWindow* window, float frameRate,
Loading