1/*
2 * Copyright (C) 2022 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17import {AbsoluteEntryIndex} from 'trace/index_types';
18import {PropertyTreeNode} from 'trace/tree_node/property_tree_node';
19import {UiPropertyTreeNode} from 'viewers/common/ui_property_tree_node';
20import {UserOptions} from 'viewers/common/user_options';
21
22class UiData {
23  constructor(
24    public allVSyncIds: string[],
25    public allPids: string[],
26    public allUids: string[],
27    public allTypes: string[],
28    public allLayerAndDisplayIds: string[],
29    public allTransactionIds: string[],
30    public allFlags: string[],
31    public entries: UiDataEntry[],
32    public currentEntryIndex: undefined | number,
33    public selectedEntryIndex: undefined | number,
34    public scrollToIndex: undefined | number,
35    public currentPropertiesTree: undefined | UiPropertyTreeNode,
36    public propertiesUserOptions: UserOptions,
37  ) {}
38
39  static EMPTY = new UiData(
40    [],
41    [],
42    [],
43    [],
44    [],
45    [],
46    [],
47    [],
48    undefined,
49    undefined,
50    undefined,
51    undefined,
52    {},
53  );
54}
55
56class UiDataEntry {
57  constructor(
58    public traceIndex: AbsoluteEntryIndex,
59    public time: PropertyTreeNode,
60    public vsyncId: number,
61    public pid: string,
62    public uid: string,
63    public type: string,
64    public layerOrDisplayId: string,
65    public transactionId: string,
66    public what: string,
67    public propertiesTree: PropertyTreeNode | undefined,
68  ) {}
69}
70
71class UiDataEntryType {
72  static DISPLAY_ADDED = 'DISPLAY_ADDED';
73  static DISPLAY_REMOVED = 'DISPLAY_REMOVED';
74  static DISPLAY_CHANGED = 'DISPLAY_CHANGED';
75  static LAYER_ADDED = 'LAYER_ADDED';
76  static LAYER_DESTROYED = 'LAYER_DESTROYED';
77  static LAYER_CHANGED = 'LAYER_CHANGED';
78  static LAYER_HANDLE_DESTROYED = 'LAYER_HANDLE_DESTROYED';
79  static NO_OP = 'NO_OP';
80}
81
82export {UiData, UiDataEntry, UiDataEntryType};
83