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

Unified Diff: cc/layer_sorter_unittest.cc

Issue 11308153: Migrate most of cc/ from WebKit::WebTransformationMatrix to gfx::Transform (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased to tip of tree and addressed feedback Created 8 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 side-by-side diff with in-line comments
Download patch
Index: cc/layer_sorter_unittest.cc
diff --git a/cc/layer_sorter_unittest.cc b/cc/layer_sorter_unittest.cc
index 812bda50c7cce857a62bcf6cd32fd892e52c039e..7e1c5c4a3012a7d1a6fd9b6c50899dc07847b1ef 100644
--- a/cc/layer_sorter_unittest.cc
+++ b/cc/layer_sorter_unittest.cc
@@ -8,9 +8,9 @@
#include "cc/math_util.h"
#include "cc/single_thread_proxy.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include <public/WebTransformationMatrix.h>
+#include "ui/gfx/transform.h"
-using WebKit::WebTransformationMatrix;
+using gfx::Transform;
namespace cc {
namespace {
@@ -26,12 +26,12 @@ TEST(LayerSorterTest, BasicOverlap)
float weight = 0;
// Trivial test, with one layer directly obscuring the other.
- WebTransformationMatrix neg4Translate;
- neg4Translate.translate3d(0, 0, -4);
+ Transform neg4Translate;
+ neg4Translate.PreconcatTranslate3d(0, 0, -4);
LayerShape front(2, 2, neg4Translate);
- WebTransformationMatrix neg5Translate;
- neg5Translate.translate3d(0, 0, -5);
+ Transform neg5Translate;
+ neg5Translate.PreconcatTranslate3d(0, 0, -5);
LayerShape back(2, 2, neg5Translate);
overlapResult = LayerSorter::checkOverlap(&front, &back, zThreshold, weight);
@@ -43,8 +43,8 @@ TEST(LayerSorterTest, BasicOverlap)
EXPECT_EQ(1, weight);
// One layer translated off to the right. No overlap should be detected.
- WebTransformationMatrix rightTranslate;
- rightTranslate.translate3d(10, 0, -5);
+ Transform rightTranslate;
+ rightTranslate.PreconcatTranslate3d(10, 0, -5);
LayerShape backRight(2, 2, rightTranslate);
overlapResult = LayerSorter::checkOverlap(&front, &backRight, zThreshold, weight);
EXPECT_EQ(LayerSorter::None, overlapResult);
@@ -60,18 +60,18 @@ TEST(LayerSorterTest, RightAngleOverlap)
const float zThreshold = 0.1f;
float weight = 0;
- WebTransformationMatrix perspectiveMatrix;
- perspectiveMatrix.applyPerspective(1000);
+ Transform perspectiveMatrix;
+ perspectiveMatrix.PreconcatPerspectiveDepth(1000);
// Two layers forming a right angle with a perspective viewing transform.
- WebTransformationMatrix leftFaceMatrix;
- leftFaceMatrix.translate3d(-1, 0, -5);
- leftFaceMatrix.rotate3d(0, 1, 0, -90);
- leftFaceMatrix.translate(-1, -1);
+ Transform leftFaceMatrix;
+ leftFaceMatrix.PreconcatTranslate3d(-1, 0, -5);
+ MathUtil::rotateAxisAngle(&leftFaceMatrix, 0, 1, 0, -90);
+ leftFaceMatrix.PreconcatTranslate(-1, -1);
LayerShape leftFace(2, 2, perspectiveMatrix * leftFaceMatrix);
- WebTransformationMatrix frontFaceMatrix;
- frontFaceMatrix.translate3d(0, 0, -4);
- frontFaceMatrix.translate(-1, -1);
+ Transform frontFaceMatrix;
+ frontFaceMatrix.PreconcatTranslate3d(0, 0, -4);
+ frontFaceMatrix.PreconcatTranslate(-1, -1);
LayerShape frontFace(2, 2, perspectiveMatrix * frontFaceMatrix);
overlapResult = LayerSorter::checkOverlap(&frontFace, &leftFace, zThreshold, weight);
@@ -84,20 +84,20 @@ TEST(LayerSorterTest, IntersectingLayerOverlap)
const float zThreshold = 0.1f;
float weight = 0;
- WebTransformationMatrix perspectiveMatrix;
- perspectiveMatrix.applyPerspective(1000);
+ Transform perspectiveMatrix;
+ perspectiveMatrix.PreconcatPerspectiveDepth(1000);
// Intersecting layers. An explicit order will be returned based on relative z
// values at the overlapping features but the weight returned should be zero.
- WebTransformationMatrix frontFaceMatrix;
- frontFaceMatrix.translate3d(0, 0, -4);
- frontFaceMatrix.translate(-1, -1);
+ Transform frontFaceMatrix;
+ frontFaceMatrix.PreconcatTranslate3d(0, 0, -4);
+ frontFaceMatrix.PreconcatTranslate(-1, -1);
LayerShape frontFace(2, 2, perspectiveMatrix * frontFaceMatrix);
- WebTransformationMatrix throughMatrix;
- throughMatrix.translate3d(0, 0, -4);
- throughMatrix.rotate3d(0, 1, 0, 45);
- throughMatrix.translate(-1, -1);
+ Transform throughMatrix;
+ throughMatrix.PreconcatTranslate3d(0, 0, -4);
+ MathUtil::rotateAxisAngle(&throughMatrix, 0, 1, 0, 45);
+ throughMatrix.PreconcatTranslate(-1, -1);
LayerShape rotatedFace(2, 2, perspectiveMatrix * throughMatrix);
overlapResult = LayerSorter::checkOverlap(&frontFace, &rotatedFace, zThreshold, weight);
EXPECT_NE(LayerSorter::None, overlapResult);
@@ -122,19 +122,19 @@ TEST(LayerSorterTest, LayersAtAngleOverlap)
// C is in front of A and behind B (not what you'd expect by comparing centers).
// A and B don't overlap, so they're incomparable.
- WebTransformationMatrix transformA;
- transformA.translate3d(-6, 0, 1);
- transformA.translate(-4, -10);
+ Transform transformA;
+ transformA.PreconcatTranslate3d(-6, 0, 1);
+ transformA.PreconcatTranslate(-4, -10);
LayerShape layerA(8, 20, transformA);
- WebTransformationMatrix transformB;
- transformB.translate3d(6, 0, -1);
- transformB.translate(-4, -10);
+ Transform transformB;
+ transformB.PreconcatTranslate3d(6, 0, -1);
+ transformB.PreconcatTranslate(-4, -10);
LayerShape layerB(8, 20, transformB);
- WebTransformationMatrix transformC;
- transformC.rotate3d(0, 1, 0, 40);
- transformC.translate(-4, -10);
+ Transform transformC;
+ MathUtil::rotateAxisAngle(&transformC, 0, 1, 0, 40);
+ transformC.PreconcatTranslate(-4, -10);
LayerShape layerC(8, 20, transformC);
overlapResult = LayerSorter::checkOverlap(&layerA, &layerC, zThreshold, weight);
@@ -156,22 +156,22 @@ TEST(LayerSorterTest, LayersUnderPathologicalPerspectiveTransform)
// where w < 0. If the code uses the invalid value, it will think that a layer has
// different bounds than it really does, which can cause things to sort incorrectly.
- WebTransformationMatrix perspectiveMatrix;
- perspectiveMatrix.applyPerspective(1);
+ Transform perspectiveMatrix;
+ perspectiveMatrix.PreconcatPerspectiveDepth(1);
- WebTransformationMatrix transformA;
- transformA.translate3d(-15, 0, -2);
- transformA.translate(-5, -5);
+ Transform transformA;
+ transformA.PreconcatTranslate3d(-15, 0, -2);
+ transformA.PreconcatTranslate(-5, -5);
LayerShape layerA(10, 10, perspectiveMatrix * transformA);
// With this sequence of transforms, when layer B is correctly clipped, it will be
// visible on the left half of the projection plane, in front of layerA. When it is
// not clipped, its bounds will actually incorrectly appear much smaller and the
// correct sorting dependency will not be found.
- WebTransformationMatrix transformB;
- transformB.translate3d(0, 0, 0.7);
- transformB.rotate3d(0, 45, 0);
- transformB.translate(-5, -5);
+ Transform transformB;
+ transformB.PreconcatTranslate3d(0, 0, 0.7);
+ MathUtil::rotateEulerAngles(&transformB, 0, 45, 0);
+ transformB.PreconcatTranslate(-5, -5);
LayerShape layerB(10, 10, perspectiveMatrix * transformB);
// Sanity check that the test case actually covers the intended scenario, where part
@@ -205,10 +205,10 @@ TEST(LayerSorterTest, verifyExistingOrderingPreservedWhenNoZDiff)
scoped_ptr<LayerImpl> layer4 = LayerImpl::create(4);
scoped_ptr<LayerImpl> layer5 = LayerImpl::create(5);
- WebTransformationMatrix BehindMatrix;
- BehindMatrix.translate3d(0, 0, 2);
- WebTransformationMatrix FrontMatrix;
- FrontMatrix.translate3d(0, 0, 1);
+ Transform BehindMatrix;
+ BehindMatrix.PreconcatTranslate3d(0, 0, 2);
+ Transform FrontMatrix;
+ FrontMatrix.PreconcatTranslate3d(0, 0, 1);
layer1->setBounds(gfx::Size(10, 10));
layer1->setContentBounds(gfx::Size(10, 10));

Powered by Google App Engine
This is Rietveld 408576698