Chromium Code Reviews| Index: cc/quads/draw_polygon.cc |
| diff --git a/cc/quads/draw_polygon.cc b/cc/quads/draw_polygon.cc |
| index 71dbf366dab963a13958b57eedffc7c85ee2deb0..b6737179994d6472ee017f999259b3dab3c8e9f4 100644 |
| --- a/cc/quads/draw_polygon.cc |
| +++ b/cc/quads/draw_polygon.cc |
| @@ -25,21 +25,21 @@ static const float compare_threshold = 1.0f; |
| // points that SHOULD be intersecting the "thick plane", but actually fail to |
| // test positively for it because |split_threshold| allowed them to be outside |
| // this range. |
| -static const float split_threshold = 0.5f; |
| +static const float split_threshold = compare_threshold / 2.0f; |
| } // namespace |
| namespace cc { |
| -gfx::Vector3dF DrawPolygon::default_normal = gfx::Vector3dF(0.0f, 0.0f, -1.0f); |
| +gfx::Vector3dF DrawPolygon::default_normal = gfx::Vector3dF(0.0f, 0.0f, 1.0f); |
| DrawPolygon::DrawPolygon() { |
| } |
| -DrawPolygon::DrawPolygon(DrawQuad* original, |
| +DrawPolygon::DrawPolygon(const DrawQuad* original, |
| const std::vector<gfx::Point3F>& in_points, |
| const gfx::Vector3dF& normal, |
| int draw_order_index) |
| - : order_index_(draw_order_index), original_ref_(original) { |
| + : order_index_(draw_order_index), original_ref_(original), is_split_(true) { |
| for (size_t i = 0; i < in_points.size(); i++) { |
| points_.push_back(in_points[i]); |
| } |
| @@ -49,12 +49,14 @@ DrawPolygon::DrawPolygon(DrawQuad* original, |
| // This takes the original DrawQuad that this polygon should be based on, |
| // a visible content rect to make the 4 corner points from, and a transformation |
| // to move it and its normal into screen space. |
| -DrawPolygon::DrawPolygon(DrawQuad* original_ref, |
| +DrawPolygon::DrawPolygon(const DrawQuad* original_ref, |
| const gfx::RectF& visible_content_rect, |
| const gfx::Transform& transform, |
| int draw_order_index) |
| - : order_index_(draw_order_index), original_ref_(original_ref) { |
| - normal_ = default_normal; |
| + : normal_(default_normal), |
| + order_index_(draw_order_index), |
| + original_ref_(original_ref), |
| + is_split_(false) { |
| gfx::Point3F points[8]; |
| int num_vertices_in_clipped_quad; |
| gfx::QuadF send_quad(visible_content_rect); |
| @@ -97,6 +99,9 @@ float DrawPolygon::SignedPointDistance(const gfx::Point3F& point) const { |
| // Assumes that layers are split and there are no intersecting planes. |
| BspCompareResult DrawPolygon::SideCompare(const DrawPolygon& a, |
| const DrawPolygon& b) { |
| + // Let's make sure that both of these are normalized. |
| + DCHECK_GE(0.001f, std::abs(a.normal_.LengthSquared() - 1.0f)); |
|
enne (OOO)
2015/02/04 21:24:00
Make a constant for this too?
awoloszyn
2015/02/12 16:48:52
Done.
|
| + DCHECK_GE(0.001f, std::abs(b.normal_.LengthSquared() - 1.0f)); |
| // Right away let's check if they're coplanar |
| double dot = gfx::DotProduct(a.normal_, b.normal_); |
| float sign = 0.0f; |
| @@ -105,7 +110,7 @@ BspCompareResult DrawPolygon::SideCompare(const DrawPolygon& a, |
| if (std::abs(dot) >= 1.0f - coplanar_dot_epsilon) { |
| normal_match = true; |
| // The normals are matching enough that we only have to test one point. |
| - sign = gfx::DotProduct(a.points_[0] - b.points_[0], b.normal_); |
| + sign = b.SignedPointDistance(a.points_[0]); |
| // Is it on either side of the splitter? |
| if (sign < -compare_threshold) { |
| return BSP_BACK; |
| @@ -168,7 +173,7 @@ static bool LineIntersectPlane(const gfx::Point3F& line_start, |
| // The case where one vertex lies on the thick-plane and the other |
| // is outside of it. |
| - if (std::abs(start_distance) < distance_threshold && |
| + if (std::abs(start_distance) <= distance_threshold && |
| std::abs(end_distance) > distance_threshold) { |
| intersection->SetPoint(line_start.x(), line_start.y(), line_start.z()); |
| return true; |
| @@ -270,7 +275,7 @@ bool DrawPolygon::Split(const DrawPolygon& splitter, |
| break; |
| } |
| } |
| - if (current_vertex++ > points_size) { |
| + if (current_vertex++ > (points_size + 1)) { |
|
enne (OOO)
2015/02/04 21:24:00
Can you explain this? Maybe also put the increment
awoloszyn
2015/02/12 16:48:52
I think this is actually un-needed. I had some rea
|
| break; |
| } |
| } |
| @@ -284,6 +289,7 @@ bool DrawPolygon::Split(const DrawPolygon& splitter, |
| // First polygon. |
| out_points[0].push_back(intersections[0]); |
| + DCHECK_GE(vertex_before[1], start1); |
| for (size_t i = start1; i <= vertex_before[1]; i++) { |
| out_points[0].push_back(points_[i]); |
| --points_remaining; |
| @@ -306,6 +312,9 @@ bool DrawPolygon::Split(const DrawPolygon& splitter, |
| scoped_ptr<DrawPolygon> poly2( |
| new DrawPolygon(original_ref_, out_points[1], normal_, order_index_)); |
| + DCHECK_GE(poly1->points().size(), 3u); |
| + DCHECK_GE(poly2->points().size(), 3u); |
| + |
| if (SideCompare(*poly1, splitter) == BSP_FRONT) { |
| *front = poly1.Pass(); |
| *back = poly2.Pass(); |