Commit f214b914 authored by Sigurd Schneider's avatar Sigurd Schneider Committed by Commit Bot

[turbolizer] Various cleanups

- Move helper functions to utils
- Use let/const instead of var
- Fix display bug when schedule view was initially selected

Bug: v8:7327
Notry: true
Change-Id: I7caf3dd17b725a4553d035293716f452b9999ed8
Reviewed-on: https://chromium-review.googlesource.com/c/1396088
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58550}
parent b53dcfd5
......@@ -7,7 +7,7 @@ import { SelectionBroker } from "../src/selection-broker"
import { TextView } from "../src/text-view"
import { SourceResolver } from "./source-resolver";
import { MySelection } from "./selection";
import { anyToString } from "./util";
import { anyToString, interpolate } from "./util";
import { InstructionSelectionHandler } from "./selection-handler";
const toolboxHTML = `<div id="disassembly-toolbox">
......@@ -292,11 +292,6 @@ export class DisassemblyView extends TextView {
return num.toFixed(3).replace(/\.?0+$/, "") + "%";
}
// Interpolate between the given start and end values by a fraction of val/max.
interpolate(val, max, start, end) {
return start + (end - start) * (val / max);
}
processLine(line) {
let view = this;
let fragments = super.processLine(line);
......@@ -326,9 +321,9 @@ export class DisassemblyView extends TextView {
let val = perc - PROF_COLS[i].perc;
let max = PROF_COLS[i + 1].perc - PROF_COLS[i].perc;
col.r = Math.round(view.interpolate(val, max, col1.r, col2.r));
col.g = Math.round(view.interpolate(val, max, col1.g, col2.g));
col.b = Math.round(view.interpolate(val, max, col1.b, col2.b));
col.r = Math.round(interpolate(val, max, col1.r, col2.r));
col.g = Math.round(interpolate(val, max, col1.g, col2.g));
col.b = Math.round(interpolate(val, max, col1.b, col2.b));
break;
}
}
......
This diff is collapsed.
......@@ -111,7 +111,7 @@ export function isIterable(obj: any): obj is Iterable<any> {
&& typeof obj != 'string' && typeof obj[Symbol.iterator] === 'function';
}
export function alignUp(raw:number, multiple:number):number {
export function alignUp(raw: number, multiple: number): number {
return Math.floor((raw + multiple - 1) / multiple) * multiple;
}
......@@ -124,4 +124,9 @@ export function measureText(text: string) {
height: textMeasure.getBBox().height,
};
}
}
// Interpolate between the given start and end values by a fraction of val/max.
export function interpolate(val: number, max: number, start: number, end: number) {
return start + (end - start) * (val / max);
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment