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 <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
11 #include <utility> | 11 #include <utility> |
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/macros.h" | 18 #include "base/macros.h" |
19 #include "base/memory/ptr_util.h" | 19 #include "base/memory/ptr_util.h" |
| 20 #include "base/stl_util.h" |
20 #include "base/strings/string_number_conversions.h" | 21 #include "base/strings/string_number_conversions.h" |
21 #include "base/strings/stringize_macros.h" | 22 #include "base/strings/stringize_macros.h" |
22 #include "base/strings/stringprintf.h" | 23 #include "base/strings/stringprintf.h" |
23 #include "base/sys_info.h" | 24 #include "base/sys_info.h" |
24 #include "base/values.h" | 25 #include "base/values.h" |
25 #include "build/build_config.h" | 26 #include "build/build_config.h" |
26 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" | |
27 #include "content/browser/gpu/compositor_util.h" | 27 #include "content/browser/gpu/compositor_util.h" |
28 #include "content/browser/gpu/gpu_data_manager_impl.h" | 28 #include "content/browser/gpu/gpu_data_manager_impl.h" |
29 #include "content/grit/content_resources.h" | 29 #include "content/grit/content_resources.h" |
30 #include "content/public/browser/browser_thread.h" | 30 #include "content/public/browser/browser_thread.h" |
31 #include "content/public/browser/gpu_data_manager_observer.h" | 31 #include "content/public/browser/gpu_data_manager_observer.h" |
32 #include "content/public/browser/web_contents.h" | 32 #include "content/public/browser/web_contents.h" |
33 #include "content/public/browser/web_ui.h" | 33 #include "content/public/browser/web_ui.h" |
34 #include "content/public/browser/web_ui_data_source.h" | 34 #include "content/public/browser/web_ui_data_source.h" |
35 #include "content/public/browser/web_ui_message_handler.h" | 35 #include "content/public/browser/web_ui_message_handler.h" |
36 #include "content/public/common/content_client.h" | 36 #include "content/public/common/content_client.h" |
37 #include "content/public/common/content_switches.h" | 37 #include "content/public/common/content_switches.h" |
38 #include "content/public/common/url_constants.h" | 38 #include "content/public/common/url_constants.h" |
39 #include "gpu/config/gpu_feature_type.h" | 39 #include "gpu/config/gpu_feature_type.h" |
40 #include "gpu/config/gpu_info.h" | 40 #include "gpu/config/gpu_info.h" |
| 41 #include "gpu/ipc/host/gpu_memory_buffer_support.h" |
41 #include "skia/ext/skia_commit_hash.h" | 42 #include "skia/ext/skia_commit_hash.h" |
42 #include "third_party/angle/src/common/version.h" | 43 #include "third_party/angle/src/common/version.h" |
43 #include "third_party/skia/include/core/SkMilestone.h" | 44 #include "third_party/skia/include/core/SkMilestone.h" |
44 #include "ui/gl/gpu_switching_manager.h" | 45 #include "ui/gl/gpu_switching_manager.h" |
45 | 46 |
46 #if defined(OS_LINUX) && defined(USE_X11) | 47 #if defined(OS_LINUX) && defined(USE_X11) |
47 #include <X11/Xlib.h> | 48 #include <X11/Xlib.h> |
48 #endif | 49 #endif |
49 #if defined(OS_WIN) | 50 #if defined(OS_WIN) |
50 #include "ui/base/win/shell.h" | 51 #include "ui/base/win/shell.h" |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 IsZeroCopyUploadEnabled() ? "Zero-copy" : "One-copy")); | 328 IsZeroCopyUploadEnabled() ? "Zero-copy" : "One-copy")); |
328 | 329 |
329 compositor_info->Append(NewDescriptionValuePair( | 330 compositor_info->Append(NewDescriptionValuePair( |
330 "Partial Raster", IsPartialRasterEnabled() ? "Enabled" : "Disabled")); | 331 "Partial Raster", IsPartialRasterEnabled() ? "Enabled" : "Disabled")); |
331 return compositor_info; | 332 return compositor_info; |
332 } | 333 } |
333 | 334 |
334 std::unique_ptr<base::ListValue> GpuMemoryBufferInfo() { | 335 std::unique_ptr<base::ListValue> GpuMemoryBufferInfo() { |
335 auto gpu_memory_buffer_info = base::MakeUnique<base::ListValue>(); | 336 auto gpu_memory_buffer_info = base::MakeUnique<base::ListValue>(); |
336 | 337 |
337 BrowserGpuMemoryBufferManager* gpu_memory_buffer_manager = | 338 const auto native_configurations = |
338 BrowserGpuMemoryBufferManager::current(); | 339 gpu::GetNativeGpuMemoryBufferConfigurations(); |
339 | |
340 for (size_t format = 0; | 340 for (size_t format = 0; |
341 format < static_cast<size_t>(gfx::BufferFormat::LAST) + 1; format++) { | 341 format < static_cast<size_t>(gfx::BufferFormat::LAST) + 1; format++) { |
342 std::string native_usage_support; | 342 std::string native_usage_support; |
343 for (size_t usage = 0; | 343 for (size_t usage = 0; |
344 usage < static_cast<size_t>(gfx::BufferUsage::LAST) + 1; usage++) { | 344 usage < static_cast<size_t>(gfx::BufferUsage::LAST) + 1; usage++) { |
345 if (gpu_memory_buffer_manager->IsNativeGpuMemoryBufferConfiguration( | 345 if (base::ContainsKey( |
346 static_cast<gfx::BufferFormat>(format), | 346 native_configurations, |
347 static_cast<gfx::BufferUsage>(usage))) | 347 std::make_pair(static_cast<gfx::BufferFormat>(format), |
| 348 static_cast<gfx::BufferUsage>(usage)))) { |
348 native_usage_support = base::StringPrintf( | 349 native_usage_support = base::StringPrintf( |
349 "%s%s %s", native_usage_support.c_str(), | 350 "%s%s %s", native_usage_support.c_str(), |
350 native_usage_support.empty() ? "" : ",", | 351 native_usage_support.empty() ? "" : ",", |
351 BufferUsageToString(static_cast<gfx::BufferUsage>(usage))); | 352 BufferUsageToString(static_cast<gfx::BufferUsage>(usage))); |
| 353 } |
352 } | 354 } |
353 if (native_usage_support.empty()) | 355 if (native_usage_support.empty()) |
354 native_usage_support = base::StringPrintf("Software only"); | 356 native_usage_support = base::StringPrintf("Software only"); |
355 | 357 |
356 gpu_memory_buffer_info->Append(NewDescriptionValuePair( | 358 gpu_memory_buffer_info->Append(NewDescriptionValuePair( |
357 BufferFormatToString(static_cast<gfx::BufferFormat>(format)), | 359 BufferFormatToString(static_cast<gfx::BufferFormat>(format)), |
358 native_usage_support)); | 360 native_usage_support)); |
359 } | 361 } |
360 return gpu_memory_buffer_info; | 362 return gpu_memory_buffer_info; |
361 } | 363 } |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 : WebUIController(web_ui) { | 560 : WebUIController(web_ui) { |
559 web_ui->AddMessageHandler(base::MakeUnique<GpuMessageHandler>()); | 561 web_ui->AddMessageHandler(base::MakeUnique<GpuMessageHandler>()); |
560 | 562 |
561 // Set up the chrome://gpu/ source. | 563 // Set up the chrome://gpu/ source. |
562 BrowserContext* browser_context = | 564 BrowserContext* browser_context = |
563 web_ui->GetWebContents()->GetBrowserContext(); | 565 web_ui->GetWebContents()->GetBrowserContext(); |
564 WebUIDataSource::Add(browser_context, CreateGpuHTMLSource()); | 566 WebUIDataSource::Add(browser_context, CreateGpuHTMLSource()); |
565 } | 567 } |
566 | 568 |
567 } // namespace content | 569 } // namespace content |
OLD | NEW |