• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 RENDER_SERVICE_BASE_COMMON_RS_HISYSEVENT_H
17 #define RENDER_SERVICE_BASE_COMMON_RS_HISYSEVENT_H
18 
19 #include "base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include/hisysevent.h"
20 #include "platform/common/rs_log.h"
21 #include <string>
22 #include <unordered_map>
23 #include <utility>
24 
25 namespace OHOS {
26 namespace Rosen {
27 namespace RSEventName {
28     const std::string NO_DRAW = "NO_DRAW";
29     const std::string JANK_FRAME_SKIP = "JANK_FRAME_SKIP";
30     const std::string RS_COMPOSITION_TIMEOUT = "RS_COMPOSITION_TIMEOUT";
31     const std::string EPS_LCD_FREQ = "EPS_LCD_FREQ";
32     const std::string JANK_STATS_RS = "JANK_STATS_RS";
33     const std::string JANK_FRAME_RS = "JANK_FRAME_RS";
34     const std::string INTERACTION_RESPONSE_LATENCY = "INTERACTION_RESPONSE_LATENCY";
35     const std::string INTERACTION_COMPLETED_LATENCY = "INTERACTION_COMPLETED_LATENCY";
36     const std::string INTERACTION_RENDER_JANK = "INTERACTION_RENDER_JANK";
37     const std::string INTERACTION_HITCH_TIME_RATIO = "INTERACTION_HITCH_TIME_RATIO";
38     const std::string FIRST_FRAME_DRAWN = "FIRST_FRAME_DRAWN";
39     const std::string RS_NODE_LIMIT_EXCEEDED = "RS_NODE_LIMIT_EXCEEDED";
40     const std::string ANIMATION_CALLBACK_MISSING = "ANIMATION_CALLBACK_MISSING";
41     const std::string HGM_VOTER_INFO = "HGM_VOTER_INFO";
42     const std::string GPU_SUBHEALTH_MONITORING = "GPU_SUBHEALTH_MONITORING";
43     const std::string IPC_DATA_OVER_ERROR = "IPC_DATA_OVER_ERROR";
44     const std::string RENDER_MEMORY_OVER_WARNING = "RENDER_MEMORY_OVER_WARNING";
45     const std::string RENDER_MEMORY_OVER_ERROR = "RENDER_MEMORY_OVER_ERROR";
46     const std::string RS_HARDWARE_THREAD_LOAD_WARNING = "RS_HARDWARE_THREAD_LOAD_WARNING";
47     const std::string RENDER_DRAWABLE_MULTI_ACCESS = "RENDER_DRAWABLE_MULTI_ACCESS";
48 } // namespace RSEventName
49 
50 enum RSEventType {
51     RS_FAULT     = 1,    // system fault event
52     RS_STATISTIC = 2,    // system statistic event
53     RS_SECURITY  = 3,    // system security event
54     RS_BEHAVIOR  = 4     // system behavior event
55 };
56 
57 class RSHiSysEvent {
58 public:
59     template<typename... Types>
EventWrite(const std::string & eventName,RSEventType type,Types &&...types)60     static int EventWrite(const std::string& eventName, RSEventType type, Types&&... types)
61     {
62         int hiSysEventWriteRet = HiSysEventWrite(HiDomain::GRAPHIC, eventName, rsEventTypeToEventTypeMap_[type],
63             std::forward<Types>(types)...);
64         if (hiSysEventWriteRet != 0) {
65             RS_LOGW("Write RSHiSysEvent failed, eventName: %{public}s, ret: %{public}d",
66                 eventName.c_str(), hiSysEventWriteRet);
67         }
68         return hiSysEventWriteRet;
69     }
70 private:
71     using HiDomain = OHOS::HiviewDFX::HiSysEvent::Domain;
72     using HiEventType = OHOS::HiviewDFX::HiSysEvent::EventType;
73     static std::unordered_map<RSEventType, HiEventType> rsEventTypeToEventTypeMap_;
74 };
75 
76 } // namespace Rosen
77 } // namespace OHOS
78 #endif