Format files to pass linter checks
Test: N/A
Change-Id: I0a9888428a8af56f075678a6f6bf02e0bf33eb8b
diff --git a/tools/winscope/src/LogEntry.vue b/tools/winscope/src/LogEntry.vue
index 5091200..90f41d7 100644
--- a/tools/winscope/src/LogEntry.vue
+++ b/tools/winscope/src/LogEntry.vue
@@ -56,10 +56,6 @@
},
},
data() {
- if (!this.source?.level) {
- console.log(this.source);
- }
-
return {
levelIcons: {
[logLevel.INFO]: 'info_outline',
diff --git a/tools/winscope/src/Rects.vue b/tools/winscope/src/Rects.vue
index 0e3f1c5..06d23a4 100644
--- a/tools/winscope/src/Rects.vue
+++ b/tools/winscope/src/Rects.vue
@@ -14,8 +14,12 @@
-->
<template>
<div class="bounds" :style="boundsStyle">
- <div class="rect" v-for="r in rects" :style="rectToStyle(r)"
- @click="onClick(r)">
+ <div
+ class="rect" v-for="r in rects"
+ :style="rectToStyle(r)"
+ @click="onClick(r)"
+ v-bind:key="`${r.left}-${r.right}-${r.top}-${r.bottom}-${r.ref.name}`"
+ >
<span class="label">{{r.label}}</span>
</div>
<div class="highlight" v-if="highlight" :style="rectToStyle(highlight)" />
@@ -24,12 +28,13 @@
<script>
-import { multiply_rect } from './matrix_utils.js'
+// eslint-disable-next-line camelcase
+import {multiply_rect} from './matrix_utils.js';
export default {
name: 'rects',
props: ['bounds', 'rects', 'highlight'],
- data () {
+ data() {
return {
desiredHeight: 800,
desiredWidth: 400,
@@ -40,40 +45,43 @@
if (this.bounds) {
return this.bounds;
}
- var width = Math.max(...this.rects.map((r) => multiply_rect(r.transform, r).right));
- var height = Math.max(...this.rects.map((r) => multiply_rect(r.transform, r).bottom));
+ const width = Math.max(
+ ...this.rects.map((r) => multiply_rect(r.transform, r).right));
+ const height = Math.max(
+ ...this.rects.map((r) => multiply_rect(r.transform, r).bottom));
return {width, height};
},
boundsStyle() {
return this.rectToStyle({top: 0, left: 0, right: this.boundsC.width,
- bottom: this.boundsC.height});
+ bottom: this.boundsC.height});
},
},
methods: {
- s(sourceCoordinate) { // translate source into target coordinates
- var scale;
- if(this.boundsC.width < this.boundsC.height) {
- scale = this.desiredHeight / this.boundsC.height;
- } else {
- scale = this.desiredWidth / this.boundsC.width;
- }
+ s(sourceCoordinate) { // translate source into target coordinates
+ let scale;
+ if (this.boundsC.width < this.boundsC.height) {
+ scale = this.desiredHeight / this.boundsC.height;
+ } else {
+ scale = this.desiredWidth / this.boundsC.width;
+ }
return sourceCoordinate * scale;
},
rectToStyle(r) {
- var x = this.s(r.left);
- var y = this.s(r.top);
- var w = this.s(r.right) - this.s(r.left);
- var h = this.s(r.bottom) - this.s(r.top);
- var t = r.transform;
- var tr = t ? `matrix(${t.dsdx}, ${t.dtdx}, ${t.dsdy}, ${t.dtdy}, ${this.s(t.tx)}, ${this.s(t.ty)})` : '';
+ const x = this.s(r.left);
+ const y = this.s(r.top);
+ const w = this.s(r.right) - this.s(r.left);
+ const h = this.s(r.bottom) - this.s(r.top);
+ const t = r.transform;
+ const tr = t ? `matrix(${t.dsdx}, ${t.dtdx}, ${t.dsdy}, ${t.dtdy}, ` +
+ `${this.s(t.tx)}, ${this.s(t.ty)})` : '';
return `top: ${y}px; left: ${x}px; height: ${h}px; width: ${w}px;` +
- `transform: ${tr}; transform-origin: 0 0;`
+ `transform: ${tr}; transform-origin: 0 0;`;
},
onClick(r) {
this.$emit('rect-click', r.ref);
},
- }
-}
+ },
+};
</script>
<style scoped>
diff --git a/tools/winscope/src/SurfaceFlingerTraceView.vue b/tools/winscope/src/SurfaceFlingerTraceView.vue
index a5f8f30..9b9c6ed 100644
--- a/tools/winscope/src/SurfaceFlingerTraceView.vue
+++ b/tools/winscope/src/SurfaceFlingerTraceView.vue
@@ -18,36 +18,39 @@
</template>
<script>
-import TraceView from "@/TraceView.vue"
+import TraceView from '@/TraceView.vue';
export default {
- name: "WindowManagerTraceView",
- props: ["store", "file"],
+ name: 'WindowManagerTraceView',
+ props: ['store', 'file'],
components: {
- TraceView
+ TraceView,
},
methods: {
summarizer(layer) {
const summary = [];
if (layer.invisibleDueTo) {
- summary.push({key: "Invisible due to", value: layer.invisibleDueTo});
+ summary.push({key: 'Invisible due to', value: layer.invisibleDueTo});
}
if (layer.occludedBy?.length > 0) {
- summary.push({key: "Occluded by", value: layer.occludedBy.join(", ")});
+ summary.push({key: 'Occluded by', value: layer.occludedBy.join(', ')});
}
if (layer.partiallyOccludedBy?.length > 0) {
- summary.push({key: "Partially occluded by", value: layer.partiallyOccludedBy.join(", ")});
+ summary.push({
+ key: 'Partially occluded by',
+ value: layer.partiallyOccludedBy.join(', '),
+ });
}
if (layer.coveredBy?.length > 0) {
- summary.push({key: "Covered by", value: layer.coveredBy.join(", ")});
+ summary.push({key: 'Covered by', value: layer.coveredBy.join(', ')});
}
return summary;
},
- }
-}
-</script>
\ No newline at end of file
+ },
+};
+</script>
diff --git a/tools/winscope/src/TraceView.vue b/tools/winscope/src/TraceView.vue
index 78d9504..02fde4f 100644
--- a/tools/winscope/src/TraceView.vue
+++ b/tools/winscope/src/TraceView.vue
@@ -15,12 +15,21 @@
<template>
<md-card-content class="container">
<div class="rects" v-if="hasScreenView">
- <rects :bounds="bounds" :rects="rects" :highlight="highlight" @rect-click="onRectClick" />
+ <rects
+ :bounds="bounds"
+ :rects="rects"
+ :highlight="highlight"
+ @rect-click="onRectClick"
+ />
</div>
<div class="hierarchy">
<flat-card>
- <md-content md-tag="md-toolbar" md-elevation="0" class="card-toolbar md-transparent md-dense">
+ <md-content
+ md-tag="md-toolbar"
+ md-elevation="0"
+ class="card-toolbar md-transparent md-dense"
+ >
<h2 class="md-title" style="flex: 1;">Hierarchy</h2>
<md-checkbox
v-model="showHierachyDiff"
@@ -28,7 +37,9 @@
>
Show Diff
</md-checkbox>
- <md-checkbox v-model="store.simplifyNames">Simplify names</md-checkbox>
+ <md-checkbox v-model="store.simplifyNames">
+ Simplify names
+ </md-checkbox>
<md-checkbox v-model="store.onlyVisible">Only visible</md-checkbox>
<md-checkbox v-model="store.flattened">Flat</md-checkbox>
<md-field md-inline class="filter">
@@ -55,7 +66,11 @@
<div class="properties">
<flat-card>
- <md-content md-tag="md-toolbar" md-elevation="0" class="card-toolbar md-transparent md-dense">
+ <md-content
+ md-tag="md-toolbar"
+ md-elevation="0"
+ class="card-toolbar md-transparent md-dense"
+ >
<h2 class="md-title" style="flex: 1">Properties</h2>
<md-checkbox
v-model="showPropertiesDiff"
@@ -71,6 +86,7 @@
<div class="properties-content">
<div v-if="elementSummary" class="element-summary">
<div v-for="elem in elementSummary" v-bind:key="elem.key">
+ <!-- eslint-disable-next-line max-len -->
<span class="key">{{ elem.key }}:</span> <span class="value">{{ elem.value }}</span>
</div>
</div>
@@ -97,28 +113,28 @@
</md-card-content>
</template>
<script>
-import TreeView from './TreeView.vue'
-import Timeline from './Timeline.vue'
-import Rects from './Rects.vue'
-import FlatCard from './components/FlatCard.vue'
-import PropertiesTreeElement from './PropertiesTreeElement.vue'
+import TreeView from './TreeView.vue';
+import Rects from './Rects.vue';
+import FlatCard from './components/FlatCard.vue';
+import PropertiesTreeElement from './PropertiesTreeElement.vue';
-import { ObjectTransformer } from './transform.js'
-import { DiffGenerator, defaultModifiedCheck } from './utils/diff.js'
-import { format_transform_type, is_simple_transform } from './matrix_utils.js'
-import { TRACE_TYPES, DUMP_TYPES } from './decode.js'
-import { stableIdCompatibilityFixup } from './utils/utils.js'
-import { CompatibleFeatures } from './utils/compatibility.js'
+import {ObjectTransformer} from './transform.js';
+import {DiffGenerator, defaultModifiedCheck} from './utils/diff.js';
+// eslint-disable-next-line camelcase
+import {format_transform_type, is_simple_transform} from './matrix_utils.js';
+import {TRACE_TYPES, DUMP_TYPES} from './decode.js';
+import {stableIdCompatibilityFixup} from './utils/utils.js';
+import {CompatibleFeatures} from './utils/compatibility.js';
function formatColorTransform(vals) {
- const fixedVals = vals.map(v => v.toFixed(1));
- var formatted = ``;
- for (var i = 0; i < fixedVals.length; i += 4) {
- formatted += `[`;
- formatted += fixedVals.slice(i, i + 4).join(", ");
- formatted += `] `;
- }
- return formatted;
+ const fixedVals = vals.map((v) => v.toFixed(1));
+ let formatted = ``;
+ for (let i = 0; i < fixedVals.length; i += 4) {
+ formatted += `[`;
+ formatted += fixedVals.slice(i, i + 4).join(', ');
+ formatted += `] `;
+ }
+ return formatted;
}
function formatProto(obj) {
@@ -128,7 +144,8 @@
if (obj.$type.name === 'RectProto') {
return `(${obj.left}, ${obj.top}) - (${obj.right}, ${obj.bottom})`;
} else if (obj.$type.name === 'FloatRectProto') {
- return `(${obj.left.toFixed(3)}, ${obj.top.toFixed(3)}) - (${obj.right.toFixed(3)}, ${obj.bottom.toFixed(3)})`;
+ return `(${obj.left.toFixed(3)}, ${obj.top.toFixed(3)}) - ` +
+ `(${obj.right.toFixed(3)}, ${obj.bottom.toFixed(3)})`;
} else if (obj.$type.name === 'PositionProto') {
return `(${obj.x.toFixed(3)}, ${obj.y.toFixed(3)})`;
} else if (obj.$type.name === 'SizeProto') {
@@ -136,13 +153,15 @@
} else if (obj.$type.name === 'ColorProto') {
return `r:${obj.r} g:${obj.g} \n b:${obj.b} a:${obj.a}`;
} else if (obj.$type.name === 'TransformProto') {
- var transform_type = format_transform_type(obj);
+ const transformType = format_transform_type(obj);
if (is_simple_transform(obj)) {
- return `${transform_type}`;
+ return `${transformType}`;
}
- return `${transform_type} dsdx:${obj.dsdx.toFixed(3)} dtdx:${obj.dtdx.toFixed(3)} dsdy:${obj.dsdy.toFixed(3)} dtdy:${obj.dtdy.toFixed(3)}`;
+ return `${transformType} dsdx:${obj.dsdx.toFixed(3)} ` +
+ `dtdx:${obj.dtdx.toFixed(3)} dsdy:${obj.dsdy.toFixed(3)} ` +
+ `dtdy:${obj.dtdy.toFixed(3)}`;
} else if (obj.$type.name === 'ColorTransformProto') {
- var formated = formatColorTransform(obj.val);
+ const formated = formatColorTransform(obj.val);
return `${formated}`;
}
}
@@ -171,8 +190,8 @@
props: ['store', 'file', 'summarizer'],
data() {
return {
- propertyFilterString: "",
- hierarchyPropertyFilterString:"",
+ propertyFilterString: '',
+ hierarchyPropertyFilterString: '',
selectedTree: null,
hierarchySelected: null,
lastSelectedStableId: null,
@@ -184,7 +203,7 @@
showHierachyDiff: false,
showPropertiesDiff: false,
PropertiesTreeElement,
- }
+ };
},
methods: {
itemSelected(item) {
@@ -196,9 +215,9 @@
},
getTransformedProperties(item) {
const transformer = new ObjectTransformer(
- item.obj,
- item.name,
- stableIdCompatibilityFixup(item),
+ item.obj,
+ item.name,
+ stableIdCompatibilityFixup(item),
).setOptions({
skip: item.skip,
formatter: formatProto,
@@ -222,12 +241,12 @@
}
return new DiffGenerator(this.item)
- .compareWith(this.getDataWithOffset(-1))
- .withUniqueNodeId(node => {
- return node.stableId;
- })
- .withModifiedCheck(defaultModifiedCheck)
- .generateDiffTree();
+ .compareWith(this.getDataWithOffset(-1))
+ .withUniqueNodeId((node) => {
+ return node.stableId;
+ })
+ .withModifiedCheck(defaultModifiedCheck)
+ .generateDiffTree();
},
setData(item) {
this.item = item;
@@ -240,13 +259,13 @@
this.selectedTree = null;
this.highlight = null;
- function find_item(item, stableId) {
+ function findItem(item, stableId) {
if (item.stableId === stableId) {
return item;
}
if (Array.isArray(item.children)) {
- for (var child of item.children) {
- var found = find_item(child, stableId);
+ for (const child of item.children) {
+ const found = findItem(child, stableId);
if (found) {
return found;
}
@@ -256,7 +275,7 @@
}
if (this.lastSelectedStableId) {
- var found = find_item(item, this.lastSelectedStableId);
+ const found = findItem(item, this.lastSelectedStableId);
if (found) {
this.itemSelected(found);
}
@@ -284,23 +303,23 @@
const id = entry.stableId;
if (!id) {
- throw new Error("Entry has no stableId...");
+ throw new Error('Entry has no stableId...');
}
const prevTree = this.getDataWithOffset(-1);
if (!prevTree) {
- console.warn("No previous entry");
+ console.warn('No previous entry');
return null;
}
const prevEntry = findEntryInTree(prevTree, id);
if (!prevEntry) {
- console.warn("Didn't exist in last entry");
+ console.warn('Didn\'t exist in last entry');
// TODO: Maybe handle this in some way.
}
return prevEntry;
- }
+ },
},
created() {
this.setData(this.file.data[this.file.selectedIndex ?? 0]);
@@ -314,24 +333,27 @@
},
showPropertiesDiff() {
if (this.hierarchySelected) {
- this.selectedTree = this.getTransformedProperties(this.hierarchySelected);
+ this.selectedTree =
+ this.getTransformedProperties(this.hierarchySelected);
}
},
},
computed: {
diffVisualizationAvailable() {
return CompatibleFeatures.DiffVisualization && (
- this.file.type == TRACE_TYPES.WINDOW_MANAGER ||
+ this.file.type == TRACE_TYPES.WINDOW_MANAGER ||
this.file.type == TRACE_TYPES.SURFACE_FLINGER
- );
+ );
},
selectedIndex() {
return this.file.selectedIndex;
},
hierarchyFilter() {
- var hierarchyPropertyFilter = getFilter(this.hierarchyPropertyFilterString);
+ const hierarchyPropertyFilter =
+ getFilter(this.hierarchyPropertyFilterString);
return this.store.onlyVisible ? (c) => {
- return c.visible && hierarchyPropertyFilter(c);} : hierarchyPropertyFilter;
+ return c.visible && hierarchyPropertyFilter(c);
+ } : hierarchyPropertyFilter;
},
propertyFilter() {
return getFilter(this.propertyFilterString);
@@ -348,30 +370,30 @@
}
return this.summarizer(this.hierarchySelected);
- }
+ },
},
components: {
'tree-view': TreeView,
'rects': Rects,
'flat-card': FlatCard,
- }
-}
+ },
+};
function getFilter(filterString) {
- var filterStrings = filterString.split(",");
- var positive = [];
- var negative = [];
+ const filterStrings = filterString.split(',');
+ const positive = [];
+ const negative = [];
filterStrings.forEach((f) => {
- if (f.startsWith("!")) {
- var str = f.substring(1);
+ if (f.startsWith('!')) {
+ const str = f.substring(1);
negative.push((s) => s.indexOf(str) === -1);
} else {
- var str = f;
+ const str = f;
positive.push((s) => s.indexOf(str) !== -1);
}
});
- var filter = (item) => {
- var apply = (f) => f(String(item.name));
+ const filter = (item) => {
+ const apply = (f) => f(String(item.name));
return (positive.length === 0 || positive.some(apply)) &&
(negative.length === 0 || negative.every(apply));
};
diff --git a/tools/winscope/src/decode.js b/tools/winscope/src/decode.js
index 5a33ed1..c3df75d 100644
--- a/tools/winscope/src/decode.js
+++ b/tools/winscope/src/decode.js
@@ -26,7 +26,7 @@
import jsonProtoDefsSysUi from 'frameworks/base/packages/SystemUI/src/com/android/systemui/tracing/sysui_trace.proto';
import jsonProtoDefsLauncher from 'packages/apps/Launcher3/protos/launcher_trace_file.proto';
import protobuf from 'protobufjs';
-import {transform_layers, transform_layers_trace} from './transform_sf.js';
+import {transformLayers, transformLayersTrace} from './transform_sf.js';
import {transform_window_service, transform_window_trace} from './transform_wm.js';
import {transform_transaction_trace, transform_TRANSACTION_EVENTS_TRACE} from './transform_transaction.js';
import {transform_wl_outputstate, transform_wayland_trace} from './transform_wl.js';
@@ -227,7 +227,7 @@
type: FILE_TYPES.SURFACE_FLINGER_TRACE,
mime: 'application/octet-stream',
protoType: SfTraceMessage,
- transform: transform_layers_trace,
+ transform: transformLayersTrace,
timeline: true,
},
},
@@ -249,7 +249,7 @@
type: FILE_TYPES.SURFACE_FLINGER_DUMP,
mime: 'application/octet-stream',
protoType: SfDumpMessage,
- transform: (decoded) => transform_layers(true /* includesCompositionState*/, decoded),
+ transform: (decoded) => transformLayers(true /* includesCompositionState*/, decoded),
timeline: false,
},
},
diff --git a/tools/winscope/src/transform.js b/tools/winscope/src/transform.js
index 552eeb1..d57de61 100644
--- a/tools/winscope/src/transform.js
+++ b/tools/winscope/src/transform.js
@@ -14,99 +14,118 @@
* limitations under the License.
*/
-import { DiffType } from './utils/diff.js';
-import intDefMapping from '../../../../prebuilts/misc/common/winscope/intDefMapping.json';
+import {DiffType} from './utils/diff.js';
+import intDefMapping from
+ '../../../../prebuilts/misc/common/winscope/intDefMapping.json';
// kind - a type used for categorization of different levels
// name - name of the node
-// children - list of child entries. Each child entry is pair list [raw object, nested transform function].
+// children - list of child entries. Each child entry is pair list
+// [raw object, nested transform function].
// bounds - used to calculate the full bounds of parents
// stableId - unique id for an entry. Used to maintain selection across frames.
-function transform({ obj, kind, name, shortName, children, timestamp, rect, bounds, highlight, rects_transform, chips, visible, flattened, stableId }) {
- function call(fn, arg) {
- return (typeof fn == 'function') ? fn(arg) : fn;
- }
- function handle_children(arg, transform) {
- return [].concat(...arg.map((item) => {
- var childrenFunc = item[0];
- var transformFunc = item[1];
- var childs = call(childrenFunc, obj);
- if (childs) {
- if (typeof childs.map != 'function') {
- throw 'Childs should be an array, but is: ' + (typeof childs) + '.'
- }
- return transform ? childs.map(transformFunc) : childs;
- } else {
- return [];
- }
- }));
- }
- function concat(arg, args, argsmap) {
- var validArg = arg !== undefined && arg !== null;
+function transform({
+ obj,
+ kind,
+ name,
+ shortName,
+ children,
+ timestamp,
+ rect,
+ bounds,
+ highlight,
+ rectsTransform,
+ chips,
+ visible,
+ flattened,
+ stableId,
+}) {
+ function call(fn, arg) {
+ return (typeof fn == 'function') ? fn(arg) : fn;
+ }
+ function handleChildren(arg, transform) {
+ return [].concat(...arg.map((item) => {
+ const childrenFunc = item[0];
+ const transformFunc = item[1];
+ const childs = call(childrenFunc, obj);
+ if (childs) {
+ if (typeof childs.map != 'function') {
+ throw new Error(
+ 'Childs should be an array, but is: ' + (typeof childs) + '.');
+ }
+ return transform ? childs.map(transformFunc) : childs;
+ } else {
+ return [];
+ }
+ }));
+ }
+ function concat(arg, args, argsmap) {
+ const validArg = arg !== undefined && arg !== null;
- if (Array.isArray(args)) {
- if (validArg) {
- return [arg].concat(...args.map(argsmap));
- } else {
- return [].concat(...args.map(argsmap));
- }
- } else if (validArg) {
- return [arg];
- } else {
- return undefined;
- }
- }
+ if (Array.isArray(args)) {
+ if (validArg) {
+ return [arg].concat(...args.map(argsmap));
+ } else {
+ return [].concat(...args.map(argsmap));
+ }
+ } else if (validArg) {
+ return [arg];
+ } else {
+ return undefined;
+ }
+ }
- var transformed_children = handle_children(children, true /* transform */);
- rects_transform = (rects_transform === undefined) ? (e) => e : rects_transform;
+ const transformedChildren = handleChildren(children, true /* transform */);
+ rectsTransform = (rectsTransform === undefined) ? (e) => e : rectsTransform;
- var kindResolved = call(kind, obj);
- var nameResolved = call(name, obj);
- var shortNameResolved = call(shortName, obj);
- var rectResolved = call(rect, obj);
- var stableIdResolved = (stableId === undefined) ?
- kindResolved + '|-|' + nameResolved :
- call(stableId, obj);
+ const kindResolved = call(kind, obj);
+ const nameResolved = call(name, obj);
+ const shortNameResolved = call(shortName, obj);
+ const rectResolved = call(rect, obj);
+ // eslint-disable-next-line max-len
+ const stableIdResolved = (stableId === undefined) ? kindResolved + '|-|' + nameResolved : call(stableId, obj);
- var result = {
- kind: kindResolved,
- name: nameResolved,
- shortName: shortNameResolved,
- collapsed: false,
- children: transformed_children,
- obj: obj,
- timestamp: call(timestamp, obj),
- skip: handle_children(children, false /* transform */),
- bounds: call(bounds, obj) || transformed_children.map((e) => e.bounds).find((e) => true) || undefined,
- rect: rectResolved,
- rects: rects_transform(concat(rectResolved, transformed_children, (e) => e.rects)),
- highlight: call(highlight, obj),
- chips: call(chips, obj),
- stableId: stableIdResolved,
- visible: call(visible, obj),
- childrenVisible: transformed_children.some((c) => {
- return c.childrenVisible || c.visible
- }),
- flattened: call(flattened, obj),
- };
+ const result = {
+ kind: kindResolved,
+ name: nameResolved,
+ shortName: shortNameResolved,
+ collapsed: false,
+ children: transformedChildren,
+ obj: obj,
+ timestamp: call(timestamp, obj),
+ skip: handleChildren(children, false /* transform */),
+ bounds: call(bounds, obj) || transformedChildren.map(
+ (e) => e.bounds).find((e) => true) || undefined,
+ rect: rectResolved,
+ rects: rectsTransform(
+ concat(rectResolved, transformedChildren, (e) => e.rects)),
+ highlight: call(highlight, obj),
+ chips: call(chips, obj),
+ stableId: stableIdResolved,
+ visible: call(visible, obj),
+ childrenVisible: transformedChildren.some((c) => {
+ return c.childrenVisible || c.visible;
+ }),
+ flattened: call(flattened, obj),
+ };
- if (rectResolved) {
- rectResolved.ref = result;
- }
+ if (rectResolved) {
+ rectResolved.ref = result;
+ }
- return Object.freeze(result);
+ return Object.freeze(result);
}
function getDiff(val, compareVal) {
- if (val && isTerminal(compareVal)) {
- return { type: DiffType.ADDED };
- } else if (isTerminal(val) && compareVal) {
- return { type: DiffType.DELETED };
- } else if (compareVal != val) {
- return { type: DiffType.MODIFIED };
- } else {
- return { type: DiffType.NONE };
- }
+ if (val && isTerminal(compareVal)) {
+ return {type: DiffType.ADDED};
+ } else if (isTerminal(val) && compareVal) {
+ return {type: DiffType.DELETED};
+ } else if (compareVal != val) {
+ return {type: DiffType.MODIFIED};
+ } else {
+ return {type: DiffType.NONE};
+ }
}
// Represents termination of the object traversal,
@@ -114,276 +133,299 @@
class Terminal { }
function isTerminal(obj) {
- return obj instanceof Terminal;
+ return obj instanceof Terminal;
}
class ObjectTransformer {
- constructor(obj, rootName, stableId) {
- this.obj = obj;
- this.rootName = rootName;
- this.stableId = stableId;
- this.diff = false;
- }
+ constructor(obj, rootName, stableId) {
+ this.obj = obj;
+ this.rootName = rootName;
+ this.stableId = stableId;
+ this.diff = false;
+ }
- setOptions(options) {
- this.options = options;
- return this;
- }
+ setOptions(options) {
+ this.options = options;
+ return this;
+ }
- withDiff(obj, fieldOptions) {
- this.diff = true;
- this.compareWithObj = obj ?? new Terminal();
- this.compareWithFieldOptions = fieldOptions;
- return this;
- }
+ withDiff(obj, fieldOptions) {
+ this.diff = true;
+ this.compareWithObj = obj ?? new Terminal();
+ this.compareWithFieldOptions = fieldOptions;
+ return this;
+ }
- /**
- * Transform the raw JS Object into a TreeView compatible object
- * @param {bool} keepOriginal whether or not to store the original object in
- * the obj property of a tree node for future reference
- * @param {bool} freeze whether or not the returned objected should be frozen
- * to prevent changing any of its properties
- * @param {string} metadataKey the key that contains a node's metadata to be
- * accessible after the transformation
- */
- transform(transformOptions = { keepOriginal: false, freeze: true, metadataKey: null }) {
- const { formatter } = this.options;
- if (!formatter) {
- throw new Error("Missing formatter, please set with setOptions()");
- }
+ /**
+ * Transform the raw JS Object into a TreeView compatible object
+ * @param {Object} transformOptions detailed below
+ * @param {bool} keepOriginal whether or not to store the original object in
+ * the obj property of a tree node for future
+ * reference
+ * @param {bool} freeze whether or not the returned objected should be frozen
+ * to prevent changing any of its properties
+ * @param {string} metadataKey the key that contains a node's metadata to be
+ * accessible after the transformation
+ * @return {Object} the transformed JS object compatible with treeviews.
+ */
+ transform(transformOptions = {
+ keepOriginal: false, freeze: true, metadataKey: null,
+ }) {
+ const {formatter} = this.options;
+ if (!formatter) {
+ throw new Error('Missing formatter, please set with setOptions()');
+ }
- return this._transform(this.obj, this.rootName, null,
- this.compareWithObj, this.rootName, null,
- this.stableId, transformOptions);
- }
+ return this._transform(this.obj, this.rootName, null,
+ this.compareWithObj, this.rootName, null,
+ this.stableId, transformOptions);
+ }
- /**
- * @param {*} metadataKey if 'obj' contains this key, it is excluded from the transformation
- */
- _transformObject(obj, fieldOptions, metadataKey) {
- const { skip, formatter } = this.options;
- const transformedObj = {
- obj: {},
- fieldOptions: {},
- };
- let formatted = undefined;
+ /**
+ * @param {Object} obj the object to transform to a treeview compatible object
+ * @param {Object} fieldOptions options on how to transform fields
+ * @param {*} metadataKey if 'obj' contains this key, it is excluded from the
+ * transformation
+ * @return {Object} the transformed JS object compatible with treeviews.
+ */
+ _transformObject(obj, fieldOptions, metadataKey) {
+ const {skip, formatter} = this.options;
+ const transformedObj = {
+ obj: {},
+ fieldOptions: {},
+ };
+ let formatted = undefined;
- if (skip && skip.includes(obj)) {
- // skip
- } else if ((formatted = formatter(obj))) {
- // Obj has been formatted into a terminal node — has no children.
- transformedObj.obj[formatted] = new Terminal();
- transformedObj.fieldOptions[formatted] = fieldOptions;
- } else if (Array.isArray(obj)) {
- obj.forEach((e, i) => {
- transformedObj.obj["" + i] = e;
- transformedObj.fieldOptions["" + i] = fieldOptions;
- });
- } else if (typeof obj == 'string') {
- // Object is a primitive type — has no children. Set to terminal
- // to differentiate between null object and Terminal element.
- transformedObj.obj[obj] = new Terminal();
- transformedObj.fieldOptions[obj] = fieldOptions;
- } else if (typeof obj == 'number' || typeof obj == 'boolean') {
- // Similar to above — primitive type node has no children.
- transformedObj.obj["" + obj] = new Terminal();
- transformedObj.fieldOptions["" + obj] = fieldOptions;
- } else if (obj && typeof obj == 'object') {
- Object.keys(obj).forEach((key) => {
- if (key === metadataKey) {
- return;
- }
- transformedObj.obj[key] = obj[key];
- transformedObj.fieldOptions[key] = obj.$type?.fields[key]?.options;
- });
- } else if (obj === null) {
- // Null object is a has no children — set to be terminal node.
- transformedObj.obj.null = new Terminal();
- transformedObj.fieldOptions.null = undefined;
- }
+ if (skip && skip.includes(obj)) {
+ // skip
+ } else if ((formatted = formatter(obj))) {
+ // Obj has been formatted into a terminal node — has no children.
+ transformedObj.obj[formatted] = new Terminal();
+ transformedObj.fieldOptions[formatted] = fieldOptions;
+ } else if (Array.isArray(obj)) {
+ obj.forEach((e, i) => {
+ transformedObj.obj['' + i] = e;
+ transformedObj.fieldOptions['' + i] = fieldOptions;
+ });
+ } else if (typeof obj == 'string') {
+ // Object is a primitive type — has no children. Set to terminal
+ // to differentiate between null object and Terminal element.
+ transformedObj.obj[obj] = new Terminal();
+ transformedObj.fieldOptions[obj] = fieldOptions;
+ } else if (typeof obj == 'number' || typeof obj == 'boolean') {
+ // Similar to above — primitive type node has no children.
+ transformedObj.obj['' + obj] = new Terminal();
+ transformedObj.fieldOptions['' + obj] = fieldOptions;
+ } else if (obj && typeof obj == 'object') {
+ Object.keys(obj).forEach((key) => {
+ if (key === metadataKey) {
+ return;
+ }
+ transformedObj.obj[key] = obj[key];
+ transformedObj.fieldOptions[key] = obj.$type?.fields[key]?.options;
+ });
+ } else if (obj === null) {
+ // Null object is a has no children — set to be terminal node.
+ transformedObj.obj.null = new Terminal();
+ transformedObj.fieldOptions.null = undefined;
+ }
- return transformedObj;
- }
+ return transformedObj;
+ }
- /**
- * Extract the value of obj's property with key 'metadataKey'
- * @param {Object} obj the obj we want to extract the metadata from
- * @param {string} metadataKey the key that stores the metadata in the object
- * @return the metadata value or null in no metadata is present
- */
- _getMetadata(obj, metadataKey) {
- if (metadataKey && obj[metadataKey]) {
- const metadata = obj[metadataKey];
- obj[metadataKey] = undefined;
- return metadata;
- } else {
- return null;
- }
- }
+ /**
+ * Extract the value of obj's property with key 'metadataKey'
+ * @param {Object} obj the obj we want to extract the metadata from
+ * @param {string} metadataKey the key that stores the metadata in the object
+ * @return {Object} the metadata value or null in no metadata is present
+ */
+ _getMetadata(obj, metadataKey) {
+ if (metadataKey && obj[metadataKey]) {
+ const metadata = obj[metadataKey];
+ obj[metadataKey] = undefined;
+ return metadata;
+ } else {
+ return null;
+ }
+ }
- _transform(obj, name, fieldOptions,
- compareWithObj, compareWithName, compareWithFieldOptions,
- stableId, transformOptions) {
+ _transform(obj, name, fieldOptions,
+ compareWithObj, compareWithName, compareWithFieldOptions,
+ stableId, transformOptions) {
+ const originalObj = obj;
+ const metadata = this._getMetadata(obj, transformOptions.metadataKey);
- const originalObj = obj;
- const metadata = this._getMetadata(obj, transformOptions.metadataKey);
+ const children = [];
- const children = [];
+ if (!isTerminal(obj)) {
+ const transformedObj =
+ this._transformObject(
+ obj, fieldOptions, transformOptions.metadataKey);
+ obj = transformedObj.obj;
+ fieldOptions = transformedObj.fieldOptions;
+ }
+ if (!isTerminal(compareWithObj)) {
+ const transformedObj =
+ this._transformObject(
+ compareWithObj, compareWithFieldOptions,
+ transformOptions.metadataKey);
+ compareWithObj = transformedObj.obj;
+ compareWithFieldOptions = transformedObj.fieldOptions;
+ }
- if (!isTerminal(obj)) {
- const transformedObj = this._transformObject(obj, fieldOptions, transformOptions.metadataKey);
- obj = transformedObj.obj;
- fieldOptions = transformedObj.fieldOptions;
- }
- if (!isTerminal(compareWithObj)) {
- const transformedObj = this._transformObject(compareWithObj, compareWithFieldOptions, transformOptions.metadataKey);
- compareWithObj = transformedObj.obj;
- compareWithFieldOptions = transformedObj.fieldOptions;
- }
+ for (const key in obj) {
+ if (obj.hasOwnProperty(key)) {
+ let compareWithChild = new Terminal();
+ let compareWithChildName = new Terminal();
+ let compareWithChildFieldOptions = undefined;
+ if (compareWithObj.hasOwnProperty(key)) {
+ compareWithChild = compareWithObj[key];
+ compareWithChildName = key;
+ compareWithChildFieldOptions = compareWithFieldOptions[key];
+ }
+ children.push(this._transform(obj[key], key, fieldOptions[key],
+ compareWithChild, compareWithChildName,
+ compareWithChildFieldOptions,
+ `${stableId}.${key}`, transformOptions));
+ }
+ }
- for (const key in obj) {
- if (obj.hasOwnProperty(key)) {
- let compareWithChild = new Terminal();
- let compareWithChildName = new Terminal();
- let compareWithChildFieldOptions = undefined;
- if (compareWithObj.hasOwnProperty(key)) {
- compareWithChild = compareWithObj[key];
- compareWithChildName = key;
- compareWithChildFieldOptions = compareWithFieldOptions[key];
- }
- children.push(this._transform(obj[key], key, fieldOptions[key],
- compareWithChild, compareWithChildName, compareWithChildFieldOptions,
- `${stableId}.${key}`, transformOptions));
- }
- }
+ // Takes care of adding deleted items to final tree
+ for (const key in compareWithObj) {
+ if (!obj.hasOwnProperty(key) && compareWithObj.hasOwnProperty(key)) {
+ children.push(this._transform(new Terminal(), new Terminal(), undefined,
+ compareWithObj[key], key, compareWithFieldOptions[key],
+ `${stableId}.${key}`, transformOptions));
+ }
+ }
- // Takes care of adding deleted items to final tree
- for (const key in compareWithObj) {
- if (!obj.hasOwnProperty(key) && compareWithObj.hasOwnProperty(key)) {
- children.push(this._transform(new Terminal(), new Terminal(), undefined,
- compareWithObj[key], key, compareWithFieldOptions[key], `${stableId}.${key}`, transformOptions));
- }
- }
+ let transformedObj;
+ if (
+ children.length == 1 &&
+ children[0].children.length == 0 &&
+ !children[0].combined
+ ) {
+ // Merge leaf key value pairs.
+ const child = children[0];
- let transformedObj;
- if (
- children.length == 1 &&
- children[0].children.length == 0 &&
- !children[0].combined
- ) {
- // Merge leaf key value pairs.
- const child = children[0];
+ transformedObj = {
+ kind: '',
+ name: name + ': ' + child.name,
+ stableId,
+ children: child.children,
+ combined: true,
+ };
- transformedObj = {
- kind: "",
- name: name + ": " + child.name,
- stableId,
- children: child.children,
- combined: true,
- }
+ if (this.diff) {
+ transformedObj.diff = child.diff;
+ }
+ } else {
+ transformedObj = {
+ kind: '',
+ name,
+ stableId,
+ children,
+ };
- if (this.diff) {
- transformedObj.diff = child.diff;
- }
- } else {
- transformedObj = {
- kind: "",
- name,
- stableId,
- children,
- };
+ let fieldOptionsToUse = fieldOptions;
- let fieldOptionsToUse = fieldOptions;
+ if (this.diff) {
+ const diff = getDiff(name, compareWithName);
+ transformedObj.diff = diff;
- if (this.diff) {
- const diff = getDiff(name, compareWithName);
- transformedObj.diff = diff;
+ if (diff.type == DiffType.DELETED) {
+ transformedObj.name = compareWithName;
+ fieldOptionsToUse = compareWithFieldOptions;
+ }
+ }
- if (diff.type == DiffType.DELETED) {
- transformedObj.name = compareWithName;
- fieldOptionsToUse = compareWithFieldOptions;
- }
- }
+ const annotationType = fieldOptionsToUse?.['(.android.typedef)'];
+ if (annotationType) {
+ if (intDefMapping[annotationType] === undefined) {
+ console.error(
+ `Missing intDef mapping for translation for ${annotationType}`);
+ } else if (intDefMapping[annotationType].flag) {
+ transformedObj.name = `${getIntFlagsAsStrings(
+ transformedObj.name, annotationType)} (${transformedObj.name})`;
+ } else {
+ transformedObj.name = `${intDefMapping[annotationType]
+ .values[transformedObj.name]} (${transformedObj.name})`;
+ }
+ }
+ }
- const annotationType = fieldOptionsToUse?.["(.android.typedef)"];
- if (annotationType) {
- if (intDefMapping[annotationType] === undefined) {
- console.error(`Missing intDef mapping for translation for ${annotationType}`);
- } else if (intDefMapping[annotationType].flag) {
- transformedObj.name = `${getIntFlagsAsStrings(transformedObj.name, annotationType)} (${transformedObj.name})`;
- } else {
- transformedObj.name = `${intDefMapping[annotationType].values[transformedObj.name]} (${transformedObj.name})`;
- }
- }
- }
+ if (transformOptions.keepOriginal) {
+ transformedObj.obj = originalObj;
+ }
- if (transformOptions.keepOriginal) {
- transformedObj.obj = originalObj;
- }
+ if (metadata) {
+ transformedObj[transformOptions.metadataKey] = metadata;
+ }
- if (metadata) {
- transformedObj[transformOptions.metadataKey] = metadata;
- }
-
- return transformOptions.freeze ? Object.freeze(transformedObj) : transformedObj;
- }
+ return transformOptions.freeze ?
+ Object.freeze(transformedObj) : transformedObj;
+ }
}
function getIntFlagsAsStrings(intFlags, annotationType) {
- const flags = [];
+ const flags = [];
- const mapping = intDefMapping[annotationType].values;
+ const mapping = intDefMapping[annotationType].values;
- // Will only contain bits that have not been associated with a flag.
- let leftOver = intFlags;
+ // Will only contain bits that have not been associated with a flag.
+ let leftOver = intFlags;
- for (const intValue in mapping) {
- if ((intFlags & parseInt(intValue)) === parseInt(intValue)) {
- flags.push(mapping[intValue]);
+ for (const intValue in mapping) {
+ if ((intFlags & parseInt(intValue)) === parseInt(intValue)) {
+ flags.push(mapping[intValue]);
- leftOver = leftOver & ~intValue;
- }
- }
+ leftOver = leftOver & ~intValue;
+ }
+ }
- if (flags.length === 0) {
- console.error("No valid flag mappings found for ", intFlags, "of type", annotationType);
- }
+ if (flags.length === 0) {
+ console.error('No valid flag mappings found for ',
+ intFlags, 'of type', annotationType);
+ }
- if (leftOver) {
- // If 0 is a valid flag value that isn't in the intDefMapping
- // it will be ignored
- flags.push(leftOver);
- }
+ if (leftOver) {
+ // If 0 is a valid flag value that isn't in the intDefMapping
+ // it will be ignored
+ flags.push(leftOver);
+ }
- return flags.join(' | ');
+ return flags.join(' | ');
}
+// eslint-disable-next-line camelcase
function nanos_to_string(elapsedRealtimeNanos) {
- var units = [
- [1000000, '(ns)'],
- [1000, 'ms'],
- [60, 's'],
- [60, 'm'],
- [24, 'h'],
- [Infinity, 'd'],
- ];
+ const units = [
+ [1000000, '(ns)'],
+ [1000, 'ms'],
+ [60, 's'],
+ [60, 'm'],
+ [24, 'h'],
+ [Infinity, 'd'],
+ ];
- var parts = []
- units.some(([div, str], i) => {
- var part = (elapsedRealtimeNanos % div).toFixed()
- if (!str.startsWith('(')) {
- parts.push(part + str);
- }
- elapsedRealtimeNanos = Math.floor(elapsedRealtimeNanos / div);
- return elapsedRealtimeNanos == 0;
- });
+ const parts = [];
+ units.some(([div, str], i) => {
+ const part = (elapsedRealtimeNanos % div).toFixed();
+ if (!str.startsWith('(')) {
+ parts.push(part + str);
+ }
+ elapsedRealtimeNanos = Math.floor(elapsedRealtimeNanos / div);
+ return elapsedRealtimeNanos == 0;
+ });
- return parts.reverse().join('');
+ return parts.reverse().join('');
}
// Returns a UI element used highlight a visible entry.
+// eslint-disable-next-line camelcase
function get_visible_chip() {
- return { short: 'V', long: "visible", class: 'default' };
+ return {short: 'V', long: 'visible', class: 'default'};
}
-export { transform, ObjectTransformer, nanos_to_string, get_visible_chip };
+// eslint-disable-next-line camelcase
+export {transform, ObjectTransformer, nanos_to_string, get_visible_chip};
diff --git a/tools/winscope/src/transform_sf.js b/tools/winscope/src/transform_sf.js
index 1598d0a..c4d3611 100644
--- a/tools/winscope/src/transform_sf.js
+++ b/tools/winscope/src/transform_sf.js
@@ -14,38 +14,41 @@
* limitations under the License.
*/
-import { transform, nanos_to_string, get_visible_chip } from './transform.js'
-import { fill_occlusion_state, fill_inherited_state } from './sf_visibility.js';
-import { getSimplifiedLayerName } from './utils/names';
+// eslint-disable-next-line camelcase
+import {transform, nanos_to_string, get_visible_chip} from './transform.js';
+// eslint-disable-next-line camelcase
+import {fill_occlusion_state, fill_inherited_state} from './sf_visibility.js';
+import {getSimplifiedLayerName} from './utils/names';
-var RELATIVE_Z_CHIP = {
+const RELATIVE_Z_CHIP = {
short: 'RelZ',
- long: "Is relative Z-ordered to another surface",
- class: 'warn'
+ long: 'Is relative Z-ordered to another surface',
+ class: 'warn',
};
-var RELATIVE_Z_PARENT_CHIP = {
+const RELATIVE_Z_PARENT_CHIP = {
short: 'RelZParent',
- long: "Something is relative Z-ordered to this surface",
- class: 'warn'
+ long: 'Something is relative Z-ordered to this surface',
+ class: 'warn',
};
-var MISSING_LAYER = {
+const MISSING_LAYER = {
short: 'MissingLayer',
- long: "This layer was referenced from the parent, but not present in the trace",
- class: 'error'
+ long:
+ 'This layer was referenced from the parent, but not present in the trace',
+ class: 'error',
};
-var GPU_CHIP = {
+const GPU_CHIP = {
short: 'GPU',
- long: "This layer was composed on the GPU",
- class: 'gpu'
+ long: 'This layer was composed on the GPU',
+ class: 'gpu',
};
-var HWC_CHIP = {
+const HWC_CHIP = {
short: 'HWC',
- long: "This layer was composed by Hardware Composer",
- class: 'hwc'
+ long: 'This layer was composed by Hardware Composer',
+ class: 'hwc',
};
-function transform_layer(layer) {
- function offset_to(bounds, x, y) {
+function transformLayer(layer) {
+ function offsetTo(bounds, x, y) {
return {
right: bounds.right - (bounds.left - x),
bottom: bounds.bottom - (bounds.top - y),
@@ -54,11 +57,11 @@
};
}
- function get_rect(layer) {
- var result = layer.bounds;
- var tx = layer.position ? layer.position.x || 0 : 0;
- var ty = layer.position ? layer.position.y || 0 : 0;
- result = offset_to(result, 0, 0);
+ function getRect(layer) {
+ let result = layer.bounds;
+ const tx = layer.position ? layer.position.x || 0 : 0;
+ const ty = layer.position ? layer.position.y || 0 : 0;
+ result = offsetTo(result, 0, 0);
result.label = layer.name;
result.transform = layer.transform;
result.transform.tx = tx;
@@ -66,15 +69,16 @@
return result;
}
- function add_hwc_composition_type_chip(layer) {
- if (layer.hwcCompositionType === "CLIENT") {
+ function addHwcCompositionTypeChip(layer) {
+ if (layer.hwcCompositionType === 'CLIENT') {
chips.push(GPU_CHIP);
- } else if (layer.hwcCompositionType === "DEVICE" || layer.hwcCompositionType === "SOLID_COLOR") {
+ } else if (layer.hwcCompositionType === 'DEVICE' ||
+ layer.hwcCompositionType === 'SOLID_COLOR') {
chips.push(HWC_CHIP);
}
}
- var chips = [];
+ const chips = [];
if (layer.visible) {
chips.push(get_visible_chip());
}
@@ -87,24 +91,27 @@
if (layer.missing) {
chips.push(MISSING_LAYER);
}
- add_hwc_composition_type_chip(layer);
+ addHwcCompositionTypeChip(layer);
- const rect = layer.visible && layer.bounds !== null ? get_rect(layer) : undefined;
+ const rect = layer.visible && layer.bounds !== null ?
+ getRect(layer) : undefined;
const simplifiedLayerName = getSimplifiedLayerName(layer.name);
- const shortName = simplifiedLayerName ? layer.id + ": " + simplifiedLayerName : undefined;
+ const shortName = simplifiedLayerName ?
+ layer.id + ': ' + simplifiedLayerName : undefined;
const transformedLayer = transform({
obj: layer,
kind: '',
- name: layer.id + ": " + layer.name,
+ name: layer.id + ': ' + layer.name,
shortName,
- children: [[layer.resolvedChildren, transform_layer]],
+ children: [[layer.resolvedChildren, transformLayer]],
rect,
undefined /* bounds */,
highlight: rect,
chips,
visible: layer.visible,
+ freeze: false,
});
// NOTE: Temporary until refactored to use flickerlib
@@ -113,25 +120,25 @@
invisibleDueTo: layer.invisibleDueTo,
occludedBy: layer.occludedBy,
partiallyOccludedBy: layer.partiallyOccludedBy,
- coveredBy: layer.coveredBy
- }
+ coveredBy: layer.coveredBy,
+ },
};
}
function missingLayer(childId) {
return {
- name: "layer #" + childId,
+ name: 'layer #' + childId,
missing: true,
zOrderRelativeOf: -1,
- transform: { dsdx: 1, dtdx: 0, dsdy: 0, dtdy: 1 },
- }
+ transform: {dsdx: 1, dtdx: 0, dsdy: 0, dtdy: 1},
+ };
}
-function transform_layers(includesCompositionState, layers) {
- var idToItem = {};
- var isChild = {}
+function transformLayers(includesCompositionState, layers) {
+ const idToItem = {};
+ const isChild = {};
- var layersList = layers.layers || [];
+ const layersList = layers.layers || [];
layersList.forEach((e) => {
idToItem[e.id] = e;
@@ -140,18 +147,19 @@
e.resolvedChildren = [];
if (Array.isArray(e.children)) {
e.resolvedChildren = e.children.map(
- (childId) => idToItem[childId] || missingLayer(childId));
+ (childId) => idToItem[childId] || missingLayer(childId));
e.children.forEach((childId) => {
isChild[childId] = true;
});
}
- // We don't clean up relatives when the relative parent is removed, so it may be inconsistent
+ // We don't clean up relatives when the relative parent is removed, so it
+ // may be inconsistent
if ((e.zOrderRelativeOf || -1) !== -1 && (idToItem[e.zOrderRelativeOf])) {
idToItem[e.zOrderRelativeOf].zOrderRelativeParentOf = e.id;
}
});
- var roots = layersList.filter((e) => !isChild[e.id]);
+ const roots = layersList.filter((e) => !isChild[e.id]);
fill_inherited_state(idToItem, roots);
// Backwards compatibility check
@@ -166,17 +174,17 @@
});
}
- var idToTransformed = {};
- var transformed_roots = roots.map((r) =>
- transform_layer(r, {
- parentBounds: { left: 0, right: 0, top: 0, bottom: 0 },
- parentHidden: null
+ const idToTransformed = {};
+ const transformedRoots = roots.map((r) =>
+ transformLayer(r, {
+ parentBounds: {left: 0, right: 0, top: 0, bottom: 0},
+ parentHidden: null,
}));
- foreachTree(transformed_roots, (n) => {
+ foreachTree(transformedRoots, (n) => {
idToTransformed[n.obj.id] = n;
});
- var flattened = [];
+ const flattened = [];
layersList.forEach((e) => {
flattened.push(idToTransformed[e.id]);
});
@@ -186,10 +194,10 @@
kind: 'layers',
name: 'layers',
children: [
- [transformed_roots, (c) => c],
+ [transformedRoots, (c) => c],
],
rects_transform(r) {
- var res = [];
+ const res = [];
flattened.forEach((l) => {
if (l.rect) {
res.push(l.rect);
@@ -201,31 +209,34 @@
});
}
-function transform_layers_entry(entry) {
+function transformLayersEntry(entry) {
const includesCompositionState = !entry.excludesCompositionState;
return transform({
obj: entry,
kind: 'entry',
- name: nanos_to_string(entry.elapsedRealtimeNanos) + " - " + entry.where,
+ name: nanos_to_string(entry.elapsedRealtimeNanos) + ' - ' + entry.where,
children: [
- [[entry.layers], (layer) => transform_layers(includesCompositionState, layer)],
+ [
+ [entry.layers],
+ (layer) => transformLayers(includesCompositionState, layer),
+ ],
],
timestamp: entry.elapsedRealtimeNanos,
stableId: 'entry',
});
}
-function transform_layers_trace(entries) {
- var r = transform({
+function transformLayersTrace(entries) {
+ const r = transform({
obj: entries,
kind: 'layerstrace',
name: 'layerstrace',
children: [
- [entries.entry, transform_layers_entry],
+ [entries.entry, transformLayersEntry],
],
});
return r;
}
-export { transform_layers, transform_layers_trace };
+export {transformLayers, transformLayersTrace};