1 /*
2  * Copyright (c) 2021 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 <algorithm>
17 
18 #include "core/pipeline/layers/layer.h"
19 
20 #include "base/log/dump_log.h"
21 
22 namespace OHOS::Ace::Flutter {
23 
AddChildren(const RefPtr<Layer> & layer)24 void Layer::AddChildren(const RefPtr<Layer>& layer)
25 {
26     auto it = std::find(children_.begin(), children_.end(), layer);
27     if (it == children_.end()) {
28         layer->SetParent(AceType::Claim(this));
29         children_.push_back(layer);
30     }
31 }
32 
DumpTree(int32_t depth)33 void Layer::DumpTree(int32_t depth)
34 {
35     if (DumpLog::GetInstance().GetDumpFile()) {
36         Dump();
37         DumpLog::GetInstance().Print(depth, AceType::TypeName(this), children_.size());
38     }
39 
40     for (const auto& item : children_) {
41         item->DumpTree(depth + 1);
42     }
43 }
44 
45 } // namespace OHOS::Ace::Flutter
46