Disable Webview Overlay when invisible
Remove Webview overlays when Webview node is set to invisible Bug: 187292989 Test: play a video in a Webview, toggle visibility for the view, check existence of a surface control named as "Webview Overlay SurfaceControl#0" Change-Id: If47a78a8ae1f7b65b9e7ab983ec72f580d78191a
This commit is contained in:
@@ -108,6 +108,13 @@ void WebViewFunctor::sync(const WebViewSyncData& syncData) const {
|
||||
mCallbacks.onSync(mFunctor, mData, syncData);
|
||||
}
|
||||
|
||||
void WebViewFunctor::onRemovedFromTree() {
|
||||
ATRACE_NAME("WebViewFunctor::onRemovedFromTree");
|
||||
if (mSurfaceControl) {
|
||||
removeOverlays();
|
||||
}
|
||||
}
|
||||
|
||||
void WebViewFunctor::drawGl(const DrawGlInfo& drawInfo) {
|
||||
ATRACE_NAME("WebViewFunctor::drawGl");
|
||||
if (!mHasContext) {
|
||||
@@ -185,6 +192,7 @@ void WebViewFunctor::removeOverlays() {
|
||||
ScopedCurrentFunctor currentFunctor(this);
|
||||
mCallbacks.removeOverlays(mFunctor, mData, currentFunctor.mergeTransaction);
|
||||
if (mSurfaceControl) {
|
||||
reparentSurfaceControl(nullptr);
|
||||
auto funcs = renderthread::RenderThread::getInstance().getASurfaceControlFunctions();
|
||||
funcs.releaseFunc(mSurfaceControl);
|
||||
mSurfaceControl = nullptr;
|
||||
@@ -217,9 +225,12 @@ ASurfaceControl* WebViewFunctor::getSurfaceControl() {
|
||||
void WebViewFunctor::mergeTransaction(ASurfaceTransaction* transaction) {
|
||||
ATRACE_NAME("WebViewFunctor::mergeTransaction");
|
||||
if (transaction == nullptr) return;
|
||||
bool done = false;
|
||||
renderthread::CanvasContext* activeContext = renderthread::CanvasContext::getActiveContext();
|
||||
LOG_ALWAYS_FATAL_IF(activeContext == nullptr, "Null active canvas context!");
|
||||
bool done = activeContext->mergeTransaction(transaction, mSurfaceControl);
|
||||
// activeContext might be null when called from mCallbacks.removeOverlays()
|
||||
if (activeContext != nullptr) {
|
||||
done = activeContext->mergeTransaction(transaction, mSurfaceControl);
|
||||
}
|
||||
if (!done) {
|
||||
auto funcs = renderthread::RenderThread::getInstance().getASurfaceControlFunctions();
|
||||
funcs.transactionApplyFunc(transaction);
|
||||
|
||||
Reference in New Issue
Block a user