blob: 908bce239eb643916480cb5288779b4ad8a79331 [file] [log] [blame]
Avi Drissman3e1a26c2022-09-15 20:26:031// Copyright 2014 The Chromium Authors
[email protected]25e9e1e2014-03-11 16:26:022// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "ui/compositor/layer_tree_owner.h"
6
Ali Hijazie63cbaf62023-12-20 19:29:357#include "base/memory/raw_ptr.h"
[email protected]25e9e1e2014-03-11 16:26:028#include "ui/compositor/layer.h"
9
10namespace ui {
11
12namespace {
13
14// Deletes |layer| and all its descendants.
15void DeepDeleteLayers(Layer* layer) {
Ali Hijazie63cbaf62023-12-20 19:29:3516 std::vector<raw_ptr<Layer, VectorExperimental>> children = layer->children();
17 for (std::vector<raw_ptr<Layer, VectorExperimental>>::const_iterator it =
18 children.begin();
19 it != children.end(); ++it) {
[email protected]25e9e1e2014-03-11 16:26:0220 Layer* child = *it;
21 DeepDeleteLayers(child);
22 }
23 delete layer;
24}
25
26} // namespace
27
domlaskowski4b33bfe2016-10-27 00:34:2228LayerTreeOwner::LayerTreeOwner(std::unique_ptr<Layer> root)
29 : root_(root.release()) {}
[email protected]25e9e1e2014-03-11 16:26:0230
31LayerTreeOwner::~LayerTreeOwner() {
32 if (root_)
33 DeepDeleteLayers(root_);
34}
35
36} // namespace ui