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
|
// figure out if we can copy the frontbuffer back
|
||||||
|
int backBufferSlot(getSlotFromBufferLocked(backBuffer.get()));
|
||||||
const sp<GraphicBuffer>& frontBuffer(mPostedBuffer);
|
const sp<GraphicBuffer>& frontBuffer(mPostedBuffer);
|
||||||
const bool canCopyBack = (frontBuffer != 0 &&
|
const bool canCopyBack = (frontBuffer != 0 &&
|
||||||
backBuffer->width == frontBuffer->width &&
|
backBuffer->width == frontBuffer->width &&
|
||||||
@ -1030,15 +1031,19 @@ status_t Surface::lock(
|
|||||||
backBuffer->format == frontBuffer->format);
|
backBuffer->format == frontBuffer->format);
|
||||||
|
|
||||||
if (canCopyBack) {
|
if (canCopyBack) {
|
||||||
// copy the area that is invalid and not repainted this round
|
Mutex::Autolock lock(mMutex);
|
||||||
const Region copyback(mDirtyRegion.subtract(newDirtyRegion));
|
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())
|
if (!copyback.isEmpty())
|
||||||
copyBlt(backBuffer, frontBuffer, copyback);
|
copyBlt(backBuffer, frontBuffer, copyback);
|
||||||
} else {
|
} else {
|
||||||
// if we can't copy-back anything, modify the user's dirty
|
// if we can't copy-back anything, modify the user's dirty
|
||||||
// region to make sure they redraw the whole buffer
|
// region to make sure they redraw the whole buffer
|
||||||
newDirtyRegion.set(bounds);
|
newDirtyRegion.set(bounds);
|
||||||
mDirtyRegion.clear();
|
|
||||||
Mutex::Autolock lock(mMutex);
|
Mutex::Autolock lock(mMutex);
|
||||||
for (size_t i=0 ; i<NUM_BUFFER_SLOTS ; i++) {
|
for (size_t i=0 ; i<NUM_BUFFER_SLOTS ; i++) {
|
||||||
mSlots[i].dirtyRegion.clear();
|
mSlots[i].dirtyRegion.clear();
|
||||||
@ -1048,15 +1053,9 @@ status_t Surface::lock(
|
|||||||
|
|
||||||
{ // scope for the lock
|
{ // scope for the lock
|
||||||
Mutex::Autolock lock(mMutex);
|
Mutex::Autolock lock(mMutex);
|
||||||
int backBufferSlot(getSlotFromBufferLocked(backBuffer.get()));
|
mSlots[backBufferSlot].dirtyRegion = newDirtyRegion;
|
||||||
if (backBufferSlot >= 0) {
|
|
||||||
Region& dirtyRegion(mSlots[backBufferSlot].dirtyRegion);
|
|
||||||
mDirtyRegion.subtract(dirtyRegion);
|
|
||||||
dirtyRegion = newDirtyRegion;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mDirtyRegion.orSelf(newDirtyRegion);
|
|
||||||
if (inOutDirtyBounds) {
|
if (inOutDirtyBounds) {
|
||||||
*inOutDirtyBounds = newDirtyRegion.getBounds();
|
*inOutDirtyBounds = newDirtyRegion.getBounds();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user