Commit fed63e98 authored by zmo@chromium.org's avatar zmo@chromium.org

Switch from CommandLine switch to WebPreferences to control Pepper 3D.

This is to get us ready to dynamically enable or disable a renderer feature whenever, for example, the gpu is switched in a multiple gpu system.

BUG=332188
TEST=
R=bbudge@chromium.org, jamesr@chromium.org, joi@chromium.org, kbr@chromium.org

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@244212 0039d316-1c4b-4281-b951-d872f2087c98
parent 96101917
......@@ -650,10 +650,6 @@ void GpuDataManagerImplPrivate::AppendRendererCommandLine(
CommandLine* command_line) const {
DCHECK(command_line);
if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL)) {
if (!command_line->HasSwitch(switches::kDisablePepper3d))
command_line->AppendSwitch(switches::kDisablePepper3d);
}
if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING) &&
!command_line->HasSwitch(switches::kDisableAcceleratedCompositing))
command_line->AppendSwitch(switches::kDisableAcceleratedCompositing);
......@@ -671,10 +667,8 @@ void GpuDataManagerImplPrivate::AppendRendererCommandLine(
command_line->AppendSwitch(switches::kEnableSoftwareCompositing);
#if defined(USE_AURA)
if (!CanUseGpuBrowserCompositor()) {
if (!CanUseGpuBrowserCompositor())
command_line->AppendSwitch(switches::kDisableGpuCompositing);
command_line->AppendSwitch(switches::kDisablePepper3d);
}
#endif
}
......@@ -776,8 +770,10 @@ void GpuDataManagerImplPrivate::UpdateRendererWebPrefs(
if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING))
prefs->accelerated_compositing_enabled = false;
if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL))
if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL)) {
prefs->experimental_webgl_enabled = false;
prefs->pepper_3d_enabled = false;
}
if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_FLASH3D))
prefs->flash_3d_enabled = false;
if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_FLASH_STAGE3D)) {
......@@ -800,12 +796,13 @@ void GpuDataManagerImplPrivate::UpdateRendererWebPrefs(
prefs->accelerated_compositing_for_video_enabled = false;
// Accelerated video and animation are slower than regular when using
// SwiftShader. 3D CSS may also be too slow to be worthwhile.
// SwiftShader. 3D CSS or Pepper 3D may also be too slow to be worthwhile.
if (ShouldUseSwiftShader()) {
prefs->accelerated_compositing_for_video_enabled = false;
prefs->accelerated_compositing_for_animation_enabled = false;
prefs->accelerated_compositing_for_3d_transforms_enabled = false;
prefs->accelerated_compositing_for_plugins_enabled = false;
prefs->pepper_3d_enabled = false;
}
if (use_software_compositor_) {
......@@ -817,8 +814,10 @@ void GpuDataManagerImplPrivate::UpdateRendererWebPrefs(
}
#if defined(USE_AURA)
if (!CanUseGpuBrowserCompositor())
if (!CanUseGpuBrowserCompositor()) {
prefs->accelerated_2d_canvas_enabled = false;
prefs->pepper_3d_enabled = false;
}
#endif
}
......
......@@ -1126,7 +1126,6 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer(
cc::switches::kTraceOverdraw,
#if defined(ENABLE_PLUGINS)
switches::kEnablePepperTesting,
switches::kDisablePepper3d,
#endif
#if defined(ENABLE_WEBRTC)
switches::kEnableAudioTrackProcessing,
......
......@@ -363,6 +363,9 @@ WebPreferences RenderViewHostImpl::GetWebkitPrefs(const GURL& url) {
!command_line.HasSwitch(switches::kDisable3DAPIs) &&
!command_line.HasSwitch(switches::kDisableExperimentalWebGL);
prefs.pepper_3d_enabled =
!command_line.HasSwitch(switches::kDisablePepper3d);
prefs.flash_3d_enabled =
GpuProcessHost::gpu_enabled() &&
!command_line.HasSwitch(switches::kDisableFlash3d);
......
......@@ -114,6 +114,7 @@ IPC_STRUCT_TRAITS_BEGIN(WebPreferences)
IPC_STRUCT_TRAITS_MEMBER(allow_file_access_from_file_urls)
IPC_STRUCT_TRAITS_MEMBER(webaudio_enabled)
IPC_STRUCT_TRAITS_MEMBER(experimental_webgl_enabled)
IPC_STRUCT_TRAITS_MEMBER(pepper_3d_enabled)
IPC_STRUCT_TRAITS_MEMBER(experimental_websocket_enabled)
IPC_STRUCT_TRAITS_MEMBER(pinch_virtual_viewport_enabled)
IPC_STRUCT_TRAITS_MEMBER(use_solid_color_scrollbars)
......
......@@ -68,21 +68,11 @@ PPB_Graphics3D_Impl::~PPB_Graphics3D_Impl() {
DestroyGLES2Impl();
}
// static
PP_Bool PPB_Graphics3D_Impl::IsGpuBlacklisted() {
CommandLine* command_line = CommandLine::ForCurrentProcess();
if (command_line)
return PP_FromBool(command_line->HasSwitch(switches::kDisablePepper3d));
return PP_TRUE;
}
// static
PP_Resource PPB_Graphics3D_Impl::Create(PP_Instance instance,
PP_Resource share_context,
const int32_t* attrib_list) {
PPB_Graphics3D_API* share_api = NULL;
if (IsGpuBlacklisted())
return 0;
if (share_context) {
EnterResourceNoLock<PPB_Graphics3D_API> enter(share_context, true);
if (enter.failed())
......@@ -101,8 +91,6 @@ PP_Resource PPB_Graphics3D_Impl::CreateRaw(PP_Instance instance,
PP_Resource share_context,
const int32_t* attrib_list) {
PPB_Graphics3D_API* share_api = NULL;
if (IsGpuBlacklisted())
return 0;
if (share_context) {
EnterResourceNoLock<PPB_Graphics3D_API> enter(share_context, true);
if (enter.failed())
......@@ -243,18 +231,14 @@ bool PPB_Graphics3D_Impl::InitRaw(PPB_Graphics3D_API* share_context,
if (!plugin_instance)
return false;
PlatformContext3D* share_platform_context = NULL;
if (share_context) {
PPB_Graphics3D_Impl* share_graphics =
static_cast<PPB_Graphics3D_Impl*>(share_context);
share_platform_context = share_graphics->platform_context();
}
const WebPreferences& prefs = static_cast<RenderViewImpl*>(plugin_instance->
GetRenderView())->webkit_preferences();
// 3D access might be disabled or blacklisted.
if (!prefs.pepper_3d_enabled)
return false;
// If accelerated compositing of plugins is disabled, fail to create a 3D
// context, because it won't be visible. This allows graceful fallback in the
// modules.
const WebPreferences& prefs = static_cast<RenderViewImpl*>(plugin_instance->
GetRenderView())->webkit_preferences();
if (!prefs.accelerated_compositing_for_plugins_enabled)
return false;
......@@ -262,6 +246,13 @@ bool PPB_Graphics3D_Impl::InitRaw(PPB_Graphics3D_API* share_context,
if (!platform_context_)
return false;
PlatformContext3D* share_platform_context = NULL;
if (share_context) {
PPB_Graphics3D_Impl* share_graphics =
static_cast<PPB_Graphics3D_Impl*>(share_context);
share_platform_context = share_graphics->platform_context();
}
if (!platform_context_->Init(attrib_list, share_platform_context))
return false;
......
......@@ -60,8 +60,6 @@ class PPB_Graphics3D_Impl : public ppapi::PPB_Graphics3D_Shared {
private:
explicit PPB_Graphics3D_Impl(PP_Instance instance);
static PP_Bool IsGpuBlacklisted();
bool Init(PPB_Graphics3D_API* share_context,
const int32_t* attrib_list);
bool InitRaw(PPB_Graphics3D_API* share_context,
......
......@@ -48,6 +48,7 @@ WebPreferences::WebPreferences()
allow_file_access_from_file_urls(false),
webaudio_enabled(false),
experimental_webgl_enabled(false),
pepper_3d_enabled(false),
flash_3d_enabled(true),
flash_stage3d_enabled(false),
flash_stage3d_baseline_enabled(false),
......
......@@ -95,6 +95,7 @@ struct WEBKIT_COMMON_EXPORT WebPreferences {
bool allow_file_access_from_file_urls;
bool webaudio_enabled;
bool experimental_webgl_enabled;
bool pepper_3d_enabled;
bool flash_3d_enabled;
bool flash_stage3d_enabled;
bool flash_stage3d_baseline_enabled;
......
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