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

Unified Diff: third_party/WebKit/Source/devtools/front_end/ui_lazy/FlameChart.js

Issue 1794473002: DevTools: Make the colors for the same URL be the same for all recording. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/platform/utilities.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/devtools/front_end/ui_lazy/FlameChart.js
diff --git a/third_party/WebKit/Source/devtools/front_end/ui_lazy/FlameChart.js b/third_party/WebKit/Source/devtools/front_end/ui_lazy/FlameChart.js
index e1adb37f900b8f226572636d60f727be9996cc34..6d8e58c9f470c7291fa286324213da89ae0cd4b0 100644
--- a/third_party/WebKit/Source/devtools/front_end/ui_lazy/FlameChart.js
+++ b/third_party/WebKit/Source/devtools/front_end/ui_lazy/FlameChart.js
@@ -310,9 +310,9 @@ WebInspector.FlameChart.Events = {
/**
* @constructor
* @param {!{min: number, max: number}|number=} hueSpace
- * @param {!{min: number, max: number, count: number}|number=} satSpace
- * @param {!{min: number, max: number, count: number}|number=} lightnessSpace
- * @param {!{min: number, max: number, count: number}|number=} alphaSpace
+ * @param {!{min: number, max: number, count: (number|undefined)}|number=} satSpace
+ * @param {!{min: number, max: number, count: (number|undefined)}|number=} lightnessSpace
+ * @param {!{min: number, max: number, count: (number|undefined)}|number=} alphaSpace
*/
WebInspector.FlameChart.ColorGenerator = function(hueSpace, satSpace, lightnessSpace, alphaSpace)
{
@@ -355,46 +355,25 @@ WebInspector.FlameChart.ColorGenerator.prototype = {
_generateColorForID: function(id)
{
var hash = String.hashCode(id);
- var h = this._indexToDistinctValueInSpace(this._colors.size, this._hueSpace);
- var s = this._indexToValueInSpace(hash, this._satSpace);
- var l = this._indexToValueInSpace(hash, this._lightnessSpace);
- var a = this._indexToValueInSpace(hash, this._alphaSpace);
+ var h = this._indexToValueInSpace(hash, this._hueSpace);
+ var s = this._indexToValueInSpace(hash >> 8, this._satSpace);
+ var l = this._indexToValueInSpace(hash >> 16, this._lightnessSpace);
+ var a = this._indexToValueInSpace(hash >> 24, this._alphaSpace);
return "hsla(" + h + ", " + s + "%, " + l + "%, " + a + ")";
},
/**
* @param {number} index
- * @param {!{min: number, max: number, count: number}|number} space
+ * @param {!{min: number, max: number, count: (number|undefined)}|number} space
* @return {number}
*/
_indexToValueInSpace: function(index, space)
{
if (typeof space === "number")
return space;
- index %= space.count;
- return space.min + Math.floor(index / (space.count - 1) * (space.max - space.min));
- },
-
- /**
- * @param {number} index
- * @param {!{min: number, max: number}|number} space
- * @return {number}
- */
- _indexToDistinctValueInSpace: function(index, space)
- {
- if (typeof space === "number")
- return space;
- index |= 0;
- var result = 0;
- var count = 0;
- // Reverse bits in index.
- do {
- result = (result << 1) | (index & 1);
- index >>= 1;
- ++count;
- } while (index);
- result /= 1 << count;
- return space.min + Math.floor(result * (space.max - space.min));
+ var count = space.count || space.max - space.min;
+ index %= count;
+ return space.min + Math.floor(index / (count - 1) * (space.max - space.min));
}
}
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/platform/utilities.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698