In iossim, ignore harmless messages from launchd.
[chromium-blink-merge.git] / cc / layer_iterator.cc
blob2d9573853941c02b7953c07a8cb94f8f3812efe3
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
3 // found in the LICENSE file.
5 #include "cc/layer_iterator.h"
7 #include "cc/layer.h"
8 #include "cc/layer_impl.h"
9 #include "cc/render_surface.h"
10 #include "cc/render_surface_impl.h"
12 namespace cc {
14 template <typename LayerType, typename LayerList, typename RenderSurfaceType, typename ActionType>
15 void LayerIteratorActions::BackToFront::begin(LayerIterator<LayerType, LayerList, RenderSurfaceType, ActionType>& it)
17 it.m_targetRenderSurfaceLayerIndex = 0;
18 it.m_currentLayerIndex = LayerIteratorValue::LayerIndexRepresentingTargetRenderSurface;
20 m_highestTargetRenderSurfaceLayer = 0;
23 template <typename LayerType, typename LayerList, typename RenderSurfaceType, typename ActionType>
24 void LayerIteratorActions::BackToFront::end(LayerIterator<LayerType, LayerList, RenderSurfaceType, ActionType>& it)
26 it.m_targetRenderSurfaceLayerIndex = LayerIteratorValue::InvalidTargetRenderSurfaceLayerIndex;
27 it.m_currentLayerIndex = 0;
30 template <typename LayerType, typename LayerList, typename RenderSurfaceType, typename ActionType>
31 void LayerIteratorActions::BackToFront::next(LayerIterator<LayerType, LayerList, RenderSurfaceType, ActionType>& it)
33 // If the current layer has a RS, move to its layer list. Otherwise, visit the next layer in the current RS layer list.
34 if (it.currentLayerRepresentsContributingRenderSurface()) {
35 // Save our position in the childLayer list for the RenderSurfaceImpl, then jump to the next RenderSurfaceImpl. Save where we
36 // came from in the next RenderSurfaceImpl so we can get back to it.
37 it.targetRenderSurface()->m_currentLayerIndexHistory = it.m_currentLayerIndex;
38 int previousTargetRenderSurfaceLayer = it.m_targetRenderSurfaceLayerIndex;
40 it.m_targetRenderSurfaceLayerIndex = ++m_highestTargetRenderSurfaceLayer;
41 it.m_currentLayerIndex = LayerIteratorValue::LayerIndexRepresentingTargetRenderSurface;
43 it.targetRenderSurface()->m_targetRenderSurfaceLayerIndexHistory = previousTargetRenderSurfaceLayer;
44 } else {
45 ++it.m_currentLayerIndex;
47 int targetRenderSurfaceNumChildren = it.targetRenderSurfaceChildren().size();
48 while (it.m_currentLayerIndex == targetRenderSurfaceNumChildren) {
49 // Jump back to the previous RenderSurfaceImpl, and get back the position where we were in that list, and move to the next position there.
50 if (!it.m_targetRenderSurfaceLayerIndex) {
51 // End of the list
52 it.m_targetRenderSurfaceLayerIndex = LayerIteratorValue::InvalidTargetRenderSurfaceLayerIndex;
53 it.m_currentLayerIndex = 0;
54 return;
56 it.m_targetRenderSurfaceLayerIndex = it.targetRenderSurface()->m_targetRenderSurfaceLayerIndexHistory;
57 it.m_currentLayerIndex = it.targetRenderSurface()->m_currentLayerIndexHistory + 1;
59 targetRenderSurfaceNumChildren = it.targetRenderSurfaceChildren().size();
64 template <typename LayerType, typename LayerList, typename RenderSurfaceType, typename ActionType>
65 void LayerIteratorActions::FrontToBack::begin(LayerIterator<LayerType, LayerList, RenderSurfaceType, ActionType>& it)
67 it.m_targetRenderSurfaceLayerIndex = 0;
68 it.m_currentLayerIndex = it.targetRenderSurfaceChildren().size() - 1;
69 goToHighestInSubtree(it);
72 template <typename LayerType, typename LayerList, typename RenderSurfaceType, typename ActionType>
73 void LayerIteratorActions::FrontToBack::end(LayerIterator<LayerType, LayerList, RenderSurfaceType, ActionType>& it)
75 it.m_targetRenderSurfaceLayerIndex = LayerIteratorValue::InvalidTargetRenderSurfaceLayerIndex;
76 it.m_currentLayerIndex = 0;
79 template <typename LayerType, typename LayerList, typename RenderSurfaceType, typename ActionType>
80 void LayerIteratorActions::FrontToBack::next(LayerIterator<LayerType, LayerList, RenderSurfaceType, ActionType>& it)
82 // Moves to the previous layer in the current RS layer list. Then we check if the
83 // new current layer has its own RS, in which case there are things in that RS layer list that are higher, so
84 // we find the highest layer in that subtree.
85 // If we move back past the front of the list, we jump up to the previous RS layer list, picking up again where we
86 // had previously recursed into the current RS layer list.
88 if (!it.currentLayerRepresentsTargetRenderSurface()) {
89 // Subtracting one here will eventually cause the current layer to become that layer
90 // representing the target render surface.
91 --it.m_currentLayerIndex;
92 goToHighestInSubtree(it);
93 } else {
94 while (it.currentLayerRepresentsTargetRenderSurface()) {
95 if (!it.m_targetRenderSurfaceLayerIndex) {
96 // End of the list
97 it.m_targetRenderSurfaceLayerIndex = LayerIteratorValue::InvalidTargetRenderSurfaceLayerIndex;
98 it.m_currentLayerIndex = 0;
99 return;
101 it.m_targetRenderSurfaceLayerIndex = it.targetRenderSurface()->m_targetRenderSurfaceLayerIndexHistory;
102 it.m_currentLayerIndex = it.targetRenderSurface()->m_currentLayerIndexHistory;
107 template <typename LayerType, typename LayerList, typename RenderSurfaceType, typename ActionType>
108 void LayerIteratorActions::FrontToBack::goToHighestInSubtree(LayerIterator<LayerType, LayerList, RenderSurfaceType, ActionType>& it)
110 if (it.currentLayerRepresentsTargetRenderSurface())
111 return;
112 while (it.currentLayerRepresentsContributingRenderSurface()) {
113 // Save where we were in the current target surface, move to the next one, and save the target surface that we
114 // came from there so we can go back to it.
115 it.targetRenderSurface()->m_currentLayerIndexHistory = it.m_currentLayerIndex;
116 int previousTargetRenderSurfaceLayer = it.m_targetRenderSurfaceLayerIndex;
118 for (LayerType* layer = it.currentLayer(); it.targetRenderSurfaceLayer() != layer; ++it.m_targetRenderSurfaceLayerIndex) { }
119 it.m_currentLayerIndex = it.targetRenderSurfaceChildren().size() - 1;
121 it.targetRenderSurface()->m_targetRenderSurfaceLayerIndexHistory = previousTargetRenderSurfaceLayer;
125 typedef std::vector<scoped_refptr<Layer> > LayerList;
126 typedef std::vector<LayerImpl*> LayerImplList;
128 // Declare each of the above functions for Layer and LayerImpl classes so that they are linked.
129 template CC_EXPORT void LayerIteratorActions::BackToFront::begin(LayerIterator<Layer, LayerList, RenderSurface, BackToFront> &);
130 template CC_EXPORT void LayerIteratorActions::BackToFront::end(LayerIterator<Layer, LayerList, RenderSurface, BackToFront>&);
131 template CC_EXPORT void LayerIteratorActions::BackToFront::next(LayerIterator<Layer, LayerList, RenderSurface, BackToFront>&);
133 template CC_EXPORT void LayerIteratorActions::BackToFront::begin(LayerIterator<LayerImpl, LayerImplList, RenderSurfaceImpl, BackToFront>&);
134 template CC_EXPORT void LayerIteratorActions::BackToFront::end(LayerIterator<LayerImpl, LayerImplList, RenderSurfaceImpl, BackToFront>&);
135 template CC_EXPORT void LayerIteratorActions::BackToFront::next(LayerIterator<LayerImpl, LayerImplList, RenderSurfaceImpl, BackToFront>&);
137 template CC_EXPORT void LayerIteratorActions::FrontToBack::next(LayerIterator<Layer, LayerList, RenderSurface, FrontToBack>&);
138 template CC_EXPORT void LayerIteratorActions::FrontToBack::end(LayerIterator<Layer, LayerList, RenderSurface, FrontToBack>&);
139 template CC_EXPORT void LayerIteratorActions::FrontToBack::begin(LayerIterator<Layer, LayerList, RenderSurface, FrontToBack>&);
140 template CC_EXPORT void LayerIteratorActions::FrontToBack::goToHighestInSubtree(LayerIterator<Layer, LayerList, RenderSurface, FrontToBack>&);
142 template CC_EXPORT void LayerIteratorActions::FrontToBack::next(LayerIterator<LayerImpl, LayerImplList, RenderSurfaceImpl, FrontToBack>&);
143 template CC_EXPORT void LayerIteratorActions::FrontToBack::end(LayerIterator<LayerImpl, LayerImplList, RenderSurfaceImpl, FrontToBack>&);
144 template CC_EXPORT void LayerIteratorActions::FrontToBack::begin(LayerIterator<LayerImpl, LayerImplList, RenderSurfaceImpl, FrontToBack>&);
145 template CC_EXPORT void LayerIteratorActions::FrontToBack::goToHighestInSubtree(LayerIterator<LayerImpl, LayerImplList, RenderSurfaceImpl, FrontToBack>&);
147 } // namespace cc