1 /* 2 * Copyright (c) 2021-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 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_1 { 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(uint32_t w, uint32_t 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 int32_t maxActionIndex_ = 0; 49 int32_t listIndex_ = 0; 50 int32_t frameViewId = 0; 51 bool flushFlag_ = false; 52 bool needStop_ = false; 53 SurfaceDev* sfDev_ = nullptr; 54 std::mutex frameMutex_; 55 std::condition_variable_any mCondFlush_; 56 std::map<View*, int32_t, CmpByStartY> viewMapList_; 57 }; 58 } // namespace V1_1 59 } // namespace Battery 60 } // namespace HDI 61 } // namespace OHOS 62 #endif // CHARGER_UI_FRAME_H 63