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_CONTRAST_EFILTER_H 17 #define IMAGE_EFFECT_CONTRAST_EFILTER_H 18 19 #include "efilter.h" 20 #include "gpu_contrast_algo.h" 21 #include "image_effect_marco_define.h" 22 23 namespace OHOS { 24 namespace Media { 25 namespace Effect { 26 class ContrastEFilter : public EFilter { 27 public: 28 class Parameter : public EFilter::Parameter { 29 public: 30 static const float INTENSITY_RANGE[]; 31 static const std::string KEY_INTENSITY; 32 }; 33 34 IMAGE_EFFECT_EXPORT explicit ContrastEFilter(const std::string &name); 35 36 ~ContrastEFilter() override; 37 38 ErrorCode Render(EffectBuffer *buffer, std::shared_ptr<EffectContext> &context) override; 39 40 ErrorCode Render(EffectBuffer *src, EffectBuffer *dst, std::shared_ptr<EffectContext> &context) override; 41 42 ErrorCode SetValue(const std::string &key, Plugin::Any &value) override; 43 44 ErrorCode Restore(const EffectJsonPtr &values) override; 45 46 IMAGE_EFFECT_EXPORT static std::shared_ptr<EffectInfo> GetEffectInfo(const std::string &name); 47 48 ErrorCode PreRender(IEffectFormat &format) override; 49 private: 50 using ApplyFunc = 51 std::function<ErrorCode(EffectBuffer *src, EffectBuffer *dst, std::map<std::string, Plugin::Any> &value, 52 std::shared_ptr<EffectContext> &context)>; 53 54 static std::shared_ptr<EffectInfo> info_; 55 std::unordered_map<IPType, std::unordered_map<IEffectFormat, ApplyFunc>> contrastFilterInfo_; 56 std::shared_ptr<GpuContrastAlgo> gpuContrastAlgo_; 57 }; 58 } // namespace Effect 59 } // namespace Media 60 } // namespace OHOS 61 62 #endif // IMAGE_EFFECT_CONTRAST_EFILTER_H