Loading libs/hwui/WebViewFunctorManager.cpp +22 −0 Original line number Diff line number Diff line Loading @@ -221,8 +221,30 @@ WebViewFunctorManager& WebViewFunctorManager::instance() { return sInstance; } static void validateCallbacks(const WebViewFunctorCallbacks& callbacks) { // TODO: Should we do a stack peek to see if this is really webview? LOG_ALWAYS_FATAL_IF(callbacks.onSync == nullptr, "onSync is null"); LOG_ALWAYS_FATAL_IF(callbacks.onContextDestroyed == nullptr, "onContextDestroyed is null"); LOG_ALWAYS_FATAL_IF(callbacks.onDestroyed == nullptr, "onDestroyed is null"); LOG_ALWAYS_FATAL_IF(callbacks.removeOverlays == nullptr, "removeOverlays is null"); switch (auto mode = WebViewFunctor_queryPlatformRenderMode()) { case RenderMode::OpenGL_ES: LOG_ALWAYS_FATAL_IF(callbacks.gles.draw == nullptr, "gles.draw is null"); break; case RenderMode::Vulkan: LOG_ALWAYS_FATAL_IF(callbacks.vk.initialize == nullptr, "vk.initialize is null"); LOG_ALWAYS_FATAL_IF(callbacks.vk.draw == nullptr, "vk.draw is null"); LOG_ALWAYS_FATAL_IF(callbacks.vk.postDraw == nullptr, "vk.postDraw is null"); break; default: LOG_ALWAYS_FATAL("unknown platform mode? %d", (int)mode); break; } } int WebViewFunctorManager::createFunctor(void* data, const WebViewFunctorCallbacks& callbacks, RenderMode functorMode) { validateCallbacks(callbacks); auto object = std::make_unique<WebViewFunctor>(data, callbacks, functorMode); int id = object->id(); auto handle = object->createHandle(); Loading libs/hwui/tests/common/TestUtils.h +7 −0 Original line number Diff line number Diff line Loading @@ -287,6 +287,7 @@ public: int sync = 0; int contextDestroyed = 0; int destroyed = 0; int removeOverlays = 0; int glesDraw = 0; }; Loading @@ -311,6 +312,12 @@ public: expectOnRenderThread("onDestroyed"); sMockFunctorCounts[functor].destroyed++; }, .removeOverlays = [](int functor, void* data, void (*mergeTransaction)(ASurfaceTransaction*)) { expectOnRenderThread("removeOverlays"); sMockFunctorCounts[functor].removeOverlays++; }, }; switch (mode) { case RenderMode::OpenGL_ES: Loading libs/hwui/tests/unit/main.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -62,8 +62,10 @@ int main(int argc, char* argv[]) { gSigChain.insert(pair<int, struct sigaction>(sig, old_sa)); } // Replace the default GLES driver // Avoid talking to SF Properties::isolatedProcess = true; // Default to GLES (Vulkan-aware tests will override this) Properties::overrideRenderPipelineType(RenderPipelineType::SkiaGL); // Run the tests testing::InitGoogleTest(&argc, argv); Loading native/webview/plat_support/draw_functor.cpp +35 −36 Original line number Diff line number Diff line Loading @@ -192,26 +192,25 @@ void postDrawVk(int functor, void* data) { int CreateFunctor_v3(void* data, int version, AwDrawFnFunctorCallbacks* functor_callbacks) { static bool callbacks_initialized = false; static uirenderer::WebViewFunctorCallbacks webview_functor_callbacks = { static uirenderer::WebViewFunctorCallbacks webview_functor_callbacks = [] { uirenderer::WebViewFunctorCallbacks ret = { .onSync = &onSync, .onContextDestroyed = &onContextDestroyed, .onDestroyed = &onDestroyed, .removeOverlays = &removeOverlays, }; if (!callbacks_initialized) { switch (uirenderer::WebViewFunctor_queryPlatformRenderMode()) { case uirenderer::RenderMode::OpenGL_ES: webview_functor_callbacks.gles.draw = &draw_gl; ret.gles.draw = &draw_gl; break; case uirenderer::RenderMode::Vulkan: webview_functor_callbacks.vk.initialize = &initializeVk; webview_functor_callbacks.vk.draw = &drawVk; webview_functor_callbacks.vk.postDraw = &postDrawVk; ret.vk.initialize = &initializeVk; ret.vk.draw = &drawVk; ret.vk.postDraw = &postDrawVk; break; } callbacks_initialized = true; } return ret; }(); SupportData* support = new SupportData{ .data = data, }; Loading Loading
libs/hwui/WebViewFunctorManager.cpp +22 −0 Original line number Diff line number Diff line Loading @@ -221,8 +221,30 @@ WebViewFunctorManager& WebViewFunctorManager::instance() { return sInstance; } static void validateCallbacks(const WebViewFunctorCallbacks& callbacks) { // TODO: Should we do a stack peek to see if this is really webview? LOG_ALWAYS_FATAL_IF(callbacks.onSync == nullptr, "onSync is null"); LOG_ALWAYS_FATAL_IF(callbacks.onContextDestroyed == nullptr, "onContextDestroyed is null"); LOG_ALWAYS_FATAL_IF(callbacks.onDestroyed == nullptr, "onDestroyed is null"); LOG_ALWAYS_FATAL_IF(callbacks.removeOverlays == nullptr, "removeOverlays is null"); switch (auto mode = WebViewFunctor_queryPlatformRenderMode()) { case RenderMode::OpenGL_ES: LOG_ALWAYS_FATAL_IF(callbacks.gles.draw == nullptr, "gles.draw is null"); break; case RenderMode::Vulkan: LOG_ALWAYS_FATAL_IF(callbacks.vk.initialize == nullptr, "vk.initialize is null"); LOG_ALWAYS_FATAL_IF(callbacks.vk.draw == nullptr, "vk.draw is null"); LOG_ALWAYS_FATAL_IF(callbacks.vk.postDraw == nullptr, "vk.postDraw is null"); break; default: LOG_ALWAYS_FATAL("unknown platform mode? %d", (int)mode); break; } } int WebViewFunctorManager::createFunctor(void* data, const WebViewFunctorCallbacks& callbacks, RenderMode functorMode) { validateCallbacks(callbacks); auto object = std::make_unique<WebViewFunctor>(data, callbacks, functorMode); int id = object->id(); auto handle = object->createHandle(); Loading
libs/hwui/tests/common/TestUtils.h +7 −0 Original line number Diff line number Diff line Loading @@ -287,6 +287,7 @@ public: int sync = 0; int contextDestroyed = 0; int destroyed = 0; int removeOverlays = 0; int glesDraw = 0; }; Loading @@ -311,6 +312,12 @@ public: expectOnRenderThread("onDestroyed"); sMockFunctorCounts[functor].destroyed++; }, .removeOverlays = [](int functor, void* data, void (*mergeTransaction)(ASurfaceTransaction*)) { expectOnRenderThread("removeOverlays"); sMockFunctorCounts[functor].removeOverlays++; }, }; switch (mode) { case RenderMode::OpenGL_ES: Loading
libs/hwui/tests/unit/main.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -62,8 +62,10 @@ int main(int argc, char* argv[]) { gSigChain.insert(pair<int, struct sigaction>(sig, old_sa)); } // Replace the default GLES driver // Avoid talking to SF Properties::isolatedProcess = true; // Default to GLES (Vulkan-aware tests will override this) Properties::overrideRenderPipelineType(RenderPipelineType::SkiaGL); // Run the tests testing::InitGoogleTest(&argc, argv); Loading
native/webview/plat_support/draw_functor.cpp +35 −36 Original line number Diff line number Diff line Loading @@ -192,26 +192,25 @@ void postDrawVk(int functor, void* data) { int CreateFunctor_v3(void* data, int version, AwDrawFnFunctorCallbacks* functor_callbacks) { static bool callbacks_initialized = false; static uirenderer::WebViewFunctorCallbacks webview_functor_callbacks = { static uirenderer::WebViewFunctorCallbacks webview_functor_callbacks = [] { uirenderer::WebViewFunctorCallbacks ret = { .onSync = &onSync, .onContextDestroyed = &onContextDestroyed, .onDestroyed = &onDestroyed, .removeOverlays = &removeOverlays, }; if (!callbacks_initialized) { switch (uirenderer::WebViewFunctor_queryPlatformRenderMode()) { case uirenderer::RenderMode::OpenGL_ES: webview_functor_callbacks.gles.draw = &draw_gl; ret.gles.draw = &draw_gl; break; case uirenderer::RenderMode::Vulkan: webview_functor_callbacks.vk.initialize = &initializeVk; webview_functor_callbacks.vk.draw = &drawVk; webview_functor_callbacks.vk.postDraw = &postDrawVk; ret.vk.initialize = &initializeVk; ret.vk.draw = &drawVk; ret.vk.postDraw = &postDrawVk; break; } callbacks_initialized = true; } return ret; }(); SupportData* support = new SupportData{ .data = data, }; Loading