| 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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 polygon->points_[pre_back_begin], polygon->points_[back_begin], | 281 polygon->points_[pre_back_begin], polygon->points_[back_begin], |
| 282 -vertex_distance[pre_back_begin] / | 282 -vertex_distance[pre_back_begin] / |
| 283 gfx::DotProduct(normal_, polygon->points_[back_begin] - | 283 gfx::DotProduct(normal_, polygon->points_[back_begin] - |
| 284 polygon->points_[pre_back_begin]), | 284 polygon->points_[pre_back_begin]), |
| 285 &pre_neg_intersection); | 285 &pre_neg_intersection); |
| 286 | 286 |
| 287 // Build the front and back polygons. | 287 // Build the front and back polygons. |
| 288 std::vector<gfx::Point3F> out_points; | 288 std::vector<gfx::Point3F> out_points; |
| 289 | 289 |
| 290 out_points.push_back(pre_pos_intersection); | 290 out_points.push_back(pre_pos_intersection); |
| 291 do { | 291 for (size_t index = front_begin; index != back_begin; index = next(index)) { |
| 292 out_points.push_back(polygon->points_[front_begin]); | 292 out_points.push_back(polygon->points_[index]); |
| 293 front_begin = next(front_begin); | 293 } |
| 294 } while (vertex_distance[front_begin] > 0.0); | 294 if (out_points.back() != pre_neg_intersection) { |
| 295 out_points.push_back(pre_neg_intersection); | 295 out_points.push_back(pre_neg_intersection); |
| 296 } |
| 296 *front = | 297 *front = |
| 297 base::MakeUnique<DrawPolygon>(polygon->original_ref_, out_points, | 298 base::MakeUnique<DrawPolygon>(polygon->original_ref_, out_points, |
| 298 polygon->normal_, polygon->order_index_); | 299 polygon->normal_, polygon->order_index_); |
| 299 | 300 |
| 300 out_points.clear(); | 301 out_points.clear(); |
| 301 | 302 |
| 302 out_points.push_back(pre_neg_intersection); | 303 out_points.push_back(pre_neg_intersection); |
| 303 do { | 304 for (size_t index = back_begin; index != front_begin; index = next(index)) { |
| 304 out_points.push_back(polygon->points_[back_begin]); | 305 out_points.push_back(polygon->points_[index]); |
| 305 back_begin = next(back_begin); | 306 } |
| 306 } while (vertex_distance[back_begin] < 0.0); | 307 if (out_points.back() != pre_pos_intersection) { |
| 307 out_points.push_back(pre_pos_intersection); | 308 out_points.push_back(pre_pos_intersection); |
| 309 } |
| 308 *back = | 310 *back = |
| 309 base::MakeUnique<DrawPolygon>(polygon->original_ref_, out_points, | 311 base::MakeUnique<DrawPolygon>(polygon->original_ref_, out_points, |
| 310 polygon->normal_, polygon->order_index_); | 312 polygon->normal_, polygon->order_index_); |
| 311 | 313 |
| 312 DCHECK_GE((*front)->points().size(), 3u); | 314 DCHECK_GE((*front)->points().size(), 3u); |
| 313 DCHECK_GE((*back)->points().size(), 3u); | 315 DCHECK_GE((*back)->points().size(), 3u); |
| 314 } | 316 } |
| 315 | 317 |
| 316 // This algorithm takes the first vertex in the polygon and uses that as a | 318 // This algorithm takes the first vertex in the polygon and uses that as a |
| 317 // pivot point to fan out and create quads from the rest of the vertices. | 319 // pivot point to fan out and create quads from the rest of the vertices. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 340 quads->push_back( | 342 quads->push_back( |
| 341 gfx::QuadF(first, | 343 gfx::QuadF(first, |
| 342 gfx::PointF(points_[offset].x(), points_[offset].y()), | 344 gfx::PointF(points_[offset].x(), points_[offset].y()), |
| 343 gfx::PointF(points_[op1].x(), points_[op1].y()), | 345 gfx::PointF(points_[op1].x(), points_[op1].y()), |
| 344 gfx::PointF(points_[op2].x(), points_[op2].y()))); | 346 gfx::PointF(points_[op2].x(), points_[op2].y()))); |
| 345 offset = op2; | 347 offset = op2; |
| 346 } | 348 } |
| 347 } | 349 } |
| 348 | 350 |
| 349 } // namespace cc | 351 } // namespace cc |
| OLD | NEW |