diff options
| author | 2022-06-29 21:21:49 +0000 | |
|---|---|---|
| committer | 2022-06-29 21:21:49 +0000 | |
| commit | 618c76e5c04f99f2e295fcd2ffcb896476a68f38 (patch) | |
| tree | db84b827307260c3e1e05d5d30a08c08d427e158 /services/surfaceflinger/LayerRenderArea.cpp | |
| parent | 31afdea9a497881604f2395b7a870d4ee21497c6 (diff) | |
| parent | 552bdbb3f7e423c4047ed209917a12f8cadf86e9 (diff) | |
Merge "Merge tm-dev-plus-aosp-without-vendor@8763363" into stage-aosp-master
Diffstat (limited to 'services/surfaceflinger/LayerRenderArea.cpp')
| -rw-r--r-- | services/surfaceflinger/LayerRenderArea.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/services/surfaceflinger/LayerRenderArea.cpp b/services/surfaceflinger/LayerRenderArea.cpp index 11fe6d0755..896f25404d 100644 --- a/services/surfaceflinger/LayerRenderArea.cpp +++ b/services/surfaceflinger/LayerRenderArea.cpp @@ -26,18 +26,12 @@ namespace android { namespace { -struct ReparentForDrawing { - const sp<Layer>& oldParent; - - ReparentForDrawing(const sp<Layer>& oldParent, const sp<Layer>& newParent, - const Rect& drawingBounds) - : oldParent(oldParent) { +void reparentForDrawing(const sp<Layer>& oldParent, const sp<Layer>& newParent, + const Rect& drawingBounds) { // Compute and cache the bounds for the new parent layer. newParent->computeBounds(drawingBounds.toFloatRect(), ui::Transform(), - 0.f /* shadowRadius */); + 0.f /* shadowRadius */); oldParent->setChildrenDrawingParent(newParent); - } - ~ReparentForDrawing() { oldParent->setChildrenDrawingParent(oldParent); } }; } // namespace @@ -112,15 +106,21 @@ void LayerRenderArea::render(std::function<void()> drawLayers) { } drawLayers(); } else { - uint32_t w = static_cast<uint32_t>(getWidth()); - uint32_t h = static_cast<uint32_t>(getHeight()); // In the "childrenOnly" case we reparent the children to a screenshot // layer which has no properties set and which does not draw. + // We hold the statelock as the reparent-for-drawing operation modifies the + // hierarchy and there could be readers on Binder threads, like dump. sp<ContainerLayer> screenshotParentLayer = mFlinger.getFactory().createContainerLayer( - {&mFlinger, nullptr, "Screenshot Parent"s, w, h, 0, LayerMetadata()}); - - ReparentForDrawing reparent(mLayer, screenshotParentLayer, sourceCrop); + {&mFlinger, nullptr, "Screenshot Parent"s, 0, LayerMetadata()}); + { + Mutex::Autolock _l(mFlinger.mStateLock); + reparentForDrawing(mLayer, screenshotParentLayer, sourceCrop); + } drawLayers(); + { + Mutex::Autolock _l(mFlinger.mStateLock); + mLayer->setChildrenDrawingParent(mLayer); + } } } |