diff options
author | Scott Lobdell <slobdell@google.com> | 2021-04-25 19:53:32 +0000 |
---|---|---|
committer | Daniel Norman <danielnorman@google.com> | 2021-04-29 09:44:07 -0700 |
commit | 2051462f672b5986ef321bf1de3657e7653864e8 (patch) | |
tree | 1dee6334f2b0a68d3cc2e532e6f89bb16149aa7d /libs/hwui/WebViewFunctorManager.cpp | |
parent | b22baa1593b2ee33200d009f7f56d1c44a75ac6d (diff) | |
parent | ab6136865a519a27d731b4caa3e782bdf02cfd91 (diff) |
Merge SP1A.210425.001
Change-Id: I8d45e47c131320cac5e794fd629fdef84dd3bcfc
Diffstat (limited to 'libs/hwui/WebViewFunctorManager.cpp')
-rw-r--r-- | libs/hwui/WebViewFunctorManager.cpp | 49 |
1 files changed, 44 insertions, 5 deletions
diff --git a/libs/hwui/WebViewFunctorManager.cpp b/libs/hwui/WebViewFunctorManager.cpp index 671c66f11e32..979678d1c4b6 100644 --- a/libs/hwui/WebViewFunctorManager.cpp +++ b/libs/hwui/WebViewFunctorManager.cpp @@ -18,6 +18,7 @@ #include <private/hwui/WebViewFunctor.h> #include "Properties.h" +#include "renderthread/CanvasContext.h" #include "renderthread/RenderThread.h" #include <log/log.h> @@ -115,11 +116,20 @@ void WebViewFunctor::drawGl(const DrawGlInfo& drawInfo) { ScopedCurrentFunctor currentFunctor(this); WebViewOverlayData overlayParams = { - // TODO: .overlaysMode = OverlaysMode::Disabled, .getSurfaceControl = currentFunctor.getSurfaceControl, .mergeTransaction = currentFunctor.mergeTransaction, }; + + if (!drawInfo.isLayer) { + renderthread::CanvasContext* activeContext = + renderthread::CanvasContext::getActiveContext(); + if (activeContext != nullptr) { + ASurfaceControl* rootSurfaceControl = activeContext->getSurfaceControl(); + if (rootSurfaceControl) overlayParams.overlaysMode = OverlaysMode::Enabled; + } + } + mCallbacks.gles.draw(mFunctor, mData, drawInfo, overlayParams); } @@ -138,11 +148,12 @@ void WebViewFunctor::drawVk(const VkFunctorDrawParams& params) { ScopedCurrentFunctor currentFunctor(this); WebViewOverlayData overlayParams = { - // TODO .overlaysMode = OverlaysMode::Disabled, .getSurfaceControl = currentFunctor.getSurfaceControl, .mergeTransaction = currentFunctor.mergeTransaction, }; + + // TODO, enable surface control once offscreen mode figured out mCallbacks.vk.draw(mFunctor, mData, params, overlayParams); } @@ -166,15 +177,43 @@ void WebViewFunctor::destroyContext() { void WebViewFunctor::removeOverlays() { ScopedCurrentFunctor currentFunctor(this); mCallbacks.removeOverlays(mFunctor, mData, currentFunctor.mergeTransaction); + if (mSurfaceControl) { + auto funcs = renderthread::RenderThread::getInstance().getASurfaceControlFunctions(); + funcs.releaseFunc(mSurfaceControl); + mSurfaceControl = nullptr; + } } ASurfaceControl* WebViewFunctor::getSurfaceControl() { - // TODO - return nullptr; + ATRACE_NAME("WebViewFunctor::getSurfaceControl"); + if (mSurfaceControl != nullptr) return mSurfaceControl; + + renderthread::CanvasContext* activeContext = renderthread::CanvasContext::getActiveContext(); + LOG_ALWAYS_FATAL_IF(activeContext == nullptr, "Null active canvas context!"); + + ASurfaceControl* rootSurfaceControl = activeContext->getSurfaceControl(); + LOG_ALWAYS_FATAL_IF(rootSurfaceControl == nullptr, "Null root surface control!"); + + auto funcs = renderthread::RenderThread::getInstance().getASurfaceControlFunctions(); + mSurfaceControl = funcs.createFunc(rootSurfaceControl, "Webview Overlay SurfaceControl"); + ASurfaceTransaction* transaction = funcs.transactionCreateFunc(); + funcs.transactionSetVisibilityFunc(transaction, mSurfaceControl, + ASURFACE_TRANSACTION_VISIBILITY_SHOW); + funcs.transactionApplyFunc(transaction); + funcs.transactionDeleteFunc(transaction); + return mSurfaceControl; } void WebViewFunctor::mergeTransaction(ASurfaceTransaction* transaction) { - // TODO + ATRACE_NAME("WebViewFunctor::mergeTransaction"); + if (transaction == nullptr) return; + renderthread::CanvasContext* activeContext = renderthread::CanvasContext::getActiveContext(); + LOG_ALWAYS_FATAL_IF(activeContext == nullptr, "Null active canvas context!"); + bool done = activeContext->mergeTransaction(transaction, mSurfaceControl); + if (!done) { + auto funcs = renderthread::RenderThread::getInstance().getASurfaceControlFunctions(); + funcs.transactionApplyFunc(transaction); + } } WebViewFunctorManager& WebViewFunctorManager::instance() { |