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

Side by Side Diff: Source/devtools/front_end/components/FlameChart.js

Issue 319363002: DevTools: CPUFlameChart: stick function entry color to the function name and url. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 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
« no previous file with comments | « no previous file | Source/devtools/front_end/profiler/CPUProfileFlameChart.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 * @param {!{min: number, max: number, count: number}|number=} hueSpace 225 * @param {!{min: number, max: number, count: number}|number=} hueSpace
226 * @param {!{min: number, max: number, count: number}|number=} satSpace 226 * @param {!{min: number, max: number, count: number}|number=} satSpace
227 * @param {!{min: number, max: number, count: number}|number=} lightnessSpace 227 * @param {!{min: number, max: number, count: number}|number=} lightnessSpace
228 */ 228 */
229 WebInspector.FlameChart.ColorGenerator = function(hueSpace, satSpace, lightnessS pace) 229 WebInspector.FlameChart.ColorGenerator = function(hueSpace, satSpace, lightnessS pace)
230 { 230 {
231 this._hueSpace = hueSpace || { min: 0, max: 360, count: 20 }; 231 this._hueSpace = hueSpace || { min: 0, max: 360, count: 20 };
232 this._satSpace = satSpace || 67; 232 this._satSpace = satSpace || 67;
233 this._lightnessSpace = lightnessSpace || 80; 233 this._lightnessSpace = lightnessSpace || 80;
234 this._colors = {}; 234 this._colors = {};
235 this._currentColorIndex = 0;
236 } 235 }
237 236
238 WebInspector.FlameChart.ColorGenerator.prototype = { 237 WebInspector.FlameChart.ColorGenerator.prototype = {
239 /** 238 /**
240 * @param {string} id 239 * @param {string} id
241 * @param {string|!CanvasGradient} color 240 * @param {string|!CanvasGradient} color
242 */ 241 */
243 setColorForID: function(id, color) 242 setColorForID: function(id, color)
244 { 243 {
245 this._colors[id] = color; 244 this._colors[id] = color;
246 }, 245 },
247 246
248 /** 247 /**
249 * @param {string} id 248 * @param {string} id
250 * @return {string} 249 * @return {string}
251 */ 250 */
252 colorForID: function(id) 251 colorForID: function(id)
253 { 252 {
254 var color = this._colors[id]; 253 var color = this._colors[id];
255 if (!color) { 254 if (!color) {
256 color = this._createColor(this._currentColorIndex++); 255 color = this._generateColorForID(id);
257 this._colors[id] = color; 256 this._colors[id] = color;
258 } 257 }
259 return color; 258 return color;
260 }, 259 },
261 260
262 /** 261 /**
263 * @param {number} index 262 * @param {string} id
264 * @return {string} 263 * @return {string}
265 */ 264 */
266 _createColor: function(index) 265 _generateColorForID: function(id)
267 { 266 {
267 var index = 0;
268 var pow = 1;
269 for (var i = 0; i < id.length; ++i)
alph 2014/06/07 13:28:22 index = id.hashCode();
270 index += id.charCodeAt(i);
268 var h = this._indexToValueInSpace(index, this._hueSpace); 271 var h = this._indexToValueInSpace(index, this._hueSpace);
269 var s = this._indexToValueInSpace(index, this._satSpace); 272 var s = this._indexToValueInSpace(index, this._satSpace);
270 var l = this._indexToValueInSpace(index, this._lightnessSpace); 273 var l = this._indexToValueInSpace(index, this._lightnessSpace);
271 return "hsl(" + h + ", " + s + "%, " + l + "%)"; 274 return "hsl(" + h + ", " + s + "%, " + l + "%)";
272 }, 275 },
273 276
274 /** 277 /**
275 * @param {number} index 278 * @param {number} index
276 * @param {!{min: number, max: number, count: number}|number} space 279 * @param {!{min: number, max: number, count: number}|number} space
277 * @return {number} 280 * @return {number}
278 */ 281 */
279 _indexToValueInSpace: function(index, space) 282 _indexToValueInSpace: function(index, space)
280 { 283 {
281 if (typeof space === "number") 284 if (typeof space === "number")
282 return space; 285 return space;
283 index %= space.count; 286 index %= space.count;
284 return space.min + index / space.count * (space.max - space.min); 287 return space.min + Math.floor(index / space.count * (space.max - space.m in));
285 } 288 }
286 } 289 }
287 290
288 291
289 /** 292 /**
290 * @constructor 293 * @constructor
291 * @implements {WebInspector.TimelineGrid.Calculator} 294 * @implements {WebInspector.TimelineGrid.Calculator}
292 */ 295 */
293 WebInspector.FlameChart.Calculator = function() 296 WebInspector.FlameChart.Calculator = function()
294 { 297 {
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 reset: function() 961 reset: function()
959 { 962 {
960 this._highlightedEntryIndex = -1; 963 this._highlightedEntryIndex = -1;
961 this._selectedEntryIndex = -1; 964 this._selectedEntryIndex = -1;
962 this._textWidth = {}; 965 this._textWidth = {};
963 this.update(); 966 this.update();
964 }, 967 },
965 968
966 __proto__: WebInspector.HBox.prototype 969 __proto__: WebInspector.HBox.prototype
967 } 970 }
OLDNEW
« no previous file with comments | « no previous file | Source/devtools/front_end/profiler/CPUProfileFlameChart.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698