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_IMPL 17 #define OHOS_IMAGE_DECODER_ADAPTER_IMPL 18 19 #include "foundation/graphic/graphic_surface/interfaces/inner_api/surface/native_buffer.h" 20 #include "image_type.h" 21 #include "ohos_image_decoder_adapter.h" 22 #include "surface_buffer.h" 23 24 namespace OHOS { 25 26 namespace Media { 27 class PixelMap; 28 } 29 30 namespace NWeb { 31 32 class OhosImageDecoderAdapterImpl : public OhosImageDecoderAdapter { 33 public: 34 OhosImageDecoderAdapterImpl(); 35 ~OhosImageDecoderAdapterImpl() override; 36 37 bool ParseImageInfo(const uint8_t* data, uint32_t size) override; 38 std::string GetEncodedFormat() override; 39 int32_t GetImageWidth() override; 40 int32_t GetImageHeight() override; 41 bool DecodeToPixelMap(const uint8_t* data, uint32_t size) override; 42 bool Decode(const uint8_t* data, 43 uint32_t size, 44 AllocatorType type, 45 bool useYuv) override; 46 int32_t GetFd() override; 47 int32_t GetStride() override; 48 int32_t GetOffset() override; 49 uint64_t GetSize() override; 50 void* GetNativeWindowBuffer() override; 51 int32_t GetPlanesCount() override; 52 void ReleasePixelMap() override; GetPixelMap()53 Media::PixelMap* GetPixelMap() { return pixelMap_.get(); } 54 void* GetDecodeData() override; 55 56 private: 57 Media::ImageInfo imageInfo_; 58 std::unique_ptr<Media::PixelMap> pixelMap_; 59 OHNativeWindowBuffer* nativeWindowBuffer_ = nullptr; 60 }; 61 62 } // namespace NWeb 63 } // namespace OHOS 64 #endif // OHOS_IMAGE_DECODER_ADAPTER_IMPL