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

Commit 8c2703df authored by Andy Yu's avatar Andy Yu
Browse files

Refactor game-related frame rate override to LayerHistory

Previously game-related frame rate overrides are maintained in Scheduler
only, which does not provide votes to the actual display refresh rate.
This causes an issue that these overrides will only be viable when they
are the divisors of the display refresh rate at the moment.

This change moves the game intervention and newly-added game default
frame rate overrides to LayerHistory, where overrides will be considered
in layer frame rate votes. Scheduler will get this information and
select the display frame rate accordingly

Bug: 286084594
Test: SurfaceFlinger unit test
      atest LayerHistoryTest
      atest FrameRateOverrideMappingsTest
      atest CtsGraphicsTestCases --test-filter "SetFrameRateTest*"
      atest CtsFrameRateOverrideTestCases
Change-Id: I9957af8e53fbdd44b8d70028572e6db8e779a1fe
parent 926dbea7
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -2782,9 +2782,16 @@ status_t SurfaceComposerClient::getHdrOutputConversionSupport(bool* isSupported)
    return statusTFromBinderStatus(status);
}

status_t SurfaceComposerClient::setOverrideFrameRate(uid_t uid, float frameRate) {
status_t SurfaceComposerClient::setGameModeFrameRateOverride(uid_t uid, float frameRate) {
    binder::Status status =
            ComposerServiceAIDL::getComposerService()->setOverrideFrameRate(uid, frameRate);
            ComposerServiceAIDL::getComposerService()->setGameModeFrameRateOverride(uid, frameRate);
    return statusTFromBinderStatus(status);
}

status_t SurfaceComposerClient::setGameDefaultFrameRateOverride(uid_t uid, float frameRate) {
    binder::Status status =
            ComposerServiceAIDL::getComposerService()->setGameDefaultFrameRateOverride(uid,
                                                                                       frameRate);
    return statusTFromBinderStatus(status);
}

+12 −1
Original line number Diff line number Diff line
@@ -477,10 +477,21 @@ interface ISurfaceComposer {

    /**
     * Set the override frame rate for a specified uid by GameManagerService.
     * This override is controlled by game mode interventions.
     * Passing the frame rate and uid to SurfaceFlinger to update the override mapping
     * in the LayerHistory.
     */
    void setGameModeFrameRateOverride(int uid, float frameRate);

    /**
     * Set the override frame rate for a specified uid by GameManagerService.
     * This override is controlled by game default frame rate sysprop:
     * "ro.surface_flinger.game_default_frame_rate_override" holding the override value,
     * "persisit.graphics.game_default_frame_rate.enabled" to determine if it's enabled.
     * Passing the frame rate and uid to SurfaceFlinger to update the override mapping
     * in the scheduler.
     */
    void setOverrideFrameRate(int uid, float frameRate);
    void setGameDefaultFrameRateOverride(int uid, float frameRate);

    oneway void updateSmallAreaDetection(in int[] appIds, in float[] thresholds);

+2 −1
Original line number Diff line number Diff line
@@ -149,7 +149,8 @@ public:
                (const gui::Color&, const gui::Color&, float, float, float), (override));
    MOCK_METHOD(binder::Status, getDisplayDecorationSupport,
                (const sp<IBinder>&, std::optional<gui::DisplayDecorationSupport>*), (override));
    MOCK_METHOD(binder::Status, setOverrideFrameRate, (int32_t, float), (override));
    MOCK_METHOD(binder::Status, setGameModeFrameRateOverride, (int32_t, float), (override));
    MOCK_METHOD(binder::Status, setGameDefaultFrameRateOverride, (int32_t, float), (override));
    MOCK_METHOD(binder::Status, enableRefreshRateOverlay, (bool), (override));
    MOCK_METHOD(binder::Status, setDebugFlash, (int), (override));
    MOCK_METHOD(binder::Status, scheduleComposite, (), (override));
+7 −1
Original line number Diff line number Diff line
@@ -201,7 +201,13 @@ public:

    // Sets the frame rate of a particular app (uid). This is currently called
    // by GameManager.
    static status_t setOverrideFrameRate(uid_t uid, float frameRate);
    static status_t setGameModeFrameRateOverride(uid_t uid, float frameRate);

    // Sets the frame rate of a particular app (uid). This is currently called
    // by GameManager and controlled by two sysprops:
    // "ro.surface_flinger.game_default_frame_rate_override" holding the override value,
    // "persisit.graphics.game_default_frame_rate.enabled" to determine if it's enabled.
    static status_t setGameDefaultFrameRateOverride(uid_t uid, float frameRate);

    // Update the small area detection whole appId-threshold mappings by same size appId and
    // threshold vector.
+5 −1
Original line number Diff line number Diff line
@@ -921,7 +921,11 @@ public:
        return binder::Status::ok();
    }

    binder::Status setOverrideFrameRate(int32_t /*uid*/, float /*frameRate*/) override {
    binder::Status setGameModeFrameRateOverride(int32_t /*uid*/, float /*frameRate*/) override {
        return binder::Status::ok();
    }

    binder::Status setGameDefaultFrameRateOverride(int32_t /*uid*/, float /*frameRate*/) override {
        return binder::Status::ok();
    }

Loading