• 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 #include "rs_trace.h"
17 #include "filter.h"
18 
19 namespace OHOS {
20 namespace Rosen {
Process(ProcessData & data)21 void Filter::Process(ProcessData& data)
22 {
23     ROSEN_TRACE_BEGIN(BYTRACE_TAG_GRAPHIC_AGP, "Filter::DoProcess");
24     DoProcess(data);
25     ROSEN_TRACE_END(BYTRACE_TAG_GRAPHIC_AGP);
26     if (this->GetFilterType() == FILTER_TYPE::ALGOFILTER) {
27         std::swap(data.srcTextureID, data.dstTextureID);
28     }
29     if (GetNextFilter() != nullptr) {
30         GetNextFilter()->Process(data);
31     }
32 }
33 
AddNextFilter(std::shared_ptr<Filter> next)34 void Filter::AddNextFilter(std::shared_ptr<Filter> next)
35 {
36     if (nextNum_ < nextPtrMax_) {
37         next_ = next;
38         if (next != nullptr) {
39             next->AddPreviousFilter(std::shared_ptr<Filter>(this));
40         }
41     }
42     if (nextNum_ == nextPtrMax_) {
43         return;
44     }
45     nextNum_++;
46 }
47 
AddPreviousFilter(std::shared_ptr<Filter> previous)48 void Filter::AddPreviousFilter(std::shared_ptr<Filter> previous)
49 {
50     if (preNum_ < prePtrMax_) {
51         previous_ = previous;
52     }
53     if (preNum_ == prePtrMax_) {
54         return;
55     }
56     preNum_++;
57 }
58 
GetNextFilter()59 std::shared_ptr<Filter> Filter::GetNextFilter()
60 {
61     return next_;
62 }
63 
GetPreviousFilter()64 std::shared_ptr<Filter> Filter::GetPreviousFilter()
65 {
66     return previous_;
67 }
68 
GetInputNumber()69 int Filter::GetInputNumber()
70 {
71     return preNum_;
72 }
73 
GetOutputNumber()74 int Filter::GetOutputNumber()
75 {
76     return nextNum_;
77 }
78 
GetMaxInputNumber()79 int Filter::GetMaxInputNumber()
80 {
81     return prePtrMax_;
82 }
83 
GetMaxOutputNumber()84 int Filter::GetMaxOutputNumber()
85 {
86     return nextPtrMax_;
87 }
88 } // namespcae Rosen
89 } // namespace OHOS