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

Commit 2ae6b6bc authored by Andy Yu's avatar Andy Yu
Browse files

Implement game mode framerate override

Add logic for setting throttling framerate requested
by Game Dashboard interventions.

- Refactored of FrameRateOverrideMappings in Scheduler
- Have mSupportsFrameRateOverride only guard mFrameRateOverrideByContent
- Remove logic that disables framerate override when it's not a divider

Bug: b/204322816
Test: atest FrameRateOverrideHostTest

Change-Id: I1a2caf378cd87ce4830f6fc48332b5df518330cc
parent 338ee42d
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -1346,6 +1346,21 @@ public:
        SAFE_PARCEL(data.writeStrongBinder, IInterface::asBinder(windowInfosListener));
        return remote()->transact(BnSurfaceComposer::REMOVE_WINDOW_INFOS_LISTENER, data, &reply);
    }

    status_t setOverrideFrameRate(uid_t uid, float frameRate) override {
        Parcel data, reply;
        SAFE_PARCEL(data.writeInterfaceToken, ISurfaceComposer::getInterfaceDescriptor());
        SAFE_PARCEL(data.writeUint32, uid);
        SAFE_PARCEL(data.writeFloat, frameRate);

        status_t err = remote()->transact(BnSurfaceComposer::SET_OVERRIDE_FRAME_RATE, data, &reply);
        if (err != NO_ERROR) {
            ALOGE("setOverrideFrameRate: failed to transact %s (%d)", strerror(-err), err);
            return err;
        }

        return NO_ERROR;
    }
};

// Out-of-line virtual method definition to trigger vtable emission in this
@@ -2306,6 +2321,17 @@ status_t BnSurfaceComposer::onTransact(

            return removeWindowInfosListener(listener);
        }
        case SET_OVERRIDE_FRAME_RATE: {
            CHECK_INTERFACE(ISurfaceComposer, data, reply);

            uid_t uid;
            SAFE_PARCEL(data.readUint32, &uid);

            float frameRate;
            SAFE_PARCEL(data.readFloat, &frameRate);

            return setOverrideFrameRate(uid, frameRate);
        }
        default: {
            return BBinder::onTransact(code, data, reply, flags);
        }
+4 −0
Original line number Diff line number Diff line
@@ -2094,6 +2094,10 @@ status_t SurfaceComposerClient::getPreferredBootDisplayMode(const sp<IBinder>& d
                                                                              displayModeId);
}

status_t SurfaceComposerClient::setOverrideFrameRate(uid_t uid, float frameRate) {
    return ComposerService::getComposerService()->setOverrideFrameRate(uid, frameRate);
}

void SurfaceComposerClient::setAutoLowLatencyMode(const sp<IBinder>& display, bool on) {
    ComposerService::getComposerService()->setAutoLowLatencyMode(display, on);
}
+8 −0
Original line number Diff line number Diff line
@@ -558,6 +558,13 @@ public:
    virtual status_t setFrameRate(const sp<IGraphicBufferProducer>& surface, float frameRate,
                                  int8_t compatibility, int8_t changeFrameRateStrategy) = 0;

    /*
     * Set the override frame rate for a specified uid by GameManagerService.
     * Passing the frame rate and uid to SurfaceFlinger to update the override mapping
     * in the scheduler.
     */
    virtual status_t setOverrideFrameRate(uid_t uid, float frameRate) = 0;

    /*
     * Sets the frame timeline vsync info received from choreographer that corresponds to next
     * buffer submitted on that surface.
@@ -678,6 +685,7 @@ public:
        SET_BOOT_DISPLAY_MODE,
        CLEAR_BOOT_DISPLAY_MODE,
        GET_PREFERRED_BOOT_DISPLAY_MODE,
        SET_OVERRIDE_FRAME_RATE,
        // Always append new enum to the end.
    };

+4 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@

#include <binder/IBinder.h>

#include <utils/Errors.h>
#include <utils/RefBase.h>
#include <utils/Singleton.h>
#include <utils/SortedVector.h>
@@ -175,6 +176,9 @@ public:
    static status_t clearBootDisplayMode(const sp<IBinder>& display);
    // Gets the display mode in which the device boots if there is no user-preferred display mode
    static status_t getPreferredBootDisplayMode(const sp<IBinder>& display, ui::DisplayModeId*);
    // Sets the frame rate of a particular app (uid). This is currently called
    // by GameManager.
    static status_t setOverrideFrameRate(uid_t uid, float frameRate);

    // Switches on/off Auto Low Latency Mode on the connected display. This should only be
    // called if the connected display supports Auto Low Latency Mode as reported by
+4 −0
Original line number Diff line number Diff line
@@ -31,9 +31,11 @@
#include <gui/SyncScreenCaptureListener.h>
#include <inttypes.h>
#include <private/gui/ComposerService.h>
#include <sys/types.h>
#include <ui/BufferQueueDefs.h>
#include <ui/DisplayMode.h>
#include <ui/Rect.h>
#include <utils/Errors.h>
#include <utils/String8.h>

#include <limits>
@@ -925,6 +927,8 @@ public:
        return NO_ERROR;
    }

    status_t setOverrideFrameRate(uid_t /*uid*/, float /*frameRate*/) override { return NO_ERROR; }

protected:
    IBinder* onAsBinder() override { return nullptr; }

Loading