From c78bb0c3fd618f5bc91c11b3baea873684accef7 Mon Sep 17 00:00:00 2001 From: juwenjing Date: Thu, 21 Nov 2024 06:49:25 +0000 Subject: [PATCH 1/4] update ui/gl/gl_fence_android_native_fence_sync.cc. Signed-off-by: juwenjing --- ui/gl/gl_fence_android_native_fence_sync.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ui/gl/gl_fence_android_native_fence_sync.cc b/ui/gl/gl_fence_android_native_fence_sync.cc index 5d4c03b98d..cd6f798780 100644 --- a/ui/gl/gl_fence_android_native_fence_sync.cc +++ b/ui/gl/gl_fence_android_native_fence_sync.cc @@ -94,12 +94,14 @@ GLFenceAndroidNativeFenceSync::~GLFenceAndroidNativeFenceSync() {} // static std::unique_ptr GLFenceAndroidNativeFenceSync::CreateInternal(EGLenum type, EGLint* attribs) { + LOG(INFO) << "jwjwj CreateInternal " << GLSurfaceEGL::GetGLDisplayEGL()->IsAndroidNativeFenceSyncSupported(); DCHECK(GLSurfaceEGL::GetGLDisplayEGL()->IsAndroidNativeFenceSyncSupported()); // Can't use MakeUnique, the no-args constructor is private. auto fence = base::WrapUnique(new GLFenceAndroidNativeFenceSync()); if (!fence->InitializeInternal(type, attribs)) { + LOG(INFO) << "jwjwj InitializeInternal fail"; #if BUILDFLAG(IS_CHROMEOS) SetFDCrashKeys(); #endif @@ -126,8 +128,18 @@ GLFenceAndroidNativeFenceSync::CreateFromGpuFence( } std::unique_ptr GLFenceAndroidNativeFenceSync::GetGpuFence() { + LOG(INFO) << "jwjwj GetGpuFence " << GLSurfaceEGL::GetGLDisplayEGL()->IsAndroidNativeFenceSyncSupported(); DCHECK(GLSurfaceEGL::GetGLDisplayEGL()->IsAndroidNativeFenceSyncSupported()); + LOG(INFO) << "jwjwj display_: " << (display_ != EGL_NO_DISPLAY) << ", sync_: " << (sync_ != EGL_NO_SYNC_KHR); + if (display_ == nullptr) { + LOG(INFO) << "jwjwj display_ null"; + } + + if (sync_ == nullptr) { + LOG(INFO) << "jwjwj sync_ null"; + } + const EGLint sync_fd = eglDupNativeFenceFDANDROID(display_, sync_); if (sync_fd < 0) { #if BUILDFLAG(IS_CHROMEOS) -- Gitee From 4c996db44570d5508c50a73104250b484692ceb9 Mon Sep 17 00:00:00 2001 From: juwenjing Date: Fri, 22 Nov 2024 10:36:29 +0800 Subject: [PATCH 2/4] fix Signed-off-by: juwenjing --- .../same_layer_native_buffer_image_backing.cc | 2 +- ui/gl/gl_fence_android_native_fence_sync.cc | 12 ------- ui/gl/ohos/native_buffer_utils.cc | 32 +++++++++++++++++++ ui/gl/ohos/native_buffer_utils.h | 2 ++ 4 files changed, 35 insertions(+), 13 deletions(-) diff --git a/gpu/command_buffer/service/ohos/same_layer_native_buffer_image_backing.cc b/gpu/command_buffer/service/ohos/same_layer_native_buffer_image_backing.cc index 88930607cc..051d5efe70 100644 --- a/gpu/command_buffer/service/ohos/same_layer_native_buffer_image_backing.cc +++ b/gpu/command_buffer/service/ohos/same_layer_native_buffer_image_backing.cc @@ -210,7 +210,7 @@ class SameLayerNativeBufferImageBacking::GLTextureVideoImageRepresentation TRACE_EVENT0("gpu", "SameLayerNativeBufferImageBacking::" "GLTextureVideoImageRepresentation::EndAccess"); - base::ScopedFD sync_fd = gl::CreateEglFenceAndExportFd(); + base::ScopedFD sync_fd = gl::ohos::CreateEglFenceAndExportFd(); scoped_native_buffer_->SetReadFence(std::move(sync_fd)); base::AutoLockMaybe auto_lock(GetDrDcLockPtr()); diff --git a/ui/gl/gl_fence_android_native_fence_sync.cc b/ui/gl/gl_fence_android_native_fence_sync.cc index cd6f798780..5d4c03b98d 100644 --- a/ui/gl/gl_fence_android_native_fence_sync.cc +++ b/ui/gl/gl_fence_android_native_fence_sync.cc @@ -94,14 +94,12 @@ GLFenceAndroidNativeFenceSync::~GLFenceAndroidNativeFenceSync() {} // static std::unique_ptr GLFenceAndroidNativeFenceSync::CreateInternal(EGLenum type, EGLint* attribs) { - LOG(INFO) << "jwjwj CreateInternal " << GLSurfaceEGL::GetGLDisplayEGL()->IsAndroidNativeFenceSyncSupported(); DCHECK(GLSurfaceEGL::GetGLDisplayEGL()->IsAndroidNativeFenceSyncSupported()); // Can't use MakeUnique, the no-args constructor is private. auto fence = base::WrapUnique(new GLFenceAndroidNativeFenceSync()); if (!fence->InitializeInternal(type, attribs)) { - LOG(INFO) << "jwjwj InitializeInternal fail"; #if BUILDFLAG(IS_CHROMEOS) SetFDCrashKeys(); #endif @@ -128,18 +126,8 @@ GLFenceAndroidNativeFenceSync::CreateFromGpuFence( } std::unique_ptr GLFenceAndroidNativeFenceSync::GetGpuFence() { - LOG(INFO) << "jwjwj GetGpuFence " << GLSurfaceEGL::GetGLDisplayEGL()->IsAndroidNativeFenceSyncSupported(); DCHECK(GLSurfaceEGL::GetGLDisplayEGL()->IsAndroidNativeFenceSyncSupported()); - LOG(INFO) << "jwjwj display_: " << (display_ != EGL_NO_DISPLAY) << ", sync_: " << (sync_ != EGL_NO_SYNC_KHR); - if (display_ == nullptr) { - LOG(INFO) << "jwjwj display_ null"; - } - - if (sync_ == nullptr) { - LOG(INFO) << "jwjwj sync_ null"; - } - const EGLint sync_fd = eglDupNativeFenceFDANDROID(display_, sync_); if (sync_fd < 0) { #if BUILDFLAG(IS_CHROMEOS) diff --git a/ui/gl/ohos/native_buffer_utils.cc b/ui/gl/ohos/native_buffer_utils.cc index d2f22f9350..04d8cef21a 100644 --- a/ui/gl/ohos/native_buffer_utils.cc +++ b/ui/gl/ohos/native_buffer_utils.cc @@ -73,5 +73,37 @@ bool InsertEglFenceAndWait(base::ScopedFD acquire_fence_fd) { return true; } +base::ScopedFD CreateEglFenceAndExportFd() { + if (!gl::GLSurfaceEGL::GetGLDisplayEGL() + ->IsAndroidNativeFenceSyncSupported()) { + LOG(ERROR) << "Unable to support native fence!"; + return base::ScopedFD(); + } + + EGLSyncKHR sync = EGL_NO_SYNC_KHR; + EGLDisplay display = eglGetCurrentDisplay(); + if (display != EGL_NO_DISPLAY) { + glFlush(); + sync = eglCreateSyncKHR(display, EGL_SYNC_NATIVE_FENCE_ANDROID, nullptr); + glFlush(); + } + + if (sync == EGL_NO_SYNC_KHR) { + LOG(ERROR) << "Unable to get EGLSyncKHR."; + return base::ScopedFD(); + } + + const EGLint sync_fd = eglDupNativeFenceFDANDROID(display, sync); + if (sync_fd < 0) { + LOG(ERROR) << "Unable to get a gpu fence."; + return base::ScopedFD(); + } + + if (display != EGL_NO_DISPLAY) { + eglDestroySyncKHR(display, sync); + } + + return base::ScopedFD(sync_fd); +} } // namespace ohos } // namespace gl diff --git a/ui/gl/ohos/native_buffer_utils.h b/ui/gl/ohos/native_buffer_utils.h index 9d4b5e5d5c..5c091e4431 100644 --- a/ui/gl/ohos/native_buffer_utils.h +++ b/ui/gl/ohos/native_buffer_utils.h @@ -30,6 +30,8 @@ GL_EXPORT void FreeEGLClientBuffer(EGLClientBuffer egl_client_buffer); GL_EXPORT bool InsertEglFenceAndWait(base::ScopedFD acquire_fence_fd); +GL_EXPORT base::ScopedFD CreateEglFenceAndExportFd(); + } // namespace ohos } // namespace gl -- Gitee From 2ddc89fb458f8921c66a4a3233287d975b93d800 Mon Sep 17 00:00:00 2001 From: juwenjing Date: Fri, 22 Nov 2024 10:53:53 +0800 Subject: [PATCH 3/4] codecheck Signed-off-by: juwenjing --- ui/gl/ohos/native_buffer_utils.cc | 63 ++++++++++++++++--------------- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/ui/gl/ohos/native_buffer_utils.cc b/ui/gl/ohos/native_buffer_utils.cc index 04d8cef21a..3ec07dda43 100644 --- a/ui/gl/ohos/native_buffer_utils.cc +++ b/ui/gl/ohos/native_buffer_utils.cc @@ -73,37 +73,38 @@ bool InsertEglFenceAndWait(base::ScopedFD acquire_fence_fd) { return true; } -base::ScopedFD CreateEglFenceAndExportFd() { - if (!gl::GLSurfaceEGL::GetGLDisplayEGL() - ->IsAndroidNativeFenceSyncSupported()) { - LOG(ERROR) << "Unable to support native fence!"; - return base::ScopedFD(); - } - - EGLSyncKHR sync = EGL_NO_SYNC_KHR; - EGLDisplay display = eglGetCurrentDisplay(); - if (display != EGL_NO_DISPLAY) { - glFlush(); - sync = eglCreateSyncKHR(display, EGL_SYNC_NATIVE_FENCE_ANDROID, nullptr); - glFlush(); - } - - if (sync == EGL_NO_SYNC_KHR) { - LOG(ERROR) << "Unable to get EGLSyncKHR."; - return base::ScopedFD(); - } - - const EGLint sync_fd = eglDupNativeFenceFDANDROID(display, sync); - if (sync_fd < 0) { - LOG(ERROR) << "Unable to get a gpu fence."; - return base::ScopedFD(); - } - - if (display != EGL_NO_DISPLAY) { - eglDestroySyncKHR(display, sync); - } - - return base::ScopedFD(sync_fd); +base::ScopedFD CreateEglFenceAndExportFd() +{ + if (!gl::GLSurfaceEGL::GetGLDisplayEGL() + ->IsAndroidNativeFenceSyncSupported()) { + LOG(ERROR) << "Unable to support native fence!"; + return base::ScopedFD(); + } + + EGLSyncKHR sync = EGL_NO_SYNC_KHR; + EGLDisplay display = eglGetCurrentDisplay(); + if (display != EGL_NO_DISPLAY) { + glFlush(); + sync = eglCreateSyncKHR(display, EGL_SYNC_NATIVE_FENCE_ANDROID, nullptr); + glFlush(); + } + + if (sync == EGL_NO_SYNC_KHR) { + LOG(ERROR) << "Unable to get EGLSyncKHR."; + return base::ScopedFD(); + } + + const EGLint sync_fd = eglDupNativeFenceFDANDROID(display, sync); + if (sync_fd < 0) { + LOG(ERROR) << "Unable to get a gpu fence."; + return base::ScopedFD(); + } + + if (display != EGL_NO_DISPLAY) { + eglDestroySyncKHR(display, sync); + } + + return base::ScopedFD(sync_fd); } } // namespace ohos } // namespace gl -- Gitee From e394146eb6925e750b743532b1f9bb22ea4e4a95 Mon Sep 17 00:00:00 2001 From: juwenjing Date: Fri, 22 Nov 2024 06:28:09 +0000 Subject: [PATCH 4/4] update ui/gl/ohos/native_buffer_utils.cc. Signed-off-by: juwenjing --- ui/gl/ohos/native_buffer_utils.cc | 6 ------ 1 file changed, 6 deletions(-) diff --git a/ui/gl/ohos/native_buffer_utils.cc b/ui/gl/ohos/native_buffer_utils.cc index 3ec07dda43..b07f5bf175 100644 --- a/ui/gl/ohos/native_buffer_utils.cc +++ b/ui/gl/ohos/native_buffer_utils.cc @@ -84,9 +84,7 @@ base::ScopedFD CreateEglFenceAndExportFd() EGLSyncKHR sync = EGL_NO_SYNC_KHR; EGLDisplay display = eglGetCurrentDisplay(); if (display != EGL_NO_DISPLAY) { - glFlush(); sync = eglCreateSyncKHR(display, EGL_SYNC_NATIVE_FENCE_ANDROID, nullptr); - glFlush(); } if (sync == EGL_NO_SYNC_KHR) { @@ -100,10 +98,6 @@ base::ScopedFD CreateEglFenceAndExportFd() return base::ScopedFD(); } - if (display != EGL_NO_DISPLAY) { - eglDestroySyncKHR(display, sync); - } - return base::ScopedFD(sync_fd); } } // namespace ohos -- Gitee