OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #include "config.h" | |
6 | |
7 #if USE(ACCELERATED_COMPOSITING) | |
8 | |
9 #include "CCLayerIterator.h" | |
10 | |
11 #include "CCLayerImpl.h" | |
12 #include "CCRenderSurface.h" | |
13 #include "LayerChromium.h" | |
14 #include "RenderSurfaceChromium.h" | |
15 | |
16 namespace cc { | |
17 | |
18 template <typename LayerType, typename LayerList, typename RenderSurfaceType, ty
pename ActionType> | |
19 void CCLayerIteratorActions::BackToFront::begin(CCLayerIterator<LayerType, Layer
List, RenderSurfaceType, ActionType>& it) | |
20 { | |
21 it.m_targetRenderSurfaceLayerIndex = 0; | |
22 it.m_currentLayerIndex = CCLayerIteratorValue::LayerIndexRepresentingTargetR
enderSurface; | |
23 | |
24 m_highestTargetRenderSurfaceLayer = 0; | |
25 } | |
26 | |
27 template <typename LayerType, typename LayerList, typename RenderSurfaceType, ty
pename ActionType> | |
28 void CCLayerIteratorActions::BackToFront::end(CCLayerIterator<LayerType, LayerLi
st, RenderSurfaceType, ActionType>& it) | |
29 { | |
30 it.m_targetRenderSurfaceLayerIndex = CCLayerIteratorValue::InvalidTargetRend
erSurfaceLayerIndex; | |
31 it.m_currentLayerIndex = 0; | |
32 } | |
33 | |
34 template <typename LayerType, typename LayerList, typename RenderSurfaceType, ty
pename ActionType> | |
35 void CCLayerIteratorActions::BackToFront::next(CCLayerIterator<LayerType, LayerL
ist, RenderSurfaceType, ActionType>& it) | |
36 { | |
37 // If the current layer has a RS, move to its layer list. Otherwise, visit t
he next layer in the current RS layer list. | |
38 if (it.currentLayerRepresentsContributingRenderSurface()) { | |
39 // Save our position in the childLayer list for the RenderSurface, then
jump to the next RenderSurface. Save where we | |
40 // came from in the next RenderSurface so we can get back to it. | |
41 it.targetRenderSurface()->m_currentLayerIndexHistory = it.m_currentLayer
Index; | |
42 int previousTargetRenderSurfaceLayer = it.m_targetRenderSurfaceLayerInde
x; | |
43 | |
44 it.m_targetRenderSurfaceLayerIndex = ++m_highestTargetRenderSurfaceLayer
; | |
45 it.m_currentLayerIndex = CCLayerIteratorValue::LayerIndexRepresentingTar
getRenderSurface; | |
46 | |
47 it.targetRenderSurface()->m_targetRenderSurfaceLayerIndexHistory = previ
ousTargetRenderSurfaceLayer; | |
48 } else { | |
49 ++it.m_currentLayerIndex; | |
50 | |
51 int targetRenderSurfaceNumChildren = it.targetRenderSurfaceChildren().si
ze(); | |
52 while (it.m_currentLayerIndex == targetRenderSurfaceNumChildren) { | |
53 // Jump back to the previous RenderSurface, and get back the positio
n where we were in that list, and move to the next position there. | |
54 if (!it.m_targetRenderSurfaceLayerIndex) { | |
55 // End of the list | |
56 it.m_targetRenderSurfaceLayerIndex = CCLayerIteratorValue::Inval
idTargetRenderSurfaceLayerIndex; | |
57 it.m_currentLayerIndex = 0; | |
58 return; | |
59 } | |
60 it.m_targetRenderSurfaceLayerIndex = it.targetRenderSurface()->m_tar
getRenderSurfaceLayerIndexHistory; | |
61 it.m_currentLayerIndex = it.targetRenderSurface()->m_currentLayerInd
exHistory + 1; | |
62 | |
63 targetRenderSurfaceNumChildren = it.targetRenderSurfaceChildren().si
ze(); | |
64 } | |
65 } | |
66 } | |
67 | |
68 template <typename LayerType, typename LayerList, typename RenderSurfaceType, ty
pename ActionType> | |
69 void CCLayerIteratorActions::FrontToBack::begin(CCLayerIterator<LayerType, Layer
List, RenderSurfaceType, ActionType>& it) | |
70 { | |
71 it.m_targetRenderSurfaceLayerIndex = 0; | |
72 it.m_currentLayerIndex = it.targetRenderSurfaceChildren().size() - 1; | |
73 goToHighestInSubtree(it); | |
74 } | |
75 | |
76 template <typename LayerType, typename LayerList, typename RenderSurfaceType, ty
pename ActionType> | |
77 void CCLayerIteratorActions::FrontToBack::end(CCLayerIterator<LayerType, LayerLi
st, RenderSurfaceType, ActionType>& it) | |
78 { | |
79 it.m_targetRenderSurfaceLayerIndex = CCLayerIteratorValue::InvalidTargetRend
erSurfaceLayerIndex; | |
80 it.m_currentLayerIndex = 0; | |
81 } | |
82 | |
83 template <typename LayerType, typename LayerList, typename RenderSurfaceType, ty
pename ActionType> | |
84 void CCLayerIteratorActions::FrontToBack::next(CCLayerIterator<LayerType, LayerL
ist, RenderSurfaceType, ActionType>& it) | |
85 { | |
86 // Moves to the previous layer in the current RS layer list. Then we check i
f the | |
87 // new current layer has its own RS, in which case there are things in that
RS layer list that are higher, so | |
88 // we find the highest layer in that subtree. | |
89 // If we move back past the front of the list, we jump up to the previous RS
layer list, picking up again where we | |
90 // had previously recursed into the current RS layer list. | |
91 | |
92 if (!it.currentLayerRepresentsTargetRenderSurface()) { | |
93 // Subtracting one here will eventually cause the current layer to becom
e that layer | |
94 // representing the target render surface. | |
95 --it.m_currentLayerIndex; | |
96 goToHighestInSubtree(it); | |
97 } else { | |
98 while (it.currentLayerRepresentsTargetRenderSurface()) { | |
99 if (!it.m_targetRenderSurfaceLayerIndex) { | |
100 // End of the list | |
101 it.m_targetRenderSurfaceLayerIndex = CCLayerIteratorValue::Inval
idTargetRenderSurfaceLayerIndex; | |
102 it.m_currentLayerIndex = 0; | |
103 return; | |
104 } | |
105 it.m_targetRenderSurfaceLayerIndex = it.targetRenderSurface()->m_tar
getRenderSurfaceLayerIndexHistory; | |
106 it.m_currentLayerIndex = it.targetRenderSurface()->m_currentLayerInd
exHistory; | |
107 } | |
108 } | |
109 } | |
110 | |
111 template <typename LayerType, typename LayerList, typename RenderSurfaceType, ty
pename ActionType> | |
112 void CCLayerIteratorActions::FrontToBack::goToHighestInSubtree(CCLayerIterator<L
ayerType, LayerList, RenderSurfaceType, ActionType>& it) | |
113 { | |
114 if (it.currentLayerRepresentsTargetRenderSurface()) | |
115 return; | |
116 while (it.currentLayerRepresentsContributingRenderSurface()) { | |
117 // Save where we were in the current target surface, move to the next on
e, and save the target surface that we | |
118 // came from there so we can go back to it. | |
119 it.targetRenderSurface()->m_currentLayerIndexHistory = it.m_currentLayer
Index; | |
120 int previousTargetRenderSurfaceLayer = it.m_targetRenderSurfaceLayerInde
x; | |
121 | |
122 for (LayerType* layer = it.currentLayer(); it.targetRenderSurfaceLayer()
!= layer; ++it.m_targetRenderSurfaceLayerIndex) { } | |
123 it.m_currentLayerIndex = it.targetRenderSurfaceChildren().size() - 1; | |
124 | |
125 it.targetRenderSurface()->m_targetRenderSurfaceLayerIndexHistory = previ
ousTargetRenderSurfaceLayer; | |
126 } | |
127 } | |
128 | |
129 typedef std::vector<scoped_refptr<LayerChromium> > LayerChromiumList; | |
130 typedef std::vector<CCLayerImpl*> CCLayerImplList; | |
131 | |
132 // Declare each of the above functions for LayerChromium and CCLayerImpl classes
so that they are linked. | |
133 template void CCLayerIteratorActions::BackToFront::begin(CCLayerIterator<LayerCh
romium, LayerChromiumList, RenderSurfaceChromium, BackToFront> &); | |
134 template void CCLayerIteratorActions::BackToFront::end(CCLayerIterator<LayerChro
mium, LayerChromiumList, RenderSurfaceChromium, BackToFront>&); | |
135 template void CCLayerIteratorActions::BackToFront::next(CCLayerIterator<LayerChr
omium, LayerChromiumList, RenderSurfaceChromium, BackToFront>&); | |
136 | |
137 template void CCLayerIteratorActions::BackToFront::begin(CCLayerIterator<CCLayer
Impl, CCLayerImplList, CCRenderSurface, BackToFront>&); | |
138 template void CCLayerIteratorActions::BackToFront::end(CCLayerIterator<CCLayerIm
pl, CCLayerImplList, CCRenderSurface, BackToFront>&); | |
139 template void CCLayerIteratorActions::BackToFront::next(CCLayerIterator<CCLayerI
mpl, CCLayerImplList, CCRenderSurface, BackToFront>&); | |
140 | |
141 template void CCLayerIteratorActions::FrontToBack::next(CCLayerIterator<LayerChr
omium, LayerChromiumList, RenderSurfaceChromium, FrontToBack>&); | |
142 template void CCLayerIteratorActions::FrontToBack::end(CCLayerIterator<LayerChro
mium, LayerChromiumList, RenderSurfaceChromium, FrontToBack>&); | |
143 template void CCLayerIteratorActions::FrontToBack::begin(CCLayerIterator<LayerCh
romium, LayerChromiumList, RenderSurfaceChromium, FrontToBack>&); | |
144 template void CCLayerIteratorActions::FrontToBack::goToHighestInSubtree(CCLayerI
terator<LayerChromium, LayerChromiumList, RenderSurfaceChromium, FrontToBack>&); | |
145 | |
146 template void CCLayerIteratorActions::FrontToBack::next(CCLayerIterator<CCLayerI
mpl, CCLayerImplList, CCRenderSurface, FrontToBack>&); | |
147 template void CCLayerIteratorActions::FrontToBack::end(CCLayerIterator<CCLayerIm
pl, CCLayerImplList, CCRenderSurface, FrontToBack>&); | |
148 template void CCLayerIteratorActions::FrontToBack::begin(CCLayerIterator<CCLayer
Impl, CCLayerImplList, CCRenderSurface, FrontToBack>&); | |
149 template void CCLayerIteratorActions::FrontToBack::goToHighestInSubtree(CCLayerI
terator<CCLayerImpl, CCLayerImplList, CCRenderSurface, FrontToBack>&); | |
150 | |
151 } // namespace cc | |
152 | |
153 #endif // USE(ACCELERATED_COMPOSITING) | |
OLD | NEW |