| 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 "cc/layer_sorter.h" | 5 #include "cc/layer_sorter.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "cc/math_util.h" | 13 #include "cc/math_util.h" |
| 14 #include "cc/render_surface_impl.h" | 14 #include "cc/render_surface_impl.h" |
| 15 #include <public/WebTransformationMatrix.h> | 15 #include "ui/gfx/transform.h" |
| 16 | 16 |
| 17 using namespace std; | 17 using namespace std; |
| 18 using WebKit::WebTransformationMatrix; | 18 using gfx::Transform; |
| 19 | 19 |
| 20 namespace cc { | 20 namespace cc { |
| 21 | 21 |
| 22 inline static float perpProduct(const gfx::Vector2dF& u, const gfx::Vector2dF& v
) | 22 inline static float perpProduct(const gfx::Vector2dF& u, const gfx::Vector2dF& v
) |
| 23 { | 23 { |
| 24 return u.x() * v.y() - u.y() * v.x(); | 24 return u.x() * v.y() - u.y() * v.x(); |
| 25 } | 25 } |
| 26 | 26 |
| 27 // Tests if two edges defined by their endpoints (a,b) and (c,d) intersect. Retu
rns true and the | 27 // Tests if two edges defined by their endpoints (a,b) and (c,d) intersect. Retu
rns true and the |
| 28 // point of intersection if they do and false otherwise. | 28 // point of intersection if they do and false otherwise. |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 if (maxDiff <= 0) | 139 if (maxDiff <= 0) |
| 140 return ABeforeB; | 140 return ABeforeB; |
| 141 | 141 |
| 142 return BBeforeA; | 142 return BBeforeA; |
| 143 } | 143 } |
| 144 | 144 |
| 145 LayerShape::LayerShape() | 145 LayerShape::LayerShape() |
| 146 { | 146 { |
| 147 } | 147 } |
| 148 | 148 |
| 149 LayerShape::LayerShape(float width, float height, const WebTransformationMatrix&
drawTransform) | 149 LayerShape::LayerShape(float width, float height, const Transform& drawTransform
) |
| 150 { | 150 { |
| 151 gfx::QuadF layerQuad(gfx::RectF(0, 0, width, height)); | 151 gfx::QuadF layerQuad(gfx::RectF(0, 0, width, height)); |
| 152 | 152 |
| 153 // Compute the projection of the layer quad onto the z = 0 plane. | 153 // Compute the projection of the layer quad onto the z = 0 plane. |
| 154 | 154 |
| 155 gfx::PointF clippedQuad[8]; | 155 gfx::PointF clippedQuad[8]; |
| 156 int numVerticesInClippedQuad; | 156 int numVerticesInClippedQuad; |
| 157 MathUtil::mapClippedQuad(drawTransform, layerQuad, clippedQuad, numVerticesI
nClippedQuad); | 157 MathUtil::mapClippedQuad(drawTransform, layerQuad, clippedQuad, numVerticesI
nClippedQuad); |
| 158 | 158 |
| 159 if (numVerticesInClippedQuad < 3) { | 159 if (numVerticesInClippedQuad < 3) { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 float maxZ = -FLT_MAX; | 223 float maxZ = -FLT_MAX; |
| 224 for (LayerList::const_iterator it = first; it < last; it++) { | 224 for (LayerList::const_iterator it = first; it < last; it++) { |
| 225 m_nodes.push_back(GraphNode(*it)); | 225 m_nodes.push_back(GraphNode(*it)); |
| 226 GraphNode& node = m_nodes.at(m_nodes.size() - 1); | 226 GraphNode& node = m_nodes.at(m_nodes.size() - 1); |
| 227 RenderSurfaceImpl* renderSurface = node.layer->renderSurface(); | 227 RenderSurfaceImpl* renderSurface = node.layer->renderSurface(); |
| 228 if (!node.layer->drawsContent() && !renderSurface) | 228 if (!node.layer->drawsContent() && !renderSurface) |
| 229 continue; | 229 continue; |
| 230 | 230 |
| 231 DVLOG(2) << "Layer " << node.layer->id() << " (" << node.layer->bounds()
.width() << " x " << node.layer->bounds().height() << ")"; | 231 DVLOG(2) << "Layer " << node.layer->id() << " (" << node.layer->bounds()
.width() << " x " << node.layer->bounds().height() << ")"; |
| 232 | 232 |
| 233 WebTransformationMatrix drawTransform; | 233 Transform drawTransform; |
| 234 float layerWidth, layerHeight; | 234 float layerWidth, layerHeight; |
| 235 if (renderSurface) { | 235 if (renderSurface) { |
| 236 drawTransform = renderSurface->drawTransform(); | 236 drawTransform = renderSurface->drawTransform(); |
| 237 layerWidth = renderSurface->contentRect().width(); | 237 layerWidth = renderSurface->contentRect().width(); |
| 238 layerHeight = renderSurface->contentRect().height(); | 238 layerHeight = renderSurface->contentRect().height(); |
| 239 } else { | 239 } else { |
| 240 drawTransform = node.layer->drawTransform(); | 240 drawTransform = node.layer->drawTransform(); |
| 241 layerWidth = node.layer->contentBounds().width(); | 241 layerWidth = node.layer->contentBounds().width(); |
| 242 layerHeight = node.layer->contentBounds().height(); | 242 layerHeight = node.layer->contentBounds().height(); |
| 243 } | 243 } |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 *it = sortedList[count++]->layer; | 406 *it = sortedList[count++]->layer; |
| 407 | 407 |
| 408 DVLOG(2) << "Sorting end ----"; | 408 DVLOG(2) << "Sorting end ----"; |
| 409 | 409 |
| 410 m_nodes.clear(); | 410 m_nodes.clear(); |
| 411 m_edges.clear(); | 411 m_edges.clear(); |
| 412 m_activeEdges.clear(); | 412 m_activeEdges.clear(); |
| 413 } | 413 } |
| 414 | 414 |
| 415 } // namespace cc | 415 } // namespace cc |
| OLD | NEW |