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

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

Issue 1375663002: Show GpuMemoryBuffer feature in chrome://gpu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: improve the look Created 5 years, 1 month 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
OLDNEW
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
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 const char* BufferFormatToString(gfx::BufferFormat format) {
237 switch (format) {
238 case gfx::BufferFormat::ATC:
239 return "ATC";
240 case gfx::BufferFormat::ATCIA:
241 return "ATCIA";
242 case gfx::BufferFormat::DXT1:
243 return "DXT1";
244 case gfx::BufferFormat::DXT5:
245 return "DXT5";
246 case gfx::BufferFormat::ETC1:
247 return "ETC1";
248 case gfx::BufferFormat::R_8:
249 return "R_8";
250 case gfx::BufferFormat::RGBA_4444:
251 return "RGBA_4444";
252 case gfx::BufferFormat::RGBX_8888:
253 return "RGBX_8888";
254 case gfx::BufferFormat::RGBA_8888:
255 return "RGBA_8888";
256 case gfx::BufferFormat::BGRX_8888:
257 return "BGRX_8888";
258 case gfx::BufferFormat::BGRA_8888:
259 return "BGRA_8888";
260 case gfx::BufferFormat::YUV_420:
261 return "YUV_420";
262 case gfx::BufferFormat::YUV_420_BIPLANAR:
263 return "YUV_420_BIPLANAR";
264 case gfx::BufferFormat::UYVY_422:
265 return "UYVY_422";
266 }
267 NOTREACHED();
268 return nullptr;
269 }
270
271 const char* BufferUsageToString(gfx::BufferUsage usage) {
272 switch (usage) {
273 case gfx::BufferUsage::GPU_READ:
274 return "GPU_READ";
275 case gfx::BufferUsage::GPU_READ_WRITE:
276 return "GPU_READ_WRITE";
277 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE:
278 return "GPU_READ_CPU_READ_WRITE";
279 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT:
280 return "GPU_READ_CPU_READ_WRITE_PERSISTENT";
281 }
282 NOTREACHED();
283 return nullptr;
284 }
285
286 base::DictionaryValue* GpuMemoryBufferInfoAsDictionaryValue() {
287 base::ListValue* gpu_memory_buffer_info = new base::ListValue();
288 gpu_memory_buffer_info->Append(
289 NewDescriptionValuePair("Formats", "Native usage support"));
reveman 2015/10/29 00:27:26 I think it's a bit inappropriate to use a value pa
vignatti (out of this project) 2015/10/29 14:15:36 Done.
290
291 BrowserGpuMemoryBufferManager* gpu_memory_buffer_manager =
292 BrowserGpuMemoryBufferManager::current();
293
294 for (size_t format = 0;
295 format < static_cast<size_t>(gfx::BufferFormat::LAST) + 1; format++) {
296 std::string native_usage_support;
297 for (size_t usage = 0;
298 usage < static_cast<size_t>(gfx::BufferUsage::LAST) + 1; usage++) {
299 if (gpu_memory_buffer_manager->IsNativeGpuMemoryBufferConfiguration(
300 static_cast<gfx::BufferFormat>(format),
301 static_cast<gfx::BufferUsage>(usage)))
302 native_usage_support =
303 base::StringPrintf("%s%s %s", native_usage_support.c_str(),
304 native_usage_support.empty() ? "" :",",
305 BufferUsageToString(static_cast<gfx::BufferUsage>(usage)));
306 }
307 if (native_usage_support.empty())
308 native_usage_support = base::StringPrintf("Unsupported");
reveman 2015/10/29 00:27:26 Maybe "Software only" instead of "Unsupported" as
vignatti (out of this project) 2015/10/29 14:15:36 yup, let's use "Software only" then. Done.
309
310 gpu_memory_buffer_info->Append(NewDescriptionValuePair(
311 BufferFormatToString(static_cast<gfx::BufferFormat>(format)),
312 native_usage_support));
313 }
314
315 base::DictionaryValue* info = new base::DictionaryValue();
316 info->Set("gpu_memory_buffer_info", gpu_memory_buffer_info);
317
318 return info;
319 }
320
235 // This class receives javascript messages from the renderer. 321 // This class receives javascript messages from the renderer.
236 // Note that the WebUI infrastructure runs on the UI thread, therefore all of 322 // 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. 323 // this class's methods are expected to run on the UI thread.
238 class GpuMessageHandler 324 class GpuMessageHandler
239 : public WebUIMessageHandler, 325 : public WebUIMessageHandler,
240 public base::SupportsWeakPtr<GpuMessageHandler>, 326 public base::SupportsWeakPtr<GpuMessageHandler>,
241 public GpuDataManagerObserver, 327 public GpuDataManagerObserver,
242 public ui::GpuSwitchingObserver { 328 public ui::GpuSwitchingObserver {
243 public: 329 public:
244 GpuMessageHandler(); 330 GpuMessageHandler();
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 feature_status->Set("problems", GetProblems()); 488 feature_status->Set("problems", GetProblems());
403 base::ListValue* workarounds = new base::ListValue(); 489 base::ListValue* workarounds = new base::ListValue();
404 for (const std::string& workaround : GetDriverBugWorkarounds()) 490 for (const std::string& workaround : GetDriverBugWorkarounds())
405 workarounds->AppendString(workaround); 491 workarounds->AppendString(workaround);
406 feature_status->Set("workarounds", workarounds); 492 feature_status->Set("workarounds", workarounds);
407 gpu_info_val->Set("featureStatus", feature_status); 493 gpu_info_val->Set("featureStatus", feature_status);
408 494
409 // Send GPU Info to javascript. 495 // Send GPU Info to javascript.
410 web_ui()->CallJavascriptFunction("browserBridge.onGpuInfoUpdate", 496 web_ui()->CallJavascriptFunction("browserBridge.onGpuInfoUpdate",
411 *(gpu_info_val.get())); 497 *(gpu_info_val.get()));
498
499 // Get GpuMemoryBuffer Info.
500 scoped_ptr<base::DictionaryValue> gpu_memory_buffer_info_val(
501 GpuMemoryBufferInfoAsDictionaryValue());
502
503 // Send GpuMemoryBuffer Info to javascript.
504 web_ui()->CallJavascriptFunction("browserBridge.onGpuMemoryBufferInfoUpdate",
505 *(gpu_memory_buffer_info_val.get()));
412 } 506 }
413 507
414 void GpuMessageHandler::OnGpuSwitched() { 508 void GpuMessageHandler::OnGpuSwitched() {
415 GpuDataManagerImpl::GetInstance()->RequestCompleteGpuInfoIfNeeded(); 509 GpuDataManagerImpl::GetInstance()->RequestCompleteGpuInfoIfNeeded();
416 } 510 }
417 511
418 } // namespace 512 } // namespace
419 513
420 514
421 //////////////////////////////////////////////////////////////////////////////// 515 ////////////////////////////////////////////////////////////////////////////////
422 // 516 //
423 // GpuInternalsUI 517 // GpuInternalsUI
424 // 518 //
425 //////////////////////////////////////////////////////////////////////////////// 519 ////////////////////////////////////////////////////////////////////////////////
426 520
427 GpuInternalsUI::GpuInternalsUI(WebUI* web_ui) 521 GpuInternalsUI::GpuInternalsUI(WebUI* web_ui)
428 : WebUIController(web_ui) { 522 : WebUIController(web_ui) {
429 web_ui->AddMessageHandler(new GpuMessageHandler()); 523 web_ui->AddMessageHandler(new GpuMessageHandler());
430 524
431 // Set up the chrome://gpu/ source. 525 // Set up the chrome://gpu/ source.
432 BrowserContext* browser_context = 526 BrowserContext* browser_context =
433 web_ui->GetWebContents()->GetBrowserContext(); 527 web_ui->GetWebContents()->GetBrowserContext();
434 WebUIDataSource::Add(browser_context, CreateGpuHTMLSource()); 528 WebUIDataSource::Add(browser_context, CreateGpuHTMLSource());
435 } 529 }
436 530
437 } // namespace content 531 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/gpu/browser_gpu_memory_buffer_manager.cc ('k') | content/browser/resources/gpu/browser_bridge.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698