• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  */
15 
16 #include "rme_core_sched.h"
17 #include <hitrace_meter.h>
18 #include <memory>
19 #include <string>
20 #include <unistd.h>
21 #include "rtg_interface.h"
22 #include "rme_log_domain.h"
23 
24 #undef LOG_TAG
25 #define LOG_TAG "ueaClient-RmeCoreSched"
26 
27 namespace OHOS {
28 namespace RME {
29 namespace {
30     constexpr int MARGIN_BEGIN = -3;
31     constexpr int MARGIN_MIDDLE = -5;
32     constexpr int MARGIN_END = -13;
33 }
RmeCoreSched()34 RmeCoreSched::RmeCoreSched() {}
35 
~RmeCoreSched()36 RmeCoreSched::~RmeCoreSched()
37 {
38     return;
39 }
40 
Init()41 bool RmeCoreSched::Init()
42 {
43     StartTrace(HITRACE_TAG_ACE, "FrameS-Init");
44     int ret = GetRtgEnable();
45     if (ret > 0) {
46         RME_LOGE("[Init]: rtgEnabled! scheme Open!ret: %{public}d", ret);
47     } else {
48         RME_LOGE("[Init]: do not enabled!ret: %{public}d", ret);
49     }
50     FinishTrace(HITRACE_TAG_ACE);
51     return ret;
52 }
53 
HandleBeginScene()54 void RmeCoreSched::HandleBeginScene()
55 {
56     HITRACE_METER(HITRACE_TAG_ACE);
57 }
58 
BeginFlushAnimation()59 void RmeCoreSched::BeginFlushAnimation()
60 {
61     m_pid = getpid();
62     if (m_rtg <= 0) {
63         m_rtg = SearchRtgForTid(m_pid);
64         if (m_rtg <= 0) {
65             return;
66         }
67     }
68     int ret = BeginFrameFreq(0);
69     m_uiTid = gettid();
70     if (!m_uiHasSend) {
71         StartTrace(HITRACE_TAG_ACE,
72             ("FrameS-Begin&AddThread-rtg:" + to_string(m_rtg) + " ret:" + to_string(ret)).c_str());
73         m_uiHasSend = true;
74     } else {
75         StartTrace(HITRACE_TAG_ACE, "FrameS-Begin");
76     }
77     FinishTrace(HITRACE_TAG_ACE);
78     return;
79 }
80 
EndFlushAnimation()81 void RmeCoreSched::EndFlushAnimation() {}
82 
BeginFlushBuild()83 void RmeCoreSched::BeginFlushBuild()
84 {
85     StartTrace(HITRACE_TAG_ACE,
86         ("FrameS-SetMargin-rtg:" + to_string(m_rtg) + " margin:" + to_string(MARGIN_BEGIN)).c_str());
87     SetMargin(MARGIN_BEGIN);
88     FinishTrace(HITRACE_TAG_ACE);
89 }
90 
EndFlushBuild()91 void RmeCoreSched::EndFlushBuild() {}
92 
BeginFlushLayout()93 void RmeCoreSched::BeginFlushLayout() {}
94 
EndFlushLayout()95 void RmeCoreSched::EndFlushLayout() {}
96 
BeginFlushRender()97 void RmeCoreSched::BeginFlushRender()
98 {
99     StartTrace(HITRACE_TAG_ACE,
100         ("FrameS-SetMargin-rtg:" + to_string(m_rtg) + " margin:" + to_string(MARGIN_MIDDLE)).c_str());
101     SetMargin(MARGIN_MIDDLE);
102     FinishTrace(HITRACE_TAG_ACE);
103 }
104 
EndFlushRender()105 void RmeCoreSched::EndFlushRender() {}
106 
BeginFlushRenderFinish()107 void RmeCoreSched::BeginFlushRenderFinish() {}
108 
EndFlushRenderFinish()109 void RmeCoreSched::EndFlushRenderFinish() {}
110 
BeginProcessPostFlush()111 void RmeCoreSched::BeginProcessPostFlush() {}
112 
ProcessCommandsStart()113 void RmeCoreSched::ProcessCommandsStart() {}
114 
AnimateStart()115 void RmeCoreSched::AnimateStart()
116 {
117     if (m_rtg <= 0) {
118         return;
119     }
120 }
121 
RenderStart()122 void RmeCoreSched::RenderStart()
123 {
124     StartTrace(HITRACE_TAG_ACE,
125         ("FrameS-SetMargin-rtg:" + to_string(m_rtg) + " margin:" + to_string(MARGIN_END)).c_str());
126     SetMargin(MARGIN_END);
127     FinishTrace(HITRACE_TAG_ACE);
128 }
129 
SendCommandsStart()130 void RmeCoreSched::SendCommandsStart()
131 {
132     if (m_rtg <= 0) {
133         return;
134     }
135     StartTrace(HITRACE_TAG_ACE, "SendCommandsStart-EndFreq");
136     EndFrameFreq(0);
137     FinishTrace(HITRACE_TAG_ACE);
138 }
139 
HandleEndScene()140 void RmeCoreSched::HandleEndScene()
141 {
142     HITRACE_METER(HITRACE_TAG_ACE);
143     if (m_rtg <= 0) {
144         return;
145     }
146     int ret = 0;
147     m_uiHasSend = false;
148     StartTrace(HITRACE_TAG_ACE,
149         ("FrameS-EndFrameFreq-rtg:" + to_string(m_rtg) + " ret:" + to_string(ret)).c_str());
150     FinishTrace(HITRACE_TAG_ACE);
151 }
152 } // namespace RME
153 } // OHOS
154