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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 | 78 |
79 scoped_ptr<DrawPolygon> DrawPolygon::CreateCopy() { | 79 scoped_ptr<DrawPolygon> DrawPolygon::CreateCopy() { |
80 scoped_ptr<DrawPolygon> new_polygon(new DrawPolygon()); | 80 scoped_ptr<DrawPolygon> new_polygon(new DrawPolygon()); |
81 new_polygon->order_index_ = order_index_; | 81 new_polygon->order_index_ = order_index_; |
82 new_polygon->original_ref_ = original_ref_; | 82 new_polygon->original_ref_ = original_ref_; |
83 new_polygon->points_.reserve(points_.size()); | 83 new_polygon->points_.reserve(points_.size()); |
84 new_polygon->points_ = points_; | 84 new_polygon->points_ = points_; |
85 new_polygon->normal_.set_x(normal_.x()); | 85 new_polygon->normal_.set_x(normal_.x()); |
86 new_polygon->normal_.set_y(normal_.y()); | 86 new_polygon->normal_.set_y(normal_.y()); |
87 new_polygon->normal_.set_z(normal_.z()); | 87 new_polygon->normal_.set_z(normal_.z()); |
88 return new_polygon.Pass(); | 88 return new_polygon; |
89 } | 89 } |
90 | 90 |
91 float DrawPolygon::SignedPointDistance(const gfx::Point3F& point) const { | 91 float DrawPolygon::SignedPointDistance(const gfx::Point3F& point) const { |
92 return gfx::DotProduct(point - points_[0], normal_); | 92 return gfx::DotProduct(point - points_[0], normal_); |
93 } | 93 } |
94 | 94 |
95 // Checks whether or not shape a lies on the front or back side of b, or | 95 // Checks whether or not shape a lies on the front or back side of b, or |
96 // whether they should be considered coplanar. If on the back side, we | 96 // whether they should be considered coplanar. If on the back side, we |
97 // say A_BEFORE_B because it should be drawn in that order. | 97 // say A_BEFORE_B because it should be drawn in that order. |
98 // Assumes that layers are split and there are no intersecting planes. | 98 // Assumes that layers are split and there are no intersecting planes. |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 // still be sorted properly in co-planar instances. | 287 // still be sorted properly in co-planar instances. |
288 scoped_ptr<DrawPolygon> poly1( | 288 scoped_ptr<DrawPolygon> poly1( |
289 new DrawPolygon(original_ref_, out_points[0], normal_, order_index_)); | 289 new DrawPolygon(original_ref_, out_points[0], normal_, order_index_)); |
290 scoped_ptr<DrawPolygon> poly2( | 290 scoped_ptr<DrawPolygon> poly2( |
291 new DrawPolygon(original_ref_, out_points[1], normal_, order_index_)); | 291 new DrawPolygon(original_ref_, out_points[1], normal_, order_index_)); |
292 | 292 |
293 DCHECK_GE(poly1->points().size(), 3u); | 293 DCHECK_GE(poly1->points().size(), 3u); |
294 DCHECK_GE(poly2->points().size(), 3u); | 294 DCHECK_GE(poly2->points().size(), 3u); |
295 | 295 |
296 if (SideCompare(*poly1, splitter) == BSP_FRONT) { | 296 if (SideCompare(*poly1, splitter) == BSP_FRONT) { |
297 *front = poly1.Pass(); | 297 *front = std::move(poly1); |
298 *back = poly2.Pass(); | 298 *back = std::move(poly2); |
299 } else { | 299 } else { |
300 *front = poly2.Pass(); | 300 *front = std::move(poly2); |
301 *back = poly1.Pass(); | 301 *back = std::move(poly1); |
302 } | 302 } |
303 return true; | 303 return true; |
304 } | 304 } |
305 | 305 |
306 // This algorithm takes the first vertex in the polygon and uses that as a | 306 // This algorithm takes the first vertex in the polygon and uses that as a |
307 // pivot point to fan out and create quads from the rest of the vertices. | 307 // pivot point to fan out and create quads from the rest of the vertices. |
308 // |offset| starts off as the second vertex, and then |op1| and |op2| indicate | 308 // |offset| starts off as the second vertex, and then |op1| and |op2| indicate |
309 // offset+1 and offset+2 respectively. | 309 // offset+1 and offset+2 respectively. |
310 // After the first quad is created, the first vertex in the next quad is the | 310 // After the first quad is created, the first vertex in the next quad is the |
311 // same as all the rest, the pivot point. The second vertex in the next quad is | 311 // same as all the rest, the pivot point. The second vertex in the next quad is |
(...skipping 18 matching lines...) Expand all Loading... |
330 quads->push_back( | 330 quads->push_back( |
331 gfx::QuadF(first, | 331 gfx::QuadF(first, |
332 gfx::PointF(points_[offset].x(), points_[offset].y()), | 332 gfx::PointF(points_[offset].x(), points_[offset].y()), |
333 gfx::PointF(points_[op1].x(), points_[op1].y()), | 333 gfx::PointF(points_[op1].x(), points_[op1].y()), |
334 gfx::PointF(points_[op2].x(), points_[op2].y()))); | 334 gfx::PointF(points_[op2].x(), points_[op2].y()))); |
335 offset = op2; | 335 offset = op2; |
336 } | 336 } |
337 } | 337 } |
338 | 338 |
339 } // namespace cc | 339 } // namespace cc |
OLD | NEW |