• 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 #ifndef RS_QOS_THREAD
17 #define RS_QOS_THREAD
18 
19 #include <cstdint>
20 #include "vsync_distributor.h"
21 #include "common/rs_common_def.h"
22 
23 namespace OHOS::Rosen {
24 class RSQosThread {
25 public:
RSQosThread()26     RSQosThread() {};
~RSQosThread()27     ~RSQosThread() {};
28 
29     static sptr<VSyncDistributor> appVSyncDistributor_;
30 
31     static RSQosThread* GetInstance();
32     static void ThreadStart();
33     static void ThreadStop();
34     static void ResetQosPid();
35     void OnRSVisibilityChangeCB(const std::map<uint32_t, RSVisibleLevel>& pidVisMap);
36 
SetQosCal(bool qosCal)37     void SetQosCal(bool qosCal)
38     {
39         qosCal_ = qosCal;
40     }
41 
GetQosCal()42     bool GetQosCal() const
43     {
44         return qosCal_;
45     }
46 
47 private:
48     static const int MAX_RATE = 1;
49     static const int MIN_RATE = INT_MAX;
50     static std::once_flag flag_;
51     static RSQosThread* instance_;
52 
53     bool qosCal_ = false;
54 
55     static void Init();
56 
57     static void GetQosVSyncRateInfos(std::vector<std::pair<uint32_t, int>>& appsRateVec);
58     static void SetQosVSyncRate(uint32_t pid, int32_t rate);
59 };
60 } // namespace OHOS::Rosen
61 
62 #endif // RS_QOS_THREAD