OLD | NEW |
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 | 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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 updateChildTracks_: function() { | 174 updateChildTracks_: function() { |
175 this.detach(); | 175 this.detach(); |
176 this.textContent = ''; | 176 this.textContent = ''; |
177 this.tracks_ = []; | 177 this.tracks_ = []; |
178 if (this.thread_) { | 178 if (this.thread_) { |
179 if (this.thread_.cpuSlices) { | 179 if (this.thread_.cpuSlices) { |
180 var track = this.addTrack_(this.thread_.cpuSlices); | 180 var track = this.addTrack_(this.thread_.cpuSlices); |
181 track.height = '4px'; | 181 track.height = '4px'; |
182 } | 182 } |
183 | 183 |
184 for (var srI = 0; srI < this.thread_.nonNestedSubRows.length; ++srI) { | 184 if (this.thread_.asyncSlices.length) { |
185 this.addTrack_(this.thread_.nonNestedSubRows[srI]); | 185 var subRows = this.thread_.asyncSlices.subRows; |
| 186 for (var srI = 0; srI < subRows.length; srI++) { |
| 187 var track = this.addTrack_(subRows[srI]); |
| 188 track.asyncStyle = true; |
| 189 } |
186 } | 190 } |
187 for (var srI = 0; srI < this.thread_.subRows.length; ++srI) { | 191 |
| 192 for (var srI = 0; srI < this.thread_.subRows.length; srI++) { |
188 this.addTrack_(this.thread_.subRows[srI]); | 193 this.addTrack_(this.thread_.subRows[srI]); |
189 } | 194 } |
| 195 |
190 if (this.tracks_.length > 0) { | 196 if (this.tracks_.length > 0) { |
191 if (this.thread_.cpuSlices) { | 197 if (this.thread_.cpuSlices) { |
192 this.tracks_[1].heading = this.heading_; | 198 this.tracks_[1].heading = this.heading_; |
193 this.tracks_[1].tooltip = this.tooltip_; | 199 this.tracks_[1].tooltip = this.tooltip_; |
194 } else { | 200 } else { |
195 this.tracks_[0].heading = this.heading_; | 201 this.tracks_[0].heading = this.heading_; |
196 this.tracks_[0].tooltip = this.tooltip_; | 202 this.tracks_[0].tooltip = this.tooltip_; |
197 } | 203 } |
198 } | 204 } |
199 } | 205 } |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 * Without eliding, text that is too wide isn't drawn at all. | 442 * Without eliding, text that is too wide isn't drawn at all. |
437 * Disable if you feel this causes a performance problem. | 443 * Disable if you feel this causes a performance problem. |
438 * This is a default value that can be overridden in tracks for testing. | 444 * This is a default value that can be overridden in tracks for testing. |
439 * @const | 445 * @const |
440 */ | 446 */ |
441 SHOULD_ELIDE_TEXT: true, | 447 SHOULD_ELIDE_TEXT: true, |
442 | 448 |
443 decorate: function() { | 449 decorate: function() { |
444 this.classList.add('timeline-slice-track'); | 450 this.classList.add('timeline-slice-track'); |
445 this.elidedTitleCache = new ElidedTitleCache(); | 451 this.elidedTitleCache = new ElidedTitleCache(); |
| 452 this.asyncStyle_ = false; |
| 453 }, |
| 454 |
| 455 get asyncStyle() { |
| 456 return this.asyncStyle_; |
| 457 }, |
| 458 |
| 459 set asyncStyle(v) { |
| 460 this.asyncStyle_ = !!v; |
| 461 this.invalidate(); |
446 }, | 462 }, |
447 | 463 |
448 get slices() { | 464 get slices() { |
449 return this.slices_; | 465 return this.slices_; |
450 }, | 466 }, |
451 | 467 |
452 set slices(slices) { | 468 set slices(slices) { |
453 this.slices_ = slices; | 469 this.slices_ = slices; |
454 this.invalidate(); | 470 this.invalidate(); |
455 }, | 471 }, |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 } | 512 } |
497 ctx.strokeStyle = 'rgba(255,0,0,0.25)'; | 513 ctx.strokeStyle = 'rgba(255,0,0,0.25)'; |
498 ctx.stroke(); | 514 ctx.stroke(); |
499 } | 515 } |
500 | 516 |
501 // Begin rendering in world space. | 517 // Begin rendering in world space. |
502 ctx.save(); | 518 ctx.save(); |
503 vp.applyTransformToCanavs(ctx); | 519 vp.applyTransformToCanavs(ctx); |
504 | 520 |
505 // Slices. | 521 // Slices. |
| 522 if (this.asyncStyle_) |
| 523 ctx.globalAlpha = 0.25; |
506 var tr = new tracing.FastRectRenderer(ctx, viewLWorld, 2 * pixWidth, | 524 var tr = new tracing.FastRectRenderer(ctx, viewLWorld, 2 * pixWidth, |
507 2 * pixWidth, viewRWorld, pallette); | 525 2 * pixWidth, viewRWorld, pallette); |
508 tr.setYandH(0, canvasH); | 526 tr.setYandH(0, canvasH); |
509 var slices = this.slices_; | 527 var slices = this.slices_; |
510 for (var i = 0; i < slices.length; ++i) { | 528 for (var i = 0; i < slices.length; ++i) { |
511 var slice = slices[i]; | 529 var slice = slices[i]; |
512 var x = slice.start; | 530 var x = slice.start; |
513 // Less than 0.001 causes short events to disappear when zoomed in. | 531 // Less than 0.001 causes short events to disappear when zoomed in. |
514 var w = Math.max(slice.duration, 0.001); | 532 var w = Math.max(slice.duration, 0.001); |
515 var colorId = slice.selected ? | 533 var colorId = slice.selected ? |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
973 }; | 991 }; |
974 | 992 |
975 return { | 993 return { |
976 TimelineCounterTrack: TimelineCounterTrack, | 994 TimelineCounterTrack: TimelineCounterTrack, |
977 TimelineSliceTrack: TimelineSliceTrack, | 995 TimelineSliceTrack: TimelineSliceTrack, |
978 TimelineThreadTrack: TimelineThreadTrack, | 996 TimelineThreadTrack: TimelineThreadTrack, |
979 TimelineViewportTrack: TimelineViewportTrack, | 997 TimelineViewportTrack: TimelineViewportTrack, |
980 TimelineCpuTrack: TimelineCpuTrack | 998 TimelineCpuTrack: TimelineCpuTrack |
981 }; | 999 }; |
982 }); | 1000 }); |
OLD | NEW |