• 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 UPDATER_UI_GRAPHIC_ENGINE_H
17 #define UPDATER_UI_GRAPHIC_ENGINE_H
18 
19 #include <memory>
20 #include <thread>
21 #include "engines/gfx/soft_engine.h"
22 #include "macros.h"
23 #include "surface_dev.h"
24 
25 namespace Updater {
26 class GraphicEngine : public OHOS::SoftEngine {
27     static constexpr uint32_t THREAD_USLEEP_TIME = 10000;
28     DISALLOW_COPY_MOVE(GraphicEngine);
29 public:
30     GraphicEngine() = default;
31     virtual ~GraphicEngine() = default;
32     static GraphicEngine &GetInstance();
33     void Init(uint32_t bkgColor, uint8_t mode, const char *fontPath);
34     void Flush(const OHOS::Rect& flushRect) override;
35     OHOS::BufferInfo *GetFBBufferInfo() override;
36     uint16_t GetScreenWidth() override;
37     uint16_t GetScreenHeight() override;
38 
39 private:
40     void FlushThreadLoop() const;
41     void InitFontEngine(const char *fontPath) const;
42     void InitImageDecodeAbility() const;
43     void InitFlushThread();
44     std::thread flushLoop_;
45     std::unique_ptr<OHOS::BufferInfo> buffInfo_ = nullptr;
46     std::unique_ptr<uint8_t[]> virAddr_ = nullptr;
47     std::unique_ptr<SurfaceDev> sfDev_ = nullptr;
48     uint32_t bkgColor_ = 0;
49     uint16_t height_ = 0;
50     uint16_t width_ = 0;
51     uint8_t colorMode_ = 0;
52     bool flushStop_ = true;
53 };
54 } // namespace Updater
55 #endif
56