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