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

Side by Side Diff: chrome/browser/resources/gpu_internals/raw_events_view.js

Issue 6677166: More about:gpu tracing improvements. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 8 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 /** 5 /**
6 * 6 *
7 * @fileoverview Displays the traced data in raw format. Its primarily 7 * @fileoverview Displays the traced data in raw format. Its primarily
8 * usefulness is to allow users to copy-paste their data in an easy to 8 * usefulness is to allow users to copy-paste their data in an easy to
9 * read format for bug reports. 9 * read format for bug reports.
10 * 10 *
11 */ 11 */
12 cr.define('gpu', function() { 12 cr.define('gpu', function() {
13 /** 13 /**
14 * Provides information on the GPU process and underlying graphics hardware. 14 * Provides information on the GPU process and underlying graphics hardware.
15 * @constructor 15 * @constructor
16 * @extends {gpu.Tab} 16 * @extends {gpu.Tab}
17 */ 17 */
18 var RawEventsView = cr.ui.define(gpu.Tab); 18 var RawEventsView = cr.ui.define(gpu.Tab);
19 19
20 RawEventsView.prototype = { 20 RawEventsView.prototype = {
21 __proto__: gpu.Tab.prototype, 21 __proto__: gpu.Tab.prototype,
22 22
23 decorate: function() { 23 decorate: function() {
24 tracingController.addEventListener('traceBegun', this.refresh.bind(this)); 24 tracingController.addEventListener('traceBegun',
25 tracingController.addEventListener('traceEnded', this.refresh.bind(this)); 25 this.setNeedsRefresh_.bind(this));
26 this.addEventListener('selectedChange', this.onSelectedChange_); 26 tracingController.addEventListener('traceEnded',
27 this.refresh(); 27 this.setNeedsRefresh_.bind(this));
28 this.addEventListener('selectedChange', this.onViewSelectedChange_);
29
30 this.setNeedsRefresh_();
28 }, 31 },
29 32
30 onSelectedChange_: function() { 33 onViewSelectedChange_: function() {
31 if (this.selected) { 34 if (this.selected) {
32 if (!tracingController.traceEvents.length) { 35 if (!tracingController.traceEvents.length) {
33 tracingController.beginTracing(); 36 tracingController.beginTracing();
34 } 37 }
35 if (this.needsRefreshOnShow_) { 38 if (this.needsRefreshOnShow_) {
36 this.needsRefreshOnShow_ = false;
37 this.refresh(); 39 this.refresh();
38 } 40 }
39 } 41 }
40 }, 42 },
41 43
44 setNeedsRefresh_: function() {
45 if (!this.selected) {
46 this.needsRefreshOnShow_ = true;
47 return;
48 } else {
49 this.refresh();
50 }
51 },
52
42 /** 53 /**
43 * Updates the view based on its currently known data 54 * Updates the view based on its currently known data
44 */ 55 */
45 refresh: function() { 56 refresh: function() {
46 if (this.parentNode.selectedTab != this) { 57 this.needsRefreshOnShow_ = false;
47 this.needsRefreshOnShow_ = true;
48 }
49 58
50 var dataElement = this.querySelector('.raw-events-view-data'); 59 var dataElement = this.querySelector('.raw-events-view-data');
51 if (tracingController.isTracingEnabled) { 60 if (tracingController.isTracingEnabled) {
52 var tmp = 'Still tracing. ' + 61 var tmp = 'Still tracing. ' +
53 'Uncheck the enable tracing button to see traced data.'; 62 'Uncheck the enable tracing button to see traced data.';
54 dataElement.textContent = tmp; 63 dataElement.textContent = tmp;
55 } else if (!tracingController.traceEvents.length) { 64 } else if (!tracingController.traceEvents.length) {
56 dataElement.textContent = 65 dataElement.textContent =
57 'No trace data collected. Collect data first.'; 66 'No trace data collected. Collect data first.';
58 } else { 67 } else {
59 var events = tracingController.traceEvents; 68 var events = tracingController.traceEvents;
60 var text = JSON.stringify(events); 69 dataElement.textContent = JSON.stringify(events);
61 dataElement.textContent = text;
62 70
63 var selection = window.getSelection(); 71 var selection = window.getSelection();
64 selection.removeAllRanges(); 72 selection.removeAllRanges();
65 var range = document.createRange(); 73 var range = document.createRange();
66 range.selectNodeContents(dataElement); 74 range.selectNodeContents(dataElement);
67 selection.addRange(range); 75 selection.addRange(range);
68 } 76 }
69 } 77 }
70 78
71 }; 79 };
72 80
73 return { 81 return {
74 RawEventsView: RawEventsView 82 RawEventsView: RawEventsView
75 }; 83 };
76 }); 84 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698