diff options
Diffstat (limited to 'chromium/ui/compositor/layer_tree_owner.cc')
-rw-r--r-- | chromium/ui/compositor/layer_tree_owner.cc | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/chromium/ui/compositor/layer_tree_owner.cc b/chromium/ui/compositor/layer_tree_owner.cc new file mode 100644 index 00000000000..ebb0a7fc7f4 --- /dev/null +++ b/chromium/ui/compositor/layer_tree_owner.cc @@ -0,0 +1,34 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ui/compositor/layer_tree_owner.h" + +#include "ui/compositor/layer.h" + +namespace ui { + +namespace { + +// Deletes |layer| and all its descendants. +void DeepDeleteLayers(Layer* layer) { + std::vector<Layer*> children = layer->children(); + for (std::vector<Layer*>::const_iterator it = children.begin(); + it != children.end(); + ++it) { + Layer* child = *it; + DeepDeleteLayers(child); + } + delete layer; +} + +} // namespace + +LayerTreeOwner::LayerTreeOwner(Layer* root) : root_(root) {} + +LayerTreeOwner::~LayerTreeOwner() { + if (root_) + DeepDeleteLayers(root_); +} + +} // namespace ui |