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

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

Issue 10909221: Implement blacklist's force GPU capability in dual GPU machines. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 3 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 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 30 matching lines...) Expand all
41 41
42 // static 42 // static
43 GpuDataManagerImpl* GpuDataManagerImpl::GetInstance() { 43 GpuDataManagerImpl* GpuDataManagerImpl::GetInstance() {
44 return Singleton<GpuDataManagerImpl>::get(); 44 return Singleton<GpuDataManagerImpl>::get();
45 } 45 }
46 46
47 GpuDataManagerImpl::GpuDataManagerImpl() 47 GpuDataManagerImpl::GpuDataManagerImpl()
48 : complete_gpu_info_already_requested_(false), 48 : complete_gpu_info_already_requested_(false),
49 gpu_feature_type_(content::GPU_FEATURE_TYPE_UNKNOWN), 49 gpu_feature_type_(content::GPU_FEATURE_TYPE_UNKNOWN),
50 preliminary_gpu_feature_type_(content::GPU_FEATURE_TYPE_UNKNOWN), 50 preliminary_gpu_feature_type_(content::GPU_FEATURE_TYPE_UNKNOWN),
51 gpu_switching_(content::GPU_SWITCHING_AUTOMATIC), 51 gpu_switching_(content::GPU_SWITCHING_OPTION_AUTOMATIC),
52 observer_list_(new GpuDataManagerObserverList), 52 observer_list_(new GpuDataManagerObserverList),
53 software_rendering_(false), 53 software_rendering_(false),
54 card_blacklisted_(false), 54 card_blacklisted_(false),
55 update_histograms_(true) { 55 update_histograms_(true) {
56 CommandLine* command_line = CommandLine::ForCurrentProcess(); 56 CommandLine* command_line = CommandLine::ForCurrentProcess();
57 if (command_line->HasSwitch(switches::kDisableAcceleratedCompositing)) { 57 if (command_line->HasSwitch(switches::kDisableAcceleratedCompositing)) {
58 command_line->AppendSwitch(switches::kDisableAccelerated2dCanvas); 58 command_line->AppendSwitch(switches::kDisableAccelerated2dCanvas);
59 command_line->AppendSwitch(switches::kDisableAcceleratedLayers); 59 command_line->AppendSwitch(switches::kDisableAcceleratedLayers);
60 } 60 }
61 if (command_line->HasSwitch(switches::kDisableGpu)) 61 if (command_line->HasSwitch(switches::kDisableGpu))
62 BlacklistCard(); 62 BlacklistCard();
63 if (command_line->HasSwitch(switches::kGpuSwitching)) {
64 std::string option_string = command_line->GetSwitchValueASCII(
65 switches::kGpuSwitching);
66 GpuSwitchingOption option = gpu_util::StringToGpuSwitchingOption(
67 option_string);
68 if (option != content::GPU_SWITCHING_OPTION_UNKNOWN)
69 gpu_switching_ = option;
70 }
63 } 71 }
64 72
65 void GpuDataManagerImpl::Initialize( 73 void GpuDataManagerImpl::Initialize(
66 const std::string& browser_version_string, 74 const std::string& browser_version_string,
67 const std::string& gpu_blacklist_json) { 75 const std::string& gpu_blacklist_json) {
68 content::GPUInfo gpu_info; 76 content::GPUInfo gpu_info;
69 gpu_info_collector::CollectPreliminaryGraphicsInfo(&gpu_info); 77 gpu_info_collector::CollectPreliminaryGraphicsInfo(&gpu_info);
70 #if defined(ARCH_CPU_X86_FAMILY) 78 #if defined(ARCH_CPU_X86_FAMILY)
71 if (!gpu_info.gpu.vendor_id || !gpu_info.gpu.device_id) 79 if (!gpu_info.gpu.vendor_id || !gpu_info.gpu.device_id)
72 gpu_info.finalized = true; 80 gpu_info.finalized = true;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 138
131 if (gpu_blacklist_.get()) { 139 if (gpu_blacklist_.get()) {
132 GpuBlacklist::Decision decision = 140 GpuBlacklist::Decision decision =
133 gpu_blacklist_->MakeBlacklistDecision( 141 gpu_blacklist_->MakeBlacklistDecision(
134 GpuBlacklist::kOsAny, NULL, gpu_info); 142 GpuBlacklist::kOsAny, NULL, gpu_info);
135 if (update_histograms_) { 143 if (update_histograms_) {
136 gpu_util::UpdateStats(gpu_blacklist_.get(), 144 gpu_util::UpdateStats(gpu_blacklist_.get(),
137 decision.blacklisted_features); 145 decision.blacklisted_features);
138 } 146 }
139 UpdateBlacklistedFeatures(decision.blacklisted_features); 147 UpdateBlacklistedFeatures(decision.blacklisted_features);
140 gpu_switching_ = decision.gpu_switching; 148 if (decision.gpu_switching != content::GPU_SWITCHING_OPTION_UNKNOWN)
149 gpu_switching_ = decision.gpu_switching;
141 } 150 }
142 151
143 { 152 {
144 base::AutoLock auto_lock(gpu_info_lock_); 153 base::AutoLock auto_lock(gpu_info_lock_);
145 gpu_info_ = gpu_info; 154 gpu_info_ = gpu_info;
146 complete_gpu_info_already_requested_ = 155 complete_gpu_info_already_requested_ =
147 complete_gpu_info_already_requested_ || gpu_info_.finalized; 156 complete_gpu_info_already_requested_ || gpu_info_.finalized;
148 } 157 }
149 158
150 // We have to update GpuFeatureType before notify all the observers. 159 // We have to update GpuFeatureType before notify all the observers.
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 swiftshader_path = swiftshader_path_; 301 swiftshader_path = swiftshader_path_;
293 } else if ((flags & (content::GPU_FEATURE_TYPE_WEBGL | 302 } else if ((flags & (content::GPU_FEATURE_TYPE_WEBGL |
294 content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING | 303 content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING |
295 content::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)) && 304 content::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)) &&
296 (use_gl == "any")) { 305 (use_gl == "any")) {
297 command_line->AppendSwitchASCII( 306 command_line->AppendSwitchASCII(
298 switches::kUseGL, gfx::kGLImplementationOSMesaName); 307 switches::kUseGL, gfx::kGLImplementationOSMesaName);
299 } else if (!use_gl.empty()) { 308 } else if (!use_gl.empty()) {
300 command_line->AppendSwitchASCII(switches::kUseGL, use_gl); 309 command_line->AppendSwitchASCII(switches::kUseGL, use_gl);
301 } 310 }
311 switch (gpu_switching_) {
312 case content::GPU_SWITCHING_OPTION_FORCE_DISCRETE:
313 command_line->AppendSwitchASCII(switches::kGpuSwitching,
314 switches::kGpuSwitchingOptionNameForceDiscrete);
315 break;
316 case content::GPU_SWITCHING_OPTION_FORCE_INTEGRATED:
317 command_line->AppendSwitchASCII(switches::kGpuSwitching,
318 switches::kGpuSwitchingOptionNameForceIntegrated);
319 break;
320 default:
321 break;
322 }
302 323
303 if (!swiftshader_path.empty()) 324 if (!swiftshader_path.empty())
304 command_line->AppendSwitchPath(switches::kSwiftShaderPath, 325 command_line->AppendSwitchPath(switches::kSwiftShaderPath,
305 swiftshader_path); 326 swiftshader_path);
306 327
307 { 328 {
308 base::AutoLock auto_lock(gpu_info_lock_); 329 base::AutoLock auto_lock(gpu_info_lock_);
309 if (gpu_info_.optimus) 330 if (gpu_info_.optimus)
310 command_line->AppendSwitch(switches::kReduceGpuSandbox); 331 command_line->AppendSwitch(switches::kReduceGpuSandbox);
311 if (gpu_info_.amd_switchable) { 332 if (gpu_info_.amd_switchable) {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 447
427 void GpuDataManagerImpl::BlacklistCard() { 448 void GpuDataManagerImpl::BlacklistCard() {
428 card_blacklisted_ = true; 449 card_blacklisted_ = true;
429 450
430 gpu_feature_type_ = content::GPU_FEATURE_TYPE_ALL; 451 gpu_feature_type_ = content::GPU_FEATURE_TYPE_ALL;
431 452
432 EnableSoftwareRenderingIfNecessary(); 453 EnableSoftwareRenderingIfNecessary();
433 NotifyGpuInfoUpdate(); 454 NotifyGpuInfoUpdate();
434 } 455 }
435 456
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698