• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "cJSON.h"
27 #include "program.h"
28 #include "ec_log.h"
29 
30 namespace OHOS {
31 namespace Rosen {
32 enum class FILTER_TYPE { INPUT, ALGOFILTER, MEGERFILTER, OUTPUT };
33 
34 struct ProcessData {
35     GLuint srcTextureID;
36     GLuint dstTextureID;
37     GLuint frameBufferID;
38     int textureWidth;
39     int textureHeight;
40 };
41 
42 class Filter {
43 public:
Filter()44     Filter() {};
~Filter()45     virtual ~Filter() {};
46     virtual FILTER_TYPE GetFilterType() = 0;
47     virtual void Process(ProcessData& data);
48     virtual void DoProcess(ProcessData& data) = 0;
49     virtual void AddNextFilter(std::shared_ptr<Filter> next);
50     virtual void AddPreviousFilter(std::shared_ptr<Filter> previous);
51     virtual std::shared_ptr<Filter> GetNextFilter();
52     virtual std::shared_ptr<Filter> GetPreviousFilter();
53     virtual int GetInputNumber();
54     virtual int GetOutputNumber();
55     virtual int GetMaxInputNumber();
56     virtual int GetMaxOutputNumber();
SetValue(const std::string & key,void * value,int size)57     virtual void SetValue(const std::string& key, void* value, int size) {};
58 
59 protected:
60     int nextNum_ = 0;
61     int preNum_ = 0;
62     int nextPtrMax_ = 1;
63     int prePtrMax_ = 1;
64     std::shared_ptr<Filter> previous_ = nullptr;
65     std::shared_ptr<Filter> next_ = nullptr;
66 };
67 } // namespace Rosen
68 } // namespace OHOS
69 #endif // FILTER_H
70