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

Commit b1e2f8de authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Properly run window animations at vsync-sf (2/2)

- Add new Choreographer instance that runs on vsync-sf
- Use this new Choreographer for WindowAnimator, and remove all
the hacks around it

Test: Open apps and close apps, notice no stutter
Test: Screen zoom animations
Test: go/wm-smoke
Bug: 36631902
Change-Id: I72a8b39709303a38fc077100229b8a81a153ba3e
parent b5a1f50f
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
#include <utils/Timers.h>

#include <binder/IInterface.h>
#include <gui/ISurfaceComposer.h>

// ----------------------------------------------------------------------------

@@ -83,7 +84,8 @@ public:
     * or requestNextVsync to receive them.
     * Other events start being delivered immediately.
     */
    DisplayEventReceiver();
    DisplayEventReceiver(
            ISurfaceComposer::VsyncSource vsyncSource = ISurfaceComposer::eVsyncSourceApp);

    /*
     * ~DisplayEventReceiver severs the connection with SurfaceFlinger, new events
+7 −1
Original line number Diff line number Diff line
@@ -72,6 +72,11 @@ public:
        eRotate270  = 3
    };

    enum VsyncSource {
        eVsyncSourceApp = 0,
        eVsyncSourceSurfaceFlinger = 1
    };

    /* create connection with surface flinger, requires
     * ACCESS_SURFACE_FLINGER permission
     */
@@ -89,7 +94,8 @@ public:
            const sp<IGraphicBufferProducer>& parent) = 0;

    /* return an IDisplayEventConnection */
    virtual sp<IDisplayEventConnection> createDisplayEventConnection() = 0;
    virtual sp<IDisplayEventConnection> createDisplayEventConnection(
            VsyncSource vsyncSource = eVsyncSourceApp) = 0;

    /* create a virtual display
     * requires ACCESS_SURFACE_FLINGER permission.
+2 −2
Original line number Diff line number Diff line
@@ -32,10 +32,10 @@ namespace android {

// ---------------------------------------------------------------------------

DisplayEventReceiver::DisplayEventReceiver() {
DisplayEventReceiver::DisplayEventReceiver(ISurfaceComposer::VsyncSource vsyncSource) {
    sp<ISurfaceComposer> sf(ComposerService::getComposerService());
    if (sf != NULL) {
        mEventConnection = sf->createDisplayEventConnection();
        mEventConnection = sf->createDisplayEventConnection(vsyncSource);
        if (mEventConnection != NULL) {
            mDataChannel = std::make_unique<gui::BitTube>();
            mEventConnection->stealReceiveChannel(mDataChannel.get());
+4 −2
Original line number Diff line number Diff line
@@ -201,7 +201,7 @@ public:
        return NO_ERROR;
    }

    virtual sp<IDisplayEventConnection> createDisplayEventConnection()
    virtual sp<IDisplayEventConnection> createDisplayEventConnection(VsyncSource vsyncSource)
    {
        Parcel data, reply;
        sp<IDisplayEventConnection> result;
@@ -210,6 +210,7 @@ public:
        if (err != NO_ERROR) {
            return result;
        }
        data.writeInt32(static_cast<int32_t>(vsyncSource));
        err = remote()->transact(
                BnSurfaceComposer::CREATE_DISPLAY_EVENT_CONNECTION,
                data, &reply);
@@ -586,7 +587,8 @@ status_t BnSurfaceComposer::onTransact(
        }
        case CREATE_DISPLAY_EVENT_CONNECTION: {
            CHECK_INTERFACE(ISurfaceComposer, data, reply);
            sp<IDisplayEventConnection> connection(createDisplayEventConnection());
            sp<IDisplayEventConnection> connection(createDisplayEventConnection(
                    static_cast<ISurfaceComposer::VsyncSource>(data.readInt32())));
            reply->writeStrongBinder(IInterface::asBinder(connection));
            return NO_ERROR;
        }
+2 −1
Original line number Diff line number Diff line
@@ -465,7 +465,8 @@ public:
            const sp<IGraphicBufferProducer>& /* parent */) override {
        return nullptr;
    }
    sp<IDisplayEventConnection> createDisplayEventConnection() override {
    sp<IDisplayEventConnection> createDisplayEventConnection(ISurfaceComposer::VsyncSource)
            override {
        return nullptr;
    }
    sp<IBinder> createDisplay(const String8& /*displayName*/,
Loading