• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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  */
15 
16 #include "rs_profiler.h"
17 #include "rs_profiler_command.h"
18 
19 namespace OHOS::Rosen {
20 
21 const RSProfiler::CommandRegistry RSProfiler::COMMANDS = {
22     { "rstree_contains", DumpTree },
23     { "rstree_fix", PatchNode },
24     { "rstree_kill_node", KillNode },
25     { "rstree_setparent", AttachChild },
26     { "rstree_getroot", GetRoot },
27     { "rstree_node_mod", DumpNodeModifiers },
28     { "rstree_node_prop", DumpNodeProperties },
29     { "rstree_pid", DumpSurfaces },
30     { "rstree_kill_pid", KillPid },
31     { "rstree_prepare_replay", PlaybackPrepare },
32     { "rstree_save_frame", TestSaveFrame },
33     { "rstree_load_frame", TestLoadFrame },
34     { "rssubtree_save", TestSaveFrame },
35     { "rssubtree_load", TestLoadFrame },
36     { "rstree_switch", TestSwitch },
37     { "rstree_dump_json", DumpTreeToJson },
38     { "rstree_clear_filter", ClearFilter },
39     { "rstree_blink_node", BlinkNode },
40     { "rstree_node_cache", PrintNodeCache },
41     { "rstree_node_cache_all", PrintNodeCacheAll },
42     { "rsrecord_start", RecordStart },
43     { "rsrecord_stop", RecordStop },
44     { "rsrecord_replay_prepare", PlaybackPrepareFirstFrame },
45     { "rsrecord_replay", PlaybackStart },
46     { "rsrecord_replay_stop", PlaybackStop },
47     { "rsrecord_pause_now", PlaybackPause },
48     { "rsrecord_pause_at", PlaybackPauseAt },
49     { "rsrecord_pause_resume", PlaybackResume },
50     { "rsrecord_pause_clear", PlaybackPauseClear },
51     { "rsrecord_sendbinary", RecordSendBinary },
52     { "rssurface_pid", DumpNodeSurface },
53     { "rscon_print", DumpConnections },
54     { "save_rdc", SaveRdc },
55     { "save_skp", SaveSkp },
56     { "info", GetDeviceInfo },
57     { "freq", GetDeviceFrequency },
58     { "fixenv", FixDeviceEnv },
59     { "set", SetSystemParameter },
60     { "get", GetSystemParameter },
61     { "params", DumpSystemParameters },
62     { "get_perf_tree", GetPerfTree },
63     { "calc_perf_node", CalcPerfNode },
64     { "calc_perf_node_all", CalcPerfNodeAll },
65     { "socket_shutdown", SocketShutdown },
66     { "version", Version },
67     { "file_version", FileVersion },
68     { "reset", Reset },
69     { "drawing_canvas", DumpDrawingCanvasNodes },
70     { "drawing_canvas_enable", DrawingCanvasRedrawEnable },
71     { "rsrecord_replay_speed", PlaybackSetSpeed },
72     { "rsrecord_replay_immediate", PlaybackSetImmediate },
73 };
74 
Invoke(const std::vector<std::string> & line)75 void RSProfiler::Invoke(const std::vector<std::string>& line)
76 {
77     if (line.empty() || line[0].empty()) {
78         return;
79     }
80 
81     const auto delegate = COMMANDS.find(line[0]);
82     if (delegate == COMMANDS.end()) {
83         Respond("Command has not been found: " + line[0]);
84         return;
85     }
86 
87     const ArgList args = (line.size() > 1) ? ArgList({ line.begin() + 1, line.end() }) : ArgList();
88     delegate->second(args);
89 }
90 
91 } // namespace OHOS::Rosen
92