diff options
author | Huihong Luo <huisinro@google.com> | 2021-06-30 10:12:17 -0700 |
---|---|---|
committer | Huihong Luo <huisinro@google.com> | 2021-06-30 11:47:21 -0700 |
commit | eb93107b574ad3a8b567597af26e72bee276598b (patch) | |
tree | 63544ca2799b94522bff7ef302321c59c96733ee | |
parent | 920e1fd7a65f64ee0d8a58c6dc1343ff8c26bdfa (diff) |
Add a sys prop to control WebView Overlays support
The boolean system property is named as "debug.hwui.webview_overlays_enabled"
Bug: 192267127
Test: change the property value, check presence of Webview Surface
Control
Change-Id: I01e3e26282a5fa79aa504a6e49c5abe1a1c3ea02
-rw-r--r-- | core/java/android/view/ViewRootImpl.java | 12 | ||||
-rw-r--r-- | graphics/java/android/graphics/HardwareRenderer.java | 5 | ||||
-rw-r--r-- | libs/hwui/Properties.cpp | 4 | ||||
-rw-r--r-- | libs/hwui/Properties.h | 7 | ||||
-rw-r--r-- | libs/hwui/WebViewFunctorManager.cpp | 2 | ||||
-rw-r--r-- | libs/hwui/jni/android_graphics_HardwareRenderer.cpp | 7 |
6 files changed, 32 insertions, 5 deletions
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 5a248af7a097..23faac6c0787 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -1442,8 +1442,10 @@ public final class ViewRootImpl implements ViewParent, if (mHardwareRendererObserver != null) { mAttachInfo.mThreadedRenderer.addObserver(mHardwareRendererObserver); } - addPrepareSurfaceControlForWebviewCallback(); - addASurfaceTransactionCallback(); + if (HardwareRenderer.isWebViewOverlaysEnabled()) { + addPrepareSurfaceControlForWebviewCallback(); + addASurfaceTransactionCallback(); + } mAttachInfo.mThreadedRenderer.setSurfaceControl(mSurfaceControl); } } @@ -7777,8 +7779,10 @@ public final class ViewRootImpl implements ViewParent, } } if (mAttachInfo.mThreadedRenderer != null) { - addPrepareSurfaceControlForWebviewCallback(); - addASurfaceTransactionCallback(); + if (HardwareRenderer.isWebViewOverlaysEnabled()) { + addPrepareSurfaceControlForWebviewCallback(); + addASurfaceTransactionCallback(); + } mAttachInfo.mThreadedRenderer.setSurfaceControl(mSurfaceControl); } } else { diff --git a/graphics/java/android/graphics/HardwareRenderer.java b/graphics/java/android/graphics/HardwareRenderer.java index 30d1e0fdb9d8..fe04f0dd4c83 100644 --- a/graphics/java/android/graphics/HardwareRenderer.java +++ b/graphics/java/android/graphics/HardwareRenderer.java @@ -1304,6 +1304,11 @@ public class HardwareRenderer { */ public static native void preload(); + /** + * @hide + */ + public static native boolean isWebViewOverlaysEnabled(); + /** @hide */ protected static native void setupShadersDiskCache(String cacheFile, String skiaCacheFile); diff --git a/libs/hwui/Properties.cpp b/libs/hwui/Properties.cpp index f0995c4f324b..b8fa55a18dac 100644 --- a/libs/hwui/Properties.cpp +++ b/libs/hwui/Properties.cpp @@ -84,6 +84,8 @@ float Properties::defaultSdrWhitePoint = 200.f; bool Properties::useHintManager = true; int Properties::targetCpuTimePercentage = 70; +bool Properties::enableWebViewOverlays = false; + StretchEffectBehavior Properties::stretchEffectBehavior = StretchEffectBehavior::ShaderHWUI; bool Properties::load() { @@ -137,6 +139,8 @@ bool Properties::load() { targetCpuTimePercentage = base::GetIntProperty(PROPERTY_TARGET_CPU_TIME_PERCENTAGE, 70); if (targetCpuTimePercentage <= 0 || targetCpuTimePercentage > 100) targetCpuTimePercentage = 70; + enableWebViewOverlays = base::GetBoolProperty(PROPERTY_WEBVIEW_OVERLAYS_ENABLED, false); + return (prevDebugLayersUpdates != debugLayersUpdates) || (prevDebugOverdraw != debugOverdraw); } diff --git a/libs/hwui/Properties.h b/libs/hwui/Properties.h index f5fd0036f7be..7df6e2c92247 100644 --- a/libs/hwui/Properties.h +++ b/libs/hwui/Properties.h @@ -182,6 +182,11 @@ enum DebugLevel { */ #define PROPERTY_REDUCE_OPS_TASK_SPLITTING "renderthread.skia.reduceopstasksplitting" +/** + * Enable WebView Overlays feature. + */ +#define PROPERTY_WEBVIEW_OVERLAYS_ENABLED "debug.hwui.webview_overlays_enabled" + /////////////////////////////////////////////////////////////////////////////// // Misc /////////////////////////////////////////////////////////////////////////////// @@ -276,6 +281,8 @@ public: static bool useHintManager; static int targetCpuTimePercentage; + static bool enableWebViewOverlays; + static StretchEffectBehavior getStretchEffectBehavior() { return stretchEffectBehavior; } diff --git a/libs/hwui/WebViewFunctorManager.cpp b/libs/hwui/WebViewFunctorManager.cpp index 974c8635b3df..93f2f42a00fd 100644 --- a/libs/hwui/WebViewFunctorManager.cpp +++ b/libs/hwui/WebViewFunctorManager.cpp @@ -121,7 +121,7 @@ void WebViewFunctor::drawGl(const DrawGlInfo& drawInfo) { .mergeTransaction = currentFunctor.mergeTransaction, }; - if (!drawInfo.isLayer) { + if (Properties::enableWebViewOverlays && !drawInfo.isLayer) { renderthread::CanvasContext* activeContext = renderthread::CanvasContext::getActiveContext(); if (activeContext != nullptr) { diff --git a/libs/hwui/jni/android_graphics_HardwareRenderer.cpp b/libs/hwui/jni/android_graphics_HardwareRenderer.cpp index 4d31cd90d40f..ef3a11c13469 100644 --- a/libs/hwui/jni/android_graphics_HardwareRenderer.cpp +++ b/libs/hwui/jni/android_graphics_HardwareRenderer.cpp @@ -933,6 +933,11 @@ static void android_view_ThreadedRenderer_setupShadersDiskCache(JNIEnv* env, job env->ReleaseStringUTFChars(skiaDiskCachePath, skiaCacheArray); } +static jboolean android_view_ThreadedRenderer_isWebViewOverlaysEnabled(JNIEnv* env, jobject clazz) { + // this value is valid only after loadSystemProperties() is called + return Properties::enableWebViewOverlays; +} + // ---------------------------------------------------------------------------- // JNI Glue // ---------------------------------------------------------------------------- @@ -1025,6 +1030,8 @@ static const JNINativeMethod gMethods[] = { (void*)android_view_ThreadedRenderer_setDisplayDensityDpi}, {"nInitDisplayInfo", "(IIFIJJ)V", (void*)android_view_ThreadedRenderer_initDisplayInfo}, {"preload", "()V", (void*)android_view_ThreadedRenderer_preload}, + {"isWebViewOverlaysEnabled", "()Z", + (void*)android_view_ThreadedRenderer_isWebViewOverlaysEnabled}, }; static JavaVM* mJvm = nullptr; |