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

Side by Side Diff: webkit/compositor_bindings/WebTransformationMatrixTest.cpp

Issue 11151032: Stop depending on wtf/MathExtras in WebTransformationMatrixTest.cpp (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
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 "config.h" 5 #include "config.h"
6 6
7 #include <public/WebTransformationMatrix.h> 7 #define _USE_MATH_DEFINES
8 #include <math.h>
8 9
9 #include "cc/test/geometry_test_utils.h" 10 #include "cc/test/geometry_test_utils.h"
10 #include <gtest/gtest.h> 11 #include "testing/gtest/include/gtest/gtest.h"
11 #include <wtf/MathExtras.h> 12 #include "third_party/WebKit/Source/Platform/chromium/public/WebTransformationMa trix.h"
12 13
13 #define EXPECT_ROW1_EQ(a, b, c, d, matrix) \ 14 #define EXPECT_ROW1_EQ(a, b, c, d, matrix) \
14 EXPECT_FLOAT_EQ((a), (matrix).m11()); \ 15 EXPECT_FLOAT_EQ((a), (matrix).m11()); \
15 EXPECT_FLOAT_EQ((b), (matrix).m21()); \ 16 EXPECT_FLOAT_EQ((b), (matrix).m21()); \
16 EXPECT_FLOAT_EQ((c), (matrix).m31()); \ 17 EXPECT_FLOAT_EQ((c), (matrix).m31()); \
17 EXPECT_FLOAT_EQ((d), (matrix).m41()); 18 EXPECT_FLOAT_EQ((d), (matrix).m41());
18 19
19 #define EXPECT_ROW2_EQ(a, b, c, d, matrix) \ 20 #define EXPECT_ROW2_EQ(a, b, c, d, matrix) \
20 EXPECT_FLOAT_EQ((a), (matrix).m12()); \ 21 EXPECT_FLOAT_EQ((a), (matrix).m12()); \
21 EXPECT_FLOAT_EQ((b), (matrix).m22()); \ 22 EXPECT_FLOAT_EQ((b), (matrix).m22()); \
(...skipping 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 WebTransformationMatrix from; 1148 WebTransformationMatrix from;
1148 from.rotate3d(1, 0, 0, 0); 1149 from.rotate3d(1, 0, 0, 0);
1149 1150
1150 WebTransformationMatrix to; 1151 WebTransformationMatrix to;
1151 1152
1152 to.makeIdentity(); 1153 to.makeIdentity();
1153 to.rotate3d(1, 0, 0, 90); 1154 to.rotate3d(1, 0, 0, 90);
1154 to.blend(from, 0); 1155 to.blend(from, 0);
1155 EXPECT_TRANSFORMATION_MATRIX_EQ(from, to); 1156 EXPECT_TRANSFORMATION_MATRIX_EQ(from, to);
1156 1157
1157 double expectedRotationAngle = 22.5 * piDouble / 180.0; 1158 double expectedRotationAngle = 22.5 * M_PI / 180.0;
1158 to.makeIdentity(); 1159 to.makeIdentity();
1159 to.rotate3d(1, 0, 0, 90); 1160 to.rotate3d(1, 0, 0, 90);
1160 to.blend(from, 0.25); 1161 to.blend(from, 0.25);
1161 EXPECT_ROW1_NEAR(1, 0, 0, 0, to, ERROR_THRESHOLD); 1162 EXPECT_ROW1_NEAR(1, 0, 0, 0, to, ERROR_THRESHOLD);
1162 EXPECT_ROW2_NEAR(0, cos(expectedRotationAngle), -sin(expectedRotationAngle), 0, to, ERROR_THRESHOLD); 1163 EXPECT_ROW2_NEAR(0, cos(expectedRotationAngle), -sin(expectedRotationAngle), 0, to, ERROR_THRESHOLD);
1163 EXPECT_ROW3_NEAR(0, sin(expectedRotationAngle), cos(expectedRotationAngle), 0, to, ERROR_THRESHOLD); 1164 EXPECT_ROW3_NEAR(0, sin(expectedRotationAngle), cos(expectedRotationAngle), 0, to, ERROR_THRESHOLD);
1164 EXPECT_ROW4_EQ(0, 0, 0, 1, to); 1165 EXPECT_ROW4_EQ(0, 0, 0, 1, to);
1165 1166
1166 expectedRotationAngle = 45 * piDouble / 180.0; 1167 expectedRotationAngle = 45 * M_PI / 180.0;
1167 to.makeIdentity(); 1168 to.makeIdentity();
1168 to.rotate3d(1, 0, 0, 90); 1169 to.rotate3d(1, 0, 0, 90);
1169 to.blend(from, 0.5); 1170 to.blend(from, 0.5);
1170 EXPECT_ROW1_NEAR(1, 0, 0, 0, to, ERROR_THRESHOLD); 1171 EXPECT_ROW1_NEAR(1, 0, 0, 0, to, ERROR_THRESHOLD);
1171 EXPECT_ROW2_NEAR(0, cos(expectedRotationAngle), -sin(expectedRotationAngle), 0, to, ERROR_THRESHOLD); 1172 EXPECT_ROW2_NEAR(0, cos(expectedRotationAngle), -sin(expectedRotationAngle), 0, to, ERROR_THRESHOLD);
1172 EXPECT_ROW3_NEAR(0, sin(expectedRotationAngle), cos(expectedRotationAngle), 0, to, ERROR_THRESHOLD); 1173 EXPECT_ROW3_NEAR(0, sin(expectedRotationAngle), cos(expectedRotationAngle), 0, to, ERROR_THRESHOLD);
1173 EXPECT_ROW4_EQ(0, 0, 0, 1, to); 1174 EXPECT_ROW4_EQ(0, 0, 0, 1, to);
1174 1175
1175 to.makeIdentity(); 1176 to.makeIdentity();
1176 to.rotate3d(1, 0, 0, 90); 1177 to.rotate3d(1, 0, 0, 90);
1177 to.blend(from, 1); 1178 to.blend(from, 1);
1178 EXPECT_ROW1_NEAR(1, 0, 0, 0, to, ERROR_THRESHOLD); 1179 EXPECT_ROW1_NEAR(1, 0, 0, 0, to, ERROR_THRESHOLD);
1179 EXPECT_ROW2_NEAR(0, 0, -1, 0, to, ERROR_THRESHOLD); 1180 EXPECT_ROW2_NEAR(0, 0, -1, 0, to, ERROR_THRESHOLD);
1180 EXPECT_ROW3_NEAR(0, 1, 0, 0, to, ERROR_THRESHOLD); 1181 EXPECT_ROW3_NEAR(0, 1, 0, 0, to, ERROR_THRESHOLD);
1181 EXPECT_ROW4_EQ(0, 0, 0, 1, to); 1182 EXPECT_ROW4_EQ(0, 0, 0, 1, to);
1182 } 1183 }
1183 1184
1184 TEST(WebTransformationMatrixTest, verifyBlendForRotationAboutY) 1185 TEST(WebTransformationMatrixTest, verifyBlendForRotationAboutY)
1185 { 1186 {
1186 WebTransformationMatrix from; 1187 WebTransformationMatrix from;
1187 from.rotate3d(0, 1, 0, 0); 1188 from.rotate3d(0, 1, 0, 0);
1188 1189
1189 WebTransformationMatrix to; 1190 WebTransformationMatrix to;
1190 1191
1191 to.makeIdentity(); 1192 to.makeIdentity();
1192 to.rotate3d(0, 1, 0, 90); 1193 to.rotate3d(0, 1, 0, 90);
1193 to.blend(from, 0); 1194 to.blend(from, 0);
1194 EXPECT_TRANSFORMATION_MATRIX_EQ(from, to); 1195 EXPECT_TRANSFORMATION_MATRIX_EQ(from, to);
1195 1196
1196 double expectedRotationAngle = 22.5 * piDouble / 180.0; 1197 double expectedRotationAngle = 22.5 * M_PI / 180.0;
1197 to.makeIdentity(); 1198 to.makeIdentity();
1198 to.rotate3d(0, 1, 0, 90); 1199 to.rotate3d(0, 1, 0, 90);
1199 to.blend(from, 0.25); 1200 to.blend(from, 0.25);
1200 EXPECT_ROW1_NEAR(cos(expectedRotationAngle), 0, sin(expectedRotationAngle), 0, to, ERROR_THRESHOLD); 1201 EXPECT_ROW1_NEAR(cos(expectedRotationAngle), 0, sin(expectedRotationAngle), 0, to, ERROR_THRESHOLD);
1201 EXPECT_ROW2_NEAR(0, 1, 0, 0, to, ERROR_THRESHOLD); 1202 EXPECT_ROW2_NEAR(0, 1, 0, 0, to, ERROR_THRESHOLD);
1202 EXPECT_ROW3_NEAR(-sin(expectedRotationAngle), 0, cos(expectedRotationAngle), 0, to, ERROR_THRESHOLD); 1203 EXPECT_ROW3_NEAR(-sin(expectedRotationAngle), 0, cos(expectedRotationAngle), 0, to, ERROR_THRESHOLD);
1203 EXPECT_ROW4_EQ(0, 0, 0, 1, to); 1204 EXPECT_ROW4_EQ(0, 0, 0, 1, to);
1204 1205
1205 expectedRotationAngle = 45 * piDouble / 180.0; 1206 expectedRotationAngle = 45 * M_PI / 180.0;
1206 to.makeIdentity(); 1207 to.makeIdentity();
1207 to.rotate3d(0, 1, 0, 90); 1208 to.rotate3d(0, 1, 0, 90);
1208 to.blend(from, 0.5); 1209 to.blend(from, 0.5);
1209 EXPECT_ROW1_NEAR(cos(expectedRotationAngle), 0, sin(expectedRotationAngle), 0, to, ERROR_THRESHOLD); 1210 EXPECT_ROW1_NEAR(cos(expectedRotationAngle), 0, sin(expectedRotationAngle), 0, to, ERROR_THRESHOLD);
1210 EXPECT_ROW2_NEAR(0, 1, 0, 0, to, ERROR_THRESHOLD); 1211 EXPECT_ROW2_NEAR(0, 1, 0, 0, to, ERROR_THRESHOLD);
1211 EXPECT_ROW3_NEAR(-sin(expectedRotationAngle), 0, cos(expectedRotationAngle), 0, to, ERROR_THRESHOLD); 1212 EXPECT_ROW3_NEAR(-sin(expectedRotationAngle), 0, cos(expectedRotationAngle), 0, to, ERROR_THRESHOLD);
1212 EXPECT_ROW4_EQ(0, 0, 0, 1, to); 1213 EXPECT_ROW4_EQ(0, 0, 0, 1, to);
1213 1214
1214 to.makeIdentity(); 1215 to.makeIdentity();
1215 to.rotate3d(0, 1, 0, 90); 1216 to.rotate3d(0, 1, 0, 90);
1216 to.blend(from, 1); 1217 to.blend(from, 1);
1217 EXPECT_ROW1_NEAR(0, 0, 1, 0, to, ERROR_THRESHOLD); 1218 EXPECT_ROW1_NEAR(0, 0, 1, 0, to, ERROR_THRESHOLD);
1218 EXPECT_ROW2_NEAR(0, 1, 0, 0, to, ERROR_THRESHOLD); 1219 EXPECT_ROW2_NEAR(0, 1, 0, 0, to, ERROR_THRESHOLD);
1219 EXPECT_ROW3_NEAR(-1, 0, 0, 0, to, ERROR_THRESHOLD); 1220 EXPECT_ROW3_NEAR(-1, 0, 0, 0, to, ERROR_THRESHOLD);
1220 EXPECT_ROW4_EQ(0, 0, 0, 1, to); 1221 EXPECT_ROW4_EQ(0, 0, 0, 1, to);
1221 } 1222 }
1222 1223
1223 TEST(WebTransformationMatrixTest, verifyBlendForRotationAboutZ) 1224 TEST(WebTransformationMatrixTest, verifyBlendForRotationAboutZ)
1224 { 1225 {
1225 WebTransformationMatrix from; 1226 WebTransformationMatrix from;
1226 from.rotate3d(0, 0, 1, 0); 1227 from.rotate3d(0, 0, 1, 0);
1227 1228
1228 WebTransformationMatrix to; 1229 WebTransformationMatrix to;
1229 1230
1230 to.makeIdentity(); 1231 to.makeIdentity();
1231 to.rotate3d(0, 0, 1, 90); 1232 to.rotate3d(0, 0, 1, 90);
1232 to.blend(from, 0); 1233 to.blend(from, 0);
1233 EXPECT_TRANSFORMATION_MATRIX_EQ(from, to); 1234 EXPECT_TRANSFORMATION_MATRIX_EQ(from, to);
1234 1235
1235 double expectedRotationAngle = 22.5 * piDouble / 180.0; 1236 double expectedRotationAngle = 22.5 * M_PI / 180.0;
1236 to.makeIdentity(); 1237 to.makeIdentity();
1237 to.rotate3d(0, 0, 1, 90); 1238 to.rotate3d(0, 0, 1, 90);
1238 to.blend(from, 0.25); 1239 to.blend(from, 0.25);
1239 EXPECT_ROW1_NEAR(cos(expectedRotationAngle), -sin(expectedRotationAngle), 0, 0, to, ERROR_THRESHOLD); 1240 EXPECT_ROW1_NEAR(cos(expectedRotationAngle), -sin(expectedRotationAngle), 0, 0, to, ERROR_THRESHOLD);
1240 EXPECT_ROW2_NEAR(sin(expectedRotationAngle), cos(expectedRotationAngle), 0, 0, to, ERROR_THRESHOLD); 1241 EXPECT_ROW2_NEAR(sin(expectedRotationAngle), cos(expectedRotationAngle), 0, 0, to, ERROR_THRESHOLD);
1241 EXPECT_ROW3_NEAR(0, 0, 1, 0, to, ERROR_THRESHOLD); 1242 EXPECT_ROW3_NEAR(0, 0, 1, 0, to, ERROR_THRESHOLD);
1242 EXPECT_ROW4_EQ(0, 0, 0, 1, to); 1243 EXPECT_ROW4_EQ(0, 0, 0, 1, to);
1243 1244
1244 expectedRotationAngle = 45 * piDouble / 180.0; 1245 expectedRotationAngle = 45 * M_PI / 180.0;
1245 to.makeIdentity(); 1246 to.makeIdentity();
1246 to.rotate3d(0, 0, 1, 90); 1247 to.rotate3d(0, 0, 1, 90);
1247 to.blend(from, 0.5); 1248 to.blend(from, 0.5);
1248 EXPECT_ROW1_NEAR(cos(expectedRotationAngle), -sin(expectedRotationAngle), 0, 0, to, ERROR_THRESHOLD); 1249 EXPECT_ROW1_NEAR(cos(expectedRotationAngle), -sin(expectedRotationAngle), 0, 0, to, ERROR_THRESHOLD);
1249 EXPECT_ROW2_NEAR(sin(expectedRotationAngle), cos(expectedRotationAngle), 0, 0, to, ERROR_THRESHOLD); 1250 EXPECT_ROW2_NEAR(sin(expectedRotationAngle), cos(expectedRotationAngle), 0, 0, to, ERROR_THRESHOLD);
1250 EXPECT_ROW3_NEAR(0, 0, 1, 0, to, ERROR_THRESHOLD); 1251 EXPECT_ROW3_NEAR(0, 0, 1, 0, to, ERROR_THRESHOLD);
1251 EXPECT_ROW4_EQ(0, 0, 0, 1, to); 1252 EXPECT_ROW4_EQ(0, 0, 0, 1, to);
1252 1253
1253 to.makeIdentity(); 1254 to.makeIdentity();
1254 to.rotate3d(0, 0, 1, 90); 1255 to.rotate3d(0, 0, 1, 90);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1296 normalizationMatrix.setM11(1 / expectedEndOfAnimation.m44()); 1297 normalizationMatrix.setM11(1 / expectedEndOfAnimation.m44());
1297 normalizationMatrix.setM22(1 / expectedEndOfAnimation.m44()); 1298 normalizationMatrix.setM22(1 / expectedEndOfAnimation.m44());
1298 normalizationMatrix.setM33(1 / expectedEndOfAnimation.m44()); 1299 normalizationMatrix.setM33(1 / expectedEndOfAnimation.m44());
1299 normalizationMatrix.setM44(1 / expectedEndOfAnimation.m44()); 1300 normalizationMatrix.setM44(1 / expectedEndOfAnimation.m44());
1300 normalizedExpectedEndOfAnimation.multiply(normalizationMatrix); 1301 normalizedExpectedEndOfAnimation.multiply(normalizationMatrix);
1301 1302
1302 EXPECT_TRANSFORMATION_MATRIX_EQ(normalizedExpectedEndOfAnimation, to); 1303 EXPECT_TRANSFORMATION_MATRIX_EQ(normalizedExpectedEndOfAnimation, to);
1303 } 1304 }
1304 1305
1305 } // namespace 1306 } // namespace
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698