| OLD | NEW |
| 1 /** | 1 /** |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 } | 303 } |
| 304 | 304 |
| 305 WebInspector.FlameChart.Events = { | 305 WebInspector.FlameChart.Events = { |
| 306 EntrySelected: "EntrySelected" | 306 EntrySelected: "EntrySelected" |
| 307 } | 307 } |
| 308 | 308 |
| 309 | 309 |
| 310 /** | 310 /** |
| 311 * @constructor | 311 * @constructor |
| 312 * @param {!{min: number, max: number}|number=} hueSpace | 312 * @param {!{min: number, max: number}|number=} hueSpace |
| 313 * @param {!{min: number, max: number, count: number}|number=} satSpace | 313 * @param {!{min: number, max: number, count: (number|undefined)}|number=} satSp
ace |
| 314 * @param {!{min: number, max: number, count: number}|number=} lightnessSpace | 314 * @param {!{min: number, max: number, count: (number|undefined)}|number=} light
nessSpace |
| 315 * @param {!{min: number, max: number, count: number}|number=} alphaSpace | 315 * @param {!{min: number, max: number, count: (number|undefined)}|number=} alpha
Space |
| 316 */ | 316 */ |
| 317 WebInspector.FlameChart.ColorGenerator = function(hueSpace, satSpace, lightnessS
pace, alphaSpace) | 317 WebInspector.FlameChart.ColorGenerator = function(hueSpace, satSpace, lightnessS
pace, alphaSpace) |
| 318 { | 318 { |
| 319 this._hueSpace = hueSpace || { min: 0, max: 360 }; | 319 this._hueSpace = hueSpace || { min: 0, max: 360 }; |
| 320 this._satSpace = satSpace || 67; | 320 this._satSpace = satSpace || 67; |
| 321 this._lightnessSpace = lightnessSpace || 80; | 321 this._lightnessSpace = lightnessSpace || 80; |
| 322 this._alphaSpace = alphaSpace || 1; | 322 this._alphaSpace = alphaSpace || 1; |
| 323 /** @type {!Map<string, string>} */ | 323 /** @type {!Map<string, string>} */ |
| 324 this._colors = new Map(); | 324 this._colors = new Map(); |
| 325 } | 325 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 348 return color; | 348 return color; |
| 349 }, | 349 }, |
| 350 | 350 |
| 351 /** | 351 /** |
| 352 * @param {string} id | 352 * @param {string} id |
| 353 * @return {string} | 353 * @return {string} |
| 354 */ | 354 */ |
| 355 _generateColorForID: function(id) | 355 _generateColorForID: function(id) |
| 356 { | 356 { |
| 357 var hash = String.hashCode(id); | 357 var hash = String.hashCode(id); |
| 358 var h = this._indexToDistinctValueInSpace(this._colors.size, this._hueSp
ace); | 358 var h = this._indexToValueInSpace(hash, this._hueSpace); |
| 359 var s = this._indexToValueInSpace(hash, this._satSpace); | 359 var s = this._indexToValueInSpace(hash >> 8, this._satSpace); |
| 360 var l = this._indexToValueInSpace(hash, this._lightnessSpace); | 360 var l = this._indexToValueInSpace(hash >> 16, this._lightnessSpace); |
| 361 var a = this._indexToValueInSpace(hash, this._alphaSpace); | 361 var a = this._indexToValueInSpace(hash >> 24, this._alphaSpace); |
| 362 return "hsla(" + h + ", " + s + "%, " + l + "%, " + a + ")"; | 362 return "hsla(" + h + ", " + s + "%, " + l + "%, " + a + ")"; |
| 363 }, | 363 }, |
| 364 | 364 |
| 365 /** | 365 /** |
| 366 * @param {number} index | 366 * @param {number} index |
| 367 * @param {!{min: number, max: number, count: number}|number} space | 367 * @param {!{min: number, max: number, count: (number|undefined)}|number} sp
ace |
| 368 * @return {number} | 368 * @return {number} |
| 369 */ | 369 */ |
| 370 _indexToValueInSpace: function(index, space) | 370 _indexToValueInSpace: function(index, space) |
| 371 { | 371 { |
| 372 if (typeof space === "number") | 372 if (typeof space === "number") |
| 373 return space; | 373 return space; |
| 374 index %= space.count; | 374 var count = space.count || space.max - space.min; |
| 375 return space.min + Math.floor(index / (space.count - 1) * (space.max - s
pace.min)); | 375 index %= count; |
| 376 }, | 376 return space.min + Math.floor(index / (count - 1) * (space.max - space.m
in)); |
| 377 | |
| 378 /** | |
| 379 * @param {number} index | |
| 380 * @param {!{min: number, max: number}|number} space | |
| 381 * @return {number} | |
| 382 */ | |
| 383 _indexToDistinctValueInSpace: function(index, space) | |
| 384 { | |
| 385 if (typeof space === "number") | |
| 386 return space; | |
| 387 index |= 0; | |
| 388 var result = 0; | |
| 389 var count = 0; | |
| 390 // Reverse bits in index. | |
| 391 do { | |
| 392 result = (result << 1) | (index & 1); | |
| 393 index >>= 1; | |
| 394 ++count; | |
| 395 } while (index); | |
| 396 result /= 1 << count; | |
| 397 return space.min + Math.floor(result * (space.max - space.min)); | |
| 398 } | 377 } |
| 399 } | 378 } |
| 400 | 379 |
| 401 | 380 |
| 402 /** | 381 /** |
| 403 * @constructor | 382 * @constructor |
| 404 * @implements {WebInspector.TimelineGrid.Calculator} | 383 * @implements {WebInspector.TimelineGrid.Calculator} |
| 405 */ | 384 */ |
| 406 WebInspector.FlameChart.Calculator = function() | 385 WebInspector.FlameChart.Calculator = function() |
| 407 { | 386 { |
| (...skipping 1563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1971 this.update(); | 1950 this.update(); |
| 1972 }, | 1951 }, |
| 1973 | 1952 |
| 1974 _enabled: function() | 1953 _enabled: function() |
| 1975 { | 1954 { |
| 1976 return this._rawTimelineDataLength !== 0; | 1955 return this._rawTimelineDataLength !== 0; |
| 1977 }, | 1956 }, |
| 1978 | 1957 |
| 1979 __proto__: WebInspector.HBox.prototype | 1958 __proto__: WebInspector.HBox.prototype |
| 1980 } | 1959 } |
| OLD | NEW |