1 /*
2  * Copyright (c) 2020-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 GRAPHIC_LITE_WINDOW_IMPL_H
17 #define GRAPHIC_LITE_WINDOW_IMPL_H
18 
19 #include "components/root_view.h"
20 #include "engines/gfx/gfx_engine_manager.h"
21 #include "iwindow.h"
22 #include "window/window.h"
23 
24 namespace OHOS {
25 class WindowImpl : public Window {
26 public:
27     WindowImpl();
28     virtual ~WindowImpl();
29 
30     void BindRootView(RootView* rootView) override;
31     void UnbindRootView() override;
32     RootView* GetRootView() override;
33     Rect GetRect() override;
34 
35     void Show() override;
36     void Hide() override;
37     void MoveTo(int16_t x, int16_t y) override;
38     void Resize(int16_t width, int16_t height) override;
39     void RaiseToTop() override;
40     void LowerToBottom() override;
41 
42     int32_t GetWindowId() override;
43 
44     void Render();
45     void Update();
46     void Flush();
47     bool Create(const WindowConfig& config);
48     void Destroy();
49     void AddToDisplay();
50     void RemoveFromDisplay();
51 
52     BufferInfo* GetBufferInfo();
53 
54 private:
55     void UpdateHalDisplayBuffer();
56 
57     struct AllocationInfo {
58         uint8_t* virAddr;
59         uint8_t* phyAddr;
60         uint16_t width;
61         uint16_t height;
62         uint32_t stride;
63         ImagePixelFormat pixelFormat;
64     };
65     RootView* rootView_;
66     IWindow* iWindow_;
67     WindowConfig config_;
68     bool isShow_;
69     AllocationInfo gfxAlloc_;
70 };
71 }
72 #endif
73