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

Unified Diff: cc/base/math_util_unittest.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
« cc/base/math_util.cc ('K') | « cc/base/math_util.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/base/math_util_unittest.cc
diff --git a/cc/base/math_util_unittest.cc b/cc/base/math_util_unittest.cc
index 446bdf55438abf767ec8a12cc6b11a8e444e8f9a..a4e58b08f13f8a014d492dee72ab923d14625cb6 100644
--- a/cc/base/math_util_unittest.cc
+++ b/cc/base/math_util_unittest.cc
@@ -11,6 +11,7 @@
#include "cc/test/geometry_test_utils.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/gfx/geometry/quad_f.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/rect_f.h"
#include "ui/gfx/transform.h"
@@ -455,5 +456,32 @@ TEST(MathUtilTest, RoundDownUnderflow) {
EXPECT_TRUE(MathUtil::VerifyRoundDown<int16_t>(-123, 50));
}
+TEST(MathUtilTest, MapClippedQuadDuplicate) {
+ gfx::Transform transform;
+ transform.MakeIdentity();
+ transform.ApplyPerspectiveDepth(50.0);
+ transform.RotateAboutYAxis(89.0);
+
+ gfx::QuadF src_quad(gfx::PointF(0.0f, 100.0f), gfx::PointF(0.0f, -100.0f),
flackr 2016/12/08 20:24:01 It might be worth explicitly pointing out the two
Peter Mayo 2016/12/08 20:29:09 Actually a comment about the whole scenario may be
+ gfx::PointF(-99.0f, -300.0f),
+ gfx::PointF(-99.0f, -100.0f));
+
+ gfx::PointF clipped_quad[8];
+ int num_vertices_in_clipped_quad;
+
+ MathUtil::MapClippedQuad(transform, src_quad, clipped_quad,
+ &num_vertices_in_clipped_quad);
+
+ printf("transformed quad is [");
+ for (int i = 0; i < num_vertices_in_clipped_quad; i++) {
+ if (i > 0)
+ printf(", ");
+ printf("(%.5f, %.5f)", clipped_quad[i].x(), clipped_quad[i].y());
+ }
+ printf("]\n");
flackr 2016/12/08 20:24:01 debugging code?
Peter Mayo 2016/12/08 20:29:09 Yup, hence 'First ... Definitely more to come, an
+
+ EXPECT_EQ(num_vertices_in_clipped_quad, 3);
+}
+
} // namespace
} // namespace cc
« cc/base/math_util.cc ('K') | « cc/base/math_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698