diff --git a/libs/gui/Surface.cpp b/libs/gui/Surface.cpp index 4b76f9834..444544221 100644 --- a/libs/gui/Surface.cpp +++ b/libs/gui/Surface.cpp @@ -1023,6 +1023,7 @@ status_t Surface::lock( } // figure out if we can copy the frontbuffer back + int backBufferSlot(getSlotFromBufferLocked(backBuffer.get())); const sp& frontBuffer(mPostedBuffer); const bool canCopyBack = (frontBuffer != 0 && backBuffer->width == frontBuffer->width && @@ -1030,15 +1031,19 @@ status_t Surface::lock( backBuffer->format == frontBuffer->format); if (canCopyBack) { - // copy the area that is invalid and not repainted this round - const Region copyback(mDirtyRegion.subtract(newDirtyRegion)); + Mutex::Autolock lock(mMutex); + Region oldDirtyRegion; + for(int i = 0 ; i < NUM_BUFFER_SLOTS; i++ ) { + if(i != backBufferSlot && !mSlots[i].dirtyRegion.isEmpty()) + oldDirtyRegion.orSelf(mSlots[i].dirtyRegion); + } + const Region copyback(oldDirtyRegion.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= 0) { - Region& dirtyRegion(mSlots[backBufferSlot].dirtyRegion); - mDirtyRegion.subtract(dirtyRegion); - dirtyRegion = newDirtyRegion; - } + mSlots[backBufferSlot].dirtyRegion = newDirtyRegion; } - mDirtyRegion.orSelf(newDirtyRegion); if (inOutDirtyBounds) { *inOutDirtyBounds = newDirtyRegion.getBounds(); }