From 6cf0db228ca275dfcda57d79c55e5fa306809632 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Fri, 17 Apr 2009 19:36:26 -0700 Subject: more Surface lifetime management Surfaces are now destroyed once all references from the clients are gone, but they go through a partial destruction as soon as the window manager requests it. This last part is still buggy. see comments in SurfaceFlinger::destroySurface() --- libs/surfaceflinger/LayerBuffer.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'libs/surfaceflinger/LayerBuffer.cpp') diff --git a/libs/surfaceflinger/LayerBuffer.cpp b/libs/surfaceflinger/LayerBuffer.cpp index f22ff59..97d6f97 100644 --- a/libs/surfaceflinger/LayerBuffer.cpp +++ b/libs/surfaceflinger/LayerBuffer.cpp @@ -50,10 +50,21 @@ LayerBuffer::~LayerBuffer() { } +void LayerBuffer::onFirstRef() +{ + mSurface = new SurfaceBuffer(mFlinger, clientIndex(), + const_cast(this)); +} + sp LayerBuffer::createSurface() const { - return new SurfaceBuffer(clientIndex(), - const_cast(this)); + return mSurface; +} + +status_t LayerBuffer::ditch() +{ + mSurface.clear(); + return NO_ERROR; } bool LayerBuffer::needsBlending() const { @@ -167,9 +178,9 @@ sp LayerBuffer::clearSource() { // LayerBuffer::SurfaceBuffer // ============================================================================ -LayerBuffer::SurfaceBuffer::SurfaceBuffer(SurfaceID id, - const sp& owner) - : LayerBaseClient::Surface(id, owner->getIdentity(), owner) +LayerBuffer::SurfaceBuffer::SurfaceBuffer(const sp& flinger, + SurfaceID id, const sp& owner) + : LayerBaseClient::Surface(flinger, id, owner->getIdentity(), owner) { } -- cgit v1.1