Loading libs/gui/DisplayEventDispatcher.cpp +8 −5 Original line number Diff line number Diff line Loading @@ -35,11 +35,14 @@ static const size_t EVENT_BUFFER_SIZE = 100; static constexpr nsecs_t WAITING_FOR_VSYNC_TIMEOUT = ms2ns(300); DisplayEventDispatcher::DisplayEventDispatcher( const sp<Looper>& looper, ISurfaceComposer::VsyncSource vsyncSource, ISurfaceComposer::EventRegistrationFlags eventRegistration) : mLooper(looper), mReceiver(vsyncSource, eventRegistration), mWaitingForVsync(false), mLastVsyncCount(0), mLastScheduleVsyncTime(0) { DisplayEventDispatcher::DisplayEventDispatcher(const sp<Looper>& looper, gui::ISurfaceComposer::VsyncSource vsyncSource, EventRegistrationFlags eventRegistration) : mLooper(looper), mReceiver(vsyncSource, eventRegistration), mWaitingForVsync(false), mLastVsyncCount(0), mLastScheduleVsyncTime(0) { ALOGV("dispatcher %p ~ Initializing display event dispatcher.", this); } Loading libs/gui/DisplayEventReceiver.cpp +12 −8 Original line number Diff line number Diff line Loading @@ -19,10 +19,9 @@ #include <utils/Errors.h> #include <gui/DisplayEventReceiver.h> #include <gui/ISurfaceComposer.h> #include <gui/VsyncEventData.h> #include <private/gui/ComposerService.h> #include <private/gui/ComposerServiceAIDL.h> #include <private/gui/BitTube.h> Loading @@ -32,15 +31,20 @@ namespace android { // --------------------------------------------------------------------------- DisplayEventReceiver::DisplayEventReceiver( ISurfaceComposer::VsyncSource vsyncSource, ISurfaceComposer::EventRegistrationFlags eventRegistration) { sp<ISurfaceComposer> sf(ComposerService::getComposerService()); DisplayEventReceiver::DisplayEventReceiver(gui::ISurfaceComposer::VsyncSource vsyncSource, EventRegistrationFlags eventRegistration) { sp<gui::ISurfaceComposer> sf(ComposerServiceAIDL::getComposerService()); if (sf != nullptr) { mEventConnection = sf->createDisplayEventConnection(vsyncSource, eventRegistration); mEventConnection = nullptr; binder::Status status = sf->createDisplayEventConnection(vsyncSource, static_cast< gui::ISurfaceComposer::EventRegistration>( eventRegistration.get()), &mEventConnection); if (mEventConnection != nullptr) { mDataChannel = std::make_unique<gui::BitTube>(); const auto status = mEventConnection->stealReceiveChannel(mDataChannel.get()); status = mEventConnection->stealReceiveChannel(mDataChannel.get()); if (!status.isOk()) { ALOGE("stealReceiveChannel failed: %s", status.toString8().c_str()); mInitError = std::make_optional<status_t>(status.transactionError()); Loading libs/gui/ISurfaceComposer.cpp +0 −45 Original line number Diff line number Diff line Loading @@ -108,35 +108,6 @@ public: data, &reply); } } void bootFinished() override { Parcel data, reply; data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); remote()->transact(BnSurfaceComposer::BOOT_FINISHED, data, &reply); } sp<IDisplayEventConnection> createDisplayEventConnection( VsyncSource vsyncSource, EventRegistrationFlags eventRegistration) override { Parcel data, reply; sp<IDisplayEventConnection> result; int err = data.writeInterfaceToken( ISurfaceComposer::getInterfaceDescriptor()); if (err != NO_ERROR) { return result; } data.writeInt32(static_cast<int32_t>(vsyncSource)); data.writeUint32(eventRegistration.get()); err = remote()->transact( BnSurfaceComposer::CREATE_DISPLAY_EVENT_CONNECTION, data, &reply); if (err != NO_ERROR) { ALOGE("ISurfaceComposer::createDisplayEventConnection: error performing " "transaction: %s (%d)", strerror(-err), -err); return result; } result = interface_cast<IDisplayEventConnection>(reply.readStrongBinder()); return result; } }; // Out-of-line virtual method definition to trigger vtable emission in this Loading Loading @@ -215,22 +186,6 @@ status_t BnSurfaceComposer::onTransact( uncachedBuffer, hasListenerCallbacks, listenerCallbacks, transactionId); } case BOOT_FINISHED: { CHECK_INTERFACE(ISurfaceComposer, data, reply); bootFinished(); return NO_ERROR; } case CREATE_DISPLAY_EVENT_CONNECTION: { CHECK_INTERFACE(ISurfaceComposer, data, reply); auto vsyncSource = static_cast<ISurfaceComposer::VsyncSource>(data.readInt32()); EventRegistrationFlags eventRegistration = static_cast<EventRegistration>(data.readUint32()); sp<IDisplayEventConnection> connection( createDisplayEventConnection(vsyncSource, eventRegistration)); reply->writeStrongBinder(IInterface::asBinder(connection)); return NO_ERROR; } default: { return BBinder::onTransact(code, data, reply, flags); } Loading libs/gui/aidl/android/gui/ISurfaceComposer.aidl +25 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import android.gui.DisplayStatInfo; import android.gui.DynamicDisplayInfo; import android.gui.FrameEvent; import android.gui.FrameStats; import android.gui.IDisplayEventConnection; import android.gui.IFpsListener; import android.gui.IHdrLayerInfoListener; import android.gui.IRegionSamplingListener; Loading @@ -47,6 +48,30 @@ import android.gui.StaticDisplayInfo; /** @hide */ interface ISurfaceComposer { enum VsyncSource { eVsyncSourceApp = 0, eVsyncSourceSurfaceFlinger = 1 } enum EventRegistration { modeChanged = 1 << 0, frameRateOverride = 1 << 1, } /** * Signal that we're done booting. * Requires ACCESS_SURFACE_FLINGER permission */ // Note this must be the 1st method, so IBinder::FIRST_CALL_TRANSACTION // is assigned, as it is called from Java by ActivityManagerService. void bootFinished(); /** * Create a display event connection */ @nullable IDisplayEventConnection createDisplayEventConnection(VsyncSource vsyncSource, EventRegistration eventRegistration); /** * Create a connection with SurfaceFlinger. */ Loading libs/gui/include/gui/DisplayEventDispatcher.h +4 −4 Original line number Diff line number Diff line Loading @@ -23,10 +23,10 @@ using FrameRateOverride = DisplayEventReceiver::Event::FrameRateOverride; class DisplayEventDispatcher : public LooperCallback { public: explicit DisplayEventDispatcher( const sp<Looper>& looper, ISurfaceComposer::VsyncSource vsyncSource = ISurfaceComposer::eVsyncSourceApp, ISurfaceComposer::EventRegistrationFlags eventRegistration = {}); explicit DisplayEventDispatcher(const sp<Looper>& looper, gui::ISurfaceComposer::VsyncSource vsyncSource = gui::ISurfaceComposer::VsyncSource::eVsyncSourceApp, EventRegistrationFlags eventRegistration = {}); status_t initialize(); void dispose(); Loading Loading
libs/gui/DisplayEventDispatcher.cpp +8 −5 Original line number Diff line number Diff line Loading @@ -35,11 +35,14 @@ static const size_t EVENT_BUFFER_SIZE = 100; static constexpr nsecs_t WAITING_FOR_VSYNC_TIMEOUT = ms2ns(300); DisplayEventDispatcher::DisplayEventDispatcher( const sp<Looper>& looper, ISurfaceComposer::VsyncSource vsyncSource, ISurfaceComposer::EventRegistrationFlags eventRegistration) : mLooper(looper), mReceiver(vsyncSource, eventRegistration), mWaitingForVsync(false), mLastVsyncCount(0), mLastScheduleVsyncTime(0) { DisplayEventDispatcher::DisplayEventDispatcher(const sp<Looper>& looper, gui::ISurfaceComposer::VsyncSource vsyncSource, EventRegistrationFlags eventRegistration) : mLooper(looper), mReceiver(vsyncSource, eventRegistration), mWaitingForVsync(false), mLastVsyncCount(0), mLastScheduleVsyncTime(0) { ALOGV("dispatcher %p ~ Initializing display event dispatcher.", this); } Loading
libs/gui/DisplayEventReceiver.cpp +12 −8 Original line number Diff line number Diff line Loading @@ -19,10 +19,9 @@ #include <utils/Errors.h> #include <gui/DisplayEventReceiver.h> #include <gui/ISurfaceComposer.h> #include <gui/VsyncEventData.h> #include <private/gui/ComposerService.h> #include <private/gui/ComposerServiceAIDL.h> #include <private/gui/BitTube.h> Loading @@ -32,15 +31,20 @@ namespace android { // --------------------------------------------------------------------------- DisplayEventReceiver::DisplayEventReceiver( ISurfaceComposer::VsyncSource vsyncSource, ISurfaceComposer::EventRegistrationFlags eventRegistration) { sp<ISurfaceComposer> sf(ComposerService::getComposerService()); DisplayEventReceiver::DisplayEventReceiver(gui::ISurfaceComposer::VsyncSource vsyncSource, EventRegistrationFlags eventRegistration) { sp<gui::ISurfaceComposer> sf(ComposerServiceAIDL::getComposerService()); if (sf != nullptr) { mEventConnection = sf->createDisplayEventConnection(vsyncSource, eventRegistration); mEventConnection = nullptr; binder::Status status = sf->createDisplayEventConnection(vsyncSource, static_cast< gui::ISurfaceComposer::EventRegistration>( eventRegistration.get()), &mEventConnection); if (mEventConnection != nullptr) { mDataChannel = std::make_unique<gui::BitTube>(); const auto status = mEventConnection->stealReceiveChannel(mDataChannel.get()); status = mEventConnection->stealReceiveChannel(mDataChannel.get()); if (!status.isOk()) { ALOGE("stealReceiveChannel failed: %s", status.toString8().c_str()); mInitError = std::make_optional<status_t>(status.transactionError()); Loading
libs/gui/ISurfaceComposer.cpp +0 −45 Original line number Diff line number Diff line Loading @@ -108,35 +108,6 @@ public: data, &reply); } } void bootFinished() override { Parcel data, reply; data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); remote()->transact(BnSurfaceComposer::BOOT_FINISHED, data, &reply); } sp<IDisplayEventConnection> createDisplayEventConnection( VsyncSource vsyncSource, EventRegistrationFlags eventRegistration) override { Parcel data, reply; sp<IDisplayEventConnection> result; int err = data.writeInterfaceToken( ISurfaceComposer::getInterfaceDescriptor()); if (err != NO_ERROR) { return result; } data.writeInt32(static_cast<int32_t>(vsyncSource)); data.writeUint32(eventRegistration.get()); err = remote()->transact( BnSurfaceComposer::CREATE_DISPLAY_EVENT_CONNECTION, data, &reply); if (err != NO_ERROR) { ALOGE("ISurfaceComposer::createDisplayEventConnection: error performing " "transaction: %s (%d)", strerror(-err), -err); return result; } result = interface_cast<IDisplayEventConnection>(reply.readStrongBinder()); return result; } }; // Out-of-line virtual method definition to trigger vtable emission in this Loading Loading @@ -215,22 +186,6 @@ status_t BnSurfaceComposer::onTransact( uncachedBuffer, hasListenerCallbacks, listenerCallbacks, transactionId); } case BOOT_FINISHED: { CHECK_INTERFACE(ISurfaceComposer, data, reply); bootFinished(); return NO_ERROR; } case CREATE_DISPLAY_EVENT_CONNECTION: { CHECK_INTERFACE(ISurfaceComposer, data, reply); auto vsyncSource = static_cast<ISurfaceComposer::VsyncSource>(data.readInt32()); EventRegistrationFlags eventRegistration = static_cast<EventRegistration>(data.readUint32()); sp<IDisplayEventConnection> connection( createDisplayEventConnection(vsyncSource, eventRegistration)); reply->writeStrongBinder(IInterface::asBinder(connection)); return NO_ERROR; } default: { return BBinder::onTransact(code, data, reply, flags); } Loading
libs/gui/aidl/android/gui/ISurfaceComposer.aidl +25 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import android.gui.DisplayStatInfo; import android.gui.DynamicDisplayInfo; import android.gui.FrameEvent; import android.gui.FrameStats; import android.gui.IDisplayEventConnection; import android.gui.IFpsListener; import android.gui.IHdrLayerInfoListener; import android.gui.IRegionSamplingListener; Loading @@ -47,6 +48,30 @@ import android.gui.StaticDisplayInfo; /** @hide */ interface ISurfaceComposer { enum VsyncSource { eVsyncSourceApp = 0, eVsyncSourceSurfaceFlinger = 1 } enum EventRegistration { modeChanged = 1 << 0, frameRateOverride = 1 << 1, } /** * Signal that we're done booting. * Requires ACCESS_SURFACE_FLINGER permission */ // Note this must be the 1st method, so IBinder::FIRST_CALL_TRANSACTION // is assigned, as it is called from Java by ActivityManagerService. void bootFinished(); /** * Create a display event connection */ @nullable IDisplayEventConnection createDisplayEventConnection(VsyncSource vsyncSource, EventRegistration eventRegistration); /** * Create a connection with SurfaceFlinger. */ Loading
libs/gui/include/gui/DisplayEventDispatcher.h +4 −4 Original line number Diff line number Diff line Loading @@ -23,10 +23,10 @@ using FrameRateOverride = DisplayEventReceiver::Event::FrameRateOverride; class DisplayEventDispatcher : public LooperCallback { public: explicit DisplayEventDispatcher( const sp<Looper>& looper, ISurfaceComposer::VsyncSource vsyncSource = ISurfaceComposer::eVsyncSourceApp, ISurfaceComposer::EventRegistrationFlags eventRegistration = {}); explicit DisplayEventDispatcher(const sp<Looper>& looper, gui::ISurfaceComposer::VsyncSource vsyncSource = gui::ISurfaceComposer::VsyncSource::eVsyncSourceApp, EventRegistrationFlags eventRegistration = {}); status_t initialize(); void dispose(); Loading