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

Side by Side Diff: tracing/tracing/ui/tracks/model_track.html

Issue 2771723003: [tracing] Move math utilities from base into their own subdirectory (attempt 2) (Closed)
Patch Set: rebase Created 3 years, 9 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
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <!-- 2 <!--
3 Copyright (c) 2013 The Chromium Authors. All rights reserved. 3 Copyright (c) 2013 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be 4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file. 5 found in the LICENSE file.
6 --> 6 -->
7 7
8 <link rel="import" href="/tracing/base/color_scheme.html"> 8 <link rel="import" href="/tracing/base/color_scheme.html">
9 <link rel="import" href="/tracing/ui/base/draw_helpers.html"> 9 <link rel="import" href="/tracing/ui/base/draw_helpers.html">
10 <link rel="import" href="/tracing/ui/base/ui.html"> 10 <link rel="import" href="/tracing/ui/base/ui.html">
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 ModelTrack.VSYNC_DENSITY_TRANSPARENT - ModelTrack.VSYNC_DENSITY_OPAQUE; 44 ModelTrack.VSYNC_DENSITY_TRANSPARENT - ModelTrack.VSYNC_DENSITY_OPAQUE;
45 45
46 /** 46 /**
47 * Generate a zebra striping from a list of times. 47 * Generate a zebra striping from a list of times.
48 * 48 *
49 * @param {!Array.<number>} times A sorted array of timestamps. 49 * @param {!Array.<number>} times A sorted array of timestamps.
50 * @param {number} minTime the lower bound of time to start striping at. 50 * @param {number} minTime the lower bound of time to start striping at.
51 * @param {number} maxTime the upper bound of time to stop striping at. 51 * @param {number} maxTime the upper bound of time to stop striping at.
52 * of |times|. 52 * of |times|.
53 * 53 *
54 * @returns {!Array.<tr.b.Range>} An array of ranges where each element 54 * @returns {!Array.<tr.b.math.Range>} An array of ranges where each element
55 * represents the time range that a stripe covers. Each range is a subset 55 * represents the time range that a stripe covers. Each range is a subset
56 * of the interval [minTime, maxTime]. 56 * of the interval [minTime, maxTime].
57 */ 57 */
58 ModelTrack.generateStripes_ = function(times, minTime, maxTime) { 58 ModelTrack.generateStripes_ = function(times, minTime, maxTime) {
59 if (times.length === 0) return []; 59 if (times.length === 0) return [];
60 60
61 // Find the lowest and highest index within the viewport. 61 // Find the lowest and highest index within the viewport.
62 var lowIndex = 62 var lowIndex =
63 tr.b.findLowIndexInSortedArray(times, tr.b.identity, minTime); 63 tr.b.math.findLowIndexInSortedArray(times, tr.b.identity, minTime);
64 var highIndex = lowIndex - 1; 64 var highIndex = lowIndex - 1;
65 while (times[highIndex + 1] <= maxTime) { 65 while (times[highIndex + 1] <= maxTime) {
66 highIndex++; 66 highIndex++;
67 } 67 }
68 68
69 var stripes = []; 69 var stripes = [];
70 // Must start at an even index and end at an odd index. 70 // Must start at an even index and end at an odd index.
71 for (var i = lowIndex - (lowIndex % 2); i <= highIndex; i += 2) { 71 for (var i = lowIndex - (lowIndex % 2); i <= highIndex; i += 2) {
72 var left = i < lowIndex ? minTime : times[i]; 72 var left = i < lowIndex ? minTime : times[i];
73 var right = i + 1 > highIndex ? maxTime : times[i + 1]; 73 var right = i + 1 > highIndex ? maxTime : times[i + 1];
74 stripes.push(tr.b.Range.fromExplicitRange(left, right)); 74 stripes.push(tr.b.math.Range.fromExplicitRange(left, right));
75 } 75 }
76 76
77 return stripes; 77 return stripes;
78 }; 78 };
79 79
80 80
81 ModelTrack.prototype = { 81 ModelTrack.prototype = {
82 82
83 __proto__: tr.ui.tracks.ContainerTrack.prototype, 83 __proto__: tr.ui.tracks.ContainerTrack.prototype,
84 84
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 } 454 }
455 455
456 var vSyncHighlightColor = 456 var vSyncHighlightColor =
457 new tr.b.Color(ColorScheme.getColorForReservedNameAsString( 457 new tr.b.Color(ColorScheme.getColorForReservedNameAsString(
458 'vsync_highlight_color')); 458 'vsync_highlight_color'));
459 459
460 var stripeRange = stripes[stripes.length - 1].max - stripes[0].min; 460 var stripeRange = stripes[stripes.length - 1].max - stripes[0].min;
461 var stripeDensity = 461 var stripeDensity =
462 stripeRange ? stripes.length / (dt.scaleX * stripeRange) : 0; 462 stripeRange ? stripes.length / (dt.scaleX * stripeRange) : 0;
463 var clampedStripeDensity = 463 var clampedStripeDensity =
464 tr.b.clamp(stripeDensity, ModelTrack.VSYNC_DENSITY_OPAQUE, 464 tr.b.math.clamp(stripeDensity, ModelTrack.VSYNC_DENSITY_OPAQUE,
465 ModelTrack.VSYNC_DENSITY_TRANSPARENT); 465 ModelTrack.VSYNC_DENSITY_TRANSPARENT);
466 var opacity = 466 var opacity =
467 (ModelTrack.VSYNC_DENSITY_TRANSPARENT - clampedStripeDensity) / 467 (ModelTrack.VSYNC_DENSITY_TRANSPARENT - clampedStripeDensity) /
468 ModelTrack.VSYNC_DENSITY_RANGE; 468 ModelTrack.VSYNC_DENSITY_RANGE;
469 if (opacity === 0) { 469 if (opacity === 0) {
470 return; 470 return;
471 } 471 }
472 472
473 var pixelRatio = window.devicePixelRatio || 1; 473 var pixelRatio = window.devicePixelRatio || 1;
474 var height = viewHeight * pixelRatio; 474 var height = viewHeight * pixelRatio;
(...skipping 17 matching lines...) Expand all
492 492
493 return bounds.top - canvasBounds.top + (bounds.height / 2); 493 return bounds.top - canvasBounds.top + (bounds.height / 2);
494 }, 494 },
495 495
496 addIntersectingEventsInRangeToSelectionInWorldSpace: function( 496 addIntersectingEventsInRangeToSelectionInWorldSpace: function(
497 loWX, hiWX, viewPixWidthWorld, selection) { 497 loWX, hiWX, viewPixWidthWorld, selection) {
498 function onPickHit(instantEvent) { 498 function onPickHit(instantEvent) {
499 selection.push(instantEvent); 499 selection.push(instantEvent);
500 } 500 }
501 var instantEventWidth = 3 * viewPixWidthWorld; 501 var instantEventWidth = 3 * viewPixWidthWorld;
502 tr.b.iterateOverIntersectingIntervals(this.model_.instantEvents, 502 tr.b.math.iterateOverIntersectingIntervals(this.model_.instantEvents,
503 function(x) { return x.start; }, 503 function(x) { return x.start; },
504 function(x) { return x.duration + instantEventWidth; }, 504 function(x) { return x.duration + instantEventWidth; },
505 loWX, hiWX, 505 loWX, hiWX,
506 onPickHit.bind(this)); 506 onPickHit.bind(this));
507 507
508 tr.ui.tracks.ContainerTrack.prototype. 508 tr.ui.tracks.ContainerTrack.prototype.
509 addIntersectingEventsInRangeToSelectionInWorldSpace. 509 addIntersectingEventsInRangeToSelectionInWorldSpace.
510 apply(this, arguments); 510 apply(this, arguments);
511 }, 511 },
512 512
513 addClosestEventToSelection: function(worldX, worldMaxDist, loY, hiY, 513 addClosestEventToSelection: function(worldX, worldMaxDist, loY, hiY,
514 selection) { 514 selection) {
515 this.addClosestInstantEventToSelection(this.model_.instantEvents, 515 this.addClosestInstantEventToSelection(this.model_.instantEvents,
516 worldX, worldMaxDist, selection); 516 worldX, worldMaxDist, selection);
517 tr.ui.tracks.ContainerTrack.prototype.addClosestEventToSelection. 517 tr.ui.tracks.ContainerTrack.prototype.addClosestEventToSelection.
518 apply(this, arguments); 518 apply(this, arguments);
519 } 519 }
520 }; 520 };
521 521
522 return { 522 return {
523 ModelTrack, 523 ModelTrack,
524 }; 524 };
525 }); 525 });
526 </script> 526 </script>
OLDNEW
« no previous file with comments | « tracing/tracing/ui/tracks/letter_dot_track.html ('k') | tracing/tracing/ui/tracks/model_track_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698