• 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 #ifndef UTILS_INCLUDE_FRAME_SCHED_H
17 #define UTILS_INCLUDE_FRAME_SCHED_H
18 
19 #include <cstdint>
20 #include <string>
21 
22 namespace OHOS {
23 namespace Rosen {
24 
25 using InitFunc = void(*)();
26 using SendFenceIdFunc = void(*)(int);
27 using MonitorGpuStartFunc = void(*)(int);
28 using MonitorGpuEndFunc = void(*)();
29 using SetFrameParamFunc = void(*)(int, int, int, int);
30 using IsScbSceneFunc = bool(*)();
31 
32 class FrameSched {
33 public:
34     static FrameSched& GetInstance();
35     void SetFrameParam(int requestId, int load, int schedFrameNum, int value);
36     void SendFenceId(uint32_t fenceId);
37     void MonitorGpuStart(uint32_t fenceId);
38     void MonitorGpuEnd();
39     bool IsScbScene();
40 
41 private:
42     FrameSched();
43     ~FrameSched();
44 
45     void Init();
46 
47     bool LoadLibrary();
48     void CloseLibrary();
49     void* LoadSymbol(const char* symName);
50 
51     void* schedHandle_ = nullptr;
52     bool schedSoLoaded_ = false;
53     InitFunc initFunc_ = nullptr;
54     SendFenceIdFunc sendFenceIdFunc_ = nullptr;
55     MonitorGpuStartFunc monitorGpuStartFunc_ = nullptr;
56     MonitorGpuEndFunc monitorGpuEndFunc_ = nullptr;
57     SetFrameParamFunc setFrameParamFunc_ = nullptr;
58     IsScbSceneFunc isScbSceneFunc_ = nullptr;
59 };
60 
61 } // namespace Rosen
62 } // namespace OHOS
63 
64 #endif // UTILS_INCLUDE_FRAME_SCHED_H