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()
diff --git a/libs/surfaceflinger/Layer.cpp b/libs/surfaceflinger/Layer.cpp
index 980b78b..5fdec3f 100644
--- a/libs/surfaceflinger/Layer.cpp
+++ b/libs/surfaceflinger/Layer.cpp
@@ -87,6 +87,12 @@
return mSurface;
}
+status_t Layer::ditch()
+{
+ mSurface.clear();
+ return NO_ERROR;
+}
+
status_t Layer::setBuffers( Client* client,
uint32_t w, uint32_t h,
PixelFormat format, uint32_t flags)
@@ -119,7 +125,7 @@
return err;
}
}
- mSurface = new SurfaceLayer(clientIndex(), this);
+ mSurface = new SurfaceLayer(mFlinger, clientIndex(), this);
return NO_ERROR;
}
@@ -626,8 +632,13 @@
// ---------------------------------------------------------------------------
-Layer::SurfaceLayer::SurfaceLayer(SurfaceID id, const sp<Layer>& owner)
- : Surface(id, owner->getIdentity(), owner)
+Layer::SurfaceLayer::SurfaceLayer(const sp<SurfaceFlinger>& flinger,
+ SurfaceID id, const sp<Layer>& owner)
+ : Surface(flinger, id, owner->getIdentity(), owner)
+{
+}
+
+Layer::SurfaceLayer::~SurfaceLayer()
{
}