summaryrefslogtreecommitdiff
path: root/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp')
-rw-r--r--Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp93
1 files changed, 93 insertions, 0 deletions
diff --git a/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp b/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp
index 89d211e81..78448a517 100644
--- a/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp
+++ b/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp
@@ -28,6 +28,7 @@
#include "CCAnimationTestCommon.h"
#include "CCLayerTreeTestCommon.h"
+#include "ContentLayerChromium.h"
#include "LayerChromium.h"
#include "TranslateTransformOperation.h"
#include "cc/CCLayerAnimationController.h"
@@ -3662,6 +3663,98 @@ TEST(CCLayerTreeHostCommonTest, verifyHitTestingForMultipleLayerLists)
EXPECT_EQ(4, resultLayer->id());
}
+class MockContentLayerDelegate : public ContentLayerDelegate {
+public:
+ MockContentLayerDelegate() { }
+ virtual ~MockContentLayerDelegate() { }
+ virtual void paintContents(SkCanvas*, const IntRect& clip, IntRect& opaque) { }
+};
+
+PassRefPtr<ContentLayerChromium> createDrawableContentLayerChromium(ContentLayerDelegate* delegate)
+{
+ RefPtr<ContentLayerChromium> toReturn = ContentLayerChromium::create(delegate);
+ toReturn->setIsDrawable(true);
+ return toReturn.release();
+}
+
+TEST(CCLayerTreeHostCommonTest, verifyRenderSurfaceTranformsInHighDPI)
+{
+ MockContentLayerDelegate delegate;
+ WebTransformationMatrix identityMatrix;
+ WebTransformationMatrix parentMatrix;
+
+ RefPtr<ContentLayerChromium> parent = createDrawableContentLayerChromium(&delegate);
+ setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(30, 30), true);
+
+ RefPtr<ContentLayerChromium> child = createDrawableContentLayerChromium(&delegate);
+ setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(2, 2), IntSize(10, 10), true);
+
+ WebTransformationMatrix replicaTransform;
+ replicaTransform.scaleNonUniform(1, -1);
+ RefPtr<ContentLayerChromium> replica = createDrawableContentLayerChromium(&delegate);
+ setLayerPropertiesForTesting(replica.get(), replicaTransform, identityMatrix, FloatPoint(0, 0), FloatPoint(2, 2), IntSize(10, 10), true);
+
+ parent->addChild(child);
+ child->setReplicaLayer(replica.get());
+
+ Vector<RefPtr<LayerChromium> > renderSurfaceLayerList;
+ Vector<RefPtr<LayerChromium> > dummyLayerList;
+ int dummyMaxTextureSize = 512;
+
+ parent->createRenderSurface();
+ parent->renderSurface()->setContentRect(IntRect(IntPoint(), parent->bounds()));
+ parent->setClipRect(IntRect(IntPoint::zero(), parent->bounds()));
+ renderSurfaceLayerList.append(parent.get());
+
+ const double deviceScaleFactor = 1.5;
+ parentMatrix.scale(deviceScaleFactor);
+ parent->setContentsScale(deviceScaleFactor);
+ child->setContentsScale(deviceScaleFactor);
+ replica->setContentsScale(deviceScaleFactor);
+
+ CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent.get(), parentMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize);
+
+ // We should have two render surfaces. The root's render surface and child's
+ // render surface (it needs one because it has a replica layer).
+ EXPECT_EQ(2u, renderSurfaceLayerList.size());
+
+ WebTransformationMatrix expectedDrawTransform;
+ expectedDrawTransform.setM11(deviceScaleFactor);
+ expectedDrawTransform.setM22(deviceScaleFactor);
+ expectedDrawTransform.setM41(0.5 * deviceScaleFactor * child->bounds().width());
+ expectedDrawTransform.setM42(0.5 * deviceScaleFactor * child->bounds().height());
+ EXPECT_TRANSFORMATION_MATRIX_EQ(expectedDrawTransform, child->drawTransform());
+
+ WebTransformationMatrix expectedRenderSurfaceDrawTransform;
+ expectedRenderSurfaceDrawTransform.translate(deviceScaleFactor * (child->position().x() + 0.5 * child->bounds().width()), deviceScaleFactor * (child->position().y() + 0.5 * child->bounds().height()));
+ EXPECT_TRANSFORMATION_MATRIX_EQ(expectedRenderSurfaceDrawTransform, child->renderSurface()->drawTransform());
+
+ WebTransformationMatrix expectedOriginTransform;
+ expectedOriginTransform.translate(deviceScaleFactor * 2, deviceScaleFactor * 2);
+ EXPECT_TRANSFORMATION_MATRIX_EQ(expectedOriginTransform, child->renderSurface()->originTransform());
+
+ WebTransformationMatrix expectedScreenSpaceTransform;
+ expectedScreenSpaceTransform.translate(deviceScaleFactor * 2, deviceScaleFactor * 2);
+ EXPECT_TRANSFORMATION_MATRIX_EQ(expectedScreenSpaceTransform, child->renderSurface()->screenSpaceTransform());
+
+ WebTransformationMatrix expectedReplicaDrawTransform;
+ expectedReplicaDrawTransform.setM22(-1);
+ expectedReplicaDrawTransform.setM41(13.5);
+ expectedReplicaDrawTransform.setM42(-1.5);
+ EXPECT_TRANSFORMATION_MATRIX_EQ(expectedReplicaDrawTransform, child->renderSurface()->replicaDrawTransform());
+
+ WebTransformationMatrix expectedReplicaOriginTransform = expectedReplicaDrawTransform;
+ expectedReplicaOriginTransform.setM41(6);
+ expectedReplicaOriginTransform.setM42(6);
+ EXPECT_TRANSFORMATION_MATRIX_EQ(expectedReplicaOriginTransform, child->renderSurface()->replicaOriginTransform());
+
+ WebTransformationMatrix expectedReplicaScreenSpaceTransform;
+ expectedReplicaScreenSpaceTransform.setM22(-1);
+ expectedReplicaScreenSpaceTransform.setM41(6);
+ expectedReplicaScreenSpaceTransform.setM42(6);
+ EXPECT_TRANSFORMATION_MATRIX_EQ(expectedReplicaScreenSpaceTransform, child->renderSurface()->replicaScreenSpaceTransform());
+}
+
TEST(CCLayerTreeHostCommonTest, verifySubtreeSearch)
{
RefPtr<LayerChromium> root = LayerChromium::create();