From 6fb1a7e9627df030667304d88a3292f91e790ea9 Mon Sep 17 00:00:00 2001 From: Robert Carr Date: Tue, 11 Dec 2018 12:07:25 -0800 Subject: SurfaceFlinger: Remove removeLayer We remove explicit layer destruction and replace it with reparent->null, completing the transition to a reference counted model. Test: Manual Bug: 62536731 Bug: 111373437 Bug: 111297488 Change-Id: I8ac7c5c5125e1c8daf84b42db00e1dd93a544bb5 --- libs/gui/SurfaceControl.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'libs/gui/SurfaceControl.cpp') diff --git a/libs/gui/SurfaceControl.cpp b/libs/gui/SurfaceControl.cpp index b6ef286fd4..8e500a4f9b 100644 --- a/libs/gui/SurfaceControl.cpp +++ b/libs/gui/SurfaceControl.cpp @@ -63,7 +63,13 @@ SurfaceControl::SurfaceControl(const sp& other) { SurfaceControl::~SurfaceControl() { - destroy(); + if (mClient != nullptr && mHandle != nullptr && mOwned) { + SurfaceComposerClient::doDropReferenceTransaction(mHandle, mClient->getClient()); + } + mClient.clear(); + mHandle.clear(); + mGraphicBufferProducer.clear(); + IPCThreadState::self()->flushCommands(); } void SurfaceControl::destroy() @@ -71,7 +77,7 @@ void SurfaceControl::destroy() // Avoid destroying the server-side surface if we are not the owner of it, meaning that we // retrieved it from another process. if (isValid() && mOwned) { - mClient->destroySurface(mHandle); + SurfaceComposerClient::Transaction().reparent(this, nullptr).apply(); } // clear all references and trigger an IPC now, to make sure things // happen without delay, since these resources are quite heavy. -- cgit v1.2.3-59-g8ed1b