From 76ef94f545f57fe35762044800627b08bbee7183 Mon Sep 17 00:00:00 2001 From: liaosirui Date: Tue, 8 Sep 2020 21:22:33 +0800 Subject: [PATCH 1/2] Fix screen flicker in Youdao dictionary. --- libs/gui/Surface.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/libs/gui/Surface.cpp b/libs/gui/Surface.cpp index 9115425cc..f1dcaf0d6 100644 --- a/libs/gui/Surface.cpp +++ b/libs/gui/Surface.cpp @@ -1233,6 +1233,14 @@ status_t Surface::lock( ALOGE("Surface::lock failed, already locked"); return INVALID_OPERATION; } + + uint32_t lockUsage; + if (inOutDirtyBounds) { + lockUsage = GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN; + } else { + lockUsage = GRALLOC_USAGE_SW_WRITE_OFTEN; + } + if (!mConnectedToCpu) { int err = Surface::connect(NATIVE_WINDOW_API_CPU); @@ -1240,7 +1248,7 @@ status_t Surface::lock( return err; } // we're intending to do software rendering from this point - setUsage(GRALLOC_USAGE_SW_WRITE_OFTEN); + setUsage(lockUsage); } ANativeWindowBuffer* out; @@ -1299,9 +1307,8 @@ status_t Surface::lock( } void* vaddr; - status_t res = backBuffer->lockAsync( - GRALLOC_USAGE_SW_WRITE_OFTEN, - newDirtyRegion.bounds(), &vaddr, fenceFd); + status_t res = backBuffer->lockAsync( + lockUsage, newDirtyRegion.bounds(), &vaddr, fenceFd); ALOGW_IF(res, "failed locking buffer (handle = %p)", backBuffer->handle); -- Gitee From ee66a97dfebcf4b3049243af9dd8c702b2ab548e Mon Sep 17 00:00:00 2001 From: liaosirui Date: Tue, 8 Sep 2020 21:26:37 +0800 Subject: [PATCH 2/2] fix code style --- libs/gui/Surface.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/gui/Surface.cpp b/libs/gui/Surface.cpp index f1dcaf0d6..d9e6cf00a 100644 --- a/libs/gui/Surface.cpp +++ b/libs/gui/Surface.cpp @@ -1248,7 +1248,7 @@ status_t Surface::lock( return err; } // we're intending to do software rendering from this point - setUsage(lockUsage); + setUsage(lockUsage); } ANativeWindowBuffer* out; @@ -1307,7 +1307,7 @@ status_t Surface::lock( } void* vaddr; - status_t res = backBuffer->lockAsync( + status_t res = backBuffer->lockAsync( lockUsage, newDirtyRegion.bounds(), &vaddr, fenceFd); ALOGW_IF(res, "failed locking buffer (handle = %p)", -- Gitee