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
3 // found in the LICENSE file.
5 #ifndef CCLayerSorter_h
6 #define CCLayerSorter_h
8 #include "CCLayerImpl.h"
9 #include "FloatPoint3D.h"
10 #include "FloatQuad.h"
11 #include "FloatRect.h"
12 #include <wtf/HashMap.h>
13 #include <wtf/Noncopyable.h>
14 #include <wtf/Vector.h>
17 class WebTransformationMatrix
;
23 WTF_MAKE_NONCOPYABLE(CCLayerSorter
);
25 CCLayerSorter() : m_zRange(0) { }
27 typedef Vector
<CCLayerImpl
*> LayerList
;
29 void sort(LayerList::iterator first
, LayerList::iterator last
);
31 // Holds various useful properties derived from a layer's 3D outline.
34 LayerShape(float width
, float height
, const WebKit::WebTransformationMatrix
& drawTransform
);
36 float layerZFromProjectedPoint(const FloatPoint
&) const;
38 FloatPoint3D layerNormal
;
39 FloatPoint3D transformOrigin
;
40 FloatQuad projectedQuad
;
41 FloatRect projectedBounds
;
44 enum ABCompareResult
{
50 static ABCompareResult
checkOverlap(LayerShape
*, LayerShape
*, float zThreshold
, float& weight
);
56 explicit GraphNode(CCLayerImpl
* cclayer
) : layer(cclayer
), incomingEdgeWeight(0) { }
60 Vector
<GraphEdge
*> incoming
;
61 Vector
<GraphEdge
*> outgoing
;
62 float incomingEdgeWeight
;
66 GraphEdge(GraphNode
* fromNode
, GraphNode
* toNode
, float weight
) : from(fromNode
), to(toNode
), weight(weight
) { };
73 typedef Vector
<GraphNode
> NodeList
;
74 typedef Vector
<GraphEdge
> EdgeList
;
79 typedef HashMap
<GraphEdge
*, GraphEdge
*> EdgeMap
;
80 EdgeMap m_activeEdges
;
82 void createGraphNodes(LayerList::iterator first
, LayerList::iterator last
);
83 void createGraphEdges();
84 void removeEdgeFromList(GraphEdge
*, Vector
<GraphEdge
*>&);