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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | cc/base/math_util_unittest.cc » ('j') | cc/base/math_util_unittest.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/base/math_util.h" 5 #include "cc/base/math_util.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 #ifdef __SSE__ 10 #ifdef __SSE__
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 const gfx::PointF& p) { 151 const gfx::PointF& p) {
152 *xmin = std::min(p.x(), *xmin); 152 *xmin = std::min(p.x(), *xmin);
153 *xmax = std::max(p.x(), *xmax); 153 *xmax = std::max(p.x(), *xmax);
154 *ymin = std::min(p.y(), *ymin); 154 *ymin = std::min(p.y(), *ymin);
155 *ymax = std::max(p.y(), *ymax); 155 *ymax = std::max(p.y(), *ymax);
156 } 156 }
157 157
158 static inline void AddVertexToClippedQuad(const gfx::PointF& new_vertex, 158 static inline void AddVertexToClippedQuad(const gfx::PointF& new_vertex,
159 gfx::PointF clipped_quad[8], 159 gfx::PointF clipped_quad[8],
160 int* num_vertices_in_clipped_quad) { 160 int* num_vertices_in_clipped_quad) {
161 if (*num_vertices_in_clipped_quad > 0) {
162 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
163 return;
164 if (clipped_quad[0] == new_vertex)
165 return;
166 }
161 clipped_quad[*num_vertices_in_clipped_quad] = new_vertex; 167 clipped_quad[*num_vertices_in_clipped_quad] = new_vertex;
162 (*num_vertices_in_clipped_quad)++; 168 (*num_vertices_in_clipped_quad)++;
163 } 169 }
164 170
165 static inline void AddVertexToClippedQuad3d(const gfx::Point3F& new_vertex, 171 static inline void AddVertexToClippedQuad3d(const gfx::Point3F& new_vertex,
166 gfx::Point3F clipped_quad[8], 172 gfx::Point3F clipped_quad[8],
167 int* num_vertices_in_clipped_quad) { 173 int* num_vertices_in_clipped_quad) {
174 if (*num_vertices_in_clipped_quad > 0) {
175 if (clipped_quad[*num_vertices_in_clipped_quad - 1] == new_vertex)
176 return;
177 if (clipped_quad[0] == new_vertex)
178 return;
179 }
168 clipped_quad[*num_vertices_in_clipped_quad] = new_vertex; 180 clipped_quad[*num_vertices_in_clipped_quad] = new_vertex;
169 (*num_vertices_in_clipped_quad)++; 181 (*num_vertices_in_clipped_quad)++;
170 } 182 }
171 183
172 gfx::Rect MathUtil::MapEnclosingClippedRect(const gfx::Transform& transform, 184 gfx::Rect MathUtil::MapEnclosingClippedRect(const gfx::Transform& transform,
173 const gfx::Rect& src_rect) { 185 const gfx::Rect& src_rect) {
174 if (transform.IsIdentityOrIntegerTranslation()) { 186 if (transform.IsIdentityOrIntegerTranslation()) {
175 gfx::Vector2d offset(static_cast<int>(transform.matrix().getFloat(0, 3)), 187 gfx::Vector2d offset(static_cast<int>(transform.matrix().getFloat(0, 3)),
176 static_cast<int>(transform.matrix().getFloat(1, 3))); 188 static_cast<int>(transform.matrix().getFloat(1, 3)));
177 return src_rect + offset; 189 return src_rect + offset;
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 #endif 941 #endif
930 } 942 }
931 943
932 ScopedSubnormalFloatDisabler::~ScopedSubnormalFloatDisabler() { 944 ScopedSubnormalFloatDisabler::~ScopedSubnormalFloatDisabler() {
933 #ifdef __SSE__ 945 #ifdef __SSE__
934 _mm_setcsr(orig_state_); 946 _mm_setcsr(orig_state_);
935 #endif 947 #endif
936 } 948 }
937 949
938 } // namespace cc 950 } // namespace cc
OLDNEW
« 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