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_STRATEGY_H 17 #define IMAGE_EFFECT_COLORSPACE_STRATEGY_H 18 19 #include <unordered_set> 20 21 #include "effect_buffer.h" 22 #include "error_code.h" 23 24 namespace OHOS { 25 namespace Media { 26 namespace Effect { 27 28 class ColorSpaceStrategy { 29 public: 30 ColorSpaceStrategy() = default; 31 ~ColorSpaceStrategy() = default; 32 33 static bool IsSupportedColorSpace(EffectColorSpace colorSpace); 34 static bool IsNeedConvertColorSpace(EffectColorSpace colorSpace); 35 static EffectColorSpace GetTargetColorSpace(EffectColorSpace src); 36 static std::unordered_set<EffectColorSpace> GetAllSupportedColorSpaces(); 37 38 void Init(const std::shared_ptr<EffectBuffer> &src, const std::shared_ptr<EffectBuffer> &dst); 39 40 ErrorCode ChooseColorSpace(const std::unordered_set<EffectColorSpace> &filtersSupportedColorSpace, 41 const EffectColorSpace &srcRealColorSpace, EffectColorSpace &outputColorSpace); 42 43 ErrorCode CheckConverterColorSpace(const EffectColorSpace &targetColorSpace); 44 45 void Deinit(); 46 private: 47 std::shared_ptr<EffectBuffer> src_ = nullptr; 48 std::shared_ptr<EffectBuffer> dst_ = nullptr; 49 }; 50 } // namespace Effect 51 } // namespace Media 52 } // namespace OHOS 53 #endif // IMAGE_EFFECT_COLORSPACE_STRATEGY_H 54