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

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: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « 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 LayerTreeImpl::~LayerTreeImpl() {
22 }
23
24 static LayerImpl* findRootScrollLayer(LayerImpl* layer)
25 {
26 if (!layer)
27 return 0;
28
29 if (layer->scrollable())
30 return layer;
31
32 for (size_t i = 0; i < layer->children().size(); ++i) {
33 LayerImpl* found = findRootScrollLayer(layer->children()[i]);
34 if (found)
35 return found;
36 }
37
38 return 0;
39 }
40
41 void LayerTreeImpl::SetRootLayer(scoped_ptr<LayerImpl> layer) {
42 root_layer_ = layer.Pass();
43 root_scroll_layer_ = findRootScrollLayer(root_layer_.get());
44 currently_scrolling_layer_ = 0;
45
46 if (root_layer_ && scrolling_layer_id_from_previous_tree_) {
47 currently_scrolling_layer_ = LayerTreeHostCommon::findLayerInSubtree(
48 root_layer_.get(),
49 scrolling_layer_id_from_previous_tree_);
50 }
51
52 scrolling_layer_id_from_previous_tree_ = 0;
53
54 client_->OnCanDrawStateChangedForTree(this);
55 }
56
57 scoped_ptr<LayerImpl> LayerTreeImpl::DetachLayerTree() {
58 // Clear all data structures that have direct references to the layer tree.
59 scrolling_layer_id_from_previous_tree_ =
60 currently_scrolling_layer_ ? currently_scrolling_layer_->id() : 0;
61 currently_scrolling_layer_ = NULL;
62
63 return root_layer_.Pass();
64 }
65
66 void LayerTreeImpl::ClearCurrentlyScrollingLayer() {
67 currently_scrolling_layer_ = NULL;
68 scrolling_layer_id_from_previous_tree_ = 0;
69 }
70
71 } // namespace cc
OLDNEW
« 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