Commit bab2b4c1 authored by boliu@chromium.org's avatar boliu@chromium.org

aw: Only enable webgl on hardware webview

Also clean up 2d canvas code to respect command line switches.

BUG=392663

Review URL: https://codereview.chromium.org/375193002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282220 0039d316-1c4b-4281-b951-d872f2087c98
parent 4b1f3bce
...@@ -9,13 +9,11 @@ ...@@ -9,13 +9,11 @@
#include "android_webview/native/aw_contents.h" #include "android_webview/native/aw_contents.h"
#include "base/android/jni_android.h" #include "base/android/jni_android.h"
#include "base/android/jni_string.h" #include "base/android/jni_string.h"
#include "base/command_line.h"
#include "base/supports_user_data.h" #include "base/supports_user_data.h"
#include "content/public/browser/navigation_controller.h" #include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_entry.h" #include "content/public/browser/navigation_entry.h"
#include "content/public/browser/render_view_host.h" #include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/renderer_preferences.h" #include "content/public/common/renderer_preferences.h"
#include "content/public/common/web_preferences.h" #include "content/public/common/web_preferences.h"
#include "jni/AwSettings_jni.h" #include "jni/AwSettings_jni.h"
...@@ -114,9 +112,6 @@ class AwSettingsUserData : public base::SupportsUserData::Data { ...@@ -114,9 +112,6 @@ class AwSettingsUserData : public base::SupportsUserData::Data {
AwSettings::AwSettings(JNIEnv* env, jobject obj, jlong web_contents) AwSettings::AwSettings(JNIEnv* env, jobject obj, jlong web_contents)
: WebContentsObserver( : WebContentsObserver(
reinterpret_cast<content::WebContents*>(web_contents)), reinterpret_cast<content::WebContents*>(web_contents)),
accelerated_2d_canvas_disabled_by_switch_(
CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableAccelerated2dCanvas)),
renderer_prefs_initialized_(false), renderer_prefs_initialized_(false),
aw_settings_(env, obj) { aw_settings_(env, obj) {
reinterpret_cast<content::WebContents*>(web_contents)-> reinterpret_cast<content::WebContents*>(web_contents)->
...@@ -414,16 +409,24 @@ void AwSettings::PopulateWebPreferencesLocked( ...@@ -414,16 +409,24 @@ void AwSettings::PopulateWebPreferencesLocked(
web_prefs->spatial_navigation_enabled = web_prefs->spatial_navigation_enabled =
Java_AwSettings_getSpatialNavigationLocked(env, obj); Java_AwSettings_getSpatialNavigationLocked(env, obj);
bool enable_supported_hardware_accelerated_features =
Java_AwSettings_getEnableSupportedHardwareAcceleratedFeaturesLocked(
env, obj);
bool accelerated_2d_canvas_enabled_by_switch =
web_prefs->accelerated_2d_canvas_enabled;
web_prefs->accelerated_2d_canvas_enabled = true; web_prefs->accelerated_2d_canvas_enabled = true;
if (accelerated_2d_canvas_disabled_by_switch_ || if (!accelerated_2d_canvas_enabled_by_switch ||
!Java_AwSettings_getEnableSupportedHardwareAcceleratedFeaturesLocked( !enable_supported_hardware_accelerated_features) {
env, obj)) {
// Any canvas smaller than this will fallback to software. Abusing this // Any canvas smaller than this will fallback to software. Abusing this
// slightly to turn canvas off without changing // slightly to turn canvas off without changing
// accelerated_2d_canvas_enabled, which also affects compositing mode. // accelerated_2d_canvas_enabled, which also affects compositing mode.
// Using 100M instead of max int to avoid overflows. // Using 100M instead of max int to avoid overflows.
web_prefs->minimum_accelerated_2d_canvas_size = 100 * 1000 * 1000; web_prefs->minimum_accelerated_2d_canvas_size = 100 * 1000 * 1000;
} }
web_prefs->experimental_webgl_enabled =
web_prefs->experimental_webgl_enabled &&
enable_supported_hardware_accelerated_features;
web_prefs->allow_displaying_insecure_content = web_prefs->allow_displaying_insecure_content =
Java_AwSettings_getAllowDisplayingInsecureContentLocked(env, obj); Java_AwSettings_getAllowDisplayingInsecureContentLocked(env, obj);
......
...@@ -50,8 +50,6 @@ class AwSettings : public content::WebContentsObserver { ...@@ -50,8 +50,6 @@ class AwSettings : public content::WebContentsObserver {
content::RenderViewHost* render_view_host) OVERRIDE; content::RenderViewHost* render_view_host) OVERRIDE;
virtual void WebContentsDestroyed() OVERRIDE; virtual void WebContentsDestroyed() OVERRIDE;
bool accelerated_2d_canvas_disabled_by_switch_;
bool renderer_prefs_initialized_; bool renderer_prefs_initialized_;
JavaObjectWeakGlobalRef aw_settings_; JavaObjectWeakGlobalRef aw_settings_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment