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_NATIVE_COMMON_UTILS_H 17 #define IMAGE_EFFECT_NATIVE_COMMON_UTILS_H 18 19 #include <vector> 20 21 #include "any.h" 22 #include "effect_info.h" 23 #include "error_code.h" 24 #include "image_effect_filter.h" 25 #include "image_type.h" 26 #include "pixel_map_napi.h" 27 #include "picture_native_impl.h" 28 29 #define EFFECT_EXPORT __attribute__((visibility("default"))) 30 31 namespace OHOS { 32 namespace Media { 33 namespace Effect { 34 class NativeCommonUtils { 35 public: 36 static ErrorCode ParseOHAny(const ImageEffect_Any *value, Plugin::Any &any); 37 38 static ErrorCode SwitchToOHAny(const Plugin::Any &any, ImageEffect_Any *value); 39 40 static void SwitchToOHFormatType(const IEffectFormat &formatType, ImageEffect_Format &ohFormatType); 41 42 static void SwitchToFormatType(const ImageEffect_Format &ohFormatType, IEffectFormat &formatType); 43 44 static void SwitchToOHEffectInfo(const EffectInfo *effectInfo, OH_EffectFilterInfo *ohFilterInfo); 45 46 static PixelMap *GetPixelMapFromOHPixelmap(OH_PixelmapNative *pixelmapNative); 47 48 static Picture *GetPictureFromNativePicture(OH_PictureNative *pictureNative); 49 50 static void ParseLookupKey(std::string &key, std::vector<const char *> &matchEFilter); 51 52 static void SwitchToEffectInfo(const OH_EffectFilterInfo *info, const std::shared_ptr<EffectInfo> &effectInfo); 53 54 static uint32_t GetSupportedFormats(const OH_EffectFilterInfo *ohFilterInfo); 55 56 static void ReportEventStartFailed(ImageEffect_ErrorCode errorCode, const char *errorMsg); 57 58 static ImageEffect_ErrorCode ConvertStartResult(ErrorCode errorCode); 59 }; 60 } // namespace Effect 61 } // namespace Media 62 } // namespace OHOS 63 #endif // IMAGE_EFFECT_NATIVE_COMMON_UTILS_H