Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

frameworks/native: 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.

Change-Id: I52de68258ac9f87d704ee5401f93417805fa6773
  • Loading branch information...
commit c9399db58b79febd8b503296d1802652340e182a 1 parent 8793184
Omprakash Dhyade authored Whitehawkx committed
Showing with 23 additions and 1 deletion.
  1. +23 −1 libs/gui/SurfaceTextureClient.cpp
View
24 libs/gui/SurfaceTextureClient.cpp
@@ -741,16 +741,31 @@ status_t SurfaceTextureClient::lock(
backBuffer->height == frontBuffer->height &&
backBuffer->format == frontBuffer->format);
+#ifdef QCOMHW
+ int backBufferSlot(getSlotFromBufferLocked(backBuffer.get()));
+#endif
if (canCopyBack) {
// copy the area that is invalid and not repainted this round
+#ifdef QCOMHW
+ 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));
+#else
const Region copyback(mDirtyRegion.subtract(newDirtyRegion));
+#endif
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);
+#ifndef QCOMHW
mDirtyRegion.clear();
+#endif
Mutex::Autolock lock(mMutex);
for (size_t i=0 ; i<NUM_BUFFER_SLOTS ; i++) {
mSlots[i].dirtyRegion.clear();
@@ -760,15 +775,22 @@ status_t SurfaceTextureClient::lock(
{ // scope for the lock
Mutex::Autolock lock(mMutex);
+#ifdef QCOMHW
+ mSlots[backBufferSlot].dirtyRegion = newDirtyRegion;
+#else
int backBufferSlot(getSlotFromBufferLocked(backBuffer.get()));
if (backBufferSlot >= 0) {
Region& dirtyRegion(mSlots[backBufferSlot].dirtyRegion);
mDirtyRegion.subtract(dirtyRegion);
dirtyRegion = newDirtyRegion;
}
+#endif
}
- mDirtyRegion.orSelf(newDirtyRegion);
+#ifndef QCOMHW
+ mDirtyRegion.orSelf(newDirtyRegion);
+#endif
+
if (inOutDirtyBounds) {
*inOutDirtyBounds = newDirtyRegion.getBounds();
}
Please sign in to comment.
Something went wrong with that request. Please try again.