Loading cmds/surfacereplayer/replayer/Replayer.cpp +0 −41 Original line number Diff line number Diff line Loading @@ -286,10 +286,6 @@ status_t Replayer::dispatchEvent(int index) { std::thread(&Replayer::createSurfaceControl, this, increment.surface_creation(), event) .detach(); } break; case increment.kSurfaceDeletion: { std::thread(&Replayer::deleteSurfaceControl, this, increment.surface_deletion(), event) .detach(); } break; case increment.kBufferUpdate: { std::lock_guard<std::mutex> lock1(mLayerLock); std::lock_guard<std::mutex> lock2(mBufferQueueSchedulerLock); Loading Loading @@ -628,47 +624,10 @@ status_t Replayer::createSurfaceControl( return NO_ERROR; } status_t Replayer::deleteSurfaceControl( const SurfaceDeletion& delete_, const std::shared_ptr<Event>& event) { ALOGV("Deleting %d Surface Control", delete_.id()); event->readyToExecute(); std::lock_guard<std::mutex> lock1(mPendingLayersLock); mLayersPendingRemoval.push_back(delete_.id()); const auto& iterator = mBufferQueueSchedulers.find(delete_.id()); if (iterator != mBufferQueueSchedulers.end()) { (*iterator).second->stopScheduling(); } std::lock_guard<std::mutex> lock2(mLayerLock); if (mLayers[delete_.id()] != nullptr) { mComposerClient->destroySurface(mLayers[delete_.id()]->getHandle()); } return NO_ERROR; } void Replayer::doDeleteSurfaceControls() { std::lock_guard<std::mutex> lock1(mPendingLayersLock); std::lock_guard<std::mutex> lock2(mLayerLock); if (!mLayersPendingRemoval.empty()) { for (int id : mLayersPendingRemoval) { mLayers.erase(id); mColors.erase(id); mBufferQueueSchedulers.erase(id); } mLayersPendingRemoval.clear(); } } status_t Replayer::injectVSyncEvent( const VSyncEvent& vSyncEvent, const std::shared_ptr<Event>& event) { ALOGV("Injecting VSync Event"); doDeleteSurfaceControls(); event->readyToExecute(); SurfaceComposerClient::injectVSync(vSyncEvent.when()); Loading cmds/surfacereplayer/replayer/Replayer.h +0 −3 Original line number Diff line number Diff line Loading @@ -70,8 +70,6 @@ class Replayer { status_t doTransaction(const Transaction& transaction, const std::shared_ptr<Event>& event); status_t createSurfaceControl(const SurfaceCreation& create, const std::shared_ptr<Event>& event); status_t deleteSurfaceControl(const SurfaceDeletion& delete_, const std::shared_ptr<Event>& event); status_t injectVSyncEvent(const VSyncEvent& vsyncEvent, const std::shared_ptr<Event>& event); void createDisplay(const DisplayCreation& create, const std::shared_ptr<Event>& event); void deleteDisplay(const DisplayDeletion& delete_, const std::shared_ptr<Event>& event); Loading Loading @@ -120,7 +118,6 @@ class Replayer { void setDisplayProjection(SurfaceComposerClient::Transaction& t, display_id id, const ProjectionChange& pc); void doDeleteSurfaceControls(); void waitUntilTimestamp(int64_t timestamp); void waitUntilDeferredTransactionLayerExists( const DeferredTransactionChange& dtc, std::unique_lock<std::mutex>& lock); Loading libs/gui/ISurfaceComposerClient.cpp +0 −8 Original line number Diff line number Diff line Loading @@ -31,7 +31,6 @@ namespace { // Anonymous enum class Tag : uint32_t { CREATE_SURFACE = IBinder::FIRST_CALL_TRANSACTION, DESTROY_SURFACE, CLEAR_LAYER_FRAME_STATS, GET_LAYER_FRAME_STATS, LAST = GET_LAYER_FRAME_STATS, Loading @@ -57,11 +56,6 @@ public: handle, gbp); } status_t destroySurface(const sp<IBinder>& handle) override { return callRemote<decltype(&ISurfaceComposerClient::destroySurface)>(Tag::DESTROY_SURFACE, handle); } status_t clearLayerFrameStats(const sp<IBinder>& handle) const override { return callRemote<decltype( &ISurfaceComposerClient::clearLayerFrameStats)>(Tag::CLEAR_LAYER_FRAME_STATS, Loading Loading @@ -92,8 +86,6 @@ status_t BnSurfaceComposerClient::onTransact(uint32_t code, const Parcel& data, switch (tag) { case Tag::CREATE_SURFACE: return callLocal(data, reply, &ISurfaceComposerClient::createSurface); case Tag::DESTROY_SURFACE: return callLocal(data, reply, &ISurfaceComposerClient::destroySurface); case Tag::CLEAR_LAYER_FRAME_STATS: return callLocal(data, reply, &ISurfaceComposerClient::clearLayerFrameStats); case Tag::GET_LAYER_FRAME_STATS: Loading libs/gui/SurfaceComposerClient.cpp +16 −18 Original line number Diff line number Diff line Loading @@ -205,6 +205,22 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::merge(Tr return *this; } void SurfaceComposerClient::doDropReferenceTransaction(const sp<IBinder>& handle, const sp<ISurfaceComposerClient>& client) { sp<ISurfaceComposer> sf(ComposerService::getComposerService()); Vector<ComposerState> composerStates; Vector<DisplayState> displayStates; ComposerState s; s.client = client; s.state.surface = handle; s.state.what |= layer_state_t::eReparent; s.state.parentHandleForChild = nullptr; composerStates.add(s); sf->setTransactionState(composerStates, displayStates, 0, nullptr, {}); } status_t SurfaceComposerClient::Transaction::apply(bool synchronous) { if (mStatus != NO_ERROR) { return mStatus; Loading Loading @@ -819,17 +835,6 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::transfer #endif SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::destroySurface( const sp<SurfaceControl>& sc) { layer_state_t* s = getLayerState(sc); if (!s) { mStatus = BAD_INDEX; return *this; } s->what |= layer_state_t::eDestroySurface; return *this; } SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setColorTransform( const sp<SurfaceControl>& sc, const mat3& matrix, const vec3& translation) { layer_state_t* s = getLayerState(sc); Loading Loading @@ -1004,13 +1009,6 @@ status_t SurfaceComposerClient::createSurfaceChecked( return err; } status_t SurfaceComposerClient::destroySurface(const sp<IBinder>& sid) { if (mStatus != NO_ERROR) return mStatus; status_t err = mClient->destroySurface(sid); return err; } status_t SurfaceComposerClient::clearLayerFrameStats(const sp<IBinder>& token) const { if (mStatus != NO_ERROR) { return mStatus; Loading libs/gui/SurfaceControl.cpp +8 −2 Original line number Diff line number Diff line Loading @@ -63,7 +63,13 @@ SurfaceControl::SurfaceControl(const sp<SurfaceControl>& other) { SurfaceControl::~SurfaceControl() { destroy(); if (mClient != nullptr && mHandle != nullptr && mOwned) { SurfaceComposerClient::doDropReferenceTransaction(mHandle, mClient->getClient()); } mClient.clear(); mHandle.clear(); mGraphicBufferProducer.clear(); IPCThreadState::self()->flushCommands(); } void SurfaceControl::destroy() Loading @@ -71,7 +77,7 @@ void SurfaceControl::destroy() // Avoid destroying the server-side surface if we are not the owner of it, meaning that we // retrieved it from another process. if (isValid() && mOwned) { mClient->destroySurface(mHandle); SurfaceComposerClient::Transaction().reparent(this, nullptr).apply(); } // clear all references and trigger an IPC now, to make sure things // happen without delay, since these resources are quite heavy. Loading Loading
cmds/surfacereplayer/replayer/Replayer.cpp +0 −41 Original line number Diff line number Diff line Loading @@ -286,10 +286,6 @@ status_t Replayer::dispatchEvent(int index) { std::thread(&Replayer::createSurfaceControl, this, increment.surface_creation(), event) .detach(); } break; case increment.kSurfaceDeletion: { std::thread(&Replayer::deleteSurfaceControl, this, increment.surface_deletion(), event) .detach(); } break; case increment.kBufferUpdate: { std::lock_guard<std::mutex> lock1(mLayerLock); std::lock_guard<std::mutex> lock2(mBufferQueueSchedulerLock); Loading Loading @@ -628,47 +624,10 @@ status_t Replayer::createSurfaceControl( return NO_ERROR; } status_t Replayer::deleteSurfaceControl( const SurfaceDeletion& delete_, const std::shared_ptr<Event>& event) { ALOGV("Deleting %d Surface Control", delete_.id()); event->readyToExecute(); std::lock_guard<std::mutex> lock1(mPendingLayersLock); mLayersPendingRemoval.push_back(delete_.id()); const auto& iterator = mBufferQueueSchedulers.find(delete_.id()); if (iterator != mBufferQueueSchedulers.end()) { (*iterator).second->stopScheduling(); } std::lock_guard<std::mutex> lock2(mLayerLock); if (mLayers[delete_.id()] != nullptr) { mComposerClient->destroySurface(mLayers[delete_.id()]->getHandle()); } return NO_ERROR; } void Replayer::doDeleteSurfaceControls() { std::lock_guard<std::mutex> lock1(mPendingLayersLock); std::lock_guard<std::mutex> lock2(mLayerLock); if (!mLayersPendingRemoval.empty()) { for (int id : mLayersPendingRemoval) { mLayers.erase(id); mColors.erase(id); mBufferQueueSchedulers.erase(id); } mLayersPendingRemoval.clear(); } } status_t Replayer::injectVSyncEvent( const VSyncEvent& vSyncEvent, const std::shared_ptr<Event>& event) { ALOGV("Injecting VSync Event"); doDeleteSurfaceControls(); event->readyToExecute(); SurfaceComposerClient::injectVSync(vSyncEvent.when()); Loading
cmds/surfacereplayer/replayer/Replayer.h +0 −3 Original line number Diff line number Diff line Loading @@ -70,8 +70,6 @@ class Replayer { status_t doTransaction(const Transaction& transaction, const std::shared_ptr<Event>& event); status_t createSurfaceControl(const SurfaceCreation& create, const std::shared_ptr<Event>& event); status_t deleteSurfaceControl(const SurfaceDeletion& delete_, const std::shared_ptr<Event>& event); status_t injectVSyncEvent(const VSyncEvent& vsyncEvent, const std::shared_ptr<Event>& event); void createDisplay(const DisplayCreation& create, const std::shared_ptr<Event>& event); void deleteDisplay(const DisplayDeletion& delete_, const std::shared_ptr<Event>& event); Loading Loading @@ -120,7 +118,6 @@ class Replayer { void setDisplayProjection(SurfaceComposerClient::Transaction& t, display_id id, const ProjectionChange& pc); void doDeleteSurfaceControls(); void waitUntilTimestamp(int64_t timestamp); void waitUntilDeferredTransactionLayerExists( const DeferredTransactionChange& dtc, std::unique_lock<std::mutex>& lock); Loading
libs/gui/ISurfaceComposerClient.cpp +0 −8 Original line number Diff line number Diff line Loading @@ -31,7 +31,6 @@ namespace { // Anonymous enum class Tag : uint32_t { CREATE_SURFACE = IBinder::FIRST_CALL_TRANSACTION, DESTROY_SURFACE, CLEAR_LAYER_FRAME_STATS, GET_LAYER_FRAME_STATS, LAST = GET_LAYER_FRAME_STATS, Loading @@ -57,11 +56,6 @@ public: handle, gbp); } status_t destroySurface(const sp<IBinder>& handle) override { return callRemote<decltype(&ISurfaceComposerClient::destroySurface)>(Tag::DESTROY_SURFACE, handle); } status_t clearLayerFrameStats(const sp<IBinder>& handle) const override { return callRemote<decltype( &ISurfaceComposerClient::clearLayerFrameStats)>(Tag::CLEAR_LAYER_FRAME_STATS, Loading Loading @@ -92,8 +86,6 @@ status_t BnSurfaceComposerClient::onTransact(uint32_t code, const Parcel& data, switch (tag) { case Tag::CREATE_SURFACE: return callLocal(data, reply, &ISurfaceComposerClient::createSurface); case Tag::DESTROY_SURFACE: return callLocal(data, reply, &ISurfaceComposerClient::destroySurface); case Tag::CLEAR_LAYER_FRAME_STATS: return callLocal(data, reply, &ISurfaceComposerClient::clearLayerFrameStats); case Tag::GET_LAYER_FRAME_STATS: Loading
libs/gui/SurfaceComposerClient.cpp +16 −18 Original line number Diff line number Diff line Loading @@ -205,6 +205,22 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::merge(Tr return *this; } void SurfaceComposerClient::doDropReferenceTransaction(const sp<IBinder>& handle, const sp<ISurfaceComposerClient>& client) { sp<ISurfaceComposer> sf(ComposerService::getComposerService()); Vector<ComposerState> composerStates; Vector<DisplayState> displayStates; ComposerState s; s.client = client; s.state.surface = handle; s.state.what |= layer_state_t::eReparent; s.state.parentHandleForChild = nullptr; composerStates.add(s); sf->setTransactionState(composerStates, displayStates, 0, nullptr, {}); } status_t SurfaceComposerClient::Transaction::apply(bool synchronous) { if (mStatus != NO_ERROR) { return mStatus; Loading Loading @@ -819,17 +835,6 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::transfer #endif SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::destroySurface( const sp<SurfaceControl>& sc) { layer_state_t* s = getLayerState(sc); if (!s) { mStatus = BAD_INDEX; return *this; } s->what |= layer_state_t::eDestroySurface; return *this; } SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setColorTransform( const sp<SurfaceControl>& sc, const mat3& matrix, const vec3& translation) { layer_state_t* s = getLayerState(sc); Loading Loading @@ -1004,13 +1009,6 @@ status_t SurfaceComposerClient::createSurfaceChecked( return err; } status_t SurfaceComposerClient::destroySurface(const sp<IBinder>& sid) { if (mStatus != NO_ERROR) return mStatus; status_t err = mClient->destroySurface(sid); return err; } status_t SurfaceComposerClient::clearLayerFrameStats(const sp<IBinder>& token) const { if (mStatus != NO_ERROR) { return mStatus; Loading
libs/gui/SurfaceControl.cpp +8 −2 Original line number Diff line number Diff line Loading @@ -63,7 +63,13 @@ SurfaceControl::SurfaceControl(const sp<SurfaceControl>& other) { SurfaceControl::~SurfaceControl() { destroy(); if (mClient != nullptr && mHandle != nullptr && mOwned) { SurfaceComposerClient::doDropReferenceTransaction(mHandle, mClient->getClient()); } mClient.clear(); mHandle.clear(); mGraphicBufferProducer.clear(); IPCThreadState::self()->flushCommands(); } void SurfaceControl::destroy() Loading @@ -71,7 +77,7 @@ void SurfaceControl::destroy() // Avoid destroying the server-side surface if we are not the owner of it, meaning that we // retrieved it from another process. if (isValid() && mOwned) { mClient->destroySurface(mHandle); SurfaceComposerClient::Transaction().reparent(this, nullptr).apply(); } // clear all references and trigger an IPC now, to make sure things // happen without delay, since these resources are quite heavy. Loading