diff options
author | nduca@chromium.org <nduca@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-15 22:25:08 +0000 |
---|---|---|
committer | nduca@chromium.org <nduca@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-15 22:25:08 +0000 |
commit | 71e2f0a1ba62594c2cb555dd291810aaa7775779 (patch) | |
tree | b394d5ff5ae951dd6894a767b1a45edc8624c707 /chrome/browser | |
parent | a8f102a29e65551638d4513a306e384d6ce829b6 (diff) | |
download | chromium_src-71e2f0a1ba62594c2cb555dd291810aaa7775779.zip chromium_src-71e2f0a1ba62594c2cb555dd291810aaa7775779.tar.gz chromium_src-71e2f0a1ba62594c2cb555dd291810aaa7775779.tar.bz2 |
Introduce gpu_trace_event for gpu performance analysis.
This changelist is a lightweight version of issue 6551019, but with
the code change confined to the gpu subsystem.
The intent of this change is to enable forward progress on gpu tracing.
Work on the aformentioned issue, i.e. fusing gpu_trace_event and trace_event, will continue.
BUG=
TEST=
Review URL: http://codereview.chromium.org/6691013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78300 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
9 files changed, 189 insertions, 36 deletions
diff --git a/chrome/browser/gpu_process_host_ui_shim.cc b/chrome/browser/gpu_process_host_ui_shim.cc index 380a37c..bc5b9da 100644 --- a/chrome/browser/gpu_process_host_ui_shim.cc +++ b/chrome/browser/gpu_process_host_ui_shim.cc @@ -15,6 +15,7 @@ #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/renderer_host/render_widget_host_view.h" #include "content/common/gpu_messages.h" +#include "gpu/common/gpu_trace_event.h" #if defined(OS_LINUX) // These two #includes need to come after gpu_messages.h. @@ -269,6 +270,7 @@ void GpuProcessHostUIShim::EstablishGpuChannel( int renderer_id, EstablishChannelCallback *callback) { DCHECK(CalledOnValidThread()); + GPU_TRACE_EVENT0("gpu", "GpuProcessHostUIShim::EstablishGpuChannel"); linked_ptr<EstablishChannelCallback> wrapped_callback(callback); // If GPU features are already blacklisted, no need to establish the channel. @@ -539,4 +541,3 @@ void GpuProcessHostUIShim::OnScheduleComposite(int renderer_id, } #endif - diff --git a/chrome/browser/resources/gpu_internals.html b/chrome/browser/resources/gpu_internals.html index 8763249..5c17de7 100644 --- a/chrome/browser/resources/gpu_internals.html +++ b/chrome/browser/resources/gpu_internals.html @@ -29,6 +29,7 @@ body { <link rel="stylesheet" href="gpu_internals/timeline_view.css"> <link rel="stylesheet" href="gpu_internals/timeline.css"> <link rel="stylesheet" href="gpu_internals/tracing_controller.css"> +<link rel="stylesheet" href="gpu_internals/raw_events_view.css"> <script src="chrome://resources/js/cr.js"></script> <script src="chrome://resources/js/cr/event_target.js"></script> <script src="chrome://resources/js/cr/ui.js"></script> @@ -44,6 +45,7 @@ body { <script src="gpu_internals/timeline_track.js"></script> <script src="gpu_internals/fast_rect_renderer.js"></script> <script src="gpu_internals/timeline_view.js"></script> +<script src="gpu_internals/raw_events_view.js"></script> <script src="gpu_internals/simulated_trace_data.js"></script> <script> @@ -62,6 +64,12 @@ function onLoad() { // Create the views. cr.ui.decorate('#info-view', gpu.InfoView); + var rawEventsView = $('raw-events-view'); + if (browserBridge.debugMode) + cr.ui.decorate('#raw-events-view', gpu.RawEventsView); + else + rawEventsView.parentNode.removeChild(rawEventsView); + timelineView = $('timeline-view'); if (browserBridge.debugMode) cr.ui.decorate(timelineView, gpu.TimelineView); @@ -100,9 +108,8 @@ document.addEventListener('DOMContentLoaded', onLoad); <!-- Tabs --> <div id="main-tabs"> <include src="gpu_internals/info_view.html"> + <include src="gpu_internals/raw_events_view.html"> <include src="gpu_internals/timeline_view.html"> </div> - - <include src="gpu_internals/tracing_controller.html"> </body> </html> diff --git a/chrome/browser/resources/gpu_internals/raw_events_view.css b/chrome/browser/resources/gpu_internals/raw_events_view.css new file mode 100644 index 0000000..c282960 --- /dev/null +++ b/chrome/browser/resources/gpu_internals/raw_events_view.css @@ -0,0 +1,14 @@ +/* +Copyright (c) 2011 The Chromium Authors. All rights reserved. +Use of this source code is governed by a BSD-style license that can be +found in the LICENSE file. +*/ +#raw-events-view { + padding: 4px; +} + +#raw-events-view-data { + cursor: text; + font-family: monospace; + -webkit-user-select: text; +}
\ No newline at end of file diff --git a/chrome/browser/resources/gpu_internals/raw_events_view.html b/chrome/browser/resources/gpu_internals/raw_events_view.html new file mode 100644 index 0000000..464bba8 --- /dev/null +++ b/chrome/browser/resources/gpu_internals/raw_events_view.html @@ -0,0 +1,9 @@ +<!-- +Copyright (c) 2011 The Chromium Authors. All rights reserved. +Use of this source code is governed by a BSD-style license that can be +found in the LICENSE file. +--> +<div id=raw-events-view label="Raw Events"> + <div class="raw-events-view-data"> + </div> +</div> diff --git a/chrome/browser/resources/gpu_internals/raw_events_view.js b/chrome/browser/resources/gpu_internals/raw_events_view.js new file mode 100644 index 0000000..5ff981a --- /dev/null +++ b/chrome/browser/resources/gpu_internals/raw_events_view.js @@ -0,0 +1,76 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +/** + * + * @fileoverview Displays the traced data in raw format. Its primarily + * usefulness is to allow users to copy-paste their data in an easy to + * read format for bug reports. + * + */ +cr.define('gpu', function() { + /** + * Provides information on the GPU process and underlying graphics hardware. + * @constructor + * @extends {gpu.Tab} + */ + var RawEventsView = cr.ui.define(gpu.Tab); + + RawEventsView.prototype = { + __proto__: gpu.Tab.prototype, + + decorate: function() { + tracingController.addEventListener('traceBegun', this.refresh.bind(this)); + tracingController.addEventListener('traceEnded', this.refresh.bind(this)); + this.addEventListener('selectedChange', this.onSelectedChange_); + this.refresh(); + }, + + onSelectedChange_: function() { + if (this.selected) { + if (!tracingController.traceEvents.length) { + tracingController.beginTracing(); + } + if (this.needsRefreshOnShow_) { + this.needsRefreshOnShow_ = false; + this.refresh(); + } + } + }, + + /** + * Updates the view based on its currently known data + */ + refresh: function() { + if (this.parentNode.selectedTab != this) { + this.needsRefreshOnShow_ = true; + } + + var dataElement = this.querySelector('.raw-events-view-data'); + if (tracingController.isTracingEnabled) { + var tmp = 'Still tracing. ' + + 'Uncheck the enable tracing button to see traced data.'; + dataElement.textContent = tmp; + } else if (!tracingController.traceEvents.length) { + dataElement.textContent = + 'No trace data collected. Collect data first.'; + } else { + var events = tracingController.traceEvents; + var text = JSON.stringify(events); + dataElement.textContent = text; + + var selection = window.getSelection(); + selection.removeAllRanges(); + var range = document.createRange(); + range.selectNodeContents(dataElement); + selection.addRange(range); + } + } + + }; + + return { + RawEventsView: RawEventsView + }; +}); diff --git a/chrome/browser/resources/gpu_internals/tracing_controller.css b/chrome/browser/resources/gpu_internals/tracing_controller.css index 331fe85..895d695 100644 --- a/chrome/browser/resources/gpu_internals/tracing_controller.css +++ b/chrome/browser/resources/gpu_internals/tracing_controller.css @@ -26,8 +26,7 @@ found in the LICENSE file. border-top-right-radius: 8px; border-top-left-radius: 8px; background-clip: border-box; - background: rgb(255,0,0); - border-left: 1px solid black; - border-top: 1px solid black; - border-right: 1px solid black; + background: rgb(255, 0, 0); + border: 1px solid black; + border-bottom: 0; } diff --git a/chrome/browser/resources/gpu_internals/tracing_controller.html b/chrome/browser/resources/gpu_internals/tracing_controller.html deleted file mode 100644 index 7db2635..0000000 --- a/chrome/browser/resources/gpu_internals/tracing_controller.html +++ /dev/null @@ -1,14 +0,0 @@ -<!-- -Copyright (c) 2011 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<div hidden> - <div id="gpu-tracing-start-button-template" class="gpu-tracing-start-button"> - Record new data - </div> - <div id="gpu-tracing-overlay-template" class="gpu-tracing-overlay"> - <div class="gpu-tracing-status">Tracing active.</div> - <button class="gpu-tracing-stop-button">Stop tracing</button> - </div> -</div> diff --git a/chrome/browser/resources/gpu_internals/tracing_controller.js b/chrome/browser/resources/gpu_internals/tracing_controller.js index f46e417..8d7471b 100644 --- a/chrome/browser/resources/gpu_internals/tracing_controller.js +++ b/chrome/browser/resources/gpu_internals/tracing_controller.js @@ -7,20 +7,29 @@ * @fileoverview State and UI for trace data collection. */ cr.define('gpu', function() { + function TracingController() { - this.overlay_ = $('gpu-tracing-overlay-template').cloneNode(true); - this.overlay_.removeAttribute('id'); - cr.ui.decorate(this.overlay_, gpu.Overlay); + this.startButton_ = document.createElement('div'); + this.startButton_.className = 'gpu-tracing-start-button'; + this.startButton_.textContent = 'Start tracing'; + this.startButton_.onclick = this.beginTracing.bind(this); + document.body.appendChild(this.startButton_); - this.traceEvents_ = []; + this.overlay_ = document.createElement('div'); + this.overlay_.className = 'gpu-tracing-overlay'; + + cr.ui.decorate(this.overlay_, gpu.Overlay); - var startButton = $('gpu-tracing-start-button-template').cloneNode(true); - startButton.removeAttribute('id'); - document.body.appendChild(startButton); - startButton.onclick = this.beginTracing.bind(this); + var statusDiv = document.createElement('div'); + statusDiv.textContent = 'Tracing active.'; + this.overlay_.appendChild(statusDiv); - var stopButton = this.overlay_.querySelector('.gpu-tracing-stop-button'); + var stopButton = document.createElement('button'); stopButton.onclick = this.endTracing.bind(this); + stopButton.innerText = 'Stop tracing'; + this.overlay_.appendChild(stopButton); + + this.traceEvents_ = []; } TracingController.prototype = { @@ -93,17 +102,18 @@ cr.define('gpu', function() { console.log('Finishing trace'); if (!browserBridge.debugMode) { - chrome.send('beginToEndTracing'); + chrome.send('endTracingAsync'); } else { - var events = getTimelineTestData1(); + var events = window.getTimelineTestData1 ? + getTimelineTestData1() : []; this.onTraceDataCollected(events); window.setTimeout(this.onEndTracingComplete.bind(this), 250); } }, + /** - * Called by the browser when all processes ack tracing - * having completed. + * Called by the browser when all processes complete tracing. */ onEndTracingComplete: function() { this.overlay_.visible = false; diff --git a/chrome/browser/ui/webui/gpu_internals_ui.cc b/chrome/browser/ui/webui/gpu_internals_ui.cc index 8e8bf2c..0729ef1 100644 --- a/chrome/browser/ui/webui/gpu_internals_ui.cc +++ b/chrome/browser/ui/webui/gpu_internals_ui.cc @@ -35,6 +35,7 @@ #include "chrome/common/url_constants.h" #include "content/browser/browser_thread.h" #include "content/browser/gpu_process_host.h" +#include "content/browser/renderer_host/render_view_host.h" #include "content/browser/tab_contents/tab_contents.h" #include "grit/browser_resources.h" #include "grit/generated_resources.h" @@ -75,6 +76,8 @@ class GpuMessageHandler virtual void RegisterMessages(); // Mesages + void OnBeginTracing(const ListValue* list); + void OnEndTracingAsync(const ListValue* list); void OnBrowserBridgeInitialized(const ListValue* list); void OnCallAsync(const ListValue* list); @@ -82,6 +85,8 @@ class GpuMessageHandler Value* OnRequestClientInfo(const ListValue* list); Value* OnRequestLogMessages(const ListValue* list); + // Callbacks. + void OnTraceDataCollected(const std::string& json_events); void OnGpuInfoUpdate(); // Executes the javascript function |function_name| in the renderer, passing @@ -95,7 +100,11 @@ class GpuMessageHandler // Cache the Singleton for efficiency. GpuDataManager* gpu_data_manager_; + void OnEndTracingComplete(); + Callback0::Type* gpu_info_update_callback_; + + bool trace_enabled_; }; //////////////////////////////////////////////////////////////////////////////// @@ -141,7 +150,9 @@ std::string GpuHTMLSource::GetMimeType(const std::string&) const { // //////////////////////////////////////////////////////////////////////////////// -GpuMessageHandler::GpuMessageHandler() : gpu_info_update_callback_(NULL) { +GpuMessageHandler::GpuMessageHandler() + : gpu_info_update_callback_(NULL) + , trace_enabled_(false) { gpu_data_manager_ = GpuDataManager::GetInstance(); DCHECK(gpu_data_manager_); } @@ -151,6 +162,9 @@ GpuMessageHandler::~GpuMessageHandler() { gpu_data_manager_->RemoveGpuInfoUpdateCallback(gpu_info_update_callback_); delete gpu_info_update_callback_; } + + if (trace_enabled_) + OnEndTracingAsync(NULL); } WebUIMessageHandler* GpuMessageHandler::Attach(WebUI* web_ui) { @@ -164,6 +178,12 @@ void GpuMessageHandler::RegisterMessages() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); web_ui_->RegisterMessageCallback( + "beginTracing", + NewCallback(this, &GpuMessageHandler::OnBeginTracing)); + web_ui_->RegisterMessageCallback( + "endTracingAsync", + NewCallback(this, &GpuMessageHandler::OnEndTracingAsync)); + web_ui_->RegisterMessageCallback( "browserBridgeInitialized", NewCallback(this, &GpuMessageHandler::OnBrowserBridgeInitialized)); web_ui_->RegisterMessageCallback( @@ -368,6 +388,38 @@ void GpuMessageHandler::OnGpuInfoUpdate() { delete gpu_info_val; } +void GpuMessageHandler::OnBeginTracing(const ListValue* args) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + + trace_enabled_ = true; + // TODO(jbates): TracingController::BeginTracing() +} + +void GpuMessageHandler::OnEndTracingAsync(const ListValue* list) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK(trace_enabled_); + + // TODO(jbates): TracingController::OnEndTracingAsync(new + // Callback(this, GpuMessageHandler::OnEndTracingComplete)) +} + +void GpuMessageHandler::OnEndTracingComplete() { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + trace_enabled_ = false; + web_ui_->CallJavascriptFunction("tracingController.onEndTracingComplete"); +} + +void GpuMessageHandler::OnTraceDataCollected(const std::string& json_events) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + std::wstring javascript; + javascript += L"tracingController.onTraceDataCollected("; + javascript += UTF8ToWide(json_events); + javascript += L");"; + + web_ui_->GetRenderViewHost()->ExecuteJavascriptInWebFrame(string16(), + WideToUTF16Hack(javascript)); +} + } // namespace @@ -385,4 +437,3 @@ GpuInternalsUI::GpuInternalsUI(TabContents* contents) : WebUI(contents) { // Set up the chrome://gpu/ source. contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); } - |