| OLD | NEW |
| 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_internals_ui.h" | 5 #include "content/browser/gpu/gpu_internals_ui.h" |
| 6 | 6 |
| 7 #if defined(OS_LINUX) && defined(USE_X11) | 7 #if defined(OS_LINUX) && defined(USE_X11) |
| 8 #include <X11/Xlib.h> | 8 #include <X11/Xlib.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/bind_helpers.h" | 14 #include "base/bind_helpers.h" |
| 15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 16 #include "base/environment.h" | 16 #include "base/environment.h" |
| 17 #include "base/i18n/time_formatting.h" | 17 #include "base/i18n/time_formatting.h" |
| 18 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
| 19 #include "base/strings/stringprintf.h" | 19 #include "base/strings/stringprintf.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 "content/browser/gpu/browser_gpu_memory_buffer_manager.h" |
| 22 #include "content/browser/gpu/compositor_util.h" | 23 #include "content/browser/gpu/compositor_util.h" |
| 23 #include "content/browser/gpu/gpu_data_manager_impl.h" | 24 #include "content/browser/gpu/gpu_data_manager_impl.h" |
| 24 #include "content/grit/content_resources.h" | 25 #include "content/grit/content_resources.h" |
| 25 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
| 26 #include "content/public/browser/gpu_data_manager_observer.h" | 27 #include "content/public/browser/gpu_data_manager_observer.h" |
| 27 #include "content/public/browser/web_contents.h" | 28 #include "content/public/browser/web_contents.h" |
| 28 #include "content/public/browser/web_ui.h" | 29 #include "content/public/browser/web_ui.h" |
| 29 #include "content/public/browser/web_ui_data_source.h" | 30 #include "content/public/browser/web_ui_data_source.h" |
| 30 #include "content/public/browser/web_ui_message_handler.h" | 31 #include "content/public/browser/web_ui_message_handler.h" |
| 31 #include "content/public/common/content_client.h" | 32 #include "content/public/common/content_client.h" |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 #if defined(OS_WIN) | 226 #if defined(OS_WIN) |
| 226 scoped_ptr<base::Value> dx_info = base::Value::CreateNullValue(); | 227 scoped_ptr<base::Value> dx_info = base::Value::CreateNullValue(); |
| 227 if (gpu_info.dx_diagnostics.children.size()) | 228 if (gpu_info.dx_diagnostics.children.size()) |
| 228 dx_info.reset(DxDiagNodeToList(gpu_info.dx_diagnostics)); | 229 dx_info.reset(DxDiagNodeToList(gpu_info.dx_diagnostics)); |
| 229 info->Set("diagnostics", dx_info.Pass()); | 230 info->Set("diagnostics", dx_info.Pass()); |
| 230 #endif | 231 #endif |
| 231 | 232 |
| 232 return info; | 233 return info; |
| 233 } | 234 } |
| 234 | 235 |
| 236 base::DictionaryValue* GmbInfoAsDictionaryValue() { |
| 237 base::ListValue* gmb_info = new base::ListValue(); |
| 238 gmb_info->Append(NewDescriptionValuePair("Native Formats", "Usage")); |
| 239 |
| 240 BrowserGpuMemoryBufferManager* gmb_manager = |
| 241 BrowserGpuMemoryBufferManager::current(); |
| 242 GpuMemoryBufferConfigurationList list = |
| 243 gmb_manager->GetNativeGpuMemoryBufferEnabledAndSupported(); |
| 244 |
| 245 GpuMemoryBufferConfigurationList::iterator it; |
| 246 for (it = list.begin(); it != list.end(); it++) |
| 247 gmb_info->Append(NewDescriptionValuePair( |
| 248 BufferFormatToString(it->first), BufferUsageToString(it->second))); |
| 249 |
| 250 base::DictionaryValue* info = new base::DictionaryValue(); |
| 251 info->Set("gmb_info", gmb_info); |
| 252 |
| 253 return info; |
| 254 } |
| 255 |
| 235 // This class receives javascript messages from the renderer. | 256 // This class receives javascript messages from the renderer. |
| 236 // Note that the WebUI infrastructure runs on the UI thread, therefore all of | 257 // Note that the WebUI infrastructure runs on the UI thread, therefore all of |
| 237 // this class's methods are expected to run on the UI thread. | 258 // this class's methods are expected to run on the UI thread. |
| 238 class GpuMessageHandler | 259 class GpuMessageHandler |
| 239 : public WebUIMessageHandler, | 260 : public WebUIMessageHandler, |
| 240 public base::SupportsWeakPtr<GpuMessageHandler>, | 261 public base::SupportsWeakPtr<GpuMessageHandler>, |
| 241 public GpuDataManagerObserver, | 262 public GpuDataManagerObserver, |
| 242 public ui::GpuSwitchingObserver { | 263 public ui::GpuSwitchingObserver { |
| 243 public: | 264 public: |
| 244 GpuMessageHandler(); | 265 GpuMessageHandler(); |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 feature_status->Set("problems", GetProblems()); | 423 feature_status->Set("problems", GetProblems()); |
| 403 base::ListValue* workarounds = new base::ListValue(); | 424 base::ListValue* workarounds = new base::ListValue(); |
| 404 for (const std::string& workaround : GetDriverBugWorkarounds()) | 425 for (const std::string& workaround : GetDriverBugWorkarounds()) |
| 405 workarounds->AppendString(workaround); | 426 workarounds->AppendString(workaround); |
| 406 feature_status->Set("workarounds", workarounds); | 427 feature_status->Set("workarounds", workarounds); |
| 407 gpu_info_val->Set("featureStatus", feature_status); | 428 gpu_info_val->Set("featureStatus", feature_status); |
| 408 | 429 |
| 409 // Send GPU Info to javascript. | 430 // Send GPU Info to javascript. |
| 410 web_ui()->CallJavascriptFunction("browserBridge.onGpuInfoUpdate", | 431 web_ui()->CallJavascriptFunction("browserBridge.onGpuInfoUpdate", |
| 411 *(gpu_info_val.get())); | 432 *(gpu_info_val.get())); |
| 433 |
| 434 // Get GpuMemoryBuffer Info. |
| 435 scoped_ptr<base::DictionaryValue> gmb_info_val(GmbInfoAsDictionaryValue()); |
| 436 |
| 437 // Add in blacklisting features |
| 438 base::DictionaryValue* gmb_status = new base::DictionaryValue; |
| 439 gmb_info_val->Set("gbmStatus", gmb_status); |
| 440 |
| 441 // Send GMB Info to javascript. |
| 442 web_ui()->CallJavascriptFunction("browserBridge.onGmbInfoUpdate", |
| 443 *(gmb_info_val.get())); |
| 412 } | 444 } |
| 413 | 445 |
| 414 void GpuMessageHandler::OnGpuSwitched() { | 446 void GpuMessageHandler::OnGpuSwitched() { |
| 415 GpuDataManagerImpl::GetInstance()->RequestCompleteGpuInfoIfNeeded(); | 447 GpuDataManagerImpl::GetInstance()->RequestCompleteGpuInfoIfNeeded(); |
| 416 } | 448 } |
| 417 | 449 |
| 418 } // namespace | 450 } // namespace |
| 419 | 451 |
| 420 | 452 |
| 421 //////////////////////////////////////////////////////////////////////////////// | 453 //////////////////////////////////////////////////////////////////////////////// |
| 422 // | 454 // |
| 423 // GpuInternalsUI | 455 // GpuInternalsUI |
| 424 // | 456 // |
| 425 //////////////////////////////////////////////////////////////////////////////// | 457 //////////////////////////////////////////////////////////////////////////////// |
| 426 | 458 |
| 427 GpuInternalsUI::GpuInternalsUI(WebUI* web_ui) | 459 GpuInternalsUI::GpuInternalsUI(WebUI* web_ui) |
| 428 : WebUIController(web_ui) { | 460 : WebUIController(web_ui) { |
| 429 web_ui->AddMessageHandler(new GpuMessageHandler()); | 461 web_ui->AddMessageHandler(new GpuMessageHandler()); |
| 430 | 462 |
| 431 // Set up the chrome://gpu/ source. | 463 // Set up the chrome://gpu/ source. |
| 432 BrowserContext* browser_context = | 464 BrowserContext* browser_context = |
| 433 web_ui->GetWebContents()->GetBrowserContext(); | 465 web_ui->GetWebContents()->GetBrowserContext(); |
| 434 WebUIDataSource::Add(browser_context, CreateGpuHTMLSource()); | 466 WebUIDataSource::Add(browser_context, CreateGpuHTMLSource()); |
| 435 } | 467 } |
| 436 | 468 |
| 437 } // namespace content | 469 } // namespace content |
| OLD | NEW |