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

Side by Side Diff: cc/layer_tree_impl.cc

Issue 11575018: cc: Add id->LayerImpl map 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
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/layer_tree_impl.h" 5 #include "cc/layer_tree_impl.h"
6 6
7 #include "cc/layer_tree_host_common.h" 7 #include "cc/layer_tree_host_common.h"
8 #include "cc/layer_tree_host_impl.h" 8 #include "cc/layer_tree_host_impl.h"
9 9
10 namespace cc { 10 namespace cc {
11 11
12 LayerTreeImpl::LayerTreeImpl(LayerTreeHostImpl* layer_tree_host_impl) 12 LayerTreeImpl::LayerTreeImpl(LayerTreeHostImpl* layer_tree_host_impl)
13 : layer_tree_host_impl_(layer_tree_host_impl) 13 : layer_tree_host_impl_(layer_tree_host_impl)
14 , source_frame_number_(-1) 14 , source_frame_number_(-1)
15 , hud_layer_(0) 15 , hud_layer_(0)
16 , root_scroll_layer_(0) 16 , root_scroll_layer_(0)
17 , currently_scrolling_layer_(0) 17 , currently_scrolling_layer_(0)
18 , scrolling_layer_id_from_previous_tree_(0) { 18 , scrolling_layer_id_from_previous_tree_(0) {
19 } 19 }
20 20
21 LayerTreeImpl::~LayerTreeImpl() { 21 LayerTreeImpl::~LayerTreeImpl() {
22 // Need to explicitly clear the tree prior to destroying this so that
23 // the LayerTreeImpl pointer is still valid in the LayerImpl dtor.
24 root_layer_.reset();
22 } 25 }
23 26
24 static LayerImpl* findRootScrollLayer(LayerImpl* layer) 27 static LayerImpl* findRootScrollLayer(LayerImpl* layer)
25 { 28 {
26 if (!layer) 29 if (!layer)
27 return 0; 30 return 0;
28 31
29 if (layer->scrollable()) 32 if (layer->scrollable())
30 return layer; 33 return layer;
31 34
(...skipping 29 matching lines...) Expand all
61 currently_scrolling_layer_ = NULL; 64 currently_scrolling_layer_ = NULL;
62 65
63 return root_layer_.Pass(); 66 return root_layer_.Pass();
64 } 67 }
65 68
66 void LayerTreeImpl::ClearCurrentlyScrollingLayer() { 69 void LayerTreeImpl::ClearCurrentlyScrollingLayer() {
67 currently_scrolling_layer_ = NULL; 70 currently_scrolling_layer_ = NULL;
68 scrolling_layer_id_from_previous_tree_ = 0; 71 scrolling_layer_id_from_previous_tree_ = 0;
69 } 72 }
70 73
74 LayerImpl* LayerTreeImpl::LayerById(int id) {
75 LayerIdMap::iterator iter = layer_id_map_.find(id);
76 return iter != layer_id_map_.end() ? iter->second : NULL;
77 }
78
79 void LayerTreeImpl::RegisterLayer(LayerImpl* layer) {
80 DCHECK(!LayerById(layer->id()));
81 layer_id_map_[layer->id()] = layer;
82 }
83
84 void LayerTreeImpl::UnregisterLayer(LayerImpl* layer) {
85 DCHECK(LayerById(layer->id()));
86 layer_id_map_.erase(layer->id());
87 }
88
71 const LayerTreeSettings& LayerTreeImpl::settings() const { 89 const LayerTreeSettings& LayerTreeImpl::settings() const {
72 return layer_tree_host_impl_->settings(); 90 return layer_tree_host_impl_->settings();
73 } 91 }
74 92
75 OutputSurface* LayerTreeImpl::output_surface() const { 93 OutputSurface* LayerTreeImpl::output_surface() const {
76 return layer_tree_host_impl_->outputSurface(); 94 return layer_tree_host_impl_->outputSurface();
77 } 95 }
78 96
79 ResourceProvider* LayerTreeImpl::resource_provider() const { 97 ResourceProvider* LayerTreeImpl::resource_provider() const {
80 return layer_tree_host_impl_->resourceProvider(); 98 return layer_tree_host_impl_->resourceProvider();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 std::string LayerTreeImpl::layer_tree_as_text() const { 133 std::string LayerTreeImpl::layer_tree_as_text() const {
116 return layer_tree_host_impl_->layerTreeAsText(); 134 return layer_tree_host_impl_->layerTreeAsText();
117 } 135 }
118 136
119 DebugRectHistory* LayerTreeImpl::debug_rect_history() const { 137 DebugRectHistory* LayerTreeImpl::debug_rect_history() const {
120 return layer_tree_host_impl_->debugRectHistory(); 138 return layer_tree_host_impl_->debugRectHistory();
121 } 139 }
122 140
123 141
124 } // namespace cc 142 } // namespace cc
OLDNEW
« cc/layer_tree_impl.h ('K') | « cc/layer_tree_impl.h ('k') | cc/quad_culler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698