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