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 #include "lite_proxy_window.h"
17 #include "gfx_utils/graphic_log.h"
18 #include "surface.h"
19 
20 namespace OHOS {
LiteProxyWindow(LiteWinRequestor * requestor)21 LiteProxyWindow::LiteProxyWindow(LiteWinRequestor* requestor)
22     : winRequestor_(requestor), id_(INVALID_WINDOW_ID), surface_(nullptr)
23 {
24 }
25 
~LiteProxyWindow()26 LiteProxyWindow::~LiteProxyWindow()
27 {
28     if (winRequestor_ != nullptr) {
29         delete winRequestor_;
30         winRequestor_ = nullptr;
31     }
32 
33     if (surface_ != nullptr) {
34         delete surface_;
35         surface_ = nullptr;
36     }
37 }
38 
Init()39 int LiteProxyWindow::Init()
40 {
41     return 0;
42 }
43 
Destroy()44 void LiteProxyWindow::Destroy()
45 {
46 }
47 
Show()48 void LiteProxyWindow::Show()
49 {
50     if (winRequestor_ != nullptr) {
51         winRequestor_->Show();
52     }
53 }
54 
Hide()55 void LiteProxyWindow::Hide()
56 {
57     if (winRequestor_ != nullptr) {
58         winRequestor_->Hide();
59     }
60 }
61 
Resize(int16_t width,int16_t height)62 void LiteProxyWindow::Resize(int16_t width, int16_t height)
63 {
64     if (winRequestor_ != nullptr) {
65         winRequestor_->Resize(width, height);
66     }
67 }
68 
MoveTo(int16_t x,int16_t y)69 void LiteProxyWindow::MoveTo(int16_t x, int16_t y)
70 {
71     if (winRequestor_ != nullptr) {
72         winRequestor_->MoveTo(x, y);
73     }
74 }
75 
RaiseToTop()76 void LiteProxyWindow::RaiseToTop()
77 {
78     if (winRequestor_ != nullptr) {
79         winRequestor_->RaiseToTop();
80     }
81 }
82 
LowerToBottom()83 void LiteProxyWindow::LowerToBottom()
84 {
85     if (winRequestor_ != nullptr) {
86         winRequestor_->LowerToBottom();
87     }
88 }
89 
GetSurface()90 ISurface* LiteProxyWindow::GetSurface()
91 {
92     if (surface_ == nullptr) {
93         Surface* surface = winRequestor_->GetSurface();
94         if (surface == nullptr) {
95             return nullptr;
96         }
97         surface_ = new LiteProxySurface(surface);
98     }
99     return surface_;
100 }
101 
GetWindowId()102 int32_t LiteProxyWindow::GetWindowId()
103 {
104     if (id_ != INVALID_WINDOW_ID) {
105         return id_;
106     }
107 
108     if (winRequestor_ != nullptr) {
109         id_ = winRequestor_->GetWindowId();
110         return id_;
111     }
112     return INVALID_WINDOW_ID;
113 }
114 
Update()115 void LiteProxyWindow::Update()
116 {
117     if (winRequestor_ != nullptr) {
118         winRequestor_->Update();
119     }
120 }
121 }