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 "cc/layer_sorter.h" | 7 #include "cc/layer_sorter.h" |
8 | 8 |
9 #include <deque> | 9 #include <deque> |
10 #include <limits> | 10 #include <limits> |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 return None; | 85 return None; |
86 | 86 |
87 gfx::PointF aPoints[4] = {a->projectedQuad.p1(), a->projectedQuad.p2(), a->p
rojectedQuad.p3(), a->projectedQuad.p4() }; | 87 gfx::PointF aPoints[4] = {a->projectedQuad.p1(), a->projectedQuad.p2(), a->p
rojectedQuad.p3(), a->projectedQuad.p4() }; |
88 gfx::PointF bPoints[4] = {b->projectedQuad.p1(), b->projectedQuad.p2(), b->p
rojectedQuad.p3(), b->projectedQuad.p4() }; | 88 gfx::PointF bPoints[4] = {b->projectedQuad.p1(), b->projectedQuad.p2(), b->p
rojectedQuad.p3(), b->projectedQuad.p4() }; |
89 | 89 |
90 // Make a list of points that inside both layer quad projections. | 90 // Make a list of points that inside both layer quad projections. |
91 std::vector<gfx::PointF> overlapPoints; | 91 std::vector<gfx::PointF> overlapPoints; |
92 | 92 |
93 // Check all four corners of one layer against the other layer's quad. | 93 // Check all four corners of one layer against the other layer's quad. |
94 for (int i = 0; i < 4; ++i) { | 94 for (int i = 0; i < 4; ++i) { |
95 if (a->projectedQuad.containsPoint(bPoints[i])) | 95 if (a->projectedQuad.Contains(bPoints[i])) |
96 overlapPoints.push_back(bPoints[i]); | 96 overlapPoints.push_back(bPoints[i]); |
97 if (b->projectedQuad.containsPoint(aPoints[i])) | 97 if (b->projectedQuad.Contains(aPoints[i])) |
98 overlapPoints.push_back(aPoints[i]); | 98 overlapPoints.push_back(aPoints[i]); |
99 } | 99 } |
100 | 100 |
101 // Check all the edges of one layer for intersection with the other layer's
edges. | 101 // Check all the edges of one layer for intersection with the other layer's
edges. |
102 gfx::PointF r; | 102 gfx::PointF r; |
103 for (int ea = 0; ea < 4; ++ea) | 103 for (int ea = 0; ea < 4; ++ea) |
104 for (int eb = 0; eb < 4; ++eb) | 104 for (int eb = 0; eb < 4; ++eb) |
105 if (edgeEdgeTest(aPoints[ea], aPoints[(ea + 1) % 4], | 105 if (edgeEdgeTest(aPoints[ea], aPoints[(ea + 1) % 4], |
106 bPoints[eb], bPoints[(eb + 1) % 4], | 106 bPoints[eb], bPoints[(eb + 1) % 4], |
107 r)) | 107 r)) |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 | 142 |
143 return BBeforeA; | 143 return BBeforeA; |
144 } | 144 } |
145 | 145 |
146 LayerShape::LayerShape() | 146 LayerShape::LayerShape() |
147 { | 147 { |
148 } | 148 } |
149 | 149 |
150 LayerShape::LayerShape(float width, float height, const WebTransformationMatrix&
drawTransform) | 150 LayerShape::LayerShape(float width, float height, const WebTransformationMatrix&
drawTransform) |
151 { | 151 { |
152 FloatQuad layerQuad(gfx::RectF(0, 0, width, height)); | 152 gfx::QuadF layerQuad(gfx::RectF(0, 0, width, height)); |
153 | 153 |
154 // Compute the projection of the layer quad onto the z = 0 plane. | 154 // Compute the projection of the layer quad onto the z = 0 plane. |
155 | 155 |
156 gfx::PointF clippedQuad[8]; | 156 gfx::PointF clippedQuad[8]; |
157 int numVerticesInClippedQuad; | 157 int numVerticesInClippedQuad; |
158 MathUtil::mapClippedQuad(drawTransform, layerQuad, clippedQuad, numVerticesI
nClippedQuad); | 158 MathUtil::mapClippedQuad(drawTransform, layerQuad, clippedQuad, numVerticesI
nClippedQuad); |
159 | 159 |
160 if (numVerticesInClippedQuad < 3) { | 160 if (numVerticesInClippedQuad < 3) { |
161 projectedBounds = gfx::RectF(); | 161 projectedBounds = gfx::RectF(); |
162 return; | 162 return; |
163 } | 163 } |
164 | 164 |
165 projectedBounds = MathUtil::computeEnclosingRectOfVertices(clippedQuad, numV
erticesInClippedQuad); | 165 projectedBounds = MathUtil::computeEnclosingRectOfVertices(clippedQuad, numV
erticesInClippedQuad); |
166 | 166 |
167 // NOTE: it will require very significant refactoring and overhead to deal w
ith | 167 // NOTE: it will require very significant refactoring and overhead to deal w
ith |
168 // generalized polygons or multiple quads per layer here. For the sake of la
yer | 168 // generalized polygons or multiple quads per layer here. For the sake of la
yer |
169 // sorting it is equally correct to take a subsection of the polygon that ca
n be made | 169 // sorting it is equally correct to take a subsection of the polygon that ca
n be made |
170 // into a quad. This will only be incorrect in the case of intersecting laye
rs, which | 170 // into a quad. This will only be incorrect in the case of intersecting laye
rs, which |
171 // are not supported yet anyway. | 171 // are not supported yet anyway. |
172 projectedQuad.setP1(clippedQuad[0]); | 172 projectedQuad.set_p1(clippedQuad[0]); |
173 projectedQuad.setP2(clippedQuad[1]); | 173 projectedQuad.set_p2(clippedQuad[1]); |
174 projectedQuad.setP3(clippedQuad[2]); | 174 projectedQuad.set_p3(clippedQuad[2]); |
175 if (numVerticesInClippedQuad >= 4) | 175 if (numVerticesInClippedQuad >= 4) |
176 projectedQuad.setP4(clippedQuad[3]); | 176 projectedQuad.set_p4(clippedQuad[3]); |
177 else | 177 else |
178 projectedQuad.setP4(clippedQuad[2]); // this will be a degenerate quad t
hat is actually a triangle. | 178 projectedQuad.set_p4(clippedQuad[2]); // this will be a degenerate quad
that is actually a triangle. |
179 | 179 |
180 // Compute the normal of the layer's plane. | 180 // Compute the normal of the layer's plane. |
181 bool clipped = false; | 181 bool clipped = false; |
182 gfx::Point3F c1 = MathUtil::mapPoint(drawTransform, gfx::Point3F(0, 0, 0), c
lipped); | 182 gfx::Point3F c1 = MathUtil::mapPoint(drawTransform, gfx::Point3F(0, 0, 0), c
lipped); |
183 gfx::Point3F c2 = MathUtil::mapPoint(drawTransform, gfx::Point3F(0, 1, 0), c
lipped); | 183 gfx::Point3F c2 = MathUtil::mapPoint(drawTransform, gfx::Point3F(0, 1, 0), c
lipped); |
184 gfx::Point3F c3 = MathUtil::mapPoint(drawTransform, gfx::Point3F(1, 0, 0), c
lipped); | 184 gfx::Point3F c3 = MathUtil::mapPoint(drawTransform, gfx::Point3F(1, 0, 0), c
lipped); |
185 // FIXME: Deal with clipping. | 185 // FIXME: Deal with clipping. |
186 gfx::Vector3dF c12 = c2 - c1; | 186 gfx::Vector3dF c12 = c2 - c1; |
187 gfx::Vector3dF c13 = c3 - c1; | 187 gfx::Vector3dF c13 = c3 - c1; |
188 layerNormal = gfx::CrossProduct(c13, c12); | 188 layerNormal = gfx::CrossProduct(c13, c12); |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 *it = sortedList[count++]->layer; | 407 *it = sortedList[count++]->layer; |
408 | 408 |
409 DVLOG(2) << "Sorting end ----"; | 409 DVLOG(2) << "Sorting end ----"; |
410 | 410 |
411 m_nodes.clear(); | 411 m_nodes.clear(); |
412 m_edges.clear(); | 412 m_edges.clear(); |
413 m_activeEdges.clear(); | 413 m_activeEdges.clear(); |
414 } | 414 } |
415 | 415 |
416 } | 416 } |
OLD | NEW |