diff options
Diffstat (limited to 'libs/surfaceflinger/Layer.cpp')
-rw-r--r-- | libs/surfaceflinger/Layer.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
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 @@ void Layer::onDraw(const Region& clip) const 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 @@ sp<GraphicBuffer> Layer::SurfaceLayer::requestBuffer(int index, int usage) 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; +} + // --------------------------------------------------------------------------- |