diff options
| author | 2012-04-12 16:32:37 -0700 | |
|---|---|---|
| committer | 2012-04-13 16:04:44 -0700 | |
| commit | ac6035a12aec38eeb14d0c13636ec980066d9a8f (patch) | |
| tree | bf61a3af5d1ba7e4f14de1c23a32aed5aed30a81 /libs/gui/SurfaceTextureClient.cpp | |
| parent | fca660cf730161f823e770ad1693fab441477edd (diff) | |
s/w rendered apps can now use n-buffering (n>2)
Bug: 6311881
Change-Id: I6e52e281e8d432430aad011f6d9dcf35d7b4ac7d
Diffstat (limited to 'libs/gui/SurfaceTextureClient.cpp')
| -rw-r--r-- | libs/gui/SurfaceTextureClient.cpp | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/libs/gui/SurfaceTextureClient.cpp b/libs/gui/SurfaceTextureClient.cpp index 99c025f91c..b37d821f9b 100644 --- a/libs/gui/SurfaceTextureClient.cpp +++ b/libs/gui/SurfaceTextureClient.cpp @@ -171,7 +171,7 @@ int SurfaceTextureClient::dequeueBuffer(android_native_buffer_t** buffer) { result); return result; } - sp<GraphicBuffer>& gbuf(mSlots[buf]); + sp<GraphicBuffer>& gbuf(mSlots[buf].buffer); if (result & ISurfaceTexture::RELEASE_ALL_BUFFERS) { freeAllBuffers(); } @@ -204,7 +204,8 @@ int SurfaceTextureClient::getSlotFromBufferLocked( android_native_buffer_t* buffer) const { bool dumpedState = false; for (int i = 0; i < NUM_BUFFER_SLOTS; i++) { - if (mSlots[i] != NULL && mSlots[i]->handle == buffer->handle) { + if (mSlots[i].buffer != NULL && + mSlots[i].buffer->handle == buffer->handle) { return i; } } @@ -586,7 +587,7 @@ int SurfaceTextureClient::setBuffersTimestamp(int64_t timestamp) void SurfaceTextureClient::freeAllBuffers() { for (int i = 0; i < NUM_BUFFER_SLOTS; i++) { - mSlots[i] = 0; + mSlots[i].buffer = 0; } } @@ -691,19 +692,32 @@ status_t SurfaceTextureClient::lock( if (canCopyBack) { // copy the area that is invalid and not repainted this round - const Region copyback(mOldDirtyRegion.subtract(newDirtyRegion)); + const Region copyback(mDirtyRegion.subtract(newDirtyRegion)); if (!copyback.isEmpty()) copyBlt(backBuffer, frontBuffer, copyback); } else { // if we can't copy-back anything, modify the user's dirty // region to make sure they redraw the whole buffer newDirtyRegion.set(bounds); + mDirtyRegion.clear(); + Mutex::Autolock lock(mMutex); + for (size_t i=0 ; i<NUM_BUFFER_SLOTS ; i++) { + mSlots[i].dirtyRegion.clear(); + } } - // keep track of the are of the buffer that is "clean" - // (ie: that will be redrawn) - mOldDirtyRegion = newDirtyRegion; + { // scope for the lock + Mutex::Autolock lock(mMutex); + int backBufferSlot(getSlotFromBufferLocked(backBuffer.get())); + if (backBufferSlot >= 0) { + Region& dirtyRegion(mSlots[backBufferSlot].dirtyRegion); + mDirtyRegion.subtract(dirtyRegion); + dirtyRegion = newDirtyRegion; + } + } + + mDirtyRegion.orSelf(newDirtyRegion); if (inOutDirtyBounds) { *inOutDirtyBounds = newDirtyRegion.getBounds(); } |