OLD | NEW |
1 // Copyright 2011 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 CCLayerSorter_h | 5 // Temporary forwarding header |
6 #define CCLayerSorter_h | 6 #include "cc/layer_sorter.h" |
7 | |
8 #include "base/basictypes.h" | |
9 #include "CCLayerImpl.h" | |
10 #include "FloatPoint3D.h" | |
11 #include "FloatQuad.h" | |
12 #include "FloatRect.h" | |
13 #include <vector> | |
14 #include <wtf/HashMap.h> | |
15 #include <wtf/Vector.h> | |
16 | |
17 namespace WebKit { | |
18 class WebTransformationMatrix; | |
19 } | |
20 | |
21 namespace cc { | |
22 | |
23 class CCLayerSorter { | |
24 public: | |
25 CCLayerSorter(); | |
26 ~CCLayerSorter(); | |
27 | |
28 typedef std::vector<CCLayerImpl*> LayerList; | |
29 | |
30 void sort(LayerList::iterator first, LayerList::iterator last); | |
31 | |
32 // Holds various useful properties derived from a layer's 3D outline. | |
33 struct LayerShape { | |
34 LayerShape(); | |
35 LayerShape(float width, float height, const WebKit::WebTransformationMat
rix& drawTransform); | |
36 | |
37 float layerZFromProjectedPoint(const FloatPoint&) const; | |
38 | |
39 FloatPoint3D layerNormal; | |
40 FloatPoint3D transformOrigin; | |
41 FloatQuad projectedQuad; | |
42 FloatRect projectedBounds; | |
43 }; | |
44 | |
45 enum ABCompareResult { | |
46 ABeforeB, | |
47 BBeforeA, | |
48 None | |
49 }; | |
50 | |
51 static ABCompareResult checkOverlap(LayerShape*, LayerShape*, float zThresho
ld, float& weight); | |
52 | |
53 private: | |
54 struct GraphEdge; | |
55 | |
56 struct GraphNode { | |
57 explicit GraphNode(CCLayerImpl* cclayer); | |
58 ~GraphNode(); | |
59 | |
60 CCLayerImpl* layer; | |
61 LayerShape shape; | |
62 Vector<GraphEdge*> incoming; | |
63 Vector<GraphEdge*> outgoing; | |
64 float incomingEdgeWeight; | |
65 }; | |
66 | |
67 struct GraphEdge { | |
68 GraphEdge(GraphNode* fromNode, GraphNode* toNode, float weight) : from(f
romNode), to(toNode), weight(weight) { }; | |
69 | |
70 GraphNode* from; | |
71 GraphNode* to; | |
72 float weight; | |
73 }; | |
74 | |
75 typedef Vector<GraphNode> NodeList; | |
76 typedef Vector<GraphEdge> EdgeList; | |
77 NodeList m_nodes; | |
78 EdgeList m_edges; | |
79 float m_zRange; | |
80 | |
81 typedef HashMap<GraphEdge*, GraphEdge*> EdgeMap; | |
82 EdgeMap m_activeEdges; | |
83 | |
84 void createGraphNodes(LayerList::iterator first, LayerList::iterator last); | |
85 void createGraphEdges(); | |
86 void removeEdgeFromList(GraphEdge*, Vector<GraphEdge*>&); | |
87 | |
88 DISALLOW_COPY_AND_ASSIGN(CCLayerSorter); | |
89 }; | |
90 | |
91 } | |
92 #endif | |
OLD | NEW |