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 FILTER_COMMON_H 17 #define FILTER_COMMON_H 18 19 #include "include/core/SkImageFilter.h" 20 #include "pixel_map.h" 21 #include "sk_image_chain.h" 22 23 namespace OHOS { 24 namespace Rosen { 25 class FilterCommon { 26 public: 27 static std::shared_ptr<FilterCommon> CreateEffect( 28 const std::shared_ptr<Media::PixelMap>& pixmap, uint32_t& errorCode); 29 static bool Blur(float radius); 30 static bool Invert(); 31 static bool Brightness(float bright); 32 static bool Grayscale(); 33 static bool SetColorMatrix(std::vector<float> cjcolorMatrix, uint32_t& code); 34 static std::shared_ptr<OHOS::Media::PixelMap> GetEffectPixelMap(); 35 static thread_local std::shared_ptr<FilterCommon> sConstructor_; 36 void AddNextFilter(sk_sp<SkImageFilter> filter); 37 std::shared_ptr<Media::PixelMap> GetDstPixelMap(); 38 Rosen::DrawError Render(bool forceCPU); 39 std::vector<sk_sp<SkImageFilter>> skFilters_; 40 std::shared_ptr<Media::PixelMap> srcPixelMap_ = nullptr; 41 std::shared_ptr<Media::PixelMap> dstPixelMap_ = nullptr; 42 }; 43 } // namespace Rosen 44 } // namespace OHOS 45 46 #endif // FILTER_COMMON_H