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

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

Issue 7495036: about:gpu support for thread name metadata. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 5 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 Renders an array of slices into the provided div, 7 * @fileoverview Renders an array of slices into the provided div,
8 * using a child canvas element. Uses a FastRectRenderer to draw only 8 * using a child canvas element. Uses a FastRectRenderer to draw only
9 * the visible slices. 9 * the visible slices.
10 */ 10 */
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 this.textContent = ''; 125 this.textContent = '';
126 this.tracks_ = []; 126 this.tracks_ = [];
127 if (this.thread_) { 127 if (this.thread_) {
128 for (var srI = 0; srI < this.thread_.nonNestedSubRows.length; ++srI) { 128 for (var srI = 0; srI < this.thread_.nonNestedSubRows.length; ++srI) {
129 addTrack(this, this.thread_.nonNestedSubRows[srI]); 129 addTrack(this, this.thread_.nonNestedSubRows[srI]);
130 } 130 }
131 for (var srI = 0; srI < this.thread_.subRows.length; ++srI) { 131 for (var srI = 0; srI < this.thread_.subRows.length; ++srI) {
132 addTrack(this, this.thread_.subRows[srI]); 132 addTrack(this, this.thread_.subRows[srI]);
133 } 133 }
134 if (this.tracks_.length > 0) { 134 if (this.tracks_.length > 0) {
135 var tname = this.thread_.name || this.thread_.tid;
135 this.tracks_[0].heading = this.thread_.parent.pid + ': ' + 136 this.tracks_[0].heading = this.thread_.parent.pid + ': ' +
136 this.thread_.tid + ': '; 137 tname + ':';
138 this.tracks_[0].title = 'pid: ' + this.thread_.parent.pid +
139 ', tid: ' + this.thread_.tid;
137 } 140 }
138 } 141 }
139 }, 142 },
140 143
141 /** 144 /**
142 * Picks a slice, if any, at a given location. 145 * Picks a slice, if any, at a given location.
143 * @param {number} wX X location to search at, in worldspace. 146 * @param {number} wX X location to search at, in worldspace.
144 * @param {number} wY Y location to search at, in offset space. 147 * @param {number} wY Y location to search at, in offset space.
145 * offset space. 148 * offset space.
146 * @param {function():*} onHitCallback Callback to call with the slice, 149 * @param {function():*} onHitCallback Callback to call with the slice,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 */ 190 */
188 TimelineSliceTrack = cr.ui.define('div'); 191 TimelineSliceTrack = cr.ui.define('div');
189 192
190 TimelineSliceTrack.prototype = { 193 TimelineSliceTrack.prototype = {
191 __proto__: HTMLDivElement.prototype, 194 __proto__: HTMLDivElement.prototype,
192 195
193 decorate: function() { 196 decorate: function() {
194 this.className = 'timeline-slice-track'; 197 this.className = 'timeline-slice-track';
195 this.slices_ = null; 198 this.slices_ = null;
196 199
197 this.titleDiv_ = document.createElement('div'); 200 this.headingDiv_ = document.createElement('div');
198 this.titleDiv_.className = 'timeline-slice-track-title'; 201 this.headingDiv_.className = 'timeline-slice-track-title';
199 this.appendChild(this.titleDiv_); 202 this.appendChild(this.headingDiv_);
200 203
201 this.canvasContainer_ = document.createElement('div'); 204 this.canvasContainer_ = document.createElement('div');
202 this.canvasContainer_.className = 'timeline-slice-track-canvas-container'; 205 this.canvasContainer_.className = 'timeline-slice-track-canvas-container';
203 this.appendChild(this.canvasContainer_); 206 this.appendChild(this.canvasContainer_);
204 this.canvas_ = document.createElement('canvas'); 207 this.canvas_ = document.createElement('canvas');
205 this.canvas_.className = 'timeline-slice-track-canvas'; 208 this.canvas_.className = 'timeline-slice-track-canvas';
206 this.canvasContainer_.appendChild(this.canvas_); 209 this.canvasContainer_.appendChild(this.canvas_);
207 210
208 this.ctx_ = this.canvas_.getContext('2d'); 211 this.ctx_ = this.canvas_.getContext('2d');
209 }, 212 },
210 213
211 set heading(text) { 214 set heading(text) {
212 this.titleDiv_.textContent = text; 215 this.headingDiv_.textContent = text;
216 },
217
218 set title(text) {
219 this.headingDiv_.textContent = text;
nduca 2011/07/26 09:46:33 Tooltips ftw!
213 }, 220 },
214 221
215 set slices(slices) { 222 set slices(slices) {
216 this.slices_ = slices; 223 this.slices_ = slices;
217 this.invalidate(); 224 this.invalidate();
218 }, 225 },
219 226
220 set viewport(v) { 227 set viewport(v) {
221 this.viewport_ = v; 228 this.viewport_ = v;
222 this.invalidate(); 229 this.invalidate();
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 ctx.textBaseline = 'top'; 309 ctx.textBaseline = 'top';
303 ctx.font = '10px sans-serif'; 310 ctx.font = '10px sans-serif';
304 ctx.strokeStyle = 'rgb(0,0,0)'; 311 ctx.strokeStyle = 'rgb(0,0,0)';
305 ctx.fillStyle = 'rgb(0,0,0)'; 312 ctx.fillStyle = 'rgb(0,0,0)';
306 var quickDiscardThresshold = pixWidth * 20; // dont render until 20px wide 313 var quickDiscardThresshold = pixWidth * 20; // dont render until 20px wide
307 for (var i = 0; i < slices.length; ++i) { 314 for (var i = 0; i < slices.length; ++i) {
308 var slice = slices[i]; 315 var slice = slices[i];
309 if (slice.duration > quickDiscardThresshold) { 316 if (slice.duration > quickDiscardThresshold) {
310 var title = slice.title; 317 var title = slice.title;
311 if (slice.didNotFinish) { 318 if (slice.didNotFinish) {
312 title += " (Did Not Finish)"; 319 title += ' (Did Not Finish)';
313 } 320 }
314 var labelWidth = quickMeasureText(ctx, title) + 2; 321 var labelWidth = quickMeasureText(ctx, title) + 2;
315 var labelWidthWorld = pixWidth * labelWidth; 322 var labelWidthWorld = pixWidth * labelWidth;
316 if (labelWidthWorld < slice.duration) { 323 if (labelWidthWorld < slice.duration) {
317 var cX = vp.xWorldToView(slice.start + 0.5 * slice.duration); 324 var cX = vp.xWorldToView(slice.start + 0.5 * slice.duration);
318 ctx.fillText(title, cX, 2.5); 325 ctx.fillText(title, cX, 2.5);
319 } 326 }
320 } 327 }
321 } 328 }
322 }, 329 },
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 onPickHit); 383 onPickHit);
377 } 384 }
378 385
379 }; 386 };
380 387
381 return { 388 return {
382 TimelineSliceTrack: TimelineSliceTrack, 389 TimelineSliceTrack: TimelineSliceTrack,
383 TimelineThreadTrack: TimelineThreadTrack 390 TimelineThreadTrack: TimelineThreadTrack
384 }; 391 };
385 }); 392 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698