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 #ifndef OHOS_IMAGE_DECODER_ADAPTER_H 17 #define OHOS_IMAGE_DECODER_ADAPTER_H 18 19 #include <string> 20 21 namespace OHOS::NWeb { 22 23 enum class AllocatorType : int32_t { 24 kDefault = 0, 25 kHeapAlloc = 1, 26 kShareMemAlloc = 2, 27 kCustomAlloc = 3, 28 kDmaAlloc = 4, 29 }; 30 31 class OhosImageDecoderAdapter { 32 public: 33 OhosImageDecoderAdapter() = default; 34 35 virtual ~OhosImageDecoderAdapter() = default; 36 37 virtual bool ParseImageInfo(const uint8_t* data, uint32_t size) = 0; 38 39 virtual std::string GetEncodedFormat() = 0; 40 41 virtual int32_t GetImageWidth() = 0; 42 43 virtual int32_t GetImageHeight() = 0; 44 45 virtual bool DecodeToPixelMap(const uint8_t* data, uint32_t size) = 0; 46 47 virtual int32_t GetFd() = 0; 48 49 virtual int32_t GetStride() = 0; 50 51 virtual int32_t GetOffset() = 0; 52 53 virtual uint64_t GetSize() = 0; 54 55 virtual void* GetNativeWindowBuffer() = 0; 56 57 virtual int32_t GetPlanesCount() = 0; 58 59 virtual void ReleasePixelMap() = 0; 60 61 virtual bool Decode(const uint8_t* data, 62 uint32_t size, 63 AllocatorType type, 64 bool useYuv) = 0; 65 66 virtual void* GetDecodeData() = 0; 67 }; 68 69 } // namespace OHOS::NWeb 70 71 #endif // OHOS_IMAGE_DECODER_ADAPTER_H