OLD | NEW |
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 #ifndef CCLayerSorter_h | 5 #ifndef CCLayerSorter_h |
6 #define CCLayerSorter_h | 6 #define CCLayerSorter_h |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/hash_tables.h" | 9 #include "base/hash_tables.h" |
10 #include "CCLayerImpl.h" | 10 #include "CCLayerImpl.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 float layerZFromProjectedPoint(const FloatPoint&) const; | 44 float layerZFromProjectedPoint(const FloatPoint&) const; |
45 | 45 |
46 FloatPoint3D layerNormal; | 46 FloatPoint3D layerNormal; |
47 FloatPoint3D transformOrigin; | 47 FloatPoint3D transformOrigin; |
48 FloatQuad projectedQuad; | 48 FloatQuad projectedQuad; |
49 FloatRect projectedBounds; | 49 FloatRect projectedBounds; |
50 }; | 50 }; |
51 | 51 |
52 struct GraphNode { | 52 struct GraphNode { |
53 explicit GraphNode(CCLayerImpl* cclayer); | 53 explicit GraphNode(LayerImpl* layerImpl); |
54 ~GraphNode(); | 54 ~GraphNode(); |
55 | 55 |
56 CCLayerImpl* layer; | 56 LayerImpl* layer; |
57 LayerShape shape; | 57 LayerShape shape; |
58 std::vector<GraphEdge*> incoming; | 58 std::vector<GraphEdge*> incoming; |
59 std::vector<GraphEdge*> outgoing; | 59 std::vector<GraphEdge*> outgoing; |
60 float incomingEdgeWeight; | 60 float incomingEdgeWeight; |
61 }; | 61 }; |
62 | 62 |
63 struct GraphEdge { | 63 struct GraphEdge { |
64 GraphEdge(GraphNode* fromNode, GraphNode* toNode, float weight) | 64 GraphEdge(GraphNode* fromNode, GraphNode* toNode, float weight) |
65 : from(fromNode) | 65 : from(fromNode) |
66 , to(toNode) | 66 , to(toNode) |
67 , weight(weight) | 67 , weight(weight) |
68 { | 68 { |
69 } | 69 } |
70 | 70 |
71 GraphNode* from; | 71 GraphNode* from; |
72 GraphNode* to; | 72 GraphNode* to; |
73 float weight; | 73 float weight; |
74 }; | 74 }; |
75 | 75 |
76 | 76 |
77 | 77 |
78 class CCLayerSorter { | 78 class LayerSorter { |
79 public: | 79 public: |
80 CCLayerSorter(); | 80 LayerSorter(); |
81 ~CCLayerSorter(); | 81 ~LayerSorter(); |
82 | 82 |
83 typedef std::vector<CCLayerImpl*> LayerList; | 83 typedef std::vector<LayerImpl*> LayerList; |
84 | 84 |
85 void sort(LayerList::iterator first, LayerList::iterator last); | 85 void sort(LayerList::iterator first, LayerList::iterator last); |
86 | 86 |
87 enum ABCompareResult { | 87 enum ABCompareResult { |
88 ABeforeB, | 88 ABeforeB, |
89 BBeforeA, | 89 BBeforeA, |
90 None | 90 None |
91 }; | 91 }; |
92 | 92 |
93 static ABCompareResult checkOverlap(LayerShape*, LayerShape*, float zThresho
ld, float& weight); | 93 static ABCompareResult checkOverlap(LayerShape*, LayerShape*, float zThresho
ld, float& weight); |
94 | 94 |
95 private: | 95 private: |
96 typedef std::vector<GraphNode> NodeList; | 96 typedef std::vector<GraphNode> NodeList; |
97 typedef std::vector<GraphEdge> EdgeList; | 97 typedef std::vector<GraphEdge> EdgeList; |
98 NodeList m_nodes; | 98 NodeList m_nodes; |
99 EdgeList m_edges; | 99 EdgeList m_edges; |
100 float m_zRange; | 100 float m_zRange; |
101 | 101 |
102 typedef base::hash_map<GraphEdge*, GraphEdge*> EdgeMap; | 102 typedef base::hash_map<GraphEdge*, GraphEdge*> EdgeMap; |
103 EdgeMap m_activeEdges; | 103 EdgeMap m_activeEdges; |
104 | 104 |
105 void createGraphNodes(LayerList::iterator first, LayerList::iterator last); | 105 void createGraphNodes(LayerList::iterator first, LayerList::iterator last); |
106 void createGraphEdges(); | 106 void createGraphEdges(); |
107 void removeEdgeFromList(GraphEdge*, std::vector<GraphEdge*>&); | 107 void removeEdgeFromList(GraphEdge*, std::vector<GraphEdge*>&); |
108 | 108 |
109 DISALLOW_COPY_AND_ASSIGN(CCLayerSorter); | 109 DISALLOW_COPY_AND_ASSIGN(LayerSorter); |
110 }; | 110 }; |
111 | 111 |
112 } | 112 } |
113 #endif | 113 #endif |
OLD | NEW |