mFrameTracker.logAndResetStats(mName);
#ifdef USE_HWC2
- ALOGE_IF(!mHwcLayers.empty(),
- "Found stale hardware composer layers when destroying "
- "surface flinger layer");
+ if (!mHwcLayers.empty()) {
+ ALOGE("Found stale hardware composer layers when destroying "
+ "surface flinger layer %s", mName.string());
+ destroyAllHwcLayers();
+ }
#endif
}
}
}
-// called with SurfaceFlinger::mStateLock from the drawing thread after
-// the layer has been remove from the current state list (and just before
-// it's removed from the drawing state list)
-void Layer::onRemoved() {
+void Layer::onRemovedFromCurrentState() {
+ // the layer is removed from SF mCurrentState to mLayersPendingRemoval
+
if (mCurrentState.zOrderRelativeOf != nullptr) {
sp<Layer> strongRelative = mCurrentState.zOrderRelativeOf.promote();
if (strongRelative != nullptr) {
strongRelative->removeZOrderRelative(this);
+ mFlinger->setTransactionFlags(eTraversalNeeded);
}
mCurrentState.zOrderRelativeOf = nullptr;
}
- mSurfaceFlingerConsumer->abandon();
+ for (const auto& child : mCurrentChildren) {
+ child->onRemovedFromCurrentState();
+ }
+}
+void Layer::onRemoved() {
+ // the layer is removed from SF mLayersPendingRemoval
+
+ mSurfaceFlingerConsumer->abandon();
#ifdef USE_HWC2
destroyAllHwcLayers();
#endif
bool isPotentialCursor() const { return mPotentialCursor;}
/*
- * called with the state lock when the surface is removed from the
- * current list
+ * called with the state lock from a binder thread when the layer is
+ * removed from the current list to the pending removal list
+ */
+ void onRemovedFromCurrentState();
+
+ /*
+ * called with the state lock from the main thread when the layer is
+ * removed from the pending removal list
*/
void onRemoved();