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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
« cc/layer_tree_host_impl.cc ('K') | « cc/layer_tree_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "cc/layer_tree_impl.h"
6
7 #include "cc/layer_tree_host_common.h"
8 #include "cc/layer_tree_host_impl.h"
9
10 namespace cc {
11
12 LayerTreeImpl::LayerTreeImpl(LayerTreeImplClient* client)
13 : client_(client)
14 , source_frame_number_(-1)
15 , hud_layer_(0)
16 , root_scroll_layer_(0)
17 , currently_scrolling_layer_(0)
18 , scrolling_layer_id_from_previous_tree_(0) {
19 }
20
21 static LayerImpl* findRootScrollLayer(LayerImpl* layer)
22 {
23 if (!layer)
24 return 0;
25
26 if (layer->scrollable())
27 return layer;
28
29 for (size_t i = 0; i < layer->children().size(); ++i) {
30 LayerImpl* found = findRootScrollLayer(layer->children()[i]);
31 if (found)
32 return found;
33 }
34
35 return 0;
36 }
37
38 void LayerTreeImpl::SetRootLayer(scoped_ptr<LayerImpl> layer) {
39 root_layer_ = layer.Pass();
40 root_scroll_layer_ = findRootScrollLayer(root_layer_.get());
41 currently_scrolling_layer_ = 0;
42
43 if (root_layer_ && scrolling_layer_id_from_previous_tree_) {
44 currently_scrolling_layer_ = LayerTreeHostCommon::findLayerInSubtree(
45 root_layer_.get(),
46 scrolling_layer_id_from_previous_tree_);
47 }
48
49 scrolling_layer_id_from_previous_tree_ = 0;
50
51 client_->OnCanDrawStateChangedForTree(this);
52 }
53
54 scoped_ptr<LayerImpl> LayerTreeImpl::DetachLayerTree() {
55 // Clear all data structures that have direct references to the layer tree.
56 scrolling_layer_id_from_previous_tree_ =
57 currently_scrolling_layer_ ? currently_scrolling_layer_->id() : 0;
58 currently_scrolling_layer_ = 0;
59
60 return root_layer_.Pass();
61 }
62
63 } // namespace cc
OLDNEW
« cc/layer_tree_host_impl.cc ('K') | « cc/layer_tree_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698