diff options
author | Bo Liu <boliu@google.com> | 2018-12-14 19:37:41 -0800 |
---|---|---|
committer | Bo Liu <boliu@google.com> | 2019-01-03 19:15:18 +0000 |
commit | d6668e7c0c59c0cf91bfb4d0491c526cd1d5e439 (patch) | |
tree | 874000f8906d220ed3b6b18c9a0fb17b37c8bf9b /libs/hwui/WebViewFunctorManager.cpp | |
parent | b34e8528ca7e6aee84ba5eef9739155f658690c5 (diff) |
Plumb new functor in native/webview
Add plumbing to native/webview for the new functor.
Add a void* data parameter to avoid having to use a thread safe
map for in both the plumbing and in webview.
Test: Compiles and webview runs
Bug: 120997728
Change-Id: I0f9f3acb05688a5afcf95974bc0b3b117f33a8e3
Diffstat (limited to 'libs/hwui/WebViewFunctorManager.cpp')
-rw-r--r-- | libs/hwui/WebViewFunctorManager.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/libs/hwui/WebViewFunctorManager.cpp b/libs/hwui/WebViewFunctorManager.cpp index 20e77b453706..5b7ae70e821c 100644 --- a/libs/hwui/WebViewFunctorManager.cpp +++ b/libs/hwui/WebViewFunctorManager.cpp @@ -37,7 +37,8 @@ RenderMode WebViewFunctor_queryPlatformRenderMode() { } } -int WebViewFunctor_create(const WebViewFunctorCallbacks& prototype, RenderMode functorMode) { +int WebViewFunctor_create(void* data, const WebViewFunctorCallbacks& prototype, + RenderMode functorMode) { if (functorMode != RenderMode::OpenGL_ES && functorMode != RenderMode::Vulkan) { ALOGW("Unknown rendermode %d", (int)functorMode); return -1; @@ -47,7 +48,7 @@ int WebViewFunctor_create(const WebViewFunctorCallbacks& prototype, RenderMode f ALOGW("Unable to map from GLES platform to a vulkan functor"); return -1; } - return WebViewFunctorManager::instance().createFunctor(prototype, functorMode); + return WebViewFunctorManager::instance().createFunctor(data, prototype, functorMode); } void WebViewFunctor_release(int functor) { @@ -56,7 +57,9 @@ void WebViewFunctor_release(int functor) { static std::atomic_int sNextId{1}; -WebViewFunctor::WebViewFunctor(const WebViewFunctorCallbacks& callbacks, RenderMode functorMode) { +WebViewFunctor::WebViewFunctor(void* data, const WebViewFunctorCallbacks& callbacks, + RenderMode functorMode) + : mData(data) { mFunctor = sNextId++; mCallbacks = callbacks; mMode = functorMode; @@ -66,12 +69,12 @@ WebViewFunctor::~WebViewFunctor() { destroyContext(); ATRACE_NAME("WebViewFunctor::onDestroy"); - mCallbacks.onDestroyed(mFunctor); + mCallbacks.onDestroyed(mFunctor, mData); } void WebViewFunctor::sync(const WebViewSyncData& syncData) const { ATRACE_NAME("WebViewFunctor::sync"); - mCallbacks.onSync(mFunctor, syncData); + mCallbacks.onSync(mFunctor, mData, syncData); } void WebViewFunctor::drawGl(const DrawGlInfo& drawInfo) { @@ -79,14 +82,14 @@ void WebViewFunctor::drawGl(const DrawGlInfo& drawInfo) { if (!mHasContext) { mHasContext = true; } - mCallbacks.gles.draw(mFunctor, drawInfo); + mCallbacks.gles.draw(mFunctor, mData, drawInfo); } void WebViewFunctor::destroyContext() { if (mHasContext) { mHasContext = false; ATRACE_NAME("WebViewFunctor::onContextDestroyed"); - mCallbacks.onContextDestroyed(mFunctor); + mCallbacks.onContextDestroyed(mFunctor, mData); } } @@ -95,9 +98,9 @@ WebViewFunctorManager& WebViewFunctorManager::instance() { return sInstance; } -int WebViewFunctorManager::createFunctor(const WebViewFunctorCallbacks& callbacks, +int WebViewFunctorManager::createFunctor(void* data, const WebViewFunctorCallbacks& callbacks, RenderMode functorMode) { - auto object = std::make_unique<WebViewFunctor>(callbacks, functorMode); + auto object = std::make_unique<WebViewFunctor>(data, callbacks, functorMode); int id = object->id(); auto handle = object->createHandle(); { @@ -164,4 +167,4 @@ sp<WebViewFunctor::Handle> WebViewFunctorManager::handleFor(int functor) { return nullptr; } -} // namespace android::uirenderer
\ No newline at end of file +} // namespace android::uirenderer |