1 /* 2 * Copyright (C) 2024 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 IMAGE_EFFECT_EFFECT_BUFFER_H 17 #define IMAGE_EFFECT_EFFECT_BUFFER_H 18 19 #include <memory> 20 21 #include "effect_info.h" 22 #include "effect_type.h" 23 #include "pixel_map.h" 24 #include "surface_buffer.h" 25 #include "image_effect_marco_define.h" 26 #include "picture.h" 27 28 namespace OHOS { 29 namespace Media { 30 namespace Effect { 31 enum class EffectPixelmapType { 32 UNKNOWN = 0, 33 PRIMARY, 34 GAINMAP, 35 DEPTHMAP, 36 UNREFOCUS, 37 WATERMARK_CUT, 38 }; 39 40 class BufferInfo { 41 public: 42 uint32_t width_ = 0; 43 uint32_t height_ = 0; 44 uint32_t len_ = 0; 45 IEffectFormat formatType_ = IEffectFormat::DEFAULT; 46 EffectColorSpace colorSpace_ = EffectColorSpace::DEFAULT; 47 uint32_t rowStride_ = 0; 48 BufferType bufferType_ = BufferType::DEFAULT; 49 EffectPixelmapType pixelmapType_ = EffectPixelmapType::UNKNOWN; 50 void *addr_ = nullptr; 51 }; 52 53 enum class DataType { 54 UNKNOWN = 0, 55 PIXEL_MAP, 56 SURFACE, 57 SURFACE_BUFFER, 58 URI, 59 PATH, 60 TEX, 61 NATIVE_WINDOW, 62 PICTURE, 63 }; 64 65 struct ExtraInfo { 66 DataType dataType = DataType::UNKNOWN; 67 BufferType bufferType = BufferType::DEFAULT; 68 PixelMap *pixelMap = nullptr; 69 std::shared_ptr<PixelMap> innerPixelMap = nullptr; // converter pixel map for color space, such as adobe rgb 70 OHOS::SurfaceBuffer *surfaceBuffer = nullptr; 71 Picture *picture = nullptr; 72 std::shared_ptr<Picture> innerPicture = nullptr; // decoded pixel map for url or path 73 int *fd = nullptr; 74 std::string uri; 75 std::string path; 76 int64_t timestamp = 0; 77 }; 78 79 class RenderTexture; 80 using RenderTexturePtr = std::shared_ptr<RenderTexture>; 81 class EffectBuffer { 82 public: 83 IMAGE_EFFECT_EXPORT EffectBuffer(std::shared_ptr<BufferInfo> & info,void * buffer,std::shared_ptr<ExtraInfo> & extraInfo)84 EffectBuffer(std::shared_ptr<BufferInfo> &info, void *buffer, std::shared_ptr<ExtraInfo> &extraInfo) 85 : bufferInfo_(info), buffer_(buffer), extraInfo_(extraInfo) {}; 86 87 std::shared_ptr<BufferInfo> bufferInfo_ = nullptr; 88 void *buffer_ = nullptr; 89 RenderTexturePtr tex; 90 std::shared_ptr<ExtraInfo> extraInfo_ = nullptr; 91 std::shared_ptr<std::unordered_map<EffectPixelmapType, std::shared_ptr<BufferInfo>>> auxiliaryBufferInfos = nullptr; 92 }; 93 } // namespace Effect 94 } // namespace Media 95 } // namespace OHOS 96 #endif // IMAGE_EFFECT_EFFECT_BUFFER_H 97