From a3aa6c9aa96873a70e2ff3170218a275f503520e Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Wed, 22 Apr 2009 15:23:34 -0700 Subject: Surfaces are now destroyed properly in SurfaceFlinger. First, the window manager tells us when a surface is no longer needed. At this point, several things happen: - the surface is removed from the active/visible list - it is added to a purgatory list, where it waits for all clients to release their reference - it destroys all data/state that can be spared Later, when all clients are done, the remains of the Surface are disposed off: it is removed from the purgatory and destroyed. In particular its gralloc buffers are destroyed at that point (when we're sure nobody is using them anymore). --- libs/surfaceflinger/Layer.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'libs/surfaceflinger/Layer.cpp') diff --git a/libs/surfaceflinger/Layer.cpp b/libs/surfaceflinger/Layer.cpp index 5fdec3f64e3a..4e3f3a9b8435 100644 --- a/libs/surfaceflinger/Layer.cpp +++ b/libs/surfaceflinger/Layer.cpp @@ -60,16 +60,24 @@ Layer::Layer(SurfaceFlinger* flinger, DisplayID display, Client* c, int32_t i) } Layer::~Layer() +{ + destroy(); + // the actual buffers will be destroyed here +} + +void Layer::destroy() { for (int i=0 ; igraphicPlane(0).getEGLDisplay()); eglDestroyImageKHR(dpy, mTextures[i].image); + mTextures[i].image = EGL_NO_IMAGE_KHR; } } } @@ -89,7 +97,9 @@ sp Layer::createSurface() const status_t Layer::ditch() { + // the layer is not on screen anymore. free as much resources as possible mSurface.clear(); + destroy(); return NO_ERROR; } -- cgit v1.2.3-59-g8ed1b