From: Jorim Jaggi Date: Thu, 8 Jun 2017 22:43:59 +0000 (-0700) Subject: Properly run window animations at vsync-sf (2/2) X-Git-Tag: android-x86-8.1-r1~35^2^2~2^2~22 X-Git-Url: http://git.osdn.net/view?p=android-x86%2Fframeworks-native.git;a=commitdiff_plain;h=b1e2f8deb38353e4bcc9d3ef06bc15bd5e417425 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 --- diff --git a/include/gui/DisplayEventReceiver.h b/include/gui/DisplayEventReceiver.h index 9557b4f967..32ce59a765 100644 --- a/include/gui/DisplayEventReceiver.h +++ b/include/gui/DisplayEventReceiver.h @@ -25,6 +25,7 @@ #include #include +#include // ---------------------------------------------------------------------------- @@ -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 diff --git a/include/gui/ISurfaceComposer.h b/include/gui/ISurfaceComposer.h index 1112973587..f80ba000b4 100644 --- a/include/gui/ISurfaceComposer.h +++ b/include/gui/ISurfaceComposer.h @@ -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& parent) = 0; /* return an IDisplayEventConnection */ - virtual sp createDisplayEventConnection() = 0; + virtual sp createDisplayEventConnection( + VsyncSource vsyncSource = eVsyncSourceApp) = 0; /* create a virtual display * requires ACCESS_SURFACE_FLINGER permission. diff --git a/libs/gui/DisplayEventReceiver.cpp b/libs/gui/DisplayEventReceiver.cpp index 1507d51fca..1757ec1cd3 100644 --- a/libs/gui/DisplayEventReceiver.cpp +++ b/libs/gui/DisplayEventReceiver.cpp @@ -32,10 +32,10 @@ namespace android { // --------------------------------------------------------------------------- -DisplayEventReceiver::DisplayEventReceiver() { +DisplayEventReceiver::DisplayEventReceiver(ISurfaceComposer::VsyncSource vsyncSource) { sp sf(ComposerService::getComposerService()); if (sf != NULL) { - mEventConnection = sf->createDisplayEventConnection(); + mEventConnection = sf->createDisplayEventConnection(vsyncSource); if (mEventConnection != NULL) { mDataChannel = std::make_unique(); mEventConnection->stealReceiveChannel(mDataChannel.get()); diff --git a/libs/gui/ISurfaceComposer.cpp b/libs/gui/ISurfaceComposer.cpp index 2516fb8a2d..0a0d112af6 100644 --- a/libs/gui/ISurfaceComposer.cpp +++ b/libs/gui/ISurfaceComposer.cpp @@ -201,7 +201,7 @@ public: return NO_ERROR; } - virtual sp createDisplayEventConnection() + virtual sp createDisplayEventConnection(VsyncSource vsyncSource) { Parcel data, reply; sp result; @@ -210,6 +210,7 @@ public: if (err != NO_ERROR) { return result; } + data.writeInt32(static_cast(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 connection(createDisplayEventConnection()); + sp connection(createDisplayEventConnection( + static_cast(data.readInt32()))); reply->writeStrongBinder(IInterface::asBinder(connection)); return NO_ERROR; } diff --git a/libs/gui/tests/Surface_test.cpp b/libs/gui/tests/Surface_test.cpp index 81820def1c..e18af17bde 100644 --- a/libs/gui/tests/Surface_test.cpp +++ b/libs/gui/tests/Surface_test.cpp @@ -465,7 +465,8 @@ public: const sp& /* parent */) override { return nullptr; } - sp createDisplayEventConnection() override { + sp createDisplayEventConnection(ISurfaceComposer::VsyncSource) + override { return nullptr; } sp createDisplay(const String8& /*displayName*/, diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 801e8ddf4d..a49e8f4aa8 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -1024,8 +1024,13 @@ status_t SurfaceFlinger::injectVSync(nsecs_t when) { // ---------------------------------------------------------------------------- -sp SurfaceFlinger::createDisplayEventConnection() { - return mEventThread->createEventConnection(); +sp SurfaceFlinger::createDisplayEventConnection( + ISurfaceComposer::VsyncSource vsyncSource) { + if (vsyncSource == eVsyncSourceSurfaceFlinger) { + return mSFEventThread->createEventConnection(); + } else { + return mEventThread->createEventConnection(); + } } // ---------------------------------------------------------------------------- diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index 1bc689dc79..c89e26f798 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -277,7 +277,8 @@ private: const sp& bufferProducer) const; virtual status_t getSupportedFrameTimestamps( std::vector* outSupported) const; - virtual sp createDisplayEventConnection(); + virtual sp createDisplayEventConnection( + ISurfaceComposer::VsyncSource vsyncSource = eVsyncSourceApp); virtual status_t captureScreen(const sp& display, const sp& producer, Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,