summaryrefslogtreecommitdiff
path: root/libs/gui/SurfaceControl.cpp
diff options
context:
space:
mode:
author Rob Carr <racarr@google.com> 2019-02-07 20:45:11 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2019-02-07 20:45:11 +0000
commitc2fdc9a5cf409586a89133295614e13144a7e559 (patch)
tree008460a16d702c47ff1312390007924ed324d000 /libs/gui/SurfaceControl.cpp
parentb73e4954e3ae9b0828600f5a9ebbef5da963f13d (diff)
parent8724653a77f855b7e062541d6e08f3ea659cef7c (diff)
Merge "SurfaceControl life-cycle refactoring."
Diffstat (limited to 'libs/gui/SurfaceControl.cpp')
-rw-r--r--libs/gui/SurfaceControl.cpp23
1 files changed, 7 insertions, 16 deletions
diff --git a/libs/gui/SurfaceControl.cpp b/libs/gui/SurfaceControl.cpp
index f06d36aea3..55488dad0b 100644
--- a/libs/gui/SurfaceControl.cpp
+++ b/libs/gui/SurfaceControl.cpp
@@ -68,10 +68,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()) {
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(