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

Unified Diff: cc/base/math_util.cc

Issue 2551263002: Don't add duplicate points when clipping (Closed)
Patch Set: First test Created 4 years 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/base/math_util_unittest.cc » ('j') | cc/base/math_util_unittest.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/base/math_util.cc
diff --git a/cc/base/math_util.cc b/cc/base/math_util.cc
index d28c195971f6cd14eb753b6d9eddd51d1dd082fb..c29f75d7101348fff392cd55c9e658afee5c9523 100644
--- a/cc/base/math_util.cc
+++ b/cc/base/math_util.cc
@@ -158,6 +158,12 @@ static inline void ExpandBoundsToIncludePoint(float* xmin,
static inline void AddVertexToClippedQuad(const gfx::PointF& new_vertex,
gfx::PointF clipped_quad[8],
int* num_vertices_in_clipped_quad) {
+ if (*num_vertices_in_clipped_quad > 0) {
+ if (clipped_quad[*num_vertices_in_clipped_quad - 1] == new_vertex)
Peter Mayo 2016/12/08 19:37:39 These are floating point values, and should use an
flackr 2016/12/08 20:24:01 If the problem case is clipping to the same infini
Peter Mayo 2016/12/08 20:29:09 Inifinity is a single value in the non-parametric
+ return;
+ if (clipped_quad[0] == new_vertex)
+ return;
+ }
clipped_quad[*num_vertices_in_clipped_quad] = new_vertex;
(*num_vertices_in_clipped_quad)++;
}
@@ -165,6 +171,12 @@ static inline void AddVertexToClippedQuad(const gfx::PointF& new_vertex,
static inline void AddVertexToClippedQuad3d(const gfx::Point3F& new_vertex,
gfx::Point3F clipped_quad[8],
int* num_vertices_in_clipped_quad) {
+ if (*num_vertices_in_clipped_quad > 0) {
+ if (clipped_quad[*num_vertices_in_clipped_quad - 1] == new_vertex)
+ return;
+ if (clipped_quad[0] == new_vertex)
+ return;
+ }
clipped_quad[*num_vertices_in_clipped_quad] = new_vertex;
(*num_vertices_in_clipped_quad)++;
}
« no previous file with comments | « no previous file | cc/base/math_util_unittest.cc » ('j') | cc/base/math_util_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698