SharedBufferStack now can grow up to 16 buffers.
there is a new resize() api, which currently only allows growing.
Change-Id: Ia37b81b73be466d2491ffed7f3a23cd8e113c6fe
diff --git a/libs/surfaceflinger/Layer.cpp b/libs/surfaceflinger/Layer.cpp
index 71573ac..1fe997d 100644
--- a/libs/surfaceflinger/Layer.cpp
+++ b/libs/surfaceflinger/Layer.cpp
@@ -208,6 +208,30 @@
drawWithOpenGL(clip, tex);
}
+
+status_t Layer::setBufferCount(int bufferCount)
+{
+ // this ensures our client doesn't go away while we're accessing
+ // the shared area.
+ sp<Client> ourClient(client.promote());
+ if (ourClient == 0) {
+ // oops, the client is already gone
+ return DEAD_OBJECT;
+ }
+
+ status_t err;
+
+ // FIXME: resize() below is NOT thread-safe, we need to synchronize
+ // the users of lcblk in our process (ie: retire), and we assume the
+ // client is not mucking with the SharedStack, which is only enforced
+ // by construction, therefore we need to protect ourselves against
+ // buggy and malicious client (as always)
+
+ err = lcblk->resize(bufferCount);
+
+ return err;
+}
+
sp<GraphicBuffer> Layer::requestBuffer(int index, int usage)
{
sp<GraphicBuffer> buffer;
@@ -642,6 +666,16 @@
return buffer;
}
+status_t Layer::SurfaceLayer::setBufferCount(int bufferCount)
+{
+ status_t err = DEAD_OBJECT;
+ sp<Layer> owner(getOwner());
+ if (owner != 0) {
+ err = owner->setBufferCount(bufferCount);
+ }
+ return err;
+}
+
// ---------------------------------------------------------------------------