summaryrefslogtreecommitdiff
path: root/Source/WebKit/chromium/tests
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit/chromium/tests')
-rw-r--r--Source/WebKit/chromium/tests/CCAnimationTestCommon.cpp4
-rw-r--r--Source/WebKit/chromium/tests/CCAnimationTestCommon.h9
-rw-r--r--Source/WebKit/chromium/tests/CCDamageTrackerTest.cpp12
-rw-r--r--Source/WebKit/chromium/tests/CCKeyframedAnimationCurveTest.cpp14
-rw-r--r--Source/WebKit/chromium/tests/CCLayerAnimationControllerTest.cpp8
-rw-r--r--Source/WebKit/chromium/tests/CCLayerImplTest.cpp2
-rw-r--r--Source/WebKit/chromium/tests/CCLayerIteratorTest.cpp8
-rw-r--r--Source/WebKit/chromium/tests/CCLayerSorterTest.cpp42
-rw-r--r--Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp147
-rw-r--r--Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp239
-rw-r--r--Source/WebKit/chromium/tests/CCLayerTreeTestCommon.h2
-rw-r--r--Source/WebKit/chromium/tests/CCMathUtilTest.cpp46
-rw-r--r--Source/WebKit/chromium/tests/CCOcclusionTrackerTest.cpp621
-rw-r--r--Source/WebKit/chromium/tests/CCQuadCullerTest.cpp58
-rw-r--r--Source/WebKit/chromium/tests/CCRenderSurfaceTest.cpp11
-rw-r--r--Source/WebKit/chromium/tests/DecimalTest.cpp971
-rw-r--r--Source/WebKit/chromium/tests/FloatQuadTest.cpp18
-rw-r--r--Source/WebKit/chromium/tests/LayerChromiumTest.cpp10
-rw-r--r--Source/WebKit/chromium/tests/LayerRendererChromiumTest.cpp41
-rw-r--r--Source/WebKit/chromium/tests/LinkHighlightTest.cpp12
-rw-r--r--Source/WebKit/chromium/tests/PopupMenuTest.cpp42
-rw-r--r--Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp26
-rw-r--r--Source/WebKit/chromium/tests/WebFrameTest.cpp81
-rw-r--r--Source/WebKit/chromium/tests/WebInputEventFactoryTestGtk.cpp28
-rw-r--r--Source/WebKit/chromium/tests/WebTransformOperationsTest.cpp341
-rw-r--r--Source/WebKit/chromium/tests/WebTransformationMatrixTest.cpp41
26 files changed, 2263 insertions, 571 deletions
diff --git a/Source/WebKit/chromium/tests/CCAnimationTestCommon.cpp b/Source/WebKit/chromium/tests/CCAnimationTestCommon.cpp
index 36f79818e..0e8c1a401 100644
--- a/Source/WebKit/chromium/tests/CCAnimationTestCommon.cpp
+++ b/Source/WebKit/chromium/tests/CCAnimationTestCommon.cpp
@@ -99,9 +99,9 @@ FakeTransformTransition::~FakeTransformTransition()
{
}
-WebCore::TransformationMatrix FakeTransformTransition::getValue(double time, const WebCore::IntSize& size) const
+WebKit::WebTransformationMatrix FakeTransformTransition::getValue(double time, const WebCore::IntSize& size) const
{
- return WebCore::TransformationMatrix();
+ return WebKit::WebTransformationMatrix();
}
PassOwnPtr<WebCore::CCAnimationCurve> FakeTransformTransition::clone() const
diff --git a/Source/WebKit/chromium/tests/CCAnimationTestCommon.h b/Source/WebKit/chromium/tests/CCAnimationTestCommon.h
index 776b75c8d..4384117d3 100644
--- a/Source/WebKit/chromium/tests/CCAnimationTestCommon.h
+++ b/Source/WebKit/chromium/tests/CCAnimationTestCommon.h
@@ -25,6 +25,7 @@
#ifndef CCAnimationTestCommon_h
#define CCAnimationTestCommon_h
+#include "IntSize.h"
#include "cc/CCAnimationCurve.h"
#include "cc/CCLayerAnimationController.h"
@@ -53,7 +54,7 @@ public:
virtual ~FakeTransformTransition();
virtual double duration() const OVERRIDE { return m_duration; }
- virtual WebCore::TransformationMatrix getValue(double time, const WebCore::IntSize&) const OVERRIDE;
+ virtual WebKit::WebTransformationMatrix getValue(double time, const WebCore::IntSize&) const OVERRIDE;
virtual PassOwnPtr<WebCore::CCAnimationCurve> clone() const OVERRIDE;
@@ -86,13 +87,13 @@ public:
virtual int id() const OVERRIDE { return 0; }
virtual void setOpacityFromAnimation(float opacity) OVERRIDE { m_opacity = opacity; }
virtual float opacity() const OVERRIDE { return m_opacity; }
- virtual void setTransformFromAnimation(const WebCore::TransformationMatrix& transform) OVERRIDE { m_transform = transform; }
- virtual const WebCore::TransformationMatrix& transform() const OVERRIDE { return m_transform; }
+ virtual void setTransformFromAnimation(const WebKit::WebTransformationMatrix& transform) OVERRIDE { m_transform = transform; }
+ virtual const WebKit::WebTransformationMatrix& transform() const OVERRIDE { return m_transform; }
virtual const WebCore::IntSize& bounds() const OVERRIDE { return m_bounds; }
private:
float m_opacity;
- WebCore::TransformationMatrix m_transform;
+ WebKit::WebTransformationMatrix m_transform;
WebCore::IntSize m_bounds;
};
diff --git a/Source/WebKit/chromium/tests/CCDamageTrackerTest.cpp b/Source/WebKit/chromium/tests/CCDamageTrackerTest.cpp
index bbea971dd..56d85fafa 100644
--- a/Source/WebKit/chromium/tests/CCDamageTrackerTest.cpp
+++ b/Source/WebKit/chromium/tests/CCDamageTrackerTest.cpp
@@ -46,7 +46,7 @@ namespace {
void executeCalculateDrawTransformsAndVisibility(CCLayerImpl* root, Vector<CCLayerImpl*>& renderSurfaceLayerList)
{
CCLayerSorter layerSorter;
- TransformationMatrix identityMatrix;
+ WebTransformationMatrix identityMatrix;
Vector<CCLayerImpl*> dummyLayerList;
int dummyMaxTextureSize = 512;
@@ -291,7 +291,7 @@ TEST_F(CCDamageTrackerTest, verifyDamageForTransformedLayer)
OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface();
CCLayerImpl* child = root->children()[0].get();
- TransformationMatrix rotation;
+ WebTransformationMatrix rotation;
rotation.rotate(45);
// Note carefully, the anchor is actually part of layer->position(). By setting anchor
@@ -332,7 +332,7 @@ TEST_F(CCDamageTrackerTest, verifyDamageForPerspectiveClippedLayer)
OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface();
CCLayerImpl* child = root->children()[0].get();
- TransformationMatrix transform;
+ WebTransformationMatrix transform;
transform.applyPerspective(1);
transform.translate3d(-150, -50, 0);
transform.rotate3d(0, 45, 0);
@@ -789,7 +789,7 @@ TEST_F(CCDamageTrackerTest, verifyDamageForReplica)
OwnPtr<CCLayerImpl> grandChild1Replica = CCLayerImpl::create(7);
grandChild1Replica->setPosition(FloatPoint::zero());
grandChild1Replica->setAnchorPoint(FloatPoint::zero());
- TransformationMatrix reflection;
+ WebTransformationMatrix reflection;
reflection.scale3d(-1.0, 1.0, 1.0);
grandChild1Replica->setTransform(reflection);
grandChild1->setReplicaLayer(grandChild1Replica.release());
@@ -928,7 +928,7 @@ TEST_F(CCDamageTrackerTest, verifyDamageForReplicaMask)
OwnPtr<CCLayerImpl> grandChild1Replica = CCLayerImpl::create(6);
grandChild1Replica->setPosition(FloatPoint::zero());
grandChild1Replica->setAnchorPoint(FloatPoint::zero());
- TransformationMatrix reflection;
+ WebTransformationMatrix reflection;
reflection.scale3d(-1.0, 1.0, 1.0);
grandChild1Replica->setTransform(reflection);
grandChild1->setReplicaLayer(grandChild1Replica.release());
@@ -988,7 +988,7 @@ TEST_F(CCDamageTrackerTest, verifyDamageForReplicaMaskWithAnchor)
OwnPtr<CCLayerImpl> grandChild1Replica = CCLayerImpl::create(6);
grandChild1Replica->setPosition(FloatPoint::zero());
grandChild1Replica->setAnchorPoint(FloatPoint::zero()); // note, this is not the anchor being tested.
- TransformationMatrix reflection;
+ WebTransformationMatrix reflection;
reflection.scale3d(-1.0, 1.0, 1.0);
grandChild1Replica->setTransform(reflection);
grandChild1->setReplicaLayer(grandChild1Replica.release());
diff --git a/Source/WebKit/chromium/tests/CCKeyframedAnimationCurveTest.cpp b/Source/WebKit/chromium/tests/CCKeyframedAnimationCurveTest.cpp
index 15b554a06..ad1ae74ca 100644
--- a/Source/WebKit/chromium/tests/CCKeyframedAnimationCurveTest.cpp
+++ b/Source/WebKit/chromium/tests/CCKeyframedAnimationCurveTest.cpp
@@ -31,18 +31,18 @@
#include <gmock/gmock.h>
#include <gtest/gtest.h>
+#include <public/WebTransformationMatrix.h>
#include <wtf/OwnPtr.h>
#include <wtf/Vector.h>
using namespace WebCore;
+using WebKit::WebTransformationMatrix;
namespace {
-void expectTranslateX(double translateX, const TransformationMatrix& matrix)
+void expectTranslateX(double translateX, const WebTransformationMatrix& matrix)
{
- TransformationMatrix::DecomposedType decomposedType;
- matrix.decompose(decomposedType);
- EXPECT_FLOAT_EQ(translateX, decomposedType.translateX);
+ EXPECT_FLOAT_EQ(translateX, matrix.m41());
}
// Tests that a float animation with one keyframe works as expected.
@@ -191,10 +191,8 @@ TEST(CCKeyframedAnimationCurveTest, RepeatedTransformKeyTimes)
expectTranslateX(4, curve->getValue(0.5, layerSize));
// There is a discontinuity at 1. Any value between 4 and 6 is valid.
- TransformationMatrix value = curve->getValue(1, layerSize);
- TransformationMatrix::DecomposedType decomposedType;
- value.decompose(decomposedType);
- EXPECT_TRUE(decomposedType.translateX >= 4 && decomposedType.translateX <= 6);
+ WebTransformationMatrix value = curve->getValue(1, layerSize);
+ EXPECT_TRUE(value.m41() >= 4 && value.m41() <= 6);
expectTranslateX(6, curve->getValue(1.5, layerSize));
expectTranslateX(6, curve->getValue(2, layerSize));
diff --git a/Source/WebKit/chromium/tests/CCLayerAnimationControllerTest.cpp b/Source/WebKit/chromium/tests/CCLayerAnimationControllerTest.cpp
index 827194bbc..dbed02c74 100644
--- a/Source/WebKit/chromium/tests/CCLayerAnimationControllerTest.cpp
+++ b/Source/WebKit/chromium/tests/CCLayerAnimationControllerTest.cpp
@@ -35,18 +35,18 @@
#include <gmock/gmock.h>
#include <gtest/gtest.h>
+#include <public/WebTransformationMatrix.h>
#include <wtf/Vector.h>
using namespace WebCore;
using namespace WebKitTests;
+using WebKit::WebTransformationMatrix;
namespace {
-void expectTranslateX(double translateX, const TransformationMatrix& matrix)
+void expectTranslateX(double translateX, const WebTransformationMatrix& matrix)
{
- TransformationMatrix::DecomposedType decomposedType;
- matrix.decompose(decomposedType);
- EXPECT_FLOAT_EQ(translateX, decomposedType.translateX);
+ EXPECT_FLOAT_EQ(translateX, matrix.m41());
}
PassOwnPtr<CCActiveAnimation> createActiveAnimation(PassOwnPtr<CCAnimationCurve> curve, int id, CCActiveAnimation::TargetProperty property)
diff --git a/Source/WebKit/chromium/tests/CCLayerImplTest.cpp b/Source/WebKit/chromium/tests/CCLayerImplTest.cpp
index f5259e1cf..827c9adaa 100644
--- a/Source/WebKit/chromium/tests/CCLayerImplTest.cpp
+++ b/Source/WebKit/chromium/tests/CCLayerImplTest.cpp
@@ -86,7 +86,7 @@ TEST(CCLayerImplTest, verifyLayerChangesAreTrackedProperly)
IntRect arbitraryIntRect = IntRect(arbitraryIntPoint, arbitraryIntSize);
FloatRect arbitraryFloatRect = FloatRect(arbitraryFloatPoint, FloatSize(1.234f, 5.678f));
Color arbitraryColor = Color(10, 20, 30);
- TransformationMatrix arbitraryTransform;
+ WebTransformationMatrix arbitraryTransform;
arbitraryTransform.scale3d(0.1, 0.2, 0.3);
WebFilterOperations arbitraryFilters;
arbitraryFilters.append(WebFilterOperation::createOpacityFilter(0.5));
diff --git a/Source/WebKit/chromium/tests/CCLayerIteratorTest.cpp b/Source/WebKit/chromium/tests/CCLayerIteratorTest.cpp
index f5eae7f84..105c7186e 100644
--- a/Source/WebKit/chromium/tests/CCLayerIteratorTest.cpp
+++ b/Source/WebKit/chromium/tests/CCLayerIteratorTest.cpp
@@ -30,8 +30,10 @@
#include "cc/CCLayerTreeHostCommon.h"
#include <gmock/gmock.h>
#include <gtest/gtest.h>
+#include <public/WebTransformationMatrix.h>
using namespace WebCore;
+using WebKit::WebTransformationMatrix;
using ::testing::Mock;
using ::testing::_;
using ::testing::AtLeast;
@@ -139,7 +141,7 @@ TEST(CCLayerIteratorTest, simpleTree)
Vector<RefPtr<LayerChromium> > layerList;
renderSurfaceLayerList.append(rootLayer.get());
CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(rootLayer.get(), rootLayer.get(),
- TransformationMatrix(), TransformationMatrix(),
+ WebTransformationMatrix(), WebTransformationMatrix(),
renderSurfaceLayerList, layerList,
256);
@@ -186,7 +188,7 @@ TEST(CCLayerIteratorTest, complexTree)
Vector<RefPtr<LayerChromium> > layerList;
renderSurfaceLayerList.append(rootLayer.get());
CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(rootLayer.get(), rootLayer.get(),
- TransformationMatrix(), TransformationMatrix(),
+ WebTransformationMatrix(), WebTransformationMatrix(),
renderSurfaceLayerList, layerList,
256);
@@ -245,7 +247,7 @@ TEST(CCLayerIteratorTest, complexTreeMultiSurface)
Vector<RefPtr<LayerChromium> > layerList;
renderSurfaceLayerList.append(rootLayer.get());
CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(rootLayer.get(), rootLayer.get(),
- TransformationMatrix(), TransformationMatrix(),
+ WebTransformationMatrix(), WebTransformationMatrix(),
renderSurfaceLayerList, layerList,
256);
diff --git a/Source/WebKit/chromium/tests/CCLayerSorterTest.cpp b/Source/WebKit/chromium/tests/CCLayerSorterTest.cpp
index 65db549ba..d231e1259 100644
--- a/Source/WebKit/chromium/tests/CCLayerSorterTest.cpp
+++ b/Source/WebKit/chromium/tests/CCLayerSorterTest.cpp
@@ -30,8 +30,10 @@
#include "cc/CCMathUtil.h"
#include "cc/CCSingleThreadProxy.h"
#include <gtest/gtest.h>
+#include <public/WebTransformationMatrix.h>
using namespace WebCore;
+using WebKit::WebTransformationMatrix;
namespace {
@@ -46,11 +48,11 @@ TEST(CCLayerSorterTest, BasicOverlap)
float weight = 0;
// Trivial test, with one layer directly obscuring the other.
- TransformationMatrix neg4Translate;
+ WebTransformationMatrix neg4Translate;
neg4Translate.translate3d(0, 0, -4);
CCLayerSorter::LayerShape front(2, 2, neg4Translate);
- TransformationMatrix neg5Translate;
+ WebTransformationMatrix neg5Translate;
neg5Translate.translate3d(0, 0, -5);
CCLayerSorter::LayerShape back(2, 2, neg5Translate);
@@ -63,7 +65,7 @@ TEST(CCLayerSorterTest, BasicOverlap)
EXPECT_EQ(1, weight);
// One layer translated off to the right. No overlap should be detected.
- TransformationMatrix rightTranslate;
+ WebTransformationMatrix rightTranslate;
rightTranslate.translate3d(10, 0, -5);
CCLayerSorter::LayerShape backRight(2, 2, rightTranslate);
overlapResult = CCLayerSorter::checkOverlap(&front, &backRight, zThreshold, weight);
@@ -80,14 +82,15 @@ TEST(CCLayerSorterTest, RightAngleOverlap)
const float zThreshold = 0.1f;
float weight = 0;
- TransformationMatrix perspectiveMatrix;
+ WebTransformationMatrix perspectiveMatrix;
perspectiveMatrix.applyPerspective(1000);
// Two layers forming a right angle with a perspective viewing transform.
- TransformationMatrix leftFaceMatrix;
- leftFaceMatrix.rotate3d(0, 1, 0, -90).translateRight3d(-1, 0, -5);
+ WebTransformationMatrix leftFaceMatrix;
+ leftFaceMatrix.rotate3d(0, 1, 0, -90);
+ leftFaceMatrix.translateRight3d(-1, 0, -5);
CCLayerSorter::LayerShape leftFace(2, 2, perspectiveMatrix * leftFaceMatrix);
- TransformationMatrix frontFaceMatrix;
+ WebTransformationMatrix frontFaceMatrix;
frontFaceMatrix.translate3d(0, 0, -4);
CCLayerSorter::LayerShape frontFace(2, 2, perspectiveMatrix * frontFaceMatrix);
@@ -101,17 +104,18 @@ TEST(CCLayerSorterTest, IntersectingLayerOverlap)
const float zThreshold = 0.1f;
float weight = 0;
- TransformationMatrix perspectiveMatrix;
+ WebTransformationMatrix perspectiveMatrix;
perspectiveMatrix.applyPerspective(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.
- TransformationMatrix frontFaceMatrix;
+ WebTransformationMatrix frontFaceMatrix;
frontFaceMatrix.translate3d(0, 0, -4);
CCLayerSorter::LayerShape frontFace(2, 2, perspectiveMatrix * frontFaceMatrix);
- TransformationMatrix throughMatrix;
- throughMatrix.rotate3d(0, 1, 0, 45).translateRight3d(0, 0, -4);
+ WebTransformationMatrix throughMatrix;
+ throughMatrix.rotate3d(0, 1, 0, 45);
+ throughMatrix.translateRight3d(0, 0, -4);
CCLayerSorter::LayerShape rotatedFace(2, 2, perspectiveMatrix * throughMatrix);
overlapResult = CCLayerSorter::checkOverlap(&frontFace, &rotatedFace, zThreshold, weight);
EXPECT_NE(CCLayerSorter::None, overlapResult);
@@ -136,15 +140,15 @@ TEST(CCLayerSorterTest, 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.
- TransformationMatrix transformA;
+ WebTransformationMatrix transformA;
transformA.translate3d(-6, 0, 1);
CCLayerSorter::LayerShape layerA(8, 20, transformA);
- TransformationMatrix transformB;
+ WebTransformationMatrix transformB;
transformB.translate3d(6, 0, -1);
CCLayerSorter::LayerShape layerB(8, 20, transformB);
- TransformationMatrix transformC;
+ WebTransformationMatrix transformC;
transformC.rotate3d(0, 1, 0, 40);
CCLayerSorter::LayerShape layerC(8, 20, transformC);
@@ -167,10 +171,10 @@ TEST(CCLayerSorterTest, 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.
- TransformationMatrix perspectiveMatrix;
+ WebTransformationMatrix perspectiveMatrix;
perspectiveMatrix.applyPerspective(1);
- TransformationMatrix transformA;
+ WebTransformationMatrix transformA;
transformA.translate3d(-15, 0, -2);
CCLayerSorter::LayerShape layerA(10, 10, perspectiveMatrix * transformA);
@@ -178,7 +182,7 @@ TEST(CCLayerSorterTest, LayersUnderPathologicalPerspectiveTransform)
// 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.
- TransformationMatrix transformB;
+ WebTransformationMatrix transformB;
transformB.translate3d(0, 0, 0.7);
transformB.rotate3d(0, 45, 0);
CCLayerSorter::LayerShape layerB(10, 10, perspectiveMatrix * transformB);
@@ -216,9 +220,9 @@ TEST(CCLayerSorterTest, verifyExistingOrderingPreservedWhenNoZDiff)
OwnPtr<CCLayerImpl> layer4 = CCLayerImpl::create(4);
OwnPtr<CCLayerImpl> layer5 = CCLayerImpl::create(5);
- TransformationMatrix BehindMatrix;
+ WebTransformationMatrix BehindMatrix;
BehindMatrix.translate3d(0, 0, 2);
- TransformationMatrix FrontMatrix;
+ WebTransformationMatrix FrontMatrix;
FrontMatrix.translate3d(0, 0, 1);
layer1->setBounds(IntSize(10, 10));
diff --git a/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp b/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp
index 17e570199..fce9046c7 100644
--- a/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp
+++ b/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp
@@ -29,20 +29,21 @@
#include "CCAnimationTestCommon.h"
#include "CCLayerTreeTestCommon.h"
#include "LayerChromium.h"
-#include "TransformationMatrix.h"
#include "TranslateTransformOperation.h"
#include "cc/CCLayerAnimationController.h"
#include "cc/CCMathUtil.h"
#include <gmock/gmock.h>
#include <gtest/gtest.h>
+#include <public/WebTransformationMatrix.h>
using namespace WebCore;
using namespace WebKitTests;
+using WebKit::WebTransformationMatrix;
namespace {
-void setLayerPropertiesForTesting(LayerChromium* layer, const TransformationMatrix& transform, const TransformationMatrix& sublayerTransform, const FloatPoint& anchor, const FloatPoint& position, const IntSize& bounds, bool preserves3D)
+void setLayerPropertiesForTesting(LayerChromium* layer, const WebTransformationMatrix& transform, const WebTransformationMatrix& sublayerTransform, const FloatPoint& anchor, const FloatPoint& position, const IntSize& bounds, bool preserves3D)
{
layer->setTransform(transform);
layer->setSublayerTransform(sublayerTransform);
@@ -54,16 +55,16 @@ void setLayerPropertiesForTesting(LayerChromium* layer, const TransformationMatr
void executeCalculateDrawTransformsAndVisibility(LayerChromium* rootLayer)
{
- TransformationMatrix identityMatrix;
+ WebTransformationMatrix identityMatrix;
Vector<RefPtr<LayerChromium> > dummyRenderSurfaceLayerList;
Vector<RefPtr<LayerChromium> > dummyLayerList;
int dummyMaxTextureSize = 512;
CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(rootLayer, rootLayer, identityMatrix, identityMatrix, dummyRenderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize);
}
-TransformationMatrix remove3DComponentOfMatrix(const TransformationMatrix& mat)
+WebTransformationMatrix remove3DComponentOfMatrix(const WebTransformationMatrix& mat)
{
- TransformationMatrix ret = mat;
+ WebTransformationMatrix ret = mat;
ret.setM13(0);
ret.setM23(0);
ret.setM31(0);
@@ -98,7 +99,7 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForNoOpLayer)
parent->addChild(child);
child->addChild(grandChild);
- TransformationMatrix identityMatrix;
+ WebTransformationMatrix identityMatrix;
setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0.0f, 0.0f), FloatPoint(0.0f, 0.0f), IntSize(0, 0), false);
setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, FloatPoint(0.0f, 0.0f), FloatPoint(0.0f, 0.0f), IntSize(0, 0), false);
setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatrix, FloatPoint(0.0f, 0.0f), FloatPoint(0.0f, 0.0f), IntSize(0, 0), false);
@@ -120,12 +121,12 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForSingleLayer)
// value of LayerChromium::position() changes if the anchor changes, even though the layer is not actually located in a
// different position. When we initialize layers for testing here, we need to initialize that unintutive position value.
- TransformationMatrix identityMatrix;
+ WebTransformationMatrix identityMatrix;
RefPtr<LayerChromium> layer = LayerChromium::create();
layer->createRenderSurface();
// Case 1: setting the sublayer transform should not affect this layer's draw transform or screen-space transform.
- TransformationMatrix arbitraryTranslation;
+ WebTransformationMatrix arbitraryTranslation;
arbitraryTranslation.translate(10.0, 20.0);
setLayerPropertiesForTesting(layer.get(), identityMatrix, arbitraryTranslation, FloatPoint(0.0f, 0.0f), FloatPoint(0.0f, 0.0f), IntSize(0, 0), false);
executeCalculateDrawTransformsAndVisibility(layer.get());
@@ -134,7 +135,7 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForSingleLayer)
// Case 2: setting the bounds of the layer should result in a draw transform that translates to half the width and height.
// The screen-space transform should remain as the identity, because it does not deal with transforming to/from the center of the layer.
- TransformationMatrix translationToCenter;
+ WebTransformationMatrix translationToCenter;
translationToCenter.translate(5.0, 6.0);
setLayerPropertiesForTesting(layer.get(), identityMatrix, identityMatrix, FloatPoint(0.0f, 0.0f), FloatPoint(0.0f, 0.0f), IntSize(10, 12), false);
executeCalculateDrawTransformsAndVisibility(layer.get());
@@ -148,7 +149,7 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForSingleLayer)
EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, layer->screenSpaceTransform());
// Case 4: A change in "actual" position affects both the draw transform and screen space transform.
- TransformationMatrix positionTransform;
+ WebTransformationMatrix positionTransform;
positionTransform.translate(0.0, 1.2);
setLayerPropertiesForTesting(layer.get(), identityMatrix, identityMatrix, FloatPoint(0.25f, 0.25f), FloatPoint(2.5f, 4.2f), IntSize(10, 12), false);
executeCalculateDrawTransformsAndVisibility(layer.get());
@@ -157,7 +158,7 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForSingleLayer)
// Case 5: In the correct sequence of transforms, the layer transform should pre-multiply the translationToCenter. This is easily tested by
// using a scale transform, because scale and translation are not commutative.
- TransformationMatrix layerTransform;
+ WebTransformationMatrix layerTransform;
layerTransform.scale3d(2.0, 2.0, 1.0);
setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, FloatPoint(0.0f, 0.0f), FloatPoint(0.0f, 0.0f), IntSize(10, 12), false);
executeCalculateDrawTransformsAndVisibility(layer.get());
@@ -165,9 +166,9 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForSingleLayer)
EXPECT_TRANSFORMATION_MATRIX_EQ(layerTransform, layer->screenSpaceTransform());
// Case 6: The layer transform should occur with respect to the anchor point.
- TransformationMatrix translationToAnchor;
+ WebTransformationMatrix translationToAnchor;
translationToAnchor.translate(5.0, 0.0);
- TransformationMatrix expectedResult = translationToAnchor * layerTransform * translationToAnchor.inverse();
+ WebTransformationMatrix expectedResult = translationToAnchor * layerTransform * translationToAnchor.inverse();
setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, FloatPoint(0.5f, 0.0f), FloatPoint(5.0f, 0.0f), IntSize(10, 12), false);
executeCalculateDrawTransformsAndVisibility(layer.get());
EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult * translationToCenter, layer->drawTransform());
@@ -185,7 +186,7 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForSingleLayer)
TEST(CCLayerTreeHostCommonTest, verifyTransformsForSimpleHierarchy)
{
- TransformationMatrix identityMatrix;
+ WebTransformationMatrix identityMatrix;
RefPtr<LayerChromium> parent = LayerChromium::create();
RefPtr<LayerChromium> child = LayerChromium::create();
RefPtr<LayerChromium> grandChild = LayerChromium::create();
@@ -194,7 +195,7 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForSimpleHierarchy)
child->addChild(grandChild);
// Case 1: parent's anchorPoint should not affect child or grandChild.
- TransformationMatrix childTranslationToCenter, grandChildTranslationToCenter;
+ WebTransformationMatrix childTranslationToCenter, grandChildTranslationToCenter;
childTranslationToCenter.translate(8.0, 9.0);
grandChildTranslationToCenter.translate(38.0, 39.0);
setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0.25f, 0.25f), FloatPoint(2.5f, 3.0f), IntSize(10, 12), false);
@@ -207,7 +208,7 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForSimpleHierarchy)
EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->screenSpaceTransform());
// Case 2: parent's position affects child and grandChild.
- TransformationMatrix parentPositionTransform;
+ WebTransformationMatrix parentPositionTransform;
parentPositionTransform.translate(0.0, 1.2);
setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0.25f, 0.25f), FloatPoint(2.5f, 4.2f), IntSize(10, 12), false);
setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, FloatPoint(0.0f, 0.0f), FloatPoint(0.0f, 0.0f), IntSize(16, 18), false);
@@ -219,11 +220,11 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForSimpleHierarchy)
EXPECT_TRANSFORMATION_MATRIX_EQ(parentPositionTransform, grandChild->screenSpaceTransform());
// Case 3: parent's local transform affects child and grandchild
- TransformationMatrix parentLayerTransform;
+ WebTransformationMatrix parentLayerTransform;
parentLayerTransform.scale3d(2.0, 2.0, 1.0);
- TransformationMatrix parentTranslationToAnchor;
+ WebTransformationMatrix parentTranslationToAnchor;
parentTranslationToAnchor.translate(2.5, 3.0);
- TransformationMatrix parentCompositeTransform = parentTranslationToAnchor * parentLayerTransform * parentTranslationToAnchor.inverse();
+ WebTransformationMatrix parentCompositeTransform = parentTranslationToAnchor * parentLayerTransform * parentTranslationToAnchor.inverse();
setLayerPropertiesForTesting(parent.get(), parentLayerTransform, identityMatrix, FloatPoint(0.25f, 0.25f), FloatPoint(2.5f, 3.0f), IntSize(10, 12), false);
setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, FloatPoint(0.0f, 0.0f), FloatPoint(0.0f, 0.0f), IntSize(16, 18), false);
setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatrix, FloatPoint(0.0f, 0.0f), FloatPoint(0.0f, 0.0f), IntSize(76, 78), false);
@@ -237,14 +238,14 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForSimpleHierarchy)
// scaling is used here again so that the correct sequence of transforms is properly tested.
// Note that preserves3D is false, but the sublayer matrix should retain its 3D properties when given to child.
// But then, the child also does not preserve3D. When it gives its hierarchy to the grandChild, it should be flattened to 2D.
- TransformationMatrix parentSublayerMatrix;
+ WebTransformationMatrix parentSublayerMatrix;
parentSublayerMatrix.scale3d(10.0, 10.0, 3.3);
- TransformationMatrix parentTranslationToCenter;
+ WebTransformationMatrix parentTranslationToCenter;
parentTranslationToCenter.translate(5.0, 6.0);
// Sublayer matrix is applied to the center of the parent layer.
parentCompositeTransform = parentTranslationToAnchor * parentLayerTransform * parentTranslationToAnchor.inverse()
* parentTranslationToCenter * parentSublayerMatrix * parentTranslationToCenter.inverse();
- TransformationMatrix flattenedCompositeTransform = remove3DComponentOfMatrix(parentCompositeTransform);
+ WebTransformationMatrix flattenedCompositeTransform = remove3DComponentOfMatrix(parentCompositeTransform);
setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSublayerMatrix, FloatPoint(0.25f, 0.25f), FloatPoint(2.5f, 3.0f), IntSize(10, 12), false);
setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, FloatPoint(0.0f, 0.0f), FloatPoint(0.0f, 0.0f), IntSize(16, 18), false);
setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatrix, FloatPoint(0.0f, 0.0f), FloatPoint(0.0f, 0.0f), IntSize(76, 78), false);
@@ -278,18 +279,18 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForSingleRenderSurface)
// Child is set up so that a new render surface should be created.
child->setOpacity(0.5f);
- TransformationMatrix identityMatrix;
- TransformationMatrix parentLayerTransform;
+ WebTransformationMatrix identityMatrix;
+ WebTransformationMatrix parentLayerTransform;
parentLayerTransform.scale3d(2.0, 2.0, 1.0);
- TransformationMatrix parentTranslationToAnchor;
+ WebTransformationMatrix parentTranslationToAnchor;
parentTranslationToAnchor.translate(2.5, 3.0);
- TransformationMatrix parentSublayerMatrix;
+ WebTransformationMatrix parentSublayerMatrix;
parentSublayerMatrix.scale3d(10.0, 10.0, 3.3);
- TransformationMatrix parentTranslationToCenter;
+ WebTransformationMatrix parentTranslationToCenter;
parentTranslationToCenter.translate(5.0, 6.0);
- TransformationMatrix parentCompositeTransform = parentTranslationToAnchor * parentLayerTransform * parentTranslationToAnchor.inverse()
+ WebTransformationMatrix parentCompositeTransform = parentTranslationToAnchor * parentLayerTransform * parentTranslationToAnchor.inverse()
* parentTranslationToCenter * parentSublayerMatrix * parentTranslationToCenter.inverse();
- TransformationMatrix childTranslationToCenter;
+ WebTransformationMatrix childTranslationToCenter;
childTranslationToCenter.translate(8.0, 9.0);
// Child's render surface should not exist yet.
@@ -331,22 +332,22 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForReplica)
// Child is set up so that a new render surface should be created.
child->setOpacity(0.5f);
- TransformationMatrix identityMatrix;
- TransformationMatrix parentLayerTransform;
+ WebTransformationMatrix identityMatrix;
+ WebTransformationMatrix parentLayerTransform;
parentLayerTransform.scale3d(2.0, 2.0, 1.0);
- TransformationMatrix parentTranslationToAnchor;
+ WebTransformationMatrix parentTranslationToAnchor;
parentTranslationToAnchor.translate(2.5, 3.0);
- TransformationMatrix parentSublayerMatrix;
+ WebTransformationMatrix parentSublayerMatrix;
parentSublayerMatrix.scale3d(10.0, 10.0, 3.3);
- TransformationMatrix parentTranslationToCenter;
+ WebTransformationMatrix parentTranslationToCenter;
parentTranslationToCenter.translate(5.0, 6.0);
- TransformationMatrix parentCompositeTransform = parentTranslationToAnchor * parentLayerTransform * parentTranslationToAnchor.inverse()
+ WebTransformationMatrix parentCompositeTransform = parentTranslationToAnchor * parentLayerTransform * parentTranslationToAnchor.inverse()
* parentTranslationToCenter * parentSublayerMatrix * parentTranslationToCenter.inverse();
- TransformationMatrix childTranslationToCenter;
+ WebTransformationMatrix childTranslationToCenter;
childTranslationToCenter.translate(8.0, 9.0);
- TransformationMatrix replicaLayerTransform;
+ WebTransformationMatrix replicaLayerTransform;
replicaLayerTransform.scale3d(3.0, 3.0, 1.0);
- TransformationMatrix replicaCompositeTransform = parentCompositeTransform * replicaLayerTransform;
+ WebTransformationMatrix replicaCompositeTransform = parentCompositeTransform * replicaLayerTransform;
// Child's render surface should not exist yet.
ASSERT_FALSE(child->renderSurface());
@@ -408,20 +409,20 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForRenderSurfaceHierarchy)
//
// x component tests that layerTransform and sublayerTransform are done in the right order (translation and scale are noncommutative).
// y component has a translation by 1.0 for every ancestor, which indicates the "depth" of the layer in the hierarchy.
- TransformationMatrix translationToAnchor;
+ WebTransformationMatrix translationToAnchor;
translationToAnchor.translate(2.5, 0.0);
- TransformationMatrix translationToCenter;
+ WebTransformationMatrix translationToCenter;
translationToCenter.translate(5.0, 5.0);
- TransformationMatrix layerTransform;
+ WebTransformationMatrix layerTransform;
layerTransform.translate(1.0, 1.0);
- TransformationMatrix sublayerTransform;
+ WebTransformationMatrix sublayerTransform;
sublayerTransform.scale3d(10.0, 1.0, 1.0);
- TransformationMatrix replicaLayerTransform;
+ WebTransformationMatrix replicaLayerTransform;
replicaLayerTransform.scale3d(-2.0, 5.0, 1.0);
- TransformationMatrix A = translationToAnchor * layerTransform * translationToAnchor.inverse();
- TransformationMatrix B = translationToCenter * sublayerTransform * translationToCenter.inverse();
- TransformationMatrix R = A * translationToAnchor * replicaLayerTransform * translationToAnchor.inverse();
+ WebTransformationMatrix A = translationToAnchor * layerTransform * translationToAnchor.inverse();
+ WebTransformationMatrix B = translationToCenter * sublayerTransform * translationToCenter.inverse();
+ WebTransformationMatrix R = A * translationToAnchor * replicaLayerTransform * translationToAnchor.inverse();
setLayerPropertiesForTesting(parent.get(), layerTransform, sublayerTransform, FloatPoint(0.25f, 0.0f), FloatPoint(2.5f, 0.0f), IntSize(10, 10), false);
setLayerPropertiesForTesting(renderSurface1.get(), layerTransform, sublayerTransform, FloatPoint(0.25f, 0.0f), FloatPoint(2.5f, 0.0f), IntSize(10, 10), false);
@@ -531,7 +532,7 @@ TEST(CCLayerTreeHostCommonTest, verifyRenderSurfaceListForClipLayer)
RefPtr<LayerChromiumWithForcedDrawsContent> child = adoptRef(new LayerChromiumWithForcedDrawsContent());
renderSurface1->setOpacity(0.9f);
- const TransformationMatrix identityMatrix;
+ const WebTransformationMatrix identityMatrix;
setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityMatrix, FloatPoint::zero(), FloatPoint::zero(), IntSize(10, 10), false);
setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, FloatPoint::zero(), FloatPoint(30, 30), IntSize(10, 10), false);
@@ -560,7 +561,7 @@ TEST(CCLayerTreeHostCommonTest, verifyRenderSurfaceListForTransparentChild)
RefPtr<LayerChromiumWithForcedDrawsContent> child = adoptRef(new LayerChromiumWithForcedDrawsContent());
renderSurface1->setOpacity(0);
- const TransformationMatrix identityMatrix;
+ const WebTransformationMatrix identityMatrix;
setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityMatrix, FloatPoint::zero(), FloatPoint::zero(), IntSize(10, 10), false);
setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, FloatPoint::zero(), FloatPoint::zero(), IntSize(10, 10), false);
@@ -588,7 +589,7 @@ TEST(CCLayerTreeHostCommonTest, verifyForceRenderSurface)
RefPtr<LayerChromiumWithForcedDrawsContent> child = adoptRef(new LayerChromiumWithForcedDrawsContent());
renderSurface1->setForceRenderSurface(true);
- const TransformationMatrix identityMatrix;
+ const WebTransformationMatrix identityMatrix;
setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityMatrix, FloatPoint::zero(), FloatPoint::zero(), IntSize(10, 10), false);
setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, FloatPoint::zero(), FloatPoint::zero(), IntSize(10, 10), false);
@@ -628,7 +629,7 @@ TEST(CCLayerTreeHostCommonTest, verifyClipRectCullsRenderSurfaces)
// clipRect, and they should never get scheduled on the list of renderSurfaces.
//
- const TransformationMatrix identityMatrix;
+ const WebTransformationMatrix identityMatrix;
RefPtr<LayerChromium> parent = LayerChromium::create();
RefPtr<LayerChromium> child = LayerChromium::create();
RefPtr<LayerChromium> grandChild = LayerChromium::create();
@@ -677,7 +678,7 @@ TEST(CCLayerTreeHostCommonTest, verifyClipRectCullsRenderSurfacesCrashRepro)
// This is a similar situation as verifyClipRectCullsRenderSurfaces, except that
// it reproduces a crash bug http://code.google.com/p/chromium/issues/detail?id=106734.
- const TransformationMatrix identityMatrix;
+ const WebTransformationMatrix identityMatrix;
RefPtr<LayerChromium> parent = LayerChromium::create();
RefPtr<LayerChromium> child = LayerChromium::create();
RefPtr<LayerChromium> grandChild = LayerChromium::create();
@@ -749,7 +750,7 @@ TEST(CCLayerTreeHostCommonTest, verifyClipRectCullsSurfaceWithoutVisibleContent)
// this clipping should be avoided and we should keep the grandChild
// in the renderSurfaceLayerList.
- const TransformationMatrix identityMatrix;
+ const WebTransformationMatrix identityMatrix;
RefPtr<LayerChromium> parent = LayerChromium::create();
RefPtr<LayerChromium> child = LayerChromium::create();
RefPtr<LayerChromium> grandChild = LayerChromium::create();
@@ -813,7 +814,7 @@ TEST(CCLayerTreeHostCommonTest, verifyClipRectIsPropagatedCorrectlyToLayers)
// grandChild4 - outside parent's clipRect, and masksToBounds; the clipRect should be empty.
//
- const TransformationMatrix identityMatrix;
+ const WebTransformationMatrix identityMatrix;
RefPtr<LayerChromium> parent = LayerChromium::create();
RefPtr<LayerChromium> child = LayerChromium::create();
RefPtr<LayerChromium> grandChild1 = LayerChromium::create();
@@ -871,7 +872,7 @@ TEST(CCLayerTreeHostCommonTest, verifyClipRectIsPropagatedCorrectlyToSurfaces)
// have a clipRect of their own layer bounds, however, if masksToBounds was true.
//
- const TransformationMatrix identityMatrix;
+ const WebTransformationMatrix identityMatrix;
RefPtr<LayerChromium> parent = LayerChromium::create();
RefPtr<LayerChromium> child = LayerChromium::create();
RefPtr<LayerChromium> grandChild1 = LayerChromium::create();
@@ -972,9 +973,9 @@ TEST(CCLayerTreeHostCommonTest, verifyAnimationsForRenderSurfaceHierarchy)
// Also put an animated opacity on a layer without descendants.
addOpacityTransitionToController(*grandChildOfRoot->layerAnimationController(), 10, 1, 0, false);
- TransformationMatrix layerTransform;
+ WebTransformationMatrix layerTransform;
layerTransform.translate(1.0, 1.0);
- TransformationMatrix sublayerTransform;
+ WebTransformationMatrix sublayerTransform;
sublayerTransform.scale3d(10.0, 1.0, 1.0);
// In combination with descendantDrawsContent and masksToBounds, an animated transform forces the layer to have a new renderSurface.
@@ -1089,7 +1090,7 @@ TEST(CCLayerTreeHostCommonTest, verifyVisibleRectForIdentityTransform)
// Test the calculateVisibleRect() function works correctly for identity transforms.
IntRect targetSurfaceRect = IntRect(IntPoint(0, 0), IntSize(100, 100));
- TransformationMatrix layerToSurfaceTransform;
+ WebTransformationMatrix layerToSurfaceTransform;
// Case 1: Layer is contained within the surface.
IntRect layerContentRect = IntRect(IntPoint(10, 10), IntSize(30, 30));
@@ -1115,7 +1116,7 @@ TEST(CCLayerTreeHostCommonTest, verifyVisibleRectForTranslations)
IntRect targetSurfaceRect = IntRect(IntPoint(0, 0), IntSize(100, 100));
IntRect layerContentRect = IntRect(IntPoint(0, 0), IntSize(30, 30));
- TransformationMatrix layerToSurfaceTransform;
+ WebTransformationMatrix layerToSurfaceTransform;
// Case 1: Layer is contained within the surface.
layerToSurfaceTransform.makeIdentity();
@@ -1145,7 +1146,7 @@ TEST(CCLayerTreeHostCommonTest, verifyVisibleRectFor2DRotations)
IntRect targetSurfaceRect = IntRect(IntPoint(0, 0), IntSize(100, 100));
IntRect layerContentRect = IntRect(IntPoint(0, 0), IntSize(30, 30));
- TransformationMatrix layerToSurfaceTransform;
+ WebTransformationMatrix layerToSurfaceTransform;
// Case 1: Layer is contained within the surface.
layerToSurfaceTransform.makeIdentity();
@@ -1192,7 +1193,7 @@ TEST(CCLayerTreeHostCommonTest, verifyVisibleRectFor3dOrthographicTransform)
IntRect targetSurfaceRect = IntRect(IntPoint(0, 0), IntSize(100, 100));
IntRect layerContentRect = IntRect(IntPoint(0, 0), IntSize(100, 100));
- TransformationMatrix layerToSurfaceTransform;
+ WebTransformationMatrix layerToSurfaceTransform;
// Case 1: Orthographic projection of a layer rotated about y-axis by 45 degrees, should be fully contained in the renderSurface.
layerToSurfaceTransform.makeIdentity();
@@ -1220,7 +1221,7 @@ TEST(CCLayerTreeHostCommonTest, verifyVisibleRectFor3dPerspectiveTransform)
IntRect targetSurfaceRect = IntRect(IntPoint(0, 0), IntSize(100, 100));
IntRect layerContentRect = IntRect(IntPoint(-50, -50), IntSize(200, 200));
- TransformationMatrix layerToSurfaceTransform;
+ WebTransformationMatrix layerToSurfaceTransform;
// Case 1: Even though the layer is twice as large as the surface, due to perspective
// foreshortening, the layer will fit fully in the surface when its translated
@@ -1262,7 +1263,7 @@ TEST(CCLayerTreeHostCommonTest, verifyVisibleRectFor3dOrthographicIsNotClippedBe
IntRect targetSurfaceRect = IntRect(IntPoint(0, 0), IntSize(100, 100));
IntRect layerContentRect = IntRect(IntPoint(0, 0), IntSize(100, 100));
- TransformationMatrix layerToSurfaceTransform;
+ WebTransformationMatrix layerToSurfaceTransform;
// This sequence of transforms effectively rotates the layer about the y-axis at the
// center of the layer.
@@ -1286,7 +1287,7 @@ TEST(CCLayerTreeHostCommonTest, verifyVisibleRectFor3dPerspectiveWhenClippedByW)
IntRect targetSurfaceRect = IntRect(IntPoint(-50, -50), IntSize(100, 100));
IntRect layerContentRect = IntRect(IntPoint(-10, -1), IntSize(20, 2));
- TransformationMatrix layerToSurfaceTransform;
+ WebTransformationMatrix layerToSurfaceTransform;
// The layer is positioned so that the right half of the layer should be in front of
// the camera, while the other half is behind the surface's projection plane. The
@@ -1294,7 +1295,7 @@ TEST(CCLayerTreeHostCommonTest, verifyVisibleRectFor3dPerspectiveWhenClippedByW)
// center of the layer.
layerToSurfaceTransform.makeIdentity();
layerToSurfaceTransform.applyPerspective(1);
- layerToSurfaceTransform.translate3d(-1, 0, 1);
+ layerToSurfaceTransform.translate3d(-2, 0, 1);
layerToSurfaceTransform.rotate3d(0, 45, 0);
// Sanity check that this transform does indeed cause w < 0 when applying the
@@ -1320,7 +1321,7 @@ TEST(CCLayerTreeHostCommonTest, verifyVisibleRectForPerspectiveUnprojection)
// This sequence of transforms causes one corner of the layer to protrude across the w = 0 plane, and should be clipped.
IntRect targetSurfaceRect = IntRect(IntPoint(-50, -50), IntSize(100, 100));
IntRect layerContentRect = IntRect(IntPoint(-10, -10), IntSize(20, 20));
- TransformationMatrix layerToSurfaceTransform;
+ WebTransformationMatrix layerToSurfaceTransform;
layerToSurfaceTransform.makeIdentity();
layerToSurfaceTransform.applyPerspective(1);
layerToSurfaceTransform.translate3d(0, 0, -5);
@@ -1348,7 +1349,7 @@ TEST(CCLayerTreeHostCommonTest, verifyBackFaceCullingWithoutPreserves3d)
// that 3d transforms still apply in this case, but they are "flattened" to each
// parent layer according to current W3C spec.
- const TransformationMatrix identityMatrix;
+ const WebTransformationMatrix identityMatrix;
RefPtr<LayerChromium> parent = LayerChromium::create();
RefPtr<LayerChromiumWithForcedDrawsContent> frontFacingChild = adoptRef(new LayerChromiumWithForcedDrawsContent());
RefPtr<LayerChromiumWithForcedDrawsContent> backFacingChild = adoptRef(new LayerChromiumWithForcedDrawsContent());
@@ -1379,7 +1380,7 @@ TEST(CCLayerTreeHostCommonTest, verifyBackFaceCullingWithoutPreserves3d)
frontFacingChildOfBackFacingSurface->setDoubleSided(false);
backFacingChildOfBackFacingSurface->setDoubleSided(false);
- TransformationMatrix backfaceMatrix;
+ WebTransformationMatrix backfaceMatrix;
backfaceMatrix.translate(50, 50);
backfaceMatrix.rotate3d(0, 1, 0, 180);
backfaceMatrix.translate(-50, -50);
@@ -1446,7 +1447,7 @@ TEST(CCLayerTreeHostCommonTest, verifyBackFaceCullingWithPreserves3d)
{
// Verify the behavior of back-face culling when preserves-3d transform style is used.
- const TransformationMatrix identityMatrix;
+ const WebTransformationMatrix identityMatrix;
RefPtr<LayerChromium> parent = LayerChromium::create();
RefPtr<LayerChromiumWithForcedDrawsContent> frontFacingChild = adoptRef(new LayerChromiumWithForcedDrawsContent());
RefPtr<LayerChromiumWithForcedDrawsContent> backFacingChild = adoptRef(new LayerChromiumWithForcedDrawsContent());
@@ -1479,7 +1480,7 @@ TEST(CCLayerTreeHostCommonTest, verifyBackFaceCullingWithPreserves3d)
frontFacingChildOfBackFacingSurface->setDoubleSided(false);
backFacingChildOfBackFacingSurface->setDoubleSided(false);
- TransformationMatrix backfaceMatrix;
+ WebTransformationMatrix backfaceMatrix;
backfaceMatrix.translate(50, 50);
backfaceMatrix.rotate3d(0, 1, 0, 180);
backfaceMatrix.translate(-50, -50);
@@ -1549,7 +1550,7 @@ TEST(CCLayerTreeHostCommonTest, verifyBackFaceCullingWithAnimatingTransforms)
// treated as "unknown" so we can not be sure that their back face is really showing.
//
- const TransformationMatrix identityMatrix;
+ const WebTransformationMatrix identityMatrix;
RefPtr<LayerChromium> parent = LayerChromium::create();
RefPtr<LayerChromiumWithForcedDrawsContent> child = adoptRef(new LayerChromiumWithForcedDrawsContent());
RefPtr<LayerChromiumWithForcedDrawsContent> animatingSurface = adoptRef(new LayerChromiumWithForcedDrawsContent());
@@ -1571,7 +1572,7 @@ TEST(CCLayerTreeHostCommonTest, verifyBackFaceCullingWithAnimatingTransforms)
childOfAnimatingSurface->setDoubleSided(false);
animatingChild->setDoubleSided(false);
- TransformationMatrix backfaceMatrix;
+ WebTransformationMatrix backfaceMatrix;
backfaceMatrix.translate(50, 50);
backfaceMatrix.rotate3d(0, 1, 0, 180);
backfaceMatrix.translate(-50, -50);
@@ -1634,7 +1635,7 @@ TEST(CCLayerTreeHostCommonTest, verifyBackFaceCullingWithPreserves3dForFlattenin
// Verify the behavior of back-face culling for a renderSurface that is created
// when it flattens its subtree, and its parent has preserves-3d.
- const TransformationMatrix identityMatrix;
+ const WebTransformationMatrix identityMatrix;
RefPtr<LayerChromium> parent = LayerChromium::create();
RefPtr<LayerChromiumWithForcedDrawsContent> frontFacingSurface = adoptRef(new LayerChromiumWithForcedDrawsContent());
RefPtr<LayerChromiumWithForcedDrawsContent> backFacingSurface = adoptRef(new LayerChromiumWithForcedDrawsContent());
@@ -1651,7 +1652,7 @@ TEST(CCLayerTreeHostCommonTest, verifyBackFaceCullingWithPreserves3dForFlattenin
frontFacingSurface->setDoubleSided(false);
backFacingSurface->setDoubleSided(false);
- TransformationMatrix backfaceMatrix;
+ WebTransformationMatrix backfaceMatrix;
backfaceMatrix.translate(50, 50);
backfaceMatrix.rotate3d(0, 1, 0, 180);
backfaceMatrix.translate(-50, -50);
diff --git a/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp b/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp
index 1275ec854..b996006ae 100644
--- a/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp
+++ b/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp
@@ -32,6 +32,7 @@
#include "CCTiledLayerTestCommon.h"
#include "CompositorFakeWebGraphicsContext3D.h"
#include "ContentLayerChromium.h"
+#include "FakeWebGraphicsContext3D.h"
#include "GraphicsContext3DPrivate.h"
#include "LayerChromium.h"
#include "TextureManager.h"
@@ -43,6 +44,7 @@
#include "cc/CCLayerImpl.h"
#include "cc/CCLayerTreeHostImpl.h"
#include "cc/CCScopedThreadProxy.h"
+#include "cc/CCSingleThreadProxy.h"
#include "cc/CCTextureUpdater.h"
#include "cc/CCThreadTask.h"
#include "cc/CCTimingFunction.h"
@@ -71,6 +73,52 @@ using namespace WTF;
namespace {
+class CompositorFakeWebGraphicsContext3DWithTextureTracking : public CompositorFakeWebGraphicsContext3D {
+public:
+ static PassOwnPtr<CompositorFakeWebGraphicsContext3DWithTextureTracking> create(Attributes attrs)
+ {
+ return adoptPtr(new CompositorFakeWebGraphicsContext3DWithTextureTracking(attrs));
+ }
+
+ virtual WebGLId createTexture()
+ {
+ WebGLId texture = m_textures.size() + 1;
+ m_textures.append(texture);
+ return texture;
+ }
+
+ virtual void deleteTexture(WebGLId texture)
+ {
+ for (size_t i = 0; i < m_textures.size(); i++) {
+ if (m_textures[i] == texture) {
+ m_textures.remove(i);
+ break;
+ }
+ }
+ }
+
+ virtual void bindTexture(WGC3Denum /* target */, WebGLId texture)
+ {
+ m_usedTextures.add(texture);
+ }
+
+ int numTextures() const { return static_cast<int>(m_textures.size()); }
+ int texture(int i) const { return m_textures[i]; }
+ void resetTextures() { m_textures.clear(); }
+
+ int numUsedTextures() const { return static_cast<int>(m_usedTextures.size()); }
+ bool usedTexture(int texture) const { return m_usedTextures.find(texture) != m_usedTextures.end(); }
+ void resetUsedTextures() { m_usedTextures.clear(); }
+
+private:
+ explicit CompositorFakeWebGraphicsContext3DWithTextureTracking(Attributes attrs) : CompositorFakeWebGraphicsContext3D(attrs)
+ {
+ }
+
+ Vector<WebGLId> m_textures;
+ HashSet<WebGLId, DefaultHash<WebGLId>::Hash, UnsignedWithZeroKeyHashTraits<WebGLId> > m_usedTextures;
+};
+
// Used by test stubs to notify the test when something interesting happens.
class TestHooks : public CCLayerAnimationDelegate {
public:
@@ -83,7 +131,7 @@ public:
virtual void applyScrollAndScale(const IntSize&, float) { }
virtual void updateAnimations(double monotonicTime) { }
virtual void layout() { }
- virtual void didRecreateContext(bool succeded) { }
+ virtual void didRecreateContext(bool succeeded) { }
virtual void didCommit() { }
virtual void didCommitAndDrawFrame() { }
virtual void scheduleComposite() { }
@@ -91,6 +139,16 @@ public:
// Implementation of CCLayerAnimationDelegate
virtual void notifyAnimationStarted(double time) { }
virtual void notifyAnimationFinished(double time) { }
+
+ virtual PassRefPtr<GraphicsContext3D> createContext()
+ {
+ GraphicsContext3D::Attributes attrs;
+ WebGraphicsContext3D::Attributes webAttrs;
+ webAttrs.alpha = attrs.alpha;
+
+ OwnPtr<WebGraphicsContext3D> webContext = CompositorFakeWebGraphicsContext3DWithTextureTracking::create(webAttrs);
+ return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(webContext.release(), GraphicsContext3D::RenderDirectlyToHostWindow);
+ }
};
// Adapts CCLayerTreeHostImpl for test. Runs real code, then invokes test hooks.
@@ -206,52 +264,6 @@ private:
bool m_didAddAnimationWasCalled;
};
-class CompositorFakeWebGraphicsContext3DWithTextureTracking : public CompositorFakeWebGraphicsContext3D {
-public:
- static PassOwnPtr<CompositorFakeWebGraphicsContext3DWithTextureTracking> create(Attributes attrs)
- {
- return adoptPtr(new CompositorFakeWebGraphicsContext3DWithTextureTracking(attrs));
- }
-
- virtual WebGLId createTexture()
- {
- WebGLId texture = m_textures.size() + 1;
- m_textures.append(texture);
- return texture;
- }
-
- virtual void deleteTexture(WebGLId texture)
- {
- for (size_t i = 0; i < m_textures.size(); i++) {
- if (m_textures[i] == texture) {
- m_textures.remove(i);
- break;
- }
- }
- }
-
- virtual void bindTexture(WGC3Denum /* target */, WebGLId texture)
- {
- m_usedTextures.add(texture);
- }
-
- int numTextures() const { return static_cast<int>(m_textures.size()); }
- int texture(int i) const { return m_textures[i]; }
- void resetTextures() { m_textures.clear(); }
-
- int numUsedTextures() const { return static_cast<int>(m_usedTextures.size()); }
- bool usedTexture(int texture) const { return m_usedTextures.find(texture) != m_usedTextures.end(); }
- void resetUsedTextures() { m_usedTextures.clear(); }
-
-private:
- explicit CompositorFakeWebGraphicsContext3DWithTextureTracking(Attributes attrs) : CompositorFakeWebGraphicsContext3D(attrs)
- {
- }
-
- Vector<WebGLId> m_textures;
- HashSet<WebGLId, DefaultHash<WebGLId>::Hash, UnsignedWithZeroKeyHashTraits<WebGLId> > m_usedTextures;
-};
-
// Implementation of CCLayerTreeHost callback interface.
class MockLayerTreeHostClient : public CCLayerTreeHostClient {
public:
@@ -285,12 +297,7 @@ public:
virtual PassRefPtr<GraphicsContext3D> createContext() OVERRIDE
{
- GraphicsContext3D::Attributes attrs;
- WebGraphicsContext3D::Attributes webAttrs;
- webAttrs.alpha = attrs.alpha;
-
- OwnPtr<WebGraphicsContext3D> webContext = CompositorFakeWebGraphicsContext3DWithTextureTracking::create(webAttrs);
- return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(webContext.release(), GraphicsContext3D::RenderDirectlyToHostWindow);
+ return m_testHooks->createContext();
}
virtual void willCommit() OVERRIDE
@@ -343,6 +350,7 @@ public:
virtual void beginTest() = 0;
void endTest();
+ void endTestAfterDelay(int delayMilliseconds);
void postSetNeedsAnimateToMainThread()
{
@@ -395,6 +403,11 @@ public:
m_timeoutTask = 0;
}
+ void clearEndTestTask()
+ {
+ m_endTestTask = 0;
+ }
+
CCLayerTreeHost* layerTreeHost() { return m_layerTreeHost.get(); }
@@ -406,6 +419,7 @@ protected:
, m_finished(false)
, m_scheduled(false)
, m_started(false)
+ , m_endTestTask(0)
{ }
void doBeginTest();
@@ -597,6 +611,34 @@ protected:
CCLayerTreeHostTest* m_test;
};
+ class EndTestTask : public WebThread::Task {
+ public:
+ explicit EndTestTask(CCLayerTreeHostTest* test)
+ : m_test(test)
+ {
+ }
+
+ virtual ~EndTestTask()
+ {
+ if (m_test)
+ m_test->clearEndTestTask();
+ }
+
+ void clearTest()
+ {
+ m_test = 0;
+ }
+
+ virtual void run()
+ {
+ if (m_test)
+ m_test->endTest();
+ }
+
+ private:
+ CCLayerTreeHostTest* m_test;
+ };
+
virtual void runTest(bool threaded)
{
if (threaded) {
@@ -621,6 +663,9 @@ protected:
if (m_timeoutTask)
m_timeoutTask->clearTest();
+ if (m_endTestTask)
+ m_endTestTask->clearTest();
+
ASSERT_FALSE(m_layerTreeHost.get());
m_client.clear();
if (m_timedOut) {
@@ -648,6 +693,7 @@ private:
RefPtr<CCScopedThreadProxy> m_mainThreadProxy;
TimeoutTask* m_timeoutTask;
BeginTask* m_beginTask;
+ EndTestTask* m_endTestTask;
};
void CCLayerTreeHostTest::doBeginTest()
@@ -686,6 +732,17 @@ void CCLayerTreeHostTest::endTest()
}
}
+void CCLayerTreeHostTest::endTestAfterDelay(int delayMilliseconds)
+{
+ // If we are called from the CCThread, re-call endTest on the main thread.
+ if (!isMainThread())
+ m_mainThreadProxy->postTask(createCCThreadTask(this, &CCLayerTreeHostTest::endTestAfterDelay, delayMilliseconds));
+ else {
+ m_endTestTask = new EndTestTask(this);
+ WebKit::Platform::current()->currentThread()->postDelayedTask(m_endTestTask, delayMilliseconds);
+ }
+}
+
class CCLayerTreeHostTestThreadOnly : public CCLayerTreeHostTest {
public:
void runTestThreaded()
@@ -1389,6 +1446,56 @@ private:
SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestSynchronizeAnimationStartTimes)
+class FakeWebGraphicsContext3DMakeCurrentFails : public FakeWebGraphicsContext3D {
+public:
+ virtual bool makeContextCurrent() { return false; }
+};
+
+// Ensures that we do not animate
+class CCLayerTreeHostTestInitializeLayerRendererFailsAfterAddAnimation : public CCLayerTreeHostTest {
+public:
+ CCLayerTreeHostTestInitializeLayerRendererFailsAfterAddAnimation()
+ {
+ }
+
+ virtual void beginTest()
+ {
+ // This will cause the animation timer to be set which will fire in
+ // CCSingleThreadProxy::animationTimerDelay() seconds.
+ postAddAnimationToMainThread();
+ }
+
+ virtual void animateLayers(CCLayerTreeHostImpl* layerTreeHostImpl, double monotonicTime)
+ {
+ ASSERT_NOT_REACHED();
+ }
+
+ virtual void didRecreateContext(bool succeeded)
+ {
+ EXPECT_FALSE(succeeded);
+
+ // Make sure we wait CCSingleThreadProxy::animationTimerDelay() seconds
+ // (use ceil just to be sure). If the timer was not disabled, we will
+ // attempt to call CCSingleThreadProxy::compositeImmediately and the
+ // test will fail.
+ endTestAfterDelay(ceil(CCSingleThreadProxy::animationTimerDelay() * 1000));
+ }
+
+ virtual PassRefPtr<GraphicsContext3D> createContext() OVERRIDE
+ {
+ return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new FakeWebGraphicsContext3DMakeCurrentFails), GraphicsContext3D::RenderDirectlyToHostWindow);
+ }
+
+ virtual void afterTest()
+ {
+ }
+};
+
+TEST_F(CCLayerTreeHostTestInitializeLayerRendererFailsAfterAddAnimation, runSingleThread)
+{
+ runTest(false);
+}
+
// Ensures that main thread animations have their start times synchronized with impl thread animations.
class CCLayerTreeHostTestAnimationFinishedEvents : public CCLayerTreeHostTestThreadOnly {
public:
@@ -1985,21 +2092,21 @@ public:
// The root render surface is the size of the viewport.
EXPECT_EQ_RECT(IntRect(0, 0, 60, 60), root->renderSurface()->contentRect());
- TransformationMatrix scaleTransform;
+ WebTransformationMatrix scaleTransform;
scaleTransform.scale(impl->settings().deviceScaleFactor);
// The root layer is scaled by 2x.
- TransformationMatrix rootScreenSpaceTransform = scaleTransform;
- TransformationMatrix rootDrawTransform = scaleTransform;
+ WebTransformationMatrix rootScreenSpaceTransform = scaleTransform;
+ WebTransformationMatrix rootDrawTransform = scaleTransform;
rootDrawTransform.translate(root->bounds().width() * 0.5, root->bounds().height() * 0.5);
EXPECT_EQ(rootDrawTransform, root->drawTransform());
EXPECT_EQ(rootScreenSpaceTransform, root->screenSpaceTransform());
// The child is at position 2,2, so translate by 2,2 before applying the scale by 2x.
- TransformationMatrix childScreenSpaceTransform = scaleTransform;
+ WebTransformationMatrix childScreenSpaceTransform = scaleTransform;
childScreenSpaceTransform.translate(2, 2);
- TransformationMatrix childDrawTransform = scaleTransform;
+ WebTransformationMatrix childDrawTransform = scaleTransform;
childDrawTransform.translate(2, 2);
childDrawTransform.translate(child->bounds().width() * 0.5, child->bounds().height() * 0.5);
@@ -2113,7 +2220,7 @@ TEST_F(CCLayerTreeHostTestAtomicCommit, runMultiThread)
runTest(true);
}
-static void setLayerPropertiesForTesting(LayerChromium* layer, LayerChromium* parent, const TransformationMatrix& transform, const FloatPoint& anchor, const FloatPoint& position, const IntSize& bounds, bool opaque)
+static void setLayerPropertiesForTesting(LayerChromium* layer, LayerChromium* parent, const WebTransformationMatrix& transform, const FloatPoint& anchor, const FloatPoint& position, const IntSize& bounds, bool opaque)
{
layer->removeAllChildren();
if (parent)
@@ -2141,7 +2248,7 @@ public:
m_layerTreeHost->setRootLayer(m_parent);
m_layerTreeHost->setViewportSize(IntSize(10, 20));
- TransformationMatrix identityMatrix;
+ WebTransformationMatrix identityMatrix;
setLayerPropertiesForTesting(m_parent.get(), 0, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(10, 20), true);
setLayerPropertiesForTesting(m_child.get(), m_parent.get(), identityMatrix, FloatPoint(0, 0), FloatPoint(0, 10), IntSize(10, 10), false);
@@ -2301,7 +2408,7 @@ private:
Region m_occludedScreenSpace;
};
-static void setTestLayerPropertiesForTesting(TestLayerChromium* layer, LayerChromium* parent, const TransformationMatrix& transform, const FloatPoint& anchor, const FloatPoint& position, const IntSize& bounds, bool opaque)
+static void setTestLayerPropertiesForTesting(TestLayerChromium* layer, LayerChromium* parent, const WebTransformationMatrix& transform, const FloatPoint& anchor, const FloatPoint& position, const IntSize& bounds, bool opaque)
{
setLayerPropertiesForTesting(layer, parent, transform, anchor, position, bounds, opaque);
layer->clearOccludedScreenSpace();
@@ -2319,8 +2426,8 @@ public:
RefPtr<TestLayerChromium> grandChild = TestLayerChromium::create();
RefPtr<TestLayerChromium> mask = TestLayerChromium::create();
- TransformationMatrix identityMatrix;
- TransformationMatrix childTransform;
+ WebTransformationMatrix identityMatrix;
+ WebTransformationMatrix childTransform;
childTransform.translate(250, 250);
childTransform.rotate(90);
childTransform.translate(-250, -250);
@@ -2521,8 +2628,8 @@ public:
RefPtr<TestLayerChromium> grandChild = TestLayerChromium::create();
RefPtr<TestLayerChromium> mask = TestLayerChromium::create();
- TransformationMatrix identityMatrix;
- TransformationMatrix childTransform;
+ WebTransformationMatrix identityMatrix;
+ WebTransformationMatrix childTransform;
childTransform.translate(250, 250);
childTransform.rotate(90);
childTransform.translate(-250, -250);
@@ -2607,7 +2714,7 @@ public:
{
// We create enough RenderSurfaces that it will trigger Vector reallocation while computing occlusion.
Region occluded;
- const TransformationMatrix identityMatrix;
+ const WebTransformationMatrix identityMatrix;
Vector<RefPtr<TestLayerChromium> > layers;
Vector<RefPtr<TestLayerChromium> > children;
int numSurfaces = 20;
diff --git a/Source/WebKit/chromium/tests/CCLayerTreeTestCommon.h b/Source/WebKit/chromium/tests/CCLayerTreeTestCommon.h
index 75e487a4a..5c01c8049 100644
--- a/Source/WebKit/chromium/tests/CCLayerTreeTestCommon.h
+++ b/Source/WebKit/chromium/tests/CCLayerTreeTestCommon.h
@@ -41,7 +41,7 @@ namespace WebKitTests {
EXPECT_EQ((expected).size().height(), (actual).size().height())
// This is a macro instead of a function so that we get useful line numbers where a test failed.
-// Even though TransformationMatrix values are double precision, there are many other floating-point values used that affect
+// Even though WebTransformationMatrix values are double precision, there are many other floating-point values used that affect
// the transforms, and so we only expect them to be accurate up to floating-point precision.
#define EXPECT_TRANSFORMATION_MATRIX_EQ(expected, actual) \
EXPECT_FLOAT_EQ((expected).m11(), (actual).m11()); \
diff --git a/Source/WebKit/chromium/tests/CCMathUtilTest.cpp b/Source/WebKit/chromium/tests/CCMathUtilTest.cpp
index 3909677a5..44a68b9eb 100644
--- a/Source/WebKit/chromium/tests/CCMathUtilTest.cpp
+++ b/Source/WebKit/chromium/tests/CCMathUtilTest.cpp
@@ -26,18 +26,20 @@
#include "cc/CCMathUtil.h"
-#include "TransformationMatrix.h"
-
+#include "CCLayerTreeTestCommon.h"
+#include "FloatRect.h"
#include <gmock/gmock.h>
#include <gtest/gtest.h>
+#include <public/WebTransformationMatrix.h>
using namespace WebCore;
+using WebKit::WebTransformationMatrix;
namespace {
TEST(CCMathUtilTest, verifyBackfaceVisibilityBasicCases)
{
- TransformationMatrix transform;
+ WebTransformationMatrix transform;
transform.makeIdentity();
EXPECT_FALSE(transform.isBackFaceVisible());
@@ -58,7 +60,7 @@ TEST(CCMathUtilTest, verifyBackfaceVisibilityBasicCases)
TEST(CCMathUtilTest, verifyBackfaceVisibilityForPerspective)
{
- TransformationMatrix layerSpaceToProjectionPlane;
+ WebTransformationMatrix layerSpaceToProjectionPlane;
// This tests if isBackFaceVisible works properly under perspective transforms.
// Specifically, layers that may have their back face visible in orthographic
@@ -104,7 +106,7 @@ TEST(CCMathUtilTest, verifyProjectionOfPerpendicularPlane)
// In this case, the m33() element of the transform becomes zero, which could cause a
// divide-by-zero when projecting points/quads.
- TransformationMatrix transform;
+ WebTransformationMatrix transform;
transform.makeIdentity();
transform.setM33(0);
@@ -116,4 +118,38 @@ TEST(CCMathUtilTest, verifyProjectionOfPerpendicularPlane)
EXPECT_TRUE(projectedRect.isEmpty());
}
+TEST(CCMathUtilTest, verifyEnclosingClippedRectUsesCorrectInitialBounds)
+{
+ HomogeneousCoordinate h1(-100, -100, 0, 1);
+ HomogeneousCoordinate h2(-10, -10, 0, 1);
+ HomogeneousCoordinate h3(10, 10, 0, -1);
+ HomogeneousCoordinate h4(100, 100, 0, -1);
+
+ // The bounds of the enclosing clipped rect should be -100 to -10 for both x and y.
+ // However, if there is a bug where the initial xmin/xmax/ymin/ymax are initialized to
+ // numeric_limits<float>::min() (which is zero, not -flt_max) then the enclosing
+ // clipped rect will be computed incorrectly.
+ FloatRect result = CCMathUtil::computeEnclosingClippedRect(h1, h2, h3, h4);
+
+ EXPECT_FLOAT_RECT_EQ(FloatRect(FloatPoint(-100, -100), FloatSize(90, 90)), result);
+}
+
+TEST(CCMathUtilTest, verifyEnclosingRectOfVerticesUsesCorrectInitialBounds)
+{
+ FloatPoint vertices[3];
+ int numVertices = 3;
+
+ vertices[0] = FloatPoint(-10, -100);
+ vertices[1] = FloatPoint(-100, -10);
+ vertices[2] = FloatPoint(-30, -30);
+
+ // The bounds of the enclosing rect should be -100 to -10 for both x and y. However,
+ // if there is a bug where the initial xmin/xmax/ymin/ymax are initialized to
+ // numeric_limits<float>::min() (which is zero, not -flt_max) then the enclosing
+ // clipped rect will be computed incorrectly.
+ FloatRect result = CCMathUtil::computeEnclosingRectOfVertices(vertices, numVertices);
+
+ EXPECT_FLOAT_RECT_EQ(FloatRect(FloatPoint(-100, -100), FloatSize(90, 90)), result);
+}
+
} // namespace
diff --git a/Source/WebKit/chromium/tests/CCOcclusionTrackerTest.cpp b/Source/WebKit/chromium/tests/CCOcclusionTrackerTest.cpp
index 976dc3f29..80317a008 100644
--- a/Source/WebKit/chromium/tests/CCOcclusionTrackerTest.cpp
+++ b/Source/WebKit/chromium/tests/CCOcclusionTrackerTest.cpp
@@ -27,30 +27,26 @@
#include "cc/CCOcclusionTracker.h"
#include "CCAnimationTestCommon.h"
+#include "CCLayerTreeTestCommon.h"
#include "CCOcclusionTrackerTestCommon.h"
#include "LayerChromium.h"
#include "Region.h"
-#include "TransformationMatrix.h"
#include "TranslateTransformOperation.h"
#include "cc/CCLayerAnimationController.h"
#include "cc/CCLayerImpl.h"
#include "cc/CCLayerTreeHostCommon.h"
+#include "cc/CCMathUtil.h"
#include "cc/CCSingleThreadProxy.h"
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <public/WebFilterOperation.h>
#include <public/WebFilterOperations.h>
+#include <public/WebTransformationMatrix.h>
using namespace WebCore;
using namespace WebKit;
using namespace WebKitTests;
-#define EXPECT_EQ_RECT(a, b) \
- EXPECT_EQ(a.x(), b.x()); \
- EXPECT_EQ(a.y(), b.y()); \
- EXPECT_EQ(a.width(), b.width()); \
- EXPECT_EQ(a.height(), b.height());
-
namespace {
class TestContentLayerChromium : public LayerChromium {
@@ -177,7 +173,7 @@ protected:
CCLayerTreeHost::setNeedsFilterContext(false);
}
- typename Types::ContentLayerType* createRoot(const TransformationMatrix& transform, const FloatPoint& position, const IntSize& bounds)
+ typename Types::ContentLayerType* createRoot(const WebTransformationMatrix& transform, const FloatPoint& position, const IntSize& bounds)
{
typename Types::ContentLayerPtrType layer(Types::createContentLayer());
typename Types::ContentLayerType* layerPtr = layer.get();
@@ -188,7 +184,7 @@ protected:
return layerPtr;
}
- typename Types::LayerType* createLayer(typename Types::LayerType* parent, const TransformationMatrix& transform, const FloatPoint& position, const IntSize& bounds)
+ typename Types::LayerType* createLayer(typename Types::LayerType* parent, const WebTransformationMatrix& transform, const FloatPoint& position, const IntSize& bounds)
{
typename Types::LayerPtrType layer(Types::createLayer());
typename Types::LayerType* layerPtr = layer.get();
@@ -197,7 +193,7 @@ protected:
return layerPtr;
}
- typename Types::LayerType* createSurface(typename Types::LayerType* parent, const TransformationMatrix& transform, const FloatPoint& position, const IntSize& bounds)
+ typename Types::LayerType* createSurface(typename Types::LayerType* parent, const WebTransformationMatrix& transform, const FloatPoint& position, const IntSize& bounds)
{
typename Types::LayerType* layer = createLayer(parent, transform, position, bounds);
WebFilterOperations filters;
@@ -206,7 +202,7 @@ protected:
return layer;
}
- typename Types::ContentLayerType* createDrawingLayer(typename Types::LayerType* parent, const TransformationMatrix& transform, const FloatPoint& position, const IntSize& bounds, bool opaque)
+ typename Types::ContentLayerType* createDrawingLayer(typename Types::LayerType* parent, const WebTransformationMatrix& transform, const FloatPoint& position, const IntSize& bounds, bool opaque)
{
typename Types::ContentLayerPtrType layer(Types::createContentLayer());
typename Types::ContentLayerType* layerPtr = layer.get();
@@ -226,7 +222,7 @@ protected:
return layerPtr;
}
- typename Types::LayerType* createReplicaLayer(typename Types::LayerType* owningLayer, const TransformationMatrix& transform, const FloatPoint& position, const IntSize& bounds)
+ typename Types::LayerType* createReplicaLayer(typename Types::LayerType* owningLayer, const WebTransformationMatrix& transform, const FloatPoint& position, const IntSize& bounds)
{
typename Types::ContentLayerPtrType layer(Types::createContentLayer());
typename Types::ContentLayerType* layerPtr = layer.get();
@@ -244,7 +240,7 @@ protected:
return layerPtr;
}
- typename Types::ContentLayerType* createDrawingSurface(typename Types::LayerType* parent, const TransformationMatrix& transform, const FloatPoint& position, const IntSize& bounds, bool opaque)
+ typename Types::ContentLayerType* createDrawingSurface(typename Types::LayerType* parent, const WebTransformationMatrix& transform, const FloatPoint& position, const IntSize& bounds, bool opaque)
{
typename Types::ContentLayerType* layer = createDrawingLayer(parent, transform, position, bounds, opaque);
WebFilterOperations filters;
@@ -336,24 +332,24 @@ protected:
m_layerIterator = m_layerIteratorBegin;
}
- const TransformationMatrix identityMatrix;
+ const WebTransformationMatrix identityMatrix;
private:
- void setBaseProperties(typename Types::LayerType* layer, const TransformationMatrix& transform, const FloatPoint& position, const IntSize& bounds)
+ void setBaseProperties(typename Types::LayerType* layer, const WebTransformationMatrix& transform, const FloatPoint& position, const IntSize& bounds)
{
layer->setTransform(transform);
- layer->setSublayerTransform(TransformationMatrix());
+ layer->setSublayerTransform(WebTransformationMatrix());
layer->setAnchorPoint(FloatPoint(0, 0));
layer->setPosition(position);
layer->setBounds(bounds);
}
- void setProperties(LayerChromium* layer, const TransformationMatrix& transform, const FloatPoint& position, const IntSize& bounds)
+ void setProperties(LayerChromium* layer, const WebTransformationMatrix& transform, const FloatPoint& position, const IntSize& bounds)
{
setBaseProperties(layer, transform, position, bounds);
}
- void setProperties(CCLayerImpl* layer, const TransformationMatrix& transform, const FloatPoint& position, const IntSize& bounds)
+ void setProperties(CCLayerImpl* layer, const WebTransformationMatrix& transform, const FloatPoint& position, const IntSize& bounds)
{
setBaseProperties(layer, transform, position, bounds);
@@ -449,9 +445,9 @@ protected:
this->visitLayer(layer, occlusion);
this->enterLayer(parent, occlusion);
- EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(30, 30, 70, 70), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(30, 30, 70, 70), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
EXPECT_TRUE(occlusion.occluded(parent, IntRect(30, 30, 70, 70)));
@@ -469,14 +465,14 @@ protected:
occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000));
EXPECT_TRUE(occlusion.unoccludedContentRect(parent, IntRect(30, 30, 70, 70)).isEmpty());
- EXPECT_EQ_RECT(IntRect(29, 30, 1, 70), occlusion.unoccludedContentRect(parent, IntRect(29, 30, 70, 70)));
- EXPECT_EQ_RECT(IntRect(29, 29, 70, 70), occlusion.unoccludedContentRect(parent, IntRect(29, 29, 70, 70)));
- EXPECT_EQ_RECT(IntRect(30, 29, 70, 1), occlusion.unoccludedContentRect(parent, IntRect(30, 29, 70, 70)));
- EXPECT_EQ_RECT(IntRect(31, 29, 70, 70), occlusion.unoccludedContentRect(parent, IntRect(31, 29, 70, 70)));
- EXPECT_EQ_RECT(IntRect(100, 30, 1, 70), occlusion.unoccludedContentRect(parent, IntRect(31, 30, 70, 70)));
- EXPECT_EQ_RECT(IntRect(31, 31, 70, 70), occlusion.unoccludedContentRect(parent, IntRect(31, 31, 70, 70)));
- EXPECT_EQ_RECT(IntRect(30, 100, 70, 1), occlusion.unoccludedContentRect(parent, IntRect(30, 31, 70, 70)));
- EXPECT_EQ_RECT(IntRect(29, 31, 70, 70), occlusion.unoccludedContentRect(parent, IntRect(29, 31, 70, 70)));
+ EXPECT_INT_RECT_EQ(IntRect(29, 30, 1, 70), occlusion.unoccludedContentRect(parent, IntRect(29, 30, 70, 70)));
+ EXPECT_INT_RECT_EQ(IntRect(29, 29, 70, 70), occlusion.unoccludedContentRect(parent, IntRect(29, 29, 70, 70)));
+ EXPECT_INT_RECT_EQ(IntRect(30, 29, 70, 1), occlusion.unoccludedContentRect(parent, IntRect(30, 29, 70, 70)));
+ EXPECT_INT_RECT_EQ(IntRect(31, 29, 70, 70), occlusion.unoccludedContentRect(parent, IntRect(31, 29, 70, 70)));
+ EXPECT_INT_RECT_EQ(IntRect(100, 30, 1, 70), occlusion.unoccludedContentRect(parent, IntRect(31, 30, 70, 70)));
+ EXPECT_INT_RECT_EQ(IntRect(31, 31, 70, 70), occlusion.unoccludedContentRect(parent, IntRect(31, 31, 70, 70)));
+ EXPECT_INT_RECT_EQ(IntRect(30, 100, 70, 1), occlusion.unoccludedContentRect(parent, IntRect(30, 31, 70, 70)));
+ EXPECT_INT_RECT_EQ(IntRect(29, 31, 70, 70), occlusion.unoccludedContentRect(parent, IntRect(29, 31, 70, 70)));
}
};
@@ -487,7 +483,7 @@ class CCOcclusionTrackerTestRotatedChild : public CCOcclusionTrackerTest<Types,
protected:
void runMyTest()
{
- TransformationMatrix layerTransform;
+ WebTransformationMatrix layerTransform;
layerTransform.translate(250, 250);
layerTransform.rotate(90);
layerTransform.translate(-250, -250);
@@ -502,9 +498,9 @@ protected:
this->visitLayer(layer, occlusion);
this->enterLayer(parent, occlusion);
- EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(30, 30, 70, 70), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(30, 30, 70, 70), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
EXPECT_TRUE(occlusion.occluded(parent, IntRect(30, 30, 70, 70)));
@@ -522,14 +518,14 @@ protected:
occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000));
EXPECT_TRUE(occlusion.unoccludedContentRect(parent, IntRect(30, 30, 70, 70)).isEmpty());
- EXPECT_EQ_RECT(IntRect(29, 30, 1, 70), occlusion.unoccludedContentRect(parent, IntRect(29, 30, 70, 70)));
- EXPECT_EQ_RECT(IntRect(29, 29, 70, 70), occlusion.unoccludedContentRect(parent, IntRect(29, 29, 70, 70)));
- EXPECT_EQ_RECT(IntRect(30, 29, 70, 1), occlusion.unoccludedContentRect(parent, IntRect(30, 29, 70, 70)));
- EXPECT_EQ_RECT(IntRect(31, 29, 70, 70), occlusion.unoccludedContentRect(parent, IntRect(31, 29, 70, 70)));
- EXPECT_EQ_RECT(IntRect(100, 30, 1, 70), occlusion.unoccludedContentRect(parent, IntRect(31, 30, 70, 70)));
- EXPECT_EQ_RECT(IntRect(31, 31, 70, 70), occlusion.unoccludedContentRect(parent, IntRect(31, 31, 70, 70)));
- EXPECT_EQ_RECT(IntRect(30, 100, 70, 1), occlusion.unoccludedContentRect(parent, IntRect(30, 31, 70, 70)));
- EXPECT_EQ_RECT(IntRect(29, 31, 70, 70), occlusion.unoccludedContentRect(parent, IntRect(29, 31, 70, 70)));
+ EXPECT_INT_RECT_EQ(IntRect(29, 30, 1, 70), occlusion.unoccludedContentRect(parent, IntRect(29, 30, 70, 70)));
+ EXPECT_INT_RECT_EQ(IntRect(29, 29, 70, 70), occlusion.unoccludedContentRect(parent, IntRect(29, 29, 70, 70)));
+ EXPECT_INT_RECT_EQ(IntRect(30, 29, 70, 1), occlusion.unoccludedContentRect(parent, IntRect(30, 29, 70, 70)));
+ EXPECT_INT_RECT_EQ(IntRect(31, 29, 70, 70), occlusion.unoccludedContentRect(parent, IntRect(31, 29, 70, 70)));
+ EXPECT_INT_RECT_EQ(IntRect(100, 30, 1, 70), occlusion.unoccludedContentRect(parent, IntRect(31, 30, 70, 70)));
+ EXPECT_INT_RECT_EQ(IntRect(31, 31, 70, 70), occlusion.unoccludedContentRect(parent, IntRect(31, 31, 70, 70)));
+ EXPECT_INT_RECT_EQ(IntRect(30, 100, 70, 1), occlusion.unoccludedContentRect(parent, IntRect(30, 31, 70, 70)));
+ EXPECT_INT_RECT_EQ(IntRect(29, 31, 70, 70), occlusion.unoccludedContentRect(parent, IntRect(29, 31, 70, 70)));
}
};
@@ -540,7 +536,7 @@ class CCOcclusionTrackerTestTranslatedChild : public CCOcclusionTrackerTest<Type
protected:
void runMyTest()
{
- TransformationMatrix layerTransform;
+ WebTransformationMatrix layerTransform;
layerTransform.translate(20, 20);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(100, 100));
@@ -553,9 +549,9 @@ protected:
this->visitLayer(layer, occlusion);
this->enterLayer(parent, occlusion);
- EXPECT_EQ_RECT(IntRect(50, 50, 50, 50), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(50, 50, 50, 50), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(50, 50, 50, 50), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(50, 50, 50, 50), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
EXPECT_TRUE(occlusion.occluded(parent, IntRect(50, 50, 50, 50)));
@@ -573,25 +569,25 @@ protected:
occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000));
EXPECT_TRUE(occlusion.unoccludedContentRect(parent, IntRect(50, 50, 50, 50)).isEmpty());
- EXPECT_EQ_RECT(IntRect(49, 50, 1, 50), occlusion.unoccludedContentRect(parent, IntRect(49, 50, 50, 50)));
- EXPECT_EQ_RECT(IntRect(49, 49, 50, 50), occlusion.unoccludedContentRect(parent, IntRect(49, 49, 50, 50)));
- EXPECT_EQ_RECT(IntRect(50, 49, 50, 1), occlusion.unoccludedContentRect(parent, IntRect(50, 49, 50, 50)));
- EXPECT_EQ_RECT(IntRect(51, 49, 50, 50), occlusion.unoccludedContentRect(parent, IntRect(51, 49, 50, 50)));
- EXPECT_EQ_RECT(IntRect(100, 50, 1, 50), occlusion.unoccludedContentRect(parent, IntRect(51, 50, 50, 50)));
- EXPECT_EQ_RECT(IntRect(51, 51, 50, 50), occlusion.unoccludedContentRect(parent, IntRect(51, 51, 50, 50)));
- EXPECT_EQ_RECT(IntRect(50, 100, 50, 1), occlusion.unoccludedContentRect(parent, IntRect(50, 51, 50, 50)));
- EXPECT_EQ_RECT(IntRect(49, 51, 50, 50), occlusion.unoccludedContentRect(parent, IntRect(49, 51, 50, 50)));
+ EXPECT_INT_RECT_EQ(IntRect(49, 50, 1, 50), occlusion.unoccludedContentRect(parent, IntRect(49, 50, 50, 50)));
+ EXPECT_INT_RECT_EQ(IntRect(49, 49, 50, 50), occlusion.unoccludedContentRect(parent, IntRect(49, 49, 50, 50)));
+ EXPECT_INT_RECT_EQ(IntRect(50, 49, 50, 1), occlusion.unoccludedContentRect(parent, IntRect(50, 49, 50, 50)));
+ EXPECT_INT_RECT_EQ(IntRect(51, 49, 50, 50), occlusion.unoccludedContentRect(parent, IntRect(51, 49, 50, 50)));
+ EXPECT_INT_RECT_EQ(IntRect(100, 50, 1, 50), occlusion.unoccludedContentRect(parent, IntRect(51, 50, 50, 50)));
+ EXPECT_INT_RECT_EQ(IntRect(51, 51, 50, 50), occlusion.unoccludedContentRect(parent, IntRect(51, 51, 50, 50)));
+ EXPECT_INT_RECT_EQ(IntRect(50, 100, 50, 1), occlusion.unoccludedContentRect(parent, IntRect(50, 51, 50, 50)));
+ EXPECT_INT_RECT_EQ(IntRect(49, 51, 50, 50), occlusion.unoccludedContentRect(parent, IntRect(49, 51, 50, 50)));
occlusion.useDefaultLayerScissorRect();
EXPECT_TRUE(occlusion.unoccludedContentRect(parent, IntRect(50, 50, 50, 50)).isEmpty());
- EXPECT_EQ_RECT(IntRect(49, 50, 1, 50), occlusion.unoccludedContentRect(parent, IntRect(49, 50, 50, 50)));
- EXPECT_EQ_RECT(IntRect(49, 49, 50, 50), occlusion.unoccludedContentRect(parent, IntRect(49, 49, 50, 50)));
- EXPECT_EQ_RECT(IntRect(50, 49, 50, 1), occlusion.unoccludedContentRect(parent, IntRect(50, 49, 50, 50)));
- EXPECT_EQ_RECT(IntRect(51, 49, 49, 1), occlusion.unoccludedContentRect(parent, IntRect(51, 49, 50, 50)));
+ EXPECT_INT_RECT_EQ(IntRect(49, 50, 1, 50), occlusion.unoccludedContentRect(parent, IntRect(49, 50, 50, 50)));
+ EXPECT_INT_RECT_EQ(IntRect(49, 49, 50, 50), occlusion.unoccludedContentRect(parent, IntRect(49, 49, 50, 50)));
+ EXPECT_INT_RECT_EQ(IntRect(50, 49, 50, 1), occlusion.unoccludedContentRect(parent, IntRect(50, 49, 50, 50)));
+ EXPECT_INT_RECT_EQ(IntRect(51, 49, 49, 1), occlusion.unoccludedContentRect(parent, IntRect(51, 49, 50, 50)));
EXPECT_TRUE(occlusion.unoccludedContentRect(parent, IntRect(51, 50, 50, 50)).isEmpty());
EXPECT_TRUE(occlusion.unoccludedContentRect(parent, IntRect(51, 51, 50, 50)).isEmpty());
EXPECT_TRUE(occlusion.unoccludedContentRect(parent, IntRect(50, 51, 50, 50)).isEmpty());
- EXPECT_EQ_RECT(IntRect(49, 51, 1, 49), occlusion.unoccludedContentRect(parent, IntRect(49, 51, 50, 50)));
+ EXPECT_INT_RECT_EQ(IntRect(49, 51, 1, 49), occlusion.unoccludedContentRect(parent, IntRect(49, 51, 50, 50)));
occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000));
}
};
@@ -603,7 +599,7 @@ class CCOcclusionTrackerTestChildInRotatedChild : public CCOcclusionTrackerTest<
protected:
void runMyTest()
{
- TransformationMatrix childTransform;
+ WebTransformationMatrix childTransform;
childTransform.translate(250, 250);
childTransform.rotate(90);
childTransform.translate(-250, -250);
@@ -620,9 +616,9 @@ protected:
this->visitLayer(layer, occlusion);
this->enterContributingSurface(child, occlusion);
- EXPECT_EQ_RECT(IntRect(30, 40, 70, 60), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(30, 40, 70, 60), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(10, 430, 60, 70), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(10, 430, 60, 70), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
EXPECT_TRUE(occlusion.occluded(child, IntRect(10, 430, 60, 70)));
@@ -642,9 +638,9 @@ protected:
this->leaveContributingSurface(child, occlusion);
this->enterLayer(parent, occlusion);
- EXPECT_EQ_RECT(IntRect(30, 40, 70, 60), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(30, 40, 70, 60), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(30, 40, 70, 60), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(30, 40, 70, 60), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
EXPECT_TRUE(occlusion.occluded(parent, IntRect(30, 40, 70, 60)));
@@ -696,7 +692,7 @@ class CCOcclusionTrackerTestVisitTargetTwoTimes : public CCOcclusionTrackerTest<
protected:
void runMyTest()
{
- TransformationMatrix childTransform;
+ WebTransformationMatrix childTransform;
childTransform.translate(250, 250);
childTransform.rotate(90);
childTransform.translate(-250, -250);
@@ -715,16 +711,16 @@ protected:
this->visitLayer(child2, occlusion);
- EXPECT_EQ_RECT(IntRect(30, 30, 60, 20), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(30, 30, 60, 20), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(30, 30, 60, 20), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(30, 30, 60, 20), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
this->visitLayer(layer, occlusion);
- EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(30, 30, 70, 70), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(2u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(10, 430, 60, 70), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(10, 430, 60, 70), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
this->enterContributingSurface(child, occlusion);
@@ -745,18 +741,18 @@ protected:
EXPECT_TRUE(occlusion.unoccludedContentRect(child, IntRect(10, 430, 60, 70)).isEmpty());
// This is the little piece not occluded by child2
- EXPECT_EQ_RECT(IntRect(9, 430, 1, 10), occlusion.unoccludedContentRect(child, IntRect(9, 430, 60, 70)));
+ EXPECT_INT_RECT_EQ(IntRect(9, 430, 1, 10), occlusion.unoccludedContentRect(child, IntRect(9, 430, 60, 70)));
// This extends past both sides of child2, so it will be the original rect.
- EXPECT_EQ_RECT(IntRect(9, 430, 60, 80), occlusion.unoccludedContentRect(child, IntRect(9, 430, 60, 80)));
+ EXPECT_INT_RECT_EQ(IntRect(9, 430, 60, 80), occlusion.unoccludedContentRect(child, IntRect(9, 430, 60, 80)));
// This extends past two adjacent sides of child2, and should included the unoccluded parts of each side.
// This also demonstrates that the rect can be arbitrary and does not get clipped to the layer's visibleLayerRect().
- EXPECT_EQ_RECT(IntRect(-10, 430, 20, 70), occlusion.unoccludedContentRect(child, IntRect(-10, 430, 60, 70)));
+ EXPECT_INT_RECT_EQ(IntRect(-10, 430, 20, 70), occlusion.unoccludedContentRect(child, IntRect(-10, 430, 60, 70)));
// This extends past three adjacent sides of child2, so it should contain the unoccluded parts of each side. The left
// and bottom edges are completely unoccluded for some row/column so we get back the original query rect.
- EXPECT_EQ_RECT(IntRect(-10, 430, 60, 80), occlusion.unoccludedContentRect(child, IntRect(-10, 430, 60, 80)));
- EXPECT_EQ_RECT(IntRect(10, 429, 60, 1), occlusion.unoccludedContentRect(child, IntRect(10, 429, 60, 70)));
- EXPECT_EQ_RECT(IntRect(70, 430, 1, 70), occlusion.unoccludedContentRect(child, IntRect(11, 430, 60, 70)));
- EXPECT_EQ_RECT(IntRect(10, 500, 60, 1), occlusion.unoccludedContentRect(child, IntRect(10, 431, 60, 70)));
+ EXPECT_INT_RECT_EQ(IntRect(-10, 430, 60, 80), occlusion.unoccludedContentRect(child, IntRect(-10, 430, 60, 80)));
+ EXPECT_INT_RECT_EQ(IntRect(10, 429, 60, 1), occlusion.unoccludedContentRect(child, IntRect(10, 429, 60, 70)));
+ EXPECT_INT_RECT_EQ(IntRect(70, 430, 1, 70), occlusion.unoccludedContentRect(child, IntRect(11, 430, 60, 70)));
+ EXPECT_INT_RECT_EQ(IntRect(10, 500, 60, 1), occlusion.unoccludedContentRect(child, IntRect(10, 431, 60, 70)));
occlusion.useDefaultLayerScissorRect();
EXPECT_TRUE(occlusion.unoccludedContentRect(child, IntRect(10, 430, 60, 70)).isEmpty());
@@ -773,13 +769,13 @@ protected:
this->leaveContributingSurface(child, occlusion);
this->enterLayer(parent, occlusion);
- EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(30, 30, 70, 70), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(2u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(30, 30, 70, 70), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(2u, occlusion.occlusionInTargetSurface().rects().size());
EXPECT_FALSE(occlusion.occluded(parent, IntRect(30, 30, 70, 70)));
- EXPECT_EQ_RECT(IntRect(90, 30, 10, 10), occlusion.unoccludedContentRect(parent, IntRect(30, 30, 70, 70)));
+ EXPECT_INT_RECT_EQ(IntRect(90, 30, 10, 10), occlusion.unoccludedContentRect(parent, IntRect(30, 30, 70, 70)));
EXPECT_TRUE(occlusion.occluded(parent, IntRect(30, 30, 60, 10)));
EXPECT_FALSE(occlusion.occluded(parent, IntRect(29, 30, 60, 10)));
@@ -792,21 +788,21 @@ protected:
EXPECT_FALSE(occlusion.occluded(parent, IntRect(30, 39, 70, 60)));
EXPECT_TRUE(occlusion.unoccludedContentRect(parent, IntRect(30, 30, 60, 10)).isEmpty());
- EXPECT_EQ_RECT(IntRect(29, 30, 1, 10), occlusion.unoccludedContentRect(parent, IntRect(29, 30, 60, 10)));
- EXPECT_EQ_RECT(IntRect(30, 29, 60, 1), occlusion.unoccludedContentRect(parent, IntRect(30, 29, 60, 10)));
- EXPECT_EQ_RECT(IntRect(90, 30, 1, 10), occlusion.unoccludedContentRect(parent, IntRect(31, 30, 60, 10)));
+ EXPECT_INT_RECT_EQ(IntRect(29, 30, 1, 10), occlusion.unoccludedContentRect(parent, IntRect(29, 30, 60, 10)));
+ EXPECT_INT_RECT_EQ(IntRect(30, 29, 60, 1), occlusion.unoccludedContentRect(parent, IntRect(30, 29, 60, 10)));
+ EXPECT_INT_RECT_EQ(IntRect(90, 30, 1, 10), occlusion.unoccludedContentRect(parent, IntRect(31, 30, 60, 10)));
EXPECT_TRUE(occlusion.unoccludedContentRect(parent, IntRect(30, 31, 60, 10)).isEmpty());
EXPECT_TRUE(occlusion.unoccludedContentRect(parent, IntRect(30, 40, 70, 60)).isEmpty());
- EXPECT_EQ_RECT(IntRect(29, 40, 1, 60), occlusion.unoccludedContentRect(parent, IntRect(29, 40, 70, 60)));
+ EXPECT_INT_RECT_EQ(IntRect(29, 40, 1, 60), occlusion.unoccludedContentRect(parent, IntRect(29, 40, 70, 60)));
// This rect is mostly occluded by |child2|.
- EXPECT_EQ_RECT(IntRect(90, 39, 10, 1), occlusion.unoccludedContentRect(parent, IntRect(30, 39, 70, 60)));
+ EXPECT_INT_RECT_EQ(IntRect(90, 39, 10, 1), occlusion.unoccludedContentRect(parent, IntRect(30, 39, 70, 60)));
// This rect extends past top/right ends of |child2|.
- EXPECT_EQ_RECT(IntRect(30, 29, 70, 11), occlusion.unoccludedContentRect(parent, IntRect(30, 29, 70, 70)));
+ EXPECT_INT_RECT_EQ(IntRect(30, 29, 70, 11), occlusion.unoccludedContentRect(parent, IntRect(30, 29, 70, 70)));
// This rect extends past left/right ends of |child2|.
- EXPECT_EQ_RECT(IntRect(20, 39, 80, 60), occlusion.unoccludedContentRect(parent, IntRect(20, 39, 80, 60)));
- EXPECT_EQ_RECT(IntRect(100, 40, 1, 60), occlusion.unoccludedContentRect(parent, IntRect(31, 40, 70, 60)));
- EXPECT_EQ_RECT(IntRect(30, 100, 70, 1), occlusion.unoccludedContentRect(parent, IntRect(30, 41, 70, 60)));
+ EXPECT_INT_RECT_EQ(IntRect(20, 39, 80, 60), occlusion.unoccludedContentRect(parent, IntRect(20, 39, 80, 60)));
+ EXPECT_INT_RECT_EQ(IntRect(100, 40, 1, 60), occlusion.unoccludedContentRect(parent, IntRect(31, 40, 70, 60)));
+ EXPECT_INT_RECT_EQ(IntRect(30, 100, 70, 1), occlusion.unoccludedContentRect(parent, IntRect(30, 41, 70, 60)));
/* Justification for the above occlusion from |layer|:
100
@@ -842,12 +838,12 @@ class CCOcclusionTrackerTestSurfaceRotatedOffAxis : public CCOcclusionTrackerTes
protected:
void runMyTest()
{
- TransformationMatrix childTransform;
+ WebTransformationMatrix childTransform;
childTransform.translate(250, 250);
childTransform.rotate(95);
childTransform.translate(-250, -250);
- TransformationMatrix layerTransform;
+ WebTransformationMatrix layerTransform;
layerTransform.translate(10, 10);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(100, 100));
@@ -859,14 +855,14 @@ protected:
TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000));
- IntRect clippedLayerInChild = layerTransform.mapRect(layer->visibleLayerRect());
+ IntRect clippedLayerInChild = CCMathUtil::mapClippedRect(layerTransform, layer->visibleLayerRect());
this->visitLayer(layer, occlusion);
this->enterContributingSurface(child, occlusion);
- EXPECT_EQ_RECT(IntRect(), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(0u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(clippedLayerInChild, occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(clippedLayerInChild, occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
EXPECT_TRUE(occlusion.occluded(child, clippedLayerInChild));
@@ -891,13 +887,13 @@ protected:
this->leaveContributingSurface(child, occlusion);
this->enterLayer(parent, occlusion);
- EXPECT_EQ_RECT(IntRect(), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(0u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(0u, occlusion.occlusionInTargetSurface().rects().size());
EXPECT_FALSE(occlusion.occluded(parent, IntRect(75, 55, 1, 1)));
- EXPECT_EQ_RECT(IntRect(75, 55, 1, 1), occlusion.unoccludedContentRect(parent, IntRect(75, 55, 1, 1)));
+ EXPECT_INT_RECT_EQ(IntRect(75, 55, 1, 1), occlusion.unoccludedContentRect(parent, IntRect(75, 55, 1, 1)));
}
};
@@ -908,7 +904,7 @@ class CCOcclusionTrackerTestSurfaceWithTwoOpaqueChildren : public CCOcclusionTra
protected:
void runMyTest()
{
- TransformationMatrix childTransform;
+ WebTransformationMatrix childTransform;
childTransform.translate(250, 250);
childTransform.rotate(90);
childTransform.translate(-250, -250);
@@ -927,9 +923,9 @@ protected:
this->visitLayer(layer1, occlusion);
this->enterContributingSurface(child, occlusion);
- EXPECT_EQ_RECT(IntRect(30, 40, 70, 60), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(30, 40, 70, 60), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(10, 430, 60, 70), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(10, 430, 60, 70), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
EXPECT_TRUE(occlusion.occluded(child, IntRect(10, 430, 60, 70)));
@@ -939,17 +935,17 @@ protected:
EXPECT_FALSE(occlusion.occluded(child, IntRect(10, 431, 60, 70)));
EXPECT_TRUE(occlusion.unoccludedContentRect(child, IntRect(10, 430, 60, 70)).isEmpty());
- EXPECT_EQ_RECT(IntRect(9, 430, 1, 70), occlusion.unoccludedContentRect(child, IntRect(9, 430, 60, 70)));
- EXPECT_EQ_RECT(IntRect(10, 429, 60, 1), occlusion.unoccludedContentRect(child, IntRect(10, 429, 60, 70)));
- EXPECT_EQ_RECT(IntRect(70, 430, 1, 70), occlusion.unoccludedContentRect(child, IntRect(11, 430, 60, 70)));
- EXPECT_EQ_RECT(IntRect(10, 500, 60, 1), occlusion.unoccludedContentRect(child, IntRect(10, 431, 60, 70)));
+ EXPECT_INT_RECT_EQ(IntRect(9, 430, 1, 70), occlusion.unoccludedContentRect(child, IntRect(9, 430, 60, 70)));
+ EXPECT_INT_RECT_EQ(IntRect(10, 429, 60, 1), occlusion.unoccludedContentRect(child, IntRect(10, 429, 60, 70)));
+ EXPECT_INT_RECT_EQ(IntRect(70, 430, 1, 70), occlusion.unoccludedContentRect(child, IntRect(11, 430, 60, 70)));
+ EXPECT_INT_RECT_EQ(IntRect(10, 500, 60, 1), occlusion.unoccludedContentRect(child, IntRect(10, 431, 60, 70)));
this->leaveContributingSurface(child, occlusion);
this->enterLayer(parent, occlusion);
- EXPECT_EQ_RECT(IntRect(30, 40, 70, 60), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(30, 40, 70, 60), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(30, 40, 70, 60), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(30, 40, 70, 60), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
EXPECT_TRUE(occlusion.occluded(parent, IntRect(30, 40, 70, 60)));
@@ -957,10 +953,10 @@ protected:
EXPECT_FALSE(occlusion.occluded(parent, IntRect(30, 39, 70, 60)));
EXPECT_TRUE(occlusion.unoccludedContentRect(parent, IntRect(30, 40, 70, 60)).isEmpty());
- EXPECT_EQ_RECT(IntRect(29, 40, 1, 60), occlusion.unoccludedContentRect(parent, IntRect(29, 40, 70, 60)));
- EXPECT_EQ_RECT(IntRect(30, 39, 70, 1), occlusion.unoccludedContentRect(parent, IntRect(30, 39, 70, 60)));
- EXPECT_EQ_RECT(IntRect(100, 40, 1, 60), occlusion.unoccludedContentRect(parent, IntRect(31, 40, 70, 60)));
- EXPECT_EQ_RECT(IntRect(30, 100, 70, 1), occlusion.unoccludedContentRect(parent, IntRect(30, 41, 70, 60)));
+ EXPECT_INT_RECT_EQ(IntRect(29, 40, 1, 60), occlusion.unoccludedContentRect(parent, IntRect(29, 40, 70, 60)));
+ EXPECT_INT_RECT_EQ(IntRect(30, 39, 70, 1), occlusion.unoccludedContentRect(parent, IntRect(30, 39, 70, 60)));
+ EXPECT_INT_RECT_EQ(IntRect(100, 40, 1, 60), occlusion.unoccludedContentRect(parent, IntRect(31, 40, 70, 60)));
+ EXPECT_INT_RECT_EQ(IntRect(30, 100, 70, 1), occlusion.unoccludedContentRect(parent, IntRect(30, 41, 70, 60)));
/* Justification for the above occlusion from |layer1| and |layer2|:
@@ -996,7 +992,7 @@ class CCOcclusionTrackerTestOverlappingSurfaceSiblings : public CCOcclusionTrack
protected:
void runMyTest()
{
- TransformationMatrix childTransform;
+ WebTransformationMatrix childTransform;
childTransform.translate(250, 250);
childTransform.rotate(90);
childTransform.translate(-250, -250);
@@ -1014,9 +1010,9 @@ protected:
this->visitLayer(layer2, occlusion);
this->enterContributingSurface(child2, occlusion);
- EXPECT_EQ_RECT(IntRect(20, 30, 80, 70), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(20, 30, 80, 70), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(-10, 420, 70, 80), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(-10, 420, 70, 80), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
EXPECT_TRUE(occlusion.occluded(child2, IntRect(-10, 420, 70, 80)));
@@ -1034,15 +1030,15 @@ protected:
occlusion.setLayerScissorRect(IntRect(-20, -20, 1000, 1000));
// There is nothing above child2's surface in the z-order.
- EXPECT_EQ_RECT(IntRect(-10, 420, 70, 80), occlusion.unoccludedContributingSurfaceContentRect(child2->renderSurface(), false, IntRect(-10, 420, 70, 80)));
+ EXPECT_INT_RECT_EQ(IntRect(-10, 420, 70, 80), occlusion.unoccludedContributingSurfaceContentRect(child2->renderSurface(), false, IntRect(-10, 420, 70, 80)));
this->leaveContributingSurface(child2, occlusion);
this->visitLayer(layer1, occlusion);
this->enterContributingSurface(child1, occlusion);
- EXPECT_EQ_RECT(IntRect(20, 20, 80, 80), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(20, 20, 80, 80), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(2u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(-10, 430, 80, 70), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(-10, 430, 80, 70), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
EXPECT_TRUE(occlusion.occluded(child1, IntRect(-10, 430, 80, 70)));
@@ -1052,14 +1048,14 @@ protected:
EXPECT_FALSE(occlusion.occluded(child1, IntRect(-10, 430, 80, 71)));
// child2's contents will occlude child1 below it.
- EXPECT_EQ_RECT(IntRect(-10, 430, 10, 70), occlusion.unoccludedContributingSurfaceContentRect(child1->renderSurface(), false, IntRect(-10, 430, 80, 70)));
+ EXPECT_INT_RECT_EQ(IntRect(-10, 430, 10, 70), occlusion.unoccludedContributingSurfaceContentRect(child1->renderSurface(), false, IntRect(-10, 430, 80, 70)));
this->leaveContributingSurface(child1, occlusion);
this->enterLayer(parent, occlusion);
- EXPECT_EQ_RECT(IntRect(20, 20, 80, 80), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(20, 20, 80, 80), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(2u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(20, 20, 80, 80), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(20, 20, 80, 80), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(2u, occlusion.occlusionInTargetSurface().rects().size());
EXPECT_FALSE(occlusion.occluded(parent, IntRect(20, 20, 80, 80)));
@@ -1105,12 +1101,12 @@ class CCOcclusionTrackerTestOverlappingSurfaceSiblingsWithTwoTransforms : public
protected:
void runMyTest()
{
- TransformationMatrix child1Transform;
+ WebTransformationMatrix child1Transform;
child1Transform.translate(250, 250);
child1Transform.rotate(-90);
child1Transform.translate(-250, -250);
- TransformationMatrix child2Transform;
+ WebTransformationMatrix child2Transform;
child2Transform.translate(250, 250);
child2Transform.rotate(90);
child2Transform.translate(-250, -250);
@@ -1128,9 +1124,9 @@ protected:
this->visitLayer(layer2, occlusion);
this->enterLayer(child2, occlusion);
- EXPECT_EQ_RECT(IntRect(20, 30, 80, 70), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(20, 30, 80, 70), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(-10, 420, 70, 80), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(-10, 420, 70, 80), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
EXPECT_TRUE(occlusion.occluded(child2, IntRect(-10, 420, 70, 80)));
@@ -1143,15 +1139,15 @@ protected:
this->enterContributingSurface(child2, occlusion);
// There is nothing above child2's surface in the z-order.
- EXPECT_EQ_RECT(IntRect(-10, 420, 70, 80), occlusion.unoccludedContributingSurfaceContentRect(child2->renderSurface(), false, IntRect(-10, 420, 70, 80)));
+ EXPECT_INT_RECT_EQ(IntRect(-10, 420, 70, 80), occlusion.unoccludedContributingSurfaceContentRect(child2->renderSurface(), false, IntRect(-10, 420, 70, 80)));
this->leaveContributingSurface(child2, occlusion);
this->visitLayer(layer1, occlusion);
this->enterContributingSurface(child1, occlusion);
- EXPECT_EQ_RECT(IntRect(10, 20, 90, 80), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(10, 20, 90, 80), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(420, -20, 80, 90), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(420, -20, 80, 90), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
EXPECT_TRUE(occlusion.occluded(child1, IntRect(420, -20, 80, 90)));
@@ -1161,16 +1157,16 @@ protected:
EXPECT_FALSE(occlusion.occluded(child1, IntRect(421, -20, 80, 90)));
// child2's contents will occlude child1 below it.
- EXPECT_EQ_RECT(IntRect(420, -20, 80, 90), occlusion.unoccludedContributingSurfaceContentRect(child1->renderSurface(), false, IntRect(420, -20, 80, 90)));
- EXPECT_EQ_RECT(IntRect(490, -10, 10, 80), occlusion.unoccludedContributingSurfaceContentRect(child1->renderSurface(), false, IntRect(420, -10, 80, 90)));
- EXPECT_EQ_RECT(IntRect(420, -20, 70, 10), occlusion.unoccludedContributingSurfaceContentRect(child1->renderSurface(), false, IntRect(420, -20, 70, 90)));
+ EXPECT_INT_RECT_EQ(IntRect(420, -20, 80, 90), occlusion.unoccludedContributingSurfaceContentRect(child1->renderSurface(), false, IntRect(420, -20, 80, 90)));
+ EXPECT_INT_RECT_EQ(IntRect(490, -10, 10, 80), occlusion.unoccludedContributingSurfaceContentRect(child1->renderSurface(), false, IntRect(420, -10, 80, 90)));
+ EXPECT_INT_RECT_EQ(IntRect(420, -20, 70, 10), occlusion.unoccludedContributingSurfaceContentRect(child1->renderSurface(), false, IntRect(420, -20, 70, 90)));
this->leaveContributingSurface(child1, occlusion);
this->enterLayer(parent, occlusion);
- EXPECT_EQ_RECT(IntRect(10, 20, 90, 80), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(10, 20, 90, 80), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(10, 20, 90, 80), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(10, 20, 90, 80), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
EXPECT_TRUE(occlusion.occluded(parent, IntRect(10, 20, 90, 80)));
@@ -1212,7 +1208,7 @@ class CCOcclusionTrackerTestFilters : public CCOcclusionTrackerTest<Types, opaqu
protected:
void runMyTest()
{
- TransformationMatrix layerTransform;
+ WebTransformationMatrix layerTransform;
layerTransform.translate(250, 250);
layerTransform.rotate(90);
layerTransform.translate(-250, -250);
@@ -1255,16 +1251,16 @@ protected:
this->visitLayer(opaqueLayer, occlusion);
this->enterContributingSurface(opaqueLayer, occlusion);
- EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(30, 30, 70, 70), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(0, 430, 70, 70), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 430, 70, 70), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
// And it gets translated to the parent surface.
this->leaveContributingSurface(opaqueLayer, occlusion);
- EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(30, 30, 70, 70), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(30, 30, 70, 70), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
// The blur layer needs to throw away any occlusion from outside its subtree.
@@ -1281,9 +1277,9 @@ protected:
// But the opaque layer's occlusion is preserved on the parent.
this->leaveContributingSurface(blurLayer, occlusion);
this->enterLayer(parent, occlusion);
- EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(30, 30, 70, 70), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(30, 30, 70, 70), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
}
};
@@ -1305,16 +1301,16 @@ protected:
this->visitLayer(surface, occlusion);
- EXPECT_EQ_RECT(IntRect(0, 100, 50, 50), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 100, 50, 50), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(0, 0, 50, 50), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 50, 50), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
this->visitContributingSurface(surface, occlusion);
this->enterLayer(parent, occlusion);
// The surface and replica should both be occluding the parent.
- EXPECT_EQ_RECT(IntRect(0, 100, 100, 100), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 100, 100, 100), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(2u, occlusion.occlusionInTargetSurface().rects().size());
}
};
@@ -1336,16 +1332,16 @@ protected:
this->visitLayer(surface, occlusion);
- EXPECT_EQ_RECT(IntRect(0, 100, 50, 50), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 100, 50, 50), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(0, 0, 50, 50), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 50, 50), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
this->visitContributingSurface(surface, occlusion);
this->enterLayer(parent, occlusion);
// The surface and replica should both be occluding the parent.
- EXPECT_EQ_RECT(IntRect(0, 100, 100, 70), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 100, 100, 70), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(2u, occlusion.occlusionInTargetSurface().rects().size());
}
};
@@ -1368,16 +1364,16 @@ protected:
this->visitLayer(surface, occlusion);
- EXPECT_EQ_RECT(IntRect(0, 100, 50, 50), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 100, 50, 50), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(0, 0, 50, 50), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 50, 50), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
this->visitContributingSurface(surface, occlusion);
this->enterLayer(parent, occlusion);
// The replica should not be occluding the parent, since it has a mask applied to it.
- EXPECT_EQ_RECT(IntRect(0, 100, 50, 50), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 100, 50, 50), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
}
};
@@ -1422,7 +1418,7 @@ protected:
EXPECT_TRUE(occlusion.occluded(parent, IntRect(100, 200, 100, 100)));
EXPECT_TRUE(occlusion.occluded(parent, IntRect(200, 200, 100, 100)));
- EXPECT_EQ_RECT(IntRect(200, 100, 100, 100), occlusion.unoccludedContentRect(parent, IntRect(0, 0, 300, 300)));
+ EXPECT_INT_RECT_EQ(IntRect(200, 100, 100, 100), occlusion.unoccludedContentRect(parent, IntRect(0, 0, 300, 300)));
}
};
@@ -1466,7 +1462,7 @@ protected:
EXPECT_TRUE(occlusion.occluded(parent, IntRect(100, 200, 100, 100)));
EXPECT_TRUE(occlusion.occluded(parent, IntRect(200, 200, 100, 100)));
- EXPECT_EQ_RECT(IntRect(200, 100, 100, 100), occlusion.unoccludedContentRect(parent, IntRect(0, 0, 300, 300)));
+ EXPECT_INT_RECT_EQ(IntRect(200, 100, 100, 100), occlusion.unoccludedContentRect(parent, IntRect(0, 0, 300, 300)));
}
};
@@ -1583,11 +1579,11 @@ protected:
EXPECT_FALSE(occlusion.occluded(parent, IntRect(100, 200, 100, 100)));
EXPECT_FALSE(occlusion.occluded(parent, IntRect(200, 200, 100, 100)));
- EXPECT_EQ_RECT(IntRect(50, 50, 200, 200), occlusion.unoccludedContentRect(parent, IntRect(0, 0, 300, 300)));
- EXPECT_EQ_RECT(IntRect(200, 50, 50, 50), occlusion.unoccludedContentRect(parent, IntRect(0, 0, 300, 100)));
- EXPECT_EQ_RECT(IntRect(200, 100, 50, 100), occlusion.unoccludedContentRect(parent, IntRect(0, 100, 300, 100)));
- EXPECT_EQ_RECT(IntRect(200, 100, 50, 100), occlusion.unoccludedContentRect(parent, IntRect(200, 100, 100, 100)));
- EXPECT_EQ_RECT(IntRect(100, 200, 100, 50), occlusion.unoccludedContentRect(parent, IntRect(100, 200, 100, 100)));
+ EXPECT_INT_RECT_EQ(IntRect(50, 50, 200, 200), occlusion.unoccludedContentRect(parent, IntRect(0, 0, 300, 300)));
+ EXPECT_INT_RECT_EQ(IntRect(200, 50, 50, 50), occlusion.unoccludedContentRect(parent, IntRect(0, 0, 300, 100)));
+ EXPECT_INT_RECT_EQ(IntRect(200, 100, 50, 100), occlusion.unoccludedContentRect(parent, IntRect(0, 100, 300, 100)));
+ EXPECT_INT_RECT_EQ(IntRect(200, 100, 50, 100), occlusion.unoccludedContentRect(parent, IntRect(200, 100, 100, 100)));
+ EXPECT_INT_RECT_EQ(IntRect(100, 200, 100, 50), occlusion.unoccludedContentRect(parent, IntRect(100, 200, 100, 100)));
}
};
@@ -1626,11 +1622,11 @@ protected:
EXPECT_FALSE(occlusion.occluded(parent, IntRect(100, 200, 100, 100)));
EXPECT_FALSE(occlusion.occluded(parent, IntRect(200, 200, 100, 100)));
- EXPECT_EQ_RECT(IntRect(50, 50, 200, 200), occlusion.unoccludedContentRect(parent, IntRect(0, 0, 300, 300)));
- EXPECT_EQ_RECT(IntRect(200, 50, 50, 50), occlusion.unoccludedContentRect(parent, IntRect(0, 0, 300, 100)));
- EXPECT_EQ_RECT(IntRect(200, 100, 50, 100), occlusion.unoccludedContentRect(parent, IntRect(0, 100, 300, 100)));
- EXPECT_EQ_RECT(IntRect(200, 100, 50, 100), occlusion.unoccludedContentRect(parent, IntRect(200, 100, 100, 100)));
- EXPECT_EQ_RECT(IntRect(100, 200, 100, 50), occlusion.unoccludedContentRect(parent, IntRect(100, 200, 100, 100)));
+ EXPECT_INT_RECT_EQ(IntRect(50, 50, 200, 200), occlusion.unoccludedContentRect(parent, IntRect(0, 0, 300, 300)));
+ EXPECT_INT_RECT_EQ(IntRect(200, 50, 50, 50), occlusion.unoccludedContentRect(parent, IntRect(0, 0, 300, 100)));
+ EXPECT_INT_RECT_EQ(IntRect(200, 100, 50, 100), occlusion.unoccludedContentRect(parent, IntRect(0, 100, 300, 100)));
+ EXPECT_INT_RECT_EQ(IntRect(200, 100, 50, 100), occlusion.unoccludedContentRect(parent, IntRect(200, 100, 100, 100)));
+ EXPECT_INT_RECT_EQ(IntRect(100, 200, 100, 50), occlusion.unoccludedContentRect(parent, IntRect(100, 200, 100, 100)));
}
};
@@ -1799,7 +1795,7 @@ protected:
this->visitLayer(layer, occlusion);
this->enterLayer(parent, occlusion);
- EXPECT_EQ_RECT(IntRect(100, 100, 100, 100), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(100, 100, 100, 100), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
EXPECT_FALSE(occlusion.occluded(parent, IntRect(0, 100, 100, 100)));
@@ -1815,7 +1811,7 @@ protected:
this->visitLayer(layer, occlusion);
this->enterLayer(parent, occlusion);
- EXPECT_EQ_RECT(IntRect(120, 120, 180, 180), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(120, 120, 180, 180), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
EXPECT_FALSE(occlusion.occluded(parent, IntRect(0, 100, 100, 100)));
@@ -1831,7 +1827,7 @@ protected:
this->visitLayer(layer, occlusion);
this->enterLayer(parent, occlusion);
- EXPECT_EQ_RECT(IntRect(250, 250, 50, 50), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(250, 250, 50, 50), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
EXPECT_FALSE(occlusion.occluded(parent, IntRect(0, 100, 100, 100)));
@@ -1848,7 +1844,7 @@ class CCOcclusionTrackerTest3dTransform : public CCOcclusionTrackerTest<Types, o
protected:
void runMyTest()
{
- TransformationMatrix transform;
+ WebTransformationMatrix transform;
transform.rotate3d(0, 30, 0);
typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(300, 300));
@@ -1860,7 +1856,7 @@ protected:
this->enterLayer(layer, occlusion);
// The layer is rotated in 3d but without preserving 3d, so it only gets resized.
- EXPECT_EQ_RECT(IntRect(0, 0, 200, 200), occlusion.unoccludedContentRect(layer, IntRect(0, 0, 200, 200)));
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 200, 200), occlusion.unoccludedContentRect(layer, IntRect(0, 0, 200, 200)));
}
};
@@ -1871,7 +1867,7 @@ class CCOcclusionTrackerTestPerspectiveTransform : public CCOcclusionTrackerTest
protected:
void runMyTest()
{
- TransformationMatrix transform;
+ WebTransformationMatrix transform;
transform.translate(150, 150);
transform.applyPerspective(400);
transform.rotate3d(1, 0, 0, -30);
@@ -1887,7 +1883,7 @@ protected:
TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
this->enterLayer(layer, occlusion);
- EXPECT_EQ_RECT(IntRect(0, 0, 200, 200), occlusion.unoccludedContentRect(layer, IntRect(0, 0, 200, 200)));
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 200, 200), occlusion.unoccludedContentRect(layer, IntRect(0, 0, 200, 200)));
}
};
@@ -1899,7 +1895,7 @@ protected:
void runMyTest()
{
// This test is based on the platform/chromium/compositing/3d-corners.html layout test.
- TransformationMatrix transform;
+ WebTransformationMatrix transform;
transform.translate(250, 50);
transform.applyPerspective(10);
transform.translate(-250, -50);
@@ -1930,7 +1926,7 @@ class CCOcclusionTrackerTestLayerBehindCameraDoesNotOcclude : public CCOcclusion
protected:
void runMyTest()
{
- TransformationMatrix transform;
+ WebTransformationMatrix transform;
transform.translate(50, 50);
transform.applyPerspective(100);
transform.translate3d(0, 0, 110);
@@ -1959,7 +1955,7 @@ class CCOcclusionTrackerTestLargePixelsOccludeInsideClipRect : public CCOcclusio
protected:
void runMyTest()
{
- TransformationMatrix transform;
+ WebTransformationMatrix transform;
transform.translate(50, 50);
transform.applyPerspective(100);
transform.translate3d(0, 0, 99);
@@ -2012,27 +2008,27 @@ protected:
this->visitLayer(topmost, occlusion);
this->enterLayer(parent2, occlusion);
// This occlusion will affect all surfaces.
- EXPECT_EQ_RECT(IntRect(0, 0, 250, 300), occlusion.unoccludedContentRect(parent2, IntRect(0, 0, 300, 300)));
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 250, 300), occlusion.unoccludedContentRect(parent2, IntRect(0, 0, 300, 300)));
this->leaveLayer(parent2, occlusion);
this->visitLayer(surfaceChild2, occlusion);
this->enterLayer(surfaceChild, occlusion);
- EXPECT_EQ_RECT(IntRect(100, 0, 150, 300), occlusion.unoccludedContentRect(surfaceChild, IntRect(0, 0, 300, 300)));
+ EXPECT_INT_RECT_EQ(IntRect(100, 0, 150, 300), occlusion.unoccludedContentRect(surfaceChild, IntRect(0, 0, 300, 300)));
this->leaveLayer(surfaceChild, occlusion);
this->enterLayer(surface, occlusion);
- EXPECT_EQ_RECT(IntRect(200, 0, 50, 300), occlusion.unoccludedContentRect(surface, IntRect(0, 0, 300, 300)));
+ EXPECT_INT_RECT_EQ(IntRect(200, 0, 50, 300), occlusion.unoccludedContentRect(surface, IntRect(0, 0, 300, 300)));
this->leaveLayer(surface, occlusion);
this->enterContributingSurface(surface, occlusion);
// Occlusion within the surface is lost when leaving the animating surface.
- EXPECT_EQ_RECT(IntRect(0, 0, 250, 300), occlusion.unoccludedContributingSurfaceContentRect(surface->renderSurface(), false, IntRect(0, 0, 300, 300)));
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 250, 300), occlusion.unoccludedContributingSurfaceContentRect(surface->renderSurface(), false, IntRect(0, 0, 300, 300)));
this->leaveContributingSurface(surface, occlusion);
this->visitLayer(layer, occlusion);
this->enterLayer(parent, occlusion);
// Occlusion is not added for the animating |layer|.
- EXPECT_EQ_RECT(IntRect(0, 0, 250, 300), occlusion.unoccludedContentRect(parent, IntRect(0, 0, 300, 300)));
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 250, 300), occlusion.unoccludedContentRect(parent, IntRect(0, 0, 300, 300)));
}
};
@@ -2064,27 +2060,27 @@ protected:
this->visitLayer(topmost, occlusion);
this->enterLayer(parent2, occlusion);
// This occlusion will affect all surfaces.
- EXPECT_EQ_RECT(IntRect(0, 0, 250, 300), occlusion.unoccludedContentRect(parent, IntRect(0, 0, 300, 300)));
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 250, 300), occlusion.unoccludedContentRect(parent, IntRect(0, 0, 300, 300)));
this->leaveLayer(parent2, occlusion);
this->visitLayer(surfaceChild2, occlusion);
this->enterLayer(surfaceChild, occlusion);
- EXPECT_EQ_RECT(IntRect(100, 0, 150, 300), occlusion.unoccludedContentRect(surfaceChild, IntRect(0, 0, 300, 300)));
+ EXPECT_INT_RECT_EQ(IntRect(100, 0, 150, 300), occlusion.unoccludedContentRect(surfaceChild, IntRect(0, 0, 300, 300)));
this->leaveLayer(surfaceChild, occlusion);
this->enterLayer(surface, occlusion);
- EXPECT_EQ_RECT(IntRect(200, 0, 50, 300), occlusion.unoccludedContentRect(surface, IntRect(0, 0, 300, 300)));
+ EXPECT_INT_RECT_EQ(IntRect(200, 0, 50, 300), occlusion.unoccludedContentRect(surface, IntRect(0, 0, 300, 300)));
this->leaveLayer(surface, occlusion);
this->enterContributingSurface(surface, occlusion);
// Occlusion within the surface is lost when leaving the animating surface.
- EXPECT_EQ_RECT(IntRect(0, 0, 250, 300), occlusion.unoccludedContributingSurfaceContentRect(surface->renderSurface(), false, IntRect(0, 0, 300, 300)));
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 250, 300), occlusion.unoccludedContributingSurfaceContentRect(surface->renderSurface(), false, IntRect(0, 0, 300, 300)));
this->leaveContributingSurface(surface, occlusion);
this->visitLayer(layer, occlusion);
this->enterLayer(parent, occlusion);
// Occlusion is not added for the animating |layer|.
- EXPECT_EQ_RECT(IntRect(0, 0, 250, 300), occlusion.unoccludedContentRect(parent, IntRect(0, 0, 300, 300)));
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 250, 300), occlusion.unoccludedContentRect(parent, IntRect(0, 0, 300, 300)));
}
};
@@ -2122,7 +2118,7 @@ protected:
this->visitLayer(surface2, occlusion);
this->enterContributingSurface(surface2, occlusion);
- EXPECT_EQ_RECT(IntRect(0, 0, 50, 300), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 50, 300), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
this->leaveContributingSurface(surface2, occlusion);
@@ -2130,53 +2126,53 @@ protected:
// surfaceChild2 is moving in screen space but not relative to its target, so occlusion should happen in its target space only.
// It also means that things occluding in screen space (e.g. surface2) cannot occlude this layer.
- EXPECT_EQ_RECT(IntRect(0, 0, 100, 300), occlusion.unoccludedContentRect(surfaceChild2, IntRect(0, 0, 100, 300)));
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 100, 300), occlusion.unoccludedContentRect(surfaceChild2, IntRect(0, 0, 100, 300)));
EXPECT_FALSE(occlusion.occluded(surfaceChild, IntRect(0, 0, 50, 300)));
this->leaveLayer(surfaceChild2, occlusion);
this->enterLayer(surfaceChild, occlusion);
EXPECT_FALSE(occlusion.occluded(surfaceChild, IntRect(0, 0, 100, 300)));
- EXPECT_EQ_RECT(IntRect(0, 0, 50, 300), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 50, 300), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(0, 0, 100, 300), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 100, 300), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
- EXPECT_EQ_RECT(IntRect(100, 0, 200, 300), occlusion.unoccludedContentRect(surface, IntRect(0, 0, 300, 300)));
+ EXPECT_INT_RECT_EQ(IntRect(100, 0, 200, 300), occlusion.unoccludedContentRect(surface, IntRect(0, 0, 300, 300)));
// The surfaceChild is occluded by the surfaceChild2, but is moving relative its target and the screen, so it
// can't be occluded.
- EXPECT_EQ_RECT(IntRect(0, 0, 200, 300), occlusion.unoccludedContentRect(surfaceChild, IntRect(0, 0, 200, 300)));
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 200, 300), occlusion.unoccludedContentRect(surfaceChild, IntRect(0, 0, 200, 300)));
EXPECT_FALSE(occlusion.occluded(surfaceChild, IntRect(0, 0, 50, 300)));
this->leaveLayer(surfaceChild, occlusion);
this->enterLayer(surface, occlusion);
// The surfaceChild is moving in screen space but not relative to its target, so occlusion should happen in its target space only.
- EXPECT_EQ_RECT(IntRect(0, 0, 50, 300), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 50, 300), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(0, 0, 100, 300), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 100, 300), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
- EXPECT_EQ_RECT(IntRect(100, 0, 200, 300), occlusion.unoccludedContentRect(surface, IntRect(0, 0, 300, 300)));
+ EXPECT_INT_RECT_EQ(IntRect(100, 0, 200, 300), occlusion.unoccludedContentRect(surface, IntRect(0, 0, 300, 300)));
this->leaveLayer(surface, occlusion);
// The surface's owning layer is moving in screen space but not relative to its target, so occlusion should happen in its target space only.
- EXPECT_EQ_RECT(IntRect(0, 0, 50, 300), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 50, 300), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(0, 0, 300, 300), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 300, 300), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
- EXPECT_EQ_RECT(IntRect(0, 0, 0, 0), occlusion.unoccludedContentRect(surface, IntRect(0, 0, 300, 300)));
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 0, 0), occlusion.unoccludedContentRect(surface, IntRect(0, 0, 300, 300)));
this->enterContributingSurface(surface, occlusion);
// The contributing |surface| is animating so it can't be occluded.
- EXPECT_EQ_RECT(IntRect(0, 0, 300, 300), occlusion.unoccludedContributingSurfaceContentRect(surface->renderSurface(), false, IntRect(0, 0, 300, 300)));
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 300, 300), occlusion.unoccludedContributingSurfaceContentRect(surface->renderSurface(), false, IntRect(0, 0, 300, 300)));
this->leaveContributingSurface(surface, occlusion);
this->enterLayer(layer, occlusion);
// The |surface| is moving in the screen and in its target, so all occlusion within the surface is lost when leaving it.
- EXPECT_EQ_RECT(IntRect(50, 0, 250, 300), occlusion.unoccludedContentRect(parent, IntRect(0, 0, 300, 300)));
+ EXPECT_INT_RECT_EQ(IntRect(50, 0, 250, 300), occlusion.unoccludedContentRect(parent, IntRect(0, 0, 300, 300)));
this->leaveLayer(layer, occlusion);
this->enterLayer(parent, occlusion);
// The |layer| is animating in the screen and in its target, so no occlusion is added.
- EXPECT_EQ_RECT(IntRect(50, 0, 250, 300), occlusion.unoccludedContentRect(parent, IntRect(0, 0, 300, 300)));
+ EXPECT_INT_RECT_EQ(IntRect(50, 0, 250, 300), occlusion.unoccludedContentRect(parent, IntRect(0, 0, 300, 300)));
}
};
@@ -2187,7 +2183,7 @@ class CCOcclusionTrackerTestSurfaceOcclusionTranslatesToParent : public CCOcclus
protected:
void runMyTest()
{
- TransformationMatrix surfaceTransform;
+ WebTransformationMatrix surfaceTransform;
surfaceTransform.translate(300, 300);
surfaceTransform.scale(2);
surfaceTransform.translate(-150, -150);
@@ -2204,9 +2200,9 @@ protected:
this->visitLayer(surface2, occlusion);
this->visitContributingSurface(surface2, occlusion);
- EXPECT_EQ_RECT(IntRect(50, 50, 200, 200), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(50, 50, 200, 200), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(50, 50, 200, 200), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(50, 50, 200, 200), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
// Clear any stored occlusion.
@@ -2216,9 +2212,9 @@ protected:
this->visitLayer(surface, occlusion);
this->visitContributingSurface(surface, occlusion);
- EXPECT_EQ_RECT(IntRect(0, 0, 400, 400), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 400, 400), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(0, 0, 400, 400), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 400, 400), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
}
};
@@ -2240,9 +2236,9 @@ protected:
this->visitLayer(surface, occlusion);
this->visitContributingSurface(surface, occlusion);
- EXPECT_EQ_RECT(IntRect(0, 0, 300, 200), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 300, 200), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(0, 0, 300, 200), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 300, 200), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
}
};
@@ -2266,22 +2262,22 @@ protected:
// |topmost| occludes the replica, but not the surface itself.
this->visitLayer(topmost, occlusion);
- EXPECT_EQ_RECT(IntRect(0, 100, 100, 100), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 100, 100, 100), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(0, 100, 100, 100), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 100, 100, 100), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
this->visitLayer(surface, occlusion);
- EXPECT_EQ_RECT(IntRect(0, 0, 100, 200), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 100, 200), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(0, 0, 100, 100), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 100, 100), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
this->enterContributingSurface(surface, occlusion);
// Surface is not occluded so it shouldn't think it is.
- EXPECT_EQ_RECT(IntRect(0, 0, 100, 100), occlusion.unoccludedContributingSurfaceContentRect(surface->renderSurface(), false, IntRect(0, 0, 100, 100)));
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 100, 100), occlusion.unoccludedContributingSurfaceContentRect(surface->renderSurface(), false, IntRect(0, 0, 100, 100)));
}
};
@@ -2304,23 +2300,23 @@ protected:
// |topmost| occludes the surface, but not the entire surface's replica.
this->visitLayer(topmost, occlusion);
- EXPECT_EQ_RECT(IntRect(0, 0, 100, 110), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 100, 110), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(0, 0, 100, 110), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 100, 110), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
this->visitLayer(surface, occlusion);
- EXPECT_EQ_RECT(IntRect(0, 0, 100, 110), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 100, 110), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(0, 0, 100, 100), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 100, 100), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
this->enterContributingSurface(surface, occlusion);
// Surface is occluded, but only the top 10px of the replica.
- EXPECT_EQ_RECT(IntRect(0, 0, 0, 0), occlusion.unoccludedContributingSurfaceContentRect(surface->renderSurface(), false, IntRect(0, 0, 100, 100)));
- EXPECT_EQ_RECT(IntRect(0, 10, 100, 90), occlusion.unoccludedContributingSurfaceContentRect(surface->renderSurface(), true, IntRect(0, 0, 100, 100)));
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 0, 0), occlusion.unoccludedContributingSurfaceContentRect(surface->renderSurface(), false, IntRect(0, 0, 100, 100)));
+ EXPECT_INT_RECT_EQ(IntRect(0, 10, 100, 90), occlusion.unoccludedContributingSurfaceContentRect(surface->renderSurface(), true, IntRect(0, 0, 100, 100)));
}
};
@@ -2345,23 +2341,23 @@ protected:
this->visitLayer(overReplica, occlusion);
this->visitLayer(overSurface, occlusion);
- EXPECT_EQ_RECT(IntRect(0, 0, 50, 200), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 50, 200), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(2u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(0, 0, 50, 200), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 50, 200), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(2u, occlusion.occlusionInTargetSurface().rects().size());
this->visitLayer(surface, occlusion);
- EXPECT_EQ_RECT(IntRect(0, 0, 100, 200), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 100, 200), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(2u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(0, 0, 100, 100), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 100, 100), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
this->enterContributingSurface(surface, occlusion);
// Surface and replica are occluded different amounts.
- EXPECT_EQ_RECT(IntRect(40, 0, 60, 100), occlusion.unoccludedContributingSurfaceContentRect(surface->renderSurface(), false, IntRect(0, 0, 100, 100)));
- EXPECT_EQ_RECT(IntRect(50, 0, 50, 100), occlusion.unoccludedContributingSurfaceContentRect(surface->renderSurface(), true, IntRect(0, 0, 100, 100)));
+ EXPECT_INT_RECT_EQ(IntRect(40, 0, 60, 100), occlusion.unoccludedContributingSurfaceContentRect(surface->renderSurface(), false, IntRect(0, 0, 100, 100)));
+ EXPECT_INT_RECT_EQ(IntRect(50, 0, 50, 100), occlusion.unoccludedContributingSurfaceContentRect(surface->renderSurface(), true, IntRect(0, 0, 100, 100)));
}
};
@@ -2385,18 +2381,18 @@ protected:
// |topmost| occludes everything partially so we know occlusion is happening at all.
this->visitLayer(topmost, occlusion);
- EXPECT_EQ_RECT(IntRect(0, 0, 100, 50), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 100, 50), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(0, 0, 100, 50), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 100, 50), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
this->visitLayer(surfaceChild, occlusion);
// surfaceChild increases the occlusion in the screen by a narrow sliver.
- EXPECT_EQ_RECT(IntRect(0, 0, 100, 60), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 100, 60), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
// In its own surface, surfaceChild is at 0,0 as is its occlusion.
- EXPECT_EQ_RECT(IntRect(0, 0, 100, 50), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 100, 50), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
// The root layer always has a clipRect. So the parent of |surface| has a clipRect. However, the owning layer for |surface| does not
@@ -2406,26 +2402,65 @@ protected:
this->enterContributingSurface(surfaceChild, occlusion);
// The surfaceChild's parent does not have a clipRect as it owns a render surface. Make sure the unoccluded rect
// does not get clipped away inappropriately.
- EXPECT_EQ_RECT(IntRect(0, 40, 100, 10), occlusion.unoccludedContributingSurfaceContentRect(surfaceChild->renderSurface(), false, IntRect(0, 0, 100, 50)));
+ EXPECT_INT_RECT_EQ(IntRect(0, 40, 100, 10), occlusion.unoccludedContributingSurfaceContentRect(surfaceChild->renderSurface(), false, IntRect(0, 0, 100, 50)));
this->leaveContributingSurface(surfaceChild, occlusion);
// When the surfaceChild's occlusion is transformed up to its parent, make sure it is not clipped away inappropriately also.
this->enterLayer(surface, occlusion);
- EXPECT_EQ_RECT(IntRect(0, 0, 100, 60), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 100, 60), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(0, 10, 100, 50), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 10, 100, 50), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
this->leaveLayer(surface, occlusion);
this->enterContributingSurface(surface, occlusion);
// The surface's parent does have a clipRect as it is the root layer.
- EXPECT_EQ_RECT(IntRect(0, 50, 100, 50), occlusion.unoccludedContributingSurfaceContentRect(surface->renderSurface(), false, IntRect(0, 0, 100, 100)));
+ EXPECT_INT_RECT_EQ(IntRect(0, 50, 100, 50), occlusion.unoccludedContributingSurfaceContentRect(surface->renderSurface(), false, IntRect(0, 0, 100, 100)));
}
};
ALL_CCOCCLUSIONTRACKER_TEST(CCOcclusionTrackerTestSurfaceChildOfSurface);
template<class Types, bool opaqueLayers>
+class CCOcclusionTrackerTestTopmostSurfaceIsClippedToScissor : public CCOcclusionTrackerTest<Types, opaqueLayers> {
+protected:
+ void runMyTest()
+ {
+ // This test verifies that the top-most surface is considered occluded outside of its scissor rect and outside the screen's scissor rect.
+
+ typename Types::ContentLayerType* parent = this->createRoot(this->identityMatrix, FloatPoint(0, 0), IntSize(100, 200));
+ typename Types::LayerType* surface = this->createDrawingSurface(parent, this->identityMatrix, FloatPoint(0, 0), IntSize(100, 300), true);
+ this->calcDrawEtc(parent);
+
+ {
+ // Make a screen scissor rect that is larger than the root layer's.
+ TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 1000, 1000));
+
+ this->visitLayer(surface, occlusion);
+
+ // The root layer always has a clipRect. So the parent of |surface| has a clipRect giving the surface itself a clipRect.
+ this->enterContributingSurface(surface, occlusion);
+ // Make sure the parent's clipRect clips the unoccluded region of the child surface.
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 100, 200), occlusion.unoccludedContributingSurfaceContentRect(surface->renderSurface(), false, IntRect(0, 0, 100, 300)));
+ }
+ this->resetLayerIterator();
+ {
+ // Make a screen scissor rect that is smaller than the root layer's.
+ TestCCOcclusionTrackerWithScissor<typename Types::LayerType, typename Types::RenderSurfaceType> occlusion(IntRect(0, 0, 100, 100));
+
+ this->visitLayer(surface, occlusion);
+
+ // The root layer always has a clipRect. So the parent of |surface| has a clipRect giving the surface itself a clipRect.
+ this->enterContributingSurface(surface, occlusion);
+ // Make sure the screen scissor rect clips the unoccluded region of the child surface.
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 100, 100), occlusion.unoccludedContributingSurfaceContentRect(surface->renderSurface(), false, IntRect(0, 0, 100, 300)));
+ }
+ }
+};
+
+ALL_CCOCCLUSIONTRACKER_TEST(CCOcclusionTrackerTestTopmostSurfaceIsClippedToScissor);
+
+template<class Types, bool opaqueLayers>
class CCOcclusionTrackerTestSurfaceChildOfClippingSurface : public CCOcclusionTrackerTest<Types, opaqueLayers> {
protected:
void runMyTest()
@@ -2444,17 +2479,17 @@ protected:
// |topmost| occludes everything partially so we know occlusion is happening at all.
this->visitLayer(topmost, occlusion);
- EXPECT_EQ_RECT(IntRect(0, 0, 80, 50), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 80, 50), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(0, 0, 80, 50), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 80, 50), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
// surfaceChild is not opaque and does not occlude, so we have a non-empty unoccluded area on surface.
this->visitLayer(surfaceChild, occlusion);
- EXPECT_EQ_RECT(IntRect(0, 0, 80, 50), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 80, 50), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(0, 0, 0, 0), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 0, 0), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(0u, occlusion.occlusionInTargetSurface().rects().size());
// The root layer always has a clipRect. So the parent of |surface| has a clipRect. However, the owning layer for |surface| does not
@@ -2463,13 +2498,13 @@ protected:
this->enterContributingSurface(surfaceChild, occlusion);
// The surfaceChild's parent does not have a clipRect as it owns a render surface.
- EXPECT_EQ_RECT(IntRect(0, 50, 80, 50), occlusion.unoccludedContributingSurfaceContentRect(surfaceChild->renderSurface(), false, IntRect(0, 0, 100, 100)));
+ EXPECT_INT_RECT_EQ(IntRect(0, 50, 80, 50), occlusion.unoccludedContributingSurfaceContentRect(surfaceChild->renderSurface(), false, IntRect(0, 0, 100, 100)));
this->leaveContributingSurface(surfaceChild, occlusion);
this->visitLayer(surface, occlusion);
this->enterContributingSurface(surface, occlusion);
// The surface's parent does have a clipRect as it is the root layer.
- EXPECT_EQ_RECT(IntRect(0, 50, 80, 50), occlusion.unoccludedContributingSurfaceContentRect(surface->renderSurface(), false, IntRect(0, 0, 100, 100)));
+ EXPECT_INT_RECT_EQ(IntRect(0, 50, 80, 50), occlusion.unoccludedContributingSurfaceContentRect(surface->renderSurface(), false, IntRect(0, 0, 100, 100)));
}
};
@@ -2480,7 +2515,7 @@ class CCOcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilter : public
protected:
void runMyTest()
{
- TransformationMatrix scaleByHalf;
+ WebTransformationMatrix scaleByHalf;
scaleByHalf.scale(0.5);
// Make a surface and its replica, each 50x50, that are completely surrounded by opaque layers which are above them in the z-order.
@@ -2517,28 +2552,28 @@ protected:
this->visitLayer(occludingLayer2, occlusion);
this->visitLayer(occludingLayer1, occlusion);
- EXPECT_EQ_RECT(IntRect(0, 0, 300, 150), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 300, 150), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(5u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(0, 0, 300, 150), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 300, 150), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(5u, occlusion.occlusionInTargetSurface().rects().size());
// Everything outside the surface/replica is occluded but the surface/replica itself is not.
this->enterLayer(filteredSurface, occlusion);
- EXPECT_EQ_RECT(IntRect(1, 0, 99, 100), occlusion.unoccludedContentRect(filteredSurface, IntRect(1, 0, 100, 100)));
- EXPECT_EQ_RECT(IntRect(0, 1, 100, 99), occlusion.unoccludedContentRect(filteredSurface, IntRect(0, 1, 100, 100)));
- EXPECT_EQ_RECT(IntRect(0, 0, 99, 100), occlusion.unoccludedContentRect(filteredSurface, IntRect(-1, 0, 100, 100)));
- EXPECT_EQ_RECT(IntRect(0, 0, 100, 99), occlusion.unoccludedContentRect(filteredSurface, IntRect(0, -1, 100, 100)));
-
- EXPECT_EQ_RECT(IntRect(300 + 1, 0, 99, 100), occlusion.unoccludedContentRect(filteredSurface, IntRect(300 + 1, 0, 100, 100)));
- EXPECT_EQ_RECT(IntRect(300 + 0, 1, 100, 99), occlusion.unoccludedContentRect(filteredSurface, IntRect(300 + 0, 1, 100, 100)));
- EXPECT_EQ_RECT(IntRect(300 + 0, 0, 99, 100), occlusion.unoccludedContentRect(filteredSurface, IntRect(300 - 1, 0, 100, 100)));
- EXPECT_EQ_RECT(IntRect(300 + 0, 0, 100, 99), occlusion.unoccludedContentRect(filteredSurface, IntRect(300 + 0, -1, 100, 100)));
+ EXPECT_INT_RECT_EQ(IntRect(1, 0, 99, 100), occlusion.unoccludedContentRect(filteredSurface, IntRect(1, 0, 100, 100)));
+ EXPECT_INT_RECT_EQ(IntRect(0, 1, 100, 99), occlusion.unoccludedContentRect(filteredSurface, IntRect(0, 1, 100, 100)));
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 99, 100), occlusion.unoccludedContentRect(filteredSurface, IntRect(-1, 0, 100, 100)));
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 100, 99), occlusion.unoccludedContentRect(filteredSurface, IntRect(0, -1, 100, 100)));
+
+ EXPECT_INT_RECT_EQ(IntRect(300 + 1, 0, 99, 100), occlusion.unoccludedContentRect(filteredSurface, IntRect(300 + 1, 0, 100, 100)));
+ EXPECT_INT_RECT_EQ(IntRect(300 + 0, 1, 100, 99), occlusion.unoccludedContentRect(filteredSurface, IntRect(300 + 0, 1, 100, 100)));
+ EXPECT_INT_RECT_EQ(IntRect(300 + 0, 0, 99, 100), occlusion.unoccludedContentRect(filteredSurface, IntRect(300 - 1, 0, 100, 100)));
+ EXPECT_INT_RECT_EQ(IntRect(300 + 0, 0, 100, 99), occlusion.unoccludedContentRect(filteredSurface, IntRect(300 + 0, -1, 100, 100)));
this->leaveLayer(filteredSurface, occlusion);
// The filtered layer/replica does not occlude.
- EXPECT_EQ_RECT(IntRect(0, 0, 300, 150), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 300, 150), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(5u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(0, 0, 0, 0), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 0, 0), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(0u, occlusion.occlusionInTargetSurface().rects().size());
// The surface has a background blur, so it needs pixels that are currently considered occluded in order to be drawn. So the pixels
@@ -2546,9 +2581,9 @@ protected:
this->visitContributingSurface(filteredSurface, occlusion);
this->enterLayer(parent, occlusion);
- EXPECT_EQ_RECT(IntRect(0, 0, 300, 150), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 300, 150), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(5u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(0, 0, 300, 150), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 300, 150), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(5u, occlusion.occlusionInTargetSurface().rects().size());
IntRect outsetRect;
@@ -2557,44 +2592,44 @@ protected:
// Nothing in the blur outsets for the filteredSurface is occluded.
outsetRect = IntRect(50 - outsetLeft, 50 - outsetTop, 50 + outsetLeft + outsetRight, 50 + outsetTop + outsetBottom);
testRect = outsetRect;
- EXPECT_EQ_RECT(outsetRect, occlusion.unoccludedContentRect(parent, testRect));
+ EXPECT_INT_RECT_EQ(outsetRect, occlusion.unoccludedContentRect(parent, testRect));
// Stuff outside the blur outsets is still occluded though.
testRect = outsetRect;
testRect.expand(1, 0);
- EXPECT_EQ_RECT(outsetRect, occlusion.unoccludedContentRect(parent, testRect));
+ EXPECT_INT_RECT_EQ(outsetRect, occlusion.unoccludedContentRect(parent, testRect));
testRect = outsetRect;
testRect.expand(0, 1);
- EXPECT_EQ_RECT(outsetRect, occlusion.unoccludedContentRect(parent, testRect));
+ EXPECT_INT_RECT_EQ(outsetRect, occlusion.unoccludedContentRect(parent, testRect));
testRect = outsetRect;
testRect.move(-1, 0);
testRect.expand(1, 0);
- EXPECT_EQ_RECT(outsetRect, occlusion.unoccludedContentRect(parent, testRect));
+ EXPECT_INT_RECT_EQ(outsetRect, occlusion.unoccludedContentRect(parent, testRect));
testRect = outsetRect;
testRect.move(0, -1);
testRect.expand(0, 1);
- EXPECT_EQ_RECT(outsetRect, occlusion.unoccludedContentRect(parent, testRect));
+ EXPECT_INT_RECT_EQ(outsetRect, occlusion.unoccludedContentRect(parent, testRect));
// Nothing in the blur outsets for the filteredSurface's replica is occluded.
outsetRect = IntRect(200 - outsetLeft, 50 - outsetTop, 50 + outsetLeft + outsetRight, 50 + outsetTop + outsetBottom);
testRect = outsetRect;
- EXPECT_EQ_RECT(outsetRect, occlusion.unoccludedContentRect(parent, testRect));
+ EXPECT_INT_RECT_EQ(outsetRect, occlusion.unoccludedContentRect(parent, testRect));
// Stuff outside the blur outsets is still occluded though.
testRect = outsetRect;
testRect.expand(1, 0);
- EXPECT_EQ_RECT(outsetRect, occlusion.unoccludedContentRect(parent, testRect));
+ EXPECT_INT_RECT_EQ(outsetRect, occlusion.unoccludedContentRect(parent, testRect));
testRect = outsetRect;
testRect.expand(0, 1);
- EXPECT_EQ_RECT(outsetRect, occlusion.unoccludedContentRect(parent, testRect));
+ EXPECT_INT_RECT_EQ(outsetRect, occlusion.unoccludedContentRect(parent, testRect));
testRect = outsetRect;
testRect.move(-1, 0);
testRect.expand(1, 0);
- EXPECT_EQ_RECT(outsetRect, occlusion.unoccludedContentRect(parent, testRect));
+ EXPECT_INT_RECT_EQ(outsetRect, occlusion.unoccludedContentRect(parent, testRect));
testRect = outsetRect;
testRect.move(0, -1);
testRect.expand(0, 1);
- EXPECT_EQ_RECT(outsetRect, occlusion.unoccludedContentRect(parent, testRect));
+ EXPECT_INT_RECT_EQ(outsetRect, occlusion.unoccludedContentRect(parent, testRect));
}
};
@@ -2605,7 +2640,7 @@ class CCOcclusionTrackerTestTwoBackgroundFiltersReduceOcclusionTwice : public CC
protected:
void runMyTest()
{
- TransformationMatrix scaleByHalf;
+ WebTransformationMatrix scaleByHalf;
scaleByHalf.scale(0.5);
// Makes two surfaces that completely cover |parent|. The occlusion both above and below the filters will be reduced by each of them.
@@ -2632,9 +2667,9 @@ protected:
occlusion.setLayerScissorRect(IntRect(0, 0, 1000, 1000));
this->visitLayer(occludingLayerAbove, occlusion);
- EXPECT_EQ_RECT(IntRect(100 / 2, 100 / 2, 50 / 2, 50 / 2), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(100 / 2, 100 / 2, 50 / 2, 50 / 2), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(100, 100, 50, 50), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(100, 100, 50, 50), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
this->visitLayer(filteredSurface2, occlusion);
@@ -2647,7 +2682,7 @@ protected:
// Test expectations in the target.
IntRect expectedOcclusion = IntRect(100 + outsetRight * 2, 100 + outsetBottom * 2, 50 - (outsetLeft + outsetRight) * 2, 50 - (outsetTop + outsetBottom) * 2);
- EXPECT_EQ_RECT(expectedOcclusion, occlusion.occlusionInTargetSurface().rects()[0]);
+ EXPECT_INT_RECT_EQ(expectedOcclusion, occlusion.occlusionInTargetSurface().rects()[0]);
// Test expectations in the screen. Take the ceiling of half of the outsets.
outsetTop = (outsetTop + 1) / 2;
@@ -2656,7 +2691,7 @@ protected:
outsetLeft = (outsetLeft + 1) / 2;
expectedOcclusion = IntRect(100 / 2 + outsetRight * 2, 100 / 2 + outsetBottom * 2, 50 / 2 - (outsetLeft + outsetRight) * 2, 50 /2 - (outsetTop + outsetBottom) * 2);
- EXPECT_EQ_RECT(expectedOcclusion, occlusion.occlusionInScreenSpace().rects()[0]);
+ EXPECT_INT_RECT_EQ(expectedOcclusion, occlusion.occlusionInScreenSpace().rects()[0]);
}
};
@@ -2703,28 +2738,28 @@ protected:
this->visitLayer(occludingLayer2, occlusion);
this->visitLayer(occludingLayer1, occlusion);
- EXPECT_EQ_RECT(IntRect(0, 0, 300, 150), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 300, 150), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(5u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(0, 0, 300, 150), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 300, 150), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(5u, occlusion.occlusionInTargetSurface().rects().size());
// Everything outside the surface/replica is occluded but the surface/replica itself is not.
this->enterLayer(filteredSurface, occlusion);
- EXPECT_EQ_RECT(IntRect(1, 0, 49, 50), occlusion.unoccludedContentRect(filteredSurface, IntRect(1, 0, 50, 50)));
- EXPECT_EQ_RECT(IntRect(0, 1, 50, 49), occlusion.unoccludedContentRect(filteredSurface, IntRect(0, 1, 50, 50)));
- EXPECT_EQ_RECT(IntRect(0, 0, 49, 50), occlusion.unoccludedContentRect(filteredSurface, IntRect(-1, 0, 50, 50)));
- EXPECT_EQ_RECT(IntRect(0, 0, 50, 49), occlusion.unoccludedContentRect(filteredSurface, IntRect(0, -1, 50, 50)));
-
- EXPECT_EQ_RECT(IntRect(150 + 1, 0, 49, 50), occlusion.unoccludedContentRect(filteredSurface, IntRect(150 + 1, 0, 50, 50)));
- EXPECT_EQ_RECT(IntRect(150 + 0, 1, 50, 49), occlusion.unoccludedContentRect(filteredSurface, IntRect(150 + 0, 1, 50, 50)));
- EXPECT_EQ_RECT(IntRect(150 + 0, 0, 49, 50), occlusion.unoccludedContentRect(filteredSurface, IntRect(150 - 1, 0, 50, 50)));
- EXPECT_EQ_RECT(IntRect(150 + 0, 0, 50, 49), occlusion.unoccludedContentRect(filteredSurface, IntRect(150 + 0, -1, 50, 50)));
+ EXPECT_INT_RECT_EQ(IntRect(1, 0, 49, 50), occlusion.unoccludedContentRect(filteredSurface, IntRect(1, 0, 50, 50)));
+ EXPECT_INT_RECT_EQ(IntRect(0, 1, 50, 49), occlusion.unoccludedContentRect(filteredSurface, IntRect(0, 1, 50, 50)));
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 49, 50), occlusion.unoccludedContentRect(filteredSurface, IntRect(-1, 0, 50, 50)));
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 50, 49), occlusion.unoccludedContentRect(filteredSurface, IntRect(0, -1, 50, 50)));
+
+ EXPECT_INT_RECT_EQ(IntRect(150 + 1, 0, 49, 50), occlusion.unoccludedContentRect(filteredSurface, IntRect(150 + 1, 0, 50, 50)));
+ EXPECT_INT_RECT_EQ(IntRect(150 + 0, 1, 50, 49), occlusion.unoccludedContentRect(filteredSurface, IntRect(150 + 0, 1, 50, 50)));
+ EXPECT_INT_RECT_EQ(IntRect(150 + 0, 0, 49, 50), occlusion.unoccludedContentRect(filteredSurface, IntRect(150 - 1, 0, 50, 50)));
+ EXPECT_INT_RECT_EQ(IntRect(150 + 0, 0, 50, 49), occlusion.unoccludedContentRect(filteredSurface, IntRect(150 + 0, -1, 50, 50)));
this->leaveLayer(filteredSurface, occlusion);
// The filtered layer/replica does not occlude.
- EXPECT_EQ_RECT(IntRect(0, 0, 300, 150), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 300, 150), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(5u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(0, 0, 0, 0), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 0, 0), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(0u, occlusion.occlusionInTargetSurface().rects().size());
// The surface has a background blur, so it needs pixels that are currently considered occluded in order to be drawn. So the pixels
@@ -2732,7 +2767,7 @@ protected:
this->visitContributingSurface(filteredSurface, occlusion);
this->enterContributingSurface(clippingSurface, occlusion);
- EXPECT_EQ_RECT(IntRect(0, 0, 300, 150), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(0, 0, 300, 150), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(5u, occlusion.occlusionInScreenSpace().rects().size());
IntRect outsetRect;
@@ -2743,45 +2778,45 @@ protected:
outsetRect = IntRect(50 - outsetLeft, 50 - outsetTop, 50 + outsetLeft + outsetRight, 50 + outsetTop + outsetBottom);
clippedOutsetRect = intersection(outsetRect, IntRect(0 - outsetLeft, 0 - outsetTop, 300 + outsetLeft + outsetRight, 70 + outsetTop + outsetBottom));
testRect = outsetRect;
- EXPECT_EQ_RECT(clippedOutsetRect, occlusion.unoccludedContentRect(clippingSurface, testRect));
+ EXPECT_INT_RECT_EQ(clippedOutsetRect, occlusion.unoccludedContentRect(clippingSurface, testRect));
// Stuff outside the (clipped) blur outsets is still occluded though.
testRect = outsetRect;
testRect.expand(1, 0);
- EXPECT_EQ_RECT(clippedOutsetRect, occlusion.unoccludedContentRect(clippingSurface, testRect));
+ EXPECT_INT_RECT_EQ(clippedOutsetRect, occlusion.unoccludedContentRect(clippingSurface, testRect));
testRect = outsetRect;
testRect.expand(0, 1);
- EXPECT_EQ_RECT(clippedOutsetRect, occlusion.unoccludedContentRect(clippingSurface, testRect));
+ EXPECT_INT_RECT_EQ(clippedOutsetRect, occlusion.unoccludedContentRect(clippingSurface, testRect));
testRect = outsetRect;
testRect.move(-1, 0);
testRect.expand(1, 0);
- EXPECT_EQ_RECT(clippedOutsetRect, occlusion.unoccludedContentRect(clippingSurface, testRect));
+ EXPECT_INT_RECT_EQ(clippedOutsetRect, occlusion.unoccludedContentRect(clippingSurface, testRect));
testRect = outsetRect;
testRect.move(0, -1);
testRect.expand(0, 1);
- EXPECT_EQ_RECT(clippedOutsetRect, occlusion.unoccludedContentRect(clippingSurface, testRect));
+ EXPECT_INT_RECT_EQ(clippedOutsetRect, occlusion.unoccludedContentRect(clippingSurface, testRect));
// Nothing in the (clipped) blur outsets for the filteredSurface's replica is occluded.
outsetRect = IntRect(200 - outsetLeft, 50 - outsetTop, 50 + outsetLeft + outsetRight, 50 + outsetTop + outsetBottom);
clippedOutsetRect = intersection(outsetRect, IntRect(0 - outsetLeft, 0 - outsetTop, 300 + outsetLeft + outsetRight, 70 + outsetTop + outsetBottom));
testRect = outsetRect;
- EXPECT_EQ_RECT(clippedOutsetRect, occlusion.unoccludedContentRect(clippingSurface, testRect));
+ EXPECT_INT_RECT_EQ(clippedOutsetRect, occlusion.unoccludedContentRect(clippingSurface, testRect));
// Stuff outside the (clipped) blur outsets is still occluded though.
testRect = outsetRect;
testRect.expand(1, 0);
- EXPECT_EQ_RECT(clippedOutsetRect, occlusion.unoccludedContentRect(clippingSurface, testRect));
+ EXPECT_INT_RECT_EQ(clippedOutsetRect, occlusion.unoccludedContentRect(clippingSurface, testRect));
testRect = outsetRect;
testRect.expand(0, 1);
- EXPECT_EQ_RECT(clippedOutsetRect, occlusion.unoccludedContentRect(clippingSurface, testRect));
+ EXPECT_INT_RECT_EQ(clippedOutsetRect, occlusion.unoccludedContentRect(clippingSurface, testRect));
testRect = outsetRect;
testRect.move(-1, 0);
testRect.expand(1, 0);
- EXPECT_EQ_RECT(clippedOutsetRect, occlusion.unoccludedContentRect(clippingSurface, testRect));
+ EXPECT_INT_RECT_EQ(clippedOutsetRect, occlusion.unoccludedContentRect(clippingSurface, testRect));
testRect = outsetRect;
testRect.move(0, -1);
testRect.expand(0, 1);
- EXPECT_EQ_RECT(clippedOutsetRect, occlusion.unoccludedContentRect(clippingSurface, testRect));
+ EXPECT_INT_RECT_EQ(clippedOutsetRect, occlusion.unoccludedContentRect(clippingSurface, testRect));
}
};
@@ -2792,7 +2827,7 @@ class CCOcclusionTrackerTestDontReduceOcclusionBelowBackgroundFilter : public CC
protected:
void runMyTest()
{
- TransformationMatrix scaleByHalf;
+ WebTransformationMatrix scaleByHalf;
scaleByHalf.scale(0.5);
// Make a surface and its replica, each 50x50, with a smaller 30x30 layer centered below each.
@@ -2827,9 +2862,9 @@ protected:
IntRect occlusionBehindReplica = IntRect(210, 60, 30, 30);
IntRect expectedOpaqueBounds = unionRect(occlusionBehindSurface, occlusionBehindReplica);
- EXPECT_EQ_RECT(expectedOpaqueBounds, occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(expectedOpaqueBounds, occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(2u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(expectedOpaqueBounds, occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(expectedOpaqueBounds, occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(2u, occlusion.occlusionInTargetSurface().rects().size());
}
};
@@ -2841,7 +2876,7 @@ class CCOcclusionTrackerTestDontReduceOcclusionIfBackgroundFilterIsOccluded : pu
protected:
void runMyTest()
{
- TransformationMatrix scaleByHalf;
+ WebTransformationMatrix scaleByHalf;
scaleByHalf.scale(0.5);
// Make a surface and its replica, each 50x50, that are completely occluded by opaque layers which are above them in the z-order.
@@ -2875,9 +2910,9 @@ protected:
IntRect occlusionAboveReplica = IntRect(200, 50, 50, 50);
IntRect expectedOpaqueBounds = unionRect(occlusionAboveSurface, occlusionAboveReplica);
- EXPECT_EQ_RECT(expectedOpaqueBounds, occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(expectedOpaqueBounds, occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(2u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(expectedOpaqueBounds, occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(expectedOpaqueBounds, occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(2u, occlusion.occlusionInTargetSurface().rects().size());
}
};
@@ -2889,7 +2924,7 @@ class CCOcclusionTrackerTestReduceOcclusionWhenBackgroundFilterIsPartiallyOcclud
protected:
void runMyTest()
{
- TransformationMatrix scaleByHalf;
+ WebTransformationMatrix scaleByHalf;
scaleByHalf.scale(0.5);
// Make a surface and its replica, each 50x50, that are partially occluded by opaque layers which are above them in the z-order.
@@ -2976,17 +3011,17 @@ protected:
// The small layer is not tracked because it is too small.
this->visitLayer(small, occlusion);
- EXPECT_EQ_RECT(IntRect(), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(0u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(0u, occlusion.occlusionInTargetSurface().rects().size());
// The large layer is tracked as it is large enough.
this->visitLayer(large, occlusion);
- EXPECT_EQ_RECT(IntRect(IntPoint(), trackingSize), occlusion.occlusionInScreenSpace().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(IntPoint(), trackingSize), occlusion.occlusionInScreenSpace().bounds());
EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size());
- EXPECT_EQ_RECT(IntRect(IntPoint(), trackingSize), occlusion.occlusionInTargetSurface().bounds());
+ EXPECT_INT_RECT_EQ(IntRect(IntPoint(), trackingSize), occlusion.occlusionInTargetSurface().bounds());
EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size());
}
};
diff --git a/Source/WebKit/chromium/tests/CCQuadCullerTest.cpp b/Source/WebKit/chromium/tests/CCQuadCullerTest.cpp
index 634a25c7a..1a119d708 100644
--- a/Source/WebKit/chromium/tests/CCQuadCullerTest.cpp
+++ b/Source/WebKit/chromium/tests/CCQuadCullerTest.cpp
@@ -33,8 +33,10 @@
#include "cc/CCTileDrawQuad.h"
#include <gmock/gmock.h>
#include <gtest/gtest.h>
+#include <public/WebTransformationMatrix.h>
using namespace WebCore;
+using WebKit::WebTransformationMatrix;
namespace {
@@ -55,7 +57,7 @@ private:
typedef CCLayerIterator<CCLayerImpl, Vector<CCLayerImpl*>, CCRenderSurface, CCLayerIteratorActions::FrontToBack> CCLayerIteratorType;
-static PassOwnPtr<CCTiledLayerImpl> makeLayer(CCTiledLayerImpl* parent, const TransformationMatrix& drawTransform, const IntRect& layerRect, float opacity, bool opaque, const IntRect& layerOpaqueRect, Vector<CCLayerImpl*>& surfaceLayerList)
+static PassOwnPtr<CCTiledLayerImpl> makeLayer(CCTiledLayerImpl* parent, const WebTransformationMatrix& drawTransform, const IntRect& layerRect, float opacity, bool opaque, const IntRect& layerOpaqueRect, Vector<CCLayerImpl*>& surfaceLayerList)
{
OwnPtr<CCTiledLayerImpl> layer = CCTiledLayerImpl::create(0);
OwnPtr<CCLayerTilingData> tiler = CCLayerTilingData::create(IntSize(100, 100), CCLayerTilingData::NoBorderTexels);
@@ -105,7 +107,7 @@ static void appendQuads(CCQuadList& quadList, Vector<OwnPtr<CCSharedQuadState> >
CCQuadList quadList; \
Vector<OwnPtr<CCSharedQuadState> > sharedStateList; \
Vector<CCLayerImpl*> renderSurfaceLayerList; \
- TransformationMatrix childTransform; \
+ WebTransformationMatrix childTransform; \
IntSize rootSize = IntSize(300, 300); \
IntRect rootRect = IntRect(IntPoint(), rootSize); \
IntSize childSize = IntSize(200, 200); \
@@ -115,8 +117,8 @@ TEST(CCQuadCullerTest, verifyNoCulling)
{
DECLARE_AND_INITIALIZE_TEST_QUADS
- OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, TransformationMatrix(), rootRect, 1.0, true, IntRect(), renderSurfaceLayerList);
- OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), TransformationMatrix(), childRect, 1.0, false, IntRect(), renderSurfaceLayerList);
+ OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1.0, true, IntRect(), renderSurfaceLayerList);
+ OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), WebTransformationMatrix(), childRect, 1.0, false, IntRect(), renderSurfaceLayerList);
TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000));
CCLayerIteratorType it = CCLayerIteratorType::begin(&renderSurfaceLayerList);
@@ -132,8 +134,8 @@ TEST(CCQuadCullerTest, verifyCullChildLinesUpTopLeft)
{
DECLARE_AND_INITIALIZE_TEST_QUADS
- OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, TransformationMatrix(), rootRect, 1.0, true, IntRect(), renderSurfaceLayerList);
- OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), TransformationMatrix(), childRect, 1.0, true, IntRect(), renderSurfaceLayerList);
+ OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1.0, true, IntRect(), renderSurfaceLayerList);
+ OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), WebTransformationMatrix(), childRect, 1.0, true, IntRect(), renderSurfaceLayerList);
TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000));
CCLayerIteratorType it = CCLayerIteratorType::begin(&renderSurfaceLayerList);
@@ -149,7 +151,7 @@ TEST(CCQuadCullerTest, verifyCullWhenChildOpacityNotOne)
{
DECLARE_AND_INITIALIZE_TEST_QUADS
- OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, TransformationMatrix(), rootRect, 1, true, IntRect(), renderSurfaceLayerList);
+ OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1, true, IntRect(), renderSurfaceLayerList);
OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 0.9f, true, IntRect(), renderSurfaceLayerList);
TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000));
CCLayerIteratorType it = CCLayerIteratorType::begin(&renderSurfaceLayerList);
@@ -166,7 +168,7 @@ TEST(CCQuadCullerTest, verifyCullWhenChildOpaqueFlagFalse)
{
DECLARE_AND_INITIALIZE_TEST_QUADS
- OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, TransformationMatrix(), rootRect, 1.0, true, IntRect(), renderSurfaceLayerList);
+ OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1.0, true, IntRect(), renderSurfaceLayerList);
OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1.0, false, IntRect(), renderSurfaceLayerList);
TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000));
CCLayerIteratorType it = CCLayerIteratorType::begin(&renderSurfaceLayerList);
@@ -185,7 +187,7 @@ TEST(CCQuadCullerTest, verifyCullCenterTileOnly)
childTransform.translate(50, 50);
- OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, TransformationMatrix(), rootRect, 1.0, true, IntRect(), renderSurfaceLayerList);
+ OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1.0, true, IntRect(), renderSurfaceLayerList);
OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1.0, true, IntRect(), renderSurfaceLayerList);
TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000));
CCLayerIteratorType it = CCLayerIteratorType::begin(&renderSurfaceLayerList);
@@ -222,7 +224,7 @@ TEST(CCQuadCullerTest, verifyCullCenterTileNonIntegralSize1)
// Make the root layer's quad have extent (99.1, 99.1) -> (200.9, 200.9) to make
// sure it doesn't get culled due to transform rounding.
- TransformationMatrix rootTransform;
+ WebTransformationMatrix rootTransform;
rootTransform.translate(99.1, 99.1);
rootTransform.scale(1.018);
@@ -251,7 +253,7 @@ TEST(CCQuadCullerTest, verifyCullCenterTileNonIntegralSize2)
childTransform.translate(100.1, 100.1);
childTransform.scale(0.982);
- TransformationMatrix rootTransform;
+ WebTransformationMatrix rootTransform;
rootTransform.translate(100, 100);
rootRect = childRect = IntRect(0, 0, 100, 100);
@@ -276,7 +278,7 @@ TEST(CCQuadCullerTest, verifyCullChildLinesUpBottomRight)
childTransform.translate(100, 100);
- OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, TransformationMatrix(), rootRect, 1.0, true, IntRect(), renderSurfaceLayerList);
+ OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1.0, true, IntRect(), renderSurfaceLayerList);
OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1.0, true, IntRect(), renderSurfaceLayerList);
TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000));
CCLayerIteratorType it = CCLayerIteratorType::begin(&renderSurfaceLayerList);
@@ -295,7 +297,7 @@ TEST(CCQuadCullerTest, verifyCullSubRegion)
childTransform.translate(50, 50);
- OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, TransformationMatrix(), rootRect, 1.0, true, IntRect(), renderSurfaceLayerList);
+ OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1.0, true, IntRect(), renderSurfaceLayerList);
IntRect childOpaqueRect(childRect.x() + childRect.width() / 4, childRect.y() + childRect.height() / 4, childRect.width() / 2, childRect.height() / 2);
OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1.0, false, childOpaqueRect, renderSurfaceLayerList);
TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000));
@@ -315,7 +317,7 @@ TEST(CCQuadCullerTest, verifyCullSubRegion2)
childTransform.translate(50, 10);
- OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, TransformationMatrix(), rootRect, 1.0, true, IntRect(), renderSurfaceLayerList);
+ OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1.0, true, IntRect(), renderSurfaceLayerList);
IntRect childOpaqueRect(childRect.x() + childRect.width() / 4, childRect.y() + childRect.height() / 4, childRect.width() / 2, childRect.height() * 3 / 4);
OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1.0, false, childOpaqueRect, renderSurfaceLayerList);
TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000));
@@ -335,7 +337,7 @@ TEST(CCQuadCullerTest, verifyCullSubRegionCheckOvercull)
childTransform.translate(50, 49);
- OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, TransformationMatrix(), rootRect, 1.0, true, IntRect(), renderSurfaceLayerList);
+ OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1.0, true, IntRect(), renderSurfaceLayerList);
IntRect childOpaqueRect(childRect.x() + childRect.width() / 4, childRect.y() + childRect.height() / 4, childRect.width() / 2, childRect.height() / 2);
OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1.0, false, childOpaqueRect, renderSurfaceLayerList);
TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000));
@@ -356,7 +358,7 @@ TEST(CCQuadCullerTest, verifyNonAxisAlignedQuadsDontOcclude)
// Use a small rotation so as to not disturb the geometry significantly.
childTransform.rotate(1);
- OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, TransformationMatrix(), rootRect, 1.0, true, IntRect(), renderSurfaceLayerList);
+ OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1.0, true, IntRect(), renderSurfaceLayerList);
OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1.0, true, IntRect(), renderSurfaceLayerList);
TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000));
CCLayerIteratorType it = CCLayerIteratorType::begin(&renderSurfaceLayerList);
@@ -379,11 +381,11 @@ TEST(CCQuadCullerTest, verifyNonAxisAlignedQuadsSafelyCulled)
DECLARE_AND_INITIALIZE_TEST_QUADS
// Use a small rotation so as to not disturb the geometry significantly.
- TransformationMatrix parentTransform;
+ WebTransformationMatrix parentTransform;
parentTransform.rotate(1);
OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, parentTransform, rootRect, 1.0, true, IntRect(), renderSurfaceLayerList);
- OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), TransformationMatrix(), childRect, 1.0, true, IntRect(), renderSurfaceLayerList);
+ OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), WebTransformationMatrix(), childRect, 1.0, true, IntRect(), renderSurfaceLayerList);
TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000));
CCLayerIteratorType it = CCLayerIteratorType::begin(&renderSurfaceLayerList);
@@ -399,8 +401,8 @@ TEST(CCQuadCullerTest, verifyCullOutsideScissorOverTile)
{
DECLARE_AND_INITIALIZE_TEST_QUADS
- OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, TransformationMatrix(), rootRect, 1.0, true, IntRect(), renderSurfaceLayerList);
- OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), TransformationMatrix(), childRect, 1.0, true, IntRect(), renderSurfaceLayerList);
+ OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1.0, true, IntRect(), renderSurfaceLayerList);
+ OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), WebTransformationMatrix(), childRect, 1.0, true, IntRect(), renderSurfaceLayerList);
TestCCOcclusionTrackerImpl occlusionTracker(IntRect(200, 100, 100, 100));
CCLayerIteratorType it = CCLayerIteratorType::begin(&renderSurfaceLayerList);
@@ -416,8 +418,8 @@ TEST(CCQuadCullerTest, verifyCullOutsideScissorOverCulledTile)
{
DECLARE_AND_INITIALIZE_TEST_QUADS
- OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, TransformationMatrix(), rootRect, 1.0, true, IntRect(), renderSurfaceLayerList);
- OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), TransformationMatrix(), childRect, 1.0, true, IntRect(), renderSurfaceLayerList);
+ OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1.0, true, IntRect(), renderSurfaceLayerList);
+ OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), WebTransformationMatrix(), childRect, 1.0, true, IntRect(), renderSurfaceLayerList);
TestCCOcclusionTrackerImpl occlusionTracker(IntRect(100, 100, 100, 100));
CCLayerIteratorType it = CCLayerIteratorType::begin(&renderSurfaceLayerList);
@@ -433,8 +435,8 @@ TEST(CCQuadCullerTest, verifyCullOutsideScissorOverPartialTiles)
{
DECLARE_AND_INITIALIZE_TEST_QUADS
- OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, TransformationMatrix(), rootRect, 1.0, true, IntRect(), renderSurfaceLayerList);
- OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), TransformationMatrix(), childRect, 1.0, true, IntRect(), renderSurfaceLayerList);
+ OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1.0, true, IntRect(), renderSurfaceLayerList);
+ OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), WebTransformationMatrix(), childRect, 1.0, true, IntRect(), renderSurfaceLayerList);
TestCCOcclusionTrackerImpl occlusionTracker(IntRect(50, 50, 200, 200));
CCLayerIteratorType it = CCLayerIteratorType::begin(&renderSurfaceLayerList);
@@ -450,8 +452,8 @@ TEST(CCQuadCullerTest, verifyCullOutsideScissorOverNoTiles)
{
DECLARE_AND_INITIALIZE_TEST_QUADS
- OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, TransformationMatrix(), rootRect, 1.0, true, IntRect(), renderSurfaceLayerList);
- OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), TransformationMatrix(), childRect, 1.0, true, IntRect(), renderSurfaceLayerList);
+ OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1.0, true, IntRect(), renderSurfaceLayerList);
+ OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), WebTransformationMatrix(), childRect, 1.0, true, IntRect(), renderSurfaceLayerList);
TestCCOcclusionTrackerImpl occlusionTracker(IntRect(500, 500, 100, 100));
CCLayerIteratorType it = CCLayerIteratorType::begin(&renderSurfaceLayerList);
@@ -467,8 +469,8 @@ TEST(CCQuadCullerTest, verifyWithoutMetrics)
{
DECLARE_AND_INITIALIZE_TEST_QUADS
- OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, TransformationMatrix(), rootRect, 1.0, true, IntRect(), renderSurfaceLayerList);
- OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), TransformationMatrix(), childRect, 1.0, true, IntRect(), renderSurfaceLayerList);
+ OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, WebTransformationMatrix(), rootRect, 1.0, true, IntRect(), renderSurfaceLayerList);
+ OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), WebTransformationMatrix(), childRect, 1.0, true, IntRect(), renderSurfaceLayerList);
TestCCOcclusionTrackerImpl occlusionTracker(IntRect(50, 50, 200, 200), false);
CCLayerIteratorType it = CCLayerIteratorType::begin(&renderSurfaceLayerList);
diff --git a/Source/WebKit/chromium/tests/CCRenderSurfaceTest.cpp b/Source/WebKit/chromium/tests/CCRenderSurfaceTest.cpp
index 7dac005d2..5cbe7fc54 100644
--- a/Source/WebKit/chromium/tests/CCRenderSurfaceTest.cpp
+++ b/Source/WebKit/chromium/tests/CCRenderSurfaceTest.cpp
@@ -26,14 +26,15 @@
#include "cc/CCRenderSurface.h"
-#include "TransformationMatrix.h"
#include "cc/CCLayerImpl.h"
#include "cc/CCSharedQuadState.h"
#include "cc/CCSingleThreadProxy.h"
#include <gmock/gmock.h>
#include <gtest/gtest.h>
+#include <public/WebTransformationMatrix.h>
using namespace WebCore;
+using WebKit::WebTransformationMatrix;
namespace {
@@ -77,7 +78,7 @@ TEST(CCRenderSurfaceTest, verifySurfaceChangesAreTrackedProperly)
EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setContentRect(testRect));
OwnPtr<CCLayerImpl> dummyMask = CCLayerImpl::create(1);
- TransformationMatrix dummyMatrix;
+ WebTransformationMatrix dummyMatrix;
dummyMatrix.translate(1.0, 2.0);
// The rest of the surface properties are either internal and should not cause change,
@@ -86,9 +87,7 @@ TEST(CCRenderSurfaceTest, verifySurfaceChangesAreTrackedProperly)
EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setDrawTransform(dummyMatrix));
EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setReplicaDrawTransform(dummyMatrix));
EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setOriginTransform(dummyMatrix));
- EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setSkipsDraw(true));
EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->clearLayerList());
- EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setMaskLayer(dummyMask.get()));
}
TEST(CCRenderSurfaceTest, sanityCheckSurfaceCreatesCorrectSharedQuadState)
@@ -103,8 +102,8 @@ TEST(CCRenderSurfaceTest, sanityCheckSurfaceCreatesCorrectSharedQuadState)
IntRect contentRect = IntRect(IntPoint::zero(), IntSize(50, 50));
IntRect clipRect = IntRect(IntPoint(5, 5), IntSize(40, 40));
- TransformationMatrix draw;
- TransformationMatrix origin;
+ WebTransformationMatrix draw;
+ WebTransformationMatrix origin;
draw.translate(30, 40);
diff --git a/Source/WebKit/chromium/tests/DecimalTest.cpp b/Source/WebKit/chromium/tests/DecimalTest.cpp
new file mode 100644
index 000000000..db69edd38
--- /dev/null
+++ b/Source/WebKit/chromium/tests/DecimalTest.cpp
@@ -0,0 +1,971 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "Decimal.h"
+
+#include <gtest/gtest.h>
+#include <wtf/MathExtras.h>
+#include <wtf/text/CString.h>
+
+namespace WebCore {
+
+std::ostream& operator<<(std::ostream& os, const Decimal& decimal)
+{
+ Decimal::EncodedData data = decimal.value();
+ return os
+ << "encode(" << String::number(data.coefficient()).ascii().data()
+ << ", " << String::number(data.exponent()).ascii().data()
+ << ", " << (data.sign() == Decimal::Negative ? "Negative" : "Positive")
+ << ")=" << decimal.toString().ascii().data();
+}
+
+} // namespace WebCore
+
+using namespace WebCore;
+
+// Simulate WebCore/html/StepRange
+class DecimalStepRange {
+public:
+ Decimal maximum;
+ Decimal minimum;
+ Decimal step;
+
+ DecimalStepRange(const Decimal& minimum, const Decimal& maximum, const Decimal& step)
+ : maximum(maximum)
+ , minimum(minimum)
+ , step(step)
+ {
+ }
+
+ Decimal clampValue(Decimal value) const
+ {
+ const Decimal result = minimum + ((value - minimum) / step).round() * step;
+ ASSERT(result.isFinite());
+ return result > maximum ? result - step : result;
+ }
+};
+
+class DecimalTest : public ::testing::Test {
+protected:
+ typedef Decimal::Sign Sign;
+ protected: static const Sign Positive = Decimal::Positive;
+ protected: static const Sign Negative = Decimal::Negative;
+
+ Decimal encode(uint64_t coefficient, int exponent, Sign sign)
+ {
+ return Decimal(sign, exponent, coefficient);
+ }
+
+ protected: Decimal fromString(const String& string)
+ {
+ return Decimal::fromString(string);
+ }
+
+ protected: String stepDown(const String& minimum, const String& maximum, const String& step, const String& valueString, int numberOfStepTimes)
+ {
+ DecimalStepRange stepRange(fromString(minimum), fromString(maximum), fromString(step));
+ Decimal value = fromString(valueString);
+ for (int i = 0; i < numberOfStepTimes; ++i) {
+ value -= stepRange.step;
+ value = stepRange.clampValue(value);
+ }
+ return value.toString();
+ }
+
+ protected: String stepUp(const String& minimum, const String& maximum, const String& step, const String& valueString, int numberOfStepTimes)
+ {
+ DecimalStepRange stepRange(fromString(minimum), fromString(maximum), fromString(step));
+ Decimal value = fromString(valueString);
+ for (int i = 0; i < numberOfStepTimes; ++i) {
+ value += stepRange.step;
+ value = stepRange.clampValue(value);
+ }
+ return value.toString();
+ }
+};
+
+TEST_F(DecimalTest, Abs)
+{
+ EXPECT_EQ(encode(0, 0, Positive), encode(0, 0, Positive).abs());
+ EXPECT_EQ(encode(0, 0, Positive), encode(0, 0, Negative).abs());
+
+ EXPECT_EQ(encode(0, 10, Positive), encode(0, 10, Positive).abs());
+ EXPECT_EQ(encode(0, 10, Positive), encode(0, 10, Negative).abs());
+
+ EXPECT_EQ(encode(0, -10, Positive), encode(0, -10, Positive).abs());
+ EXPECT_EQ(encode(0, -10, Positive), encode(0, -10, Negative).abs());
+
+ EXPECT_EQ(encode(1, 0, Positive), encode(1, 0, Positive).abs());
+ EXPECT_EQ(encode(1, 0, Positive), encode(1, 0, Negative).abs());
+
+ EXPECT_EQ(encode(1, 10, Positive), encode(1, 10, Positive).abs());
+ EXPECT_EQ(encode(1, 10, Positive), encode(1, 10, Negative).abs());
+
+ EXPECT_EQ(encode(1, -10, Positive), encode(1, -10, Positive).abs());
+ EXPECT_EQ(encode(1, -10, Positive), encode(1, -10, Negative).abs());
+}
+
+TEST_F(DecimalTest, AbsBigExponent)
+{
+ EXPECT_EQ(encode(1, 1000, Positive), encode(1, 1000, Positive).abs());
+ EXPECT_EQ(encode(1, 1000, Positive), encode(1, 1000, Negative).abs());
+}
+
+TEST_F(DecimalTest, AbsSmallExponent)
+{
+ EXPECT_EQ(encode(1, -1000, Positive), encode(1, -1000, Positive).abs());
+ EXPECT_EQ(encode(1, -1000, Positive), encode(1, -1000, Negative).abs());
+}
+
+TEST_F(DecimalTest, AbsSpecialValues)
+{
+ EXPECT_EQ(Decimal::infinity(Positive), Decimal::infinity(Positive).abs());
+ EXPECT_EQ(Decimal::infinity(Positive), Decimal::infinity(Negative).abs());
+ EXPECT_EQ(Decimal::nan(), Decimal::nan().abs());
+}
+
+TEST_F(DecimalTest, Add)
+{
+ EXPECT_EQ(encode(0, 0, Positive), Decimal(0) + Decimal(0));
+ EXPECT_EQ(Decimal(1), Decimal(2) + Decimal(-1));
+ EXPECT_EQ(Decimal(1), Decimal(-1) + Decimal(2));
+ EXPECT_EQ(encode(100, 0, Positive), Decimal(99) + Decimal(1));
+ EXPECT_EQ(encode(100, 0, Negative), Decimal(-50) + Decimal(-50));
+ EXPECT_EQ(encode(UINT64_C(1000000000000000), 35, Positive), encode(1, 50, Positive) + Decimal(1));
+ EXPECT_EQ(encode(UINT64_C(1000000000000000), 35, Positive), Decimal(1) + encode(1, 50, Positive));
+ EXPECT_EQ(encode(UINT64_C(10000000001), 0, Positive), encode(1, 10, Positive) + Decimal(1));
+ EXPECT_EQ(encode(UINT64_C(10000000001), 0, Positive), Decimal(1) + encode(1, 10, Positive));
+ EXPECT_EQ(encode(1, 0, Positive), encode(1, -1022, Positive) + encode(1, 0, Positive));
+ EXPECT_EQ(encode(2, -1022, Positive), encode(1, -1022, Positive) + encode(1, -1022, Positive));
+}
+
+TEST_F(DecimalTest, AddBigExponent)
+{
+ EXPECT_EQ(encode(1, 1022, Positive), encode(1, 1022, Positive) + encode(1, 0, Positive));
+ EXPECT_EQ(encode(2, 1022, Positive), encode(1, 1022, Positive) + encode(1, 1022, Positive));
+ EXPECT_EQ(Decimal::infinity(Positive), encode(std::numeric_limits<uint64_t>::max(), 1022, Positive) + encode(1, 0, Positive));
+ EXPECT_EQ(encode(1, 1022, Positive), encode(1, 1022, Positive) + encode(1, -1000, Positive));
+}
+
+TEST_F(DecimalTest, AddSmallExponent)
+{
+ EXPECT_EQ(encode(1, 0, Positive), encode(1, -1022, Positive) + encode(1, 0, Positive));
+ EXPECT_EQ(encode(2, -1022, Positive), encode(1, -1022, Positive) + encode(1, -1022, Positive));
+}
+
+TEST_F(DecimalTest, AddSpecialValues)
+{
+ const Decimal Infinity(Decimal::infinity(Positive));
+ const Decimal MinusInfinity(Decimal::infinity(Negative));
+ const Decimal NaN(Decimal::nan());
+ const Decimal Ten(10);
+
+ EXPECT_EQ(Infinity, Infinity + Infinity);
+ EXPECT_EQ(NaN, Infinity + MinusInfinity);
+ EXPECT_EQ(NaN, MinusInfinity + Infinity);
+ EXPECT_EQ(MinusInfinity, MinusInfinity + MinusInfinity);
+
+ EXPECT_EQ(Infinity, Infinity + Ten);
+ EXPECT_EQ(Infinity, Ten + Infinity);
+ EXPECT_EQ(MinusInfinity, MinusInfinity + Ten);
+ EXPECT_EQ(MinusInfinity, Ten + MinusInfinity);
+
+ EXPECT_EQ(NaN, NaN + NaN);
+ EXPECT_EQ(NaN, NaN + Ten);
+ EXPECT_EQ(NaN, Ten + NaN);
+
+ EXPECT_EQ(NaN, NaN - Infinity);
+ EXPECT_EQ(NaN, NaN - MinusInfinity);
+ EXPECT_EQ(NaN, Infinity - NaN);
+ EXPECT_EQ(NaN, MinusInfinity - NaN);
+}
+
+TEST_F(DecimalTest, Ceiling)
+{
+ EXPECT_EQ(Decimal(1), Decimal(1).ceiling());
+ EXPECT_EQ(Decimal(2), encode(11, -1, Positive).ceiling());
+ EXPECT_EQ(Decimal(2), encode(13, -1, Positive).ceiling());
+ EXPECT_EQ(Decimal(2), encode(15, -1, Positive).ceiling());
+ EXPECT_EQ(Decimal(2), encode(19, -1, Positive).ceiling());
+
+ EXPECT_EQ(Decimal(-1), Decimal(-1).ceiling());
+ EXPECT_EQ(Decimal(-1), encode(11, -1, Negative).ceiling());
+ EXPECT_EQ(Decimal(-1), encode(13, -1, Negative).ceiling());
+ EXPECT_EQ(Decimal(-1), encode(15, -1, Negative).ceiling());
+ EXPECT_EQ(Decimal(-1), encode(19, -1, Negative).ceiling());
+}
+
+TEST_F(DecimalTest, CeilingBigExponent)
+{
+ EXPECT_EQ(encode(1, 1000, Positive), encode(1, 1000, Positive).ceiling());
+ EXPECT_EQ(encode(1, 1000, Negative), encode(1, 1000, Negative).ceiling());
+}
+
+TEST_F(DecimalTest, CeilingSmallExponent)
+{
+ EXPECT_EQ(encode(0, 0, Positive), encode(1, -1000, Positive).ceiling());
+ EXPECT_EQ(encode(0, 0, Negative), encode(1, -1000, Negative).ceiling());
+}
+
+TEST_F(DecimalTest, CeilingSpecialValues)
+{
+ EXPECT_EQ(Decimal::infinity(Positive), Decimal::infinity(Positive).ceiling());
+ EXPECT_EQ(Decimal::infinity(Negative), Decimal::infinity(Negative).ceiling());
+ EXPECT_EQ(Decimal::nan(), Decimal::nan().ceiling());
+}
+
+TEST_F(DecimalTest, Compare)
+{
+ EXPECT_TRUE(Decimal(0) == Decimal(0));
+ EXPECT_TRUE(Decimal(0) != Decimal(1));
+ EXPECT_TRUE(Decimal(0) < Decimal(1));
+ EXPECT_TRUE(Decimal(0) <= Decimal(0));
+ EXPECT_TRUE(Decimal(0) > Decimal(-1));
+ EXPECT_TRUE(Decimal(0) >= Decimal(0));
+
+ EXPECT_FALSE(Decimal(1) == Decimal(2));
+ EXPECT_FALSE(Decimal(1) != Decimal(1));
+ EXPECT_FALSE(Decimal(1) < Decimal(0));
+ EXPECT_FALSE(Decimal(1) <= Decimal(0));
+ EXPECT_FALSE(Decimal(1) > Decimal(2));
+ EXPECT_FALSE(Decimal(1) >= Decimal(2));
+}
+
+TEST_F(DecimalTest, CompareBigExponent)
+{
+ EXPECT_TRUE(encode(1, 1000, Positive) == encode(1, 1000, Positive));
+ EXPECT_FALSE(encode(1, 1000, Positive) != encode(1, 1000, Positive));
+ EXPECT_FALSE(encode(1, 1000, Positive) < encode(1, 1000, Positive));
+ EXPECT_TRUE(encode(1, 1000, Positive) <= encode(1, 1000, Positive));
+ EXPECT_FALSE(encode(1, 1000, Positive) > encode(1, 1000, Positive));
+ EXPECT_TRUE(encode(1, 1000, Positive) >= encode(1, 1000, Positive));
+
+ EXPECT_TRUE(encode(1, 1000, Negative) == encode(1, 1000, Negative));
+ EXPECT_FALSE(encode(1, 1000, Negative) != encode(1, 1000, Negative));
+ EXPECT_FALSE(encode(1, 1000, Negative) < encode(1, 1000, Negative));
+ EXPECT_TRUE(encode(1, 1000, Negative) <= encode(1, 1000, Negative));
+ EXPECT_FALSE(encode(1, 1000, Negative) > encode(1, 1000, Negative));
+ EXPECT_TRUE(encode(1, 1000, Negative) >= encode(1, 1000, Negative));
+
+ EXPECT_FALSE(encode(2, 1000, Positive) == encode(1, 1000, Positive));
+ EXPECT_TRUE(encode(2, 1000, Positive) != encode(1, 1000, Positive));
+ EXPECT_FALSE(encode(2, 1000, Positive) < encode(1, 1000, Positive));
+ EXPECT_FALSE(encode(2, 1000, Positive) <= encode(1, 1000, Positive));
+ EXPECT_TRUE(encode(2, 1000, Positive) > encode(1, 1000, Positive));
+ EXPECT_TRUE(encode(2, 1000, Positive) >= encode(1, 1000, Positive));
+
+ EXPECT_FALSE(encode(2, 1000, Negative) == encode(1, 1000, Negative));
+ EXPECT_TRUE(encode(2, 1000, Negative) != encode(1, 1000, Negative));
+ EXPECT_TRUE(encode(2, 1000, Negative) < encode(1, 1000, Negative));
+ EXPECT_TRUE(encode(2, 1000, Negative) <= encode(1, 1000, Negative));
+ EXPECT_FALSE(encode(2, 1000, Negative) > encode(1, 1000, Negative));
+ EXPECT_FALSE(encode(2, 1000, Negative) >= encode(1, 1000, Negative));
+}
+
+TEST_F(DecimalTest, CompareSmallExponent)
+{
+ EXPECT_TRUE(encode(1, -1000, Positive) == encode(1, -1000, Positive));
+ EXPECT_FALSE(encode(1, -1000, Positive) != encode(1, -1000, Positive));
+ EXPECT_FALSE(encode(1, -1000, Positive) < encode(1, -1000, Positive));
+ EXPECT_TRUE(encode(1, -1000, Positive) <= encode(1, -1000, Positive));
+ EXPECT_FALSE(encode(1, -1000, Positive) > encode(1, -1000, Positive));
+ EXPECT_TRUE(encode(1, -1000, Positive) >= encode(1, -1000, Positive));
+
+ EXPECT_TRUE(encode(1, -1000, Negative) == encode(1, -1000, Negative));
+ EXPECT_FALSE(encode(1, -1000, Negative) != encode(1, -1000, Negative));
+ EXPECT_FALSE(encode(1, -1000, Negative) < encode(1, -1000, Negative));
+ EXPECT_TRUE(encode(1, -1000, Negative) <= encode(1, -1000, Negative));
+ EXPECT_FALSE(encode(1, -1000, Negative) > encode(1, -1000, Negative));
+ EXPECT_TRUE(encode(1, -1000, Negative) >= encode(1, -1000, Negative));
+
+ EXPECT_FALSE(encode(2, -1000, Positive) == encode(1, -1000, Positive));
+ EXPECT_TRUE(encode(2, -1000, Positive) != encode(1, -1000, Positive));
+ EXPECT_FALSE(encode(2, -1000, Positive) < encode(1, -1000, Positive));
+ EXPECT_FALSE(encode(2, -1000, Positive) <= encode(1, -1000, Positive));
+ EXPECT_TRUE(encode(2, -1000, Positive) > encode(1, -1000, Positive));
+ EXPECT_TRUE(encode(2, -1000, Positive) >= encode(1, -1000, Positive));
+
+ EXPECT_FALSE(encode(2, -1000, Negative) == encode(1, -1000, Negative));
+ EXPECT_TRUE(encode(2, -1000, Negative) != encode(1, -1000, Negative));
+ EXPECT_TRUE(encode(2, -1000, Negative) < encode(1, -1000, Negative));
+ EXPECT_TRUE(encode(2, -1000, Negative) <= encode(1, -1000, Negative));
+ EXPECT_FALSE(encode(2, -1000, Negative) > encode(1, -1000, Negative));
+ EXPECT_FALSE(encode(2, -1000, Negative) >= encode(1, -1000, Negative));
+}
+
+TEST_F(DecimalTest, CompareSpecialValues)
+{
+ const Decimal Infinity(Decimal::infinity(Positive));
+ const Decimal MinusInfinity(Decimal::infinity(Negative));
+ const Decimal NaN(Decimal::nan());
+ const Decimal Zero(Decimal::zero(Positive));
+ const Decimal MinusZero(Decimal::zero(Negative));
+ const Decimal Ten(10);
+
+ EXPECT_TRUE(Zero == Zero);
+ EXPECT_FALSE(Zero != Zero);
+ EXPECT_FALSE(Zero < Zero);
+ EXPECT_TRUE(Zero <= Zero);
+ EXPECT_FALSE(Zero > Zero);
+ EXPECT_TRUE(Zero >= Zero);
+
+ EXPECT_TRUE(Zero == MinusZero);
+ EXPECT_FALSE(Zero != MinusZero);
+ EXPECT_FALSE(Zero < MinusZero);
+ EXPECT_TRUE(Zero <= MinusZero);
+ EXPECT_FALSE(Zero > MinusZero);
+ EXPECT_TRUE(Zero >= MinusZero);
+
+ EXPECT_TRUE(MinusZero == Zero);
+ EXPECT_FALSE(MinusZero != Zero);
+ EXPECT_FALSE(MinusZero < Zero);
+ EXPECT_TRUE(MinusZero <= Zero);
+ EXPECT_FALSE(MinusZero > Zero);
+ EXPECT_TRUE(MinusZero >= Zero);
+
+ EXPECT_TRUE(MinusZero == MinusZero);
+ EXPECT_FALSE(MinusZero != MinusZero);
+ EXPECT_FALSE(MinusZero < MinusZero);
+ EXPECT_TRUE(MinusZero <= MinusZero);
+ EXPECT_FALSE(MinusZero > MinusZero);
+ EXPECT_TRUE(MinusZero >= MinusZero);
+
+ EXPECT_TRUE(Infinity == Infinity);
+ EXPECT_FALSE(Infinity != Infinity);
+ EXPECT_FALSE(Infinity < Infinity);
+ EXPECT_TRUE(Infinity <= Infinity);
+ EXPECT_FALSE(Infinity > Infinity);
+ EXPECT_TRUE(Infinity >= Infinity);
+
+ EXPECT_FALSE(Infinity == Ten);
+ EXPECT_TRUE(Infinity != Ten);
+ EXPECT_FALSE(Infinity < Ten);
+ EXPECT_FALSE(Infinity <= Ten);
+ EXPECT_TRUE(Infinity > Ten);
+ EXPECT_TRUE(Infinity >= Ten);
+
+ EXPECT_FALSE(Infinity == MinusInfinity);
+ EXPECT_TRUE(Infinity != MinusInfinity);
+ EXPECT_FALSE(Infinity < MinusInfinity);
+ EXPECT_FALSE(Infinity <= MinusInfinity);
+ EXPECT_TRUE(Infinity > MinusInfinity);
+ EXPECT_TRUE(Infinity >= MinusInfinity);
+
+ EXPECT_FALSE(Infinity == NaN);
+ EXPECT_FALSE(Infinity != NaN);
+ EXPECT_FALSE(Infinity < NaN);
+ EXPECT_FALSE(Infinity <= NaN);
+ EXPECT_FALSE(Infinity > NaN);
+ EXPECT_FALSE(Infinity >= NaN);
+
+ EXPECT_FALSE(MinusInfinity == Infinity);
+ EXPECT_TRUE(MinusInfinity != Infinity);
+ EXPECT_TRUE(MinusInfinity < Infinity);
+ EXPECT_TRUE(MinusInfinity <= Infinity);
+ EXPECT_FALSE(MinusInfinity > Infinity);
+ EXPECT_FALSE(MinusInfinity >= Infinity);
+
+ EXPECT_FALSE(MinusInfinity == Ten);
+ EXPECT_TRUE(MinusInfinity != Ten);
+ EXPECT_TRUE(MinusInfinity < Ten);
+ EXPECT_TRUE(MinusInfinity <= Ten);
+ EXPECT_FALSE(MinusInfinity > Ten);
+ EXPECT_FALSE(MinusInfinity >= Ten);
+
+ EXPECT_TRUE(MinusInfinity == MinusInfinity);
+ EXPECT_FALSE(MinusInfinity != MinusInfinity);
+ EXPECT_FALSE(MinusInfinity < MinusInfinity);
+ EXPECT_TRUE(MinusInfinity <= MinusInfinity);
+ EXPECT_FALSE(MinusInfinity > MinusInfinity);
+ EXPECT_TRUE(MinusInfinity >= MinusInfinity);
+
+ EXPECT_FALSE(MinusInfinity == NaN);
+ EXPECT_FALSE(MinusInfinity != NaN);
+ EXPECT_FALSE(MinusInfinity < NaN);
+ EXPECT_FALSE(MinusInfinity <= NaN);
+ EXPECT_FALSE(MinusInfinity > NaN);
+ EXPECT_FALSE(MinusInfinity >= NaN);
+
+ EXPECT_FALSE(NaN == Infinity);
+ EXPECT_FALSE(NaN != Infinity);
+ EXPECT_FALSE(NaN < Infinity);
+ EXPECT_FALSE(NaN <= Infinity);
+ EXPECT_FALSE(NaN > Infinity);
+ EXPECT_FALSE(NaN >= Infinity);
+
+ EXPECT_FALSE(NaN == Ten);
+ EXPECT_FALSE(NaN != Ten);
+ EXPECT_FALSE(NaN < Ten);
+ EXPECT_FALSE(NaN <= Ten);
+ EXPECT_FALSE(NaN > Ten);
+ EXPECT_FALSE(NaN >= Ten);
+
+ EXPECT_FALSE(NaN == MinusInfinity);
+ EXPECT_FALSE(NaN != MinusInfinity);
+ EXPECT_FALSE(NaN < MinusInfinity);
+ EXPECT_FALSE(NaN <= MinusInfinity);
+ EXPECT_FALSE(NaN > MinusInfinity);
+ EXPECT_FALSE(NaN >= MinusInfinity);
+
+ EXPECT_TRUE(NaN == NaN);
+ EXPECT_FALSE(NaN != NaN);
+ EXPECT_FALSE(NaN < NaN);
+ EXPECT_TRUE(NaN <= NaN);
+ EXPECT_FALSE(NaN > NaN);
+ EXPECT_TRUE(NaN >= NaN);
+}
+
+TEST_F(DecimalTest, Division)
+{
+ EXPECT_EQ(encode(0, 0, Positive), Decimal(0) / Decimal(1));
+ EXPECT_EQ(encode(2, 0, Negative), Decimal(2) / Decimal(-1));
+ EXPECT_EQ(encode(5, -1, Negative), Decimal(-1) / Decimal(2));
+ EXPECT_EQ(encode(99, 0, Positive), Decimal(99) / Decimal(1));
+ EXPECT_EQ(Decimal(1), Decimal(-50) / Decimal(-50));
+ EXPECT_EQ(encode(UINT64_C(3333333333333333), -16, Positive), Decimal(1) / Decimal(3));
+ EXPECT_EQ(encode(UINT64_C(12345678901234), -1, Positive), encode(UINT64_C(12345678901234), 0, Positive) / Decimal(10));
+}
+
+TEST_F(DecimalTest, DivisionBigExponent)
+{
+ EXPECT_EQ(encode(1, 1022, Positive), encode(1, 1022, Positive) / encode(1, 0, Positive));
+ EXPECT_EQ(encode(1, 0, Positive), encode(1, 1022, Positive) / encode(1, 1022, Positive));
+ EXPECT_EQ(Decimal::infinity(Positive), encode(1, 1022, Positive) / encode(1, -1000, Positive));
+}
+
+TEST_F(DecimalTest, DivisionSmallExponent)
+{
+ EXPECT_EQ(encode(1, -1022, Positive), encode(1, -1022, Positive) / encode(1, 0, Positive));
+ EXPECT_EQ(encode(1, 0, Positive), encode(1, -1022, Positive) / encode(1, -1022, Positive));
+}
+
+TEST_F(DecimalTest, DivisionSpecialValues)
+{
+ const Decimal Infinity(Decimal::infinity(Positive));
+ const Decimal MinusInfinity(Decimal::infinity(Negative));
+ const Decimal NaN(Decimal::nan());
+ const Decimal Zero(Decimal::zero(Positive));
+ const Decimal MinusZero(Decimal::zero(Negative));
+ const Decimal Ten(10);
+ const Decimal MinusTen(-10);
+
+ EXPECT_EQ(NaN, Zero / Zero);
+ EXPECT_EQ(NaN, Zero / MinusZero);
+ EXPECT_EQ(NaN, MinusZero / Zero);
+ EXPECT_EQ(NaN, MinusZero / MinusZero);
+
+ EXPECT_EQ(Infinity, Ten / Zero);
+ EXPECT_EQ(MinusInfinity, Ten / MinusZero);
+ EXPECT_EQ(MinusInfinity, MinusTen / Zero);
+ EXPECT_EQ(Infinity, MinusTen / MinusZero);
+
+ EXPECT_EQ(Infinity, Infinity / Zero);
+ EXPECT_EQ(MinusInfinity, Infinity / MinusZero);
+ EXPECT_EQ(MinusInfinity, MinusInfinity / Zero);
+ EXPECT_EQ(Infinity, MinusInfinity / MinusZero);
+
+ EXPECT_EQ(NaN, Infinity / Infinity);
+ EXPECT_EQ(NaN, Infinity / MinusInfinity);
+ EXPECT_EQ(NaN, MinusInfinity / Infinity);
+ EXPECT_EQ(NaN, MinusInfinity / MinusInfinity);
+
+ EXPECT_EQ(Zero, Ten / Infinity);
+ EXPECT_EQ(MinusZero, Ten / MinusInfinity);
+ EXPECT_EQ(MinusZero, MinusTen / Infinity);
+ EXPECT_EQ(Zero, MinusTen / MinusInfinity);
+
+ EXPECT_EQ(NaN, NaN / NaN);
+ EXPECT_EQ(NaN, NaN / Ten);
+ EXPECT_EQ(NaN, Ten / NaN);
+
+ EXPECT_EQ(NaN, NaN / Infinity);
+ EXPECT_EQ(NaN, NaN / MinusInfinity);
+ EXPECT_EQ(NaN, Infinity / NaN);
+ EXPECT_EQ(NaN, MinusInfinity / NaN);
+}
+
+TEST_F(DecimalTest, EncodedData)
+{
+ EXPECT_EQ(encode(0, 0, Positive), encode(0, 0, Positive));
+ EXPECT_EQ(encode(0, 0, Negative), encode(0, 0, Negative));
+ EXPECT_EQ(Decimal(1), Decimal(1));
+ EXPECT_EQ(encode(1, 0, Negative), encode(1, 0, Negative));
+ EXPECT_EQ(Decimal::infinity(Positive), encode(1, 2000, Positive));
+ EXPECT_EQ(Decimal::zero(Positive), encode(1, -2000, Positive));
+}
+
+TEST_F(DecimalTest, Floor)
+{
+ EXPECT_EQ(Decimal(1), Decimal(1).floor());
+ EXPECT_EQ(Decimal(1), encode(11, -1, Positive).floor());
+ EXPECT_EQ(Decimal(1), encode(13, -1, Positive).floor());
+ EXPECT_EQ(Decimal(1), encode(15, -1, Positive).floor());
+ EXPECT_EQ(Decimal(1), encode(19, -1, Positive).floor());
+
+ EXPECT_EQ(Decimal(-1), Decimal(-1).floor());
+ EXPECT_EQ(Decimal(-2), encode(11, -1, Negative).floor());
+ EXPECT_EQ(Decimal(-2), encode(13, -1, Negative).floor());
+ EXPECT_EQ(Decimal(-2), encode(15, -1, Negative).floor());
+ EXPECT_EQ(Decimal(-2), encode(19, -1, Negative).floor());
+}
+
+TEST_F(DecimalTest, FloorBigExponent)
+{
+ EXPECT_EQ(encode(1, 1000, Positive), encode(1, 1000, Positive).floor());
+ EXPECT_EQ(encode(1, 1000, Negative), encode(1, 1000, Negative).floor());
+}
+
+TEST_F(DecimalTest, FloorSmallExponent)
+{
+ EXPECT_EQ(encode(0, 0, Positive), encode(1, -1000, Positive).floor());
+ EXPECT_EQ(encode(0, 0, Negative), encode(1, -1000, Negative).floor());
+}
+
+TEST_F(DecimalTest, FloorSpecialValues)
+{
+ EXPECT_EQ(Decimal::infinity(Positive), Decimal::infinity(Positive).floor());
+ EXPECT_EQ(Decimal::infinity(Negative), Decimal::infinity(Negative).floor());
+ EXPECT_EQ(Decimal::nan(), Decimal::nan().floor());
+}
+
+TEST_F(DecimalTest, FromInt32)
+{
+ EXPECT_EQ(encode(0, 0, Positive), Decimal(0));
+ EXPECT_EQ(encode(1, 0, Positive), Decimal(1));
+ EXPECT_EQ(encode(1, 0, Negative), Decimal(-1));
+ EXPECT_EQ(encode(100, 0, Positive), Decimal(100));
+ EXPECT_EQ(encode(100, 0, Negative), Decimal(-100));
+ EXPECT_EQ(encode(0x7FFFFFFF, 0, Positive), Decimal(std::numeric_limits<int32_t>::max()));
+ EXPECT_EQ(encode(0x80000000u, 0, Negative), Decimal(std::numeric_limits<int32_t>::min()));
+}
+
+TEST_F(DecimalTest, FromString)
+{
+ EXPECT_EQ(encode(0, 0, Positive), fromString("0"));
+ EXPECT_EQ(encode(0, 0, Negative), fromString("-0"));
+ EXPECT_EQ(Decimal(1), fromString("1"));
+ EXPECT_EQ(encode(1, 0, Negative), fromString("-1"));
+ EXPECT_EQ(Decimal(1), fromString("01"));
+ EXPECT_EQ(encode(3, 0, Positive), fromString("+3"));
+ EXPECT_EQ(encode(0, 3, Positive), fromString("0E3"));
+ EXPECT_EQ(encode(5, -1, Positive), fromString(".5"));
+ EXPECT_EQ(encode(100, 0, Positive), fromString("100"));
+ EXPECT_EQ(encode(100, 0, Negative), fromString("-100"));
+ EXPECT_EQ(encode(123, -2, Positive), fromString("1.23"));
+ EXPECT_EQ(encode(123, -2, Negative), fromString("-1.23"));
+ EXPECT_EQ(encode(123, 8, Positive), fromString("1.23E10"));
+ EXPECT_EQ(encode(123, 8, Negative), fromString("-1.23E10"));
+ EXPECT_EQ(encode(123, 8, Positive), fromString("1.23E+10"));
+ EXPECT_EQ(encode(123, 8, Negative), fromString("-1.23E+10"));
+ EXPECT_EQ(encode(123, -12, Positive), fromString("1.23E-10"));
+ EXPECT_EQ(encode(123, -12, Negative), fromString("-1.23E-10"));
+ EXPECT_EQ(encode(5, -7, Positive), fromString("0.0000005"));
+ EXPECT_EQ(encode(0, 0, Positive), fromString("0e9999"));
+ EXPECT_EQ(encode(123, -3, Positive), fromString("0.123"));
+ EXPECT_EQ(encode(0, -2, Positive), fromString("00.00"));
+ EXPECT_EQ(encode(1, 2, Positive), fromString("1E2"));
+ EXPECT_EQ(Decimal::infinity(Positive), fromString("1E20000"));
+ EXPECT_EQ(Decimal::zero(Positive), fromString("1E-20000"));
+ EXPECT_EQ(encode(1000, 1023, Positive), fromString("1E1026"));
+ EXPECT_EQ(Decimal::zero(Positive), fromString("1E-1026"));
+ EXPECT_EQ(Decimal::infinity(Positive), fromString("1234567890E1036"));
+
+ // 2^1024
+ const uint64_t leadingDigitsOf2PowerOf1024 = UINT64_C(17976931348623159);
+ EXPECT_EQ(encode(leadingDigitsOf2PowerOf1024, 292, Positive), fromString("179769313486231590772930519078902473361797697894230657273430081157732675805500963132708477322407536021120113879871393357658789768814416622492847430639474124377767893424865485276302219601246094119453082952085005768838150682342462881473913110540827237163350510684586298239947245938479716304835356329624224137216"));
+}
+
+// These strings are look like proper number, but we don't accept them.
+TEST_F(DecimalTest, FromStringLikeNumber)
+{
+ EXPECT_EQ(Decimal::nan(), fromString(" 123 "));
+ EXPECT_EQ(Decimal::nan(), fromString("1,234"));
+}
+
+// fromString doesn't support infinity and NaN.
+TEST_F(DecimalTest, FromStringSpecialValues)
+{
+ EXPECT_EQ(Decimal::nan(), fromString("INF"));
+ EXPECT_EQ(Decimal::nan(), fromString("Infinity"));
+ EXPECT_EQ(Decimal::nan(), fromString("infinity"));
+ EXPECT_EQ(Decimal::nan(), fromString("+Infinity"));
+ EXPECT_EQ(Decimal::nan(), fromString("+infinity"));
+ EXPECT_EQ(Decimal::nan(), fromString("-Infinity"));
+ EXPECT_EQ(Decimal::nan(), fromString("-infinity"));
+ EXPECT_EQ(Decimal::nan(), fromString("NaN"));
+ EXPECT_EQ(Decimal::nan(), fromString("nan"));
+ EXPECT_EQ(Decimal::nan(), fromString("+NaN"));
+ EXPECT_EQ(Decimal::nan(), fromString("+nan"));
+ EXPECT_EQ(Decimal::nan(), fromString("-NaN"));
+ EXPECT_EQ(Decimal::nan(), fromString("-nan"));
+}
+
+TEST_F(DecimalTest, fromStringTruncated)
+{
+ EXPECT_EQ(Decimal::nan(), fromString("x"));
+ EXPECT_EQ(Decimal::nan(), fromString("0."));
+ EXPECT_EQ(Decimal::nan(), fromString("1x"));
+
+ EXPECT_EQ(Decimal::nan(), fromString("1Ex"));
+ EXPECT_EQ(Decimal::nan(), fromString("1E2x"));
+ EXPECT_EQ(Decimal::nan(), fromString("1E+x"));
+}
+
+TEST_F(DecimalTest, Multiplication)
+{
+ EXPECT_EQ(encode(0, 0, Positive), Decimal(0) * Decimal(0));
+ EXPECT_EQ(encode(2, 0, Negative), Decimal(2) * Decimal(-1));
+ EXPECT_EQ(encode(2, 0, Negative), Decimal(-1) * Decimal(2));
+ EXPECT_EQ(encode(99, 0, Positive), Decimal(99) * Decimal(1));
+ EXPECT_EQ(encode(2500, 0, Positive), Decimal(-50) * Decimal(-50));
+}
+
+TEST_F(DecimalTest, MultiplicationBigExponent)
+{
+ EXPECT_EQ(encode(1, 1022, Positive), encode(1, 1022, Positive) * encode(1, 0, Positive));
+ EXPECT_EQ(Decimal::infinity(Positive), encode(1, 1022, Positive) * encode(1, 1022, Positive));
+ EXPECT_EQ(encode(1, 22, Positive), encode(1, 1022, Positive) * encode(1, -1000, Positive));
+}
+
+TEST_F(DecimalTest, MultiplicationSmallExponent)
+{
+ EXPECT_EQ(encode(1, -1022, Positive), encode(1, -1022, Positive) * encode(1, 0, Positive));
+ EXPECT_EQ(encode(0, 0, Positive), encode(1, -1022, Positive) * encode(1, -1022, Positive));
+}
+
+TEST_F(DecimalTest, MultiplicationSpecialValues)
+{
+ const Decimal Infinity(Decimal::infinity(Positive));
+ const Decimal MinusInfinity(Decimal::infinity(Negative));
+ const Decimal NaN(Decimal::nan());
+ const Decimal Ten(10);
+ const Decimal MinusTen(-10);
+ const Decimal Zero(Decimal::zero(Positive));
+ const Decimal MinusZero(Decimal::zero(Negative));
+
+ EXPECT_EQ(Infinity, Infinity * Infinity);
+ EXPECT_EQ(MinusInfinity, Infinity * MinusInfinity);
+ EXPECT_EQ(MinusInfinity, MinusInfinity * Infinity);
+ EXPECT_EQ(Infinity, MinusInfinity * MinusInfinity);
+
+ EXPECT_EQ(NaN, Infinity * Zero);
+ EXPECT_EQ(NaN, Zero * MinusInfinity);
+ EXPECT_EQ(NaN, MinusInfinity * Zero);
+ EXPECT_EQ(NaN, MinusInfinity * Zero);
+
+ EXPECT_EQ(NaN, Infinity * MinusZero);
+ EXPECT_EQ(NaN, MinusZero * MinusInfinity);
+ EXPECT_EQ(NaN, MinusInfinity * MinusZero);
+ EXPECT_EQ(NaN, MinusInfinity * MinusZero);
+
+ EXPECT_EQ(Infinity, Infinity * Ten);
+ EXPECT_EQ(Infinity, Ten * Infinity);
+ EXPECT_EQ(MinusInfinity, MinusInfinity * Ten);
+ EXPECT_EQ(MinusInfinity, Ten * MinusInfinity);
+
+ EXPECT_EQ(MinusInfinity, Infinity * MinusTen);
+ EXPECT_EQ(MinusInfinity, MinusTen * Infinity);
+ EXPECT_EQ(Infinity, MinusInfinity * MinusTen);
+ EXPECT_EQ(Infinity, MinusTen * MinusInfinity);
+
+ EXPECT_EQ(NaN, NaN * NaN);
+ EXPECT_EQ(NaN, NaN * Ten);
+ EXPECT_EQ(NaN, Ten * NaN);
+
+ EXPECT_EQ(NaN, NaN * Infinity);
+ EXPECT_EQ(NaN, NaN * MinusInfinity);
+ EXPECT_EQ(NaN, Infinity * NaN);
+ EXPECT_EQ(NaN, MinusInfinity * NaN);
+}
+
+TEST_F(DecimalTest, Negate)
+{
+ EXPECT_EQ(encode(0, 0, Negative), -encode(0, 0, Positive));
+ EXPECT_EQ(encode(0, 0, Positive), -encode(0, 0, Negative));
+
+ EXPECT_EQ(encode(0, 10, Negative), -encode(0, 10, Positive));
+ EXPECT_EQ(encode(0, 10, Positive), -encode(0, 10, Negative));
+
+ EXPECT_EQ(encode(0, -10, Negative), -encode(0, -10, Positive));
+ EXPECT_EQ(encode(0, -10, Positive), -encode(0, -10, Negative));
+
+ EXPECT_EQ(encode(1, 0, Negative), -encode(1, 0, Positive));
+ EXPECT_EQ(encode(1, 0, Positive), -encode(1, 0, Negative));
+
+ EXPECT_EQ(encode(1, 10, Negative), -encode(1, 10, Positive));
+ EXPECT_EQ(encode(1, 10, Positive), -encode(1, 10, Negative));
+
+ EXPECT_EQ(encode(1, -10, Negative), -encode(1, -10, Positive));
+ EXPECT_EQ(encode(1, -10, Positive), -encode(1, -10, Negative));
+}
+
+TEST_F(DecimalTest, NegateBigExponent)
+{
+ EXPECT_EQ(encode(1, 1000, Negative), -encode(1, 1000, Positive));
+ EXPECT_EQ(encode(1, 1000, Positive), -encode(1, 1000, Negative));
+}
+
+TEST_F(DecimalTest, NegateSmallExponent)
+{
+ EXPECT_EQ(encode(1, -1000, Negative), -encode(1, -1000, Positive));
+ EXPECT_EQ(encode(1, -1000, Positive), -encode(1, -1000, Negative));
+}
+
+TEST_F(DecimalTest, NegateSpecialValues)
+{
+ EXPECT_EQ(Decimal::infinity(Negative), -Decimal::infinity(Positive));
+ EXPECT_EQ(Decimal::infinity(Positive), -Decimal::infinity(Negative));
+ EXPECT_EQ(Decimal::nan(), -Decimal::nan());
+}
+
+TEST_F(DecimalTest, Predicates)
+{
+ EXPECT_TRUE(Decimal::zero(Positive).isFinite());
+ EXPECT_TRUE(Decimal::zero(Positive).isPositive());
+ EXPECT_FALSE(Decimal::zero(Positive).isNegative());
+ EXPECT_FALSE(Decimal::zero(Positive).isSpecial());
+ EXPECT_TRUE(Decimal::zero(Positive).isZero());
+
+ EXPECT_TRUE(Decimal::zero(Negative).isFinite());
+ EXPECT_FALSE(Decimal::zero(Negative).isPositive());
+ EXPECT_TRUE(Decimal::zero(Negative).isNegative());
+ EXPECT_FALSE(Decimal::zero(Negative).isSpecial());
+ EXPECT_TRUE(Decimal::zero(Negative).isZero());
+
+ EXPECT_TRUE(Decimal(123).isFinite());
+ EXPECT_TRUE(Decimal(123).isPositive());
+ EXPECT_FALSE(Decimal(123).isNegative());
+ EXPECT_FALSE(Decimal(123).isSpecial());
+ EXPECT_FALSE(Decimal(123).isZero());
+
+ EXPECT_TRUE(Decimal(-123).isFinite());
+ EXPECT_FALSE(Decimal(-123).isPositive());
+ EXPECT_TRUE(Decimal(-123).isNegative());
+ EXPECT_FALSE(Decimal(-123).isSpecial());
+ EXPECT_FALSE(Decimal(-123).isZero());
+}
+
+TEST_F(DecimalTest, PredicatesSpecialValues)
+{
+ EXPECT_FALSE(Decimal::infinity(Positive).isFinite());
+ EXPECT_TRUE(Decimal::infinity(Positive).isPositive());
+ EXPECT_FALSE(Decimal::infinity(Positive).isNegative());
+ EXPECT_TRUE(Decimal::infinity(Positive).isSpecial());
+ EXPECT_FALSE(Decimal::infinity(Positive).isZero());
+
+ EXPECT_FALSE(Decimal::infinity(Negative).isFinite());
+ EXPECT_FALSE(Decimal::infinity(Negative).isPositive());
+ EXPECT_TRUE(Decimal::infinity(Negative).isNegative());
+ EXPECT_TRUE(Decimal::infinity(Negative).isSpecial());
+ EXPECT_FALSE(Decimal::infinity(Negative).isZero());
+
+ EXPECT_FALSE(Decimal::nan().isFinite());
+ EXPECT_TRUE(Decimal::nan().isSpecial());
+ EXPECT_FALSE(Decimal::nan().isZero());
+}
+
+// LayoutTests/fast/forms/number/number-stepup-stepdown-from-renderer
+TEST_F(DecimalTest, RealWorldExampleNumberStepUpStepDownFromRenderer)
+{
+ EXPECT_EQ(String("10"), stepDown("0", "100", "10", "19", 1));
+ EXPECT_EQ(String("90"), stepUp("0", "99", "10", "89", 1));
+ EXPECT_EQ(String("1"), stepUp("0", "1", "0.33333333333333333", "0", 3)); // step=1/3
+ EXPECT_EQ(String("0.01"), stepUp("0", "0.01", "0.0033333333333333333", "0", 3)); // step=1/300
+ EXPECT_EQ(String("1"), stepUp("0", "1", "0.003921568627450980", "0", 255)); // step=1/255
+ EXPECT_EQ(String("1"), stepUp("0", "1", "0.1", "0", 10));
+}
+
+TEST_F(DecimalTest, RealWorldExampleNumberStepUpStepDownFromRendererRounding)
+{
+ EXPECT_EQ(String("5.015"), stepUp("0", "100", "0.005", "5.005", 2));
+ EXPECT_EQ(String("5.06"), stepUp("0", "100", "0.005", "5.005", 11));
+ EXPECT_EQ(String("5.065"), stepUp("0", "100", "0.005", "5.005", 12));
+
+ EXPECT_EQ(String("5.015"), stepUp("4", "9", "0.005", "5.005", 2));
+ EXPECT_EQ(String("5.06"), stepUp("4", "9", "0.005", "5.005", 11));
+ EXPECT_EQ(String("5.065"), stepUp("4", "9", "0.005", "5.005", 12));
+}
+
+TEST_F(DecimalTest, RealWorldExampleRangeStepUpStepDown)
+{
+ EXPECT_EQ(String("1e+38"), stepUp("0", "1E38", "1", "1E38", 9));
+ EXPECT_EQ(String("1e+38"), stepDown("0", "1E38", "1", "1E38", 9));
+}
+
+TEST_F(DecimalTest, Remainder)
+{
+ EXPECT_EQ(encode(9, -1, Negative), encode(21, -1, Positive).remainder(3));
+ EXPECT_EQ(Decimal(1), Decimal(10).remainder(3));
+ EXPECT_EQ(encode(1, 0, Negative), Decimal(-10).remainder(3));
+ EXPECT_EQ(encode(2, -1, Positive), encode(102, -1, Positive).remainder(1));
+ EXPECT_EQ(encode(1, -1, Positive), Decimal(10).remainder(encode(3, -1, Positive)));
+ EXPECT_EQ(encode(3, -1, Negative), encode(36, -1, Positive).remainder(encode(13, -1, Positive)));
+ EXPECT_EQ(encode(1, 87, Positive), (encode(1234, 100, Positive).remainder(Decimal(3))));
+}
+
+TEST_F(DecimalTest, RemainderBigExponent)
+{
+ EXPECT_EQ(encode(0, 1022, Positive), encode(1, 1022, Positive).remainder(encode(1, 0, Positive)));
+ EXPECT_EQ(encode(0, 1022, Positive), encode(1, 1022, Positive).remainder(encode(1, 1022, Positive)));
+ EXPECT_EQ(Decimal::infinity(Positive), encode(1, 1022, Positive).remainder(encode(1, -1000, Positive)));
+}
+
+TEST_F(DecimalTest, RemainderSmallExponent)
+{
+ EXPECT_EQ(encode(1, -1022, Positive), encode(1, -1022, Positive).remainder(encode(1, 0, Positive)));
+ EXPECT_EQ(encode(0, -1022, Positive), encode(1, -1022, Positive).remainder(encode(1, -1022, Positive)));
+}
+
+TEST_F(DecimalTest, RemainderSpecialValues)
+{
+ EXPECT_EQ(Decimal::infinity(Positive), Decimal::infinity(Positive).remainder(1));
+ EXPECT_EQ(Decimal::infinity(Negative), Decimal::infinity(Negative).remainder(1));
+ EXPECT_EQ(Decimal::nan(), Decimal::nan().remainder(1));
+
+ EXPECT_EQ(Decimal::infinity(Negative), Decimal::infinity(Positive).remainder(-1));
+ EXPECT_EQ(Decimal::infinity(Positive), Decimal::infinity(Negative).remainder(-1));
+ EXPECT_EQ(Decimal::nan(), Decimal::nan().remainder(-1));
+
+ EXPECT_EQ(Decimal::infinity(Positive), Decimal::infinity(Positive).remainder(3));
+ EXPECT_EQ(Decimal::infinity(Negative), Decimal::infinity(Negative).remainder(3));
+ EXPECT_EQ(Decimal::nan(), Decimal::nan().remainder(3));
+
+ EXPECT_EQ(Decimal::infinity(Negative), Decimal::infinity(Positive).remainder(-1));
+ EXPECT_EQ(Decimal::infinity(Positive), Decimal::infinity(Negative).remainder(-1));
+ EXPECT_EQ(Decimal::nan(), Decimal::nan().remainder(-1));
+
+ EXPECT_EQ(Decimal::nan(), Decimal(1).remainder(Decimal::infinity(Positive)));
+ EXPECT_EQ(Decimal::nan(), Decimal(1).remainder(Decimal::infinity(Negative)));
+ EXPECT_EQ(Decimal::nan(), Decimal(1).remainder(Decimal::nan()));
+}
+
+TEST_F(DecimalTest, Round)
+{
+ EXPECT_EQ(Decimal(1), (Decimal(9) / Decimal(10)).round());
+ EXPECT_EQ(Decimal(25), (Decimal(5) / fromString("0.200")).round());
+ EXPECT_EQ(Decimal(3), (Decimal(5) / Decimal(2)).round());
+ EXPECT_EQ(Decimal(1), (Decimal(2) / Decimal(3)).round());
+ EXPECT_EQ(Decimal(3), (Decimal(10) / Decimal(3)).round());
+ EXPECT_EQ(Decimal(3), (Decimal(1) / fromString("0.3")).round());
+ EXPECT_EQ(Decimal(10), (Decimal(1) / fromString("0.1")).round());
+ EXPECT_EQ(Decimal(5), (Decimal(1) / fromString("0.2")).round());
+ EXPECT_EQ(Decimal(10), (fromString("10.2") / 1).round());
+ EXPECT_EQ(encode(1234, 100, Positive), encode(1234, 100, Positive).round());
+}
+
+TEST_F(DecimalTest, RoundSpecialValues)
+{
+ EXPECT_EQ(Decimal::infinity(Positive), Decimal::infinity(Positive).round());
+ EXPECT_EQ(Decimal::infinity(Negative), Decimal::infinity(Negative).round());
+ EXPECT_EQ(Decimal::nan(), Decimal::nan().round());
+}
+
+TEST_F(DecimalTest, Subtract)
+{
+ EXPECT_EQ(encode(0, 0, Positive), Decimal(0) - Decimal(0));
+ EXPECT_EQ(encode(3, 0, Positive), Decimal(2) - Decimal(-1));
+ EXPECT_EQ(encode(3, 0, Negative), Decimal(-1) - Decimal(2));
+ EXPECT_EQ(encode(98, 0, Positive), Decimal(99) - Decimal(1));
+ EXPECT_EQ(encode(0, 0, Positive), Decimal(-50) - Decimal(-50));
+ EXPECT_EQ(encode(UINT64_C(1000000000000000), 35, Positive), encode(1, 50, Positive) - Decimal(1));
+ EXPECT_EQ(encode(UINT64_C(1000000000000000), 35, Negative), Decimal(1) - encode(1, 50, Positive));
+}
+
+TEST_F(DecimalTest, SubtractBigExponent)
+{
+ EXPECT_EQ(encode(1, 1022, Positive), encode(1, 1022, Positive) - encode(1, 0, Positive));
+ EXPECT_EQ(encode(0, 0, Positive), encode(1, 1022, Positive) - encode(1, 1022, Positive));
+ EXPECT_EQ(encode(1, 1022, Positive), encode(1, 1022, Positive) + encode(1, -1000, Positive));
+}
+
+TEST_F(DecimalTest, SubtractSmallExponent)
+{
+ EXPECT_EQ(encode(UINT64_C(10000000000000000), -16, Negative), encode(1, -1022, Positive) - encode(1, 0, Positive));
+ EXPECT_EQ(encode(0, 0, Positive), encode(1, -1022, Positive) - encode(1, -1022, Positive));
+}
+
+TEST_F(DecimalTest, SubtractSpecialValues)
+{
+ const Decimal Infinity(Decimal::infinity(Positive));
+ const Decimal MinusInfinity(Decimal::infinity(Negative));
+ const Decimal NaN(Decimal::nan());
+ const Decimal Ten(10);
+
+ EXPECT_EQ(NaN, Infinity - Infinity);
+ EXPECT_EQ(Infinity, Infinity - MinusInfinity);
+ EXPECT_EQ(MinusInfinity, MinusInfinity - Infinity);
+ EXPECT_EQ(NaN, MinusInfinity - MinusInfinity);
+
+ EXPECT_EQ(Infinity, Infinity - Ten);
+ EXPECT_EQ(MinusInfinity, Ten - Infinity);
+ EXPECT_EQ(MinusInfinity, MinusInfinity - Ten);
+ EXPECT_EQ(Infinity, Ten - MinusInfinity);
+
+ EXPECT_EQ(NaN, NaN - NaN);
+ EXPECT_EQ(NaN, NaN - Ten);
+ EXPECT_EQ(NaN, Ten - NaN);
+
+ EXPECT_EQ(NaN, NaN - Infinity);
+ EXPECT_EQ(NaN, NaN - MinusInfinity);
+ EXPECT_EQ(NaN, Infinity - NaN);
+ EXPECT_EQ(NaN, MinusInfinity - NaN);
+}
+
+TEST_F(DecimalTest, ToString)
+{
+ EXPECT_EQ(String("0"), Decimal::zero(Positive).toString());
+ EXPECT_EQ(String("-0"), Decimal::zero(Negative).toString());
+ EXPECT_EQ(String("1"), Decimal(1).toString());
+ EXPECT_EQ(String("-1"), Decimal(-1).toString());
+ EXPECT_EQ(String("1234567"), Decimal(1234567).toString());
+ EXPECT_EQ(String("-1234567"), Decimal(-1234567).toString());
+ EXPECT_EQ(String("0.5"), encode(5, -1, Positive).toString());
+ EXPECT_EQ(String("-0.5"), encode(5, -1, Negative).toString());
+ EXPECT_EQ(String("12.345"), encode(12345, -3, Positive).toString());
+ EXPECT_EQ(String("-12.345"), encode(12345, -3, Negative).toString());
+ EXPECT_EQ(String("0.12345"), encode(12345, -5, Positive).toString());
+ EXPECT_EQ(String("-0.12345"), encode(12345, -5, Negative).toString());
+ EXPECT_EQ(String("50"), encode(50, 0, Positive).toString());
+ EXPECT_EQ(String("-50"), encode(50, 0, Negative).toString());
+ EXPECT_EQ(String("5e+1"), encode(5, 1, Positive).toString());
+ EXPECT_EQ(String("-5e+1"), encode(5, 1, Negative).toString());
+ EXPECT_EQ(String("5.678e+103"), encode(5678, 100, Positive).toString());
+ EXPECT_EQ(String("-5.678e+103"), encode(5678, 100, Negative).toString());
+ EXPECT_EQ(String("5.678e-97"), encode(5678, -100, Positive).toString());
+ EXPECT_EQ(String("-5.678e-97"), encode(5678, -100, Negative).toString());
+}
+
+TEST_F(DecimalTest, ToStringSpecialValues)
+{
+ EXPECT_EQ(String("Infinity"), Decimal::infinity(Positive).toString());
+ EXPECT_EQ(String("-Infinity"), Decimal::infinity(Negative).toString());
+ EXPECT_EQ(String("NaN"), Decimal::nan().toString());
+}
diff --git a/Source/WebKit/chromium/tests/FloatQuadTest.cpp b/Source/WebKit/chromium/tests/FloatQuadTest.cpp
index 6c7091ca4..3e2f9bce6 100644
--- a/Source/WebKit/chromium/tests/FloatQuadTest.cpp
+++ b/Source/WebKit/chromium/tests/FloatQuadTest.cpp
@@ -25,20 +25,20 @@
#include "config.h"
+#include "cc/CCMathUtil.h"
#include "FloatQuad.h"
-
-#include "TransformationMatrix.h"
-
#include <gtest/gtest.h>
+#include <public/WebTransformationMatrix.h>
using namespace WebCore;
+using WebKit::WebTransformationMatrix;
namespace {
TEST(FloatQuadTest, IsRectilinearTest)
{
const int numRectilinear = 8;
- TransformationMatrix rectilinearTrans[numRectilinear];
+ WebTransformationMatrix rectilinearTrans[numRectilinear];
rectilinearTrans[1].rotate(90);
rectilinearTrans[2].rotate(180);
rectilinearTrans[3].rotate(270);
@@ -50,12 +50,14 @@ TEST(FloatQuadTest, IsRectilinearTest)
rectilinearTrans[7].rotate(180);
for (int i = 0; i < numRectilinear; ++i) {
- FloatQuad quad = rectilinearTrans[i].mapQuad(FloatRect(0.01010101f, 0.01010101f, 100.01010101f, 100.01010101f));
+ bool clipped = false;
+ FloatQuad quad = CCMathUtil::mapQuad(rectilinearTrans[i], FloatRect(0.01010101f, 0.01010101f, 100.01010101f, 100.01010101f), clipped);
+ ASSERT_TRUE(!clipped);
EXPECT_TRUE(quad.isRectilinear());
}
const int numNonRectilinear = 10;
- TransformationMatrix nonRectilinearTrans[numNonRectilinear];
+ WebTransformationMatrix nonRectilinearTrans[numNonRectilinear];
nonRectilinearTrans[0].rotate(359.999);
nonRectilinearTrans[1].rotate(0.0000001);
nonRectilinearTrans[2].rotate(89.999999);
@@ -68,7 +70,9 @@ TEST(FloatQuadTest, IsRectilinearTest)
nonRectilinearTrans[9].skewY(0.00001);
for (int i = 0; i < numNonRectilinear; ++i) {
- FloatQuad quad = nonRectilinearTrans[i].mapQuad(FloatRect(0.01010101f, 0.01010101f, 100.01010101f, 100.01010101f));
+ bool clipped = false;
+ FloatQuad quad = CCMathUtil::mapQuad(nonRectilinearTrans[i], FloatRect(0.01010101f, 0.01010101f, 100.01010101f, 100.01010101f), clipped);
+ ASSERT_TRUE(!clipped);
EXPECT_FALSE(quad.isRectilinear());
}
}
diff --git a/Source/WebKit/chromium/tests/LayerChromiumTest.cpp b/Source/WebKit/chromium/tests/LayerChromiumTest.cpp
index 491d48db5..8213dd812 100644
--- a/Source/WebKit/chromium/tests/LayerChromiumTest.cpp
+++ b/Source/WebKit/chromium/tests/LayerChromiumTest.cpp
@@ -36,9 +36,11 @@
#include "cc/CCSingleThreadProxy.h"
#include <gmock/gmock.h>
#include <gtest/gtest.h>
+#include <public/WebTransformationMatrix.h>
using namespace WebCore;
using namespace WebKitTests;
+using WebKit::WebTransformationMatrix;
using ::testing::Mock;
using ::testing::_;
using ::testing::AtLeast;
@@ -496,8 +498,8 @@ TEST_F(LayerChromiumTest, checkPropertyChangeCausesCorrectBehavior)
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setDrawOpacity(0.5f));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setClipRect(IntRect(3, 3, 8, 8)));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setTargetRenderSurface(0));
- EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setDrawTransform(TransformationMatrix()));
- EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setScreenSpaceTransform(TransformationMatrix()));
+ EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setDrawTransform(WebTransformationMatrix()));
+ EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setScreenSpaceTransform(WebTransformationMatrix()));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setDrawableContentRect(IntRect(4, 5, 6, 7)));
EXPECT_FALSE(testLayer->needsDisplay());
@@ -512,13 +514,13 @@ TEST_F(LayerChromiumTest, checkPropertyChangeCausesCorrectBehavior)
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setOpaque(true));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setPosition(FloatPoint(4.0f, 9.0f)));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setReplicaLayer(dummyLayer.get()));
- EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setSublayerTransform(TransformationMatrix(0, 0, 0, 0, 0, 0)));
+ EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setSublayerTransform(WebTransformationMatrix(0, 0, 0, 0, 0, 0)));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setScrollable(true));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setShouldScrollOnMainThread(true));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setNonFastScrollableRegion(Region(IntRect(1, 1, 2, 2))));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setHaveWheelEventHandlers(true));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setScrollPosition(IntPoint(10, 10)));
- EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setTransform(TransformationMatrix(0, 0, 0, 0, 0, 0)));
+ EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setTransform(WebTransformationMatrix(0, 0, 0, 0, 0, 0)));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setDoubleSided(false));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setDebugName("Test Layer"));
EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setDrawCheckerboardForMissingTiles(!testLayer->drawCheckerboardForMissingTiles()));
diff --git a/Source/WebKit/chromium/tests/LayerRendererChromiumTest.cpp b/Source/WebKit/chromium/tests/LayerRendererChromiumTest.cpp
index 8445feba7..4ed35986c 100644
--- a/Source/WebKit/chromium/tests/LayerRendererChromiumTest.cpp
+++ b/Source/WebKit/chromium/tests/LayerRendererChromiumTest.cpp
@@ -275,3 +275,44 @@ TEST(LayerRendererChromiumTest2, initializationDoesNotMakeSynchronousCalls)
EXPECT_TRUE(layerRendererChromium.initialize());
}
+
+class LoseContextOnFirstGetContext : public FakeWebGraphicsContext3D {
+public:
+ LoseContextOnFirstGetContext()
+ : m_contextLost(false)
+ {
+ }
+
+ virtual bool makeContextCurrent() OVERRIDE
+ {
+ return !m_contextLost;
+ }
+
+ virtual void getProgramiv(WebGLId program, WGC3Denum pname, WGC3Dint* value) OVERRIDE
+ {
+ m_contextLost = true;
+ *value = 0;
+ }
+
+ virtual void getShaderiv(WebGLId shader, WGC3Denum pname, WGC3Dint* value) OVERRIDE
+ {
+ m_contextLost = true;
+ *value = 0;
+ }
+
+ virtual WGC3Denum getGraphicsResetStatusARB() OVERRIDE
+ {
+ return m_contextLost ? 1 : 0;
+ }
+
+private:
+ bool m_contextLost;
+};
+
+TEST(LayerRendererChromiumTest2, initializationWithQuicklyLostContextDoesNotAssert)
+{
+ FakeLayerRendererChromiumClient mockClient;
+ FakeLayerRendererChromium layerRendererChromium(&mockClient, GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new LoseContextOnFirstGetContext), GraphicsContext3D::RenderDirectlyToHostWindow));
+
+ layerRendererChromium.initialize();
+}
diff --git a/Source/WebKit/chromium/tests/LinkHighlightTest.cpp b/Source/WebKit/chromium/tests/LinkHighlightTest.cpp
index edcfd4a63..be467a0d5 100644
--- a/Source/WebKit/chromium/tests/LinkHighlightTest.cpp
+++ b/Source/WebKit/chromium/tests/LinkHighlightTest.cpp
@@ -31,11 +31,12 @@
#include "GraphicsLayerClient.h"
#include "IntRect.h"
#include "Path.h"
-#include "TransformationMatrix.h"
#include <gtest/gtest.h>
+#include <public/WebTransformationMatrix.h>
#include <wtf/PassOwnPtr.h>
using namespace WebCore;
+using WebKit::WebTransformationMatrix;
namespace {
@@ -63,11 +64,10 @@ TEST(LinkHighlightTest, verifyLinkHighlightLayer)
EXPECT_TRUE(contentLayer->transform().isIdentityOrTranslation());
EXPECT_TRUE(contentLayer->transform().isIntegerTranslation());
- TransformationMatrix::DecomposedType decomposition;
- EXPECT_TRUE(contentLayer->transform().decompose(decomposition));
-
- FloatPoint expectedTranslation(pathBoundingRect.x() + pathBoundingRect.width() / 2, pathBoundingRect.y() + pathBoundingRect.height() / 2);
- EXPECT_EQ(FloatPoint(decomposition.translateX, decomposition.translateY), expectedTranslation);
+ float expectedXTranslation = pathBoundingRect.x() + pathBoundingRect.width() / 2;
+ float expectedYTranslation = pathBoundingRect.y() + pathBoundingRect.height() / 2;
+ EXPECT_FLOAT_EQ(expectedXTranslation, contentLayer->transform().m41());
+ EXPECT_FLOAT_EQ(expectedYTranslation, contentLayer->transform().m42());
}
TEST(LinkHighlightTest, verifyGraphicsLayerChromiumEmbedding)
diff --git a/Source/WebKit/chromium/tests/PopupMenuTest.cpp b/Source/WebKit/chromium/tests/PopupMenuTest.cpp
index 1db65ec6e..7acb31149 100644
--- a/Source/WebKit/chromium/tests/PopupMenuTest.cpp
+++ b/Source/WebKit/chromium/tests/PopupMenuTest.cpp
@@ -182,10 +182,6 @@ public:
protected:
virtual void SetUp()
{
- // When touch is enabled, padding is added to option elements
- // In these tests, we'll assume touch is disabled.
- m_touchWasEnabled = RuntimeEnabledFeatures::touchEnabled();
- RuntimeEnabledFeatures::setTouchEnabled(false);
m_webView = static_cast<WebViewImpl*>(WebView::create(&m_webviewClient));
m_webView->initializeMainFrame(&m_webFrameClient);
m_popupMenu = adoptRef(new PopupMenuChromium(&m_popupMenuClient));
@@ -196,7 +192,6 @@ protected:
m_popupMenu = 0;
m_webView->close();
webkit_support::UnregisterAllMockedURLs();
- RuntimeEnabledFeatures::setTouchEnabled(m_touchWasEnabled);
}
// Returns true if there currently is a select popup in the WebView.
@@ -284,7 +279,6 @@ protected:
TestWebFrameClient m_webFrameClient;
TestPopupMenuClient m_popupMenuClient;
RefPtr<PopupMenu> m_popupMenu;
- bool m_touchWasEnabled;
std::string baseURL;
};
@@ -360,8 +354,9 @@ TEST_F(SelectPopupMenuTest, ClickItem)
{
showPopup();
- // Y of 18 to be on the item at index 1 (12 font plus border and more to be safe).
- IntPoint row1Point(2, 18);
+ int menuItemHeight = m_webView->selectPopup()->menuItemHeight();
+ // menuItemHeight * 1.5 means the Y position on the item at index 1.
+ IntPoint row1Point(2, menuItemHeight * 1.5);
// Simulate a click down/up on the first item.
simulateLeftMouseDownEvent(row1Point);
simulateLeftMouseUpEvent(row1Point);
@@ -377,8 +372,9 @@ TEST_F(SelectPopupMenuTest, MouseOverItemClickOutside)
{
showPopup();
- // Y of 18 to be on the item at index 1 (12 font plus border and more to be safe).
- IntPoint row1Point(2, 18);
+ int menuItemHeight = m_webView->selectPopup()->menuItemHeight();
+ // menuItemHeight * 1.5 means the Y position on the item at index 1.
+ IntPoint row1Point(2, menuItemHeight * 1.5);
// Simulate the mouse moving over the first item.
PlatformMouseEvent mouseEvent(row1Point, row1Point, NoButton, PlatformEvent::MouseMoved,
1, false, false, false, false, 0);
@@ -421,9 +417,9 @@ TEST_F(SelectPopupMenuTest, DISABLED_SelectItemEventFire)
showPopup();
- int menuHeight = m_webView->selectPopup()->menuItemHeight();
- // menuHeight * 0.5 means the Y position on the item at index 0.
- IntPoint row1Point(2, menuHeight * 0.5);
+ int menuItemHeight = m_webView->selectPopup()->menuItemHeight();
+ // menuItemHeight * 0.5 means the Y position on the item at index 0.
+ IntPoint row1Point(2, menuItemHeight * 0.5);
simulateLeftMouseDownEvent(row1Point);
simulateLeftMouseUpEvent(row1Point);
@@ -437,8 +433,8 @@ TEST_F(SelectPopupMenuTest, DISABLED_SelectItemEventFire)
m_popupMenuClient.setDisabledIndex(1);
showPopup();
- // menuHeight * 1.5 means the Y position on the item at index 1.
- row1Point.setY(menuHeight * 1.5);
+ // menuItemHeight * 1.5 means the Y position on the item at index 1.
+ row1Point.setY(menuItemHeight * 1.5);
simulateLeftMouseDownEvent(row1Point);
simulateLeftMouseUpEvent(row1Point);
@@ -446,8 +442,8 @@ TEST_F(SelectPopupMenuTest, DISABLED_SelectItemEventFire)
EXPECT_STREQ("upclick", std::string(element.innerText().utf8()).c_str());
showPopup();
- // menuHeight * 2.5 means the Y position on the item at index 2.
- row1Point.setY(menuHeight * 2.5);
+ // menuItemHeight * 2.5 means the Y position on the item at index 2.
+ row1Point.setY(menuItemHeight * 2.5);
simulateLeftMouseDownEvent(row1Point);
simulateLeftMouseUpEvent(row1Point);
@@ -488,9 +484,9 @@ TEST_F(SelectPopupMenuTest, SelectItemRemoveSelectOnChange)
showPopup();
- int menuHeight = m_webView->selectPopup()->menuItemHeight();
- // menuHeight * 1.5 means the Y position on the item at index 1.
- IntPoint row1Point(2, menuHeight * 1.5);
+ int menuItemHeight = m_webView->selectPopup()->menuItemHeight();
+ // menuItemHeight * 1.5 means the Y position on the item at index 1.
+ IntPoint row1Point(2, menuItemHeight * 1.5);
simulateLeftMouseDownEvent(row1Point);
simulateLeftMouseUpEvent(row1Point);
@@ -510,9 +506,9 @@ TEST_F(SelectPopupMenuTest, SelectItemRemoveSelectOnClick)
showPopup();
- int menuHeight = m_webView->selectPopup()->menuItemHeight();
- // menuHeight * 1.5 means the Y position on the item at index 1.
- IntPoint row1Point(2, menuHeight * 1.5);
+ int menuItemHeight = m_webView->selectPopup()->menuItemHeight();
+ // menuItemHeight * 1.5 means the Y position on the item at index 1.
+ IntPoint row1Point(2, menuItemHeight * 1.5);
simulateLeftMouseDownEvent(row1Point);
simulateLeftMouseUpEvent(row1Point);
diff --git a/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp b/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp
index c9125a852..80b099f19 100644
--- a/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp
+++ b/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp
@@ -33,10 +33,12 @@
#include "WebCompositor.h"
#include "cc/CCSingleThreadProxy.h" // For DebugScopedSetImplThread
#include <gtest/gtest.h>
+#include <public/WebTransformationMatrix.h>
using namespace WebCore;
using namespace WebKitTests;
using namespace WTF;
+using WebKit::WebTransformationMatrix;
#define EXPECT_EQ_RECT(a, b) \
EXPECT_EQ(a.x(), b.x()); \
@@ -109,7 +111,7 @@ TEST(TiledLayerChromiumTest, pushOccludedDirtyTiles)
// The tile size is 100x100, so this invalidates and then paints two tiles.
layer->setBounds(IntSize(100, 200));
- layer->setDrawTransform(TransformationMatrix(1, 0, 0, 1, layer->bounds().width() / 2.0, layer->bounds().height() / 2.0));
+ layer->setDrawTransform(WebTransformationMatrix(1, 0, 0, 1, layer->bounds().width() / 2.0, layer->bounds().height() / 2.0));
layer->setVisibleLayerRect(IntRect(0, 0, 100, 200));
layer->invalidateRect(IntRect(0, 0, 100, 200));
layer->updateLayerRect(updater, IntRect(0, 0, 100, 200), &occluded);
@@ -327,7 +329,7 @@ TEST(TiledLayerChromiumTest, pushIdlePaintedOccludedTiles)
occluded.setOcclusion(IntRect(0, 0, 100, 100));
layer->setBounds(IntSize(100, 100));
- layer->setDrawTransform(TransformationMatrix(1, 0, 0, 1, layer->bounds().width() / 2.0, layer->bounds().height() / 2.0));
+ layer->setDrawTransform(WebTransformationMatrix(1, 0, 0, 1, layer->bounds().width() / 2.0, layer->bounds().height() / 2.0));
layer->setVisibleLayerRect(IntRect(0, 0, 100, 100));
layer->invalidateRect(IntRect(0, 0, 100, 100));
layer->updateLayerRect(updater, IntRect(0, 0, 100, 100), &occluded);
@@ -1018,7 +1020,7 @@ TEST(TiledLayerChromiumTest, tilesPaintedWithOcclusion)
// The tile size is 100x100.
layer->setBounds(IntSize(600, 600));
- layer->setDrawTransform(TransformationMatrix(1, 0, 0, 1, layer->bounds().width() / 2.0, layer->bounds().height() / 2.0));
+ layer->setDrawTransform(WebTransformationMatrix(1, 0, 0, 1, layer->bounds().width() / 2.0, layer->bounds().height() / 2.0));
occluded.setOcclusion(IntRect(200, 200, 300, 100));
layer->setVisibleLayerRect(IntRect(IntPoint(), layer->bounds()));
@@ -1063,7 +1065,7 @@ TEST(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndVisiblityConstraints)
// The tile size is 100x100.
layer->setBounds(IntSize(600, 600));
- layer->setDrawTransform(TransformationMatrix(1, 0, 0, 1, layer->bounds().width() / 2.0, layer->bounds().height() / 2.0));
+ layer->setDrawTransform(WebTransformationMatrix(1, 0, 0, 1, layer->bounds().width() / 2.0, layer->bounds().height() / 2.0));
// The partially occluded tiles (by the 150 occlusion height) are visible beyond the occlusion, so not culled.
occluded.setOcclusion(IntRect(200, 200, 300, 150));
@@ -1114,7 +1116,7 @@ TEST(TiledLayerChromiumTest, tilesNotPaintedWithoutInvalidation)
// The tile size is 100x100.
layer->setBounds(IntSize(600, 600));
- layer->setDrawTransform(TransformationMatrix(1, 0, 0, 1, layer->bounds().width() / 2.0, layer->bounds().height() / 2.0));
+ layer->setDrawTransform(WebTransformationMatrix(1, 0, 0, 1, layer->bounds().width() / 2.0, layer->bounds().height() / 2.0));
occluded.setOcclusion(IntRect(200, 200, 300, 100));
layer->setVisibleLayerRect(IntRect(0, 0, 600, 600));
@@ -1149,10 +1151,10 @@ TEST(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndTransforms)
// This makes sure the painting works when the occluded region (in screen space)
// is transformed differently than the layer.
layer->setBounds(IntSize(600, 600));
- TransformationMatrix screenTransform;
+ WebTransformationMatrix screenTransform;
screenTransform.scale(0.5);
layer->setScreenSpaceTransform(screenTransform);
- layer->setDrawTransform(screenTransform * TransformationMatrix(1, 0, 0, 1, layer->bounds().width() / 2.0, layer->bounds().height() / 2.0));
+ layer->setDrawTransform(screenTransform * WebTransformationMatrix(1, 0, 0, 1, layer->bounds().width() / 2.0, layer->bounds().height() / 2.0));
occluded.setOcclusion(IntRect(100, 100, 150, 50));
layer->setVisibleLayerRect(IntRect(IntPoint(), layer->bounds()));
@@ -1179,7 +1181,7 @@ TEST(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndScaling)
// pixels, which means none should be occluded.
layer->setContentsScale(0.5);
layer->setBounds(IntSize(600, 600));
- layer->setDrawTransform(TransformationMatrix(1, 0, 0, 1, layer->bounds().width() / 2.0, layer->bounds().height() / 2.0));
+ layer->setDrawTransform(WebTransformationMatrix(1, 0, 0, 1, layer->bounds().width() / 2.0, layer->bounds().height() / 2.0));
occluded.setOcclusion(IntRect(200, 200, 300, 100));
layer->setVisibleLayerRect(IntRect(IntPoint(), layer->bounds()));
@@ -1212,10 +1214,10 @@ TEST(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndScaling)
layer->fakeLayerTextureUpdater()->clearPrepareRectCount();
// This makes sure content scaling and transforms work together.
- TransformationMatrix screenTransform;
+ WebTransformationMatrix screenTransform;
screenTransform.scale(0.5);
layer->setScreenSpaceTransform(screenTransform);
- layer->setDrawTransform(screenTransform * TransformationMatrix(1, 0, 0, 1, layer->bounds().width() / 2.0, layer->bounds().height() / 2.0));
+ layer->setDrawTransform(screenTransform * WebTransformationMatrix(1, 0, 0, 1, layer->bounds().width() / 2.0, layer->bounds().height() / 2.0));
occluded.setOcclusion(IntRect(100, 100, 150, 100));
layer->setVisibleLayerRect(IntRect(IntPoint(), layer->bounds()));
@@ -1244,7 +1246,7 @@ TEST(TiledLayerChromiumTest, visibleContentOpaqueRegion)
IntRect visibleBounds = IntRect(0, 0, 100, 150);
layer->setBounds(contentBounds.size());
- layer->setDrawTransform(TransformationMatrix(1, 0, 0, 1, layer->bounds().width() / 2.0, layer->bounds().height() / 2.0));
+ layer->setDrawTransform(WebTransformationMatrix(1, 0, 0, 1, layer->bounds().width() / 2.0, layer->bounds().height() / 2.0));
layer->setVisibleLayerRect(visibleBounds);
layer->setDrawOpacity(1);
@@ -1338,7 +1340,7 @@ TEST(TiledLayerChromiumTest, pixelsPaintedMetrics)
IntRect visibleBounds = IntRect(0, 0, 100, 300);
layer->setBounds(contentBounds.size());
- layer->setDrawTransform(TransformationMatrix(1, 0, 0, 1, layer->bounds().width() / 2.0, layer->bounds().height() / 2.0));
+ layer->setDrawTransform(WebTransformationMatrix(1, 0, 0, 1, layer->bounds().width() / 2.0, layer->bounds().height() / 2.0));
layer->setVisibleLayerRect(visibleBounds);
layer->setDrawOpacity(1);
diff --git a/Source/WebKit/chromium/tests/WebFrameTest.cpp b/Source/WebKit/chromium/tests/WebFrameTest.cpp
index a6ab77fc1..4aa905c78 100644
--- a/Source/WebKit/chromium/tests/WebFrameTest.cpp
+++ b/Source/WebKit/chromium/tests/WebFrameTest.cpp
@@ -643,4 +643,85 @@ TEST_F(WebFrameTest, FindInPage)
webView->close();
}
+TEST_F(WebFrameTest, GetContentAsPlainText)
+{
+ WebView* webView = FrameTestHelpers::createWebViewAndLoad("about:blank", true);
+ // We set the size because it impacts line wrapping, which changes the
+ // resulting text value.
+ webView->resize(WebSize(640, 480));
+ WebFrame* frame = webView->mainFrame();
+
+ // Generate a simple test case.
+ const char simpleSource[] = "<div>Foo bar</div><div></div>baz";
+ GURL testURL("about:blank");
+ frame->loadHTMLString(simpleSource, testURL);
+ webkit_support::RunAllPendingMessages();
+
+ // Make sure it comes out OK.
+ const std::string expected("Foo bar\nbaz");
+ WebString text = frame->contentAsText(std::numeric_limits<size_t>::max());
+ EXPECT_EQ(expected, std::string(text.utf8()));
+
+ // Try reading the same one with clipping of the text.
+ const int length = 5;
+ text = frame->contentAsText(length);
+ EXPECT_EQ(expected.substr(0, length), std::string(text.utf8()));
+
+ // Now do a new test with a subframe.
+ const char outerFrameSource[] = "Hello<iframe></iframe> world";
+ frame->loadHTMLString(outerFrameSource, testURL);
+ webkit_support::RunAllPendingMessages();
+
+ // Load something into the subframe.
+ WebFrame* subframe = frame->findChildByExpression(WebString::fromUTF8("/html/body/iframe"));
+ ASSERT_TRUE(subframe);
+ subframe->loadHTMLString("sub<p>text", testURL);
+ webkit_support::RunAllPendingMessages();
+
+ text = frame->contentAsText(std::numeric_limits<size_t>::max());
+ EXPECT_EQ("Hello world\n\nsub\ntext", std::string(text.utf8()));
+
+ // Get the frame text where the subframe separator falls on the boundary of
+ // what we'll take. There used to be a crash in this case.
+ text = frame->contentAsText(12);
+ EXPECT_EQ("Hello world", std::string(text.utf8()));
+
+ webView->close();
+}
+
+TEST_F(WebFrameTest, GetFullHtmlOfPage)
+{
+ WebView* webView = FrameTestHelpers::createWebViewAndLoad("about:blank", true);
+ WebFrame* frame = webView->mainFrame();
+
+ // Generate a simple test case.
+ const char simpleSource[] = "<p>Hello</p><p>World</p>";
+ GURL testURL("about:blank");
+ frame->loadHTMLString(simpleSource, testURL);
+ webkit_support::RunAllPendingMessages();
+
+ WebString text = frame->contentAsText(std::numeric_limits<size_t>::max());
+ EXPECT_EQ("Hello\n\nWorld", std::string(text.utf8()));
+
+ const std::string html = frame->contentAsMarkup().utf8();
+
+ // Load again with the output html.
+ frame->loadHTMLString(html, testURL);
+ webkit_support::RunAllPendingMessages();
+
+ EXPECT_EQ(html, std::string(frame->contentAsMarkup().utf8()));
+
+ text = frame->contentAsText(std::numeric_limits<size_t>::max());
+ EXPECT_EQ("Hello\n\nWorld", std::string(text.utf8()));
+
+ // Test selection check
+ EXPECT_FALSE(frame->hasSelection());
+ frame->executeCommand(WebString::fromUTF8("SelectAll"));
+ EXPECT_TRUE(frame->hasSelection());
+ frame->executeCommand(WebString::fromUTF8("Unselect"));
+ EXPECT_FALSE(frame->hasSelection());
+ WebString selectionHtml = frame->selectionAsMarkup();
+ EXPECT_TRUE(selectionHtml.isEmpty());
+}
+
} // namespace
diff --git a/Source/WebKit/chromium/tests/WebInputEventFactoryTestGtk.cpp b/Source/WebKit/chromium/tests/WebInputEventFactoryTestGtk.cpp
index 64c63eae9..3792eaf79 100644
--- a/Source/WebKit/chromium/tests/WebInputEventFactoryTestGtk.cpp
+++ b/Source/WebKit/chromium/tests/WebInputEventFactoryTestGtk.cpp
@@ -31,11 +31,16 @@
#include "config.h"
#include <gdk/gdk.h>
+#include <gdk/gdkkeysyms.h>
#include <gtest/gtest.h>
+#include "KeyboardEvent.h"
#include "WebInputEvent.h"
+#include "WebInputEventConversion.h"
#include "WebInputEventFactory.h"
+using WebKit::WebInputEvent;
+using WebKit::WebKeyboardEvent;
using WebKit::WebMouseEvent;
using WebKit::WebInputEventFactory;
@@ -172,4 +177,27 @@ TEST(WebInputEventFactoryTest, MouseUpClickCount)
EXPECT_EQ(0, mouseUpEvent.clickCount);
}
+TEST(WebInputEventFactoryTest, NumPadConversion)
+{
+ // Construct a GDK input event for the numpad "5" key.
+ char five[] = "5";
+ GdkEventKey gdkEvent;
+ memset(&gdkEvent, 0, sizeof(GdkEventKey));
+ gdkEvent.type = GDK_KEY_PRESS;
+ gdkEvent.keyval = GDK_KP_5;
+ gdkEvent.string = five;
+
+ // Numpad flag should be set on the WebKeyboardEvent.
+ WebKeyboardEvent webEvent = WebInputEventFactory::keyboardEvent(&gdkEvent);
+ EXPECT_TRUE(webEvent.modifiers & WebInputEvent::IsKeyPad);
+
+ // Round-trip through the WebCore KeyboardEvent class.
+ WebKit::PlatformKeyboardEventBuilder platformBuilder(webEvent);
+ RefPtr<WebCore::KeyboardEvent> keypress = WebCore::KeyboardEvent::create(platformBuilder, 0);
+ EXPECT_TRUE(keypress->keyLocation() == WebCore::KeyboardEvent::DOM_KEY_LOCATION_NUMPAD);
+
+ WebKit::WebKeyboardEventBuilder builder(*keypress);
+ EXPECT_TRUE(builder.modifiers & WebInputEvent::IsKeyPad);
+}
+
} // anonymous namespace
diff --git a/Source/WebKit/chromium/tests/WebTransformOperationsTest.cpp b/Source/WebKit/chromium/tests/WebTransformOperationsTest.cpp
new file mode 100644
index 000000000..deaf7ad74
--- /dev/null
+++ b/Source/WebKit/chromium/tests/WebTransformOperationsTest.cpp
@@ -0,0 +1,341 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include <public/WebTransformOperations.h>
+
+#include <public/WebTransformationMatrix.h>
+
+#include "CCLayerTreeTestCommon.h"
+
+#include <gtest/gtest.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
+#include <wtf/Vector.h>
+
+using namespace WebKit;
+
+TEST(WebTransformOperationTest, transformTypesAreUnique)
+{
+ Vector<OwnPtr<WebTransformOperations> > transforms;
+
+ WebTransformOperations* toAdd = new WebTransformOperations();
+ toAdd->appendTranslate(0, 0, 0);
+ transforms.append(adoptPtr(toAdd));
+
+ toAdd = new WebTransformOperations();
+ toAdd->appendRotate(0, 0, 1, 0);
+ transforms.append(adoptPtr(toAdd));
+
+ toAdd = new WebTransformOperations();
+ toAdd->appendScale(1, 1, 1);
+ transforms.append(adoptPtr(toAdd));
+
+ toAdd = new WebTransformOperations();
+ toAdd->appendSkew(0, 0);
+ transforms.append(adoptPtr(toAdd));
+
+ toAdd = new WebTransformOperations();
+ toAdd->appendPerspective(800);
+ transforms.append(adoptPtr(toAdd));
+
+ for (size_t i = 0; i < transforms.size(); ++i) {
+ for (size_t j = 0; j < transforms.size(); ++j) {
+ bool matchesType = transforms[i]->matchesTypes(*transforms[j]);
+ EXPECT_TRUE((i == j && matchesType) || !matchesType);
+ }
+ }
+}
+
+TEST(WebTransformOperationTest, matchTypesSameLength)
+{
+ WebTransformOperations translates;
+ translates.appendTranslate(0, 0, 0);
+ translates.appendTranslate(0, 0, 0);
+ translates.appendTranslate(0, 0, 0);
+
+ WebTransformOperations skews;
+ skews.appendSkew(0, 0);
+ skews.appendSkew(0, 0);
+ skews.appendSkew(0, 0);
+
+ WebTransformOperations translates2;
+ translates2.appendTranslate(0, 0, 0);
+ translates2.appendTranslate(0, 0, 0);
+ translates2.appendTranslate(0, 0, 0);
+
+ WebTransformOperations translates3 = translates2;
+
+ EXPECT_FALSE(translates.matchesTypes(skews));
+ EXPECT_TRUE(translates.matchesTypes(translates2));
+ EXPECT_TRUE(translates.matchesTypes(translates3));
+}
+
+TEST(WebTransformOperationTest, matchTypesDifferentLength)
+{
+ WebTransformOperations translates;
+ translates.appendTranslate(0, 0, 0);
+ translates.appendTranslate(0, 0, 0);
+ translates.appendTranslate(0, 0, 0);
+
+ WebTransformOperations skews;
+ skews.appendSkew(0, 0);
+ skews.appendSkew(0, 0);
+
+ WebTransformOperations translates2;
+ translates2.appendTranslate(0, 0, 0);
+ translates2.appendTranslate(0, 0, 0);
+
+ EXPECT_FALSE(translates.matchesTypes(skews));
+ EXPECT_FALSE(translates.matchesTypes(translates2));
+}
+
+TEST(WebTransformOperationTest, applyTranslate)
+{
+ double x = 1;
+ double y = 2;
+ double z = 3;
+ WebTransformOperations operations;
+ operations.appendTranslate(x, y, z);
+ WebTransformationMatrix expected;
+ expected.translate3d(x, y, z);
+ EXPECT_TRANSFORMATION_MATRIX_EQ(expected, operations.apply());
+}
+
+TEST(WebTransformOperationTest, applyRotate)
+{
+ double x = 1;
+ double y = 2;
+ double z = 3;
+ double degrees = 80;
+ WebTransformOperations operations;
+ operations.appendRotate(x, y, z, degrees);
+ WebTransformationMatrix expected;
+ expected.rotate3d(x, y, z, degrees);
+ EXPECT_TRANSFORMATION_MATRIX_EQ(expected, operations.apply());
+}
+
+TEST(WebTransformOperationTest, applyScale)
+{
+ double x = 1;
+ double y = 2;
+ double z = 3;
+ WebTransformOperations operations;
+ operations.appendScale(x, y, z);
+ WebTransformationMatrix expected;
+ expected.scale3d(x, y, z);
+ EXPECT_TRANSFORMATION_MATRIX_EQ(expected, operations.apply());
+}
+
+TEST(WebTransformOperationTest, applySkew)
+{
+ double x = 1;
+ double y = 2;
+ WebTransformOperations operations;
+ operations.appendSkew(x, y);
+ WebTransformationMatrix expected;
+ expected.skewX(x);
+ expected.skewY(y);
+ EXPECT_TRANSFORMATION_MATRIX_EQ(expected, operations.apply());
+}
+
+TEST(WebTransformOperationTest, applyPerspective)
+{
+ double depth = 800;
+ WebTransformOperations operations;
+ operations.appendPerspective(depth);
+ WebTransformationMatrix expected;
+ expected.applyPerspective(depth);
+ EXPECT_TRANSFORMATION_MATRIX_EQ(expected, operations.apply());
+}
+
+TEST(WebTransformOperationTest, applyMatrix)
+{
+ double dx = 1;
+ double dy = 2;
+ double dz = 3;
+ WebTransformationMatrix expectedMatrix;
+ expectedMatrix.translate3d(dx, dy, dz);
+ WebTransformOperations matrixTransform;
+ matrixTransform.appendMatrix(expectedMatrix);
+ EXPECT_TRANSFORMATION_MATRIX_EQ(expectedMatrix, matrixTransform.apply());
+}
+
+TEST(WebTransformOperationTest, applyOrder)
+{
+ double sx = 2;
+ double sy = 4;
+ double sz = 8;
+
+ double dx = 1;
+ double dy = 2;
+ double dz = 3;
+
+ WebTransformOperations operations;
+ operations.appendScale(sx, sy, sz);
+ operations.appendTranslate(dx, dy, dz);
+
+ WebTransformationMatrix expectedScaleMatrix;
+ expectedScaleMatrix.scale3d(sx, sy, sz);
+
+ WebTransformationMatrix expectedTranslateMatrix;
+ expectedTranslateMatrix.translate3d(dx, dy, dz);
+
+ WebTransformationMatrix expectedCombinedMatrix = expectedScaleMatrix;
+ expectedCombinedMatrix.multiply(expectedTranslateMatrix);
+
+ EXPECT_TRANSFORMATION_MATRIX_EQ(expectedCombinedMatrix, operations.apply());
+}
+
+TEST(WebTransformOperationTest, blendOrder)
+{
+ double sx1 = 2;
+ double sy1 = 4;
+ double sz1 = 8;
+
+ double dx1 = 1;
+ double dy1 = 2;
+ double dz1 = 3;
+
+ double sx2 = 4;
+ double sy2 = 8;
+ double sz2 = 16;
+
+ double dx2 = 10;
+ double dy2 = 20;
+ double dz2 = 30;
+
+ WebTransformOperations operationsFrom;
+ operationsFrom.appendScale(sx1, sy1, sz1);
+ operationsFrom.appendTranslate(dx1, dy1, dz1);
+
+ WebTransformOperations operationsTo;
+ operationsTo.appendScale(sx2, sy2, sz2);
+ operationsTo.appendTranslate(dx2, dy2, dz2);
+
+ WebTransformationMatrix scaleFrom;
+ scaleFrom.scale3d(sx1, sy1, sz1);
+ WebTransformationMatrix translateFrom;
+ translateFrom.translate3d(dx1, dy1, dz1);
+
+ WebTransformationMatrix scaleTo;
+ scaleTo.scale3d(sx2, sy2, sz2);
+ WebTransformationMatrix translateTo;
+ translateTo.translate3d(dx2, dy2, dz2);
+
+ double progress = 0.25;
+
+ WebTransformationMatrix blendedScale = scaleTo;
+ blendedScale.blend(scaleFrom, progress);
+
+ WebTransformationMatrix blendedTranslate = translateTo;
+ blendedTranslate.blend(translateFrom, progress);
+
+ WebTransformationMatrix expected = blendedScale;
+ expected.multiply(blendedTranslate);
+
+ EXPECT_TRANSFORMATION_MATRIX_EQ(expected, operationsTo.blend(operationsFrom, progress));
+}
+
+static void checkProgress(double progress,
+ const WebTransformationMatrix& fromMatrix,
+ const WebTransformationMatrix& toMatrix,
+ const WebTransformOperations& fromTransform,
+ const WebTransformOperations& toTransform)
+{
+ WebTransformationMatrix expectedMatrix = toMatrix;
+ expectedMatrix.blend(fromMatrix, progress);
+ EXPECT_TRANSFORMATION_MATRIX_EQ(expectedMatrix, toTransform.blend(fromTransform, progress));
+}
+
+TEST(WebTransformOperationTest, blendProgress)
+{
+ double sx = 2;
+ double sy = 4;
+ double sz = 8;
+ WebTransformOperations operationsFrom;
+ operationsFrom.appendScale(sx, sy, sz);
+
+ WebTransformationMatrix matrixFrom;
+ matrixFrom.scale3d(sx, sy, sz);
+
+ sx = 4;
+ sy = 8;
+ sz = 16;
+ WebTransformOperations operationsTo;
+ operationsTo.appendScale(sx, sy, sz);
+
+ WebTransformationMatrix matrixTo;
+ matrixTo.scale3d(sx, sy, sz);
+
+ checkProgress(-1, matrixFrom, matrixTo, operationsFrom, operationsTo);
+ checkProgress(0, matrixFrom, matrixTo, operationsFrom, operationsTo);
+ checkProgress(0.25, matrixFrom, matrixTo, operationsFrom, operationsTo);
+ checkProgress(0.5, matrixFrom, matrixTo, operationsFrom, operationsTo);
+ checkProgress(1, matrixFrom, matrixTo, operationsFrom, operationsTo);
+ checkProgress(2, matrixFrom, matrixTo, operationsFrom, operationsTo);
+}
+
+TEST(WebTransformOperationTest, blendWhenTypesDoNotMatch)
+{
+ double sx1 = 2;
+ double sy1 = 4;
+ double sz1 = 8;
+
+ double dx1 = 1;
+ double dy1 = 2;
+ double dz1 = 3;
+
+ double sx2 = 4;
+ double sy2 = 8;
+ double sz2 = 16;
+
+ double dx2 = 10;
+ double dy2 = 20;
+ double dz2 = 30;
+
+ WebTransformOperations operationsFrom;
+ operationsFrom.appendScale(sx1, sy1, sz1);
+ operationsFrom.appendTranslate(dx1, dy1, dz1);
+
+ WebTransformOperations operationsTo;
+ operationsTo.appendTranslate(dx2, dy2, dz2);
+ operationsTo.appendScale(sx2, sy2, sz2);
+
+ WebTransformationMatrix from;
+ from.scale3d(sx1, sy1, sz1);
+ from.translate3d(dx1, dy1, dz1);
+
+ WebTransformationMatrix to;
+ to.translate3d(dx2, dy2, dz2);
+ to.scale3d(sx2, sy2, sz2);
+
+ double progress = 0.25;
+
+ WebTransformationMatrix expected = to;
+ expected.blend(from, progress);
+
+ EXPECT_TRANSFORMATION_MATRIX_EQ(expected, operationsTo.blend(operationsFrom, progress));
+}
diff --git a/Source/WebKit/chromium/tests/WebTransformationMatrixTest.cpp b/Source/WebKit/chromium/tests/WebTransformationMatrixTest.cpp
index 2888e0d7c..937cee202 100644
--- a/Source/WebKit/chromium/tests/WebTransformationMatrixTest.cpp
+++ b/Source/WebKit/chromium/tests/WebTransformationMatrixTest.cpp
@@ -153,6 +153,15 @@ TEST(WebTransformationMatrixTest, verifyConstructorFor2dElements)
EXPECT_ROW4_EQ(0, 0, 0, 1, A);
}
+TEST(WebTransformationMatrixTest, verifyConstructorForAllElements)
+{
+ WebTransformationMatrix A(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
+ EXPECT_ROW1_EQ(1, 5, 9, 13, A);
+ EXPECT_ROW2_EQ(2, 6, 10, 14, A);
+ EXPECT_ROW3_EQ(3, 7, 11, 15, A);
+ EXPECT_ROW4_EQ(4, 8, 12, 16, A);
+}
+
TEST(WebTransformationMatrixTest, verifyCopyConstructor)
{
WebTransformationMatrix A;
@@ -624,6 +633,38 @@ TEST(WebTransformationMatrixTest, verifyRotateAxisAngle3d)
EXPECT_ROW4_EQ(0, 0, 0, 1, A);
}
+TEST(WebTransformationMatrixTest, verifyRotateAxisAngle3dForArbitraryAxis)
+{
+ // Check rotation about an arbitrary non-axis-aligned vector.
+ WebTransformationMatrix A;
+ A.rotate3d(1, 1, 1, 90);
+ EXPECT_ROW1_NEAR(0.3333333333333334258519187,
+ -0.2440169358562924717404030,
+ 0.9106836025229592124219380,
+ 0, A, ERROR_THRESHOLD);
+ EXPECT_ROW2_NEAR(0.9106836025229592124219380,
+ 0.3333333333333334258519187,
+ -0.2440169358562924717404030,
+ 0, A, ERROR_THRESHOLD);
+ EXPECT_ROW3_NEAR(-0.2440169358562924717404030,
+ 0.9106836025229592124219380,
+ 0.3333333333333334258519187,
+ 0, A, ERROR_THRESHOLD);
+ EXPECT_ROW4_EQ(0, 0, 0, 1, A);
+}
+
+TEST(WebTransformationMatrixTest, verifyRotateAxisAngle3dForDegenerateAxis)
+{
+ // Check rotation about a degenerate zero vector.
+ // It is expected to default to rotation about the z-axis.
+ WebTransformationMatrix A;
+ A.rotate3d(0, 0, 0, 90);
+ EXPECT_ROW1_NEAR(0, -1, 0, 0, A, ERROR_THRESHOLD);
+ EXPECT_ROW2_NEAR(1, 0, 0, 0, A, ERROR_THRESHOLD);
+ EXPECT_ROW3_EQ(0, 0, 1, 0, A);
+ EXPECT_ROW4_EQ(0, 0, 0, 1, A);
+}
+
TEST(WebTransformationMatrixTest, verifySkewX)
{
WebTransformationMatrix A;