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

Side by Side Diff: cc/layers/layer_iterator.h

Issue 250803013: Don't clear render surfaces unnecessarily. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make the bots happy. Created 6 years, 7 months 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 #ifndef CC_LAYERS_LAYER_ITERATOR_H_ 5 #ifndef CC_LAYERS_LAYER_ITERATOR_H_
6 #define CC_LAYERS_LAYER_ITERATOR_H_ 6 #define CC_LAYERS_LAYER_ITERATOR_H_
7 7
8 #include "cc/base/cc_export.h" 8 #include "cc/base/cc_export.h"
9 #include "cc/trees/layer_tree_host_common.h" 9 #include "cc/trees/layer_tree_host_common.h"
10 10
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 bool represents_itself; 96 bool represents_itself;
97 LayerType* target_render_surface_layer; 97 LayerType* target_render_surface_layer;
98 LayerType* current_layer; 98 LayerType* current_layer;
99 }; 99 };
100 100
101 // An iterator class for walking over layers in the 101 // An iterator class for walking over layers in the
102 // RenderSurface-Layer tree. 102 // RenderSurface-Layer tree.
103 template <typename LayerType> 103 template <typename LayerType>
104 class LayerIterator { 104 class LayerIterator {
105 typedef LayerIterator<LayerType> LayerIteratorType; 105 typedef LayerIterator<LayerType> LayerIteratorType;
106 typedef typename LayerType::RenderSurfaceListType LayerList; 106 typedef typename LayerType::LayerListType LayerList;
107 typedef typename LayerType::RenderSurfaceListType RenderSurfaceLayerList;
107 typedef typename LayerType::RenderSurfaceType RenderSurfaceType; 108 typedef typename LayerType::RenderSurfaceType RenderSurfaceType;
108 109
109 public: 110 public:
110 LayerIterator() : render_surface_layer_list_(NULL) {} 111 LayerIterator() : render_surface_layer_list_(NULL) {}
111 112
112 static LayerIteratorType Begin(const LayerList* render_surface_layer_list) { 113 static LayerIteratorType Begin(
114 const RenderSurfaceLayerList* render_surface_layer_list) {
113 return LayerIteratorType(render_surface_layer_list, true); 115 return LayerIteratorType(render_surface_layer_list, true);
114 } 116 }
115 static LayerIteratorType End(const LayerList* render_surface_layer_list) { 117 static LayerIteratorType End(
118 const RenderSurfaceLayerList* render_surface_layer_list) {
116 return LayerIteratorType(render_surface_layer_list, false); 119 return LayerIteratorType(render_surface_layer_list, false);
117 } 120 }
118 121
119 LayerIteratorType& operator++() { 122 LayerIteratorType& operator++() {
120 MoveToNext(); 123 MoveToNext();
121 return *this; 124 return *this;
122 } 125 }
123 bool operator==(const LayerIterator& other) const { 126 bool operator==(const LayerIterator& other) const {
124 return target_render_surface_layer_index_ == 127 return target_render_surface_layer_index_ ==
125 other.target_render_surface_layer_index_ && 128 other.target_render_surface_layer_index_ &&
(...skipping 28 matching lines...) Expand all
154 represents_target_render_surface(); 157 represents_target_render_surface();
155 position.represents_contributing_render_surface = 158 position.represents_contributing_render_surface =
156 represents_contributing_render_surface(); 159 represents_contributing_render_surface();
157 position.represents_itself = represents_itself(); 160 position.represents_itself = represents_itself();
158 position.target_render_surface_layer = target_render_surface_layer(); 161 position.target_render_surface_layer = target_render_surface_layer();
159 position.current_layer = current_layer(); 162 position.current_layer = current_layer();
160 return position; 163 return position;
161 } 164 }
162 165
163 private: 166 private:
164 LayerIterator(const LayerList* render_surface_layer_list, bool start) 167 LayerIterator(const RenderSurfaceLayerList* render_surface_layer_list,
168 bool start)
165 : render_surface_layer_list_(render_surface_layer_list), 169 : render_surface_layer_list_(render_surface_layer_list),
166 target_render_surface_layer_index_(0) { 170 target_render_surface_layer_index_(0) {
167 for (size_t i = 0; i < render_surface_layer_list->size(); ++i) { 171 for (size_t i = 0; i < render_surface_layer_list->size(); ++i) {
168 if (!render_surface_layer_list->at(i)->render_surface()) { 172 if (!render_surface_layer_list->at(i)->render_surface()) {
169 NOTREACHED(); 173 NOTREACHED();
170 MoveToEnd(); 174 MoveToEnd();
171 return; 175 return;
172 } 176 }
173 } 177 }
174 178
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 } 243 }
240 current_layer_index_ = target_render_surface_children().size() - 1; 244 current_layer_index_ = target_render_surface_children().size() - 1;
241 245
242 target_render_surface()->target_render_surface_layer_index_history_ = 246 target_render_surface()->target_render_surface_layer_index_history_ =
243 previous_target_render_surface_layer; 247 previous_target_render_surface_layer;
244 } 248 }
245 } 249 }
246 250
247 inline LayerType* current_layer() const { 251 inline LayerType* current_layer() const {
248 return current_layer_represents_target_render_surface() 252 return current_layer_represents_target_render_surface()
249 ? target_render_surface_layer() 253 ? target_render_surface_layer()
250 : target_render_surface_children().at(current_layer_index_); 254 : LayerTreeHostCommon::get_child_as_raw_ptr(
255 target_render_surface_children(), current_layer_index_);
251 } 256 }
252 257
253 inline bool current_layer_represents_contributing_render_surface() const { 258 inline bool current_layer_represents_contributing_render_surface() const {
254 return LayerTreeHostCommon::RenderSurfaceContributesToTarget<LayerType>( 259 return LayerTreeHostCommon::RenderSurfaceContributesToTarget<LayerType>(
255 current_layer(), target_render_surface_layer()->id()); 260 current_layer(), target_render_surface_layer()->id());
256 } 261 }
257 inline bool current_layer_represents_target_render_surface() const { 262 inline bool current_layer_represents_target_render_surface() const {
258 return current_layer_index_ == 263 return current_layer_index_ ==
259 LayerIteratorValue::kLayerIndexRepresentingTargetRenderSurface; 264 LayerIteratorValue::kLayerIndexRepresentingTargetRenderSurface;
260 } 265 }
261 266
262 inline RenderSurfaceType* target_render_surface() const { 267 inline RenderSurfaceType* target_render_surface() const {
263 return target_render_surface_layer()->render_surface(); 268 return target_render_surface_layer()->render_surface();
264 } 269 }
265 inline const LayerList& target_render_surface_children() const { 270 inline const LayerList& target_render_surface_children() const {
266 return target_render_surface()->layer_list(); 271 return target_render_surface()->layer_list();
267 } 272 }
268 273
269 const LayerList* render_surface_layer_list_; 274 const RenderSurfaceLayerList* render_surface_layer_list_;
270 275
271 // The iterator's current position. 276 // The iterator's current position.
272 277
273 // A position in the render_surface_layer_list. This points to a layer which 278 // A position in the render_surface_layer_list. This points to a layer which
274 // owns the current target surface. This is a value from 0 to n-1 279 // owns the current target surface. This is a value from 0 to n-1
275 // (n = size of render_surface_layer_list = number of surfaces). 280 // (n = size of render_surface_layer_list = number of surfaces).
276 // A value outside of this range 281 // A value outside of this range
277 // (for example, LayerIteratorValue::kInvalidTargetRenderSurfaceLayerIndex) 282 // (for example, LayerIteratorValue::kInvalidTargetRenderSurfaceLayerIndex)
278 // is used to indicate a position outside the bounds of the tree. 283 // is used to indicate a position outside the bounds of the tree.
279 int target_render_surface_layer_index_; 284 int target_render_surface_layer_index_;
280 // A position in the list of layers that are children of the 285 // A position in the list of layers that are children of the
281 // current target surface. When pointing to one of these layers, 286 // current target surface. When pointing to one of these layers,
282 // this is a value from 0 to n-1 (n = number of children). 287 // this is a value from 0 to n-1 (n = number of children).
283 // Since the iterator must also stop at the layers representing 288 // Since the iterator must also stop at the layers representing
284 // the target surface, this is done by setting the current_layerIndex 289 // the target surface, this is done by setting the current_layerIndex
285 // to a value of LayerIteratorValue::LayerRepresentingTargetRenderSurface. 290 // to a value of LayerIteratorValue::LayerRepresentingTargetRenderSurface.
286 int current_layer_index_; 291 int current_layer_index_;
287 }; 292 };
288 293
289 } // namespace cc 294 } // namespace cc
290 295
291 #endif // CC_LAYERS_LAYER_ITERATOR_H_ 296 #endif // CC_LAYERS_LAYER_ITERATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698