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

Commit 1768cb03 authored by Huihong Luo's avatar Huihong Luo
Browse files

Variable refresh rate for virtual display

Allow virtual display to request a refresh rate, so it can be different
from VSYNC frequencies. SurfaceFlinger drops frames for the
corresponding virtual display based on the refresh rate.

Bug: 241286579
Test: atest libgui_test libsurfaceflinger_unittest SurfaceFlinger_test
Change-Id: I4fba0e553618bb4c7333514b16206ae4277acf72
parent 67011ef8
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -1182,12 +1182,14 @@ void SurfaceComposerClient::Transaction::setDefaultApplyToken(sp<IBinder> applyT
}
// ---------------------------------------------------------------------------

sp<IBinder> SurfaceComposerClient::createDisplay(const String8& displayName, bool secure) {
sp<IBinder> SurfaceComposerClient::createDisplay(const String8& displayName, bool secure,
                                                 float requestedRefereshRate) {
    sp<IBinder> display = nullptr;
    binder::Status status =
            ComposerServiceAIDL::getComposerService()->createDisplay(std::string(
                                                                             displayName.string()),
                                                                     secure, &display);
                                                                     secure, requestedRefereshRate,
                                                                     &display);
    return status.isOk() ? display : nullptr;
}

+13 −1
Original line number Diff line number Diff line
@@ -79,9 +79,21 @@ interface ISurfaceComposer {

    /**
     * Create a virtual display
     *
     * displayName
     *     The name of the virtual display
     * secure
     *     Whether this virtual display is secure
     * requestedRefreshRate
     *     The refresh rate, frames per second, to request on the virtual display.
     *     This is just a request, the actual rate may be adjusted to align well
     *     with physical displays running concurrently. If 0 is specified, the
     *     virtual display is refreshed at the physical display refresh rate.
     *
     * requires ACCESS_SURFACE_FLINGER permission.
     */
    @nullable IBinder createDisplay(@utf8InCpp String displayName, boolean secure);
    @nullable IBinder createDisplay(@utf8InCpp String displayName, boolean secure,
            float requestedRefreshRate);

    /**
     * Destroy a virtual display
+1 −1
Original line number Diff line number Diff line
@@ -67,7 +67,7 @@ public:
                 sp<gui::IDisplayEventConnection>*),
                (override));
    MOCK_METHOD(binder::Status, createConnection, (sp<gui::ISurfaceComposerClient>*), (override));
    MOCK_METHOD(binder::Status, createDisplay, (const std::string&, bool, sp<IBinder>*),
    MOCK_METHOD(binder::Status, createDisplay, (const std::string&, bool, float, sp<IBinder>*),
                (override));
    MOCK_METHOD(binder::Status, destroyDisplay, (const sp<IBinder>&), (override));
    MOCK_METHOD(binder::Status, getPhysicalDisplayIds, (std::vector<int64_t>*), (override));
+2 −1
Original line number Diff line number Diff line
@@ -355,7 +355,8 @@ public:
    sp<SurfaceControl> mirrorDisplay(DisplayId displayId);

    //! Create a virtual display
    static sp<IBinder> createDisplay(const String8& displayName, bool secure);
    static sp<IBinder> createDisplay(const String8& displayName, bool secure,
                                     float requestedRefereshRate = 0);

    //! Destroy a virtual display
    static void destroyDisplay(const sp<IBinder>& display);
+1 −0
Original line number Diff line number Diff line
@@ -736,6 +736,7 @@ public:
    }

    binder::Status createDisplay(const std::string& /*displayName*/, bool /*secure*/,
                                 float /*requestedRefreshRate*/,
                                 sp<IBinder>* /*outDisplay*/) override {
        return binder::Status::ok();
    }
Loading