• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 CHARGER_UI_FRAME_H
17 #define CHARGER_UI_FRAME_H
18 
19 #include <map>
20 #include <condition_variable>
21 #include "surface_dev.h"
22 #include "view.h"
23 
24 namespace OHOS {
25 namespace HDI {
26 namespace Battery {
27 namespace V1_0 {
28 struct CmpByStartY {
operatorCmpByStartY29     bool operator()(const View* v1, const View* v2) const
30     {
31         return v1->startY_ < v2->startY_;
32     }
33 };
34 
35 class Frame : public View {
36 public:
37     Frame(unsigned int w, unsigned int h, View::PixelFormat pixType, SurfaceDev* sfDev);
38 
39     ~Frame() override;
40 
41     void OnDraw() override;
42 
43     void ViewRegister(View* view);
44 
45 private:
46     void FlushThreadLoop();
47 
48     int currentActionIndex_ = 0;
49     int maxActionIndex_ = 0;
50     int listIndex_ = 0;
51     int frameViewId = 0;
52     bool flushFlag_ = false;
53     bool needStop_ = false;
54     SurfaceDev* sfDev_ = nullptr;
55     std::mutex frameMutex_;
56     std::mutex keyMutex_;
57     std::condition_variable_any mCondFlush_;
58     std::condition_variable_any mCondKey_;
59     std::map<View*, int, CmpByStartY> viewMapList_;
60 };
61 }  // namespace V1_0
62 }  // namespace Battery
63 }  // namespace HDI
64 }  // namespace OHOS
65 #endif // CHARGER_UI_FRAME_H
66