• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021–2022 Beijing OSWare Technology Co., Ltd
3  * This file contains confidential and proprietary information of
4  * OSWare Technology Co., Ltd
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 #ifndef SORFT_VSYNC_H
20 #define SORFT_VSYNC_H
21 
22 #include <thread>
23 #include <memory>
24 #include <mutex>
25 #include "hdi_display.h"
26 namespace OHOS {
27 namespace HDI {
28 namespace DISPLAY {
29 class SorftVsync {
30 public:
31     SorftVsync();
32     virtual ~SorftVsync();
33     static SorftVsync &GetInstance();
34 
35     int32_t Init();
36     void EnableVsync(bool enable);
37     void WorkThread();
38     void ReqesterVBlankCb(std::shared_ptr<VsyncCallBack> &cb);
39     bool CheckRuning();
40 
41 private:
42     std::unique_ptr<std::thread> thread_;
43     bool enable_ = false;
44     std::mutex mutext_;
45     std::condition_variable condition_;
46     std::shared_ptr<VsyncCallBack> callback_;
47     bool running_ = false;
48 };
49 } // namespace OHOS
50 } // namespace HDI
51 } // namespace DISPLAY
52 
53 #endif // SORFT_VSYNC_H