1/*
2 * Copyright (C) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15import { LtpoStruct } from './../ui-worker/ProcedureWorkerLTPO';
16import { query } from '../SqlLite';
17
18export const queryPresentInfo = (): Promise<Array<LtpoStruct>> =>
19  query(
20    'queryPresentInfo',
21    `SELECT ts,dur,name FROM "callstack" WHERE callid in (SELECT id FROM "thread" WHERE name LIKE('Present%'))
22  AND name LIKE('H:Waiting for Present Fence%')`
23  );
24
25export const queryFanceNameList = (): Promise<Array<LtpoStruct>> =>
26  query(
27    'queryFanceNameList',
28    `SELECT ts,dur,name FROM "callstack" WHERE callid in (SELECT id FROM "thread" WHERE name LIKE('RSHardwareThrea%'))
29  AND name LIKE('H:Present Fence%')`
30  );
31
32export const queryFpsNameList = (): Promise<Array<LtpoStruct>> =>
33  query(
34    'queryFpsNameList',
35    `SELECT ts,dur,name FROM "callstack" WHERE callid in (SELECT id FROM "thread" WHERE name LIKE('RSHardwareThrea%'))
36  AND name LIKE('%Layers rate%')`
37  );
38export const queryRealFpsList = (): Promise<Array<LtpoStruct>> =>
39  query(
40    'queryRealFpsList',
41    `SELECT ts,dur,name FROM "callstack" WHERE callid in (SELECT id FROM "thread" WHERE name LIKE('RSHardwareThrea%'))
42  AND name LIKE('H:RSHardwareThread::PerformSetActiveMode%')`
43  );
44export const querySignaledList = (): Promise<Array<LtpoStruct>> =>
45  query(
46    'querySignaledList',
47    `SELECT ts,dur,name FROM "callstack" WHERE callid in (SELECT id FROM "thread" WHERE name LIKE('RSHardwareThrea%'))
48    AND name LIKE('%has signaled')`
49  );
50export const queryRSNowTimeList = (): Promise<Array<LtpoStruct>> =>
51  query(
52    'queryRSNowTimeList',
53    `SELECT ts,dur,name FROM "callstack" WHERE callid in (SELECT id FROM "thread" WHERE name LIKE('render_service%'))
54    AND (name LIKE('H:ReceiveVsync dataCount:24bytes%'))
55    OR (name LIKE('H:ReceiveVsync dataCount: 24bytes%'))`
56  );
57export const querySkipDataList = (): Promise<Array<LtpoStruct>> =>
58  query(
59    'querySkipDataList',
60    `SELECT ts FROM "callstack" WHERE callid in (SELECT id FROM "thread" WHERE name LIKE('render_service%'))
61    AND name LIKE('H:DisplayNodeSkip skip commit')`
62  );
63