fix copy back dirty region
Copyback dirty region logic does copyback, even when its not necessary causing 2ms delay. Fix the logic to copy back only what is necessary CRs-fixed: 562334 Change-Id: I52de68258ac9f87d704ee5401f93417805fa6773
This commit is contained in:
parent
cfd539bf4a
commit
8760f1673e
@ -1023,6 +1023,7 @@ status_t Surface::lock(
|
||||
}
|
||||
|
||||
// figure out if we can copy the frontbuffer back
|
||||
int backBufferSlot(getSlotFromBufferLocked(backBuffer.get()));
|
||||
const sp<GraphicBuffer>& 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<NUM_BUFFER_SLOTS ; i++) {
|
||||
mSlots[i].dirtyRegion.clear();
|
||||
@ -1048,15 +1053,9 @@ status_t Surface::lock(
|
||||
|
||||
{ // 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;
|
||||
}
|
||||
mSlots[backBufferSlot].dirtyRegion = newDirtyRegion;
|
||||
}
|
||||
|
||||
mDirtyRegion.orSelf(newDirtyRegion);
|
||||
if (inOutDirtyBounds) {
|
||||
*inOutDirtyBounds = newDirtyRegion.getBounds();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user