OLD | NEW |
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 CCLayerIterator_h | 5 #ifndef CCLayerIterator_h |
6 #define CCLayerIterator_h | 6 #define CCLayerIterator_h |
7 | 7 |
| 8 #include "base/memory/ref_counted.h" |
| 9 #include "cc/cc_export.h" |
8 #include "cc/layer_tree_host_common.h" | 10 #include "cc/layer_tree_host_common.h" |
9 | 11 |
10 #include "base/memory/ref_counted.h" | |
11 | |
12 namespace cc { | 12 namespace cc { |
13 | 13 |
14 // These classes provide means to iterate over the RenderSurfaceImpl-Layer tree. | 14 // These classes provide means to iterate over the RenderSurfaceImpl-Layer tree. |
15 | 15 |
16 // Example code follows, for a tree of Layer/RenderSurface objects. See below fo
r details. | 16 // Example code follows, for a tree of Layer/RenderSurface objects. See below fo
r details. |
17 // | 17 // |
18 // void doStuffOnLayers(const std::vector<scoped_refptr<Layer> >& renderSurfaceL
ayerList) | 18 // void doStuffOnLayers(const std::vector<scoped_refptr<Layer> >& renderSurfaceL
ayerList) |
19 // { | 19 // { |
20 // typedef LayerIterator<Layer, RenderSurface, LayerIteratorActions::FrontTo
Back> LayerIteratorType; | 20 // typedef LayerIterator<Layer, RenderSurface, LayerIteratorActions::FrontTo
Back> LayerIteratorType; |
21 // | 21 // |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 // A position in the list of layers that are children of the current target
surface. When pointing to one of | 161 // A position in the list of layers that are children of the current target
surface. When pointing to one of |
162 // these layers, this is a value from 0 to n-1 (n = number of children). Sin
ce the iterator must also stop at | 162 // these layers, this is a value from 0 to n-1 (n = number of children). Sin
ce the iterator must also stop at |
163 // the layers representing the target surface, this is done by setting the c
urrentLayerIndex to a value of | 163 // the layers representing the target surface, this is done by setting the c
urrentLayerIndex to a value of |
164 // LayerIteratorValue::LayerRepresentingTargetRenderSurface. | 164 // LayerIteratorValue::LayerRepresentingTargetRenderSurface. |
165 int m_currentLayerIndex; | 165 int m_currentLayerIndex; |
166 | 166 |
167 friend struct LayerIteratorActions; | 167 friend struct LayerIteratorActions; |
168 }; | 168 }; |
169 | 169 |
170 // Orderings for iterating over the RenderSurfaceImpl-Layer tree. | 170 // Orderings for iterating over the RenderSurfaceImpl-Layer tree. |
171 struct LayerIteratorActions { | 171 struct CC_EXPORT LayerIteratorActions { |
172 // Walks layers sorted by z-order from back to front. | 172 // Walks layers sorted by z-order from back to front. |
173 class BackToFront { | 173 class CC_EXPORT BackToFront { |
174 public: | 174 public: |
175 template <typename LayerType, typename LayerList, typename RenderSurface
Type, typename ActionType> | 175 template <typename LayerType, typename LayerList, typename RenderSurface
Type, typename ActionType> |
176 void begin(LayerIterator<LayerType, LayerList, RenderSurfaceType, Action
Type>&); | 176 void begin(LayerIterator<LayerType, LayerList, RenderSurfaceType, Action
Type>&); |
177 | 177 |
178 template <typename LayerType, typename LayerList, typename RenderSurface
Type, typename ActionType> | 178 template <typename LayerType, typename LayerList, typename RenderSurface
Type, typename ActionType> |
179 void end(LayerIterator<LayerType, LayerList, RenderSurfaceType, ActionTy
pe>&); | 179 void end(LayerIterator<LayerType, LayerList, RenderSurfaceType, ActionTy
pe>&); |
180 | 180 |
181 template <typename LayerType, typename LayerList, typename RenderSurface
Type, typename ActionType> | 181 template <typename LayerType, typename LayerList, typename RenderSurface
Type, typename ActionType> |
182 void next(LayerIterator<LayerType, LayerList, RenderSurfaceType, ActionT
ype>&); | 182 void next(LayerIterator<LayerType, LayerList, RenderSurfaceType, ActionT
ype>&); |
183 | 183 |
184 private: | 184 private: |
185 int m_highestTargetRenderSurfaceLayer; | 185 int m_highestTargetRenderSurfaceLayer; |
186 }; | 186 }; |
187 | 187 |
188 // Walks layers sorted by z-order from front to back | 188 // Walks layers sorted by z-order from front to back |
189 class FrontToBack { | 189 class CC_EXPORT FrontToBack { |
190 public: | 190 public: |
191 template <typename LayerType, typename LayerList, typename RenderSurface
Type, typename ActionType> | 191 template <typename LayerType, typename LayerList, typename RenderSurface
Type, typename ActionType> |
192 void begin(LayerIterator<LayerType, LayerList, RenderSurfaceType, Action
Type>&); | 192 void begin(LayerIterator<LayerType, LayerList, RenderSurfaceType, Action
Type>&); |
193 | 193 |
194 template <typename LayerType, typename LayerList, typename RenderSurface
Type, typename ActionType> | 194 template <typename LayerType, typename LayerList, typename RenderSurface
Type, typename ActionType> |
195 void end(LayerIterator<LayerType, LayerList, RenderSurfaceType, ActionTy
pe>&); | 195 void end(LayerIterator<LayerType, LayerList, RenderSurfaceType, ActionTy
pe>&); |
196 | 196 |
197 template <typename LayerType, typename LayerList, typename RenderSurface
Type, typename ActionType> | 197 template <typename LayerType, typename LayerList, typename RenderSurface
Type, typename ActionType> |
198 void next(LayerIterator<LayerType, LayerList, RenderSurfaceType, ActionT
ype>&); | 198 void next(LayerIterator<LayerType, LayerList, RenderSurfaceType, ActionT
ype>&); |
199 | 199 |
200 private: | 200 private: |
201 template <typename LayerType, typename LayerList, typename RenderSurface
Type, typename ActionType> | 201 template <typename LayerType, typename LayerList, typename RenderSurface
Type, typename ActionType> |
202 void goToHighestInSubtree(LayerIterator<LayerType, LayerList, RenderSurf
aceType, ActionType>&); | 202 void goToHighestInSubtree(LayerIterator<LayerType, LayerList, RenderSurf
aceType, ActionType>&); |
203 }; | 203 }; |
204 }; | 204 }; |
205 | 205 |
206 } // namespace cc | 206 } // namespace cc |
207 | 207 |
208 #endif | 208 #endif |
OLD | NEW |