Don't consider a Bluetooth adapter present until it has an address.
[chromium-blink-merge.git] / cc / CCLayerSorter.h
blob0fb64a640c9f82e53135923c8a4a9609625b36fe
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>
16 namespace WebKit {
17 class WebTransformationMatrix;
20 namespace WebCore {
22 class CCLayerSorter {
23 WTF_MAKE_NONCOPYABLE(CCLayerSorter);
24 public:
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.
32 struct LayerShape {
33 LayerShape() { }
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 {
45 ABeforeB,
46 BBeforeA,
47 None
50 static ABCompareResult checkOverlap(LayerShape*, LayerShape*, float zThreshold, float& weight);
52 private:
53 struct GraphEdge;
55 struct GraphNode {
56 explicit GraphNode(CCLayerImpl* cclayer) : layer(cclayer), incomingEdgeWeight(0) { }
58 CCLayerImpl* layer;
59 LayerShape shape;
60 Vector<GraphEdge*> incoming;
61 Vector<GraphEdge*> outgoing;
62 float incomingEdgeWeight;
65 struct GraphEdge {
66 GraphEdge(GraphNode* fromNode, GraphNode* toNode, float weight) : from(fromNode), to(toNode), weight(weight) { };
68 GraphNode* from;
69 GraphNode* to;
70 float weight;
73 typedef Vector<GraphNode> NodeList;
74 typedef Vector<GraphEdge> EdgeList;
75 NodeList m_nodes;
76 EdgeList m_edges;
77 float m_zRange;
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*>&);
88 #endif