Loading services/surfaceflinger/Layer.cpp +4 −12 Original line number Diff line number Diff line Loading @@ -254,8 +254,7 @@ Layer::~Layer() { mFlinger->mTunnelModeEnabledReporter->decrementTunnelModeCount(); } if (mHadClonedChild) { auto& roots = mFlinger->mLayerMirrorRoots; roots.erase(std::remove(roots.begin(), roots.end(), this), roots.end()); mFlinger->mNumClones--; } if (hasTrustedPresentationListener()) { mFlinger->mNumTrustedPresentationListeners--; Loading Loading @@ -2595,7 +2594,7 @@ void Layer::updateCloneBufferInfo() { mDrawingState.inputInfo = tmpInputInfo; } bool Layer::updateMirrorInfo(const std::deque<Layer*>& cloneRootsPendingUpdates) { void Layer::updateMirrorInfo() { if (mClonedChild == nullptr || !mClonedChild->isClonedFromAlive()) { // If mClonedChild is null, there is nothing to mirror. If isClonedFromAlive returns false, // it means that there is a clone, but the layer it was cloned from has been destroyed. In Loading @@ -2603,7 +2602,7 @@ bool Layer::updateMirrorInfo(const std::deque<Layer*>& cloneRootsPendingUpdates) // destroyed. The root, this layer, will still be around since the client can continue // to hold a reference, but no cloned layers will be displayed. mClonedChild = nullptr; return true; return; } std::map<sp<Layer>, sp<Layer>> clonedLayersMap; Loading @@ -2618,13 +2617,6 @@ bool Layer::updateMirrorInfo(const std::deque<Layer*>& cloneRootsPendingUpdates) mClonedChild->updateClonedDrawingState(clonedLayersMap); mClonedChild->updateClonedChildren(sp<Layer>::fromExisting(this), clonedLayersMap); mClonedChild->updateClonedRelatives(clonedLayersMap); for (Layer* root : cloneRootsPendingUpdates) { if (clonedLayersMap.find(sp<Layer>::fromExisting(root)) != clonedLayersMap.end()) { return false; } } return true; } void Layer::updateClonedDrawingState(std::map<sp<Layer>, sp<Layer>>& clonedLayersMap) { Loading Loading @@ -2772,7 +2764,7 @@ bool Layer::isInternalDisplayOverlay() const { void Layer::setClonedChild(const sp<Layer>& clonedChild) { mClonedChild = clonedChild; mHadClonedChild = true; mFlinger->mLayerMirrorRoots.push_back(this); mFlinger->mNumClones++; } bool Layer::setDropInputMode(gui::DropInputMode mode) { Loading services/surfaceflinger/Layer.h +1 −1 Original line number Diff line number Diff line Loading @@ -651,7 +651,7 @@ public: gui::WindowInfo::Type getWindowType() const { return mWindowType; } bool updateMirrorInfo(const std::deque<Layer*>& cloneRootsPendingUpdates); void updateMirrorInfo(); /* * doTransaction - process the transaction. This is a good place to figure Loading services/surfaceflinger/LayerRenderArea.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -85,7 +85,7 @@ void LayerRenderArea::render(std::function<void()> drawLayers) { // If layer is offscreen, update mirroring info if it exists if (mLayer->isRemovedFromCurrentState()) { mLayer->traverse(LayerVector::StateSet::Drawing, [&](Layer* layer) { layer->updateMirrorInfo({}); }); [&](Layer* layer) { layer->updateMirrorInfo(); }); mLayer->traverse(LayerVector::StateSet::Drawing, [&](Layer* layer) { layer->updateCloneBufferInfo(); }); } Loading services/surfaceflinger/SurfaceFlinger.cpp +3 −16 Original line number Diff line number Diff line Loading @@ -4024,21 +4024,8 @@ void SurfaceFlinger::doCommitTransactions() { } commitOffscreenLayers(); if (mLayerMirrorRoots.size() > 0) { std::deque<Layer*> pendingUpdates; pendingUpdates.insert(pendingUpdates.end(), mLayerMirrorRoots.begin(), mLayerMirrorRoots.end()); std::vector<Layer*> needsUpdating; for (Layer* cloneRoot : mLayerMirrorRoots) { pendingUpdates.pop_front(); if (cloneRoot->updateMirrorInfo(pendingUpdates)) { } else { needsUpdating.push_back(cloneRoot); } } for (Layer* cloneRoot : needsUpdating) { cloneRoot->updateMirrorInfo({}); } if (mNumClones > 0) { mDrawingState.traverse([&](Layer* layer) { layer->updateMirrorInfo(); }); } } Loading Loading @@ -4145,7 +4132,7 @@ bool SurfaceFlinger::latchBuffers() { mBootStage = BootStage::BOOTANIMATION; } if (mLayerMirrorRoots.size() > 0) { if (mNumClones > 0) { mDrawingState.traverse([&](Layer* layer) { layer->updateCloneBufferInfo(); }); } Loading services/surfaceflinger/SurfaceFlinger.h +2 −1 Original line number Diff line number Diff line Loading @@ -296,7 +296,8 @@ public: // the client can no longer modify this layer directly. void onHandleDestroyed(BBinder* handle, sp<Layer>& layer, uint32_t layerId); std::vector<Layer*> mLayerMirrorRoots; // TODO: Remove atomic if move dtor to main thread CL lands std::atomic<uint32_t> mNumClones; TransactionCallbackInvoker& getTransactionCallbackInvoker() { return mTransactionCallbackInvoker; Loading Loading
services/surfaceflinger/Layer.cpp +4 −12 Original line number Diff line number Diff line Loading @@ -254,8 +254,7 @@ Layer::~Layer() { mFlinger->mTunnelModeEnabledReporter->decrementTunnelModeCount(); } if (mHadClonedChild) { auto& roots = mFlinger->mLayerMirrorRoots; roots.erase(std::remove(roots.begin(), roots.end(), this), roots.end()); mFlinger->mNumClones--; } if (hasTrustedPresentationListener()) { mFlinger->mNumTrustedPresentationListeners--; Loading Loading @@ -2595,7 +2594,7 @@ void Layer::updateCloneBufferInfo() { mDrawingState.inputInfo = tmpInputInfo; } bool Layer::updateMirrorInfo(const std::deque<Layer*>& cloneRootsPendingUpdates) { void Layer::updateMirrorInfo() { if (mClonedChild == nullptr || !mClonedChild->isClonedFromAlive()) { // If mClonedChild is null, there is nothing to mirror. If isClonedFromAlive returns false, // it means that there is a clone, but the layer it was cloned from has been destroyed. In Loading @@ -2603,7 +2602,7 @@ bool Layer::updateMirrorInfo(const std::deque<Layer*>& cloneRootsPendingUpdates) // destroyed. The root, this layer, will still be around since the client can continue // to hold a reference, but no cloned layers will be displayed. mClonedChild = nullptr; return true; return; } std::map<sp<Layer>, sp<Layer>> clonedLayersMap; Loading @@ -2618,13 +2617,6 @@ bool Layer::updateMirrorInfo(const std::deque<Layer*>& cloneRootsPendingUpdates) mClonedChild->updateClonedDrawingState(clonedLayersMap); mClonedChild->updateClonedChildren(sp<Layer>::fromExisting(this), clonedLayersMap); mClonedChild->updateClonedRelatives(clonedLayersMap); for (Layer* root : cloneRootsPendingUpdates) { if (clonedLayersMap.find(sp<Layer>::fromExisting(root)) != clonedLayersMap.end()) { return false; } } return true; } void Layer::updateClonedDrawingState(std::map<sp<Layer>, sp<Layer>>& clonedLayersMap) { Loading Loading @@ -2772,7 +2764,7 @@ bool Layer::isInternalDisplayOverlay() const { void Layer::setClonedChild(const sp<Layer>& clonedChild) { mClonedChild = clonedChild; mHadClonedChild = true; mFlinger->mLayerMirrorRoots.push_back(this); mFlinger->mNumClones++; } bool Layer::setDropInputMode(gui::DropInputMode mode) { Loading
services/surfaceflinger/Layer.h +1 −1 Original line number Diff line number Diff line Loading @@ -651,7 +651,7 @@ public: gui::WindowInfo::Type getWindowType() const { return mWindowType; } bool updateMirrorInfo(const std::deque<Layer*>& cloneRootsPendingUpdates); void updateMirrorInfo(); /* * doTransaction - process the transaction. This is a good place to figure Loading
services/surfaceflinger/LayerRenderArea.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -85,7 +85,7 @@ void LayerRenderArea::render(std::function<void()> drawLayers) { // If layer is offscreen, update mirroring info if it exists if (mLayer->isRemovedFromCurrentState()) { mLayer->traverse(LayerVector::StateSet::Drawing, [&](Layer* layer) { layer->updateMirrorInfo({}); }); [&](Layer* layer) { layer->updateMirrorInfo(); }); mLayer->traverse(LayerVector::StateSet::Drawing, [&](Layer* layer) { layer->updateCloneBufferInfo(); }); } Loading
services/surfaceflinger/SurfaceFlinger.cpp +3 −16 Original line number Diff line number Diff line Loading @@ -4024,21 +4024,8 @@ void SurfaceFlinger::doCommitTransactions() { } commitOffscreenLayers(); if (mLayerMirrorRoots.size() > 0) { std::deque<Layer*> pendingUpdates; pendingUpdates.insert(pendingUpdates.end(), mLayerMirrorRoots.begin(), mLayerMirrorRoots.end()); std::vector<Layer*> needsUpdating; for (Layer* cloneRoot : mLayerMirrorRoots) { pendingUpdates.pop_front(); if (cloneRoot->updateMirrorInfo(pendingUpdates)) { } else { needsUpdating.push_back(cloneRoot); } } for (Layer* cloneRoot : needsUpdating) { cloneRoot->updateMirrorInfo({}); } if (mNumClones > 0) { mDrawingState.traverse([&](Layer* layer) { layer->updateMirrorInfo(); }); } } Loading Loading @@ -4145,7 +4132,7 @@ bool SurfaceFlinger::latchBuffers() { mBootStage = BootStage::BOOTANIMATION; } if (mLayerMirrorRoots.size() > 0) { if (mNumClones > 0) { mDrawingState.traverse([&](Layer* layer) { layer->updateCloneBufferInfo(); }); } Loading
services/surfaceflinger/SurfaceFlinger.h +2 −1 Original line number Diff line number Diff line Loading @@ -296,7 +296,8 @@ public: // the client can no longer modify this layer directly. void onHandleDestroyed(BBinder* handle, sp<Layer>& layer, uint32_t layerId); std::vector<Layer*> mLayerMirrorRoots; // TODO: Remove atomic if move dtor to main thread CL lands std::atomic<uint32_t> mNumClones; TransactionCallbackInvoker& getTransactionCallbackInvoker() { return mTransactionCallbackInvoker; Loading