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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 25 matching lines...) Expand all Loading... | |
36 } | 36 } |
37 | 37 |
38 DrawPolygon::DrawPolygon(const DrawQuad* original, | 38 DrawPolygon::DrawPolygon(const DrawQuad* original, |
39 const std::vector<gfx::Point3F>& in_points, | 39 const std::vector<gfx::Point3F>& in_points, |
40 const gfx::Vector3dF& normal, | 40 const gfx::Vector3dF& normal, |
41 int draw_order_index) | 41 int draw_order_index) |
42 : order_index_(draw_order_index), original_ref_(original), is_split_(true) { | 42 : order_index_(draw_order_index), original_ref_(original), is_split_(true) { |
43 for (size_t i = 0; i < in_points.size(); i++) { | 43 for (size_t i = 0; i < in_points.size(); i++) { |
44 points_.push_back(in_points[i]); | 44 points_.push_back(in_points[i]); |
45 } | 45 } |
46 #if DCHECK_IS_ON() | |
47 normal_ = normal; | 46 normal_ = normal; |
danakj
2017/03/17 14:14:44
can this be initialized in the constructor init li
Peter Mayo
2017/03/17 16:04:07
Yes, that makes sense now. Done.
| |
48 ConstructNormal(); | 47 // If life was fair, we could recalculate the normal from the given points |
49 DCHECK_LE((normal_ - normal).Length(), normalized_threshold); | 48 // and assert it was roughly the same. This causes unhelpful breaks on |
50 #endif | 49 // trivial slices of split polygons. Similarly, when splitting, it is |
51 normal_ = normal; | 50 // better to keep the normal that was constructed from the original. |
52 } | 51 } |
53 | 52 |
54 // This takes the original DrawQuad that this polygon should be based on, | 53 // This takes the original DrawQuad that this polygon should be based on, |
55 // a visible content rect to make the 4 corner points from, and a transformation | 54 // a visible content rect to make the 4 corner points from, and a transformation |
56 // to move it and its normal into screen space. | 55 // to move it and its normal into screen space. |
57 DrawPolygon::DrawPolygon(const DrawQuad* original_ref, | 56 DrawPolygon::DrawPolygon(const DrawQuad* original_ref, |
58 const gfx::RectF& visible_layer_rect, | 57 const gfx::RectF& visible_layer_rect, |
59 const gfx::Transform& transform, | 58 const gfx::Transform& transform, |
60 int draw_order_index) | 59 int draw_order_index) |
61 : normal_(0.0f, 0.0f, 1.0f), | 60 : normal_(0.0f, 0.0f, 1.0f), |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
342 quads->push_back( | 341 quads->push_back( |
343 gfx::QuadF(first, | 342 gfx::QuadF(first, |
344 gfx::PointF(points_[offset].x(), points_[offset].y()), | 343 gfx::PointF(points_[offset].x(), points_[offset].y()), |
345 gfx::PointF(points_[op1].x(), points_[op1].y()), | 344 gfx::PointF(points_[op1].x(), points_[op1].y()), |
346 gfx::PointF(points_[op2].x(), points_[op2].y()))); | 345 gfx::PointF(points_[op2].x(), points_[op2].y()))); |
347 offset = op2; | 346 offset = op2; |
348 } | 347 } |
349 } | 348 } |
350 | 349 |
351 } // namespace cc | 350 } // namespace cc |
OLD | NEW |