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

Side by Side Diff: third_party/WebKit/Source/platform/transforms/TransformOperationsTest.cpp

Issue 2482753002: Fix matrix3d transform under page zoom (Closed)
Patch Set: Add a comment for zoom Created 4 years, 1 month 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 toOps.blendedBoundsForBox(box, identityOperations, 0, 1, &bounds)); 501 toOps.blendedBoundsForBox(box, identityOperations, 0, 1, &bounds));
502 EXPECT_PRED_FORMAT2(FloatBoxTest::AssertAlmostEqual, 502 EXPECT_PRED_FORMAT2(FloatBoxTest::AssertAlmostEqual,
503 FloatBox(-33, -13, 3, 57, 19, 52), bounds); 503 FloatBox(-33, -13, 3, 57, 19, 52), bounds);
504 504
505 EXPECT_TRUE( 505 EXPECT_TRUE(
506 identityOperations.blendedBoundsForBox(box, fromOps, 0, 1, &bounds)); 506 identityOperations.blendedBoundsForBox(box, fromOps, 0, 1, &bounds));
507 EXPECT_PRED_FORMAT2(FloatBoxTest::AssertAlmostEqual, 507 EXPECT_PRED_FORMAT2(FloatBoxTest::AssertAlmostEqual,
508 FloatBox(-7, -3, 2, 15, 23, 20), bounds); 508 FloatBox(-7, -3, 2, 15, 23, 20), bounds);
509 } 509 }
510 510
511 TEST(TransformOperationsTest, ZoomTest) {
512 double zoomFactor = 1.25;
513
514 FloatPoint3D originalPoint(2, 3, 4);
515
516 TransformOperations ops;
517 ops.operations().append(TranslateTransformOperation::create(
518 Length(1, Fixed), Length(2, Fixed), 3, TransformOperation::Translate3D));
519 ops.operations().append(PerspectiveTransformOperation::create(1234));
520 ops.operations().append(
521 Matrix3DTransformOperation::create(TransformationMatrix(
522 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)));
523
524 // Apply unzoomed ops to unzoomed units, then zoom in
525 FloatPoint3D unzoomedPoint = originalPoint;
526 TransformOperations unzoomedOps = ops;
527 TransformationMatrix unzoomedMatrix;
528 ops.apply(FloatSize(0, 0), unzoomedMatrix);
529 FloatPoint3D result1 = unzoomedMatrix.mapPoint(unzoomedPoint);
530 result1.scale(zoomFactor, zoomFactor, zoomFactor);
531
532 // Apply zoomed ops to zoomed units
533 FloatPoint3D zoomedPoint = originalPoint;
534 zoomedPoint.scale(zoomFactor, zoomFactor, zoomFactor);
535 TransformOperations zoomedOps = ops.zoom(zoomFactor);
536 TransformationMatrix zoomedMatrix;
537 zoomedOps.apply(FloatSize(0, 0), zoomedMatrix);
538 FloatPoint3D result2 = zoomedMatrix.mapPoint(zoomedPoint);
539
540 EXPECT_EQ(result1, result2);
541 }
542
511 } // namespace blink 543 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698