Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Unified Diff: cc/layer_tree_impl.cc

Issue 11450015: [cc] Move root layer pointer to LayerTreeImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/layer_tree_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/layer_tree_impl.cc
diff --git a/cc/layer_tree_impl.cc b/cc/layer_tree_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ba4874cb8bbd4268915003a29d2421cc1cc3bdf3
--- /dev/null
+++ b/cc/layer_tree_impl.cc
@@ -0,0 +1,71 @@
+// Copyright 2011 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 "cc/layer_tree_impl.h"
+
+#include "cc/layer_tree_host_common.h"
+#include "cc/layer_tree_host_impl.h"
+
+namespace cc {
+
+LayerTreeImpl::LayerTreeImpl(LayerTreeImplClient* client)
+ : client_(client)
+ , source_frame_number_(-1)
+ , hud_layer_(0)
+ , root_scroll_layer_(0)
+ , currently_scrolling_layer_(0)
+ , scrolling_layer_id_from_previous_tree_(0) {
+}
+
+LayerTreeImpl::~LayerTreeImpl() {
+}
+
+static LayerImpl* findRootScrollLayer(LayerImpl* layer)
+{
+ if (!layer)
+ return 0;
+
+ if (layer->scrollable())
+ return layer;
+
+ for (size_t i = 0; i < layer->children().size(); ++i) {
+ LayerImpl* found = findRootScrollLayer(layer->children()[i]);
+ if (found)
+ return found;
+ }
+
+ return 0;
+}
+
+void LayerTreeImpl::SetRootLayer(scoped_ptr<LayerImpl> layer) {
+ root_layer_ = layer.Pass();
+ root_scroll_layer_ = findRootScrollLayer(root_layer_.get());
+ currently_scrolling_layer_ = 0;
+
+ if (root_layer_ && scrolling_layer_id_from_previous_tree_) {
+ currently_scrolling_layer_ = LayerTreeHostCommon::findLayerInSubtree(
+ root_layer_.get(),
+ scrolling_layer_id_from_previous_tree_);
+ }
+
+ scrolling_layer_id_from_previous_tree_ = 0;
+
+ client_->OnCanDrawStateChangedForTree(this);
+}
+
+scoped_ptr<LayerImpl> LayerTreeImpl::DetachLayerTree() {
+ // Clear all data structures that have direct references to the layer tree.
+ scrolling_layer_id_from_previous_tree_ =
+ currently_scrolling_layer_ ? currently_scrolling_layer_->id() : 0;
+ currently_scrolling_layer_ = NULL;
+
+ return root_layer_.Pass();
+}
+
+void LayerTreeImpl::ClearCurrentlyScrollingLayer() {
+ currently_scrolling_layer_ = NULL;
+ scrolling_layer_id_from_previous_tree_ = 0;
+}
+
+} // namespace cc
« no previous file with comments | « cc/layer_tree_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698