• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "cj_filter.h"
16 
17 #include <atomic>
18 #include <mutex>
19 #include <shared_mutex>
20 #include <unordered_map>
21 
22 #include "effect_errors.h"
23 #include "effect_utils.h"
24 #include "filter_common.h"
25 #include "sk_image_chain.h"
26 #include "sk_image_filter_factory.h"
27 
28 namespace OHOS {
29 namespace CJEffectKit {
30 using namespace OHOS::Rosen;
31 using namespace OHOS::Media;
32 
33 const int64_t EFFECTKIT_ERROR = -1;
34 
CreateEffect(Media::PixelMapImpl * source,uint32_t & errorCode)35 int64_t CJFilter::CreateEffect(Media::PixelMapImpl* source, uint32_t& errorCode)
36 {
37     std::shared_ptr<Media::PixelMap> pixmap = source->GetRealPixelMap();
38     FilterCommon::CreateEffect(pixmap, errorCode);
39     auto native = FFIData::Create<CJFilter>();
40     if (native == nullptr) {
41         return EFFECTKIT_ERROR;
42     }
43     return native->GetID();
44 }
45 
Blur(float radius)46 void CJFilter::Blur(float radius)
47 {
48     FilterCommon::Blur(radius);
49 }
50 
Invert()51 void CJFilter::Invert()
52 {
53     FilterCommon::Invert();
54 }
55 
Brightness(float bright)56 void CJFilter::Brightness(float bright)
57 {
58     FilterCommon::Brightness(bright);
59 }
60 
Grayscale()61 void CJFilter::Grayscale()
62 {
63     FilterCommon::Grayscale();
64 }
65 
SetColorMatrix(std::vector<float> cjcolorMatrix,uint32_t & code)66 void CJFilter::SetColorMatrix(std::vector<float> cjcolorMatrix, uint32_t& code)
67 {
68     FilterCommon::SetColorMatrix(cjcolorMatrix, code);
69 }
70 
GetEffectPixelMap()71 std::shared_ptr<OHOS::Media::PixelMap> CJFilter::GetEffectPixelMap()
72 {
73     return FilterCommon::GetEffectPixelMap();
74 }
75 
76 } // namespace CJEffectKit
77 } // namespace OHOS