1 /*
2 * Copyright (c) 2023 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_ohos_image_decoder_adapter_impl.h"
17
18 #include "ohos_image_decoder_adapter.h"
19
20 namespace OHOS::ArkWeb {
21
ArkOhosImageDecoderAdapterImpl(std::shared_ptr<OHOS::NWeb::OhosImageDecoderAdapter> ref)22 ArkOhosImageDecoderAdapterImpl::ArkOhosImageDecoderAdapterImpl(std::shared_ptr<OHOS::NWeb::OhosImageDecoderAdapter> ref)
23 : real_(ref)
24 {}
25
ParseImageInfo(const uint8_t * data,uint32_t size)26 bool ArkOhosImageDecoderAdapterImpl::ParseImageInfo(const uint8_t* data, uint32_t size)
27 {
28 return real_->ParseImageInfo(data, size);
29 }
30
GetEncodedFormat()31 ArkWebString ArkOhosImageDecoderAdapterImpl::GetEncodedFormat()
32 {
33 return ArkWebStringClassToStruct(real_->GetEncodedFormat());
34 }
35
GetImageWidth()36 int32_t ArkOhosImageDecoderAdapterImpl::GetImageWidth()
37 {
38 return real_->GetImageWidth();
39 }
40
GetImageHeight()41 int32_t ArkOhosImageDecoderAdapterImpl::GetImageHeight()
42 {
43 return real_->GetImageHeight();
44 }
45
DecodeToPixelMap(const uint8_t * data,uint32_t size)46 bool ArkOhosImageDecoderAdapterImpl::DecodeToPixelMap(const uint8_t* data, uint32_t size)
47 {
48 return real_->DecodeToPixelMap(data, size);
49 }
50
Decode(const uint8_t * data,uint32_t size,uint32_t type,bool useYuv)51 bool ArkOhosImageDecoderAdapterImpl::Decode(const uint8_t* data,
52 uint32_t size,
53 uint32_t type,
54 bool useYuv)
55 {
56 return real_->Decode(data, size, (OHOS::NWeb::AllocatorType)type, useYuv);
57 }
58
GetFd()59 int32_t ArkOhosImageDecoderAdapterImpl::GetFd()
60 {
61 return real_->GetFd();
62 }
63
GetStride()64 int32_t ArkOhosImageDecoderAdapterImpl::GetStride()
65 {
66 return real_->GetStride();
67 }
68
GetOffset()69 int32_t ArkOhosImageDecoderAdapterImpl::GetOffset()
70 {
71 return real_->GetOffset();
72 }
73
GetSize()74 uint64_t ArkOhosImageDecoderAdapterImpl::GetSize()
75 {
76 return real_->GetSize();
77 }
78
GetNativeWindowBuffer()79 void* ArkOhosImageDecoderAdapterImpl::GetNativeWindowBuffer()
80 {
81 return real_->GetNativeWindowBuffer();
82 }
83
GetPlanesCount()84 int32_t ArkOhosImageDecoderAdapterImpl::GetPlanesCount()
85 {
86 return real_->GetPlanesCount();
87 }
88
ReleasePixelMap()89 void ArkOhosImageDecoderAdapterImpl::ReleasePixelMap()
90 {
91 return real_->ReleasePixelMap();
92 }
93
GetDecodeData()94 void* ArkOhosImageDecoderAdapterImpl::GetDecodeData()
95 {
96 return real_->GetDecodeData();
97 }
98
99 } // namespace OHOS::ArkWeb
100