1 /*
2  * Copyright (c) 2022 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_H
17 #define FILTER_H
18 
19 #include <memory>
20 #include <string>
21 #include <vector>
22 #include <iostream>
23 #include <fstream>
24 #include <sstream>
25 #include <GLES3/gl32.h>
26 #include "program.h"
27 #include "ec_log.h"
28 
29 namespace OHOS {
30 namespace Rosen {
31 enum class FILTER_TYPE { INPUT, ALGOFILTER, MEGERFILTER, OUTPUT };
32 
33 struct ProcessData {
34     GLuint srcTextureID;
35     GLuint dstTextureID;
36     GLuint frameBufferID;
37     int textureWidth;
38     int textureHeight;
39 };
40 
41 class Filter {
42 public:
Filter()43     Filter() {};
~Filter()44     virtual ~Filter() {};
45     virtual FILTER_TYPE GetFilterType() = 0;
46     virtual bool Process(ProcessData& data);
47     virtual void AddNextFilter(std::shared_ptr<Filter> next);
48     virtual void AddPreviousFilter(std::shared_ptr<Filter> previous);
49     virtual std::shared_ptr<Filter> GetNextFilter();
50     virtual std::shared_ptr<Filter> GetPreviousFilter();
51     virtual int GetInputNumber();
52     virtual int GetOutputNumber();
53     virtual int GetMaxInputNumber();
54     virtual int GetMaxOutputNumber();
SetValue(const std::string & key,std::shared_ptr<void> value,int size)55     virtual void SetValue(const std::string& key, std::shared_ptr<void> value, int size) {};
56 
57 protected:
58     virtual void DoProcess(ProcessData& data) = 0;
59     int nextNum_ = 0;
60     int preNum_ = 0;
61     int nextPtrMax_ = 1;
62     int prePtrMax_ = 1;
63     std::shared_ptr<Filter> previous_ = nullptr;
64     std::shared_ptr<Filter> next_ = nullptr;
65 };
66 } // namespace Rosen
67 } // namespace OHOS
68 #endif // FILTER_H
69