summaryrefslogtreecommitdiffstats
path: root/libs/surfaceflinger/LayerBase.cpp
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2009-04-17 19:36:26 -0700
committerMathias Agopian <mathias@google.com>2009-04-24 15:00:41 -0700
commit6cf0db228ca275dfcda57d79c55e5fa306809632 (patch)
treec1e57e8da8c8428bcac5afc877c16f472d0fb501 /libs/surfaceflinger/LayerBase.cpp
parent2b1927f686eaec23a5798966b96aadaee3e2eb85 (diff)
downloadframeworks_base-6cf0db228ca275dfcda57d79c55e5fa306809632.zip
frameworks_base-6cf0db228ca275dfcda57d79c55e5fa306809632.tar.gz
frameworks_base-6cf0db228ca275dfcda57d79c55e5fa306809632.tar.bz2
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()
Diffstat (limited to 'libs/surfaceflinger/LayerBase.cpp')
-rw-r--r--libs/surfaceflinger/LayerBase.cpp27
1 files changed, 17 insertions, 10 deletions
diff --git a/libs/surfaceflinger/LayerBase.cpp b/libs/surfaceflinger/LayerBase.cpp
index 6da0bf7..8609225 100644
--- a/libs/surfaceflinger/LayerBase.cpp
+++ b/libs/surfaceflinger/LayerBase.cpp
@@ -681,25 +681,32 @@ sp<LayerBaseClient::Surface> LayerBaseClient::getSurface()
sp<LayerBaseClient::Surface> LayerBaseClient::createSurface() const
{
- return new Surface(clientIndex(), mIdentity,
+ return new Surface(mFlinger, clientIndex(), mIdentity,
const_cast<LayerBaseClient *>(this));
}
// ---------------------------------------------------------------------------
-LayerBaseClient::Surface::Surface(SurfaceID id, int identity,
+LayerBaseClient::Surface::Surface(
+ const sp<SurfaceFlinger>& flinger,
+ SurfaceID id, int identity,
const sp<LayerBaseClient>& owner)
- : mToken(id), mIdentity(identity), mOwner(owner)
-{
+ : mFlinger(flinger), mToken(id), mIdentity(identity), mOwner(owner)
+{
}
-LayerBaseClient::Surface::~Surface() {
- // TODO: We now have a point here were we can clean-up the
- // client's mess.
- // This is also where surface id should be recycled.
- //LOGD("Surface %d, heaps={%p, %p} destroyed",
- // mId, mHeap[0].get(), mHeap[1].get());
+LayerBaseClient::Surface::~Surface()
+{
+ /*
+ * This is a good place to clean-up all client resources
+ */
+
+ // destroy client resources
+ sp<LayerBaseClient> layer = getOwner();
+ if (layer != 0) {
+ mFlinger->destroySurface(layer);
+ }
}
sp<LayerBaseClient> LayerBaseClient::Surface::getOwner() const {