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/ui/ISurface.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'libs/ui/ISurface.cpp') diff --git a/libs/ui/ISurface.cpp b/libs/ui/ISurface.cpp index b78e8b5ab5..a2dbe7ff81 100644 --- a/libs/ui/ISurface.cpp +++ b/libs/ui/ISurface.cpp @@ -71,12 +71,13 @@ public: { } - virtual sp getBuffer(int usage) + virtual sp requestBuffer(int bufferIdx, int usage) { Parcel data, reply; data.writeInterfaceToken(ISurface::getInterfaceDescriptor()); + data.writeInt32(bufferIdx); data.writeInt32(usage); - remote()->transact(GET_BUFFER, data, &reply); + remote()->transact(REQUEST_BUFFER, data, &reply); sp buffer = new SurfaceBuffer(reply); return buffer; } @@ -134,10 +135,11 @@ status_t BnSurface::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { switch(code) { - case GET_BUFFER: { + case REQUEST_BUFFER: { CHECK_INTERFACE(ISurface, data, reply); + int bufferIdx = data.readInt32(); int usage = data.readInt32(); - sp buffer(getBuffer(usage)); + sp buffer(requestBuffer(bufferIdx, usage)); return SurfaceBuffer::writeToParcel(reply, buffer.get()); } case REGISTER_BUFFERS: { -- cgit v1.2.3-59-g8ed1b