diff options
author | Mathias Agopian <mathias@google.com> | 2009-09-07 16:32:45 -0700 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2009-09-07 16:32:45 -0700 |
commit | 9779b221e999583ff89e0dfc40e56398737adbb3 (patch) | |
tree | 76b185d252b95b05e8d74e7a1644b843f8839725 /libs/surfaceflinger/LayerBuffer.cpp | |
parent | a4eb91da03bd785bc91bed0d25a9efaa9baba1c1 (diff) | |
download | frameworks_base-9779b221e999583ff89e0dfc40e56398737adbb3.zip frameworks_base-9779b221e999583ff89e0dfc40e56398737adbb3.tar.gz frameworks_base-9779b221e999583ff89e0dfc40e56398737adbb3.tar.bz2 |
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
Diffstat (limited to 'libs/surfaceflinger/LayerBuffer.cpp')
-rw-r--r-- | libs/surfaceflinger/LayerBuffer.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/libs/surfaceflinger/LayerBuffer.cpp b/libs/surfaceflinger/LayerBuffer.cpp index 8a55a3f..433b48e 100644 --- a/libs/surfaceflinger/LayerBuffer.cpp +++ b/libs/surfaceflinger/LayerBuffer.cpp @@ -28,6 +28,7 @@ #include <hardware/copybit.h> +#include "Buffer.h" #include "BufferAllocator.h" #include "LayerBuffer.h" #include "SurfaceFlinger.h" @@ -58,7 +59,7 @@ LayerBuffer::~LayerBuffer() void LayerBuffer::onFirstRef() { LayerBaseClient::onFirstRef(); - mSurface = new SurfaceBuffer(mFlinger, clientIndex(), + mSurface = new SurfaceLayerBuffer(mFlinger, clientIndex(), const_cast<LayerBuffer *>(this)); } @@ -181,21 +182,21 @@ sp<LayerBuffer::Source> LayerBuffer::clearSource() { } // ============================================================================ -// LayerBuffer::SurfaceBuffer +// LayerBuffer::SurfaceLayerBuffer // ============================================================================ -LayerBuffer::SurfaceBuffer::SurfaceBuffer(const sp<SurfaceFlinger>& flinger, +LayerBuffer::SurfaceLayerBuffer::SurfaceLayerBuffer(const sp<SurfaceFlinger>& flinger, SurfaceID id, const sp<LayerBuffer>& owner) : LayerBaseClient::Surface(flinger, id, owner->getIdentity(), owner) { } -LayerBuffer::SurfaceBuffer::~SurfaceBuffer() +LayerBuffer::SurfaceLayerBuffer::~SurfaceLayerBuffer() { unregisterBuffers(); } -status_t LayerBuffer::SurfaceBuffer::registerBuffers( +status_t LayerBuffer::SurfaceLayerBuffer::registerBuffers( const ISurface::BufferHeap& buffers) { sp<LayerBuffer> owner(getOwner()); @@ -204,21 +205,21 @@ status_t LayerBuffer::SurfaceBuffer::registerBuffers( return NO_INIT; } -void LayerBuffer::SurfaceBuffer::postBuffer(ssize_t offset) +void LayerBuffer::SurfaceLayerBuffer::postBuffer(ssize_t offset) { sp<LayerBuffer> owner(getOwner()); if (owner != 0) owner->postBuffer(offset); } -void LayerBuffer::SurfaceBuffer::unregisterBuffers() +void LayerBuffer::SurfaceLayerBuffer::unregisterBuffers() { sp<LayerBuffer> owner(getOwner()); if (owner != 0) owner->unregisterBuffers(); } -sp<OverlayRef> LayerBuffer::SurfaceBuffer::createOverlay( +sp<OverlayRef> LayerBuffer::SurfaceLayerBuffer::createOverlay( uint32_t w, uint32_t h, int32_t format) { sp<OverlayRef> result; sp<LayerBuffer> owner(getOwner()); @@ -462,8 +463,8 @@ void LayerBuffer::BufferSource::onDraw(const Region& clip) const const int tmp_h = floorf(src_height * yscale); if (mTempBitmap==0 || - mTempBitmap->getWidth() < tmp_w || - mTempBitmap->getHeight() < tmp_h) { + mTempBitmap->getWidth() < size_t(tmp_w) || + mTempBitmap->getHeight() < size_t(tmp_h)) { mTempBitmap.clear(); mTempBitmap = new android::Buffer( tmp_w, tmp_h, src.img.format, |