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

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: use IsNativeGpuMemoryBufferConfiguration 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* NativeBufferFormatToString(gfx::BufferFormat format) {
reveman 2015/10/27 23:20:36 nit: Remove "Native" prefix
vignatti (out of this project) 2015/10/28 14:17:28 Done.
237 switch (format) {
238 case gfx::BufferFormat::R_8:
239 return "R_8";
240 case gfx::BufferFormat::RGBA_4444:
241 return "RGBA_4444";
242 case gfx::BufferFormat::RGBA_8888:
243 return "RGBA_8888";
244 case gfx::BufferFormat::BGRA_8888:
245 return "BGRA_8888";
246 case gfx::BufferFormat::UYVY_422:
247 return "UYVY_422";
248 case gfx::BufferFormat::YUV_420_BIPLANAR:
249 return "YUV_420_BIPLANAR";
250 default:
reveman 2015/10/27 23:20:35 nit: remove default case, include all formats and
vignatti (out of this project) 2015/10/28 14:17:28 Done.
251 NOTREACHED();
252 return "";
253 }
254 }
255
256 const char* NativeBufferUsageToString(gfx::BufferUsage usage) {
reveman 2015/10/27 23:20:36 nit: Remove "Native" prefix
vignatti (out of this project) 2015/10/28 14:17:28 Done.
257 switch (usage) {
258 case gfx::BufferUsage::GPU_READ:
259 return "GPU_READ";
260 case gfx::BufferUsage::GPU_READ_WRITE:
261 return "GPU_READ_WRITE";
262 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE:
263 return "GPU_READ_CPU_READ_WRITE";
264 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT:
265 return "GPU_READ_CPU_READ_WRITE_PERSISTENT";
266 }
267 }
reveman 2015/10/27 23:20:35 NOTREACHED(); return nullptr;
vignatti (out of this project) 2015/10/28 14:17:28 Done.
268
269 base::DictionaryValue* GmbInfoAsDictionaryValue() {
reveman 2015/10/27 23:20:36 nit: Gmb -> GpuMemoryBuffer. please avoid the GMB
vignatti (out of this project) 2015/10/28 14:17:28 Done.
270 base::ListValue* gmb_info = new base::ListValue();
reveman 2015/10/27 23:20:36 nit: gmb -> gpu_memory_buffer
vignatti (out of this project) 2015/10/28 14:17:28 Done.
271 gmb_info->Append(NewDescriptionValuePair("Native Formats", "Usage"));
272
273 BrowserGpuMemoryBufferManager* gmb_manager =
reveman 2015/10/27 23:20:36 nit: gmb -> gpu_memory_buffer
vignatti (out of this project) 2015/10/28 14:17:28 Done.
274 BrowserGpuMemoryBufferManager::current();
275
276 const gfx::BufferFormat kNativeFormats[] = {
277 gfx::BufferFormat::R_8, gfx::BufferFormat::RGBA_4444,
278 gfx::BufferFormat::RGBA_8888, gfx::BufferFormat::BGRA_8888,
279 gfx::BufferFormat::UYVY_422, gfx::BufferFormat::YUV_420_BIPLANAR};
reveman 2015/10/27 23:20:36 I don't think this code should assume that only th
280 const gfx::BufferUsage kNativeUsages[] = {
281 gfx::BufferUsage::GPU_READ, gfx::BufferUsage::GPU_READ_WRITE,
282 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE,
283 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT};
reveman 2015/10/27 23:20:35 can you use gfx::BufferUsage::LAST and gfx::Buffer
vignatti (out of this project) 2015/10/28 14:17:28 hmm with this the code became not so clear now, bu
284 for (auto& format : kNativeFormats) {
285 for (auto& usage : kNativeUsages) {
286 if (gmb_manager->IsNativeGpuMemoryBufferConfiguration(format, usage))
287 gmb_info->Append(NewDescriptionValuePair(
288 NativeBufferFormatToString(format),
289 NativeBufferUsageToString(usage)));
290 }
291 }
292
293 base::DictionaryValue* info = new base::DictionaryValue();
294 info->Set("gmb_info", gmb_info);
reveman 2015/10/27 23:20:35 gmb -> gpu_memory_buffer
vignatti (out of this project) 2015/10/28 14:17:29 Done.
295
296 return info;
297 }
298
235 // This class receives javascript messages from the renderer. 299 // This class receives javascript messages from the renderer.
236 // Note that the WebUI infrastructure runs on the UI thread, therefore all of 300 // 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. 301 // this class's methods are expected to run on the UI thread.
238 class GpuMessageHandler 302 class GpuMessageHandler
239 : public WebUIMessageHandler, 303 : public WebUIMessageHandler,
240 public base::SupportsWeakPtr<GpuMessageHandler>, 304 public base::SupportsWeakPtr<GpuMessageHandler>,
241 public GpuDataManagerObserver, 305 public GpuDataManagerObserver,
242 public ui::GpuSwitchingObserver { 306 public ui::GpuSwitchingObserver {
243 public: 307 public:
244 GpuMessageHandler(); 308 GpuMessageHandler();
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 feature_status->Set("problems", GetProblems()); 466 feature_status->Set("problems", GetProblems());
403 base::ListValue* workarounds = new base::ListValue(); 467 base::ListValue* workarounds = new base::ListValue();
404 for (const std::string& workaround : GetDriverBugWorkarounds()) 468 for (const std::string& workaround : GetDriverBugWorkarounds())
405 workarounds->AppendString(workaround); 469 workarounds->AppendString(workaround);
406 feature_status->Set("workarounds", workarounds); 470 feature_status->Set("workarounds", workarounds);
407 gpu_info_val->Set("featureStatus", feature_status); 471 gpu_info_val->Set("featureStatus", feature_status);
408 472
409 // Send GPU Info to javascript. 473 // Send GPU Info to javascript.
410 web_ui()->CallJavascriptFunction("browserBridge.onGpuInfoUpdate", 474 web_ui()->CallJavascriptFunction("browserBridge.onGpuInfoUpdate",
411 *(gpu_info_val.get())); 475 *(gpu_info_val.get()));
476
477 // Get GpuMemoryBuffer Info.
478 scoped_ptr<base::DictionaryValue> gmb_info_val(GmbInfoAsDictionaryValue());
reveman 2015/10/27 23:20:36 gmb -> gpu_memory_buffer
479
480 // Add in blacklisting features
reveman 2015/10/27 23:20:36 blacklisting features?
vignatti (out of this project) 2015/10/28 14:17:29 Done.
481 base::DictionaryValue* gmb_status = new base::DictionaryValue;
reveman 2015/10/27 23:20:35 gmb -> gpu_memory_buffer
vignatti (out of this project) 2015/10/28 14:17:28 Done.
482 gmb_info_val->Set("gbmStatus", gmb_status);
reveman 2015/10/27 23:20:36 gmb -> gpu_memory_buffer
vignatti (out of this project) 2015/10/28 14:17:28 Done.
483
484 // Send GMB Info to javascript.
reveman 2015/10/27 23:20:36 gmb -> gpu_memory_buffer
vignatti (out of this project) 2015/10/28 14:17:29 Done.
485 web_ui()->CallJavascriptFunction("browserBridge.onGmbInfoUpdate",
486 *(gmb_info_val.get()));
reveman 2015/10/27 23:20:36 gmb -> gpu_memory_buffer
vignatti (out of this project) 2015/10/28 14:17:29 Done.
412 } 487 }
413 488
414 void GpuMessageHandler::OnGpuSwitched() { 489 void GpuMessageHandler::OnGpuSwitched() {
415 GpuDataManagerImpl::GetInstance()->RequestCompleteGpuInfoIfNeeded(); 490 GpuDataManagerImpl::GetInstance()->RequestCompleteGpuInfoIfNeeded();
416 } 491 }
417 492
418 } // namespace 493 } // namespace
419 494
420 495
421 //////////////////////////////////////////////////////////////////////////////// 496 ////////////////////////////////////////////////////////////////////////////////
422 // 497 //
423 // GpuInternalsUI 498 // GpuInternalsUI
424 // 499 //
425 //////////////////////////////////////////////////////////////////////////////// 500 ////////////////////////////////////////////////////////////////////////////////
426 501
427 GpuInternalsUI::GpuInternalsUI(WebUI* web_ui) 502 GpuInternalsUI::GpuInternalsUI(WebUI* web_ui)
428 : WebUIController(web_ui) { 503 : WebUIController(web_ui) {
429 web_ui->AddMessageHandler(new GpuMessageHandler()); 504 web_ui->AddMessageHandler(new GpuMessageHandler());
430 505
431 // Set up the chrome://gpu/ source. 506 // Set up the chrome://gpu/ source.
432 BrowserContext* browser_context = 507 BrowserContext* browser_context =
433 web_ui->GetWebContents()->GetBrowserContext(); 508 web_ui->GetWebContents()->GetBrowserContext();
434 WebUIDataSource::Add(browser_context, CreateGpuHTMLSource()); 509 WebUIDataSource::Add(browser_context, CreateGpuHTMLSource());
435 } 510 }
436 511
437 } // namespace content 512 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698