mirror of
https://github.com/team-infusion-developers/android_hardware_samsung.git
synced 2024-11-06 21:55:41 +00:00
gralloc: Update freed buffermask at alloc
This fixes screen tearing because of the change of HIDL behavior. The buffer is freed before the next allocation causing the bufferslots always be unused at allocation. Only the first buffer in the framebuffer /dev/graphics/fb0 was used. Thanks to @Chronomonochrome for pointing out the issue in gralloc. Change-Id: If1f6eb667506743cca828fbf87a45e7c2ee849a9
This commit is contained in:
parent
ca4cd7f5c3
commit
07865c0821
2 changed files with 12 additions and 1 deletions
|
@ -61,6 +61,8 @@ struct private_module_t {
|
|||
uint32_t flags;
|
||||
uint32_t numBuffers;
|
||||
uint32_t bufferMask;
|
||||
uint32_t bufferFreedMask;
|
||||
|
||||
pthread_mutex_t lock;
|
||||
buffer_handle_t currentBuffer;
|
||||
int ion_client;
|
||||
|
|
|
@ -453,14 +453,21 @@ static int gralloc_alloc_framebuffer_locked(alloc_device_t* dev, size_t size, in
|
|||
ALOGD_IF(debug_level > 0, "%s current=0x%x vaddr=0x%x l_paddr=0x%x before", __func__, current, vaddr, l_paddr);
|
||||
|
||||
/* find a free slot */
|
||||
uint32_t freeSlot = numBuffers -1;
|
||||
for (uint32_t i = 0; i < numBuffers; i++) {
|
||||
if ((bufferMask & (1LU<<i)) == 0) {
|
||||
m->bufferMask |= (1LU<<i);
|
||||
freeSlot = i;
|
||||
break;
|
||||
}
|
||||
current += bufferSize;
|
||||
l_paddr = vaddr + current;
|
||||
}
|
||||
ALOGE("%d: Using bufferslot:%d", __func__, freeSlot);
|
||||
|
||||
/* Update buffermask with freed slots */
|
||||
m->bufferMask ^= m->bufferFreedMask;
|
||||
m->bufferFreedMask &= m->bufferMask;
|
||||
|
||||
ALOGD_IF(debug_level > 0, "%s current=0x%x vaddr=0x%x l_paddr=0x%x after", __func__, current, vaddr, l_paddr);
|
||||
|
||||
|
@ -683,7 +690,9 @@ static int alloc_device_free(alloc_device_t* dev, buffer_handle_t handle)
|
|||
const size_t bufferSize = m->finfo.line_length * m->info.yres;
|
||||
int index = (hnd->base - m->framebuffer->base) / bufferSize;
|
||||
|
||||
m->bufferMask &= ~(1<<index);
|
||||
/* Mark slot as freed */
|
||||
m->bufferFreedMask |= (1LU<<index);
|
||||
|
||||
close(hnd->fd);
|
||||
|
||||
} else if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_UMP) {
|
||||
|
|
Loading…
Reference in a new issue