From cbb288bfe89f585bf48371bd31b2d4aafa32f32e Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Mon, 7 Sep 2009 16:32:45 -0700 Subject: fix [2068105] implement queueBuffer/lockBuffer/dequeueBuffer properly Rewrote SurfaceFlinger's buffer management from the ground-up. The design now support an arbitrary number of buffers per surface, however the current implementation is limited to four. Currently only 2 buffers are used in practice. The main new feature is to be able to dequeue all buffers at once (very important when there are only two). A client can dequeue all buffers until there are none available, it can lock all buffers except the last one that is used for composition. The client will block then, until a new buffer is enqueued. The current implementation requires that buffers are locked in the same order they are dequeued and enqueued in the same order they are locked. Only one buffer can be locked at a time. eg. Allowed sequence: DQ, DQ, LOCK, Q, LOCK, Q eg. Forbidden sequence: DQ, DQ, LOCK, LOCK, Q, Q --- libs/surfaceflinger/LayerBase.cpp | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) (limited to 'libs/surfaceflinger/LayerBase.cpp') diff --git a/libs/surfaceflinger/LayerBase.cpp b/libs/surfaceflinger/LayerBase.cpp index ec38fe9fd5..62e41b0f17 100644 --- a/libs/surfaceflinger/LayerBase.cpp +++ b/libs/surfaceflinger/LayerBase.cpp @@ -30,7 +30,6 @@ #include "clz.h" #include "LayerBase.h" -#include "LayerBlur.h" #include "SurfaceFlinger.h" #include "DisplayHardware/DisplayHardware.h" @@ -127,9 +126,6 @@ uint32_t LayerBase::setTransactionFlags(uint32_t flags) { return android_atomic_or(flags, &mTransactionFlags); } -void LayerBase::setSizeChanged(uint32_t w, uint32_t h) { -} - bool LayerBase::setPosition(int32_t x, int32_t y) { if (mCurrentState.transform.tx() == x && mCurrentState.transform.ty() == y) return false; @@ -149,7 +145,6 @@ bool LayerBase::setLayer(uint32_t z) { bool LayerBase::setSize(uint32_t w, uint32_t h) { if (mCurrentState.w == w && mCurrentState.h == h) return false; - setSizeChanged(w, h); mCurrentState.w = w; mCurrentState.h = h; requestTransaction(); @@ -219,21 +214,14 @@ uint32_t LayerBase::doTransaction(uint32_t flags) return flags; } -Point LayerBase::getPhysicalSize() const -{ - const Layer::State& front(drawingState()); - return Point(front.w, front.h); -} - void LayerBase::validateVisibility(const Transform& planeTransform) { const Layer::State& s(drawingState()); const Transform tr(planeTransform * s.transform); const bool transformed = tr.transformed(); - const Point size(getPhysicalSize()); - uint32_t w = size.x; - uint32_t h = size.y; + uint32_t w = s.w; + uint32_t h = s.h; tr.transform(mVertices[0], 0, 0); tr.transform(mVertices[1], 0, h); tr.transform(mVertices[2], w, h); @@ -655,9 +643,7 @@ int32_t LayerBaseClient::sIdentity = 0; LayerBaseClient::LayerBaseClient(SurfaceFlinger* flinger, DisplayID display, const sp& client, int32_t i) : LayerBase(flinger, display), client(client), - lcblk( client!=0 ? &(client->ctrlblk->layers[i]) : 0 ), - mIndex(i), - mIdentity(uint32_t(android_atomic_inc(&sIdentity))) + mIndex(i), mIdentity(uint32_t(android_atomic_inc(&sIdentity))) { } @@ -666,11 +652,8 @@ void LayerBaseClient::onFirstRef() sp client(this->client.promote()); if (client != 0) { client->bindLayer(this, mIndex); - // Initialize this layer's control block - memset(this->lcblk, 0, sizeof(layer_cblk_t)); - this->lcblk->identity = mIdentity; - Region::writeEmpty(&(this->lcblk->region[0]), sizeof(flat_region_t)); - Region::writeEmpty(&(this->lcblk->region[1]), sizeof(flat_region_t)); + // Initialize this layer's identity + client->ctrlblk->setIdentity(mIndex, mIdentity); } } @@ -759,7 +742,7 @@ status_t LayerBaseClient::Surface::onTransact( return BnSurface::onTransact(code, data, reply, flags); } -sp LayerBaseClient::Surface::getBuffer(int) +sp LayerBaseClient::Surface::requestBuffer(int index, int usage) { return NULL; } -- cgit v1.2.3-59-g8ed1b