| 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 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 return "SCANOUT"; | 295 return "SCANOUT"; |
| 296 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE: | 296 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE: |
| 297 return "GPU_READ_CPU_READ_WRITE"; | 297 return "GPU_READ_CPU_READ_WRITE"; |
| 298 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT: | 298 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT: |
| 299 return "GPU_READ_CPU_READ_WRITE_PERSISTENT"; | 299 return "GPU_READ_CPU_READ_WRITE_PERSISTENT"; |
| 300 } | 300 } |
| 301 NOTREACHED(); | 301 NOTREACHED(); |
| 302 return nullptr; | 302 return nullptr; |
| 303 } | 303 } |
| 304 | 304 |
| 305 base::DictionaryValue* GpuMemoryBufferInfoAsDictionaryValue() { | 305 base::ListValue* CompositorInfo() { |
| 306 base::ListValue* compositor_info = new base::ListValue(); |
| 307 |
| 308 compositor_info->Append(NewDescriptionValuePair( |
| 309 "Tile Update Mode", |
| 310 IsZeroCopyUploadEnabled() ? "Zero-copy" : "One-copy")); |
| 311 |
| 312 compositor_info->Append(NewDescriptionValuePair( |
| 313 "Partial Raster", IsPartialRasterEnabled() ? "Enabled" : "Disabled")); |
| 314 return compositor_info; |
| 315 } |
| 316 |
| 317 base::ListValue* GpuMemoryBufferInfo() { |
| 306 base::ListValue* gpu_memory_buffer_info = new base::ListValue(); | 318 base::ListValue* gpu_memory_buffer_info = new base::ListValue(); |
| 307 | 319 |
| 308 BrowserGpuMemoryBufferManager* gpu_memory_buffer_manager = | 320 BrowserGpuMemoryBufferManager* gpu_memory_buffer_manager = |
| 309 BrowserGpuMemoryBufferManager::current(); | 321 BrowserGpuMemoryBufferManager::current(); |
| 310 | 322 |
| 311 for (size_t format = 0; | 323 for (size_t format = 0; |
| 312 format < static_cast<size_t>(gfx::BufferFormat::LAST) + 1; format++) { | 324 format < static_cast<size_t>(gfx::BufferFormat::LAST) + 1; format++) { |
| 313 std::string native_usage_support; | 325 std::string native_usage_support; |
| 314 for (size_t usage = 0; | 326 for (size_t usage = 0; |
| 315 usage < static_cast<size_t>(gfx::BufferUsage::LAST) + 1; usage++) { | 327 usage < static_cast<size_t>(gfx::BufferUsage::LAST) + 1; usage++) { |
| 316 if (gpu_memory_buffer_manager->IsNativeGpuMemoryBufferConfiguration( | 328 if (gpu_memory_buffer_manager->IsNativeGpuMemoryBufferConfiguration( |
| 317 static_cast<gfx::BufferFormat>(format), | 329 static_cast<gfx::BufferFormat>(format), |
| 318 static_cast<gfx::BufferUsage>(usage))) | 330 static_cast<gfx::BufferUsage>(usage))) |
| 319 native_usage_support = base::StringPrintf( | 331 native_usage_support = base::StringPrintf( |
| 320 "%s%s %s", native_usage_support.c_str(), | 332 "%s%s %s", native_usage_support.c_str(), |
| 321 native_usage_support.empty() ? "" : ",", | 333 native_usage_support.empty() ? "" : ",", |
| 322 BufferUsageToString(static_cast<gfx::BufferUsage>(usage))); | 334 BufferUsageToString(static_cast<gfx::BufferUsage>(usage))); |
| 323 } | 335 } |
| 324 if (native_usage_support.empty()) | 336 if (native_usage_support.empty()) |
| 325 native_usage_support = base::StringPrintf("Software only"); | 337 native_usage_support = base::StringPrintf("Software only"); |
| 326 | 338 |
| 327 gpu_memory_buffer_info->Append(NewDescriptionValuePair( | 339 gpu_memory_buffer_info->Append(NewDescriptionValuePair( |
| 328 BufferFormatToString(static_cast<gfx::BufferFormat>(format)), | 340 BufferFormatToString(static_cast<gfx::BufferFormat>(format)), |
| 329 native_usage_support)); | 341 native_usage_support)); |
| 330 } | 342 } |
| 331 | 343 return gpu_memory_buffer_info; |
| 332 base::DictionaryValue* info = new base::DictionaryValue(); | |
| 333 info->Set("gpu_memory_buffer_info", gpu_memory_buffer_info); | |
| 334 | |
| 335 return info; | |
| 336 } | 344 } |
| 337 | 345 |
| 338 // This class receives javascript messages from the renderer. | 346 // This class receives javascript messages from the renderer. |
| 339 // Note that the WebUI infrastructure runs on the UI thread, therefore all of | 347 // Note that the WebUI infrastructure runs on the UI thread, therefore all of |
| 340 // this class's methods are expected to run on the UI thread. | 348 // this class's methods are expected to run on the UI thread. |
| 341 class GpuMessageHandler | 349 class GpuMessageHandler |
| 342 : public WebUIMessageHandler, | 350 : public WebUIMessageHandler, |
| 343 public base::SupportsWeakPtr<GpuMessageHandler>, | 351 public base::SupportsWeakPtr<GpuMessageHandler>, |
| 344 public GpuDataManagerObserver, | 352 public GpuDataManagerObserver, |
| 345 public ui::GpuSwitchingObserver { | 353 public ui::GpuSwitchingObserver { |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 | 509 |
| 502 // Add in blacklisting features | 510 // Add in blacklisting features |
| 503 base::DictionaryValue* feature_status = new base::DictionaryValue; | 511 base::DictionaryValue* feature_status = new base::DictionaryValue; |
| 504 feature_status->Set("featureStatus", GetFeatureStatus()); | 512 feature_status->Set("featureStatus", GetFeatureStatus()); |
| 505 feature_status->Set("problems", GetProblems()); | 513 feature_status->Set("problems", GetProblems()); |
| 506 base::ListValue* workarounds = new base::ListValue(); | 514 base::ListValue* workarounds = new base::ListValue(); |
| 507 for (const std::string& workaround : GetDriverBugWorkarounds()) | 515 for (const std::string& workaround : GetDriverBugWorkarounds()) |
| 508 workarounds->AppendString(workaround); | 516 workarounds->AppendString(workaround); |
| 509 feature_status->Set("workarounds", workarounds); | 517 feature_status->Set("workarounds", workarounds); |
| 510 gpu_info_val->Set("featureStatus", feature_status); | 518 gpu_info_val->Set("featureStatus", feature_status); |
| 519 gpu_info_val->Set("compositorInfo", CompositorInfo()); |
| 520 gpu_info_val->Set("gpuMemoryBufferInfo", GpuMemoryBufferInfo()); |
| 511 | 521 |
| 512 // Send GPU Info to javascript. | 522 // Send GPU Info to javascript. |
| 513 web_ui()->CallJavascriptFunction("browserBridge.onGpuInfoUpdate", | 523 web_ui()->CallJavascriptFunction("browserBridge.onGpuInfoUpdate", |
| 514 *(gpu_info_val.get())); | 524 *(gpu_info_val.get())); |
| 515 | |
| 516 // Get GpuMemoryBuffer Info. | |
| 517 scoped_ptr<base::DictionaryValue> gpu_memory_buffer_info_val( | |
| 518 GpuMemoryBufferInfoAsDictionaryValue()); | |
| 519 | |
| 520 // Send GpuMemoryBuffer Info to javascript. | |
| 521 web_ui()->CallJavascriptFunction("browserBridge.onGpuMemoryBufferInfoUpdate", | |
| 522 *(gpu_memory_buffer_info_val.get())); | |
| 523 } | 525 } |
| 524 | 526 |
| 525 void GpuMessageHandler::OnGpuSwitched() { | 527 void GpuMessageHandler::OnGpuSwitched() { |
| 526 GpuDataManagerImpl::GetInstance()->RequestCompleteGpuInfoIfNeeded(); | 528 GpuDataManagerImpl::GetInstance()->RequestCompleteGpuInfoIfNeeded(); |
| 527 } | 529 } |
| 528 | 530 |
| 529 } // namespace | 531 } // namespace |
| 530 | 532 |
| 531 | 533 |
| 532 //////////////////////////////////////////////////////////////////////////////// | 534 //////////////////////////////////////////////////////////////////////////////// |
| 533 // | 535 // |
| 534 // GpuInternalsUI | 536 // GpuInternalsUI |
| 535 // | 537 // |
| 536 //////////////////////////////////////////////////////////////////////////////// | 538 //////////////////////////////////////////////////////////////////////////////// |
| 537 | 539 |
| 538 GpuInternalsUI::GpuInternalsUI(WebUI* web_ui) | 540 GpuInternalsUI::GpuInternalsUI(WebUI* web_ui) |
| 539 : WebUIController(web_ui) { | 541 : WebUIController(web_ui) { |
| 540 web_ui->AddMessageHandler(new GpuMessageHandler()); | 542 web_ui->AddMessageHandler(new GpuMessageHandler()); |
| 541 | 543 |
| 542 // Set up the chrome://gpu/ source. | 544 // Set up the chrome://gpu/ source. |
| 543 BrowserContext* browser_context = | 545 BrowserContext* browser_context = |
| 544 web_ui->GetWebContents()->GetBrowserContext(); | 546 web_ui->GetWebContents()->GetBrowserContext(); |
| 545 WebUIDataSource::Add(browser_context, CreateGpuHTMLSource()); | 547 WebUIDataSource::Add(browser_context, CreateGpuHTMLSource()); |
| 546 } | 548 } |
| 547 | 549 |
| 548 } // namespace content | 550 } // namespace content |
| OLD | NEW |