diff options
author | Huihong Luo <huisinro@google.com> | 2021-06-25 13:59:39 -0700 |
---|---|---|
committer | Huihong Luo <huisinro@google.com> | 2021-06-28 20:36:40 -0700 |
commit | 540fdf89b1432f99e3c01d6ec838d434609eefb7 (patch) | |
tree | 7d2a02978e9bb3dfbcdef4b95968a932b7f0c2ec /libs/hwui/WebViewFunctorManager.cpp | |
parent | fb0faec367832e8fdc05508d831a697972dfa4f2 (diff) |
Reparent surface control for Webview overlay
When the root surface control changes, the parent of the Webview surface control must be changed.
Bug: 191900007
Test: switch app, or turn on/off screen
Change-Id: Ib7b34133776fd5944afc638bfee471afe6a17349
Diffstat (limited to 'libs/hwui/WebViewFunctorManager.cpp')
-rw-r--r-- | libs/hwui/WebViewFunctorManager.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/libs/hwui/WebViewFunctorManager.cpp b/libs/hwui/WebViewFunctorManager.cpp index 92e20c477669..974c8635b3df 100644 --- a/libs/hwui/WebViewFunctorManager.cpp +++ b/libs/hwui/WebViewFunctorManager.cpp @@ -126,7 +126,14 @@ void WebViewFunctor::drawGl(const DrawGlInfo& drawInfo) { renderthread::CanvasContext::getActiveContext(); if (activeContext != nullptr) { ASurfaceControl* rootSurfaceControl = activeContext->getSurfaceControl(); - if (rootSurfaceControl) overlayParams.overlaysMode = OverlaysMode::Enabled; + if (rootSurfaceControl) { + overlayParams.overlaysMode = OverlaysMode::Enabled; + int32_t rgid = activeContext->getSurfaceControlGenerationId(); + if (mParentSurfaceControlGenerationId != rgid) { + reparentSurfaceControl(rootSurfaceControl); + mParentSurfaceControlGenerationId = rgid; + } + } } } @@ -195,6 +202,7 @@ ASurfaceControl* WebViewFunctor::getSurfaceControl() { LOG_ALWAYS_FATAL_IF(rootSurfaceControl == nullptr, "Null root surface control!"); auto funcs = renderthread::RenderThread::getInstance().getASurfaceControlFunctions(); + mParentSurfaceControlGenerationId = activeContext->getSurfaceControlGenerationId(); mSurfaceControl = funcs.createFunc(rootSurfaceControl, "Webview Overlay SurfaceControl"); ASurfaceTransaction* transaction = funcs.transactionCreateFunc(); activeContext->prepareSurfaceControlForWebview(); @@ -218,6 +226,17 @@ void WebViewFunctor::mergeTransaction(ASurfaceTransaction* transaction) { } } +void WebViewFunctor::reparentSurfaceControl(ASurfaceControl* parent) { + ATRACE_NAME("WebViewFunctor::reparentSurfaceControl"); + if (mSurfaceControl == nullptr) return; + + auto funcs = renderthread::RenderThread::getInstance().getASurfaceControlFunctions(); + ASurfaceTransaction* transaction = funcs.transactionCreateFunc(); + funcs.transactionReparentFunc(transaction, mSurfaceControl, parent); + mergeTransaction(transaction); + funcs.transactionDeleteFunc(transaction); +} + WebViewFunctorManager& WebViewFunctorManager::instance() { static WebViewFunctorManager sInstance; return sInstance; |