blob: 9f9ae4815be34384f475172a58cbb33c09cc26d8 [file] [log] [blame]
Vishnu Nair4df8eb62022-02-17 15:32:02 -08001/*
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
17#undef LOG_TAG
18#define LOG_TAG "LayerTraceGenerator"
19
20#include <fstream>
21#include <iostream>
22#include <string>
23
24#include "LayerTraceGenerator.h"
25
26using namespace android;
27
28int main(int argc, char** argv) {
29 if (argc > 3) {
30 std::cout << "Usage: " << argv[0]
31 << " [transaction-trace-path] [output-layers-trace-path]\n";
32 return -1;
33 }
34
35 const char* transactionTracePath =
36 (argc > 1) ? argv[1] : "/data/misc/wmtrace/transactions_trace.winscope";
37 std::cout << "Parsing " << transactionTracePath << "\n";
38 std::fstream input(transactionTracePath, std::ios::in | std::ios::binary);
39 if (!input) {
40 std::cout << "Error: Could not open " << transactionTracePath;
41 return -1;
42 }
43
44 proto::TransactionTraceFile transactionTraceFile;
45 if (!transactionTraceFile.ParseFromIstream(&input)) {
46 std::cout << "Error: Failed to parse " << transactionTracePath;
47 return -1;
48 }
49
50 const char* outputLayersTracePath =
51 (argc == 3) ? argv[2] : "/data/misc/wmtrace/layers_trace.winscope";
52 ;
53 ALOGD("Generating %s...", outputLayersTracePath);
54 std::cout << "Generating " << outputLayersTracePath << "\n";
Vishnu Nair5d60bbe2022-10-18 16:59:10 -070055
56 // sink any log spam from the stubbed surfaceflinger
57 __android_log_set_logger([](const struct __android_log_message* /* log_message */) {});
58
Vishnu Nair4df8eb62022-02-17 15:32:02 -080059 if (!LayerTraceGenerator().generate(transactionTraceFile, outputLayersTracePath)) {
60 std::cout << "Error: Failed to generate layers trace " << outputLayersTracePath;
61 return -1;
62 }
63 return 0;
64}