OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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.h" | 5 #include "content/browser/gpu/gpu_data_manager.h" |
6 | 6 |
7 #if defined(OS_MACOSX) | 7 #if defined(OS_MACOSX) |
8 #include <CoreGraphics/CGDisplayConfiguration.h> | 8 #include <CoreGraphics/CGDisplayConfiguration.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... |
33 << base::StringPrintf("%04x", flags); | 33 << base::StringPrintf("%04x", flags); |
34 if (flags & kCGDisplayAddFlag) { | 34 if (flags & kCGDisplayAddFlag) { |
35 GpuDataManager* manager = | 35 GpuDataManager* manager = |
36 reinterpret_cast<GpuDataManager*>(gpu_data_manager); | 36 reinterpret_cast<GpuDataManager*>(gpu_data_manager); |
37 DCHECK(manager); | 37 DCHECK(manager); |
38 manager->HandleGpuSwitch(); | 38 manager->HandleGpuSwitch(); |
39 } | 39 } |
40 } | 40 } |
41 #endif | 41 #endif |
42 | 42 |
| 43 DictionaryValue* NewDescriptionValuePair(const std::string& desc, |
| 44 const std::string& value) { |
| 45 DictionaryValue* dict = new DictionaryValue(); |
| 46 dict->SetString("description", desc); |
| 47 dict->SetString("value", value); |
| 48 return dict; |
| 49 } |
| 50 |
| 51 DictionaryValue* NewDescriptionValuePair(const std::string& desc, |
| 52 Value* value) { |
| 53 DictionaryValue* dict = new DictionaryValue(); |
| 54 dict->SetString("description", desc); |
| 55 dict->Set("value", value); |
| 56 return dict; |
| 57 } |
| 58 |
| 59 #if defined(OS_WIN) |
| 60 // Output DxDiagNode tree as nested array of {description,value} pairs |
| 61 ListValue* DxDiagNodeToList(const DxDiagNode& node) { |
| 62 ListValue* list = new ListValue(); |
| 63 for (std::map<std::string, std::string>::const_iterator it = |
| 64 node.values.begin(); |
| 65 it != node.values.end(); |
| 66 ++it) { |
| 67 list->Append(NewDescriptionValuePair(it->first, it->second)); |
| 68 } |
| 69 |
| 70 for (std::map<std::string, DxDiagNode>::const_iterator it = |
| 71 node.children.begin(); |
| 72 it != node.children.end(); |
| 73 ++it) { |
| 74 ListValue* sublist = DxDiagNodeToList(it->second); |
| 75 list->Append(NewDescriptionValuePair(it->first, sublist)); |
| 76 } |
| 77 return list; |
| 78 } |
| 79 |
| 80 #endif // OS_WIN |
| 81 |
43 } // namespace anonymous | 82 } // namespace anonymous |
44 | 83 |
45 GpuDataManager::GpuDataManager() | 84 GpuDataManager::GpuDataManager() |
46 : complete_gpu_info_already_requested_(false) { | 85 : complete_gpu_info_already_requested_(false) { |
47 // Certain tests doesn't go through the browser startup path that | 86 // Certain tests doesn't go through the browser startup path that |
48 // initializes GpuDataManager on FILE thread; therefore, it is initialized | 87 // initializes GpuDataManager on FILE thread; therefore, it is initialized |
49 // on UI thread later, and we skip the preliminary gpu info collection | 88 // on UI thread later, and we skip the preliminary gpu info collection |
50 // in such situation. | 89 // in such situation. |
51 if (!BrowserThread::CurrentlyOn(BrowserThread::FILE)) | 90 if (!BrowserThread::CurrentlyOn(BrowserThread::FILE)) |
52 return; | 91 return; |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 GPUInfo gpu_info; | 275 GPUInfo gpu_info; |
237 gpu_info_collector::CollectVideoCardInfo(&gpu_info); | 276 gpu_info_collector::CollectVideoCardInfo(&gpu_info); |
238 LOG(INFO) << "Switching to use GPU: vendor_id = 0x" | 277 LOG(INFO) << "Switching to use GPU: vendor_id = 0x" |
239 << base::StringPrintf("%04x", gpu_info.vendor_id) | 278 << base::StringPrintf("%04x", gpu_info.vendor_id) |
240 << ", device_id = 0x" | 279 << ", device_id = 0x" |
241 << base::StringPrintf("%04x", gpu_info.device_id); | 280 << base::StringPrintf("%04x", gpu_info.device_id); |
242 // TODO(zmo): update gpu_info_, re-run blacklist logic, maybe close and | 281 // TODO(zmo): update gpu_info_, re-run blacklist logic, maybe close and |
243 // relaunch GPU process. | 282 // relaunch GPU process. |
244 } | 283 } |
245 | 284 |
| 285 DictionaryValue* GpuDataManager::GpuInfoAsDictionaryValue() const { |
| 286 ListValue* basic_info = new ListValue(); |
| 287 basic_info->Append(NewDescriptionValuePair( |
| 288 "Initialization time", |
| 289 base::Int64ToString(gpu_info().initialization_time.InMilliseconds()))); |
| 290 basic_info->Append(NewDescriptionValuePair( |
| 291 "Vendor Id", base::StringPrintf("0x%04x", gpu_info().vendor_id))); |
| 292 basic_info->Append(NewDescriptionValuePair( |
| 293 "Device Id", base::StringPrintf("0x%04x", gpu_info().device_id))); |
| 294 basic_info->Append(NewDescriptionValuePair("Driver vendor", |
| 295 gpu_info().driver_vendor)); |
| 296 basic_info->Append(NewDescriptionValuePair("Driver version", |
| 297 gpu_info().driver_version)); |
| 298 basic_info->Append(NewDescriptionValuePair("Driver date", |
| 299 gpu_info().driver_date)); |
| 300 basic_info->Append(NewDescriptionValuePair("Pixel shader version", |
| 301 gpu_info().pixel_shader_version)); |
| 302 basic_info->Append(NewDescriptionValuePair("Vertex shader version", |
| 303 gpu_info().vertex_shader_version)); |
| 304 basic_info->Append(NewDescriptionValuePair("GL version", |
| 305 gpu_info().gl_version)); |
| 306 basic_info->Append(NewDescriptionValuePair("GL_VENDOR", |
| 307 gpu_info().gl_vendor)); |
| 308 basic_info->Append(NewDescriptionValuePair("GL_RENDERER", |
| 309 gpu_info().gl_renderer)); |
| 310 basic_info->Append(NewDescriptionValuePair("GL_VERSION", |
| 311 gpu_info().gl_version_string)); |
| 312 basic_info->Append(NewDescriptionValuePair("GL_EXTENSIONS", |
| 313 gpu_info().gl_extensions)); |
| 314 |
| 315 DictionaryValue* info = new DictionaryValue(); |
| 316 info->Set("basic_info", basic_info); |
| 317 |
| 318 #if defined(OS_WIN) |
| 319 Value* dx_info; |
| 320 if (gpu_info().dx_diagnostics.children.size()) |
| 321 dx_info = DxDiagNodeToList(gpu_info().dx_diagnostics); |
| 322 else |
| 323 dx_info = Value::CreateNullValue(); |
| 324 info->Set("diagnostics", dx_info); |
| 325 #endif |
| 326 |
| 327 return info; |
| 328 } |
| 329 |
246 void GpuDataManager::RunGpuInfoUpdateCallbacks() { | 330 void GpuDataManager::RunGpuInfoUpdateCallbacks() { |
247 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 331 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
248 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 332 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
249 NewRunnableMethod(this, &GpuDataManager::RunGpuInfoUpdateCallbacks)); | 333 NewRunnableMethod(this, &GpuDataManager::RunGpuInfoUpdateCallbacks)); |
250 return; | 334 return; |
251 } | 335 } |
252 | 336 |
253 std::set<Callback0::Type*>::iterator i = gpu_info_update_callbacks_.begin(); | 337 std::set<Callback0::Type*>::iterator i = gpu_info_update_callbacks_.begin(); |
254 for (; i != gpu_info_update_callbacks_.end(); ++i) { | 338 for (; i != gpu_info_update_callbacks_.end(); ++i) { |
255 (*i)->Run(); | 339 (*i)->Run(); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | 387 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
304 if (browser_command_line.HasSwitch(switches::kIgnoreGpuBlacklist) || | 388 if (browser_command_line.HasSwitch(switches::kIgnoreGpuBlacklist) || |
305 browser_command_line.GetSwitchValueASCII( | 389 browser_command_line.GetSwitchValueASCII( |
306 switches::kUseGL) == gfx::kGLImplementationOSMesaName) | 390 switches::kUseGL) == gfx::kGLImplementationOSMesaName) |
307 return NULL; | 391 return NULL; |
308 // No need to return an empty blacklist. | 392 // No need to return an empty blacklist. |
309 if (gpu_blacklist_.get() != NULL && gpu_blacklist_->max_entry_id() == 0) | 393 if (gpu_blacklist_.get() != NULL && gpu_blacklist_->max_entry_id() == 0) |
310 return NULL; | 394 return NULL; |
311 return gpu_blacklist_.get(); | 395 return gpu_blacklist_.get(); |
312 } | 396 } |
OLD | NEW |