OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/quads/draw_polygon.h" | 5 #include "cc/quads/draw_polygon.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "cc/output/bsp_compare_result.h" | 9 #include "cc/output/bsp_compare_result.h" |
10 #include "cc/quads/draw_quad.h" | 10 #include "cc/quads/draw_quad.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 new_polygon->normal_.set_z(normal_.z()); | 86 new_polygon->normal_.set_z(normal_.z()); |
87 return new_polygon.Pass(); | 87 return new_polygon.Pass(); |
88 } | 88 } |
89 | 89 |
90 float DrawPolygon::SignedPointDistance(const gfx::Point3F& point) const { | 90 float DrawPolygon::SignedPointDistance(const gfx::Point3F& point) const { |
91 return gfx::DotProduct(point - points_[0], normal_); | 91 return gfx::DotProduct(point - points_[0], normal_); |
92 } | 92 } |
93 | 93 |
94 // Checks whether or not shape a lies on the front or back side of b, or | 94 // Checks whether or not shape a lies on the front or back side of b, or |
95 // whether they should be considered coplanar. If on the back side, we | 95 // whether they should be considered coplanar. If on the back side, we |
96 // say A_BEFORE_B because it should be drawn in that order. | 96 // say ABeforeB because it should be drawn in that order. |
97 // Assumes that layers are split and there are no intersecting planes. | 97 // Assumes that layers are split and there are no intersecting planes. |
98 BspCompareResult DrawPolygon::SideCompare(const DrawPolygon& a, | 98 BspCompareResult DrawPolygon::SideCompare(const DrawPolygon& a, |
99 const DrawPolygon& b) { | 99 const DrawPolygon& b) { |
100 // Right away let's check if they're coplanar | 100 // Right away let's check if they're coplanar |
101 double dot = gfx::DotProduct(a.normal_, b.normal_); | 101 double dot = gfx::DotProduct(a.normal_, b.normal_); |
102 float sign = 0.0f; | 102 float sign = 0.0f; |
103 bool normal_match = false; | 103 bool normal_match = false; |
104 // This check assumes that the normals are normalized. | 104 // This check assumes that the normals are normalized. |
105 if (std::abs(dot) >= 1.0f - coplanar_dot_epsilon) { | 105 if (std::abs(dot) >= 1.0f - coplanar_dot_epsilon) { |
106 normal_match = true; | 106 normal_match = true; |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 quads->push_back( | 343 quads->push_back( |
344 gfx::QuadF(first, | 344 gfx::QuadF(first, |
345 gfx::PointF(points_[offset].x(), points_[offset].y()), | 345 gfx::PointF(points_[offset].x(), points_[offset].y()), |
346 gfx::PointF(points_[op1].x(), points_[op1].y()), | 346 gfx::PointF(points_[op1].x(), points_[op1].y()), |
347 gfx::PointF(points_[op2].x(), points_[op2].y()))); | 347 gfx::PointF(points_[op2].x(), points_[op2].y()))); |
348 offset = op2; | 348 offset = op2; |
349 } | 349 } |
350 } | 350 } |
351 | 351 |
352 } // namespace cc | 352 } // namespace cc |
OLD | NEW |