Loading libs/hwui/WebViewFunctorManager.cpp +19 −0 Original line number Diff line number Diff line Loading @@ -86,6 +86,10 @@ void WebViewFunctor_release(int functor) { WebViewFunctorManager::instance().releaseFunctor(functor); } void WebViewFunctor_reportRenderingThreads(int functor, const int32_t* thread_ids, size_t size) { WebViewFunctorManager::instance().reportRenderingThreads(functor, thread_ids, size); } static std::atomic_int sNextId{1}; WebViewFunctor::WebViewFunctor(void* data, const WebViewFunctorCallbacks& callbacks, Loading Loading @@ -260,6 +264,10 @@ void WebViewFunctor::reparentSurfaceControl(ASurfaceControl* parent) { funcs.transactionDeleteFunc(transaction); } void WebViewFunctor::reportRenderingThreads(const int32_t* thread_ids, size_t size) { // TODO(b/329219352): Pass the threads to HWUI and update the ADPF session. } WebViewFunctorManager& WebViewFunctorManager::instance() { static WebViewFunctorManager sInstance; return sInstance; Loading Loading @@ -346,6 +354,17 @@ void WebViewFunctorManager::destroyFunctor(int functor) { } } void WebViewFunctorManager::reportRenderingThreads(int functor, const int32_t* thread_ids, size_t size) { std::lock_guard _lock{mLock}; for (auto& iter : mFunctors) { if (iter->id() == functor) { iter->reportRenderingThreads(thread_ids, size); break; } } } sp<WebViewFunctor::Handle> WebViewFunctorManager::handleFor(int functor) { std::lock_guard _lock{mLock}; for (auto& iter : mActiveFunctors) { Loading libs/hwui/WebViewFunctorManager.h +3 −0 Original line number Diff line number Diff line Loading @@ -81,6 +81,8 @@ public: ASurfaceControl* getSurfaceControl(); void mergeTransaction(ASurfaceTransaction* transaction); void reportRenderingThreads(const int32_t* thread_ids, size_t size); sp<Handle> createHandle() { LOG_ALWAYS_FATAL_IF(mCreatedHandle); mCreatedHandle = true; Loading Loading @@ -110,6 +112,7 @@ public: void releaseFunctor(int functor); void onContextDestroyed(); void destroyFunctor(int functor); void reportRenderingThreads(int functor, const int32_t* thread_ids, size_t size); sp<WebViewFunctor::Handle> handleFor(int functor); Loading libs/hwui/private/hwui/WebViewFunctor.h +5 −0 Original line number Diff line number Diff line Loading @@ -106,6 +106,11 @@ ANDROID_API int WebViewFunctor_create(void* data, const WebViewFunctorCallbacks& // and it should be considered alive & active until that point. ANDROID_API void WebViewFunctor_release(int functor); // Reports the list of threads critical for frame production for the given // functor. Must be called on render thread. ANDROID_API void WebViewFunctor_reportRenderingThreads(int functor, const int32_t* thread_ids, size_t size); } // namespace android::uirenderer #endif // FRAMEWORKS_BASE_WEBVIEWFUNCTOR_H native/webview/plat_support/draw_fn.h +8 −1 Original line number Diff line number Diff line Loading @@ -23,7 +23,8 @@ extern "C" { // 1 is Android Q. This matches kAwDrawGLInfoVersion version 3. // 2 Adds transfer_function_* and color_space_toXYZD50 to AwDrawFn_DrawGLParams. // 3 Adds SurfaceControl related functions. static const int kAwDrawFnVersion = 3; // 4 Adds AwDrawFn_ReportRenderingThreads to AwDrawFnFunctionTable. static const int kAwDrawFnVersion = 4; // Returns parent ASurfaceControl for WebView overlays. It will be have same // geometry as the surface we draw into and positioned below it (underlay). Loading Loading @@ -268,6 +269,10 @@ typedef int AwDrawFn_CreateFunctor_v3( // released, and it should be considered alive & active until that point. typedef void AwDrawFn_ReleaseFunctor(int functor); // Report the list of threads critical for frame production for the given // functor. Must be called on render thread. typedef void AwDrawFn_ReportRenderingThreads(int functor, const int32_t* thread_ids, size_t size); struct AwDrawFnFunctionTable { int version; AwDrawFn_QueryRenderMode* query_render_mode; Loading @@ -276,6 +281,8 @@ struct AwDrawFnFunctionTable { AwDrawFn_ReleaseFunctor* release_functor; // Added in version 3. AwDrawFn_CreateFunctor_v3* create_functor_v3; // Added in version 4. AwDrawFn_ReportRenderingThreads* report_rendering_threads; }; #ifdef __cplusplus Loading native/webview/plat_support/draw_functor.cpp +13 −8 Original line number Diff line number Diff line Loading @@ -290,6 +290,10 @@ AwDrawFnRenderMode QueryRenderMode(void) { } } void ReportRenderingThreads(int functor, const int32_t* thread_ids, size_t size) { uirenderer::WebViewFunctor_reportRenderingThreads(functor, thread_ids, size); } jlong GetDrawFnFunctionTable() { static AwDrawFnFunctionTable function_table = { .version = kAwDrawFnVersion, Loading @@ -297,6 +301,7 @@ jlong GetDrawFnFunctionTable() { .create_functor = &CreateFunctor, .release_functor = &ReleaseFunctor, .create_functor_v3 = &CreateFunctor_v3, .report_rendering_threads = &ReportRenderingThreads, }; return reinterpret_cast<intptr_t>(&function_table); } Loading Loading
libs/hwui/WebViewFunctorManager.cpp +19 −0 Original line number Diff line number Diff line Loading @@ -86,6 +86,10 @@ void WebViewFunctor_release(int functor) { WebViewFunctorManager::instance().releaseFunctor(functor); } void WebViewFunctor_reportRenderingThreads(int functor, const int32_t* thread_ids, size_t size) { WebViewFunctorManager::instance().reportRenderingThreads(functor, thread_ids, size); } static std::atomic_int sNextId{1}; WebViewFunctor::WebViewFunctor(void* data, const WebViewFunctorCallbacks& callbacks, Loading Loading @@ -260,6 +264,10 @@ void WebViewFunctor::reparentSurfaceControl(ASurfaceControl* parent) { funcs.transactionDeleteFunc(transaction); } void WebViewFunctor::reportRenderingThreads(const int32_t* thread_ids, size_t size) { // TODO(b/329219352): Pass the threads to HWUI and update the ADPF session. } WebViewFunctorManager& WebViewFunctorManager::instance() { static WebViewFunctorManager sInstance; return sInstance; Loading Loading @@ -346,6 +354,17 @@ void WebViewFunctorManager::destroyFunctor(int functor) { } } void WebViewFunctorManager::reportRenderingThreads(int functor, const int32_t* thread_ids, size_t size) { std::lock_guard _lock{mLock}; for (auto& iter : mFunctors) { if (iter->id() == functor) { iter->reportRenderingThreads(thread_ids, size); break; } } } sp<WebViewFunctor::Handle> WebViewFunctorManager::handleFor(int functor) { std::lock_guard _lock{mLock}; for (auto& iter : mActiveFunctors) { Loading
libs/hwui/WebViewFunctorManager.h +3 −0 Original line number Diff line number Diff line Loading @@ -81,6 +81,8 @@ public: ASurfaceControl* getSurfaceControl(); void mergeTransaction(ASurfaceTransaction* transaction); void reportRenderingThreads(const int32_t* thread_ids, size_t size); sp<Handle> createHandle() { LOG_ALWAYS_FATAL_IF(mCreatedHandle); mCreatedHandle = true; Loading Loading @@ -110,6 +112,7 @@ public: void releaseFunctor(int functor); void onContextDestroyed(); void destroyFunctor(int functor); void reportRenderingThreads(int functor, const int32_t* thread_ids, size_t size); sp<WebViewFunctor::Handle> handleFor(int functor); Loading
libs/hwui/private/hwui/WebViewFunctor.h +5 −0 Original line number Diff line number Diff line Loading @@ -106,6 +106,11 @@ ANDROID_API int WebViewFunctor_create(void* data, const WebViewFunctorCallbacks& // and it should be considered alive & active until that point. ANDROID_API void WebViewFunctor_release(int functor); // Reports the list of threads critical for frame production for the given // functor. Must be called on render thread. ANDROID_API void WebViewFunctor_reportRenderingThreads(int functor, const int32_t* thread_ids, size_t size); } // namespace android::uirenderer #endif // FRAMEWORKS_BASE_WEBVIEWFUNCTOR_H
native/webview/plat_support/draw_fn.h +8 −1 Original line number Diff line number Diff line Loading @@ -23,7 +23,8 @@ extern "C" { // 1 is Android Q. This matches kAwDrawGLInfoVersion version 3. // 2 Adds transfer_function_* and color_space_toXYZD50 to AwDrawFn_DrawGLParams. // 3 Adds SurfaceControl related functions. static const int kAwDrawFnVersion = 3; // 4 Adds AwDrawFn_ReportRenderingThreads to AwDrawFnFunctionTable. static const int kAwDrawFnVersion = 4; // Returns parent ASurfaceControl for WebView overlays. It will be have same // geometry as the surface we draw into and positioned below it (underlay). Loading Loading @@ -268,6 +269,10 @@ typedef int AwDrawFn_CreateFunctor_v3( // released, and it should be considered alive & active until that point. typedef void AwDrawFn_ReleaseFunctor(int functor); // Report the list of threads critical for frame production for the given // functor. Must be called on render thread. typedef void AwDrawFn_ReportRenderingThreads(int functor, const int32_t* thread_ids, size_t size); struct AwDrawFnFunctionTable { int version; AwDrawFn_QueryRenderMode* query_render_mode; Loading @@ -276,6 +281,8 @@ struct AwDrawFnFunctionTable { AwDrawFn_ReleaseFunctor* release_functor; // Added in version 3. AwDrawFn_CreateFunctor_v3* create_functor_v3; // Added in version 4. AwDrawFn_ReportRenderingThreads* report_rendering_threads; }; #ifdef __cplusplus Loading
native/webview/plat_support/draw_functor.cpp +13 −8 Original line number Diff line number Diff line Loading @@ -290,6 +290,10 @@ AwDrawFnRenderMode QueryRenderMode(void) { } } void ReportRenderingThreads(int functor, const int32_t* thread_ids, size_t size) { uirenderer::WebViewFunctor_reportRenderingThreads(functor, thread_ids, size); } jlong GetDrawFnFunctionTable() { static AwDrawFnFunctionTable function_table = { .version = kAwDrawFnVersion, Loading @@ -297,6 +301,7 @@ jlong GetDrawFnFunctionTable() { .create_functor = &CreateFunctor, .release_functor = &ReleaseFunctor, .create_functor_v3 = &CreateFunctor_v3, .report_rendering_threads = &ReportRenderingThreads, }; return reinterpret_cast<intptr_t>(&function_table); } Loading