• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 HGM_FRAME_RATE_MANAGER_H
17 #define HGM_FRAME_RATE_MANAGER_H
18 
19 #include <unordered_map>
20 #include <vector>
21 
22 #include "animation/rs_frame_rate_range.h"
23 #include "common/rs_common_def.h"
24 #include "parameters.h"
25 #include "screen_manager/screen_types.h"
26 
27 namespace OHOS {
28 namespace Rosen {
29 struct FrameRateRangeData {
30     ScreenId screenId = INVALID_SCREEN_ID;
31     FrameRateRange rsRange;
32     std::unordered_map<pid_t, FrameRateRange> multiAppRange;
33 };
34 
35 class HgmFrameRateManager {
36 public:
HgmFrameRateManager()37     HgmFrameRateManager() {}
38 
39     void UniProcessData(const FrameRateRangeData& data);
40     void Reset();
41 private:
42     void CalcRefreshRate(const ScreenId id, const FrameRateRange& range);
43     void ExecuteSwitchRefreshRate(const ScreenId id);
44     uint32_t GetDrawingFrameRate(const uint32_t refreshRate, const FrameRateRange& range);
45 
46     uint32_t currRefreshRate_ = -1;
47     uint32_t rsFrameRate_ = -1;
48     std::unordered_map<pid_t, uint32_t> multiAppFrameRate_;
49 };
50 } // namespace Rosen
51 } // namespace OHOS
52 #endif // HGM_FRAME_RATE_MANAGER_H