From 5fdf7b8d26f3cd1a2f2fb8a441d40d33270d3b77 Mon Sep 17 00:00:00 2001 From: Huihong Luo Date: Fri, 15 Jan 2021 14:27:06 -0800 Subject: Add SurfaceControl to hwui add a method, setSurfaceControl, for java layer to pass surface control to the render thread Bug: 173671170 Test: call setSurfaceControl method in ViewRootImpl.java Change-Id: I886a79c377938f19cf38b9058f2bec64e1439000 --- libs/hwui/renderthread/RenderThread.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'libs/hwui/renderthread/RenderThread.cpp') diff --git a/libs/hwui/renderthread/RenderThread.cpp b/libs/hwui/renderthread/RenderThread.cpp index 7750a31b817f..26101867c43f 100644 --- a/libs/hwui/renderthread/RenderThread.cpp +++ b/libs/hwui/renderthread/RenderThread.cpp @@ -33,6 +33,7 @@ #include #include +#include #include #include #include @@ -49,6 +50,17 @@ static bool gHasRenderThreadInstance = false; static JVMAttachHook gOnStartHook = nullptr; +ASurfaceControlFunctions::ASurfaceControlFunctions() { + void* handle_ = dlopen("libandroid.so", RTLD_NOW | RTLD_NODELETE); + acquireFunc = (ASC_acquire) dlsym(handle_, "ASurfaceControl_acquire"); + LOG_ALWAYS_FATAL_IF(acquireFunc == nullptr, + "Failed to find required symbol ASurfaceControl_acquire!"); + + releaseFunc = (ASC_release) dlsym(handle_, "ASurfaceControl_release"); + LOG_ALWAYS_FATAL_IF(releaseFunc == nullptr, + "Failed to find required symbol ASurfaceControl_release!"); +} + void RenderThread::frameCallback(int64_t frameTimeNanos, void* data) { RenderThread* rt = reinterpret_cast(data); int64_t vsyncId = AChoreographer_getVsyncId(rt->mChoreographer); -- cgit v1.2.3 From 71db8892acc0c80c343141139bde8cfd3f037c4a Mon Sep 17 00:00:00 2001 From: Jorim Jaggi Date: Wed, 3 Feb 2021 23:19:29 +0100 Subject: Add GPU completion to FrameMetrics (1/3) - Add SurfaceStatsCallback to TransactionCompletedListener - Register a callback in RenderProxy to be called when we have surface stats from SF via the BLAST callback. - Instead of finishing a frame for frame metrics reporting immediately, wait until BLAST callback fires, note GPU completion time and finish frame. - Expose GPU_COMPLETION in FrameMetrics - Modify TOTAL_DURATION to also include GPU_COMPLETION Test: FrameMetricsListenerTest Fixes: 171046219 Change-Id: I16fa1d80cfc4e7a5527c18fec7e885409f17ee4d --- libs/hwui/renderthread/RenderThread.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'libs/hwui/renderthread/RenderThread.cpp') diff --git a/libs/hwui/renderthread/RenderThread.cpp b/libs/hwui/renderthread/RenderThread.cpp index 26101867c43f..5dc02e8454ac 100644 --- a/libs/hwui/renderthread/RenderThread.cpp +++ b/libs/hwui/renderthread/RenderThread.cpp @@ -59,6 +59,26 @@ ASurfaceControlFunctions::ASurfaceControlFunctions() { releaseFunc = (ASC_release) dlsym(handle_, "ASurfaceControl_release"); LOG_ALWAYS_FATAL_IF(releaseFunc == nullptr, "Failed to find required symbol ASurfaceControl_release!"); + + registerListenerFunc = (ASC_registerSurfaceStatsListener) dlsym(handle_, + "ASurfaceControl_registerSurfaceStatsListener"); + LOG_ALWAYS_FATAL_IF(registerListenerFunc == nullptr, + "Failed to find required symbol ASurfaceControl_registerSurfaceStatsListener!"); + + unregisterListenerFunc = (ASC_unregisterSurfaceStatsListener) dlsym(handle_, + "ASurfaceControl_unregisterSurfaceStatsListener"); + LOG_ALWAYS_FATAL_IF(unregisterListenerFunc == nullptr, + "Failed to find required symbol ASurfaceControl_unregisterSurfaceStatsListener!"); + + getAcquireTimeFunc = (ASCStats_getAcquireTime) dlsym(handle_, + "ASurfaceControlStats_getAcquireTime"); + LOG_ALWAYS_FATAL_IF(getAcquireTimeFunc == nullptr, + "Failed to find required symbol ASurfaceControlStats_getAcquireTime!"); + + getFrameNumberFunc = (ASCStats_getFrameNumber) dlsym(handle_, + "ASurfaceControlStats_getFrameNumber"); + LOG_ALWAYS_FATAL_IF(getFrameNumberFunc == nullptr, + "Failed to find required symbol ASurfaceControlStats_getFrameNumber!"); } void RenderThread::frameCallback(int64_t frameTimeNanos, void* data) { @@ -146,7 +166,8 @@ RenderThread::RenderThread() , mFrameCallbackTaskPending(false) , mRenderState(nullptr) , mEglManager(nullptr) - , mFunctorManager(WebViewFunctorManager::instance()) { + , mFunctorManager(WebViewFunctorManager::instance()) + , mGlobalProfileData(mJankDataMutex) { Properties::load(); start("RenderThread"); } -- cgit v1.2.3