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

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

Issue 15385003: Move GPU device/driver info related code from content to gpu. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 7 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_private.h" 5 #include "content/browser/gpu/gpu_data_manager_impl_private.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/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
11 #include "base/metrics/field_trial.h" 11 #include "base/metrics/field_trial.h"
12 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
13 #include "base/stringprintf.h" 13 #include "base/stringprintf.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/sys_info.h" 15 #include "base/sys_info.h"
16 #include "base/version.h" 16 #include "base/version.h"
17 #include "cc/base/switches.h" 17 #include "cc/base/switches.h"
18 #include "content/browser/gpu/gpu_control_list_jsons.h"
19 #include "content/browser/gpu/gpu_process_host.h" 18 #include "content/browser/gpu/gpu_process_host.h"
20 #include "content/browser/gpu/gpu_util.h"
21 #include "content/common/gpu/gpu_messages.h" 19 #include "content/common/gpu/gpu_messages.h"
22 #include "content/gpu/gpu_info_collector.h" 20 #include "content/gpu/gpu_info_collector.h"
23 #include "content/public/browser/browser_thread.h" 21 #include "content/public/browser/browser_thread.h"
24 #include "content/public/browser/gpu_data_manager_observer.h" 22 #include "content/public/browser/gpu_data_manager_observer.h"
25 #include "content/public/common/content_client.h" 23 #include "content/public/common/content_client.h"
26 #include "content/public/common/content_constants.h" 24 #include "content/public/common/content_constants.h"
27 #include "content/public/common/content_switches.h" 25 #include "content/public/common/content_switches.h"
28 #include "content/public/common/gpu_feature_type.h"
29 #include "gpu/command_buffer/service/gpu_switches.h" 26 #include "gpu/command_buffer/service/gpu_switches.h"
27 #include "gpu/config/gpu_control_list_jsons.h"
28 #include "gpu/config/gpu_feature_type.h"
29 #include "gpu/config/gpu_util.h"
30 #include "ui/base/ui_base_switches.h" 30 #include "ui/base/ui_base_switches.h"
31 #include "ui/gl/gl_implementation.h" 31 #include "ui/gl/gl_implementation.h"
32 #include "ui/gl/gl_switches.h" 32 #include "ui/gl/gl_switches.h"
33 #include "ui/gl/gpu_switching_manager.h" 33 #include "ui/gl/gpu_switching_manager.h"
34 #include "webkit/glue/webpreferences.h" 34 #include "webkit/glue/webpreferences.h"
35 #include "webkit/plugins/plugin_switches.h" 35 #include "webkit/plugins/plugin_switches.h"
36 36
37 #if defined(OS_MACOSX) 37 #if defined(OS_MACOSX)
38 #include <ApplicationServices/ApplicationServices.h> 38 #include <ApplicationServices/ApplicationServices.h>
39 #endif // OS_MACOSX 39 #endif // OS_MACOSX
40 #if defined(OS_WIN) 40 #if defined(OS_WIN)
41 #include "base/win/windows_version.h" 41 #include "base/win/windows_version.h"
42 #endif // OS_WIN 42 #endif // OS_WIN
43 #if defined(OS_ANDROID) 43 #if defined(OS_ANDROID)
44 #include "ui/gfx/android/device_display_info.h" 44 #include "ui/gfx/android/device_display_info.h"
45 #endif // OS_ANDROID 45 #endif // OS_ANDROID
46 46
47 namespace content { 47 namespace content {
48
48 namespace { 49 namespace {
49 50
51 enum GpuFeatureStatus {
52 kGpuFeatureEnabled = 0,
53 kGpuFeatureBlacklisted = 1,
54 kGpuFeatureDisabled = 2, // disabled by user but not blacklisted
55 kGpuFeatureNumStatus
56 };
57
58 #if defined(OS_WIN)
59
60 enum WinSubVersion {
61 kWinOthers = 0,
62 kWinXP,
63 kWinVista,
64 kWin7,
65 kNumWinSubVersions
66 };
67
68 int GetGpuBlacklistHistogramValueWin(GpuFeatureStatus status) {
69 static WinSubVersion sub_version = kNumWinSubVersions;
70 if (sub_version == kNumWinSubVersions) {
71 sub_version = kWinOthers;
72 std::string version_str = base::SysInfo::OperatingSystemVersion();
73 size_t pos = version_str.find_first_not_of("0123456789.");
74 if (pos != std::string::npos)
75 version_str = version_str.substr(0, pos);
76 Version os_version(version_str);
77 if (os_version.IsValid() && os_version.components().size() >= 2) {
78 const std::vector<uint16>& version_numbers = os_version.components();
79 if (version_numbers[0] == 5)
80 sub_version = kWinXP;
81 else if (version_numbers[0] == 6 && version_numbers[1] == 0)
82 sub_version = kWinVista;
83 else if (version_numbers[0] == 6 && version_numbers[1] == 1)
84 sub_version = kWin7;
85 }
86 }
87 int entry_index = static_cast<int>(sub_version) * kGpuFeatureNumStatus;
88 switch (status) {
89 case kGpuFeatureEnabled:
90 break;
91 case kGpuFeatureBlacklisted:
92 entry_index++;
93 break;
94 case kGpuFeatureDisabled:
95 entry_index += 2;
96 break;
97 }
98 return entry_index;
99 }
100 #endif // OS_WIN
101
102 // Send UMA histograms about the enabled features.
103 void UpdateStats(const gpu::GpuBlacklist* blacklist,
104 const std::set<int>& blacklisted_features) {
105 uint32 max_entry_id = blacklist->max_entry_id();
106 if (max_entry_id == 0) {
107 // GPU Blacklist was not loaded. No need to go further.
108 return;
109 }
110
111 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
112 bool disabled = false;
113 if (blacklisted_features.size() == 0) {
114 UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResultsPerEntry",
115 0, max_entry_id + 1);
116 } else {
117 std::vector<uint32> flag_entries;
118 blacklist->GetDecisionEntries(&flag_entries, disabled);
119 DCHECK_GT(flag_entries.size(), 0u);
120 for (size_t i = 0; i < flag_entries.size(); ++i) {
121 UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResultsPerEntry",
122 flag_entries[i], max_entry_id + 1);
123 }
124 }
125
126 // This counts how many users are affected by a disabled entry - this allows
127 // us to understand the impact of an entry before enable it.
128 std::vector<uint32> flag_disabled_entries;
129 disabled = true;
130 blacklist->GetDecisionEntries(&flag_disabled_entries, disabled);
131 for (size_t i = 0; i < flag_disabled_entries.size(); ++i) {
132 UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResultsPerDisabledEntry",
133 flag_disabled_entries[i], max_entry_id + 1);
134 }
135
136 const gpu::GpuFeatureType kGpuFeatures[] = {
137 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS,
138 gpu::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING,
139 gpu::GPU_FEATURE_TYPE_WEBGL
140 };
141 const std::string kGpuBlacklistFeatureHistogramNames[] = {
142 "GPU.BlacklistFeatureTestResults.Accelerated2dCanvas",
143 "GPU.BlacklistFeatureTestResults.AcceleratedCompositing",
144 "GPU.BlacklistFeatureTestResults.Webgl"
145 };
146 const bool kGpuFeatureUserFlags[] = {
147 command_line.HasSwitch(switches::kDisableAccelerated2dCanvas),
148 command_line.HasSwitch(switches::kDisableAcceleratedCompositing),
149 #if defined(OS_ANDROID)
150 !command_line.HasSwitch(switches::kEnableExperimentalWebGL)
151 #else
152 command_line.HasSwitch(switches::kDisableExperimentalWebGL)
153 #endif
154 };
155 #if defined(OS_WIN)
156 const std::string kGpuBlacklistFeatureHistogramNamesWin[] = {
157 "GPU.BlacklistFeatureTestResultsWindows.Accelerated2dCanvas",
158 "GPU.BlacklistFeatureTestResultsWindows.AcceleratedCompositing",
159 "GPU.BlacklistFeatureTestResultsWindows.Webgl"
160 };
161 #endif
162 const size_t kNumFeatures =
163 sizeof(kGpuFeatures) / sizeof(gpu::GpuFeatureType);
164 for (size_t i = 0; i < kNumFeatures; ++i) {
165 // We can't use UMA_HISTOGRAM_ENUMERATION here because the same name is
166 // expected if the macro is used within a loop.
167 GpuFeatureStatus value = kGpuFeatureEnabled;
168 if (blacklisted_features.count(kGpuFeatures[i]))
169 value = kGpuFeatureBlacklisted;
170 else if (kGpuFeatureUserFlags[i])
171 value = kGpuFeatureDisabled;
172 base::HistogramBase* histogram_pointer = base::LinearHistogram::FactoryGet(
173 kGpuBlacklistFeatureHistogramNames[i],
174 1, kGpuFeatureNumStatus, kGpuFeatureNumStatus + 1,
175 base::HistogramBase::kUmaTargetedHistogramFlag);
176 histogram_pointer->Add(value);
177 #if defined(OS_WIN)
178 histogram_pointer = base::LinearHistogram::FactoryGet(
179 kGpuBlacklistFeatureHistogramNamesWin[i],
180 1, kNumWinSubVersions * kGpuFeatureNumStatus,
181 kNumWinSubVersions * kGpuFeatureNumStatus + 1,
182 base::HistogramBase::kUmaTargetedHistogramFlag);
183 histogram_pointer->Add(GetGpuBlacklistHistogramValueWin(value));
184 #endif
185 }
186 }
187
50 // Strip out the non-digital info; if after that, we get an empty string, 188 // Strip out the non-digital info; if after that, we get an empty string,
51 // return "0". 189 // return "0".
52 std::string ProcessVersionString(const std::string& raw_string) { 190 std::string ProcessVersionString(const std::string& raw_string) {
53 const std::string valid_set = "0123456789."; 191 const std::string valid_set = "0123456789.";
54 size_t start_pos = raw_string.find_first_of(valid_set); 192 size_t start_pos = raw_string.find_first_of(valid_set);
55 if (start_pos == std::string::npos) 193 if (start_pos == std::string::npos)
56 return "0"; 194 return "0";
57 size_t end_pos = raw_string.find_first_not_of(raw_string, start_pos); 195 size_t end_pos = raw_string.find_first_not_of(raw_string, start_pos);
58 std::string version_string = raw_string.substr( 196 std::string version_string = raw_string.substr(
59 start_pos, end_pos - start_pos); 197 start_pos, end_pos - start_pos);
(...skipping 21 matching lines...) Expand all
81 if (flags & kCGDisplayAddFlag) { 219 if (flags & kCGDisplayAddFlag) {
82 GpuDataManagerImpl* manager = 220 GpuDataManagerImpl* manager =
83 reinterpret_cast<GpuDataManagerImpl*>(gpu_data_manager); 221 reinterpret_cast<GpuDataManagerImpl*>(gpu_data_manager);
84 DCHECK(manager); 222 DCHECK(manager);
85 manager->HandleGpuSwitch(); 223 manager->HandleGpuSwitch();
86 } 224 }
87 } 225 }
88 #endif // OS_MACOSX 226 #endif // OS_MACOSX
89 227
90 #if defined(OS_ANDROID) 228 #if defined(OS_ANDROID)
91 void ApplyAndroidWorkarounds(const GPUInfo& gpu_info, 229 void ApplyAndroidWorkarounds(const gpu::GPUInfo& gpu_info,
92 CommandLine* command_line) { 230 CommandLine* command_line) {
93 std::string vendor(StringToLowerASCII(gpu_info.gl_vendor)); 231 std::string vendor(StringToLowerASCII(gpu_info.gl_vendor));
94 std::string renderer(StringToLowerASCII(gpu_info.gl_renderer)); 232 std::string renderer(StringToLowerASCII(gpu_info.gl_renderer));
95 bool is_img = 233 bool is_img =
96 gpu_info.gl_vendor.find("Imagination") != std::string::npos; 234 gpu_info.gl_vendor.find("Imagination") != std::string::npos;
97 bool is_arm = 235 bool is_arm =
98 gpu_info.gl_vendor.find("ARM") != std::string::npos; 236 gpu_info.gl_vendor.find("ARM") != std::string::npos;
99 bool is_qualcomm = 237 bool is_qualcomm =
100 gpu_info.gl_vendor.find("Qualcomm") != std::string::npos; 238 gpu_info.gl_vendor.find("Qualcomm") != std::string::npos;
101 bool is_mali_t604 = is_arm && 239 bool is_mali_t604 = is_arm &&
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 BLOCK_STATUS_NOT_BLOCKED, 307 BLOCK_STATUS_NOT_BLOCKED,
170 BLOCK_STATUS_SPECIFIC_DOMAIN_BLOCKED, 308 BLOCK_STATUS_SPECIFIC_DOMAIN_BLOCKED,
171 BLOCK_STATUS_ALL_DOMAINS_BLOCKED, 309 BLOCK_STATUS_ALL_DOMAINS_BLOCKED,
172 BLOCK_STATUS_MAX 310 BLOCK_STATUS_MAX
173 }; 311 };
174 312
175 } // namespace anonymous 313 } // namespace anonymous
176 314
177 void GpuDataManagerImplPrivate::InitializeForTesting( 315 void GpuDataManagerImplPrivate::InitializeForTesting(
178 const std::string& gpu_blacklist_json, 316 const std::string& gpu_blacklist_json,
179 const GPUInfo& gpu_info) { 317 const gpu::GPUInfo& gpu_info) {
180 // This function is for testing only, so disable histograms. 318 // This function is for testing only, so disable histograms.
181 update_histograms_ = false; 319 update_histograms_ = false;
182 320
183 InitializeImpl(gpu_blacklist_json, std::string(), std::string(), gpu_info); 321 InitializeImpl(gpu_blacklist_json, std::string(), std::string(), gpu_info);
184 } 322 }
185 323
186 bool GpuDataManagerImplPrivate::IsFeatureBlacklisted(int feature) const { 324 bool GpuDataManagerImplPrivate::IsFeatureBlacklisted(int feature) const {
187 if (use_swiftshader_) { 325 if (use_swiftshader_) {
188 // Skia's software rendering is probably more efficient than going through 326 // Skia's software rendering is probably more efficient than going through
189 // software emulation of the GPU, so use that. 327 // software emulation of the GPU, so use that.
190 if (feature == GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS) 328 if (feature == gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)
191 return true; 329 return true;
192 return false; 330 return false;
193 } 331 }
194 332
195 return (blacklisted_features_.count(feature) == 1); 333 return (blacklisted_features_.count(feature) == 1);
196 } 334 }
197 335
198 size_t GpuDataManagerImplPrivate::GetBlacklistedFeatureCount() const { 336 size_t GpuDataManagerImplPrivate::GetBlacklistedFeatureCount() const {
199 if (use_swiftshader_) 337 if (use_swiftshader_)
200 return 1; 338 return 1;
201 return blacklisted_features_.size(); 339 return blacklisted_features_.size();
202 } 340 }
203 341
204 GPUInfo GpuDataManagerImplPrivate::GetGPUInfo() const { 342 gpu::GPUInfo GpuDataManagerImplPrivate::GetGPUInfo() const {
205 return gpu_info_; 343 return gpu_info_;
206 } 344 }
207 345
208 void GpuDataManagerImplPrivate::GetGpuProcessHandles( 346 void GpuDataManagerImplPrivate::GetGpuProcessHandles(
209 const GpuDataManager::GetGpuProcessHandlesCallback& callback) const { 347 const GpuDataManager::GetGpuProcessHandlesCallback& callback) const {
210 GpuProcessHost::GetProcessHandles(callback); 348 GpuProcessHost::GetProcessHandles(callback);
211 } 349 }
212 350
213 bool GpuDataManagerImplPrivate::GpuAccessAllowed( 351 bool GpuDataManagerImplPrivate::GpuAccessAllowed(
214 std::string* reason) const { 352 std::string* reason) const {
(...skipping 16 matching lines...) Expand all
231 else 369 else
232 *reason += "in chrome://settings."; 370 *reason += "in chrome://settings.";
233 } 371 }
234 return false; 372 return false;
235 } 373 }
236 374
237 // We only need to block GPU process if more features are disallowed other 375 // We only need to block GPU process if more features are disallowed other
238 // than those in the preliminary gpu feature flags because the latter work 376 // than those in the preliminary gpu feature flags because the latter work
239 // through renderer commandline switches. 377 // through renderer commandline switches.
240 std::set<int> features = preliminary_blacklisted_features_; 378 std::set<int> features = preliminary_blacklisted_features_;
241 MergeFeatureSets(&features, blacklisted_features_); 379 gpu::MergeFeatureSets(&features, blacklisted_features_);
242 if (features.size() > preliminary_blacklisted_features_.size()) { 380 if (features.size() > preliminary_blacklisted_features_.size()) {
243 if (reason) { 381 if (reason) {
244 *reason = "Features are disabled upon full but not preliminary GPU info."; 382 *reason = "Features are disabled upon full but not preliminary GPU info.";
245 } 383 }
246 return false; 384 return false;
247 } 385 }
248 386
249 if (blacklisted_features_.size() == NUMBER_OF_GPU_FEATURE_TYPES) { 387 if (blacklisted_features_.size() == gpu::NUMBER_OF_GPU_FEATURE_TYPES) {
250 // On Linux, we use cached GL strings to make blacklist decsions at browser 388 // On Linux, we use cached GL strings to make blacklist decsions at browser
251 // startup time. We need to launch the GPU process to validate these 389 // startup time. We need to launch the GPU process to validate these
252 // strings even if all features are blacklisted. If all GPU features are 390 // strings even if all features are blacklisted. If all GPU features are
253 // disabled, the GPU process will only initialize GL bindings, create a GL 391 // disabled, the GPU process will only initialize GL bindings, create a GL
254 // context, and collect full GPU info. 392 // context, and collect full GPU info.
255 #if !defined(OS_LINUX) 393 #if !defined(OS_LINUX)
256 if (reason) { 394 if (reason) {
257 *reason = "All GPU features are blacklisted."; 395 *reason = "All GPU features are blacklisted.";
258 } 396 }
259 return false; 397 return false;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 if (gl_vendor.empty() && gl_renderer.empty() && gl_version.empty()) 480 if (gl_vendor.empty() && gl_renderer.empty() && gl_version.empty())
343 return; 481 return;
344 482
345 // If GPUInfo already got GL strings, do nothing. This is for the rare 483 // If GPUInfo already got GL strings, do nothing. This is for the rare
346 // situation where GPU process collected GL strings before this call. 484 // situation where GPU process collected GL strings before this call.
347 if (!gpu_info_.gl_vendor.empty() || 485 if (!gpu_info_.gl_vendor.empty() ||
348 !gpu_info_.gl_renderer.empty() || 486 !gpu_info_.gl_renderer.empty() ||
349 !gpu_info_.gl_version_string.empty()) 487 !gpu_info_.gl_version_string.empty())
350 return; 488 return;
351 489
352 GPUInfo gpu_info = gpu_info_; 490 gpu::GPUInfo gpu_info = gpu_info_;
353 491
354 gpu_info.gl_vendor = gl_vendor; 492 gpu_info.gl_vendor = gl_vendor;
355 gpu_info.gl_renderer = gl_renderer; 493 gpu_info.gl_renderer = gl_renderer;
356 gpu_info.gl_version_string = gl_version; 494 gpu_info.gl_version_string = gl_version;
357 495
358 gpu_info_collector::CollectDriverInfoGL(&gpu_info); 496 gpu::CollectDriverInfoGL(&gpu_info);
359 497
360 UpdateGpuInfo(gpu_info); 498 UpdateGpuInfo(gpu_info);
361 UpdateGpuSwitchingManager(gpu_info); 499 UpdateGpuSwitchingManager(gpu_info);
362 UpdatePreliminaryBlacklistedFeatures(); 500 UpdatePreliminaryBlacklistedFeatures();
363 } 501 }
364 502
365 void GpuDataManagerImplPrivate::GetGLStrings(std::string* gl_vendor, 503 void GpuDataManagerImplPrivate::GetGLStrings(std::string* gl_vendor,
366 std::string* gl_renderer, 504 std::string* gl_renderer,
367 std::string* gl_version) { 505 std::string* gl_version) {
368 DCHECK(gl_vendor && gl_renderer && gl_version); 506 DCHECK(gl_vendor && gl_renderer && gl_version);
369 507
370 *gl_vendor = gpu_info_.gl_vendor; 508 *gl_vendor = gpu_info_.gl_vendor;
371 *gl_renderer = gpu_info_.gl_renderer; 509 *gl_renderer = gpu_info_.gl_renderer;
372 *gl_version = gpu_info_.gl_version_string; 510 *gl_version = gpu_info_.gl_version_string;
373 } 511 }
374 512
375 void GpuDataManagerImplPrivate::Initialize() { 513 void GpuDataManagerImplPrivate::Initialize() {
376 TRACE_EVENT0("startup", "GpuDataManagerImpl::Initialize"); 514 TRACE_EVENT0("startup", "GpuDataManagerImpl::Initialize");
377 CommandLine* command_line = CommandLine::ForCurrentProcess(); 515 CommandLine* command_line = CommandLine::ForCurrentProcess();
378 if (command_line->HasSwitch(switches::kSkipGpuDataLoading)) 516 if (command_line->HasSwitch(switches::kSkipGpuDataLoading))
379 return; 517 return;
380 518
381 GPUInfo gpu_info; 519 gpu::GPUInfo gpu_info;
382 { 520 {
383 TRACE_EVENT0("startup", 521 TRACE_EVENT0("startup",
384 "GpuDataManagerImpl::Initialize:CollectBasicGraphicsInfo"); 522 "GpuDataManagerImpl::Initialize:CollectBasicGraphicsInfo");
385 gpu_info_collector::CollectBasicGraphicsInfo(&gpu_info); 523 gpu::CollectBasicGraphicsInfo(&gpu_info);
386 } 524 }
387 #if defined(ARCH_CPU_X86_FAMILY) 525 #if defined(ARCH_CPU_X86_FAMILY)
388 if (!gpu_info.gpu.vendor_id || !gpu_info.gpu.device_id) 526 if (!gpu_info.gpu.vendor_id || !gpu_info.gpu.device_id)
389 gpu_info.finalized = true; 527 gpu_info.finalized = true;
390 #endif 528 #endif
391 529
392 std::string gpu_blacklist_string; 530 std::string gpu_blacklist_string;
393 std::string gpu_switching_list_string; 531 std::string gpu_switching_list_string;
394 std::string gpu_driver_bug_list_string; 532 std::string gpu_driver_bug_list_string;
395 if (!command_line->HasSwitch(switches::kIgnoreGpuBlacklist)) { 533 if (!command_line->HasSwitch(switches::kIgnoreGpuBlacklist)) {
396 gpu_blacklist_string = kSoftwareRenderingListJson; 534 gpu_blacklist_string = gpu::kSoftwareRenderingListJson;
397 gpu_switching_list_string = kGpuSwitchingListJson; 535 gpu_switching_list_string = gpu::kGpuSwitchingListJson;
398 } 536 }
399 if (!command_line->HasSwitch(switches::kDisableGpuDriverBugWorkarounds)) { 537 if (!command_line->HasSwitch(switches::kDisableGpuDriverBugWorkarounds)) {
400 gpu_driver_bug_list_string = kGpuDriverBugListJson; 538 gpu_driver_bug_list_string = gpu::kGpuDriverBugListJson;
401 } 539 }
402 InitializeImpl(gpu_blacklist_string, 540 InitializeImpl(gpu_blacklist_string,
403 gpu_switching_list_string, 541 gpu_switching_list_string,
404 gpu_driver_bug_list_string, 542 gpu_driver_bug_list_string,
405 gpu_info); 543 gpu_info);
406 } 544 }
407 545
408 void GpuDataManagerImplPrivate::UpdateGpuInfo(const GPUInfo& gpu_info) { 546 void GpuDataManagerImplPrivate::UpdateGpuInfo(const gpu::GPUInfo& gpu_info) {
409 // No further update of gpu_info if falling back to SwiftShader. 547 // No further update of gpu_info if falling back to SwiftShader.
410 if (use_swiftshader_) 548 if (use_swiftshader_)
411 return; 549 return;
412 550
413 gpu_info_collector::MergeGPUInfo(&gpu_info_, gpu_info); 551 gpu::MergeGPUInfo(&gpu_info_, gpu_info);
414 complete_gpu_info_already_requested_ = 552 complete_gpu_info_already_requested_ =
415 complete_gpu_info_already_requested_ || gpu_info_.finalized; 553 complete_gpu_info_already_requested_ || gpu_info_.finalized;
416 554
417 GetContentClient()->SetGpuInfo(gpu_info_); 555 GetContentClient()->SetGpuInfo(gpu_info_);
418 556
419 if (gpu_blacklist_) { 557 if (gpu_blacklist_) {
420 std::set<int> features = gpu_blacklist_->MakeDecision( 558 std::set<int> features = gpu_blacklist_->MakeDecision(
421 GpuControlList::kOsAny, std::string(), gpu_info_); 559 gpu::GpuControlList::kOsAny, std::string(), gpu_info_);
422 if (update_histograms_) 560 if (update_histograms_)
423 UpdateStats(gpu_blacklist_.get(), features); 561 UpdateStats(gpu_blacklist_.get(), features);
424 562
425 UpdateBlacklistedFeatures(features); 563 UpdateBlacklistedFeatures(features);
426 } 564 }
427 if (gpu_switching_list_) { 565 if (gpu_switching_list_) {
428 std::set<int> option = gpu_switching_list_->MakeDecision( 566 std::set<int> option = gpu_switching_list_->MakeDecision(
429 GpuControlList::kOsAny, std::string(), gpu_info_); 567 gpu::GpuControlList::kOsAny, std::string(), gpu_info_);
430 if (option.size() == 1) { 568 if (option.size() == 1) {
431 // Blacklist decision should not overwrite commandline switch from users. 569 // Blacklist decision should not overwrite commandline switch from users.
432 CommandLine* command_line = CommandLine::ForCurrentProcess(); 570 CommandLine* command_line = CommandLine::ForCurrentProcess();
433 if (!command_line->HasSwitch(switches::kGpuSwitching)) 571 if (!command_line->HasSwitch(switches::kGpuSwitching)) {
434 gpu_switching_ = static_cast<GpuSwitchingOption>(*(option.begin())); 572 gpu_switching_ = static_cast<gpu::GpuSwitchingOption>(
573 *(option.begin()));
574 }
435 } 575 }
436 } 576 }
437 if (gpu_driver_bug_list_) 577 if (gpu_driver_bug_list_) {
438 gpu_driver_bugs_ = gpu_driver_bug_list_->MakeDecision( 578 gpu_driver_bugs_ = gpu_driver_bug_list_->MakeDecision(
439 GpuControlList::kOsAny, std::string(), gpu_info_); 579 gpu::GpuControlList::kOsAny, std::string(), gpu_info_);
580 }
440 581
441 // We have to update GpuFeatureType before notify all the observers. 582 // We have to update GpuFeatureType before notify all the observers.
442 NotifyGpuInfoUpdate(); 583 NotifyGpuInfoUpdate();
443 } 584 }
444 585
445 void GpuDataManagerImplPrivate::UpdateVideoMemoryUsageStats( 586 void GpuDataManagerImplPrivate::UpdateVideoMemoryUsageStats(
446 const GPUVideoMemoryUsageStats& video_memory_usage_stats) { 587 const GPUVideoMemoryUsageStats& video_memory_usage_stats) {
447 GpuDataManagerImpl::UnlockedSession session(owner_); 588 GpuDataManagerImpl::UnlockedSession session(owner_);
448 observer_list_->Notify(&GpuDataManagerObserver::OnVideoMemoryUsageStatsUpdate, 589 observer_list_->Notify(&GpuDataManagerObserver::OnVideoMemoryUsageStatsUpdate,
449 video_memory_usage_stats); 590 video_memory_usage_stats);
450 } 591 }
451 592
452 void GpuDataManagerImplPrivate::AppendRendererCommandLine( 593 void GpuDataManagerImplPrivate::AppendRendererCommandLine(
453 CommandLine* command_line) const { 594 CommandLine* command_line) const {
454 DCHECK(command_line); 595 DCHECK(command_line);
455 596
456 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_WEBGL)) { 597 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL)) {
457 #if !defined(OS_ANDROID) 598 #if !defined(OS_ANDROID)
458 if (!command_line->HasSwitch(switches::kDisableExperimentalWebGL)) 599 if (!command_line->HasSwitch(switches::kDisableExperimentalWebGL))
459 command_line->AppendSwitch(switches::kDisableExperimentalWebGL); 600 command_line->AppendSwitch(switches::kDisableExperimentalWebGL);
460 #endif 601 #endif
461 if (!command_line->HasSwitch(switches::kDisablePepper3d)) 602 if (!command_line->HasSwitch(switches::kDisablePepper3d))
462 command_line->AppendSwitch(switches::kDisablePepper3d); 603 command_line->AppendSwitch(switches::kDisablePepper3d);
463 } 604 }
464 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_MULTISAMPLING) && 605 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_MULTISAMPLING) &&
465 !command_line->HasSwitch(switches::kDisableGLMultisampling)) 606 !command_line->HasSwitch(switches::kDisableGLMultisampling))
466 command_line->AppendSwitch(switches::kDisableGLMultisampling); 607 command_line->AppendSwitch(switches::kDisableGLMultisampling);
467 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING) && 608 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING) &&
468 !command_line->HasSwitch(switches::kDisableAcceleratedCompositing)) 609 !command_line->HasSwitch(switches::kDisableAcceleratedCompositing))
469 command_line->AppendSwitch(switches::kDisableAcceleratedCompositing); 610 command_line->AppendSwitch(switches::kDisableAcceleratedCompositing);
470 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS) && 611 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS) &&
471 !command_line->HasSwitch(switches::kDisableAccelerated2dCanvas)) 612 !command_line->HasSwitch(switches::kDisableAccelerated2dCanvas))
472 command_line->AppendSwitch(switches::kDisableAccelerated2dCanvas); 613 command_line->AppendSwitch(switches::kDisableAccelerated2dCanvas);
473 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_ACCELERATED_VIDEO_DECODE) && 614 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_VIDEO_DECODE) &&
474 !command_line->HasSwitch(switches::kDisableAcceleratedVideoDecode)) 615 !command_line->HasSwitch(switches::kDisableAcceleratedVideoDecode))
475 command_line->AppendSwitch(switches::kDisableAcceleratedVideoDecode); 616 command_line->AppendSwitch(switches::kDisableAcceleratedVideoDecode);
476 if (ShouldUseSwiftShader()) 617 if (ShouldUseSwiftShader())
477 command_line->AppendSwitch(switches::kDisableFlashFullscreen3d); 618 command_line->AppendSwitch(switches::kDisableFlashFullscreen3d);
478 } 619 }
479 620
480 void GpuDataManagerImplPrivate::AppendGpuCommandLine( 621 void GpuDataManagerImplPrivate::AppendGpuCommandLine(
481 CommandLine* command_line) const { 622 CommandLine* command_line) const {
482 DCHECK(command_line); 623 DCHECK(command_line);
483 624
484 std::string use_gl = 625 std::string use_gl =
485 CommandLine::ForCurrentProcess()->GetSwitchValueASCII(switches::kUseGL); 626 CommandLine::ForCurrentProcess()->GetSwitchValueASCII(switches::kUseGL);
486 base::FilePath swiftshader_path = 627 base::FilePath swiftshader_path =
487 CommandLine::ForCurrentProcess()->GetSwitchValuePath( 628 CommandLine::ForCurrentProcess()->GetSwitchValuePath(
488 switches::kSwiftShaderPath); 629 switches::kSwiftShaderPath);
489 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_MULTISAMPLING) && 630 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_MULTISAMPLING) &&
490 !command_line->HasSwitch(switches::kDisableGLMultisampling)) 631 !command_line->HasSwitch(switches::kDisableGLMultisampling))
491 command_line->AppendSwitch(switches::kDisableGLMultisampling); 632 command_line->AppendSwitch(switches::kDisableGLMultisampling);
492 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_TEXTURE_SHARING)) 633 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_TEXTURE_SHARING))
493 command_line->AppendSwitch(switches::kDisableImageTransportSurface); 634 command_line->AppendSwitch(switches::kDisableImageTransportSurface);
494 635
495 if (use_swiftshader_) { 636 if (use_swiftshader_) {
496 command_line->AppendSwitchASCII(switches::kUseGL, "swiftshader"); 637 command_line->AppendSwitchASCII(switches::kUseGL, "swiftshader");
497 if (swiftshader_path.empty()) 638 if (swiftshader_path.empty())
498 swiftshader_path = swiftshader_path_; 639 swiftshader_path = swiftshader_path_;
499 } else if ((IsFeatureBlacklisted(GPU_FEATURE_TYPE_WEBGL) || 640 } else if ((IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL) ||
500 IsFeatureBlacklisted(GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING) || 641 IsFeatureBlacklisted(
501 IsFeatureBlacklisted(GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)) && 642 gpu::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING) ||
643 IsFeatureBlacklisted(
644 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)) &&
502 (use_gl == "any")) { 645 (use_gl == "any")) {
503 command_line->AppendSwitchASCII( 646 command_line->AppendSwitchASCII(
504 switches::kUseGL, gfx::kGLImplementationOSMesaName); 647 switches::kUseGL, gfx::kGLImplementationOSMesaName);
505 } else if (!use_gl.empty()) { 648 } else if (!use_gl.empty()) {
506 command_line->AppendSwitchASCII(switches::kUseGL, use_gl); 649 command_line->AppendSwitchASCII(switches::kUseGL, use_gl);
507 } 650 }
508 if (ui::GpuSwitchingManager::GetInstance()->SupportsDualGpus()) { 651 if (ui::GpuSwitchingManager::GetInstance()->SupportsDualGpus()) {
509 command_line->AppendSwitchASCII(switches::kSupportsDualGpus, "true"); 652 command_line->AppendSwitchASCII(switches::kSupportsDualGpus, "true");
510 switch (gpu_switching_) { 653 switch (gpu_switching_) {
511 case GPU_SWITCHING_OPTION_FORCE_DISCRETE: 654 case gpu::GPU_SWITCHING_OPTION_FORCE_DISCRETE:
512 command_line->AppendSwitchASCII(switches::kGpuSwitching, 655 command_line->AppendSwitchASCII(switches::kGpuSwitching,
513 switches::kGpuSwitchingOptionNameForceDiscrete); 656 switches::kGpuSwitchingOptionNameForceDiscrete);
514 break; 657 break;
515 case GPU_SWITCHING_OPTION_FORCE_INTEGRATED: 658 case gpu::GPU_SWITCHING_OPTION_FORCE_INTEGRATED:
516 command_line->AppendSwitchASCII(switches::kGpuSwitching, 659 command_line->AppendSwitchASCII(switches::kGpuSwitching,
517 switches::kGpuSwitchingOptionNameForceIntegrated); 660 switches::kGpuSwitchingOptionNameForceIntegrated);
518 break; 661 break;
519 case GPU_SWITCHING_OPTION_AUTOMATIC: 662 case gpu::GPU_SWITCHING_OPTION_AUTOMATIC:
520 case GPU_SWITCHING_OPTION_UNKNOWN: 663 case gpu::GPU_SWITCHING_OPTION_UNKNOWN:
521 break; 664 break;
522 } 665 }
523 } else { 666 } else {
524 command_line->AppendSwitchASCII(switches::kSupportsDualGpus, "false"); 667 command_line->AppendSwitchASCII(switches::kSupportsDualGpus, "false");
525 } 668 }
526 669
527 if (!swiftshader_path.empty()) 670 if (!swiftshader_path.empty())
528 command_line->AppendSwitchPath(switches::kSwiftShaderPath, 671 command_line->AppendSwitchPath(switches::kSwiftShaderPath,
529 swiftshader_path); 672 swiftshader_path);
530 673
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 } 711 }
569 712
570 void GpuDataManagerImplPrivate::AppendPluginCommandLine( 713 void GpuDataManagerImplPrivate::AppendPluginCommandLine(
571 CommandLine* command_line) const { 714 CommandLine* command_line) const {
572 DCHECK(command_line); 715 DCHECK(command_line);
573 716
574 #if defined(OS_MACOSX) 717 #if defined(OS_MACOSX)
575 // TODO(jbauman): Add proper blacklist support for core animation plugins so 718 // TODO(jbauman): Add proper blacklist support for core animation plugins so
576 // special-casing this video card won't be necessary. See 719 // special-casing this video card won't be necessary. See
577 // http://crbug.com/134015 720 // http://crbug.com/134015
578 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING) || 721 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING) ||
579 CommandLine::ForCurrentProcess()->HasSwitch( 722 CommandLine::ForCurrentProcess()->HasSwitch(
580 switches::kDisableAcceleratedCompositing)) { 723 switches::kDisableAcceleratedCompositing)) {
581 if (!command_line->HasSwitch( 724 if (!command_line->HasSwitch(
582 switches::kDisableCoreAnimationPlugins)) 725 switches::kDisableCoreAnimationPlugins))
583 command_line->AppendSwitch( 726 command_line->AppendSwitch(
584 switches::kDisableCoreAnimationPlugins); 727 switches::kDisableCoreAnimationPlugins);
585 } 728 }
586 #endif 729 #endif
587 } 730 }
588 731
589 void GpuDataManagerImplPrivate::UpdateRendererWebPrefs( 732 void GpuDataManagerImplPrivate::UpdateRendererWebPrefs(
590 WebPreferences* prefs) const { 733 WebPreferences* prefs) const {
591 DCHECK(prefs); 734 DCHECK(prefs);
592 735
593 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING)) 736 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING))
594 prefs->accelerated_compositing_enabled = false; 737 prefs->accelerated_compositing_enabled = false;
595 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_WEBGL)) 738 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL))
596 prefs->experimental_webgl_enabled = false; 739 prefs->experimental_webgl_enabled = false;
597 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_FLASH3D)) 740 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_FLASH3D))
598 prefs->flash_3d_enabled = false; 741 prefs->flash_3d_enabled = false;
599 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_FLASH_STAGE3D)) { 742 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_FLASH_STAGE3D)) {
600 prefs->flash_stage3d_enabled = false; 743 prefs->flash_stage3d_enabled = false;
601 prefs->flash_stage3d_baseline_enabled = false; 744 prefs->flash_stage3d_baseline_enabled = false;
602 } 745 }
603 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_FLASH_STAGE3D_BASELINE)) 746 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_FLASH_STAGE3D_BASELINE))
604 prefs->flash_stage3d_baseline_enabled = false; 747 prefs->flash_stage3d_baseline_enabled = false;
605 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)) 748 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS))
606 prefs->accelerated_2d_canvas_enabled = false; 749 prefs->accelerated_2d_canvas_enabled = false;
607 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_MULTISAMPLING)) 750 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_MULTISAMPLING))
608 prefs->gl_multisampling_enabled = false; 751 prefs->gl_multisampling_enabled = false;
609 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_3D_CSS)) { 752 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_3D_CSS)) {
610 prefs->accelerated_compositing_for_3d_transforms_enabled = false; 753 prefs->accelerated_compositing_for_3d_transforms_enabled = false;
611 prefs->accelerated_compositing_for_animation_enabled = false; 754 prefs->accelerated_compositing_for_animation_enabled = false;
612 } 755 }
613 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_ACCELERATED_VIDEO)) 756 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_VIDEO))
614 prefs->accelerated_compositing_for_video_enabled = false; 757 prefs->accelerated_compositing_for_video_enabled = false;
615 758
616 // Accelerated video and animation are slower than regular when using 759 // Accelerated video and animation are slower than regular when using
617 // SwiftShader. 3D CSS may also be too slow to be worthwhile. 760 // SwiftShader. 3D CSS may also be too slow to be worthwhile.
618 if (ShouldUseSwiftShader()) { 761 if (ShouldUseSwiftShader()) {
619 prefs->accelerated_compositing_for_video_enabled = false; 762 prefs->accelerated_compositing_for_video_enabled = false;
620 prefs->accelerated_compositing_for_animation_enabled = false; 763 prefs->accelerated_compositing_for_animation_enabled = false;
621 prefs->accelerated_compositing_for_3d_transforms_enabled = false; 764 prefs->accelerated_compositing_for_3d_transforms_enabled = false;
622 prefs->accelerated_compositing_for_plugins_enabled = false; 765 prefs->accelerated_compositing_for_plugins_enabled = false;
623 } 766 }
624 } 767 }
625 768
626 GpuSwitchingOption GpuDataManagerImplPrivate::GetGpuSwitchingOption() const { 769 gpu::GpuSwitchingOption
770 GpuDataManagerImplPrivate::GetGpuSwitchingOption() const {
627 if (!ui::GpuSwitchingManager::GetInstance()->SupportsDualGpus()) 771 if (!ui::GpuSwitchingManager::GetInstance()->SupportsDualGpus())
628 return GPU_SWITCHING_OPTION_UNKNOWN; 772 return gpu::GPU_SWITCHING_OPTION_UNKNOWN;
629 return gpu_switching_; 773 return gpu_switching_;
630 } 774 }
631 775
632 void GpuDataManagerImplPrivate::DisableHardwareAcceleration() { 776 void GpuDataManagerImplPrivate::DisableHardwareAcceleration() {
633 card_blacklisted_ = true; 777 card_blacklisted_ = true;
634 778
635 for (int i = 0; i < NUMBER_OF_GPU_FEATURE_TYPES; ++i) 779 for (int i = 0; i < gpu::NUMBER_OF_GPU_FEATURE_TYPES; ++i)
636 blacklisted_features_.insert(i); 780 blacklisted_features_.insert(i);
637 781
638 EnableSwiftShaderIfNecessary(); 782 EnableSwiftShaderIfNecessary();
639 NotifyGpuInfoUpdate(); 783 NotifyGpuInfoUpdate();
640 } 784 }
641 785
642 std::string GpuDataManagerImplPrivate::GetBlacklistVersion() const { 786 std::string GpuDataManagerImplPrivate::GetBlacklistVersion() const {
643 if (gpu_blacklist_) 787 if (gpu_blacklist_)
644 return gpu_blacklist_->version(); 788 return gpu_blacklist_->version();
645 return "0"; 789 return "0";
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 if (base::win::GetVersion() < base::win::VERSION_VISTA) 841 if (base::win::GetVersion() < base::win::VERSION_VISTA)
698 return false; 842 return false;
699 843
700 if (gpu_info_.amd_switchable) 844 if (gpu_info_.amd_switchable)
701 return false; 845 return false;
702 if (use_swiftshader_) 846 if (use_swiftshader_)
703 return false; 847 return false;
704 CommandLine* command_line = CommandLine::ForCurrentProcess(); 848 CommandLine* command_line = CommandLine::ForCurrentProcess();
705 if (command_line->HasSwitch(switches::kDisableImageTransportSurface)) 849 if (command_line->HasSwitch(switches::kDisableImageTransportSurface))
706 return false; 850 return false;
707 return !IsFeatureBlacklisted(GPU_FEATURE_TYPE_TEXTURE_SHARING); 851 return !IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_TEXTURE_SHARING);
708 } 852 }
709 #endif 853 #endif
710 854
711 void GpuDataManagerImplPrivate::BlockDomainFrom3DAPIs( 855 void GpuDataManagerImplPrivate::BlockDomainFrom3DAPIs(
712 const GURL& url, GpuDataManagerImpl::DomainGuilt guilt) { 856 const GURL& url, GpuDataManagerImpl::DomainGuilt guilt) {
713 BlockDomainFrom3DAPIsAtTime(url, guilt, base::Time::Now()); 857 BlockDomainFrom3DAPIsAtTime(url, guilt, base::Time::Now());
714 } 858 }
715 859
716 bool GpuDataManagerImplPrivate::Are3DAPIsBlocked(const GURL& url, 860 bool GpuDataManagerImplPrivate::Are3DAPIsBlocked(const GURL& url,
717 int render_process_id, 861 int render_process_id,
(...skipping 20 matching lines...) Expand all
738 882
739 // static 883 // static
740 GpuDataManagerImplPrivate* GpuDataManagerImplPrivate::Create( 884 GpuDataManagerImplPrivate* GpuDataManagerImplPrivate::Create(
741 GpuDataManagerImpl* owner) { 885 GpuDataManagerImpl* owner) {
742 return new GpuDataManagerImplPrivate(owner); 886 return new GpuDataManagerImplPrivate(owner);
743 } 887 }
744 888
745 GpuDataManagerImplPrivate::GpuDataManagerImplPrivate( 889 GpuDataManagerImplPrivate::GpuDataManagerImplPrivate(
746 GpuDataManagerImpl* owner) 890 GpuDataManagerImpl* owner)
747 : complete_gpu_info_already_requested_(false), 891 : complete_gpu_info_already_requested_(false),
748 gpu_switching_(GPU_SWITCHING_OPTION_AUTOMATIC), 892 gpu_switching_(gpu::GPU_SWITCHING_OPTION_AUTOMATIC),
749 observer_list_(new GpuDataManagerObserverList), 893 observer_list_(new GpuDataManagerObserverList),
750 use_swiftshader_(false), 894 use_swiftshader_(false),
751 card_blacklisted_(false), 895 card_blacklisted_(false),
752 update_histograms_(true), 896 update_histograms_(true),
753 window_count_(0), 897 window_count_(0),
754 domain_blocking_enabled_(true), 898 domain_blocking_enabled_(true),
755 owner_(owner) { 899 owner_(owner) {
756 DCHECK(owner_); 900 DCHECK(owner_);
757 CommandLine* command_line = CommandLine::ForCurrentProcess(); 901 CommandLine* command_line = CommandLine::ForCurrentProcess();
758 if (command_line->HasSwitch(switches::kDisableAcceleratedCompositing)) { 902 if (command_line->HasSwitch(switches::kDisableAcceleratedCompositing)) {
759 command_line->AppendSwitch(switches::kDisableAccelerated2dCanvas); 903 command_line->AppendSwitch(switches::kDisableAccelerated2dCanvas);
760 command_line->AppendSwitch(switches::kDisableAcceleratedLayers); 904 command_line->AppendSwitch(switches::kDisableAcceleratedLayers);
761 } 905 }
762 if (command_line->HasSwitch(switches::kDisableGpu)) 906 if (command_line->HasSwitch(switches::kDisableGpu))
763 DisableHardwareAcceleration(); 907 DisableHardwareAcceleration();
764 if (command_line->HasSwitch(switches::kGpuSwitching)) { 908 if (command_line->HasSwitch(switches::kGpuSwitching)) {
765 std::string option_string = command_line->GetSwitchValueASCII( 909 std::string option_string = command_line->GetSwitchValueASCII(
766 switches::kGpuSwitching); 910 switches::kGpuSwitching);
767 GpuSwitchingOption option = StringToGpuSwitchingOption(option_string); 911 gpu::GpuSwitchingOption option =
768 if (option != GPU_SWITCHING_OPTION_UNKNOWN) 912 gpu::StringToGpuSwitchingOption(option_string);
913 if (option != gpu::GPU_SWITCHING_OPTION_UNKNOWN)
769 gpu_switching_ = option; 914 gpu_switching_ = option;
770 } 915 }
771 916
772 #if defined(OS_MACOSX) 917 #if defined(OS_MACOSX)
773 CGDisplayRegisterReconfigurationCallback(DisplayReconfigCallback, owner_); 918 CGDisplayRegisterReconfigurationCallback(DisplayReconfigCallback, owner_);
774 #endif // OS_MACOSX 919 #endif // OS_MACOSX
775 } 920 }
776 921
777 GpuDataManagerImplPrivate::~GpuDataManagerImplPrivate() { 922 GpuDataManagerImplPrivate::~GpuDataManagerImplPrivate() {
778 #if defined(OS_MACOSX) 923 #if defined(OS_MACOSX)
779 CGDisplayRemoveReconfigurationCallback(DisplayReconfigCallback, owner_); 924 CGDisplayRemoveReconfigurationCallback(DisplayReconfigCallback, owner_);
780 #endif 925 #endif
781 } 926 }
782 927
783 void GpuDataManagerImplPrivate::InitializeImpl( 928 void GpuDataManagerImplPrivate::InitializeImpl(
784 const std::string& gpu_blacklist_json, 929 const std::string& gpu_blacklist_json,
785 const std::string& gpu_switching_list_json, 930 const std::string& gpu_switching_list_json,
786 const std::string& gpu_driver_bug_list_json, 931 const std::string& gpu_driver_bug_list_json,
787 const GPUInfo& gpu_info) { 932 const gpu::GPUInfo& gpu_info) {
788 std::string browser_version_string = ProcessVersionString( 933 std::string browser_version_string = ProcessVersionString(
789 GetContentClient()->GetProduct()); 934 GetContentClient()->GetProduct());
790 CHECK(!browser_version_string.empty()); 935 CHECK(!browser_version_string.empty());
791 936
792 if (!gpu_blacklist_json.empty()) { 937 if (!gpu_blacklist_json.empty()) {
793 gpu_blacklist_.reset(GpuBlacklist::Create()); 938 gpu_blacklist_.reset(gpu::GpuBlacklist::Create());
794 gpu_blacklist_->LoadList( 939 gpu_blacklist_->LoadList(
795 browser_version_string, gpu_blacklist_json, 940 browser_version_string, gpu_blacklist_json,
796 GpuControlList::kCurrentOsOnly); 941 gpu::GpuControlList::kCurrentOsOnly);
797 } 942 }
798 if (!gpu_switching_list_json.empty()) { 943 if (!gpu_switching_list_json.empty()) {
799 gpu_switching_list_.reset(GpuSwitchingList::Create()); 944 gpu_switching_list_.reset(gpu::GpuSwitchingList::Create());
800 gpu_switching_list_->LoadList( 945 gpu_switching_list_->LoadList(
801 browser_version_string, gpu_switching_list_json, 946 browser_version_string, gpu_switching_list_json,
802 GpuControlList::kCurrentOsOnly); 947 gpu::GpuControlList::kCurrentOsOnly);
803 } 948 }
804 if (!gpu_driver_bug_list_json.empty()) { 949 if (!gpu_driver_bug_list_json.empty()) {
805 gpu_driver_bug_list_.reset(GpuDriverBugList::Create()); 950 gpu_driver_bug_list_.reset(gpu::GpuDriverBugList::Create());
806 gpu_driver_bug_list_->LoadList( 951 gpu_driver_bug_list_->LoadList(
807 browser_version_string, gpu_driver_bug_list_json, 952 browser_version_string, gpu_driver_bug_list_json,
808 GpuControlList::kCurrentOsOnly); 953 gpu::GpuControlList::kCurrentOsOnly);
809 } 954 }
810 955
811 gpu_info_ = gpu_info; 956 gpu_info_ = gpu_info;
812 UpdateGpuInfo(gpu_info); 957 UpdateGpuInfo(gpu_info);
813 UpdateGpuSwitchingManager(gpu_info); 958 UpdateGpuSwitchingManager(gpu_info);
814 UpdatePreliminaryBlacklistedFeatures(); 959 UpdatePreliminaryBlacklistedFeatures();
815 960
816 CommandLine* command_line = CommandLine::ForCurrentProcess(); 961 CommandLine* command_line = CommandLine::ForCurrentProcess();
817 // We pass down the list to GPU command buffer through commandline 962 // We pass down the list to GPU command buffer through commandline
818 // switches at GPU process launch. However, in situations where we don't 963 // switches at GPU process launch. However, in situations where we don't
(...skipping 12 matching lines...) Expand all
831 976
832 void GpuDataManagerImplPrivate::UpdateBlacklistedFeatures( 977 void GpuDataManagerImplPrivate::UpdateBlacklistedFeatures(
833 const std::set<int>& features) { 978 const std::set<int>& features) {
834 CommandLine* command_line = CommandLine::ForCurrentProcess(); 979 CommandLine* command_line = CommandLine::ForCurrentProcess();
835 blacklisted_features_ = features; 980 blacklisted_features_ = features;
836 981
837 // Force disable using the GPU for these features, even if they would 982 // Force disable using the GPU for these features, even if they would
838 // otherwise be allowed. 983 // otherwise be allowed.
839 if (card_blacklisted_ || 984 if (card_blacklisted_ ||
840 command_line->HasSwitch(switches::kBlacklistAcceleratedCompositing)) { 985 command_line->HasSwitch(switches::kBlacklistAcceleratedCompositing)) {
841 blacklisted_features_.insert(GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING); 986 blacklisted_features_.insert(
987 gpu::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING);
842 } 988 }
843 if (card_blacklisted_ || 989 if (card_blacklisted_ ||
844 command_line->HasSwitch(switches::kBlacklistWebGL)) { 990 command_line->HasSwitch(switches::kBlacklistWebGL)) {
845 blacklisted_features_.insert(GPU_FEATURE_TYPE_WEBGL); 991 blacklisted_features_.insert(gpu::GPU_FEATURE_TYPE_WEBGL);
846 } 992 }
847 993
848 EnableSwiftShaderIfNecessary(); 994 EnableSwiftShaderIfNecessary();
849 } 995 }
850 996
851 void GpuDataManagerImplPrivate::UpdatePreliminaryBlacklistedFeatures() { 997 void GpuDataManagerImplPrivate::UpdatePreliminaryBlacklistedFeatures() {
852 preliminary_blacklisted_features_ = blacklisted_features_; 998 preliminary_blacklisted_features_ = blacklisted_features_;
853 } 999 }
854 1000
855 void GpuDataManagerImplPrivate::UpdateGpuSwitchingManager( 1001 void GpuDataManagerImplPrivate::UpdateGpuSwitchingManager(
856 const GPUInfo& gpu_info) { 1002 const gpu::GPUInfo& gpu_info) {
857 ui::GpuSwitchingManager::GetInstance()->SetGpuCount( 1003 ui::GpuSwitchingManager::GetInstance()->SetGpuCount(
858 gpu_info.secondary_gpus.size() + 1); 1004 gpu_info.secondary_gpus.size() + 1);
859 1005
860 if (ui::GpuSwitchingManager::GetInstance()->SupportsDualGpus()) { 1006 if (ui::GpuSwitchingManager::GetInstance()->SupportsDualGpus()) {
861 switch (gpu_switching_) { 1007 switch (gpu_switching_) {
862 case GPU_SWITCHING_OPTION_FORCE_DISCRETE: 1008 case gpu::GPU_SWITCHING_OPTION_FORCE_DISCRETE:
863 ui::GpuSwitchingManager::GetInstance()->ForceUseOfDiscreteGpu(); 1009 ui::GpuSwitchingManager::GetInstance()->ForceUseOfDiscreteGpu();
864 break; 1010 break;
865 case GPU_SWITCHING_OPTION_FORCE_INTEGRATED: 1011 case gpu::GPU_SWITCHING_OPTION_FORCE_INTEGRATED:
866 ui::GpuSwitchingManager::GetInstance()->ForceUseOfIntegratedGpu(); 1012 ui::GpuSwitchingManager::GetInstance()->ForceUseOfIntegratedGpu();
867 break; 1013 break;
868 case GPU_SWITCHING_OPTION_AUTOMATIC: 1014 case gpu::GPU_SWITCHING_OPTION_AUTOMATIC:
869 case GPU_SWITCHING_OPTION_UNKNOWN: 1015 case gpu::GPU_SWITCHING_OPTION_UNKNOWN:
870 break; 1016 break;
871 } 1017 }
872 } 1018 }
873 } 1019 }
874 1020
875 void GpuDataManagerImplPrivate::NotifyGpuInfoUpdate() { 1021 void GpuDataManagerImplPrivate::NotifyGpuInfoUpdate() {
876 observer_list_->Notify(&GpuDataManagerObserver::OnGpuInfoUpdate); 1022 observer_list_->Notify(&GpuDataManagerObserver::OnGpuInfoUpdate);
877 } 1023 }
878 1024
879 void GpuDataManagerImplPrivate::EnableSwiftShaderIfNecessary() { 1025 void GpuDataManagerImplPrivate::EnableSwiftShaderIfNecessary() {
880 if (!GpuAccessAllowed(NULL) || 1026 if (!GpuAccessAllowed(NULL) ||
881 blacklisted_features_.count(GPU_FEATURE_TYPE_WEBGL)) { 1027 blacklisted_features_.count(gpu::GPU_FEATURE_TYPE_WEBGL)) {
882 if (!swiftshader_path_.empty() && 1028 if (!swiftshader_path_.empty() &&
883 !CommandLine::ForCurrentProcess()->HasSwitch( 1029 !CommandLine::ForCurrentProcess()->HasSwitch(
884 switches::kDisableSoftwareRasterizer)) 1030 switches::kDisableSoftwareRasterizer))
885 use_swiftshader_ = true; 1031 use_swiftshader_ = true;
886 } 1032 }
887 } 1033 }
888 1034
889 std::string GpuDataManagerImplPrivate::GetDomainFromURL( 1035 std::string GpuDataManagerImplPrivate::GetDomainFromURL(
890 const GURL& url) const { 1036 const GURL& url) const {
891 // For the moment, we just use the host, or its IP address, as the 1037 // For the moment, we just use the host, or its IP address, as the
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
986 int render_process_id, 1132 int render_process_id,
987 int render_view_id, 1133 int render_view_id,
988 ThreeDAPIType requester) { 1134 ThreeDAPIType requester) {
989 GpuDataManagerImpl::UnlockedSession session(owner_); 1135 GpuDataManagerImpl::UnlockedSession session(owner_);
990 observer_list_->Notify(&GpuDataManagerObserver::DidBlock3DAPIs, 1136 observer_list_->Notify(&GpuDataManagerObserver::DidBlock3DAPIs,
991 url, render_process_id, render_view_id, requester); 1137 url, render_process_id, render_view_id, requester);
992 } 1138 }
993 1139
994 } // namespace content 1140 } // namespace content
995 1141
OLDNEW
« no previous file with comments | « content/browser/gpu/gpu_data_manager_impl_private.h ('k') | content/browser/gpu/gpu_driver_bug_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698