OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/memory/scoped_vector.h" |
| 6 #include "cc/test/geometry_test_utils.h" |
| 7 #include "cc/transform_operations.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "third_party/WebKit/Source/Platform/chromium/public/WebTransformationMa
trix.h" |
| 10 |
| 11 using WebKit::WebTransformationMatrix; |
| 12 |
| 13 namespace cc { |
| 14 namespace { |
| 15 |
| 16 TEST(TransformOperationTest, TransformTypesAreUnique) { |
| 17 ScopedVector<TransformOperations> transforms; |
| 18 |
| 19 TransformOperations* to_add = new TransformOperations(); |
| 20 to_add->AppendTranslate(1, 0, 0); |
| 21 transforms.push_back(to_add); |
| 22 |
| 23 to_add = new TransformOperations(); |
| 24 to_add->AppendRotate(0, 0, 1, 2); |
| 25 transforms.push_back(to_add); |
| 26 |
| 27 to_add = new TransformOperations(); |
| 28 to_add->AppendScale(2, 2, 2); |
| 29 transforms.push_back(to_add); |
| 30 |
| 31 to_add = new TransformOperations(); |
| 32 to_add->AppendSkew(1, 0); |
| 33 transforms.push_back(to_add); |
| 34 |
| 35 to_add = new TransformOperations(); |
| 36 to_add->AppendPerspective(800); |
| 37 transforms.push_back(to_add); |
| 38 |
| 39 for (size_t i = 0; i < transforms.size(); ++i) { |
| 40 for (size_t j = 0; j < transforms.size(); ++j) { |
| 41 bool matches_type = transforms[i]->MatchesTypes(*transforms[j]); |
| 42 EXPECT_TRUE((i == j && matches_type) || !matches_type); |
| 43 } |
| 44 } |
| 45 } |
| 46 |
| 47 TEST(TransformOperationTest, MatchTypesSameLength) { |
| 48 TransformOperations translates; |
| 49 translates.AppendTranslate(1, 0, 0); |
| 50 translates.AppendTranslate(1, 0, 0); |
| 51 translates.AppendTranslate(1, 0, 0); |
| 52 |
| 53 TransformOperations skews; |
| 54 skews.AppendSkew(0, 2); |
| 55 skews.AppendSkew(0, 2); |
| 56 skews.AppendSkew(0, 2); |
| 57 |
| 58 TransformOperations translates2; |
| 59 translates2.AppendTranslate(0, 2, 0); |
| 60 translates2.AppendTranslate(0, 2, 0); |
| 61 translates2.AppendTranslate(0, 2, 0); |
| 62 |
| 63 TransformOperations translates3 = translates2; |
| 64 |
| 65 EXPECT_FALSE(translates.MatchesTypes(skews)); |
| 66 EXPECT_TRUE(translates.MatchesTypes(translates2)); |
| 67 EXPECT_TRUE(translates.MatchesTypes(translates3)); |
| 68 } |
| 69 |
| 70 TEST(TransformOperationTest, MatchTypesDifferentLength) { |
| 71 TransformOperations translates; |
| 72 translates.AppendTranslate(1, 0, 0); |
| 73 translates.AppendTranslate(1, 0, 0); |
| 74 translates.AppendTranslate(1, 0, 0); |
| 75 |
| 76 TransformOperations skews; |
| 77 skews.AppendSkew(2, 0); |
| 78 skews.AppendSkew(2, 0); |
| 79 |
| 80 TransformOperations translates2; |
| 81 translates2.AppendTranslate(0, 2, 0); |
| 82 translates2.AppendTranslate(0, 2, 0); |
| 83 |
| 84 EXPECT_FALSE(translates.MatchesTypes(skews)); |
| 85 EXPECT_FALSE(translates.MatchesTypes(translates2)); |
| 86 } |
| 87 |
| 88 void GetIdentityOperations(ScopedVector<TransformOperations>* operations) { |
| 89 TransformOperations* to_add = new TransformOperations(); |
| 90 operations->push_back(to_add); |
| 91 |
| 92 to_add = new TransformOperations(); |
| 93 to_add->AppendTranslate(0, 0, 0); |
| 94 operations->push_back(to_add); |
| 95 |
| 96 to_add = new TransformOperations(); |
| 97 to_add->AppendTranslate(0, 0, 0); |
| 98 to_add->AppendTranslate(0, 0, 0); |
| 99 operations->push_back(to_add); |
| 100 |
| 101 to_add = new TransformOperations(); |
| 102 to_add->AppendScale(1, 1, 1); |
| 103 operations->push_back(to_add); |
| 104 |
| 105 to_add = new TransformOperations(); |
| 106 to_add->AppendScale(1, 1, 1); |
| 107 to_add->AppendScale(1, 1, 1); |
| 108 operations->push_back(to_add); |
| 109 |
| 110 to_add = new TransformOperations(); |
| 111 to_add->AppendSkew(0, 0); |
| 112 operations->push_back(to_add); |
| 113 |
| 114 to_add = new TransformOperations(); |
| 115 to_add->AppendSkew(0, 0); |
| 116 to_add->AppendSkew(0, 0); |
| 117 operations->push_back(to_add); |
| 118 |
| 119 to_add = new TransformOperations(); |
| 120 to_add->AppendRotate(0, 0, 1, 0); |
| 121 operations->push_back(to_add); |
| 122 |
| 123 to_add = new TransformOperations(); |
| 124 to_add->AppendRotate(0, 0, 1, 0); |
| 125 to_add->AppendRotate(0, 0, 1, 0); |
| 126 operations->push_back(to_add); |
| 127 |
| 128 to_add = new TransformOperations(); |
| 129 to_add->AppendMatrix(WebTransformationMatrix()); |
| 130 operations->push_back(to_add); |
| 131 |
| 132 to_add = new TransformOperations(); |
| 133 to_add->AppendMatrix(WebTransformationMatrix()); |
| 134 to_add->AppendMatrix(WebTransformationMatrix()); |
| 135 operations->push_back(to_add); |
| 136 } |
| 137 |
| 138 TEST(TransformOperationTest, IdentityAlwaysMatches) { |
| 139 ScopedVector<TransformOperations> operations; |
| 140 GetIdentityOperations(&operations); |
| 141 |
| 142 for (size_t i = 0; i < operations.size(); ++i) { |
| 143 for (size_t j = 0; j < operations.size(); ++j) |
| 144 EXPECT_TRUE(operations[i]->MatchesTypes(*operations[j])); |
| 145 } |
| 146 } |
| 147 |
| 148 TEST(TransformOperationTest, ApplyTranslate) { |
| 149 double x = 1; |
| 150 double y = 2; |
| 151 double z = 3; |
| 152 TransformOperations operations; |
| 153 operations.AppendTranslate(x, y, z); |
| 154 WebTransformationMatrix expected; |
| 155 expected.translate3d(x, y, z); |
| 156 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, operations.Apply()); |
| 157 } |
| 158 |
| 159 TEST(TransformOperationTest, ApplyRotate) { |
| 160 double x = 1; |
| 161 double y = 2; |
| 162 double z = 3; |
| 163 double degrees = 80; |
| 164 TransformOperations operations; |
| 165 operations.AppendRotate(x, y, z, degrees); |
| 166 WebTransformationMatrix expected; |
| 167 expected.rotate3d(x, y, z, degrees); |
| 168 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, operations.Apply()); |
| 169 } |
| 170 |
| 171 TEST(TransformOperationTest, ApplyScale) { |
| 172 double x = 1; |
| 173 double y = 2; |
| 174 double z = 3; |
| 175 TransformOperations operations; |
| 176 operations.AppendScale(x, y, z); |
| 177 WebTransformationMatrix expected; |
| 178 expected.scale3d(x, y, z); |
| 179 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, operations.Apply()); |
| 180 } |
| 181 |
| 182 TEST(TransformOperationTest, ApplySkew) { |
| 183 double x = 1; |
| 184 double y = 2; |
| 185 TransformOperations operations; |
| 186 operations.AppendSkew(x, y); |
| 187 WebTransformationMatrix expected; |
| 188 expected.skewX(x); |
| 189 expected.skewY(y); |
| 190 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, operations.Apply()); |
| 191 } |
| 192 |
| 193 TEST(TransformOperationTest, ApplyPerspective) { |
| 194 double depth = 800; |
| 195 TransformOperations operations; |
| 196 operations.AppendPerspective(depth); |
| 197 WebTransformationMatrix expected; |
| 198 expected.applyPerspective(depth); |
| 199 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, operations.Apply()); |
| 200 } |
| 201 |
| 202 TEST(TransformOperationTest, ApplyMatrix) { |
| 203 double dx = 1; |
| 204 double dy = 2; |
| 205 double dz = 3; |
| 206 WebTransformationMatrix expected_matrix; |
| 207 expected_matrix.translate3d(dx, dy, dz); |
| 208 TransformOperations matrix_transform; |
| 209 matrix_transform.AppendMatrix(expected_matrix); |
| 210 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_matrix, matrix_transform.Apply()); |
| 211 } |
| 212 |
| 213 TEST(TransformOperationTest, ApplyOrder) { |
| 214 double sx = 2; |
| 215 double sy = 4; |
| 216 double sz = 8; |
| 217 |
| 218 double dx = 1; |
| 219 double dy = 2; |
| 220 double dz = 3; |
| 221 |
| 222 TransformOperations operations; |
| 223 operations.AppendScale(sx, sy, sz); |
| 224 operations.AppendTranslate(dx, dy, dz); |
| 225 |
| 226 WebTransformationMatrix expected_scale_matrix; |
| 227 expected_scale_matrix.scale3d(sx, sy, sz); |
| 228 |
| 229 WebTransformationMatrix expected_translate_matrix; |
| 230 expected_translate_matrix.translate3d(dx, dy, dz); |
| 231 |
| 232 WebTransformationMatrix expected_combined_matrix = expected_scale_matrix; |
| 233 expected_combined_matrix.multiply(expected_translate_matrix); |
| 234 |
| 235 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_combined_matrix, operations.Apply()); |
| 236 } |
| 237 |
| 238 TEST(TransformOperationTest, BlendOrder) { |
| 239 double sx1 = 2; |
| 240 double sy1 = 4; |
| 241 double sz1 = 8; |
| 242 |
| 243 double dx1 = 1; |
| 244 double dy1 = 2; |
| 245 double dz1 = 3; |
| 246 |
| 247 double sx2 = 4; |
| 248 double sy2 = 8; |
| 249 double sz2 = 16; |
| 250 |
| 251 double dx2 = 10; |
| 252 double dy2 = 20; |
| 253 double dz2 = 30; |
| 254 |
| 255 TransformOperations operations_from; |
| 256 operations_from.AppendScale(sx1, sy1, sz1); |
| 257 operations_from.AppendTranslate(dx1, dy1, dz1); |
| 258 |
| 259 TransformOperations operations_to; |
| 260 operations_to.AppendScale(sx2, sy2, sz2); |
| 261 operations_to.AppendTranslate(dx2, dy2, dz2); |
| 262 |
| 263 WebTransformationMatrix scale_from; |
| 264 scale_from.scale3d(sx1, sy1, sz1); |
| 265 WebTransformationMatrix translate_from; |
| 266 translate_from.translate3d(dx1, dy1, dz1); |
| 267 |
| 268 WebTransformationMatrix scale_to; |
| 269 scale_to.scale3d(sx2, sy2, sz2); |
| 270 WebTransformationMatrix translate_to; |
| 271 translate_to.translate3d(dx2, dy2, dz2); |
| 272 |
| 273 double progress = 0.25; |
| 274 |
| 275 WebTransformationMatrix blended_scale = scale_to; |
| 276 blended_scale.blend(scale_from, progress); |
| 277 |
| 278 WebTransformationMatrix blended_translate = translate_to; |
| 279 blended_translate.blend(translate_from, progress); |
| 280 |
| 281 WebTransformationMatrix expected = blended_scale; |
| 282 expected.multiply(blended_translate); |
| 283 |
| 284 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 285 expected, operations_to.Blend(operations_from, progress)); |
| 286 } |
| 287 |
| 288 static void CheckProgress(double progress, |
| 289 const WebTransformationMatrix& from_matrix, |
| 290 const WebTransformationMatrix& to_matrix, |
| 291 const TransformOperations& from_transform, |
| 292 const TransformOperations& to_transform) { |
| 293 WebTransformationMatrix expected_matrix = to_matrix; |
| 294 expected_matrix.blend(from_matrix, progress); |
| 295 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 296 expected_matrix, to_transform.Blend(from_transform, progress)); |
| 297 } |
| 298 |
| 299 TEST(TransformOperationTest, BlendProgress) { |
| 300 double sx = 2; |
| 301 double sy = 4; |
| 302 double sz = 8; |
| 303 TransformOperations operations_from; |
| 304 operations_from.AppendScale(sx, sy, sz); |
| 305 |
| 306 WebTransformationMatrix matrix_from; |
| 307 matrix_from.scale3d(sx, sy, sz); |
| 308 |
| 309 sx = 4; |
| 310 sy = 8; |
| 311 sz = 16; |
| 312 TransformOperations operations_to; |
| 313 operations_to.AppendScale(sx, sy, sz); |
| 314 |
| 315 WebTransformationMatrix matrix_to; |
| 316 matrix_to.scale3d(sx, sy, sz); |
| 317 |
| 318 CheckProgress(-1, matrix_from, matrix_to, operations_from, operations_to); |
| 319 CheckProgress(0, matrix_from, matrix_to, operations_from, operations_to); |
| 320 CheckProgress(0.25, matrix_from, matrix_to, operations_from, operations_to); |
| 321 CheckProgress(0.5, matrix_from, matrix_to, operations_from, operations_to); |
| 322 CheckProgress(1, matrix_from, matrix_to, operations_from, operations_to); |
| 323 CheckProgress(2, matrix_from, matrix_to, operations_from, operations_to); |
| 324 } |
| 325 |
| 326 TEST(TransformOperationTest, BlendWhenTypesDoNotMatch) { |
| 327 double sx1 = 2; |
| 328 double sy1 = 4; |
| 329 double sz1 = 8; |
| 330 |
| 331 double dx1 = 1; |
| 332 double dy1 = 2; |
| 333 double dz1 = 3; |
| 334 |
| 335 double sx2 = 4; |
| 336 double sy2 = 8; |
| 337 double sz2 = 16; |
| 338 |
| 339 double dx2 = 10; |
| 340 double dy2 = 20; |
| 341 double dz2 = 30; |
| 342 |
| 343 TransformOperations operations_from; |
| 344 operations_from.AppendScale(sx1, sy1, sz1); |
| 345 operations_from.AppendTranslate(dx1, dy1, dz1); |
| 346 |
| 347 TransformOperations operations_to; |
| 348 operations_to.AppendTranslate(dx2, dy2, dz2); |
| 349 operations_to.AppendScale(sx2, sy2, sz2); |
| 350 |
| 351 WebTransformationMatrix from; |
| 352 from.scale3d(sx1, sy1, sz1); |
| 353 from.translate3d(dx1, dy1, dz1); |
| 354 |
| 355 WebTransformationMatrix to; |
| 356 to.translate3d(dx2, dy2, dz2); |
| 357 to.scale3d(sx2, sy2, sz2); |
| 358 |
| 359 double progress = 0.25; |
| 360 |
| 361 WebTransformationMatrix expected = to; |
| 362 expected.blend(from, progress); |
| 363 |
| 364 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 365 expected, operations_to.Blend(operations_from, progress)); |
| 366 } |
| 367 |
| 368 TEST(TransformOperationTest, LargeRotationsWithSameAxis) { |
| 369 TransformOperations operations_from; |
| 370 operations_from.AppendRotate(0, 0, 1, 0); |
| 371 |
| 372 TransformOperations operations_to; |
| 373 operations_to.AppendRotate(0, 0, 2, 360); |
| 374 |
| 375 double progress = 0.5; |
| 376 |
| 377 WebTransformationMatrix expected; |
| 378 expected.rotate3d(0, 0, 1, 180); |
| 379 |
| 380 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 381 expected, operations_to.Blend(operations_from, progress)); |
| 382 } |
| 383 |
| 384 TEST(TransformOperationTest, LargeRotationsWithSameAxisInDifferentDirection) { |
| 385 TransformOperations operations_from; |
| 386 operations_from.AppendRotate(0, 0, 1, 180); |
| 387 |
| 388 TransformOperations operations_to; |
| 389 operations_to.AppendRotate(0, 0, -1, 180); |
| 390 |
| 391 double progress = 0.5; |
| 392 |
| 393 WebTransformationMatrix expected; |
| 394 |
| 395 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 396 expected, operations_to.Blend(operations_from, progress)); |
| 397 } |
| 398 |
| 399 TEST(TransformOperationTest, LargeRotationsWithDifferentAxes) { |
| 400 TransformOperations operations_from; |
| 401 operations_from.AppendRotate(0, 0, 1, 180); |
| 402 |
| 403 TransformOperations operations_to; |
| 404 operations_to.AppendRotate(0, 1, 0, 180); |
| 405 |
| 406 double progress = 0.5; |
| 407 WebTransformationMatrix matrix_from; |
| 408 matrix_from.rotate3d(0, 0, 1, 180); |
| 409 |
| 410 WebTransformationMatrix matrix_to; |
| 411 matrix_to.rotate3d(0, 1, 0, 180); |
| 412 |
| 413 WebTransformationMatrix expected = matrix_to; |
| 414 expected.blend(matrix_from, progress); |
| 415 |
| 416 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 417 expected, operations_to.Blend(operations_from, progress)); |
| 418 } |
| 419 |
| 420 TEST(TransformOperationTest, BlendRotationFromIdentity) { |
| 421 ScopedVector<TransformOperations> identity_operations; |
| 422 GetIdentityOperations(&identity_operations); |
| 423 |
| 424 for (size_t i = 0; i < identity_operations.size(); ++i) { |
| 425 TransformOperations operations; |
| 426 operations.AppendRotate(0, 0, 1, 360); |
| 427 |
| 428 double progress = 0.5; |
| 429 |
| 430 WebTransformationMatrix expected; |
| 431 expected.rotate3d(0, 0, 1, 180); |
| 432 |
| 433 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 434 expected, operations.Blend(*identity_operations[i], progress)); |
| 435 } |
| 436 } |
| 437 |
| 438 TEST(TransformOperationTest, BlendTranslationFromIdentity) { |
| 439 ScopedVector<TransformOperations> identity_operations; |
| 440 GetIdentityOperations(&identity_operations); |
| 441 |
| 442 for (size_t i = 0; i < identity_operations.size(); ++i) { |
| 443 TransformOperations operations; |
| 444 operations.AppendTranslate(2, 2, 2); |
| 445 |
| 446 double progress = 0.5; |
| 447 |
| 448 WebTransformationMatrix expected; |
| 449 expected.translate3d(1, 1, 1); |
| 450 |
| 451 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 452 expected, operations.Blend(*identity_operations[i], progress)); |
| 453 } |
| 454 } |
| 455 |
| 456 TEST(TransformOperationTest, BlendScaleFromIdentity) { |
| 457 ScopedVector<TransformOperations> identity_operations; |
| 458 GetIdentityOperations(&identity_operations); |
| 459 |
| 460 for (size_t i = 0; i < identity_operations.size(); ++i) { |
| 461 TransformOperations operations; |
| 462 operations.AppendScale(3, 3, 3); |
| 463 |
| 464 double progress = 0.5; |
| 465 |
| 466 WebTransformationMatrix expected; |
| 467 expected.scale3d(2, 2, 2); |
| 468 |
| 469 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 470 expected, operations.Blend(*identity_operations[i], progress)); |
| 471 } |
| 472 } |
| 473 |
| 474 TEST(TransformOperationTest, BlendSkewFromIdentity) { |
| 475 ScopedVector<TransformOperations> identity_operations; |
| 476 GetIdentityOperations(&identity_operations); |
| 477 |
| 478 for (size_t i = 0; i < identity_operations.size(); ++i) { |
| 479 TransformOperations operations; |
| 480 operations.AppendSkew(2, 2); |
| 481 |
| 482 double progress = 0.5; |
| 483 |
| 484 WebTransformationMatrix expected; |
| 485 expected.skewX(1); |
| 486 expected.skewY(1); |
| 487 |
| 488 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 489 expected, operations.Blend(*identity_operations[i], progress)); |
| 490 } |
| 491 } |
| 492 |
| 493 TEST(TransformOperationTest, BlendPerspectiveFromIdentity) { |
| 494 ScopedVector<TransformOperations> identity_operations; |
| 495 GetIdentityOperations(&identity_operations); |
| 496 |
| 497 for (size_t i = 0; i < identity_operations.size(); ++i) { |
| 498 TransformOperations operations; |
| 499 operations.AppendPerspective(1000); |
| 500 |
| 501 double progress = 0.5; |
| 502 |
| 503 WebTransformationMatrix expected; |
| 504 expected.applyPerspective(500 + 0.5 * std::numeric_limits<double>::max()); |
| 505 |
| 506 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 507 expected, operations.Blend(*identity_operations[i], progress)); |
| 508 } |
| 509 } |
| 510 |
| 511 TEST(TransformOperationTest, BlendRotationToIdentity) { |
| 512 ScopedVector<TransformOperations> identity_operations; |
| 513 GetIdentityOperations(&identity_operations); |
| 514 |
| 515 for (size_t i = 0; i < identity_operations.size(); ++i) { |
| 516 TransformOperations operations; |
| 517 operations.AppendRotate(0, 0, 1, 360); |
| 518 |
| 519 double progress = 0.5; |
| 520 |
| 521 WebTransformationMatrix expected; |
| 522 expected.rotate3d(0, 0, 1, 180); |
| 523 |
| 524 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 525 expected, identity_operations[i]->Blend(operations, progress)); |
| 526 } |
| 527 } |
| 528 |
| 529 TEST(TransformOperationTest, BlendTranslationToIdentity) { |
| 530 ScopedVector<TransformOperations> identity_operations; |
| 531 GetIdentityOperations(&identity_operations); |
| 532 |
| 533 for (size_t i = 0; i < identity_operations.size(); ++i) { |
| 534 TransformOperations operations; |
| 535 operations.AppendTranslate(2, 2, 2); |
| 536 |
| 537 double progress = 0.5; |
| 538 |
| 539 WebTransformationMatrix expected; |
| 540 expected.translate3d(1, 1, 1); |
| 541 |
| 542 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 543 expected, identity_operations[i]->Blend(operations, progress)); |
| 544 } |
| 545 } |
| 546 |
| 547 TEST(TransformOperationTest, BlendScaleToIdentity) { |
| 548 ScopedVector<TransformOperations> identity_operations; |
| 549 GetIdentityOperations(&identity_operations); |
| 550 |
| 551 for (size_t i = 0; i < identity_operations.size(); ++i) { |
| 552 TransformOperations operations; |
| 553 operations.AppendScale(3, 3, 3); |
| 554 |
| 555 double progress = 0.5; |
| 556 |
| 557 WebTransformationMatrix expected; |
| 558 expected.scale3d(2, 2, 2); |
| 559 |
| 560 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 561 expected, identity_operations[i]->Blend(operations, progress)); |
| 562 } |
| 563 } |
| 564 |
| 565 TEST(TransformOperationTest, BlendSkewToIdentity) { |
| 566 ScopedVector<TransformOperations> identity_operations; |
| 567 GetIdentityOperations(&identity_operations); |
| 568 |
| 569 for (size_t i = 0; i < identity_operations.size(); ++i) { |
| 570 TransformOperations operations; |
| 571 operations.AppendSkew(2, 2); |
| 572 |
| 573 double progress = 0.5; |
| 574 |
| 575 WebTransformationMatrix expected; |
| 576 expected.skewX(1); |
| 577 expected.skewY(1); |
| 578 |
| 579 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 580 expected, identity_operations[i]->Blend(operations, progress)); |
| 581 } |
| 582 } |
| 583 |
| 584 TEST(TransformOperationTest, BlendPerspectiveToIdentity) { |
| 585 ScopedVector<TransformOperations> identity_operations; |
| 586 GetIdentityOperations(&identity_operations); |
| 587 |
| 588 for (size_t i = 0; i < identity_operations.size(); ++i) { |
| 589 TransformOperations operations; |
| 590 operations.AppendPerspective(1000); |
| 591 |
| 592 double progress = 0.5; |
| 593 |
| 594 WebTransformationMatrix expected; |
| 595 expected.applyPerspective(500 + 0.5 * std::numeric_limits<double>::max()); |
| 596 |
| 597 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 598 expected, identity_operations[i]->Blend(operations, progress)); |
| 599 } |
| 600 } |
| 601 |
| 602 } // namespace |
| 603 } // namespace cc |
OLD | NEW |