diff options
author | Vishnu Nair <vishnun@google.com> | 2021-07-14 02:45:56 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2021-07-14 02:45:56 +0000 |
commit | aff187c337b48200bd621e380451f9d4615ad6b7 (patch) | |
tree | a4822f883ac75445a44bdc0947821630efcd0829 | |
parent | 311ea1b9e8cf457a554c006691b08da848b1f3a6 (diff) | |
parent | 14d218b589719842142dd7455484f80025fb63f3 (diff) | |
download | native-aff187c337b48200bd621e380451f9d4615ad6b7.tar.gz |
Merge "SF: Avoid promoting parent layer in binder thread" into sc-dev
-rw-r--r-- | services/surfaceflinger/Layer.h | 7 | ||||
-rw-r--r-- | services/surfaceflinger/RefreshRateOverlay.cpp | 1 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 5 |
3 files changed, 12 insertions, 1 deletions
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h index e726d379d6..6b56b2d924 100644 --- a/services/surfaceflinger/Layer.h +++ b/services/surfaceflinger/Layer.h @@ -796,6 +796,11 @@ public: // for symmetry with Vector::remove ssize_t removeChild(const sp<Layer>& layer); sp<Layer> getParent() const { return mCurrentParent.promote(); } + + // Should be called with the surfaceflinger statelock held + bool isAtRoot() const { return mIsAtRoot; } + void setIsAtRoot(bool isAtRoot) { mIsAtRoot = isAtRoot; } + bool hasParent() const { return getParent() != nullptr; } Rect getScreenBounds(bool reduceTransparentRegion = true) const; bool setChildLayer(const sp<Layer>& childLayer, int32_t z); @@ -1103,6 +1108,8 @@ private: // A list of regions on this layer that should have blurs. const std::vector<BlurRegion> getBlurRegions() const; + + bool mIsAtRoot = false; }; std::ostream& operator<<(std::ostream& stream, const Layer::FrameRate& rate); diff --git a/services/surfaceflinger/RefreshRateOverlay.cpp b/services/surfaceflinger/RefreshRateOverlay.cpp index 663e62a2f5..27a1c280fb 100644 --- a/services/surfaceflinger/RefreshRateOverlay.cpp +++ b/services/surfaceflinger/RefreshRateOverlay.cpp @@ -197,6 +197,7 @@ bool RefreshRateOverlay::createLayer() { Mutex::Autolock _l(mFlinger.mStateLock); mLayer = mClient->getLayerUser(mIBinder); mLayer->setFrameRate(Layer::FrameRate(Fps(0.0f), Layer::FrameRateCompatibility::NoVote)); + mLayer->setIsAtRoot(true); // setting Layer's Z requires resorting layersSortedByZ ssize_t idx = mFlinger.mDrawingState.layersSortedByZ.indexOf(mLayer); diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 2650fa0583..72700162ba 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -4181,6 +4181,7 @@ uint32_t SurfaceFlinger::setClientStateLocked( : nullptr; if (layer->reparent(parentHandle)) { if (!hadParent) { + layer->setIsAtRoot(false); mCurrentState.layersSortedByZ.remove(layer); } flags |= eTransactionNeeded | eTraversalNeeded; @@ -4447,7 +4448,8 @@ void SurfaceFlinger::onHandleDestroyed(sp<Layer>& layer) { // with the idea that the parent holds a reference and will eventually // be cleaned up. However no one cleans up the top-level so we do so // here. - if (layer->getParent() == nullptr) { + if (layer->isAtRoot()) { + layer->setIsAtRoot(false); mCurrentState.layersSortedByZ.remove(layer); } markLayerPendingRemovalLocked(layer); @@ -6924,6 +6926,7 @@ sp<Layer> SurfaceFlinger::handleLayerCreatedLocked(const sp<IBinder>& handle, bo } if (parent == nullptr && allowAddRoot) { + layer->setIsAtRoot(true); mCurrentState.layersSortedByZ.add(layer); } else if (parent == nullptr) { layer->onRemovedFromCurrentState(); |