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_COLORSPACE_HELPER_H
17 #define IMAGE_EFFECT_COLORSPACE_HELPER_H
18 
19 #include <memory>
20 
21 #include "effect_info.h"
22 #include "color_space.h"
23 #include "error_code.h"
24 #include "surface_buffer.h"
25 #include "v1_0/cm_color_space.h"
26 #include "effect_buffer.h"
27 #include "effect_context.h"
28 #include "image_effect_marco_define.h"
29 
30 namespace OHOS {
31 namespace Media {
32 namespace Effect {
33 class ColorSpaceHelper {
34 public:
35     IMAGE_EFFECT_EXPORT static bool IsHdrColorSpace(EffectColorSpace colorSpace);
36 
37     IMAGE_EFFECT_EXPORT
38     static EffectColorSpace ConvertToEffectColorSpace(OHOS::ColorManager::ColorSpaceName colorSpaceName);
39     IMAGE_EFFECT_EXPORT static OHOS::ColorManager::ColorSpaceName ConvertToColorSpaceName(EffectColorSpace colorSpace);
40     IMAGE_EFFECT_EXPORT static EffectColorSpace ConvertToEffectColorSpace(
41         OHOS::HDI::Display::Graphic::Common::V1_0::CM_ColorSpaceType type);
42     IMAGE_EFFECT_EXPORT static OHOS::HDI::Display::Graphic::Common::V1_0::CM_ColorSpaceType ConvertToCMColorSpace(
43         EffectColorSpace colorSpace);
44     IMAGE_EFFECT_EXPORT static ErrorCode SetSurfaceBufferMetadataType(SurfaceBuffer *sb,
45         const OHOS::HDI::Display::Graphic::Common::V1_0::CM_HDR_Metadata_Type &type);
46     IMAGE_EFFECT_EXPORT static ErrorCode GetSurfaceBufferMetadataType(SurfaceBuffer *sb,
47         OHOS::HDI::Display::Graphic::Common::V1_0::CM_HDR_Metadata_Type &type);
48     IMAGE_EFFECT_EXPORT static ErrorCode SetSurfaceBufferColorSpaceType(SurfaceBuffer *sb,
49         const OHOS::HDI::Display::Graphic::Common::V1_0::CM_ColorSpaceType &type);
50     IMAGE_EFFECT_EXPORT static ErrorCode GetSurfaceBufferColorSpaceType(SurfaceBuffer *sb,
51         OHOS::HDI::Display::Graphic::Common::V1_0::CM_ColorSpaceType &type);
52 
53     IMAGE_EFFECT_EXPORT
54     static ErrorCode SetHDRDynamicMetadata(SurfaceBuffer *sb, const std::vector<uint8_t> &hdrDynamicMetadata);
55 
56     IMAGE_EFFECT_EXPORT
57     static ErrorCode SetHDRStaticMetadata(SurfaceBuffer *sb, const std::vector<uint8_t> &hdrStaticMetadata);
58 
59     IMAGE_EFFECT_EXPORT static ErrorCode UpdateMetadata(EffectBuffer *input);
60     IMAGE_EFFECT_EXPORT static ErrorCode UpdateMetadata(SurfaceBuffer *input, const EffectColorSpace &colorSpace);
61     IMAGE_EFFECT_EXPORT static ErrorCode ConvertColorSpace(std::shared_ptr<EffectBuffer> &srcBuffer,
62         std::shared_ptr<EffectContext> &context);
63 };
64 } // namespace Effect
65 } // namespace Media
66 } // namespace OHOS
67 #endif // IMAGE_EFFECT_COLORSPACE_HELPER_H
68