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_native_image_adapter_wrapper.h"
17
18 #include "ohos_adapter/bridge/ark_frame_available_listener_impl.h"
19
20 #include "base/bridge/ark_web_bridge_macros.h"
21
22 namespace OHOS::ArkWeb {
23
ArkNativeImageAdapterWrapper(ArkWebRefPtr<ArkNativeImageAdapter> ref)24 ArkNativeImageAdapterWrapper::ArkNativeImageAdapterWrapper(ArkWebRefPtr<ArkNativeImageAdapter> ref) : ctocpp_(ref) {}
25
CreateNativeImage(uint32_t textureId,uint32_t textureTarget)26 void ArkNativeImageAdapterWrapper::CreateNativeImage(uint32_t textureId, uint32_t textureTarget)
27 {
28 return ctocpp_->CreateNativeImage(textureId, textureTarget);
29 }
30
AquireNativeWindowFromNativeImage()31 NWeb::NWebNativeWindow ArkNativeImageAdapterWrapper::AquireNativeWindowFromNativeImage()
32 {
33 return ctocpp_->AquireNativeWindowFromNativeImage();
34 }
35
AttachContext(uint32_t textureId)36 int32_t ArkNativeImageAdapterWrapper::AttachContext(uint32_t textureId)
37 {
38 return ctocpp_->AttachContext(textureId);
39 }
40
DetachContext()41 int32_t ArkNativeImageAdapterWrapper::DetachContext()
42 {
43 return ctocpp_->DetachContext();
44 }
45
UpdateSurfaceImage()46 int32_t ArkNativeImageAdapterWrapper::UpdateSurfaceImage()
47 {
48 return ctocpp_->UpdateSurfaceImage();
49 }
50
GetTimestamp()51 int64_t ArkNativeImageAdapterWrapper::GetTimestamp()
52 {
53 return ctocpp_->GetTimestamp();
54 }
55
GetTransformMatrix(float matrix[16])56 int32_t ArkNativeImageAdapterWrapper::GetTransformMatrix(float matrix[16])
57 {
58 return ctocpp_->GetTransformMatrix(matrix);
59 }
60
GetSurfaceId(uint64_t * surfaceId)61 int32_t ArkNativeImageAdapterWrapper::GetSurfaceId(uint64_t* surfaceId)
62 {
63 return ctocpp_->GetSurfaceId(surfaceId);
64 }
65
SetOnFrameAvailableListener(std::shared_ptr<OHOS::NWeb::FrameAvailableListener> listener)66 int32_t ArkNativeImageAdapterWrapper::SetOnFrameAvailableListener(
67 std::shared_ptr<OHOS::NWeb::FrameAvailableListener> listener)
68 {
69 if (CHECK_SHARED_PTR_IS_NULL(listener)) {
70 return ctocpp_->SetOnFrameAvailableListener(nullptr);
71 }
72 return ctocpp_->SetOnFrameAvailableListener(new ArkFrameAvailableListenerImpl(listener));
73 }
74
UnsetOnFrameAvailableListener()75 int32_t ArkNativeImageAdapterWrapper::UnsetOnFrameAvailableListener()
76 {
77 return ctocpp_->UnsetOnFrameAvailableListener();
78 }
79
DestroyNativeImage()80 void ArkNativeImageAdapterWrapper::DestroyNativeImage()
81 {
82 return ctocpp_->DestroyNativeImage();
83 }
84
NewNativeImage()85 void ArkNativeImageAdapterWrapper::NewNativeImage()
86 {
87 return ctocpp_->NewNativeImage();
88 }
89
AcquireNativeWindowBuffer(void ** windowBuffer,int * acquireFenceFd)90 int32_t ArkNativeImageAdapterWrapper::AcquireNativeWindowBuffer(
91 void** windowBuffer,
92 int* acquireFenceFd)
93 {
94 return ctocpp_->AcquireNativeWindowBuffer(windowBuffer, acquireFenceFd);
95 }
96
GetNativeBuffer(void * windowBuffer,void ** nativeBuffer)97 int32_t ArkNativeImageAdapterWrapper::GetNativeBuffer(
98 void* windowBuffer,
99 void** nativeBuffer)
100 {
101 return ctocpp_->GetNativeBuffer(windowBuffer, nativeBuffer);
102 }
103
ReleaseNativeWindowBuffer(void * windowBuffer,int fenceFd)104 int32_t ArkNativeImageAdapterWrapper::ReleaseNativeWindowBuffer(void* windowBuffer, int fenceFd)
105 {
106 return ctocpp_->ReleaseNativeWindowBuffer(windowBuffer, fenceFd);
107 }
108
GetNativeWindowBufferSize(void * windowBuffer,uint32_t * width,uint32_t * height)109 void ArkNativeImageAdapterWrapper::GetNativeWindowBufferSize(
110 void* windowBuffer,
111 uint32_t* width,
112 uint32_t* height)
113 {
114 return ctocpp_->GetNativeWindowBufferSize(windowBuffer, width, height);
115 }
116
117 } // namespace OHOS::ArkWeb
118