diff options
author | 2019-02-04 15:20:26 -0800 | |
---|---|---|
committer | 2019-02-05 09:14:14 -0800 | |
commit | 8724653a77f855b7e062541d6e08f3ea659cef7c (patch) | |
tree | 36e9f4220b02f69c6f2c352d79900062b753233c /libs/gui/SurfaceControl.cpp | |
parent | 0e87539913e3fe631730b40c1f2c0be2fcee66d8 (diff) |
SurfaceControl life-cycle refactoring.
We provide a method called "release" which allows the client
to drop its references without reparenting the SurfaceControl
to null as the destructor would. The Java and NDK API's already
have this method but it's not perfectly functional at the moment.
Additionally we remove the strange pass-through of clear to destroy
and expose destroy directly.
Test: Builds
Bug: 123587983
Change-Id: Ia89ada1476daef97e6f30d50a57065c3636a6489
Diffstat (limited to 'libs/gui/SurfaceControl.cpp')
-rw-r--r-- | libs/gui/SurfaceControl.cpp | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/libs/gui/SurfaceControl.cpp b/libs/gui/SurfaceControl.cpp index 008f520bb0..d2b0e6a220 100644 --- a/libs/gui/SurfaceControl.cpp +++ b/libs/gui/SurfaceControl.cpp @@ -66,10 +66,7 @@ SurfaceControl::~SurfaceControl() if (mClient != nullptr && mHandle != nullptr && mOwned) { SurfaceComposerClient::doDropReferenceTransaction(mHandle, mClient->getClient()); } - mClient.clear(); - mHandle.clear(); - mGraphicBufferProducer.clear(); - IPCThreadState::self()->flushCommands(); + release(); } void SurfaceControl::destroy() @@ -79,7 +76,12 @@ void SurfaceControl::destroy() if (isValid() && mOwned) { SurfaceComposerClient::Transaction().reparent(this, nullptr).apply(); } - // clear all references and trigger an IPC now, to make sure things + release(); +} + +void SurfaceControl::release() +{ + // Trigger an IPC now, to make sure things // happen without delay, since these resources are quite heavy. mClient.clear(); mHandle.clear(); @@ -87,17 +89,6 @@ void SurfaceControl::destroy() IPCThreadState::self()->flushCommands(); } -void SurfaceControl::clear() -{ - // here, the window manager tells us explicitly that we should destroy - // the surface's resource. Soon after this call, it will also release - // its last reference (which will call the dtor); however, it is possible - // that a client living in the same process still holds references which - // would delay the call to the dtor -- that is why we need this explicit - // "clear()" call. - destroy(); -} - void SurfaceControl::disconnect() { if (mGraphicBufferProducer != nullptr) { mGraphicBufferProducer->disconnect( |