• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-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 #ifndef ROSEN_MODULE_RS_FRAME_REPORT_H
17 #define ROSEN_MODULE_RS_FRAME_REPORT_H
18 
19 #include <string>
20 #include <unordered_map>
21 
22 namespace OHOS {
23 namespace Rosen {
24 
25 enum class FrameSchedEvent {
26     SCHED_EVENT_BASE = 0,
27     INIT = 1,
28     RS_RENDER_START = 10001,
29     RS_RENDER_END = 10002,
30     RS_UNI_RENDER_START = 10003,
31     RS_UNI_RENDER_END = 10004,
32     RS_HARDWARE_START = 10005,
33     RS_HARDWARE_END = 10006,
34     RS_HARDWARE_INFO = 10007,
35     RS_BUFFER_COUNT = 10008,
36     RS_FRAME_DEADLINE = 10009,
37     RS_UNBLOCK_MAINTHREAD = 10010,
38     RS_POST_AND_WAIT = 10011,
39     RS_BEGIN_FLUSH = 10012,
40     RS_BLUR_PREDICT = 10013,
41 };
42 
43 using FrameGetEnableFunc = int (*)();
44 using ReportSchedEventFunc = void (*)(FrameSchedEvent, const std::unordered_map<std::string, std::string>&);
45 using InitFunc = void (*)();
46 using ProcessCommandsStartFunc = void(*)();
47 using AnimateStartFunc = void(*)();
48 using RenderStartFunc = void(*)(uint64_t);
49 using ParallelRenderStartFunc = void(*)();
50 using RenderEndFunc = void(*)();
51 using ParallelRenderEndFunc = void(*)();
52 using SendCommandsStartFunc = void(*)();
53 using SetFrameParamFunc = void(*)(int, int, int, int);
54 class RsFrameReport final {
55 public:
56     static RsFrameReport& GetInstance();
57     void Init();
58     int GetEnable();
59     void ReportSchedEvent(FrameSchedEvent event, const std::unordered_map<std::string, std::string> &payload);
60 
61     void ProcessCommandsStart();
62     void AnimateStart();
63     void RenderStart(uint64_t timestamp);
64     void RSRenderStart();
65     void RenderEnd();
66     void RSRenderEnd();
67     void SendCommandsStart();
68     void SetFrameParam(int requestId, int load, int schedFrameNum, int value);
69     void UnblockMainThread();
70     void PostAndWait();
71     void BeginFlush();
72 
73 private:
74     RsFrameReport();
75     ~RsFrameReport();
76     bool LoadLibrary();
77     void CloseLibrary();
78     void *LoadSymbol(const char *symName);
79 
80     void *frameSchedHandle_ = nullptr;
81     bool frameSchedSoLoaded_ = false;
82 
83     FrameGetEnableFunc frameGetEnableFunc_ = nullptr;
84     ReportSchedEventFunc reportSchedEventFunc_ = nullptr;
85     InitFunc initFunc_ = nullptr;
86     ProcessCommandsStartFunc processCommandsStartFun_ = nullptr;
87     AnimateStartFunc animateStartFunc_ = nullptr;
88     RenderStartFunc renderStartFunc_ = nullptr;
89     ParallelRenderStartFunc parallelRenderStartFunc_ = nullptr;
90     RenderEndFunc renderEndFunc_ = nullptr;
91     ParallelRenderEndFunc parallelRenderEndFunc_ = nullptr;
92     SendCommandsStartFunc sendCommandsStartFunc_ = nullptr;
93     SetFrameParamFunc setFrameParamFunc_ = nullptr;
94 };
95 } // namespace Rosen
96 } // namespace OHOS
97 #endif // ROSEN_MODULE_RS_FRAME_REPORT_H
98