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 #include "ohos_adapter/bridge/ark_window_adapter_wrapper.h"
17
18 namespace OHOS::ArkWeb {
19
ArkWindowAdapterWrapper(ArkWebRefPtr<ArkWindowAdapter> ref)20 ArkWindowAdapterWrapper::ArkWindowAdapterWrapper(ArkWebRefPtr<ArkWindowAdapter> ref) : ctocpp_(ref) {}
21
CreateNativeWindowFromSurface(void * pSurface)22 ArkWebNativeWindow ArkWindowAdapterWrapper::CreateNativeWindowFromSurface(void* pSurface)
23 {
24 if (!ctocpp_) {
25 return nullptr;
26 }
27 return ctocpp_->CreateNativeWindowFromSurface(pSurface);
28 }
29
DestroyNativeWindow(ArkWebNativeWindow window)30 void ArkWindowAdapterWrapper::DestroyNativeWindow(ArkWebNativeWindow window)
31 {
32 if (!ctocpp_) {
33 return;
34 }
35 ctocpp_->DestroyNativeWindow(window);
36 }
37
NativeWindowSetBufferGeometry(ArkWebNativeWindow window,int32_t width,int32_t height)38 int32_t ArkWindowAdapterWrapper::NativeWindowSetBufferGeometry(ArkWebNativeWindow window, int32_t width, int32_t height)
39 {
40 if (!ctocpp_) {
41 return -1;
42 }
43 return ctocpp_->NativeWindowSetBufferGeometry(window, width, height);
44 }
45
NativeWindowSurfaceCleanCache(ArkWebNativeWindow window)46 void ArkWindowAdapterWrapper::NativeWindowSurfaceCleanCache(ArkWebNativeWindow window)
47 {
48 if (!ctocpp_) {
49 return;
50 }
51 ctocpp_->NativeWindowSurfaceCleanCache(window);
52 }
53
NativeWindowSurfaceCleanCacheWithPara(ArkWebNativeWindow window,bool cleanAll)54 void ArkWindowAdapterWrapper::NativeWindowSurfaceCleanCacheWithPara(ArkWebNativeWindow window, bool cleanAll)
55 {
56 if (!ctocpp_) {
57 return;
58 }
59 ctocpp_->NativeWindowSurfaceCleanCacheWithPara(window, cleanAll);
60 }
61 } // namespace OHOS::ArkWeb
62