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

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: address nits and change GpuMemoryBufferInfoAsDictionaryValue main loop 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("Native Formats", "Usage"));
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 for (size_t usage = 0;
297 usage < static_cast<size_t>(gfx::BufferUsage::LAST) + 1; usage++) {
298 if (gpu_memory_buffer_manager->IsNativeGpuMemoryBufferConfiguration(
299 static_cast<gfx::BufferFormat>(format),
300 static_cast<gfx::BufferUsage>(usage)))
301 gpu_memory_buffer_info->Append(NewDescriptionValuePair(
302 BufferFormatToString(static_cast<gfx::BufferFormat>(format)),
303 BufferUsageToString(static_cast<gfx::BufferUsage>(usage))));
304 }
305 }
306
307 base::DictionaryValue* info = new base::DictionaryValue();
308 info->Set("gmb_info", gpu_memory_buffer_info);
reveman 2015/10/28 14:41:07 nit: "gpu_memory_buffer_info"
vignatti (out of this project) 2015/10/28 16:55:25 Done.
309
310 return info;
311 }
312
235 // This class receives javascript messages from the renderer. 313 // This class receives javascript messages from the renderer.
236 // Note that the WebUI infrastructure runs on the UI thread, therefore all of 314 // 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. 315 // this class's methods are expected to run on the UI thread.
238 class GpuMessageHandler 316 class GpuMessageHandler
239 : public WebUIMessageHandler, 317 : public WebUIMessageHandler,
240 public base::SupportsWeakPtr<GpuMessageHandler>, 318 public base::SupportsWeakPtr<GpuMessageHandler>,
241 public GpuDataManagerObserver, 319 public GpuDataManagerObserver,
242 public ui::GpuSwitchingObserver { 320 public ui::GpuSwitchingObserver {
243 public: 321 public:
244 GpuMessageHandler(); 322 GpuMessageHandler();
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 feature_status->Set("problems", GetProblems()); 480 feature_status->Set("problems", GetProblems());
403 base::ListValue* workarounds = new base::ListValue(); 481 base::ListValue* workarounds = new base::ListValue();
404 for (const std::string& workaround : GetDriverBugWorkarounds()) 482 for (const std::string& workaround : GetDriverBugWorkarounds())
405 workarounds->AppendString(workaround); 483 workarounds->AppendString(workaround);
406 feature_status->Set("workarounds", workarounds); 484 feature_status->Set("workarounds", workarounds);
407 gpu_info_val->Set("featureStatus", feature_status); 485 gpu_info_val->Set("featureStatus", feature_status);
408 486
409 // Send GPU Info to javascript. 487 // Send GPU Info to javascript.
410 web_ui()->CallJavascriptFunction("browserBridge.onGpuInfoUpdate", 488 web_ui()->CallJavascriptFunction("browserBridge.onGpuInfoUpdate",
411 *(gpu_info_val.get())); 489 *(gpu_info_val.get()));
490
491 // Get GpuMemoryBuffer Info.
492 scoped_ptr<base::DictionaryValue> gpu_memory_buffer_info_val(
493 GpuMemoryBufferInfoAsDictionaryValue());
494
495 // Send GpuMemoryBuffer Info to javascript.
496 web_ui()->CallJavascriptFunction("browserBridge.onGpuMemoryBufferInfoUpdate",
497 *(gpu_memory_buffer_info_val.get()));
412 } 498 }
413 499
414 void GpuMessageHandler::OnGpuSwitched() { 500 void GpuMessageHandler::OnGpuSwitched() {
415 GpuDataManagerImpl::GetInstance()->RequestCompleteGpuInfoIfNeeded(); 501 GpuDataManagerImpl::GetInstance()->RequestCompleteGpuInfoIfNeeded();
416 } 502 }
417 503
418 } // namespace 504 } // namespace
419 505
420 506
421 //////////////////////////////////////////////////////////////////////////////// 507 ////////////////////////////////////////////////////////////////////////////////
422 // 508 //
423 // GpuInternalsUI 509 // GpuInternalsUI
424 // 510 //
425 //////////////////////////////////////////////////////////////////////////////// 511 ////////////////////////////////////////////////////////////////////////////////
426 512
427 GpuInternalsUI::GpuInternalsUI(WebUI* web_ui) 513 GpuInternalsUI::GpuInternalsUI(WebUI* web_ui)
428 : WebUIController(web_ui) { 514 : WebUIController(web_ui) {
429 web_ui->AddMessageHandler(new GpuMessageHandler()); 515 web_ui->AddMessageHandler(new GpuMessageHandler());
430 516
431 // Set up the chrome://gpu/ source. 517 // Set up the chrome://gpu/ source.
432 BrowserContext* browser_context = 518 BrowserContext* browser_context =
433 web_ui->GetWebContents()->GetBrowserContext(); 519 web_ui->GetWebContents()->GetBrowserContext();
434 WebUIDataSource::Add(browser_context, CreateGpuHTMLSource()); 520 WebUIDataSource::Add(browser_context, CreateGpuHTMLSource());
435 } 521 }
436 522
437 } // namespace content 523 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698