diff options
author | Vishnu Nair <vishnun@google.com> | 2021-07-14 03:01:21 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-07-14 03:01:21 +0000 |
commit | 0a879b6b6129723320e53564d5d91011af08ee59 (patch) | |
tree | a4822f883ac75445a44bdc0947821630efcd0829 | |
parent | f57a4d8a480e063c4e5b0bf419ebcf06a6e3a36e (diff) | |
parent | aff187c337b48200bd621e380451f9d4615ad6b7 (diff) | |
download | native-0a879b6b6129723320e53564d5d91011af08ee59.tar.gz |
Merge "SF: Avoid promoting parent layer in binder thread" into sc-dev am: aff187c337
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/15276211
Change-Id: I463456553ece9da19064633bd22e325d5fddf59a
-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(); |