Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Side by Side Diff: content/browser/gpu/gpu_data_manager_impl.cc

Issue 13983014: [CLOSED] Cleaning up the plethora of switches for GPU vs software vs SwiftShader. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/gpu/gpu_data_manager_impl.h" 5 #include "content/browser/gpu/gpu_data_manager_impl.h"
6 6
7 #if defined(OS_MACOSX) 7 #if defined(OS_MACOSX)
8 #include <ApplicationServices/ApplicationServices.h> 8 #include <ApplicationServices/ApplicationServices.h>
9 #endif // OS_MACOSX 9 #endif // OS_MACOSX
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/file_util.h" 14 #include "base/file_util.h"
15 #include "base/metrics/field_trial.h" 15 #include "base/metrics/field_trial.h"
16 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
17 #include "base/stringprintf.h" 17 #include "base/stringprintf.h"
18 #include "base/strings/string_number_conversions.h" 18 #include "base/strings/string_number_conversions.h"
19 #include "base/strings/string_piece.h" 19 #include "base/strings/string_piece.h"
20 #include "base/sys_info.h" 20 #include "base/sys_info.h"
21 #include "base/values.h" 21 #include "base/values.h"
22 #include "base/version.h" 22 #include "base/version.h"
23 #include "cc/base/switches.h"
23 #include "content/browser/gpu/gpu_process_host.h" 24 #include "content/browser/gpu/gpu_process_host.h"
24 #include "content/browser/gpu/gpu_util.h" 25 #include "content/browser/gpu/gpu_util.h"
25 #include "content/common/gpu/gpu_messages.h" 26 #include "content/common/gpu/gpu_messages.h"
26 #include "content/gpu/gpu_info_collector.h" 27 #include "content/gpu/gpu_info_collector.h"
27 #include "content/public/browser/browser_thread.h" 28 #include "content/public/browser/browser_thread.h"
28 #include "content/public/browser/gpu_data_manager_observer.h" 29 #include "content/public/browser/gpu_data_manager_observer.h"
29 #include "content/public/common/content_client.h" 30 #include "content/public/common/content_client.h"
30 #include "content/public/common/content_constants.h" 31 #include "content/public/common/content_constants.h"
31 #include "content/public/common/content_switches.h" 32 #include "content/public/common/content_switches.h"
32 #include "content/public/common/gpu_feature_type.h" 33 #include "content/public/common/gpu_feature_type.h"
33 #include "gpu/command_buffer/service/gpu_switches.h" 34 #include "gpu/command_buffer/service/gpu_switches.h"
34 #include "grit/content_resources.h" 35 #include "grit/content_resources.h"
35 #include "ui/base/ui_base_switches.h" 36 #include "ui/base/ui_base_switches.h"
36 #include "ui/gl/gl_implementation.h" 37 #include "ui/gl/gl_implementation.h"
37 #include "ui/gl/gl_switches.h" 38 #include "ui/gl/gl_switches.h"
38 #include "ui/gl/gpu_switching_manager.h" 39 #include "ui/gl/gpu_switching_manager.h"
39 #include "webkit/glue/webpreferences.h" 40 #include "webkit/glue/webpreferences.h"
40 #include "webkit/plugins/plugin_switches.h" 41 #include "webkit/plugins/plugin_switches.h"
41 42
42 #if defined(OS_WIN) 43 #if defined(OS_WIN)
43 #include "base/win/windows_version.h" 44 #include "base/win/windows_version.h"
44 #endif 45 #endif
45 46
46 namespace content { 47 namespace content {
47 namespace { 48 namespace {
48 49
50 const bool DISABLE_GPU = true;
51
49 // Strip out the non-digital info; if after that, we get an empty string, 52 // Strip out the non-digital info; if after that, we get an empty string,
50 // return "0". 53 // return "0".
51 std::string ProcessVersionString(const std::string& raw_string) { 54 std::string ProcessVersionString(const std::string& raw_string) {
52 const std::string valid_set = "0123456789."; 55 const std::string valid_set = "0123456789.";
53 size_t start_pos = raw_string.find_first_of(valid_set); 56 size_t start_pos = raw_string.find_first_of(valid_set);
54 if (start_pos == std::string::npos) 57 if (start_pos == std::string::npos)
55 return "0"; 58 return "0";
56 size_t end_pos = raw_string.find_first_not_of(raw_string, start_pos); 59 size_t end_pos = raw_string.find_first_not_of(raw_string, start_pos);
57 std::string version_string = raw_string.substr( 60 std::string version_string = raw_string.substr(
58 start_pos, end_pos - start_pos); 61 start_pos, end_pos - start_pos);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 void GpuDataManagerImpl::InitializeForTesting( 117 void GpuDataManagerImpl::InitializeForTesting(
115 const std::string& gpu_blacklist_json, 118 const std::string& gpu_blacklist_json,
116 const GPUInfo& gpu_info) { 119 const GPUInfo& gpu_info) {
117 // This function is for testing only, so disable histograms. 120 // This function is for testing only, so disable histograms.
118 update_histograms_ = false; 121 update_histograms_ = false;
119 122
120 InitializeImpl(gpu_blacklist_json, std::string(), std::string(), gpu_info); 123 InitializeImpl(gpu_blacklist_json, std::string(), std::string(), gpu_info);
121 } 124 }
122 125
123 bool GpuDataManagerImpl::IsFeatureBlacklisted(int feature) const { 126 bool GpuDataManagerImpl::IsFeatureBlacklisted(int feature) const {
124 if (software_rendering_) { 127 if (use_swiftshader_) {
125 // Skia's software rendering is probably more efficient than going through 128 // Skia's rendering is more efficient than going through
126 // software emulation of the GPU, so use that. 129 // SwiftShader emulation, so use that.
127 if (feature == GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS) 130 if (feature == GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)
128 return true; 131 return true;
129 return false; 132 return false;
130 } 133 }
131 134
132 return (blacklisted_features_.count(feature) == 1); 135 return (blacklisted_features_.count(feature) == 1);
133 } 136 }
134 137
135 size_t GpuDataManagerImpl::GetBlacklistedFeatureCount() const { 138 size_t GpuDataManagerImpl::GetBlacklistedFeatureCount() const {
136 if (software_rendering_) 139 if (use_swiftshader_)
137 return 1; 140 return 1;
138 return blacklisted_features_.size(); 141 return blacklisted_features_.size();
139 } 142 }
140 143
141 void GpuDataManagerImpl::AddGpuSwitchCallback( 144 void GpuDataManagerImpl::AddGpuSwitchCallback(
142 const GpuSwitchCallback& callback) { 145 const GpuSwitchCallback& callback) {
143 gpu_switch_callbacks_.push_back(callback); 146 gpu_switch_callbacks_.push_back(callback);
144 } 147 }
145 148
146 void GpuDataManagerImpl::RemoveGpuSwitchCallback( 149 void GpuDataManagerImpl::RemoveGpuSwitchCallback(
(...skipping 14 matching lines...) Expand all
161 } 164 }
162 return gpu_info; 165 return gpu_info;
163 } 166 }
164 167
165 void GpuDataManagerImpl::GetGpuProcessHandles( 168 void GpuDataManagerImpl::GetGpuProcessHandles(
166 const GetGpuProcessHandlesCallback& callback) const { 169 const GetGpuProcessHandlesCallback& callback) const {
167 GpuProcessHost::GetProcessHandles(callback); 170 GpuProcessHost::GetProcessHandles(callback);
168 } 171 }
169 172
170 bool GpuDataManagerImpl::GpuAccessAllowed() const { 173 bool GpuDataManagerImpl::GpuAccessAllowed() const {
171 if (software_rendering_) 174 if (use_swiftshader_)
172 return true; 175 return true;
173 176
174 if (!gpu_info_.gpu_accessible) 177 if (!gpu_info_.gpu_accessible)
175 return false; 178 return false;
176 179
177 if (card_blacklisted_) 180 if (card_blacklisted_)
178 return false; 181 return false;
179 182
180 // We only need to block GPU process if more features are disallowed other 183 // We only need to block GPU process if more features are disallowed other
181 // than those in the preliminary gpu feature flags because the latter work 184 // than those in the preliminary gpu feature flags because the latter work
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 return gpu_info_.finalized; 221 return gpu_info_.finalized;
219 } 222 }
220 223
221 void GpuDataManagerImpl::RequestVideoMemoryUsageStatsUpdate() const { 224 void GpuDataManagerImpl::RequestVideoMemoryUsageStatsUpdate() const {
222 GpuProcessHost::SendOnIO( 225 GpuProcessHost::SendOnIO(
223 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, 226 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED,
224 CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH, 227 CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH,
225 new GpuMsg_GetVideoMemoryUsageStats()); 228 new GpuMsg_GetVideoMemoryUsageStats());
226 } 229 }
227 230
228 bool GpuDataManagerImpl::ShouldUseSoftwareRendering() const { 231 bool GpuDataManagerImpl::ShouldUseSwiftShader() const {
229 return software_rendering_; 232 return use_swiftshader_;
230 } 233 }
231 234
232 void GpuDataManagerImpl::RegisterSwiftShaderPath(const base::FilePath& path) { 235 void GpuDataManagerImpl::RegisterSwiftShaderPath(const base::FilePath& path) {
233 swiftshader_path_ = path; 236 swiftshader_path_ = path;
234 EnableSoftwareRenderingIfNecessary(); 237 EnableSwiftShaderIfNecessary();
235 } 238 }
236 239
237 void GpuDataManagerImpl::AddObserver(GpuDataManagerObserver* observer) { 240 void GpuDataManagerImpl::AddObserver(GpuDataManagerObserver* observer) {
238 observer_list_->AddObserver(observer); 241 observer_list_->AddObserver(observer);
239 } 242 }
240 243
241 void GpuDataManagerImpl::RemoveObserver(GpuDataManagerObserver* observer) { 244 void GpuDataManagerImpl::RemoveObserver(GpuDataManagerObserver* observer) {
242 observer_list_->RemoveObserver(observer); 245 observer_list_->RemoveObserver(observer);
243 } 246 }
244 247
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 IDR_GPU_DRIVER_BUG_LIST, ui::SCALE_FACTOR_NONE); 344 IDR_GPU_DRIVER_BUG_LIST, ui::SCALE_FACTOR_NONE);
342 gpu_driver_bug_list_string = gpu_driver_bug_list_json.as_string(); 345 gpu_driver_bug_list_string = gpu_driver_bug_list_json.as_string();
343 } 346 }
344 InitializeImpl(gpu_blacklist_string, 347 InitializeImpl(gpu_blacklist_string,
345 gpu_switching_list_string, 348 gpu_switching_list_string,
346 gpu_driver_bug_list_string, 349 gpu_driver_bug_list_string,
347 gpu_info); 350 gpu_info);
348 } 351 }
349 352
350 void GpuDataManagerImpl::UpdateGpuInfo(const GPUInfo& gpu_info) { 353 void GpuDataManagerImpl::UpdateGpuInfo(const GPUInfo& gpu_info) {
351 // No further update of gpu_info if falling back to software renderer. 354 // No further update of gpu_info if falling back to SwiftShader.
352 if (software_rendering_) 355 if (use_swiftshader_)
353 return; 356 return;
354 357
355 GPUInfo my_gpu_info; 358 GPUInfo my_gpu_info;
356 { 359 {
357 base::AutoLock auto_lock(gpu_info_lock_); 360 base::AutoLock auto_lock(gpu_info_lock_);
358 gpu_info_collector::MergeGPUInfo(&gpu_info_, gpu_info); 361 gpu_info_collector::MergeGPUInfo(&gpu_info_, gpu_info);
359 complete_gpu_info_already_requested_ = 362 complete_gpu_info_already_requested_ =
360 complete_gpu_info_already_requested_ || gpu_info_.finalized; 363 complete_gpu_info_already_requested_ || gpu_info_.finalized;
361 my_gpu_info = gpu_info_; 364 my_gpu_info = gpu_info_;
362 } 365 }
(...skipping 29 matching lines...) Expand all
392 void GpuDataManagerImpl::UpdateVideoMemoryUsageStats( 395 void GpuDataManagerImpl::UpdateVideoMemoryUsageStats(
393 const GPUVideoMemoryUsageStats& video_memory_usage_stats) { 396 const GPUVideoMemoryUsageStats& video_memory_usage_stats) {
394 observer_list_->Notify(&GpuDataManagerObserver::OnVideoMemoryUsageStatsUpdate, 397 observer_list_->Notify(&GpuDataManagerObserver::OnVideoMemoryUsageStatsUpdate,
395 video_memory_usage_stats); 398 video_memory_usage_stats);
396 } 399 }
397 400
398 void GpuDataManagerImpl::AppendRendererCommandLine( 401 void GpuDataManagerImpl::AppendRendererCommandLine(
399 CommandLine* command_line) const { 402 CommandLine* command_line) const {
400 DCHECK(command_line); 403 DCHECK(command_line);
401 404
405 if (DISABLE_GPU) {
406 if (!command_line->HasSwitch(switches::kAllowWebUICompositing))
407 command_line->AppendSwitch(switches::kAllowWebUICompositing);
408 if (!command_line->HasSwitch(switches::kDisableGpu))
409 command_line->AppendSwitch(switches::kDisableGpu);
410 #ifndef OS_ANDROID
411 if (!command_line->HasSwitch(switches::kDisableExperimentalWebGL))
412 command_line->AppendSwitch(switches::kDisableExperimentalWebGL);
413 #endif
414 if (!command_line->HasSwitch(switches::kDisablePepper3d))
415 command_line->AppendSwitch(switches::kDisablePepper3d);
416 if (!command_line->HasSwitch(switches::kDisableAcceleratedPlugins))
417 command_line->AppendSwitch(switches::kDisableAcceleratedPlugins);
418 if (!command_line->HasSwitch(switches::kDisableAccelerated2dCanvas))
419 command_line->AppendSwitch(switches::kDisableAccelerated2dCanvas);
420 if (!command_line->HasSwitch(switches::kDisableAcceleratedVideoDecode))
421 command_line->AppendSwitch(switches::kDisableAcceleratedVideoDecode);
422 if (!command_line->HasSwitch(switches::kDisableFlashFullscreen3d))
423 command_line->AppendSwitch(switches::kDisableFlashFullscreen3d);
424 if (!command_line->HasSwitch(cc::switches::kEnableCompositorFrameMessage))
425 command_line->AppendSwitch(cc::switches::kEnableCompositorFrameMessage);
426 return;
427 }
428
402 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_WEBGL)) { 429 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_WEBGL)) {
403 #if !defined(OS_ANDROID) 430 #if !defined(OS_ANDROID)
404 if (!command_line->HasSwitch(switches::kDisableExperimentalWebGL)) 431 if (!command_line->HasSwitch(switches::kDisableExperimentalWebGL))
405 command_line->AppendSwitch(switches::kDisableExperimentalWebGL); 432 command_line->AppendSwitch(switches::kDisableExperimentalWebGL);
406 #endif 433 #endif
407 if (!command_line->HasSwitch(switches::kDisablePepper3d)) 434 if (!command_line->HasSwitch(switches::kDisablePepper3d))
408 command_line->AppendSwitch(switches::kDisablePepper3d); 435 command_line->AppendSwitch(switches::kDisablePepper3d);
409 } 436 }
410 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_MULTISAMPLING) && 437 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_MULTISAMPLING) &&
411 !command_line->HasSwitch(switches::kDisableGLMultisampling)) 438 !command_line->HasSwitch(switches::kDisableGLMultisampling))
412 command_line->AppendSwitch(switches::kDisableGLMultisampling); 439 command_line->AppendSwitch(switches::kDisableGLMultisampling);
413 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING) && 440 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING) &&
414 !command_line->HasSwitch(switches::kDisableAcceleratedCompositing)) 441 !command_line->HasSwitch(switches::kDisableAcceleratedCompositing))
415 command_line->AppendSwitch(switches::kDisableAcceleratedCompositing); 442 command_line->AppendSwitch(switches::kDisableAcceleratedCompositing);
416 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS) && 443 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS) &&
417 !command_line->HasSwitch(switches::kDisableAccelerated2dCanvas)) 444 !command_line->HasSwitch(switches::kDisableAccelerated2dCanvas))
418 command_line->AppendSwitch(switches::kDisableAccelerated2dCanvas); 445 command_line->AppendSwitch(switches::kDisableAccelerated2dCanvas);
419 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_ACCELERATED_VIDEO_DECODE) && 446 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_ACCELERATED_VIDEO_DECODE) &&
420 !command_line->HasSwitch(switches::kDisableAcceleratedVideoDecode)) 447 !command_line->HasSwitch(switches::kDisableAcceleratedVideoDecode))
421 command_line->AppendSwitch(switches::kDisableAcceleratedVideoDecode); 448 command_line->AppendSwitch(switches::kDisableAcceleratedVideoDecode);
422 if (ShouldUseSoftwareRendering()) 449 if (ShouldUseSwiftShader())
423 command_line->AppendSwitch(switches::kDisableFlashFullscreen3d); 450 command_line->AppendSwitch(switches::kDisableFlashFullscreen3d);
424 } 451 }
425 452
426 void GpuDataManagerImpl::AppendGpuCommandLine( 453 void GpuDataManagerImpl::AppendGpuCommandLine(
427 CommandLine* command_line) const { 454 CommandLine* command_line) const {
428 DCHECK(command_line); 455 DCHECK(command_line);
429 456
430 std::string use_gl = 457 std::string use_gl =
431 CommandLine::ForCurrentProcess()->GetSwitchValueASCII(switches::kUseGL); 458 CommandLine::ForCurrentProcess()->GetSwitchValueASCII(switches::kUseGL);
432 base::FilePath swiftshader_path = 459 base::FilePath swiftshader_path =
433 CommandLine::ForCurrentProcess()->GetSwitchValuePath( 460 CommandLine::ForCurrentProcess()->GetSwitchValuePath(
434 switches::kSwiftShaderPath); 461 switches::kSwiftShaderPath);
435 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_MULTISAMPLING) && 462 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_MULTISAMPLING) &&
436 !command_line->HasSwitch(switches::kDisableGLMultisampling)) 463 !command_line->HasSwitch(switches::kDisableGLMultisampling))
437 command_line->AppendSwitch(switches::kDisableGLMultisampling); 464 command_line->AppendSwitch(switches::kDisableGLMultisampling);
438 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_TEXTURE_SHARING)) 465 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_TEXTURE_SHARING))
439 command_line->AppendSwitch(switches::kDisableImageTransportSurface); 466 command_line->AppendSwitch(switches::kDisableImageTransportSurface);
440 467
441 if (software_rendering_) { 468 if (use_swiftshader_) {
442 command_line->AppendSwitchASCII(switches::kUseGL, "swiftshader"); 469 command_line->AppendSwitchASCII(switches::kUseGL, "swiftshader");
443 if (swiftshader_path.empty()) 470 if (swiftshader_path.empty())
444 swiftshader_path = swiftshader_path_; 471 swiftshader_path = swiftshader_path_;
445 } else if ((IsFeatureBlacklisted(GPU_FEATURE_TYPE_WEBGL) || 472 } else if ((IsFeatureBlacklisted(GPU_FEATURE_TYPE_WEBGL) ||
446 IsFeatureBlacklisted(GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING) || 473 IsFeatureBlacklisted(GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING) ||
447 IsFeatureBlacklisted(GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)) && 474 IsFeatureBlacklisted(GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)) &&
448 (use_gl == "any")) { 475 (use_gl == "any")) {
449 command_line->AppendSwitchASCII( 476 command_line->AppendSwitchASCII(
450 switches::kUseGL, gfx::kGLImplementationOSMesaName); 477 switches::kUseGL, gfx::kGLImplementationOSMesaName);
451 } else if (!use_gl.empty()) { 478 } else if (!use_gl.empty()) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 switches::kDisableCoreAnimationPlugins)) 558 switches::kDisableCoreAnimationPlugins))
532 command_line->AppendSwitch( 559 command_line->AppendSwitch(
533 switches::kDisableCoreAnimationPlugins); 560 switches::kDisableCoreAnimationPlugins);
534 } 561 }
535 #endif 562 #endif
536 } 563 }
537 564
538 void GpuDataManagerImpl::UpdateRendererWebPrefs( 565 void GpuDataManagerImpl::UpdateRendererWebPrefs(
539 webkit_glue::WebPreferences* prefs) const { 566 webkit_glue::WebPreferences* prefs) const {
540 DCHECK(prefs); 567 DCHECK(prefs);
568
569 if (DISABLE_GPU) {
570 prefs->force_compositing_mode = true;
571 prefs->accelerated_compositing_enabled = true;
572 prefs->accelerated_compositing_for_3d_transforms_enabled = true;
573 prefs->accelerated_compositing_for_animation_enabled = true;
574 prefs->experimental_webgl_enabled = false;
575 prefs->flash_3d_enabled = false;
576 prefs->flash_stage3d_enabled = false;
577 prefs->flash_stage3d_baseline_enabled = false;
578 prefs->accelerated_2d_canvas_enabled = false;
579 prefs->gl_multisampling_enabled = false;
580 prefs->accelerated_compositing_for_video_enabled = false;
581 prefs->accelerated_compositing_for_plugins_enabled = false;
582 return;
583 }
584
541 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING)) 585 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING))
542 prefs->accelerated_compositing_enabled = false; 586 prefs->accelerated_compositing_enabled = false;
543 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_WEBGL)) 587 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_WEBGL))
544 prefs->experimental_webgl_enabled = false; 588 prefs->experimental_webgl_enabled = false;
545 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_FLASH3D)) 589 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_FLASH3D))
546 prefs->flash_3d_enabled = false; 590 prefs->flash_3d_enabled = false;
547 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_FLASH_STAGE3D)) { 591 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_FLASH_STAGE3D)) {
548 prefs->flash_stage3d_enabled = false; 592 prefs->flash_stage3d_enabled = false;
549 prefs->flash_stage3d_baseline_enabled = false; 593 prefs->flash_stage3d_baseline_enabled = false;
550 } 594 }
551 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_FLASH_STAGE3D_BASELINE)) 595 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_FLASH_STAGE3D_BASELINE))
552 prefs->flash_stage3d_baseline_enabled = false; 596 prefs->flash_stage3d_baseline_enabled = false;
553 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)) 597 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS))
554 prefs->accelerated_2d_canvas_enabled = false; 598 prefs->accelerated_2d_canvas_enabled = false;
555 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_MULTISAMPLING)) 599 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_MULTISAMPLING))
556 prefs->gl_multisampling_enabled = false; 600 prefs->gl_multisampling_enabled = false;
557 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_3D_CSS)) { 601 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_3D_CSS)) {
558 prefs->accelerated_compositing_for_3d_transforms_enabled = false; 602 prefs->accelerated_compositing_for_3d_transforms_enabled = false;
559 prefs->accelerated_compositing_for_animation_enabled = false; 603 prefs->accelerated_compositing_for_animation_enabled = false;
560 } 604 }
561 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_ACCELERATED_VIDEO)) 605 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_ACCELERATED_VIDEO))
562 prefs->accelerated_compositing_for_video_enabled = false; 606 prefs->accelerated_compositing_for_video_enabled = false;
563 607
564 // Accelerated video and animation are slower than regular when using a 608 // Accelerated video and animation are slower than regular when using
565 // software 3d rasterizer. 3D CSS may also be too slow to be worthwhile. 609 // SwiftShader. 3D CSS may also be too slow to be worthwhile.
566 if (ShouldUseSoftwareRendering()) { 610 if (ShouldUseSwiftShader()) {
567 prefs->accelerated_compositing_for_video_enabled = false; 611 prefs->accelerated_compositing_for_video_enabled = false;
568 prefs->accelerated_compositing_for_animation_enabled = false; 612 prefs->accelerated_compositing_for_animation_enabled = false;
569 prefs->accelerated_compositing_for_3d_transforms_enabled = false; 613 prefs->accelerated_compositing_for_3d_transforms_enabled = false;
570 prefs->accelerated_compositing_for_plugins_enabled = false; 614 prefs->accelerated_compositing_for_plugins_enabled = false;
571 } 615 }
572 } 616 }
573 617
574 GpuSwitchingOption GpuDataManagerImpl::GetGpuSwitchingOption() const { 618 GpuSwitchingOption GpuDataManagerImpl::GetGpuSwitchingOption() const {
575 if (!ui::GpuSwitchingManager::GetInstance()->SupportsDualGpus()) 619 if (!ui::GpuSwitchingManager::GetInstance()->SupportsDualGpus())
576 return GPU_SWITCHING_OPTION_UNKNOWN; 620 return GPU_SWITCHING_OPTION_UNKNOWN;
577 return gpu_switching_; 621 return gpu_switching_;
578 } 622 }
579 623
580 void GpuDataManagerImpl::DisableHardwareAcceleration() { 624 void GpuDataManagerImpl::DisableHardwareAcceleration() {
581 card_blacklisted_ = true; 625 card_blacklisted_ = true;
582 626
583 for (int i = 0; i < NUMBER_OF_GPU_FEATURE_TYPES; ++i) 627 for (int i = 0; i < NUMBER_OF_GPU_FEATURE_TYPES; ++i)
584 blacklisted_features_.insert(i); 628 blacklisted_features_.insert(i);
585 629
586 EnableSoftwareRenderingIfNecessary(); 630 EnableSwiftShaderIfNecessary();
587 NotifyGpuInfoUpdate(); 631 NotifyGpuInfoUpdate();
588 } 632 }
589 633
590 std::string GpuDataManagerImpl::GetBlacklistVersion() const { 634 std::string GpuDataManagerImpl::GetBlacklistVersion() const {
591 if (gpu_blacklist_) 635 if (gpu_blacklist_)
592 return gpu_blacklist_->version(); 636 return gpu_blacklist_->version();
593 return "0"; 637 return "0";
594 } 638 }
595 639
596 base::ListValue* GpuDataManagerImpl::GetBlacklistReasons() const { 640 base::ListValue* GpuDataManagerImpl::GetBlacklistReasons() const {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 gpu_switch_callbacks_[i].Run(); 683 gpu_switch_callbacks_[i].Run();
640 } 684 }
641 685
642 #if defined(OS_WIN) 686 #if defined(OS_WIN)
643 bool GpuDataManagerImpl::IsUsingAcceleratedSurface() const { 687 bool GpuDataManagerImpl::IsUsingAcceleratedSurface() const {
644 if (base::win::GetVersion() < base::win::VERSION_VISTA) 688 if (base::win::GetVersion() < base::win::VERSION_VISTA)
645 return false; 689 return false;
646 690
647 if (gpu_info_.amd_switchable) 691 if (gpu_info_.amd_switchable)
648 return false; 692 return false;
649 if (software_rendering_) 693 if (use_swiftshader_)
650 return false; 694 return false;
651 CommandLine* command_line = CommandLine::ForCurrentProcess(); 695 CommandLine* command_line = CommandLine::ForCurrentProcess();
652 if (command_line->HasSwitch(switches::kDisableImageTransportSurface)) 696 if (command_line->HasSwitch(switches::kDisableImageTransportSurface))
653 return false; 697 return false;
654 return !IsFeatureBlacklisted(GPU_FEATURE_TYPE_TEXTURE_SHARING); 698 return !IsFeatureBlacklisted(GPU_FEATURE_TYPE_TEXTURE_SHARING);
655 } 699 }
656 #endif 700 #endif
657 701
658 void GpuDataManagerImpl::BlockDomainFrom3DAPIs( 702 void GpuDataManagerImpl::BlockDomainFrom3DAPIs(
659 const GURL& url, DomainGuilt guilt) { 703 const GURL& url, DomainGuilt guilt) {
(...skipping 18 matching lines...) Expand all
678 } 722 }
679 723
680 void GpuDataManagerImpl::DisableDomainBlockingFor3DAPIsForTesting() { 724 void GpuDataManagerImpl::DisableDomainBlockingFor3DAPIsForTesting() {
681 domain_blocking_enabled_ = false; 725 domain_blocking_enabled_ = false;
682 } 726 }
683 727
684 GpuDataManagerImpl::GpuDataManagerImpl() 728 GpuDataManagerImpl::GpuDataManagerImpl()
685 : complete_gpu_info_already_requested_(false), 729 : complete_gpu_info_already_requested_(false),
686 gpu_switching_(GPU_SWITCHING_OPTION_AUTOMATIC), 730 gpu_switching_(GPU_SWITCHING_OPTION_AUTOMATIC),
687 observer_list_(new GpuDataManagerObserverList), 731 observer_list_(new GpuDataManagerObserverList),
688 software_rendering_(false), 732 use_swiftshader_(false),
689 card_blacklisted_(false), 733 card_blacklisted_(false),
690 update_histograms_(true), 734 update_histograms_(true),
691 window_count_(0), 735 window_count_(0),
692 domain_blocking_enabled_(true) { 736 domain_blocking_enabled_(true) {
693 CommandLine* command_line = CommandLine::ForCurrentProcess(); 737 CommandLine* command_line = CommandLine::ForCurrentProcess();
694 if (command_line->HasSwitch(switches::kDisableAcceleratedCompositing)) { 738 if (command_line->HasSwitch(switches::kDisableAcceleratedCompositing)) {
695 command_line->AppendSwitch(switches::kDisableAccelerated2dCanvas); 739 command_line->AppendSwitch(switches::kDisableAccelerated2dCanvas);
696 command_line->AppendSwitch(switches::kDisableAcceleratedLayers); 740 command_line->AppendSwitch(switches::kDisableAcceleratedLayers);
697 } 741 }
698 if (command_line->HasSwitch(switches::kDisableGpu)) 742 if (command_line->HasSwitch(switches::kDisableGpu))
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 // otherwise be allowed. 806 // otherwise be allowed.
763 if (card_blacklisted_ || 807 if (card_blacklisted_ ||
764 command_line->HasSwitch(switches::kBlacklistAcceleratedCompositing)) { 808 command_line->HasSwitch(switches::kBlacklistAcceleratedCompositing)) {
765 blacklisted_features_.insert(GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING); 809 blacklisted_features_.insert(GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING);
766 } 810 }
767 if (card_blacklisted_ || 811 if (card_blacklisted_ ||
768 command_line->HasSwitch(switches::kBlacklistWebGL)) { 812 command_line->HasSwitch(switches::kBlacklistWebGL)) {
769 blacklisted_features_.insert(GPU_FEATURE_TYPE_WEBGL); 813 blacklisted_features_.insert(GPU_FEATURE_TYPE_WEBGL);
770 } 814 }
771 815
772 EnableSoftwareRenderingIfNecessary(); 816 EnableSwiftShaderIfNecessary();
773 } 817 }
774 818
775 void GpuDataManagerImpl::UpdatePreliminaryBlacklistedFeatures() { 819 void GpuDataManagerImpl::UpdatePreliminaryBlacklistedFeatures() {
776 preliminary_blacklisted_features_ = blacklisted_features_; 820 preliminary_blacklisted_features_ = blacklisted_features_;
777 } 821 }
778 822
779 void GpuDataManagerImpl::UpdateGpuSwitchingManager(const GPUInfo& gpu_info) { 823 void GpuDataManagerImpl::UpdateGpuSwitchingManager(const GPUInfo& gpu_info) {
780 ui::GpuSwitchingManager::GetInstance()->SetGpuCount( 824 ui::GpuSwitchingManager::GetInstance()->SetGpuCount(
781 gpu_info.secondary_gpus.size() + 1); 825 gpu_info.secondary_gpus.size() + 1);
782 826
783 if (ui::GpuSwitchingManager::GetInstance()->SupportsDualGpus()) { 827 if (ui::GpuSwitchingManager::GetInstance()->SupportsDualGpus()) {
784 switch (gpu_switching_) { 828 switch (gpu_switching_) {
785 case GPU_SWITCHING_OPTION_FORCE_DISCRETE: 829 case GPU_SWITCHING_OPTION_FORCE_DISCRETE:
786 ui::GpuSwitchingManager::GetInstance()->ForceUseOfDiscreteGpu(); 830 ui::GpuSwitchingManager::GetInstance()->ForceUseOfDiscreteGpu();
787 break; 831 break;
788 case GPU_SWITCHING_OPTION_FORCE_INTEGRATED: 832 case GPU_SWITCHING_OPTION_FORCE_INTEGRATED:
789 ui::GpuSwitchingManager::GetInstance()->ForceUseOfIntegratedGpu(); 833 ui::GpuSwitchingManager::GetInstance()->ForceUseOfIntegratedGpu();
790 break; 834 break;
791 case GPU_SWITCHING_OPTION_AUTOMATIC: 835 case GPU_SWITCHING_OPTION_AUTOMATIC:
792 case GPU_SWITCHING_OPTION_UNKNOWN: 836 case GPU_SWITCHING_OPTION_UNKNOWN:
793 break; 837 break;
794 } 838 }
795 } 839 }
796 } 840 }
797 841
798 void GpuDataManagerImpl::NotifyGpuInfoUpdate() { 842 void GpuDataManagerImpl::NotifyGpuInfoUpdate() {
799 observer_list_->Notify(&GpuDataManagerObserver::OnGpuInfoUpdate); 843 observer_list_->Notify(&GpuDataManagerObserver::OnGpuInfoUpdate);
800 } 844 }
801 845
802 void GpuDataManagerImpl::EnableSoftwareRenderingIfNecessary() { 846 void GpuDataManagerImpl::EnableSwiftShaderIfNecessary() {
803 if (!GpuAccessAllowed() || 847 if (!GpuAccessAllowed() ||
804 blacklisted_features_.count(GPU_FEATURE_TYPE_WEBGL)) { 848 blacklisted_features_.count(GPU_FEATURE_TYPE_WEBGL)) {
805 if (!swiftshader_path_.empty() && 849 if (!swiftshader_path_.empty() &&
806 !CommandLine::ForCurrentProcess()->HasSwitch( 850 !CommandLine::ForCurrentProcess()->HasSwitch(
807 switches::kDisableSoftwareRasterizer)) 851 switches::kDisableSoftwareRasterizer))
808 software_rendering_ = true; 852 use_swiftshader_ = true;
809 } 853 }
810 } 854 }
811 855
812 std::string GpuDataManagerImpl::GetDomainFromURL(const GURL& url) const { 856 std::string GpuDataManagerImpl::GetDomainFromURL(const GURL& url) const {
813 // For the moment, we just use the host, or its IP address, as the 857 // For the moment, we just use the host, or its IP address, as the
814 // entry in the set, rather than trying to figure out the top-level 858 // entry in the set, rather than trying to figure out the top-level
815 // domain. This does mean that a.foo.com and b.foo.com will be 859 // domain. This does mean that a.foo.com and b.foo.com will be
816 // treated independently in the blocking of a given domain, but it 860 // treated independently in the blocking of a given domain, but it
817 // would require a third-party library to reliably figure out the 861 // would require a third-party library to reliably figure out the
818 // top-level domain from a URL. 862 // top-level domain from a URL.
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 950
907 void GpuDataManagerImpl::Notify3DAPIBlocked(const GURL& url, 951 void GpuDataManagerImpl::Notify3DAPIBlocked(const GURL& url,
908 int render_process_id, 952 int render_process_id,
909 int render_view_id, 953 int render_view_id,
910 ThreeDAPIType requester) { 954 ThreeDAPIType requester) {
911 observer_list_->Notify(&GpuDataManagerObserver::DidBlock3DAPIs, 955 observer_list_->Notify(&GpuDataManagerObserver::DidBlock3DAPIs,
912 url, render_process_id, render_view_id, requester); 956 url, render_process_id, render_view_id, requester);
913 } 957 }
914 958
915 } // namespace content 959 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/gpu/gpu_data_manager_impl.h ('k') | content/browser/gpu/gpu_data_manager_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698