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 #include "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "CCLayerSorter.h" | 7 #include "CCLayerSorter.h" |
8 | 8 |
9 #include "CCMathUtil.h" | 9 #include "CCMathUtil.h" |
10 #include "CCRenderSurface.h" | 10 #include "CCRenderSurface.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 | 55 |
56 float t = perpProduct(u, w) / denom; | 56 float t = perpProduct(u, w) / denom; |
57 if (t < 0 || t > 1) | 57 if (t < 0 || t > 1) |
58 return false; | 58 return false; |
59 | 59 |
60 u.scale(s); | 60 u.scale(s); |
61 r = a + u; | 61 r = a + u; |
62 return true; | 62 return true; |
63 } | 63 } |
64 | 64 |
| 65 CCLayerSorter::GraphNode::GraphNode(CCLayerImpl* cclayer) |
| 66 : layer(cclayer) |
| 67 , incomingEdgeWeight(0) |
| 68 { |
| 69 } |
| 70 |
| 71 CCLayerSorter::GraphNode::~GraphNode() |
| 72 { |
| 73 } |
| 74 |
| 75 CCLayerSorter::CCLayerSorter() |
| 76 : m_zRange(0) |
| 77 { |
| 78 } |
| 79 |
| 80 CCLayerSorter::~CCLayerSorter() |
| 81 { |
| 82 } |
| 83 |
65 // Checks whether layer "a" draws on top of layer "b". The weight value returned
is an indication of | 84 // Checks whether layer "a" draws on top of layer "b". The weight value returned
is an indication of |
66 // the maximum z-depth difference between the layers or zero if the layers are f
ound to be intesecting | 85 // the maximum z-depth difference between the layers or zero if the layers are f
ound to be intesecting |
67 // (some features are in front and some are behind). | 86 // (some features are in front and some are behind). |
68 CCLayerSorter::ABCompareResult CCLayerSorter::checkOverlap(LayerShape* a, LayerS
hape* b, float zThreshold, float& weight) | 87 CCLayerSorter::ABCompareResult CCLayerSorter::checkOverlap(LayerShape* a, LayerS
hape* b, float zThreshold, float& weight) |
69 { | 88 { |
70 weight = 0; | 89 weight = 0; |
71 | 90 |
72 // Early out if the projected bounds don't overlap. | 91 // Early out if the projected bounds don't overlap. |
73 if (!a->projectedBounds.intersects(b->projectedBounds)) | 92 if (!a->projectedBounds.intersects(b->projectedBounds)) |
74 return None; | 93 return None; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 else | 144 else |
126 weight = fabsf(maxDiff); | 145 weight = fabsf(maxDiff); |
127 | 146 |
128 // Maintain relative order if the layers have the same depth at all intersec
tion points. | 147 // Maintain relative order if the layers have the same depth at all intersec
tion points. |
129 if (maxDiff <= 0) | 148 if (maxDiff <= 0) |
130 return ABeforeB; | 149 return ABeforeB; |
131 | 150 |
132 return BBeforeA; | 151 return BBeforeA; |
133 } | 152 } |
134 | 153 |
| 154 CCLayerSorter::LayerShape::LayerShape() |
| 155 { |
| 156 } |
| 157 |
135 CCLayerSorter::LayerShape::LayerShape(float width, float height, const WebTransf
ormationMatrix& drawTransform) | 158 CCLayerSorter::LayerShape::LayerShape(float width, float height, const WebTransf
ormationMatrix& drawTransform) |
136 { | 159 { |
137 FloatQuad layerQuad(FloatRect(0, 0, width, height)); | 160 FloatQuad layerQuad(FloatRect(0, 0, width, height)); |
138 | 161 |
139 // Compute the projection of the layer quad onto the z = 0 plane. | 162 // Compute the projection of the layer quad onto the z = 0 plane. |
140 | 163 |
141 FloatPoint clippedQuad[8]; | 164 FloatPoint clippedQuad[8]; |
142 int numVerticesInClippedQuad; | 165 int numVerticesInClippedQuad; |
143 CCMathUtil::mapClippedQuad(drawTransform, layerQuad, clippedQuad, numVertice
sInClippedQuad); | 166 CCMathUtil::mapClippedQuad(drawTransform, layerQuad, clippedQuad, numVertice
sInClippedQuad); |
144 | 167 |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 #if !defined( NDEBUG ) | 436 #if !defined( NDEBUG ) |
414 LOG(CCLayerSorter, "Sorting end ----\n"); | 437 LOG(CCLayerSorter, "Sorting end ----\n"); |
415 #endif | 438 #endif |
416 | 439 |
417 m_nodes.clear(); | 440 m_nodes.clear(); |
418 m_edges.clear(); | 441 m_edges.clear(); |
419 m_activeEdges.clear(); | 442 m_activeEdges.clear(); |
420 } | 443 } |
421 | 444 |
422 } | 445 } |
OLD | NEW |