diff options
author | Mathias Agopian <mathias@google.com> | 2009-04-17 19:36:26 -0700 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2009-04-24 15:00:41 -0700 |
commit | 9a11206fe793363c0e8897b478cbe6ef8c52b543 (patch) | |
tree | 0b7fc29027a6803e1ab992f47f0dd66c2a3e3843 /libs/surfaceflinger/LayerBase.cpp | |
parent | 9f88afb013a7560bf1362d7999a4609e38d0ea77 (diff) | |
download | frameworks_native-9a11206fe793363c0e8897b478cbe6ef8c52b543.zip frameworks_native-9a11206fe793363c0e8897b478cbe6ef8c52b543.tar.gz frameworks_native-9a11206fe793363c0e8897b478cbe6ef8c52b543.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.cpp | 27 |
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 { |