Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Unified Diff: cc/quads/draw_polygon.cc

Issue 2714243002: Correct polygon splitting in an almost-coplanar case. (Closed)
Patch Set: Make constants float, for Windows. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | cc/quads/draw_polygon_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/quads/draw_polygon.cc
diff --git a/cc/quads/draw_polygon.cc b/cc/quads/draw_polygon.cc
index a950e752bc5eaa3e2f0e4cd675da872d9eb79716..6574196ae0976031b002422978571f191c861adf 100644
--- a/cc/quads/draw_polygon.cc
+++ b/cc/quads/draw_polygon.cc
@@ -288,11 +288,12 @@ void DrawPolygon::SplitPolygon(std::unique_ptr<DrawPolygon> polygon,
std::vector<gfx::Point3F> out_points;
out_points.push_back(pre_pos_intersection);
- do {
- out_points.push_back(polygon->points_[front_begin]);
- front_begin = next(front_begin);
- } while (vertex_distance[front_begin] > 0.0);
- out_points.push_back(pre_neg_intersection);
+ for (size_t index = front_begin; index != back_begin; index = next(index)) {
+ out_points.push_back(polygon->points_[index]);
+ }
+ if (out_points.back() != pre_neg_intersection) {
+ out_points.push_back(pre_neg_intersection);
+ }
*front =
base::MakeUnique<DrawPolygon>(polygon->original_ref_, out_points,
polygon->normal_, polygon->order_index_);
@@ -300,11 +301,12 @@ void DrawPolygon::SplitPolygon(std::unique_ptr<DrawPolygon> polygon,
out_points.clear();
out_points.push_back(pre_neg_intersection);
- do {
- out_points.push_back(polygon->points_[back_begin]);
- back_begin = next(back_begin);
- } while (vertex_distance[back_begin] < 0.0);
- out_points.push_back(pre_pos_intersection);
+ for (size_t index = back_begin; index != front_begin; index = next(index)) {
+ out_points.push_back(polygon->points_[index]);
+ }
+ if (out_points.back() != pre_pos_intersection) {
+ out_points.push_back(pre_pos_intersection);
+ }
*back =
base::MakeUnique<DrawPolygon>(polygon->original_ref_, out_points,
polygon->normal_, polygon->order_index_);
« no previous file with comments | « no previous file | cc/quads/draw_polygon_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698