| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/layer_tree_host_common.h" | 5 #include "cc/layer_tree_host_common.h" |
| 6 | 6 |
| 7 #include "cc/content_layer.h" | 7 #include "cc/content_layer.h" |
| 8 #include "cc/content_layer_client.h" | 8 #include "cc/content_layer_client.h" |
| 9 #include "cc/layer.h" | 9 #include "cc/layer.h" |
| 10 #include "cc/layer_animation_controller.h" | 10 #include "cc/layer_animation_controller.h" |
| 11 #include "cc/layer_impl.h" | 11 #include "cc/layer_impl.h" |
| 12 #include "cc/layer_sorter.h" | 12 #include "cc/layer_sorter.h" |
| 13 #include "cc/math_util.h" | 13 #include "cc/math_util.h" |
| 14 #include "cc/proxy.h" | 14 #include "cc/proxy.h" |
| 15 #include "cc/single_thread_proxy.h" | 15 #include "cc/single_thread_proxy.h" |
| 16 #include "cc/test/animation_test_common.h" | 16 #include "cc/test/animation_test_common.h" |
| 17 #include "cc/test/geometry_test_utils.h" | 17 #include "cc/test/geometry_test_utils.h" |
| 18 #include "cc/thread.h" | 18 #include "cc/thread.h" |
| 19 #include "ui/gfx/size_conversions.h" | 19 #include "ui/gfx/size_conversions.h" |
| 20 #include "testing/gmock/include/gmock/gmock.h" | 20 #include "testing/gmock/include/gmock/gmock.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 22 #include <public/WebTransformationMatrix.h> | 22 #include "ui/gfx/transform.h" |
| 23 | 23 |
| 24 using namespace WebKitTests; | 24 using namespace WebKitTests; |
| 25 using WebKit::WebTransformationMatrix; | |
| 26 | 25 |
| 27 namespace cc { | 26 namespace cc { |
| 28 namespace { | 27 namespace { |
| 29 | 28 |
| 30 template<typename LayerType> | 29 template<typename LayerType> |
| 31 void setLayerPropertiesForTestingInternal(LayerType* layer, const WebTransformat
ionMatrix& transform, const WebTransformationMatrix& sublayerTransform, const gf
x::PointF& anchor, const gfx::PointF& position, const gfx::Size& bounds, bool pr
eserves3D) | 30 void setLayerPropertiesForTestingInternal(LayerType* layer, const gfx::Transform
& transform, const gfx::Transform& sublayerTransform, const gfx::PointF& anchor,
const gfx::PointF& position, const gfx::Size& bounds, bool preserves3D) |
| 32 { | 31 { |
| 33 layer->setTransform(transform); | 32 layer->setTransform(transform); |
| 34 layer->setSublayerTransform(sublayerTransform); | 33 layer->setSublayerTransform(sublayerTransform); |
| 35 layer->setAnchorPoint(anchor); | 34 layer->setAnchorPoint(anchor); |
| 36 layer->setPosition(position); | 35 layer->setPosition(position); |
| 37 layer->setBounds(bounds); | 36 layer->setBounds(bounds); |
| 38 layer->setPreserves3D(preserves3D); | 37 layer->setPreserves3D(preserves3D); |
| 39 } | 38 } |
| 40 | 39 |
| 41 void setLayerPropertiesForTesting(Layer* layer, const WebTransformationMatrix& t
ransform, const WebTransformationMatrix& sublayerTransform, const gfx::PointF& a
nchor, const gfx::PointF& position, const gfx::Size& bounds, bool preserves3D) | 40 void setLayerPropertiesForTesting(Layer* layer, const gfx::Transform& transform,
const gfx::Transform& sublayerTransform, const gfx::PointF& anchor, const gfx::
PointF& position, const gfx::Size& bounds, bool preserves3D) |
| 42 { | 41 { |
| 43 setLayerPropertiesForTestingInternal<Layer>(layer, transform, sublayerTransf
orm, anchor, position, bounds, preserves3D); | 42 setLayerPropertiesForTestingInternal<Layer>(layer, transform, sublayerTransf
orm, anchor, position, bounds, preserves3D); |
| 44 layer->setAutomaticallyComputeRasterScale(true); | 43 layer->setAutomaticallyComputeRasterScale(true); |
| 45 } | 44 } |
| 46 | 45 |
| 47 void setLayerPropertiesForTesting(LayerImpl* layer, const WebTransformationMatri
x& transform, const WebTransformationMatrix& sublayerTransform, const gfx::Point
F& anchor, const gfx::PointF& position, const gfx::Size& bounds, bool preserves3
D) | 46 void setLayerPropertiesForTesting(LayerImpl* layer, const gfx::Transform& transf
orm, const gfx::Transform& sublayerTransform, const gfx::PointF& anchor, const g
fx::PointF& position, const gfx::Size& bounds, bool preserves3D) |
| 48 { | 47 { |
| 49 setLayerPropertiesForTestingInternal<LayerImpl>(layer, transform, sublayerTr
ansform, anchor, position, bounds, preserves3D); | 48 setLayerPropertiesForTestingInternal<LayerImpl>(layer, transform, sublayerTr
ansform, anchor, position, bounds, preserves3D); |
| 50 layer->setContentBounds(bounds); | 49 layer->setContentBounds(bounds); |
| 51 } | 50 } |
| 52 | 51 |
| 53 void executeCalculateDrawTransformsAndVisibility(Layer* rootLayer, float deviceS
caleFactor = 1, float pageScaleFactor = 1) | 52 void executeCalculateDrawTransformsAndVisibility(Layer* rootLayer, float deviceS
caleFactor = 1, float pageScaleFactor = 1) |
| 54 { | 53 { |
| 55 WebTransformationMatrix identityMatrix; | 54 gfx::Transform identityMatrix; |
| 56 std::vector<scoped_refptr<Layer> > dummyRenderSurfaceLayerList; | 55 std::vector<scoped_refptr<Layer> > dummyRenderSurfaceLayerList; |
| 57 int dummyMaxTextureSize = 512; | 56 int dummyMaxTextureSize = 512; |
| 58 gfx::Size deviceViewportSize = gfx::Size(rootLayer->bounds().width() * devic
eScaleFactor, rootLayer->bounds().height() * deviceScaleFactor); | 57 gfx::Size deviceViewportSize = gfx::Size(rootLayer->bounds().width() * devic
eScaleFactor, rootLayer->bounds().height() * deviceScaleFactor); |
| 59 | 58 |
| 60 // We are probably not testing what is intended if the rootLayer bounds are
empty. | 59 // We are probably not testing what is intended if the rootLayer bounds are
empty. |
| 61 DCHECK(!rootLayer->bounds().IsEmpty()); | 60 DCHECK(!rootLayer->bounds().IsEmpty()); |
| 62 LayerTreeHostCommon::calculateDrawTransforms(rootLayer, deviceViewportSize,
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, dummyRenderSurfaceLayer
List); | 61 LayerTreeHostCommon::calculateDrawTransforms(rootLayer, deviceViewportSize,
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, dummyRenderSurfaceLayer
List); |
| 63 } | 62 } |
| 64 | 63 |
| 65 void executeCalculateDrawTransformsAndVisibility(LayerImpl* rootLayer, float dev
iceScaleFactor = 1, float pageScaleFactor = 1) | 64 void executeCalculateDrawTransformsAndVisibility(LayerImpl* rootLayer, float dev
iceScaleFactor = 1, float pageScaleFactor = 1) |
| 66 { | 65 { |
| 67 // Note: this version skips layer sorting. | 66 // Note: this version skips layer sorting. |
| 68 | 67 |
| 69 WebTransformationMatrix identityMatrix; | 68 gfx::Transform identityMatrix; |
| 70 std::vector<LayerImpl*> dummyRenderSurfaceLayerList; | 69 std::vector<LayerImpl*> dummyRenderSurfaceLayerList; |
| 71 int dummyMaxTextureSize = 512; | 70 int dummyMaxTextureSize = 512; |
| 72 gfx::Size deviceViewportSize = gfx::Size(rootLayer->bounds().width() * devic
eScaleFactor, rootLayer->bounds().height() * deviceScaleFactor); | 71 gfx::Size deviceViewportSize = gfx::Size(rootLayer->bounds().width() * devic
eScaleFactor, rootLayer->bounds().height() * deviceScaleFactor); |
| 73 | 72 |
| 74 // We are probably not testing what is intended if the rootLayer bounds are
empty. | 73 // We are probably not testing what is intended if the rootLayer bounds are
empty. |
| 75 DCHECK(!rootLayer->bounds().IsEmpty()); | 74 DCHECK(!rootLayer->bounds().IsEmpty()); |
| 76 LayerTreeHostCommon::calculateDrawTransforms(rootLayer, deviceViewportSize,
deviceScaleFactor, pageScaleFactor, 0, dummyMaxTextureSize, dummyRenderSurfaceLa
yerList); | 75 LayerTreeHostCommon::calculateDrawTransforms(rootLayer, deviceViewportSize,
deviceScaleFactor, pageScaleFactor, 0, dummyMaxTextureSize, dummyRenderSurfaceLa
yerList); |
| 77 } | 76 } |
| 78 | 77 |
| 79 WebTransformationMatrix remove3DComponentOfMatrix(const WebTransformationMatrix&
mat) | |
| 80 { | |
| 81 WebTransformationMatrix ret = mat; | |
| 82 ret.setM13(0); | |
| 83 ret.setM23(0); | |
| 84 ret.setM31(0); | |
| 85 ret.setM32(0); | |
| 86 ret.setM33(1); | |
| 87 ret.setM34(0); | |
| 88 ret.setM43(0); | |
| 89 return ret; | |
| 90 } | |
| 91 | |
| 92 scoped_ptr<LayerImpl> createTreeForFixedPositionTests() | 78 scoped_ptr<LayerImpl> createTreeForFixedPositionTests() |
| 93 { | 79 { |
| 94 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 80 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
| 95 scoped_ptr<LayerImpl> child = LayerImpl::create(2); | 81 scoped_ptr<LayerImpl> child = LayerImpl::create(2); |
| 96 scoped_ptr<LayerImpl> grandChild = LayerImpl::create(3); | 82 scoped_ptr<LayerImpl> grandChild = LayerImpl::create(3); |
| 97 scoped_ptr<LayerImpl> greatGrandChild = LayerImpl::create(4); | 83 scoped_ptr<LayerImpl> greatGrandChild = LayerImpl::create(4); |
| 98 | 84 |
| 99 WebTransformationMatrix IdentityMatrix; | 85 gfx::Transform IdentityMatrix; |
| 100 gfx::PointF anchor(0, 0); | 86 gfx::PointF anchor(0, 0); |
| 101 gfx::PointF position(0, 0); | 87 gfx::PointF position(0, 0); |
| 102 gfx::Size bounds(100, 100); | 88 gfx::Size bounds(100, 100); |
| 103 setLayerPropertiesForTesting(root.get(), IdentityMatrix, IdentityMatrix, anc
hor, position, bounds, false); | 89 setLayerPropertiesForTesting(root.get(), IdentityMatrix, IdentityMatrix, anc
hor, position, bounds, false); |
| 104 setLayerPropertiesForTesting(child.get(), IdentityMatrix, IdentityMatrix, an
chor, position, bounds, false); | 90 setLayerPropertiesForTesting(child.get(), IdentityMatrix, IdentityMatrix, an
chor, position, bounds, false); |
| 105 setLayerPropertiesForTesting(grandChild.get(), IdentityMatrix, IdentityMatri
x, anchor, position, bounds, false); | 91 setLayerPropertiesForTesting(grandChild.get(), IdentityMatrix, IdentityMatri
x, anchor, position, bounds, false); |
| 106 setLayerPropertiesForTesting(greatGrandChild.get(), IdentityMatrix, Identity
Matrix, anchor, position, bounds, false); | 92 setLayerPropertiesForTesting(greatGrandChild.get(), IdentityMatrix, Identity
Matrix, anchor, position, bounds, false); |
| 107 | 93 |
| 108 grandChild->addChild(greatGrandChild.Pass()); | 94 grandChild->addChild(greatGrandChild.Pass()); |
| 109 child->addChild(grandChild.Pass()); | 95 child->addChild(grandChild.Pass()); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 // and with identity transforms, then the drawTransform, | 139 // and with identity transforms, then the drawTransform, |
| 154 // screenSpaceTransform, and the hierarchy passed on to children | 140 // screenSpaceTransform, and the hierarchy passed on to children |
| 155 // layers should also be identity transforms. | 141 // layers should also be identity transforms. |
| 156 | 142 |
| 157 scoped_refptr<Layer> parent = Layer::create(); | 143 scoped_refptr<Layer> parent = Layer::create(); |
| 158 scoped_refptr<Layer> child = Layer::create(); | 144 scoped_refptr<Layer> child = Layer::create(); |
| 159 scoped_refptr<Layer> grandChild = Layer::create(); | 145 scoped_refptr<Layer> grandChild = Layer::create(); |
| 160 parent->addChild(child); | 146 parent->addChild(child); |
| 161 child->addChild(grandChild); | 147 child->addChild(grandChild); |
| 162 | 148 |
| 163 WebTransformationMatrix identityMatrix; | 149 gfx::Transform identityMatrix; |
| 164 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 150 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 165 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(0, 0), false); | 151 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(0, 0), false); |
| 166 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(0, 0), false); | 152 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(0, 0), false); |
| 167 | 153 |
| 168 executeCalculateDrawTransformsAndVisibility(parent.get()); | 154 executeCalculateDrawTransformsAndVisibility(parent.get()); |
| 169 | 155 |
| 170 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); | 156 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); |
| 171 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->screenSpaceTransform(
)); | 157 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->screenSpaceTransform(
)); |
| 172 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->drawTransform())
; | 158 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->drawTransform())
; |
| 173 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->screenSpaceTrans
form()); | 159 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->screenSpaceTrans
form()); |
| 174 } | 160 } |
| 175 | 161 |
| 176 TEST(LayerTreeHostCommonTest, verifyTransformsForSingleLayer) | 162 TEST(LayerTreeHostCommonTest, verifyTransformsForSingleLayer) |
| 177 { | 163 { |
| 178 WebTransformationMatrix identityMatrix; | 164 gfx::Transform identityMatrix; |
| 179 scoped_refptr<Layer> layer = Layer::create(); | 165 scoped_refptr<Layer> layer = Layer::create(); |
| 180 | 166 |
| 181 scoped_refptr<Layer> root = Layer::create(); | 167 scoped_refptr<Layer> root = Layer::create(); |
| 182 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 2), false); | 168 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 2), false); |
| 183 root->addChild(layer); | 169 root->addChild(layer); |
| 184 | 170 |
| 185 // Case 1: setting the sublayer transform should not affect this layer's dra
w transform or screen-space transform. | 171 // Case 1: setting the sublayer transform should not affect this layer's dra
w transform or screen-space transform. |
| 186 WebTransformationMatrix arbitraryTranslation; | 172 gfx::Transform arbitraryTranslation; |
| 187 arbitraryTranslation.translate(10, 20); | 173 arbitraryTranslation.Translate(10, 20); |
| 188 setLayerPropertiesForTesting(layer.get(), identityMatrix, arbitraryTranslati
on, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 174 setLayerPropertiesForTesting(layer.get(), identityMatrix, arbitraryTranslati
on, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 189 executeCalculateDrawTransformsAndVisibility(root.get()); | 175 executeCalculateDrawTransformsAndVisibility(root.get()); |
| 190 WebTransformationMatrix expectedDrawTransform = identityMatrix; | 176 gfx::Transform expectedDrawTransform = identityMatrix; |
| 191 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedDrawTransform, layer->drawTransform(
)); | 177 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedDrawTransform, layer->drawTransform(
)); |
| 192 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, layer->screenSpaceTransform(
)); | 178 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, layer->screenSpaceTransform(
)); |
| 193 | 179 |
| 194 // Case 2: Setting the bounds of the layer should not affect either the draw
transform or the screenspace transform. | 180 // Case 2: Setting the bounds of the layer should not affect either the draw
transform or the screenspace transform. |
| 195 WebTransformationMatrix translationToCenter; | 181 gfx::Transform translationToCenter; |
| 196 translationToCenter.translate(5, 6); | 182 translationToCenter.Translate(5, 6); |
| 197 setLayerPropertiesForTesting(layer.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 12), false); | 183 setLayerPropertiesForTesting(layer.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 12), false); |
| 198 executeCalculateDrawTransformsAndVisibility(root.get()); | 184 executeCalculateDrawTransformsAndVisibility(root.get()); |
| 199 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, layer->drawTransform()); | 185 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, layer->drawTransform()); |
| 200 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, layer->screenSpaceTransform(
)); | 186 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, layer->screenSpaceTransform(
)); |
| 201 | 187 |
| 202 // Case 3: The anchor point by itself (without a layer transform) should hav
e no effect on the transforms. | 188 // Case 3: The anchor point by itself (without a layer transform) should hav
e no effect on the transforms. |
| 203 setLayerPropertiesForTesting(layer.get(), identityMatrix, identityMatrix, gf
x::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(10, 12), false); | 189 setLayerPropertiesForTesting(layer.get(), identityMatrix, identityMatrix, gf
x::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(10, 12), false); |
| 204 executeCalculateDrawTransformsAndVisibility(root.get()); | 190 executeCalculateDrawTransformsAndVisibility(root.get()); |
| 205 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, layer->drawTransform()); | 191 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, layer->drawTransform()); |
| 206 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, layer->screenSpaceTransform(
)); | 192 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, layer->screenSpaceTransform(
)); |
| 207 | 193 |
| 208 // Case 4: A change in actual position affects both the draw transform and s
creen space transform. | 194 // Case 4: A change in actual position affects both the draw transform and s
creen space transform. |
| 209 WebTransformationMatrix positionTransform; | 195 gfx::Transform positionTransform; |
| 210 positionTransform.translate(0, 1.2); | 196 positionTransform.Translate(0, 1.2); |
| 211 setLayerPropertiesForTesting(layer.get(), identityMatrix, identityMatrix, gf
x::PointF(0.25, 0.25), gfx::PointF(0, 1.2f), gfx::Size(10, 12), false); | 197 setLayerPropertiesForTesting(layer.get(), identityMatrix, identityMatrix, gf
x::PointF(0.25, 0.25), gfx::PointF(0, 1.2f), gfx::Size(10, 12), false); |
| 212 executeCalculateDrawTransformsAndVisibility(root.get()); | 198 executeCalculateDrawTransformsAndVisibility(root.get()); |
| 213 EXPECT_TRANSFORMATION_MATRIX_EQ(positionTransform, layer->drawTransform()); | 199 EXPECT_TRANSFORMATION_MATRIX_EQ(positionTransform, layer->drawTransform()); |
| 214 EXPECT_TRANSFORMATION_MATRIX_EQ(positionTransform, layer->screenSpaceTransfo
rm()); | 200 EXPECT_TRANSFORMATION_MATRIX_EQ(positionTransform, layer->screenSpaceTransfo
rm()); |
| 215 | 201 |
| 216 // Case 5: In the correct sequence of transforms, the layer transform should
pre-multiply the translationToCenter. This is easily tested by | 202 // Case 5: In the correct sequence of transforms, the layer transform should
pre-multiply the translationToCenter. This is easily tested by |
| 217 // using a scale transform, because scale and translation are not co
mmutative. | 203 // using a scale transform, because scale and translation are not co
mmutative. |
| 218 WebTransformationMatrix layerTransform; | 204 gfx::Transform layerTransform; |
| 219 layerTransform.scale3d(2, 2, 1); | 205 layerTransform.Scale3d(2, 2, 1); |
| 220 setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 12), false); | 206 setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 12), false); |
| 221 executeCalculateDrawTransformsAndVisibility(root.get()); | 207 executeCalculateDrawTransformsAndVisibility(root.get()); |
| 222 EXPECT_TRANSFORMATION_MATRIX_EQ(layerTransform, layer->drawTransform()); | 208 EXPECT_TRANSFORMATION_MATRIX_EQ(layerTransform, layer->drawTransform()); |
| 223 EXPECT_TRANSFORMATION_MATRIX_EQ(layerTransform, layer->screenSpaceTransform(
)); | 209 EXPECT_TRANSFORMATION_MATRIX_EQ(layerTransform, layer->screenSpaceTransform(
)); |
| 224 | 210 |
| 225 // Case 6: The layer transform should occur with respect to the anchor point
. | 211 // Case 6: The layer transform should occur with respect to the anchor point
. |
| 226 WebTransformationMatrix translationToAnchor; | 212 gfx::Transform translationToAnchor; |
| 227 translationToAnchor.translate(5, 0); | 213 translationToAnchor.Translate(5, 0); |
| 228 WebTransformationMatrix expectedResult = translationToAnchor * layerTransfor
m * translationToAnchor.inverse(); | 214 gfx::Transform expectedResult = translationToAnchor * layerTransform * MathU
til::inverse(translationToAnchor); |
| 229 setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, gf
x::PointF(0.5, 0), gfx::PointF(0, 0), gfx::Size(10, 12), false); | 215 setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, gf
x::PointF(0.5, 0), gfx::PointF(0, 0), gfx::Size(10, 12), false); |
| 230 executeCalculateDrawTransformsAndVisibility(root.get()); | 216 executeCalculateDrawTransformsAndVisibility(root.get()); |
| 231 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->drawTransform()); | 217 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->drawTransform()); |
| 232 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->screenSpaceTransform(
)); | 218 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->screenSpaceTransform(
)); |
| 233 | 219 |
| 234 // Case 7: Verify that position pre-multiplies the layer transform. | 220 // Case 7: Verify that position pre-multiplies the layer transform. |
| 235 // The current implementation of calculateDrawTransforms does this i
mplicitly, but it is | 221 // The current implementation of calculateDrawTransforms does this i
mplicitly, but it is |
| 236 // still worth testing to detect accidental regressions. | 222 // still worth testing to detect accidental regressions. |
| 237 expectedResult = positionTransform * translationToAnchor * layerTransform *
translationToAnchor.inverse(); | 223 expectedResult = positionTransform * translationToAnchor * layerTransform *
MathUtil::inverse(translationToAnchor); |
| 238 setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, gf
x::PointF(0.5, 0), gfx::PointF(0, 1.2f), gfx::Size(10, 12), false); | 224 setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, gf
x::PointF(0.5, 0), gfx::PointF(0, 1.2f), gfx::Size(10, 12), false); |
| 239 executeCalculateDrawTransformsAndVisibility(root.get()); | 225 executeCalculateDrawTransformsAndVisibility(root.get()); |
| 240 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->drawTransform()); | 226 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->drawTransform()); |
| 241 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->screenSpaceTransform(
)); | 227 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->screenSpaceTransform(
)); |
| 242 } | 228 } |
| 243 | 229 |
| 244 TEST(LayerTreeHostCommonTest, verifyTransformsForSimpleHierarchy) | 230 TEST(LayerTreeHostCommonTest, verifyTransformsForSimpleHierarchy) |
| 245 { | 231 { |
| 246 WebTransformationMatrix identityMatrix; | 232 gfx::Transform identityMatrix; |
| 247 scoped_refptr<Layer> root = Layer::create(); | 233 scoped_refptr<Layer> root = Layer::create(); |
| 248 scoped_refptr<Layer> parent = Layer::create(); | 234 scoped_refptr<Layer> parent = Layer::create(); |
| 249 scoped_refptr<Layer> child = Layer::create(); | 235 scoped_refptr<Layer> child = Layer::create(); |
| 250 scoped_refptr<Layer> grandChild = Layer::create(); | 236 scoped_refptr<Layer> grandChild = Layer::create(); |
| 251 root->addChild(parent); | 237 root->addChild(parent); |
| 252 parent->addChild(child); | 238 parent->addChild(child); |
| 253 child->addChild(grandChild); | 239 child->addChild(grandChild); |
| 254 | 240 |
| 255 // One-time setup of root layer | 241 // One-time setup of root layer |
| 256 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 2), false); | 242 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 2), false); |
| 257 | 243 |
| 258 // Case 1: parent's anchorPoint should not affect child or grandChild. | 244 // Case 1: parent's anchorPoint should not affect child or grandChild. |
| 259 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(10, 12), false); | 245 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(10, 12), false); |
| 260 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); | 246 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); |
| 261 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(76, 78), false); | 247 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(76, 78), false); |
| 262 executeCalculateDrawTransformsAndVisibility(root.get()); | 248 executeCalculateDrawTransformsAndVisibility(root.get()); |
| 263 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); | 249 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); |
| 264 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->screenSpaceTransform(
)); | 250 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->screenSpaceTransform(
)); |
| 265 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->drawTransform())
; | 251 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->drawTransform())
; |
| 266 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->screenSpaceTrans
form()); | 252 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->screenSpaceTrans
form()); |
| 267 | 253 |
| 268 // Case 2: parent's position affects child and grandChild. | 254 // Case 2: parent's position affects child and grandChild. |
| 269 WebTransformationMatrix parentPositionTransform; | 255 gfx::Transform parentPositionTransform; |
| 270 parentPositionTransform.translate(0, 1.2); | 256 parentPositionTransform.Translate(0, 1.2); |
| 271 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0.25, 0.25), gfx::PointF(0, 1.2f), gfx::Size(10, 12), false); | 257 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0.25, 0.25), gfx::PointF(0, 1.2f), gfx::Size(10, 12), false); |
| 272 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); | 258 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); |
| 273 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(76, 78), false); | 259 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(76, 78), false); |
| 274 executeCalculateDrawTransformsAndVisibility(root.get()); | 260 executeCalculateDrawTransformsAndVisibility(root.get()); |
| 275 EXPECT_TRANSFORMATION_MATRIX_EQ(parentPositionTransform, child->drawTransfor
m()); | 261 EXPECT_TRANSFORMATION_MATRIX_EQ(parentPositionTransform, child->drawTransfor
m()); |
| 276 EXPECT_TRANSFORMATION_MATRIX_EQ(parentPositionTransform, child->screenSpaceT
ransform()); | 262 EXPECT_TRANSFORMATION_MATRIX_EQ(parentPositionTransform, child->screenSpaceT
ransform()); |
| 277 EXPECT_TRANSFORMATION_MATRIX_EQ(parentPositionTransform, grandChild->drawTra
nsform()); | 263 EXPECT_TRANSFORMATION_MATRIX_EQ(parentPositionTransform, grandChild->drawTra
nsform()); |
| 278 EXPECT_TRANSFORMATION_MATRIX_EQ(parentPositionTransform, grandChild->screenS
paceTransform()); | 264 EXPECT_TRANSFORMATION_MATRIX_EQ(parentPositionTransform, grandChild->screenS
paceTransform()); |
| 279 | 265 |
| 280 // Case 3: parent's local transform affects child and grandchild | 266 // Case 3: parent's local transform affects child and grandchild |
| 281 WebTransformationMatrix parentLayerTransform; | 267 gfx::Transform parentLayerTransform; |
| 282 parentLayerTransform.scale3d(2, 2, 1); | 268 parentLayerTransform.Scale3d(2, 2, 1); |
| 283 WebTransformationMatrix parentTranslationToAnchor; | 269 gfx::Transform parentTranslationToAnchor; |
| 284 parentTranslationToAnchor.translate(2.5, 3); | 270 parentTranslationToAnchor.Translate(2.5, 3); |
| 285 WebTransformationMatrix parentCompositeTransform = parentTranslationToAnchor
* parentLayerTransform * parentTranslationToAnchor.inverse(); | 271 gfx::Transform parentCompositeTransform = parentTranslationToAnchor * parent
LayerTransform * MathUtil::inverse(parentTranslationToAnchor); |
| 286 setLayerPropertiesForTesting(parent.get(), parentLayerTransform, identityMat
rix, gfx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(10, 12), false); | 272 setLayerPropertiesForTesting(parent.get(), parentLayerTransform, identityMat
rix, gfx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(10, 12), false); |
| 287 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); | 273 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); |
| 288 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(76, 78), false); | 274 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(76, 78), false); |
| 289 executeCalculateDrawTransformsAndVisibility(root.get()); | 275 executeCalculateDrawTransformsAndVisibility(root.get()); |
| 290 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->drawTransfo
rm()); | 276 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->drawTransfo
rm()); |
| 291 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->screenSpace
Transform()); | 277 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->screenSpace
Transform()); |
| 292 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, grandChild->drawTr
ansform()); | 278 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, grandChild->drawTr
ansform()); |
| 293 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, grandChild->screen
SpaceTransform()); | 279 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, grandChild->screen
SpaceTransform()); |
| 294 | 280 |
| 295 // Case 4: parent's sublayerMatrix affects child and grandchild | 281 // Case 4: parent's sublayerMatrix affects child and grandchild |
| 296 // scaling is used here again so that the correct sequence of transf
orms is properly tested. | 282 // scaling is used here again so that the correct sequence of transf
orms is properly tested. |
| 297 // Note that preserves3D is false, but the sublayer matrix should re
tain its 3D properties when given to child. | 283 // Note that preserves3D is false, but the sublayer matrix should re
tain its 3D properties when given to child. |
| 298 // But then, the child also does not preserve3D. When it gives its h
ierarchy to the grandChild, it should be flattened to 2D. | 284 // But then, the child also does not preserve3D. When it gives its h
ierarchy to the grandChild, it should be flattened to 2D. |
| 299 WebTransformationMatrix parentSublayerMatrix; | 285 gfx::Transform parentSublayerMatrix; |
| 300 parentSublayerMatrix.scale3d(10, 10, 3.3); | 286 parentSublayerMatrix.Scale3d(10, 10, 3.3); |
| 301 WebTransformationMatrix parentTranslationToCenter; | 287 gfx::Transform parentTranslationToCenter; |
| 302 parentTranslationToCenter.translate(5, 6); | 288 parentTranslationToCenter.Translate(5, 6); |
| 303 // Sublayer matrix is applied to the center of the parent layer. | 289 // Sublayer matrix is applied to the center of the parent layer. |
| 304 parentCompositeTransform = parentTranslationToAnchor * parentLayerTransform
* parentTranslationToAnchor.inverse() | 290 parentCompositeTransform = parentTranslationToAnchor * parentLayerTransform
* MathUtil::inverse(parentTranslationToAnchor) |
| 305 * parentTranslationToCenter * parentSublayerMatrix * parentTranslati
onToCenter.inverse(); | 291 * parentTranslationToCenter * parentSublayerMatrix * MathUtil::inver
se(parentTranslationToCenter); |
| 306 WebTransformationMatrix flattenedCompositeTransform = remove3DComponentOfMat
rix(parentCompositeTransform); | 292 gfx::Transform flattenedCompositeTransform = MathUtil::to2dTransform(parentC
ompositeTransform); |
| 307 setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSubla
yerMatrix, gfx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(10, 12), false)
; | 293 setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSubla
yerMatrix, gfx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(10, 12), false)
; |
| 308 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); | 294 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); |
| 309 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(76, 78), false); | 295 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(76, 78), false); |
| 310 executeCalculateDrawTransformsAndVisibility(root.get()); | 296 executeCalculateDrawTransformsAndVisibility(root.get()); |
| 311 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->drawTransfo
rm()); | 297 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->drawTransfo
rm()); |
| 312 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->screenSpace
Transform()); | 298 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->screenSpace
Transform()); |
| 313 EXPECT_TRANSFORMATION_MATRIX_EQ(flattenedCompositeTransform, grandChild->dra
wTransform()); | 299 EXPECT_TRANSFORMATION_MATRIX_EQ(flattenedCompositeTransform, grandChild->dra
wTransform()); |
| 314 EXPECT_TRANSFORMATION_MATRIX_EQ(flattenedCompositeTransform, grandChild->scr
eenSpaceTransform()); | 300 EXPECT_TRANSFORMATION_MATRIX_EQ(flattenedCompositeTransform, grandChild->scr
eenSpaceTransform()); |
| 315 | 301 |
| 316 // Case 5: same as Case 4, except that child does preserve 3D, so the grandC
hild should receive the non-flattened composite transform. | 302 // Case 5: same as Case 4, except that child does preserve 3D, so the grandC
hild should receive the non-flattened composite transform. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 329 { | 315 { |
| 330 scoped_refptr<Layer> root = Layer::create(); | 316 scoped_refptr<Layer> root = Layer::create(); |
| 331 scoped_refptr<Layer> parent = Layer::create(); | 317 scoped_refptr<Layer> parent = Layer::create(); |
| 332 scoped_refptr<Layer> child = Layer::create(); | 318 scoped_refptr<Layer> child = Layer::create(); |
| 333 scoped_refptr<LayerWithForcedDrawsContent> grandChild = make_scoped_refptr(n
ew LayerWithForcedDrawsContent()); | 319 scoped_refptr<LayerWithForcedDrawsContent> grandChild = make_scoped_refptr(n
ew LayerWithForcedDrawsContent()); |
| 334 root->addChild(parent); | 320 root->addChild(parent); |
| 335 parent->addChild(child); | 321 parent->addChild(child); |
| 336 child->addChild(grandChild); | 322 child->addChild(grandChild); |
| 337 | 323 |
| 338 // One-time setup of root layer | 324 // One-time setup of root layer |
| 339 WebTransformationMatrix identityMatrix; | 325 gfx::Transform identityMatrix; |
| 340 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 2), false); | 326 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 2), false); |
| 341 | 327 |
| 342 // Child is set up so that a new render surface should be created. | 328 // Child is set up so that a new render surface should be created. |
| 343 child->setOpacity(0.5); | 329 child->setOpacity(0.5); |
| 344 | 330 |
| 345 WebTransformationMatrix parentLayerTransform; | 331 gfx::Transform parentLayerTransform; |
| 346 parentLayerTransform.scale3d(1, 0.9, 1); | 332 parentLayerTransform.Scale3d(1, 0.9, 1); |
| 347 WebTransformationMatrix parentTranslationToAnchor; | 333 gfx::Transform parentTranslationToAnchor; |
| 348 parentTranslationToAnchor.translate(25, 30); | 334 parentTranslationToAnchor.Translate(25, 30); |
| 349 WebTransformationMatrix parentSublayerMatrix; | 335 gfx::Transform parentSublayerMatrix; |
| 350 parentSublayerMatrix.scale3d(0.9, 1, 3.3); | 336 parentSublayerMatrix.Scale3d(0.9, 1, 3.3); |
| 351 WebTransformationMatrix parentTranslationToCenter; | 337 gfx::Transform parentTranslationToCenter; |
| 352 parentTranslationToCenter.translate(50, 60); | 338 parentTranslationToCenter.Translate(50, 60); |
| 353 WebTransformationMatrix parentCompositeTransform = parentTranslationToAnchor
* parentLayerTransform * parentTranslationToAnchor.inverse() | 339 gfx::Transform parentCompositeTransform = parentTranslationToAnchor * parent
LayerTransform * MathUtil::inverse(parentTranslationToAnchor) |
| 354 * parentTranslationToCenter * parentSublayerMatrix * parentTranslati
onToCenter.inverse(); | 340 * parentTranslationToCenter * parentSublayerMatrix * MathUtil::inver
se(parentTranslationToCenter); |
| 355 gfx::Vector2dF parentCompositeScale = MathUtil::computeTransform2dScaleCompo
nents(parentCompositeTransform); | 341 gfx::Vector2dF parentCompositeScale = MathUtil::computeTransform2dScaleCompo
nents(parentCompositeTransform); |
| 356 WebTransformationMatrix surfaceSublayerTransform; | 342 gfx::Transform surfaceSublayerTransform; |
| 357 surfaceSublayerTransform.scaleNonUniform(parentCompositeScale.x(), parentCom
positeScale.y()); | 343 surfaceSublayerTransform.Scale(parentCompositeScale.x(), parentCompositeScal
e.y()); |
| 358 WebTransformationMatrix surfaceSublayerCompositeTransform = parentCompositeT
ransform * surfaceSublayerTransform.inverse(); | 344 gfx::Transform surfaceSublayerCompositeTransform = parentCompositeTransform
* MathUtil::inverse(surfaceSublayerTransform); |
| 359 | 345 |
| 360 // Child's render surface should not exist yet. | 346 // Child's render surface should not exist yet. |
| 361 ASSERT_FALSE(child->renderSurface()); | 347 ASSERT_FALSE(child->renderSurface()); |
| 362 | 348 |
| 363 setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSubla
yerMatrix, gfx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(100, 120), fals
e); | 349 setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSubla
yerMatrix, gfx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(100, 120), fals
e); |
| 364 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); | 350 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); |
| 365 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(8, 10), false); | 351 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(8, 10), false); |
| 366 executeCalculateDrawTransformsAndVisibility(root.get()); | 352 executeCalculateDrawTransformsAndVisibility(root.get()); |
| 367 | 353 |
| 368 // Render surface should have been created now. | 354 // Render surface should have been created now. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 388 scoped_refptr<Layer> parent = Layer::create(); | 374 scoped_refptr<Layer> parent = Layer::create(); |
| 389 scoped_refptr<Layer> child = Layer::create(); | 375 scoped_refptr<Layer> child = Layer::create(); |
| 390 scoped_refptr<Layer> childReplica = Layer::create(); | 376 scoped_refptr<Layer> childReplica = Layer::create(); |
| 391 scoped_refptr<LayerWithForcedDrawsContent> grandChild = make_scoped_refptr(n
ew LayerWithForcedDrawsContent()); | 377 scoped_refptr<LayerWithForcedDrawsContent> grandChild = make_scoped_refptr(n
ew LayerWithForcedDrawsContent()); |
| 392 root->addChild(parent); | 378 root->addChild(parent); |
| 393 parent->addChild(child); | 379 parent->addChild(child); |
| 394 child->addChild(grandChild); | 380 child->addChild(grandChild); |
| 395 child->setReplicaLayer(childReplica.get()); | 381 child->setReplicaLayer(childReplica.get()); |
| 396 | 382 |
| 397 // One-time setup of root layer | 383 // One-time setup of root layer |
| 398 WebTransformationMatrix identityMatrix; | 384 gfx::Transform identityMatrix; |
| 399 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 2), false); | 385 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 2), false); |
| 400 | 386 |
| 401 // Child is set up so that a new render surface should be created. | 387 // Child is set up so that a new render surface should be created. |
| 402 child->setOpacity(0.5); | 388 child->setOpacity(0.5); |
| 403 | 389 |
| 404 WebTransformationMatrix parentLayerTransform; | 390 gfx::Transform parentLayerTransform; |
| 405 parentLayerTransform.scale3d(2, 2, 1); | 391 parentLayerTransform.Scale3d(2, 2, 1); |
| 406 WebTransformationMatrix parentTranslationToAnchor; | 392 gfx::Transform parentTranslationToAnchor; |
| 407 parentTranslationToAnchor.translate(2.5, 3); | 393 parentTranslationToAnchor.Translate(2.5, 3); |
| 408 WebTransformationMatrix parentSublayerMatrix; | 394 gfx::Transform parentSublayerMatrix; |
| 409 parentSublayerMatrix.scale3d(10, 10, 3.3); | 395 parentSublayerMatrix.Scale3d(10, 10, 3.3); |
| 410 WebTransformationMatrix parentTranslationToCenter; | 396 gfx::Transform parentTranslationToCenter; |
| 411 parentTranslationToCenter.translate(5, 6); | 397 parentTranslationToCenter.Translate(5, 6); |
| 412 WebTransformationMatrix parentCompositeTransform = parentTranslationToAnchor
* parentLayerTransform * parentTranslationToAnchor.inverse() | 398 gfx::Transform parentCompositeTransform = parentTranslationToAnchor * parent
LayerTransform * MathUtil::inverse(parentTranslationToAnchor) |
| 413 * parentTranslationToCenter * parentSublayerMatrix * parentTranslati
onToCenter.inverse(); | 399 * parentTranslationToCenter * parentSublayerMatrix * MathUtil::inver
se(parentTranslationToCenter); |
| 414 WebTransformationMatrix childTranslationToCenter; | 400 gfx::Transform childTranslationToCenter; |
| 415 childTranslationToCenter.translate(8, 9); | 401 childTranslationToCenter.Translate(8, 9); |
| 416 WebTransformationMatrix replicaLayerTransform; | 402 gfx::Transform replicaLayerTransform; |
| 417 replicaLayerTransform.scale3d(3, 3, 1); | 403 replicaLayerTransform.Scale3d(3, 3, 1); |
| 418 gfx::Vector2dF parentCompositeScale = MathUtil::computeTransform2dScaleCompo
nents(parentCompositeTransform); | 404 gfx::Vector2dF parentCompositeScale = MathUtil::computeTransform2dScaleCompo
nents(parentCompositeTransform); |
| 419 WebTransformationMatrix surfaceSublayerTransform; | 405 gfx::Transform surfaceSublayerTransform; |
| 420 surfaceSublayerTransform.scaleNonUniform(parentCompositeScale.x(), parentCom
positeScale.y()); | 406 surfaceSublayerTransform.Scale(parentCompositeScale.x(), parentCompositeScal
e.y()); |
| 421 WebTransformationMatrix replicaCompositeTransform = parentCompositeTransform
* replicaLayerTransform * surfaceSublayerTransform.inverse(); | 407 gfx::Transform replicaCompositeTransform = parentCompositeTransform * replic
aLayerTransform * MathUtil::inverse(surfaceSublayerTransform); |
| 422 | 408 |
| 423 // Child's render surface should not exist yet. | 409 // Child's render surface should not exist yet. |
| 424 ASSERT_FALSE(child->renderSurface()); | 410 ASSERT_FALSE(child->renderSurface()); |
| 425 | 411 |
| 426 setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSubla
yerMatrix, gfx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(10, 12), false)
; | 412 setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSubla
yerMatrix, gfx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(10, 12), false)
; |
| 427 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); | 413 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); |
| 428 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(-0.5, -0.5), gfx::Size(1, 1), false); | 414 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(-0.5, -0.5), gfx::Size(1, 1), false); |
| 429 setLayerPropertiesForTesting(childReplica.get(), replicaLayerTransform, iden
tityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(0, 0), false); | 415 setLayerPropertiesForTesting(childReplica.get(), replicaLayerTransform, iden
tityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(0, 0), false); |
| 430 executeCalculateDrawTransformsAndVisibility(root.get()); | 416 executeCalculateDrawTransformsAndVisibility(root.get()); |
| 431 | 417 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 childOfRS1->addChild(grandChildOfRS1); | 454 childOfRS1->addChild(grandChildOfRS1); |
| 469 childOfRS2->addChild(grandChildOfRS2); | 455 childOfRS2->addChild(grandChildOfRS2); |
| 470 renderSurface1->setReplicaLayer(replicaOfRS1.get()); | 456 renderSurface1->setReplicaLayer(replicaOfRS1.get()); |
| 471 renderSurface2->setReplicaLayer(replicaOfRS2.get()); | 457 renderSurface2->setReplicaLayer(replicaOfRS2.get()); |
| 472 | 458 |
| 473 // In combination with descendantDrawsContent, opacity != 1 forces the layer
to have a new renderSurface. | 459 // In combination with descendantDrawsContent, opacity != 1 forces the layer
to have a new renderSurface. |
| 474 renderSurface1->setOpacity(0.5); | 460 renderSurface1->setOpacity(0.5); |
| 475 renderSurface2->setOpacity(0.33f); | 461 renderSurface2->setOpacity(0.33f); |
| 476 | 462 |
| 477 // One-time setup of root layer | 463 // One-time setup of root layer |
| 478 WebTransformationMatrix identityMatrix; | 464 gfx::Transform identityMatrix; |
| 479 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 2), false); | 465 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 2), false); |
| 480 | 466 |
| 481 // All layers in the tree are initialized with an anchor at .25 and a size o
f (10,10). | 467 // All layers in the tree are initialized with an anchor at .25 and a size o
f (10,10). |
| 482 // matrix "A" is the composite layer transform used in all layers, centered
about the anchor point | 468 // matrix "A" is the composite layer transform used in all layers, centered
about the anchor point |
| 483 // matrix "B" is the sublayer transform used in all layers, centered about t
he center position of the layer. | 469 // matrix "B" is the sublayer transform used in all layers, centered about t
he center position of the layer. |
| 484 // matrix "R" is the composite replica transform used in all replica layers. | 470 // matrix "R" is the composite replica transform used in all replica layers. |
| 485 // | 471 // |
| 486 // x component tests that layerTransform and sublayerTransform are done in t
he right order (translation and scale are noncommutative). | 472 // x component tests that layerTransform and sublayerTransform are done in t
he right order (translation and scale are noncommutative). |
| 487 // y component has a translation by 1 for every ancestor, which indicates th
e "depth" of the layer in the hierarchy. | 473 // y component has a translation by 1 for every ancestor, which indicates th
e "depth" of the layer in the hierarchy. |
| 488 WebTransformationMatrix translationToAnchor; | 474 gfx::Transform translationToAnchor; |
| 489 translationToAnchor.translate(2.5, 0); | 475 translationToAnchor.Translate(2.5, 0); |
| 490 WebTransformationMatrix translationToCenter; | 476 gfx::Transform translationToCenter; |
| 491 translationToCenter.translate(5, 5); | 477 translationToCenter.Translate(5, 5); |
| 492 WebTransformationMatrix layerTransform; | 478 gfx::Transform layerTransform; |
| 493 layerTransform.translate(1, 1); | 479 layerTransform.Translate(1, 1); |
| 494 WebTransformationMatrix sublayerTransform; | 480 gfx::Transform sublayerTransform; |
| 495 sublayerTransform.scale3d(10, 1, 1); | 481 sublayerTransform.Scale3d(10, 1, 1); |
| 496 WebTransformationMatrix replicaLayerTransform; | 482 gfx::Transform replicaLayerTransform; |
| 497 replicaLayerTransform.scale3d(-2, 5, 1); | 483 replicaLayerTransform.Scale3d(-2, 5, 1); |
| 498 | 484 |
| 499 WebTransformationMatrix A = translationToAnchor * layerTransform * translati
onToAnchor.inverse(); | 485 gfx::Transform A = translationToAnchor * layerTransform * MathUtil::inverse(
translationToAnchor); |
| 500 WebTransformationMatrix B = translationToCenter * sublayerTransform * transl
ationToCenter.inverse(); | 486 gfx::Transform B = translationToCenter * sublayerTransform * MathUtil::inver
se(translationToCenter); |
| 501 WebTransformationMatrix R = A * translationToAnchor * replicaLayerTransform
* translationToAnchor.inverse(); | 487 gfx::Transform R = A * translationToAnchor * replicaLayerTransform * MathUti
l::inverse(translationToAnchor); |
| 502 | 488 |
| 503 gfx::Vector2dF surface1ParentTransformScale = MathUtil::computeTransform2dSc
aleComponents(A * B); | 489 gfx::Vector2dF surface1ParentTransformScale = MathUtil::computeTransform2dSc
aleComponents(A * B); |
| 504 WebTransformationMatrix surface1SublayerTransform; | 490 gfx::Transform surface1SublayerTransform; |
| 505 surface1SublayerTransform.scaleNonUniform(surface1ParentTransformScale.x(),
surface1ParentTransformScale.y()); | 491 surface1SublayerTransform.Scale(surface1ParentTransformScale.x(), surface1Pa
rentTransformScale.y()); |
| 506 | 492 |
| 507 // SS1 = transform given to the subtree of renderSurface1 | 493 // SS1 = transform given to the subtree of renderSurface1 |
| 508 WebTransformationMatrix SS1 = surface1SublayerTransform; | 494 gfx::Transform SS1 = surface1SublayerTransform; |
| 509 // S1 = transform to move from renderSurface1 pixels to the layer space of t
he owning layer | 495 // S1 = transform to move from renderSurface1 pixels to the layer space of t
he owning layer |
| 510 WebTransformationMatrix S1 = surface1SublayerTransform.inverse(); | 496 gfx::Transform S1 = MathUtil::inverse(surface1SublayerTransform); |
| 511 | 497 |
| 512 gfx::Vector2dF surface2ParentTransformScale = MathUtil::computeTransform2dSc
aleComponents(SS1 * A * B); | 498 gfx::Vector2dF surface2ParentTransformScale = MathUtil::computeTransform2dSc
aleComponents(SS1 * A * B); |
| 513 WebTransformationMatrix surface2SublayerTransform; | 499 gfx::Transform surface2SublayerTransform; |
| 514 surface2SublayerTransform.scaleNonUniform(surface2ParentTransformScale.x(),
surface2ParentTransformScale.y()); | 500 surface2SublayerTransform.Scale(surface2ParentTransformScale.x(), surface2Pa
rentTransformScale.y()); |
| 515 | 501 |
| 516 // SS2 = transform given to the subtree of renderSurface2 | 502 // SS2 = transform given to the subtree of renderSurface2 |
| 517 WebTransformationMatrix SS2 = surface2SublayerTransform; | 503 gfx::Transform SS2 = surface2SublayerTransform; |
| 518 // S2 = transform to move from renderSurface2 pixels to the layer space of t
he owning layer | 504 // S2 = transform to move from renderSurface2 pixels to the layer space of t
he owning layer |
| 519 WebTransformationMatrix S2 = surface2SublayerTransform.inverse(); | 505 gfx::Transform S2 = MathUtil::inverse(surface2SublayerTransform); |
| 520 | 506 |
| 521 setLayerPropertiesForTesting(parent.get(), layerTransform, sublayerTransform
, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 507 setLayerPropertiesForTesting(parent.get(), layerTransform, sublayerTransform
, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
| 522 setLayerPropertiesForTesting(renderSurface1.get(), layerTransform, sublayerT
ransform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 508 setLayerPropertiesForTesting(renderSurface1.get(), layerTransform, sublayerT
ransform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
| 523 setLayerPropertiesForTesting(renderSurface2.get(), layerTransform, sublayerT
ransform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 509 setLayerPropertiesForTesting(renderSurface2.get(), layerTransform, sublayerT
ransform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
| 524 setLayerPropertiesForTesting(childOfRoot.get(), layerTransform, sublayerTran
sform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 510 setLayerPropertiesForTesting(childOfRoot.get(), layerTransform, sublayerTran
sform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
| 525 setLayerPropertiesForTesting(childOfRS1.get(), layerTransform, sublayerTrans
form, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 511 setLayerPropertiesForTesting(childOfRS1.get(), layerTransform, sublayerTrans
form, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
| 526 setLayerPropertiesForTesting(childOfRS2.get(), layerTransform, sublayerTrans
form, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 512 setLayerPropertiesForTesting(childOfRS2.get(), layerTransform, sublayerTrans
form, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
| 527 setLayerPropertiesForTesting(grandChildOfRoot.get(), layerTransform, sublaye
rTransform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 513 setLayerPropertiesForTesting(grandChildOfRoot.get(), layerTransform, sublaye
rTransform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
| 528 setLayerPropertiesForTesting(grandChildOfRS1.get(), layerTransform, sublayer
Transform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 514 setLayerPropertiesForTesting(grandChildOfRS1.get(), layerTransform, sublayer
Transform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
| 529 setLayerPropertiesForTesting(grandChildOfRS2.get(), layerTransform, sublayer
Transform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 515 setLayerPropertiesForTesting(grandChildOfRS2.get(), layerTransform, sublayer
Transform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * R * S1, renderSurface1->renderSurfac
e()->replicaScreenSpaceTransform()); | 585 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * R * S1, renderSurface1->renderSurfac
e()->replicaScreenSpaceTransform()); |
| 600 // Draw transform of render surface 2 is described with respect to render su
rface 1. | 586 // Draw transform of render surface 2 is described with respect to render su
rface 1. |
| 601 EXPECT_TRANSFORMATION_MATRIX_EQ(SS1 * B * A * S2, renderSurface2->renderSurf
ace()->drawTransform()); | 587 EXPECT_TRANSFORMATION_MATRIX_EQ(SS1 * B * A * S2, renderSurface2->renderSurf
ace()->drawTransform()); |
| 602 EXPECT_TRANSFORMATION_MATRIX_EQ(SS1 * B * R * S2, renderSurface2->renderSurf
ace()->replicaDrawTransform()); | 588 EXPECT_TRANSFORMATION_MATRIX_EQ(SS1 * B * R * S2, renderSurface2->renderSurf
ace()->replicaDrawTransform()); |
| 603 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * A * S2, renderSurface2->rend
erSurface()->screenSpaceTransform()); | 589 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * A * S2, renderSurface2->rend
erSurface()->screenSpaceTransform()); |
| 604 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * R * S2, renderSurface2->rend
erSurface()->replicaScreenSpaceTransform()); | 590 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * R * S2, renderSurface2->rend
erSurface()->replicaScreenSpaceTransform()); |
| 605 | 591 |
| 606 // Sanity check. If these fail there is probably a bug in the test itself. | 592 // Sanity check. If these fail there is probably a bug in the test itself. |
| 607 // It is expected that we correctly set up transforms so that the y-componen
t of the screen-space transform | 593 // It is expected that we correctly set up transforms so that the y-componen
t of the screen-space transform |
| 608 // encodes the "depth" of the layer in the tree. | 594 // encodes the "depth" of the layer in the tree. |
| 609 EXPECT_FLOAT_EQ(1, parent->screenSpaceTransform().m42()); | 595 EXPECT_FLOAT_EQ(1, parent->screenSpaceTransform().matrix().getDouble(1, 3)); |
| 610 EXPECT_FLOAT_EQ(2, childOfRoot->screenSpaceTransform().m42()); | 596 EXPECT_FLOAT_EQ(2, childOfRoot->screenSpaceTransform().matrix().getDouble(1,
3)); |
| 611 EXPECT_FLOAT_EQ(3, grandChildOfRoot->screenSpaceTransform().m42()); | 597 EXPECT_FLOAT_EQ(3, grandChildOfRoot->screenSpaceTransform().matrix().getDoub
le(1, 3)); |
| 612 | 598 |
| 613 EXPECT_FLOAT_EQ(2, renderSurface1->screenSpaceTransform().m42()); | 599 EXPECT_FLOAT_EQ(2, renderSurface1->screenSpaceTransform().matrix().getDouble
(1, 3)); |
| 614 EXPECT_FLOAT_EQ(3, childOfRS1->screenSpaceTransform().m42()); | 600 EXPECT_FLOAT_EQ(3, childOfRS1->screenSpaceTransform().matrix().getDouble(1,
3)); |
| 615 EXPECT_FLOAT_EQ(4, grandChildOfRS1->screenSpaceTransform().m42()); | 601 EXPECT_FLOAT_EQ(4, grandChildOfRS1->screenSpaceTransform().matrix().getDoubl
e(1, 3)); |
| 616 | 602 |
| 617 EXPECT_FLOAT_EQ(3, renderSurface2->screenSpaceTransform().m42()); | 603 EXPECT_FLOAT_EQ(3, renderSurface2->screenSpaceTransform().matrix().getDouble
(1, 3)); |
| 618 EXPECT_FLOAT_EQ(4, childOfRS2->screenSpaceTransform().m42()); | 604 EXPECT_FLOAT_EQ(4, childOfRS2->screenSpaceTransform().matrix().getDouble(1,
3)); |
| 619 EXPECT_FLOAT_EQ(5, grandChildOfRS2->screenSpaceTransform().m42()); | 605 EXPECT_FLOAT_EQ(5, grandChildOfRS2->screenSpaceTransform().matrix().getDoubl
e(1, 3)); |
| 620 } | 606 } |
| 621 | 607 |
| 622 TEST(LayerTreeHostCommonTest, verifyTransformsForFlatteningLayer) | 608 TEST(LayerTreeHostCommonTest, verifyTransformsForFlatteningLayer) |
| 623 { | 609 { |
| 624 // For layers that flatten their subtree, there should be an orthographic pr
ojection | 610 // For layers that flatten their subtree, there should be an orthographic pr
ojection |
| 625 // (for x and y values) in the middle of the transform sequence. Note that t
he way the | 611 // (for x and y values) in the middle of the transform sequence. Note that t
he way the |
| 626 // code is currently implemented, it is not expected to use a canonical orth
ographic | 612 // code is currently implemented, it is not expected to use a canonical orth
ographic |
| 627 // projection. | 613 // projection. |
| 628 | 614 |
| 629 scoped_refptr<Layer> root = Layer::create(); | 615 scoped_refptr<Layer> root = Layer::create(); |
| 630 scoped_refptr<Layer> child = Layer::create(); | 616 scoped_refptr<Layer> child = Layer::create(); |
| 631 scoped_refptr<LayerWithForcedDrawsContent> grandChild = make_scoped_refptr(n
ew LayerWithForcedDrawsContent()); | 617 scoped_refptr<LayerWithForcedDrawsContent> grandChild = make_scoped_refptr(n
ew LayerWithForcedDrawsContent()); |
| 632 | 618 |
| 633 WebTransformationMatrix rotationAboutYAxis; | 619 gfx::Transform rotationAboutYAxis; |
| 634 rotationAboutYAxis.rotate3d(0, 30, 0); | 620 MathUtil::rotateEulerAngles(&rotationAboutYAxis, 0, 30, 0); |
| 635 | 621 |
| 636 const WebTransformationMatrix identityMatrix; | 622 const gfx::Transform identityMatrix; |
| 637 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(), gfx::PointF(), gfx::Size(100, 100), false); | 623 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(), gfx::PointF(), gfx::Size(100, 100), false); |
| 638 setLayerPropertiesForTesting(child.get(), rotationAboutYAxis, identityMatrix
, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); | 624 setLayerPropertiesForTesting(child.get(), rotationAboutYAxis, identityMatrix
, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); |
| 639 setLayerPropertiesForTesting(grandChild.get(), rotationAboutYAxis, identityM
atrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); | 625 setLayerPropertiesForTesting(grandChild.get(), rotationAboutYAxis, identityM
atrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); |
| 640 | 626 |
| 641 root->addChild(child); | 627 root->addChild(child); |
| 642 child->addChild(grandChild); | 628 child->addChild(grandChild); |
| 643 child->setForceRenderSurface(true); | 629 child->setForceRenderSurface(true); |
| 644 | 630 |
| 645 // No layers in this test should preserve 3d. | 631 // No layers in this test should preserve 3d. |
| 646 ASSERT_FALSE(root->preserves3D()); | 632 ASSERT_FALSE(root->preserves3D()); |
| 647 ASSERT_FALSE(child->preserves3D()); | 633 ASSERT_FALSE(child->preserves3D()); |
| 648 ASSERT_FALSE(grandChild->preserves3D()); | 634 ASSERT_FALSE(grandChild->preserves3D()); |
| 649 | 635 |
| 650 WebTransformationMatrix expectedChildDrawTransform = rotationAboutYAxis; | 636 gfx::Transform expectedChildDrawTransform = rotationAboutYAxis; |
| 651 WebTransformationMatrix expectedChildScreenSpaceTransform = rotationAboutYAx
is; | 637 gfx::Transform expectedChildScreenSpaceTransform = rotationAboutYAxis; |
| 652 WebTransformationMatrix expectedGrandChildDrawTransform = rotationAboutYAxis
; // draws onto child's renderSurface | 638 gfx::Transform expectedGrandChildDrawTransform = rotationAboutYAxis; // draw
s onto child's renderSurface |
| 653 WebTransformationMatrix expectedGrandChildScreenSpaceTransform = rotationAbo
utYAxis.to2dTransform() * rotationAboutYAxis; | 639 gfx::Transform expectedGrandChildScreenSpaceTransform = MathUtil::to2dTransf
orm(rotationAboutYAxis) * rotationAboutYAxis; |
| 654 | 640 |
| 655 executeCalculateDrawTransformsAndVisibility(root.get()); | 641 executeCalculateDrawTransformsAndVisibility(root.get()); |
| 656 | 642 |
| 657 // The child's drawTransform should have been taken by its surface. | 643 // The child's drawTransform should have been taken by its surface. |
| 658 ASSERT_TRUE(child->renderSurface()); | 644 ASSERT_TRUE(child->renderSurface()); |
| 659 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildDrawTransform, child->renderSur
face()->drawTransform()); | 645 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildDrawTransform, child->renderSur
face()->drawTransform()); |
| 660 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildScreenSpaceTransform, child->re
nderSurface()->screenSpaceTransform()); | 646 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildScreenSpaceTransform, child->re
nderSurface()->screenSpaceTransform()); |
| 661 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); | 647 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); |
| 662 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildScreenSpaceTransform, child->sc
reenSpaceTransform()); | 648 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildScreenSpaceTransform, child->sc
reenSpaceTransform()); |
| 663 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildDrawTransform, grandChild-
>drawTransform()); | 649 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildDrawTransform, grandChild-
>drawTransform()); |
| 664 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildScreenSpaceTransform, gran
dChild->screenSpaceTransform()); | 650 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildScreenSpaceTransform, gran
dChild->screenSpaceTransform()); |
| 665 } | 651 } |
| 666 | 652 |
| 667 TEST(LayerTreeHostCommonTest, verifyTransformsForDegenerateIntermediateLayer) | 653 TEST(LayerTreeHostCommonTest, verifyTransformsForDegenerateIntermediateLayer) |
| 668 { | 654 { |
| 669 // A layer that is empty in one axis, but not the other, was accidentally sk
ipping a necessary translation. | 655 // A layer that is empty in one axis, but not the other, was accidentally sk
ipping a necessary translation. |
| 670 // Without that translation, the coordinate space of the layer's drawTransfo
rm is incorrect. | 656 // Without that translation, the coordinate space of the layer's drawTransfo
rm is incorrect. |
| 671 // | 657 // |
| 672 // Normally this isn't a problem, because the layer wouldn't be drawn anyway
, but if that layer becomes a renderSurface, then | 658 // Normally this isn't a problem, because the layer wouldn't be drawn anyway
, but if that layer becomes a renderSurface, then |
| 673 // its drawTransform is implicitly inherited by the rest of the subtree, whi
ch then is positioned incorrectly as a result. | 659 // its drawTransform is implicitly inherited by the rest of the subtree, whi
ch then is positioned incorrectly as a result. |
| 674 | 660 |
| 675 scoped_refptr<Layer> root = Layer::create(); | 661 scoped_refptr<Layer> root = Layer::create(); |
| 676 scoped_refptr<Layer> child = Layer::create(); | 662 scoped_refptr<Layer> child = Layer::create(); |
| 677 scoped_refptr<LayerWithForcedDrawsContent> grandChild = make_scoped_refptr(n
ew LayerWithForcedDrawsContent()); | 663 scoped_refptr<LayerWithForcedDrawsContent> grandChild = make_scoped_refptr(n
ew LayerWithForcedDrawsContent()); |
| 678 | 664 |
| 679 // The child height is zero, but has non-zero width that should be accounted
for while computing drawTransforms. | 665 // The child height is zero, but has non-zero width that should be accounted
for while computing drawTransforms. |
| 680 const WebTransformationMatrix identityMatrix; | 666 const gfx::Transform identityMatrix; |
| 681 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(), gfx::PointF(), gfx::Size(100, 100), false); | 667 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(), gfx::PointF(), gfx::Size(100, 100), false); |
| 682 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(), gfx::PointF(), gfx::Size(10, 0), false); | 668 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(), gfx::PointF(), gfx::Size(10, 0), false); |
| 683 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); | 669 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); |
| 684 | 670 |
| 685 root->addChild(child); | 671 root->addChild(child); |
| 686 child->addChild(grandChild); | 672 child->addChild(grandChild); |
| 687 child->setForceRenderSurface(true); | 673 child->setForceRenderSurface(true); |
| 688 | 674 |
| 689 executeCalculateDrawTransformsAndVisibility(root.get()); | 675 executeCalculateDrawTransformsAndVisibility(root.get()); |
| 690 | 676 |
| 691 ASSERT_TRUE(child->renderSurface()); | 677 ASSERT_TRUE(child->renderSurface()); |
| 692 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->renderSurface()->draw
Transform()); // This is the real test, the rest are sanity checks. | 678 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->renderSurface()->draw
Transform()); // This is the real test, the rest are sanity checks. |
| 693 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); | 679 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); |
| 694 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->drawTransform())
; | 680 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->drawTransform())
; |
| 695 } | 681 } |
| 696 | 682 |
| 697 TEST(LayerTreeHostCommonTest, verifyRenderSurfaceListForRenderSurfaceWithClipped
Layer) | 683 TEST(LayerTreeHostCommonTest, verifyRenderSurfaceListForRenderSurfaceWithClipped
Layer) |
| 698 { | 684 { |
| 699 scoped_refptr<Layer> parent = Layer::create(); | 685 scoped_refptr<Layer> parent = Layer::create(); |
| 700 scoped_refptr<Layer> renderSurface1 = Layer::create(); | 686 scoped_refptr<Layer> renderSurface1 = Layer::create(); |
| 701 scoped_refptr<LayerWithForcedDrawsContent> child = make_scoped_refptr(new La
yerWithForcedDrawsContent()); | 687 scoped_refptr<LayerWithForcedDrawsContent> child = make_scoped_refptr(new La
yerWithForcedDrawsContent()); |
| 702 | 688 |
| 703 const WebTransformationMatrix identityMatrix; | 689 const gfx::Transform identityMatrix; |
| 704 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); | 690 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); |
| 705 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); | 691 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); |
| 706 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(), gfx::PointF(30, 30), gfx::Size(10, 10), false); | 692 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(), gfx::PointF(30, 30), gfx::Size(10, 10), false); |
| 707 | 693 |
| 708 parent->addChild(renderSurface1); | 694 parent->addChild(renderSurface1); |
| 709 parent->setMasksToBounds(true); | 695 parent->setMasksToBounds(true); |
| 710 renderSurface1->addChild(child); | 696 renderSurface1->addChild(child); |
| 711 renderSurface1->setForceRenderSurface(true); | 697 renderSurface1->setForceRenderSurface(true); |
| 712 | 698 |
| 713 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 699 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
| 714 int dummyMaxTextureSize = 512; | 700 int dummyMaxTextureSize = 512; |
| 715 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, renderSurfaceLayerList); | 701 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, renderSurfaceLayerList); |
| 716 | 702 |
| 717 // The child layer's content is entirely outside the parent's clip rect, so
the intermediate | 703 // The child layer's content is entirely outside the parent's clip rect, so
the intermediate |
| 718 // render surface should not be listed here, even if it was forced to be cre
ated. Render surfaces without children or visible | 704 // render surface should not be listed here, even if it was forced to be cre
ated. Render surfaces without children or visible |
| 719 // content are unexpected at draw time (e.g. we might try to create a conten
t texture of size 0). | 705 // content are unexpected at draw time (e.g. we might try to create a conten
t texture of size 0). |
| 720 ASSERT_TRUE(parent->renderSurface()); | 706 ASSERT_TRUE(parent->renderSurface()); |
| 721 ASSERT_FALSE(renderSurface1->renderSurface()); | 707 ASSERT_FALSE(renderSurface1->renderSurface()); |
| 722 EXPECT_EQ(1U, renderSurfaceLayerList.size()); | 708 EXPECT_EQ(1U, renderSurfaceLayerList.size()); |
| 723 } | 709 } |
| 724 | 710 |
| 725 TEST(LayerTreeHostCommonTest, verifyRenderSurfaceListForTransparentChild) | 711 TEST(LayerTreeHostCommonTest, verifyRenderSurfaceListForTransparentChild) |
| 726 { | 712 { |
| 727 scoped_refptr<Layer> parent = Layer::create(); | 713 scoped_refptr<Layer> parent = Layer::create(); |
| 728 scoped_refptr<Layer> renderSurface1 = Layer::create(); | 714 scoped_refptr<Layer> renderSurface1 = Layer::create(); |
| 729 scoped_refptr<LayerWithForcedDrawsContent> child = make_scoped_refptr(new La
yerWithForcedDrawsContent()); | 715 scoped_refptr<LayerWithForcedDrawsContent> child = make_scoped_refptr(new La
yerWithForcedDrawsContent()); |
| 730 | 716 |
| 731 const WebTransformationMatrix identityMatrix; | 717 const gfx::Transform identityMatrix; |
| 732 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); | 718 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); |
| 733 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(), gfx::PointF(), gfx::Size(10, 10), false); | 719 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(), gfx::PointF(), gfx::Size(10, 10), false); |
| 734 | 720 |
| 735 parent->addChild(renderSurface1); | 721 parent->addChild(renderSurface1); |
| 736 renderSurface1->addChild(child); | 722 renderSurface1->addChild(child); |
| 737 renderSurface1->setForceRenderSurface(true); | 723 renderSurface1->setForceRenderSurface(true); |
| 738 renderSurface1->setOpacity(0); | 724 renderSurface1->setOpacity(0); |
| 739 | 725 |
| 740 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 726 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
| 741 int dummyMaxTextureSize = 512; | 727 int dummyMaxTextureSize = 512; |
| 742 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, renderSurfaceLayerList); | 728 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, renderSurfaceLayerList); |
| 743 | 729 |
| 744 // Since the layer is transparent, renderSurface1->renderSurface() should no
t have gotten added anywhere. | 730 // Since the layer is transparent, renderSurface1->renderSurface() should no
t have gotten added anywhere. |
| 745 // Also, the drawable content rect should not have been extended by the chil
dren. | 731 // Also, the drawable content rect should not have been extended by the chil
dren. |
| 746 ASSERT_TRUE(parent->renderSurface()); | 732 ASSERT_TRUE(parent->renderSurface()); |
| 747 EXPECT_EQ(0U, parent->renderSurface()->layerList().size()); | 733 EXPECT_EQ(0U, parent->renderSurface()->layerList().size()); |
| 748 EXPECT_EQ(1U, renderSurfaceLayerList.size()); | 734 EXPECT_EQ(1U, renderSurfaceLayerList.size()); |
| 749 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); | 735 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); |
| 750 EXPECT_EQ(gfx::Rect(), parent->drawableContentRect()); | 736 EXPECT_EQ(gfx::Rect(), parent->drawableContentRect()); |
| 751 } | 737 } |
| 752 | 738 |
| 753 TEST(LayerTreeHostCommonTest, verifyForceRenderSurface) | 739 TEST(LayerTreeHostCommonTest, verifyForceRenderSurface) |
| 754 { | 740 { |
| 755 scoped_refptr<Layer> parent = Layer::create(); | 741 scoped_refptr<Layer> parent = Layer::create(); |
| 756 scoped_refptr<Layer> renderSurface1 = Layer::create(); | 742 scoped_refptr<Layer> renderSurface1 = Layer::create(); |
| 757 scoped_refptr<LayerWithForcedDrawsContent> child = make_scoped_refptr(new La
yerWithForcedDrawsContent()); | 743 scoped_refptr<LayerWithForcedDrawsContent> child = make_scoped_refptr(new La
yerWithForcedDrawsContent()); |
| 758 renderSurface1->setForceRenderSurface(true); | 744 renderSurface1->setForceRenderSurface(true); |
| 759 | 745 |
| 760 const WebTransformationMatrix identityMatrix; | 746 const gfx::Transform identityMatrix; |
| 761 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); | 747 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); |
| 762 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); | 748 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); |
| 763 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(), gfx::PointF(), gfx::Size(10, 10), false); | 749 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(), gfx::PointF(), gfx::Size(10, 10), false); |
| 764 | 750 |
| 765 parent->addChild(renderSurface1); | 751 parent->addChild(renderSurface1); |
| 766 renderSurface1->addChild(child); | 752 renderSurface1->addChild(child); |
| 767 | 753 |
| 768 // Sanity check before the actual test | 754 // Sanity check before the actual test |
| 769 EXPECT_FALSE(parent->renderSurface()); | 755 EXPECT_FALSE(parent->renderSurface()); |
| 770 EXPECT_FALSE(renderSurface1->renderSurface()); | 756 EXPECT_FALSE(renderSurface1->renderSurface()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 794 LayerImpl* child = root->children()[0]; | 780 LayerImpl* child = root->children()[0]; |
| 795 LayerImpl* grandChild = child->children()[0]; | 781 LayerImpl* grandChild = child->children()[0]; |
| 796 | 782 |
| 797 child->setIsContainerForFixedPositionLayers(true); | 783 child->setIsContainerForFixedPositionLayers(true); |
| 798 grandChild->setFixedToContainerLayer(true); | 784 grandChild->setFixedToContainerLayer(true); |
| 799 | 785 |
| 800 // Case 1: scrollDelta of 0, 0 | 786 // Case 1: scrollDelta of 0, 0 |
| 801 child->setScrollDelta(gfx::Vector2d(0, 0)); | 787 child->setScrollDelta(gfx::Vector2d(0, 0)); |
| 802 executeCalculateDrawTransformsAndVisibility(root.get()); | 788 executeCalculateDrawTransformsAndVisibility(root.get()); |
| 803 | 789 |
| 804 WebTransformationMatrix expectedChildTransform; | 790 gfx::Transform expectedChildTransform; |
| 805 WebTransformationMatrix expectedGrandChildTransform = expectedChildTransform
; | 791 gfx::Transform expectedGrandChildTransform = expectedChildTransform; |
| 806 | 792 |
| 807 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 793 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); |
| 808 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 794 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); |
| 809 | 795 |
| 810 // Case 2: scrollDelta of 10, 10 | 796 // Case 2: scrollDelta of 10, 10 |
| 811 child->setScrollDelta(gfx::Vector2d(10, 10)); | 797 child->setScrollDelta(gfx::Vector2d(10, 10)); |
| 812 executeCalculateDrawTransformsAndVisibility(root.get()); | 798 executeCalculateDrawTransformsAndVisibility(root.get()); |
| 813 | 799 |
| 814 // Here the child is affected by scrollDelta, but the fixed position grandCh
ild should not be affected. | 800 // Here the child is affected by scrollDelta, but the fixed position grandCh
ild should not be affected. |
| 815 expectedChildTransform.makeIdentity(); | 801 expectedChildTransform.MakeIdentity(); |
| 816 expectedChildTransform.translate(-10, -10); | 802 expectedChildTransform.Translate(-10, -10); |
| 817 | 803 |
| 818 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 804 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); |
| 819 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 805 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); |
| 820 } | 806 } |
| 821 | 807 |
| 822 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithT
ransformedDirectContainer) | 808 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithT
ransformedDirectContainer) |
| 823 { | 809 { |
| 824 // This test checks for correct scroll compensation when the fixed-position
container | 810 // This test checks for correct scroll compensation when the fixed-position
container |
| 825 // is the direct parent of the fixed-position layer, but that container is t
ransformed. | 811 // is the direct parent of the fixed-position layer, but that container is t
ransformed. |
| 826 // In this case, the fixed position element inherits the container's transfo
rm, | 812 // In this case, the fixed position element inherits the container's transfo
rm, |
| 827 // but the scrollDelta that has to be undone should not be affected by that
transform. | 813 // but the scrollDelta that has to be undone should not be affected by that
transform. |
| 828 // | 814 // |
| 829 // Transforms are in general non-commutative; using something like a non-uni
form scale | 815 // gfx::Transforms are in general non-commutative; using something like a no
n-uniform scale |
| 830 // helps to verify that translations and non-uniform scales are applied in t
he correct | 816 // helps to verify that translations and non-uniform scales are applied in t
he correct |
| 831 // order. | 817 // order. |
| 832 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); | 818 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); |
| 833 LayerImpl* child = root->children()[0]; | 819 LayerImpl* child = root->children()[0]; |
| 834 LayerImpl* grandChild = child->children()[0]; | 820 LayerImpl* grandChild = child->children()[0]; |
| 835 | 821 |
| 836 // This scale will cause child and grandChild to be effectively 200 x 800 wi
th respect to the renderTarget. | 822 // This scale will cause child and grandChild to be effectively 200 x 800 wi
th respect to the renderTarget. |
| 837 WebTransformationMatrix nonUniformScale; | 823 gfx::Transform nonUniformScale; |
| 838 nonUniformScale.scaleNonUniform(2, 8); | 824 nonUniformScale.Scale(2, 8); |
| 839 child->setTransform(nonUniformScale); | 825 child->setTransform(nonUniformScale); |
| 840 | 826 |
| 841 child->setIsContainerForFixedPositionLayers(true); | 827 child->setIsContainerForFixedPositionLayers(true); |
| 842 grandChild->setFixedToContainerLayer(true); | 828 grandChild->setFixedToContainerLayer(true); |
| 843 | 829 |
| 844 // Case 1: scrollDelta of 0, 0 | 830 // Case 1: scrollDelta of 0, 0 |
| 845 child->setScrollDelta(gfx::Vector2d(0, 0)); | 831 child->setScrollDelta(gfx::Vector2d(0, 0)); |
| 846 executeCalculateDrawTransformsAndVisibility(root.get()); | 832 executeCalculateDrawTransformsAndVisibility(root.get()); |
| 847 | 833 |
| 848 WebTransformationMatrix expectedChildTransform; | 834 gfx::Transform expectedChildTransform; |
| 849 expectedChildTransform.multiply(nonUniformScale); | 835 expectedChildTransform.PreconcatTransform(nonUniformScale); |
| 850 | 836 |
| 851 WebTransformationMatrix expectedGrandChildTransform = expectedChildTransform
; | 837 gfx::Transform expectedGrandChildTransform = expectedChildTransform; |
| 852 | 838 |
| 853 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 839 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); |
| 854 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 840 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); |
| 855 | 841 |
| 856 // Case 2: scrollDelta of 10, 20 | 842 // Case 2: scrollDelta of 10, 20 |
| 857 child->setScrollDelta(gfx::Vector2d(10, 20)); | 843 child->setScrollDelta(gfx::Vector2d(10, 20)); |
| 858 executeCalculateDrawTransformsAndVisibility(root.get()); | 844 executeCalculateDrawTransformsAndVisibility(root.get()); |
| 859 | 845 |
| 860 // The child should be affected by scrollDelta, but the fixed position grand
Child should not be affected. | 846 // The child should be affected by scrollDelta, but the fixed position grand
Child should not be affected. |
| 861 expectedChildTransform.makeIdentity(); | 847 expectedChildTransform.MakeIdentity(); |
| 862 expectedChildTransform.translate(-10, -20); // scrollDelta | 848 expectedChildTransform.Translate(-10, -20); // scrollDelta |
| 863 expectedChildTransform.multiply(nonUniformScale); | 849 expectedChildTransform.PreconcatTransform(nonUniformScale); |
| 864 | 850 |
| 865 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 851 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); |
| 866 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 852 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); |
| 867 } | 853 } |
| 868 | 854 |
| 869 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD
istantContainer) | 855 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD
istantContainer) |
| 870 { | 856 { |
| 871 // This test checks for correct scroll compensation when the fixed-position
container | 857 // This test checks for correct scroll compensation when the fixed-position
container |
| 872 // is NOT the direct parent of the fixed-position layer. | 858 // is NOT the direct parent of the fixed-position layer. |
| 873 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); | 859 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); |
| 874 LayerImpl* child = root->children()[0]; | 860 LayerImpl* child = root->children()[0]; |
| 875 LayerImpl* grandChild = child->children()[0]; | 861 LayerImpl* grandChild = child->children()[0]; |
| 876 LayerImpl* greatGrandChild = grandChild->children()[0]; | 862 LayerImpl* greatGrandChild = grandChild->children()[0]; |
| 877 | 863 |
| 878 child->setIsContainerForFixedPositionLayers(true); | 864 child->setIsContainerForFixedPositionLayers(true); |
| 879 grandChild->setPosition(gfx::PointF(8, 6)); | 865 grandChild->setPosition(gfx::PointF(8, 6)); |
| 880 greatGrandChild->setFixedToContainerLayer(true); | 866 greatGrandChild->setFixedToContainerLayer(true); |
| 881 | 867 |
| 882 // Case 1: scrollDelta of 0, 0 | 868 // Case 1: scrollDelta of 0, 0 |
| 883 child->setScrollDelta(gfx::Vector2d(0, 0)); | 869 child->setScrollDelta(gfx::Vector2d(0, 0)); |
| 884 executeCalculateDrawTransformsAndVisibility(root.get()); | 870 executeCalculateDrawTransformsAndVisibility(root.get()); |
| 885 | 871 |
| 886 WebTransformationMatrix expectedChildTransform; | 872 gfx::Transform expectedChildTransform; |
| 887 WebTransformationMatrix expectedGrandChildTransform; | 873 gfx::Transform expectedGrandChildTransform; |
| 888 expectedGrandChildTransform.translate(8, 6); | 874 expectedGrandChildTransform.Translate(8, 6); |
| 889 | 875 |
| 890 WebTransformationMatrix expectedGreatGrandChildTransform = expectedGrandChil
dTransform; | 876 gfx::Transform expectedGreatGrandChildTransform = expectedGrandChildTransfor
m; |
| 891 | 877 |
| 892 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 878 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); |
| 893 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 879 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); |
| 894 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); | 880 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); |
| 895 | 881 |
| 896 // Case 2: scrollDelta of 10, 10 | 882 // Case 2: scrollDelta of 10, 10 |
| 897 child->setScrollDelta(gfx::Vector2d(10, 10)); | 883 child->setScrollDelta(gfx::Vector2d(10, 10)); |
| 898 executeCalculateDrawTransformsAndVisibility(root.get()); | 884 executeCalculateDrawTransformsAndVisibility(root.get()); |
| 899 | 885 |
| 900 // Here the child and grandChild are affected by scrollDelta, but the fixed
position greatGrandChild should not be affected. | 886 // Here the child and grandChild are affected by scrollDelta, but the fixed
position greatGrandChild should not be affected. |
| 901 expectedChildTransform.makeIdentity(); | 887 expectedChildTransform.MakeIdentity(); |
| 902 expectedChildTransform.translate(-10, -10); | 888 expectedChildTransform.Translate(-10, -10); |
| 903 expectedGrandChildTransform.makeIdentity(); | 889 expectedGrandChildTransform.MakeIdentity(); |
| 904 expectedGrandChildTransform.translate(-2, -4); | 890 expectedGrandChildTransform.Translate(-2, -4); |
| 905 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 891 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); |
| 906 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 892 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); |
| 907 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); | 893 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); |
| 908 } | 894 } |
| 909 | 895 |
| 910 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD
istantContainerAndTransforms) | 896 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD
istantContainerAndTransforms) |
| 911 { | 897 { |
| 912 // This test checks for correct scroll compensation when the fixed-position
container | 898 // This test checks for correct scroll compensation when the fixed-position
container |
| 913 // is NOT the direct parent of the fixed-position layer, and the hierarchy h
as various | 899 // is NOT the direct parent of the fixed-position layer, and the hierarchy h
as various |
| 914 // transforms that have to be processed in the correct order. | 900 // transforms that have to be processed in the correct order. |
| 915 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); | 901 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); |
| 916 LayerImpl* child = root->children()[0]; | 902 LayerImpl* child = root->children()[0]; |
| 917 LayerImpl* grandChild = child->children()[0]; | 903 LayerImpl* grandChild = child->children()[0]; |
| 918 LayerImpl* greatGrandChild = grandChild->children()[0]; | 904 LayerImpl* greatGrandChild = grandChild->children()[0]; |
| 919 | 905 |
| 920 WebTransformationMatrix rotationAboutZ; | 906 gfx::Transform rotationAboutZ; |
| 921 rotationAboutZ.rotate3d(0, 0, 90); | 907 MathUtil::rotateEulerAngles(&rotationAboutZ, 0, 0, 90); |
| 922 | 908 |
| 923 child->setIsContainerForFixedPositionLayers(true); | 909 child->setIsContainerForFixedPositionLayers(true); |
| 924 child->setTransform(rotationAboutZ); | 910 child->setTransform(rotationAboutZ); |
| 925 grandChild->setPosition(gfx::PointF(8, 6)); | 911 grandChild->setPosition(gfx::PointF(8, 6)); |
| 926 grandChild->setTransform(rotationAboutZ); | 912 grandChild->setTransform(rotationAboutZ); |
| 927 greatGrandChild->setFixedToContainerLayer(true); // greatGrandChild is posit
ioned upside-down with respect to the renderTarget. | 913 greatGrandChild->setFixedToContainerLayer(true); // greatGrandChild is posit
ioned upside-down with respect to the renderTarget. |
| 928 | 914 |
| 929 // Case 1: scrollDelta of 0, 0 | 915 // Case 1: scrollDelta of 0, 0 |
| 930 child->setScrollDelta(gfx::Vector2d(0, 0)); | 916 child->setScrollDelta(gfx::Vector2d(0, 0)); |
| 931 executeCalculateDrawTransformsAndVisibility(root.get()); | 917 executeCalculateDrawTransformsAndVisibility(root.get()); |
| 932 | 918 |
| 933 WebTransformationMatrix expectedChildTransform; | 919 gfx::Transform expectedChildTransform; |
| 934 expectedChildTransform.multiply(rotationAboutZ); | 920 expectedChildTransform.PreconcatTransform(rotationAboutZ); |
| 935 | 921 |
| 936 WebTransformationMatrix expectedGrandChildTransform; | 922 gfx::Transform expectedGrandChildTransform; |
| 937 expectedGrandChildTransform.multiply(rotationAboutZ); // child's local trans
form is inherited | 923 expectedGrandChildTransform.PreconcatTransform(rotationAboutZ); // child's l
ocal transform is inherited |
| 938 expectedGrandChildTransform.translate(8, 6); // translation because of posit
ion occurs before layer's local transform. | 924 expectedGrandChildTransform.Translate(8, 6); // translation because of posit
ion occurs before layer's local transform. |
| 939 expectedGrandChildTransform.multiply(rotationAboutZ); // grandChild's local
transform | 925 expectedGrandChildTransform.PreconcatTransform(rotationAboutZ); // grandChil
d's local transform |
| 940 | 926 |
| 941 WebTransformationMatrix expectedGreatGrandChildTransform = expectedGrandChil
dTransform; | 927 gfx::Transform expectedGreatGrandChildTransform = expectedGrandChildTransfor
m; |
| 942 | 928 |
| 943 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 929 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); |
| 944 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 930 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); |
| 945 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); | 931 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); |
| 946 | 932 |
| 947 // Case 2: scrollDelta of 10, 20 | 933 // Case 2: scrollDelta of 10, 20 |
| 948 child->setScrollDelta(gfx::Vector2d(10, 20)); | 934 child->setScrollDelta(gfx::Vector2d(10, 20)); |
| 949 executeCalculateDrawTransformsAndVisibility(root.get()); | 935 executeCalculateDrawTransformsAndVisibility(root.get()); |
| 950 | 936 |
| 951 // Here the child and grandChild are affected by scrollDelta, but the fixed
position greatGrandChild should not be affected. | 937 // Here the child and grandChild are affected by scrollDelta, but the fixed
position greatGrandChild should not be affected. |
| 952 expectedChildTransform.makeIdentity(); | 938 expectedChildTransform.MakeIdentity(); |
| 953 expectedChildTransform.translate(-10, -20); // scrollDelta | 939 expectedChildTransform.Translate(-10, -20); // scrollDelta |
| 954 expectedChildTransform.multiply(rotationAboutZ); | 940 expectedChildTransform.PreconcatTransform(rotationAboutZ); |
| 955 | 941 |
| 956 expectedGrandChildTransform.makeIdentity(); | 942 expectedGrandChildTransform.MakeIdentity(); |
| 957 expectedGrandChildTransform.translate(-10, -20); // child's scrollDelta is i
nherited | 943 expectedGrandChildTransform.Translate(-10, -20); // child's scrollDelta is i
nherited |
| 958 expectedGrandChildTransform.multiply(rotationAboutZ); // child's local trans
form is inherited | 944 expectedGrandChildTransform.PreconcatTransform(rotationAboutZ); // child's l
ocal transform is inherited |
| 959 expectedGrandChildTransform.translate(8, 6); // translation because of posit
ion occurs before layer's local transform. | 945 expectedGrandChildTransform.Translate(8, 6); // translation because of posit
ion occurs before layer's local transform. |
| 960 expectedGrandChildTransform.multiply(rotationAboutZ); // grandChild's local
transform | 946 expectedGrandChildTransform.PreconcatTransform(rotationAboutZ); // grandChil
d's local transform |
| 961 | 947 |
| 962 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 948 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); |
| 963 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 949 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); |
| 964 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); | 950 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); |
| 965 } | 951 } |
| 966 | 952 |
| 967 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithM
ultipleScrollDeltas) | 953 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithM
ultipleScrollDeltas) |
| 968 { | 954 { |
| 969 // This test checks for correct scroll compensation when the fixed-position
container | 955 // This test checks for correct scroll compensation when the fixed-position
container |
| 970 // has multiple ancestors that have nonzero scrollDelta before reaching the
space where the layer is fixed. | 956 // has multiple ancestors that have nonzero scrollDelta before reaching the
space where the layer is fixed. |
| 971 // In this test, each scrollDelta occurs in a different space because of eac
h layer's local transform. | 957 // In this test, each scrollDelta occurs in a different space because of eac
h layer's local transform. |
| 972 // This test checks for correct scroll compensation when the fixed-position
container | 958 // This test checks for correct scroll compensation when the fixed-position
container |
| 973 // is NOT the direct parent of the fixed-position layer, and the hierarchy h
as various | 959 // is NOT the direct parent of the fixed-position layer, and the hierarchy h
as various |
| 974 // transforms that have to be processed in the correct order. | 960 // transforms that have to be processed in the correct order. |
| 975 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); | 961 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); |
| 976 LayerImpl* child = root->children()[0]; | 962 LayerImpl* child = root->children()[0]; |
| 977 LayerImpl* grandChild = child->children()[0]; | 963 LayerImpl* grandChild = child->children()[0]; |
| 978 LayerImpl* greatGrandChild = grandChild->children()[0]; | 964 LayerImpl* greatGrandChild = grandChild->children()[0]; |
| 979 | 965 |
| 980 WebTransformationMatrix rotationAboutZ; | 966 gfx::Transform rotationAboutZ; |
| 981 rotationAboutZ.rotate3d(0, 0, 90); | 967 MathUtil::rotateEulerAngles(&rotationAboutZ, 0, 0, 90); |
| 982 | 968 |
| 983 child->setIsContainerForFixedPositionLayers(true); | 969 child->setIsContainerForFixedPositionLayers(true); |
| 984 child->setTransform(rotationAboutZ); | 970 child->setTransform(rotationAboutZ); |
| 985 grandChild->setPosition(gfx::PointF(8, 6)); | 971 grandChild->setPosition(gfx::PointF(8, 6)); |
| 986 grandChild->setTransform(rotationAboutZ); | 972 grandChild->setTransform(rotationAboutZ); |
| 987 greatGrandChild->setFixedToContainerLayer(true); // greatGrandChild is posit
ioned upside-down with respect to the renderTarget. | 973 greatGrandChild->setFixedToContainerLayer(true); // greatGrandChild is posit
ioned upside-down with respect to the renderTarget. |
| 988 | 974 |
| 989 // Case 1: scrollDelta of 0, 0 | 975 // Case 1: scrollDelta of 0, 0 |
| 990 child->setScrollDelta(gfx::Vector2d(0, 0)); | 976 child->setScrollDelta(gfx::Vector2d(0, 0)); |
| 991 executeCalculateDrawTransformsAndVisibility(root.get()); | 977 executeCalculateDrawTransformsAndVisibility(root.get()); |
| 992 | 978 |
| 993 WebTransformationMatrix expectedChildTransform; | 979 gfx::Transform expectedChildTransform; |
| 994 expectedChildTransform.multiply(rotationAboutZ); | 980 expectedChildTransform.PreconcatTransform(rotationAboutZ); |
| 995 | 981 |
| 996 WebTransformationMatrix expectedGrandChildTransform; | 982 gfx::Transform expectedGrandChildTransform; |
| 997 expectedGrandChildTransform.multiply(rotationAboutZ); // child's local trans
form is inherited | 983 expectedGrandChildTransform.PreconcatTransform(rotationAboutZ); // child's l
ocal transform is inherited |
| 998 expectedGrandChildTransform.translate(8, 6); // translation because of posit
ion occurs before layer's local transform. | 984 expectedGrandChildTransform.Translate(8, 6); // translation because of posit
ion occurs before layer's local transform. |
| 999 expectedGrandChildTransform.multiply(rotationAboutZ); // grandChild's local
transform | 985 expectedGrandChildTransform.PreconcatTransform(rotationAboutZ); // grandChil
d's local transform |
| 1000 | 986 |
| 1001 WebTransformationMatrix expectedGreatGrandChildTransform = expectedGrandChil
dTransform; | 987 gfx::Transform expectedGreatGrandChildTransform = expectedGrandChildTransfor
m; |
| 1002 | 988 |
| 1003 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 989 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); |
| 1004 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 990 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); |
| 1005 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); | 991 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); |
| 1006 | 992 |
| 1007 // Case 2: scrollDelta of 10, 20 | 993 // Case 2: scrollDelta of 10, 20 |
| 1008 child->setScrollDelta(gfx::Vector2d(10, 0)); | 994 child->setScrollDelta(gfx::Vector2d(10, 0)); |
| 1009 grandChild->setScrollDelta(gfx::Vector2d(5, 0)); | 995 grandChild->setScrollDelta(gfx::Vector2d(5, 0)); |
| 1010 executeCalculateDrawTransformsAndVisibility(root.get()); | 996 executeCalculateDrawTransformsAndVisibility(root.get()); |
| 1011 | 997 |
| 1012 // Here the child and grandChild are affected by scrollDelta, but the fixed
position greatGrandChild should not be affected. | 998 // Here the child and grandChild are affected by scrollDelta, but the fixed
position greatGrandChild should not be affected. |
| 1013 expectedChildTransform.makeIdentity(); | 999 expectedChildTransform.MakeIdentity(); |
| 1014 expectedChildTransform.translate(-10, 0); // scrollDelta | 1000 expectedChildTransform.Translate(-10, 0); // scrollDelta |
| 1015 expectedChildTransform.multiply(rotationAboutZ); | 1001 expectedChildTransform.PreconcatTransform(rotationAboutZ); |
| 1016 | 1002 |
| 1017 expectedGrandChildTransform.makeIdentity(); | 1003 expectedGrandChildTransform.MakeIdentity(); |
| 1018 expectedGrandChildTransform.translate(-10, 0); // child's scrollDelta is inh
erited | 1004 expectedGrandChildTransform.Translate(-10, 0); // child's scrollDelta is inh
erited |
| 1019 expectedGrandChildTransform.multiply(rotationAboutZ); // child's local trans
form is inherited | 1005 expectedGrandChildTransform.PreconcatTransform(rotationAboutZ); // child's l
ocal transform is inherited |
| 1020 expectedGrandChildTransform.translate(-5, 0); // grandChild's scrollDelta | 1006 expectedGrandChildTransform.Translate(-5, 0); // grandChild's scrollDelta |
| 1021 expectedGrandChildTransform.translate(8, 6); // translation because of posit
ion occurs before layer's local transform. | 1007 expectedGrandChildTransform.Translate(8, 6); // translation because of posit
ion occurs before layer's local transform. |
| 1022 expectedGrandChildTransform.multiply(rotationAboutZ); // grandChild's local
transform | 1008 expectedGrandChildTransform.PreconcatTransform(rotationAboutZ); // grandChil
d's local transform |
| 1023 | 1009 |
| 1024 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 1010 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); |
| 1025 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 1011 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); |
| 1026 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); | 1012 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); |
| 1027 } | 1013 } |
| 1028 | 1014 |
| 1029 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithI
ntermediateSurfaceAndTransforms) | 1015 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithI
ntermediateSurfaceAndTransforms) |
| 1030 { | 1016 { |
| 1031 // This test checks for correct scroll compensation when the fixed-position
container | 1017 // This test checks for correct scroll compensation when the fixed-position
container |
| 1032 // contributes to a different renderSurface than the fixed-position layer. I
n this | 1018 // contributes to a different renderSurface than the fixed-position layer. I
n this |
| 1033 // case, the surface drawTransforms also have to be accounted for when check
ing the | 1019 // case, the surface drawTransforms also have to be accounted for when check
ing the |
| 1034 // scrollDelta. | 1020 // scrollDelta. |
| 1035 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); | 1021 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); |
| 1036 LayerImpl* child = root->children()[0]; | 1022 LayerImpl* child = root->children()[0]; |
| 1037 LayerImpl* grandChild = child->children()[0]; | 1023 LayerImpl* grandChild = child->children()[0]; |
| 1038 LayerImpl* greatGrandChild = grandChild->children()[0]; | 1024 LayerImpl* greatGrandChild = grandChild->children()[0]; |
| 1039 | 1025 |
| 1040 child->setIsContainerForFixedPositionLayers(true); | 1026 child->setIsContainerForFixedPositionLayers(true); |
| 1041 grandChild->setPosition(gfx::PointF(8, 6)); | 1027 grandChild->setPosition(gfx::PointF(8, 6)); |
| 1042 grandChild->setForceRenderSurface(true); | 1028 grandChild->setForceRenderSurface(true); |
| 1043 greatGrandChild->setFixedToContainerLayer(true); | 1029 greatGrandChild->setFixedToContainerLayer(true); |
| 1044 greatGrandChild->setDrawsContent(true); | 1030 greatGrandChild->setDrawsContent(true); |
| 1045 | 1031 |
| 1046 WebTransformationMatrix rotationAboutZ; | 1032 gfx::Transform rotationAboutZ; |
| 1047 rotationAboutZ.rotate3d(0, 0, 90); | 1033 MathUtil::rotateEulerAngles(&rotationAboutZ, 0, 0, 90); |
| 1048 grandChild->setTransform(rotationAboutZ); | 1034 grandChild->setTransform(rotationAboutZ); |
| 1049 | 1035 |
| 1050 // Case 1: scrollDelta of 0, 0 | 1036 // Case 1: scrollDelta of 0, 0 |
| 1051 child->setScrollDelta(gfx::Vector2d(0, 0)); | 1037 child->setScrollDelta(gfx::Vector2d(0, 0)); |
| 1052 executeCalculateDrawTransformsAndVisibility(root.get()); | 1038 executeCalculateDrawTransformsAndVisibility(root.get()); |
| 1053 | 1039 |
| 1054 WebTransformationMatrix expectedChildTransform; | 1040 gfx::Transform expectedChildTransform; |
| 1055 WebTransformationMatrix expectedSurfaceDrawTransform; | 1041 gfx::Transform expectedSurfaceDrawTransform; |
| 1056 expectedSurfaceDrawTransform.translate(8, 6); | 1042 expectedSurfaceDrawTransform.Translate(8, 6); |
| 1057 expectedSurfaceDrawTransform.multiply(rotationAboutZ); | 1043 expectedSurfaceDrawTransform.PreconcatTransform(rotationAboutZ); |
| 1058 WebTransformationMatrix expectedGrandChildTransform; | 1044 gfx::Transform expectedGrandChildTransform; |
| 1059 WebTransformationMatrix expectedGreatGrandChildTransform; | 1045 gfx::Transform expectedGreatGrandChildTransform; |
| 1060 ASSERT_TRUE(grandChild->renderSurface()); | 1046 ASSERT_TRUE(grandChild->renderSurface()); |
| 1061 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 1047 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); |
| 1062 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, grandChild->re
nderSurface()->drawTransform()); | 1048 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, grandChild->re
nderSurface()->drawTransform()); |
| 1063 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 1049 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); |
| 1064 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); | 1050 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); |
| 1065 | 1051 |
| 1066 // Case 2: scrollDelta of 10, 30 | 1052 // Case 2: scrollDelta of 10, 30 |
| 1067 child->setScrollDelta(gfx::Vector2d(10, 30)); | 1053 child->setScrollDelta(gfx::Vector2d(10, 30)); |
| 1068 executeCalculateDrawTransformsAndVisibility(root.get()); | 1054 executeCalculateDrawTransformsAndVisibility(root.get()); |
| 1069 | 1055 |
| 1070 // Here the grandChild remains unchanged, because it scrolls along with the | 1056 // Here the grandChild remains unchanged, because it scrolls along with the |
| 1071 // renderSurface, and the translation is actually in the renderSurface. But,
the fixed | 1057 // renderSurface, and the translation is actually in the renderSurface. But,
the fixed |
| 1072 // position greatGrandChild is more awkward: its actually being drawn with r
espect to | 1058 // position greatGrandChild is more awkward: its actually being drawn with r
espect to |
| 1073 // the renderSurface, but it needs to remain fixed with resepct to a contain
er beyond | 1059 // the renderSurface, but it needs to remain fixed with resepct to a contain
er beyond |
| 1074 // that surface. So, the net result is that, unlike previous tests where the
fixed | 1060 // that surface. So, the net result is that, unlike previous tests where the
fixed |
| 1075 // position layer's transform remains unchanged, here the fixed position lay
er's | 1061 // position layer's transform remains unchanged, here the fixed position lay
er's |
| 1076 // transform explicitly contains the translation that cancels out the scroll
. | 1062 // transform explicitly contains the translation that cancels out the scroll
. |
| 1077 expectedChildTransform.makeIdentity(); | 1063 expectedChildTransform.MakeIdentity(); |
| 1078 expectedChildTransform.translate(-10, -30); // scrollDelta | 1064 expectedChildTransform.Translate(-10, -30); // scrollDelta |
| 1079 | 1065 |
| 1080 expectedSurfaceDrawTransform.makeIdentity(); | 1066 expectedSurfaceDrawTransform.MakeIdentity(); |
| 1081 expectedSurfaceDrawTransform.translate(-10, -30); // scrollDelta | 1067 expectedSurfaceDrawTransform.Translate(-10, -30); // scrollDelta |
| 1082 expectedSurfaceDrawTransform.translate(8, 6); | 1068 expectedSurfaceDrawTransform.Translate(8, 6); |
| 1083 expectedSurfaceDrawTransform.multiply(rotationAboutZ); | 1069 expectedSurfaceDrawTransform.PreconcatTransform(rotationAboutZ); |
| 1084 | 1070 |
| 1085 // The rotation and its inverse are needed to place the scrollDelta compensa
tion in | 1071 // The rotation and its inverse are needed to place the scrollDelta compensa
tion in |
| 1086 // the correct space. This test will fail if the rotation/inverse are backwa
rds, too, | 1072 // the correct space. This test will fail if the rotation/inverse are backwa
rds, too, |
| 1087 // so it requires perfect order of operations. | 1073 // so it requires perfect order of operations. |
| 1088 expectedGreatGrandChildTransform.makeIdentity(); | 1074 expectedGreatGrandChildTransform.MakeIdentity(); |
| 1089 expectedGreatGrandChildTransform.multiply(rotationAboutZ.inverse()); | 1075 expectedGreatGrandChildTransform.PreconcatTransform(MathUtil::inverse(rotati
onAboutZ)); |
| 1090 expectedGreatGrandChildTransform.translate(10, 30); // explicit canceling ou
t the scrollDelta that gets embedded in the fixed position layer's surface. | 1076 expectedGreatGrandChildTransform.Translate(10, 30); // explicit canceling ou
t the scrollDelta that gets embedded in the fixed position layer's surface. |
| 1091 expectedGreatGrandChildTransform.multiply(rotationAboutZ); | 1077 expectedGreatGrandChildTransform.PreconcatTransform(rotationAboutZ); |
| 1092 | 1078 |
| 1093 ASSERT_TRUE(grandChild->renderSurface()); | 1079 ASSERT_TRUE(grandChild->renderSurface()); |
| 1094 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 1080 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); |
| 1095 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, grandChild->re
nderSurface()->drawTransform()); | 1081 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, grandChild->re
nderSurface()->drawTransform()); |
| 1096 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 1082 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); |
| 1097 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); | 1083 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); |
| 1098 } | 1084 } |
| 1099 | 1085 |
| 1100 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithM
ultipleIntermediateSurfaces) | 1086 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithM
ultipleIntermediateSurfaces) |
| 1101 { | 1087 { |
| 1102 // This test checks for correct scroll compensation when the fixed-position
container | 1088 // This test checks for correct scroll compensation when the fixed-position
container |
| 1103 // contributes to a different renderSurface than the fixed-position layer, w
ith | 1089 // contributes to a different renderSurface than the fixed-position layer, w
ith |
| 1104 // additional renderSurfaces in-between. This checks that the conversion to
ancestor | 1090 // additional renderSurfaces in-between. This checks that the conversion to
ancestor |
| 1105 // surfaces is accumulated properly in the final matrix transform. | 1091 // surfaces is accumulated properly in the final matrix transform. |
| 1106 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); | 1092 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); |
| 1107 LayerImpl* child = root->children()[0]; | 1093 LayerImpl* child = root->children()[0]; |
| 1108 LayerImpl* grandChild = child->children()[0]; | 1094 LayerImpl* grandChild = child->children()[0]; |
| 1109 LayerImpl* greatGrandChild = grandChild->children()[0]; | 1095 LayerImpl* greatGrandChild = grandChild->children()[0]; |
| 1110 | 1096 |
| 1111 // Add one more layer to the test tree for this scenario. | 1097 // Add one more layer to the test tree for this scenario. |
| 1112 { | 1098 { |
| 1113 WebTransformationMatrix identity; | 1099 gfx::Transform identity; |
| 1114 scoped_ptr<LayerImpl> fixedPositionChild = LayerImpl::create(5); | 1100 scoped_ptr<LayerImpl> fixedPositionChild = LayerImpl::create(5); |
| 1115 setLayerPropertiesForTesting(fixedPositionChild.get(), identity, identit
y, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 1101 setLayerPropertiesForTesting(fixedPositionChild.get(), identity, identit
y, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 1116 greatGrandChild->addChild(fixedPositionChild.Pass()); | 1102 greatGrandChild->addChild(fixedPositionChild.Pass()); |
| 1117 } | 1103 } |
| 1118 LayerImpl* fixedPositionChild = greatGrandChild->children()[0]; | 1104 LayerImpl* fixedPositionChild = greatGrandChild->children()[0]; |
| 1119 | 1105 |
| 1120 // Actually set up the scenario here. | 1106 // Actually set up the scenario here. |
| 1121 child->setIsContainerForFixedPositionLayers(true); | 1107 child->setIsContainerForFixedPositionLayers(true); |
| 1122 grandChild->setPosition(gfx::PointF(8, 6)); | 1108 grandChild->setPosition(gfx::PointF(8, 6)); |
| 1123 grandChild->setForceRenderSurface(true); | 1109 grandChild->setForceRenderSurface(true); |
| 1124 greatGrandChild->setPosition(gfx::PointF(40, 60)); | 1110 greatGrandChild->setPosition(gfx::PointF(40, 60)); |
| 1125 greatGrandChild->setForceRenderSurface(true); | 1111 greatGrandChild->setForceRenderSurface(true); |
| 1126 fixedPositionChild->setFixedToContainerLayer(true); | 1112 fixedPositionChild->setFixedToContainerLayer(true); |
| 1127 fixedPositionChild->setDrawsContent(true); | 1113 fixedPositionChild->setDrawsContent(true); |
| 1128 | 1114 |
| 1129 // The additional rotations, which are non-commutative with translations, he
lp to | 1115 // The additional rotations, which are non-commutative with translations, he
lp to |
| 1130 // verify that we have correct order-of-operations in the final scroll compe
nsation. | 1116 // verify that we have correct order-of-operations in the final scroll compe
nsation. |
| 1131 // Note that rotating about the center of the layer ensures we do not accide
ntally | 1117 // Note that rotating about the center of the layer ensures we do not accide
ntally |
| 1132 // clip away layers that we want to test. | 1118 // clip away layers that we want to test. |
| 1133 WebTransformationMatrix rotationAboutZ; | 1119 gfx::Transform rotationAboutZ; |
| 1134 rotationAboutZ.translate(50, 50); | 1120 rotationAboutZ.Translate(50, 50); |
| 1135 rotationAboutZ.rotate3d(0, 0, 90); | 1121 MathUtil::rotateEulerAngles(&rotationAboutZ, 0, 0, 90); |
| 1136 rotationAboutZ.translate(-50, -50); | 1122 rotationAboutZ.Translate(-50, -50); |
| 1137 grandChild->setTransform(rotationAboutZ); | 1123 grandChild->setTransform(rotationAboutZ); |
| 1138 greatGrandChild->setTransform(rotationAboutZ); | 1124 greatGrandChild->setTransform(rotationAboutZ); |
| 1139 | 1125 |
| 1140 // Case 1: scrollDelta of 0, 0 | 1126 // Case 1: scrollDelta of 0, 0 |
| 1141 child->setScrollDelta(gfx::Vector2d(0, 0)); | 1127 child->setScrollDelta(gfx::Vector2d(0, 0)); |
| 1142 executeCalculateDrawTransformsAndVisibility(root.get()); | 1128 executeCalculateDrawTransformsAndVisibility(root.get()); |
| 1143 | 1129 |
| 1144 WebTransformationMatrix expectedChildTransform; | 1130 gfx::Transform expectedChildTransform; |
| 1145 | 1131 |
| 1146 WebTransformationMatrix expectedGrandChildSurfaceDrawTransform; | 1132 gfx::Transform expectedGrandChildSurfaceDrawTransform; |
| 1147 expectedGrandChildSurfaceDrawTransform.translate(8, 6); | 1133 expectedGrandChildSurfaceDrawTransform.Translate(8, 6); |
| 1148 expectedGrandChildSurfaceDrawTransform.multiply(rotationAboutZ); | 1134 expectedGrandChildSurfaceDrawTransform.PreconcatTransform(rotationAboutZ); |
| 1149 | 1135 |
| 1150 WebTransformationMatrix expectedGrandChildTransform; | 1136 gfx::Transform expectedGrandChildTransform; |
| 1151 | 1137 |
| 1152 WebTransformationMatrix expectedGreatGrandChildSurfaceDrawTransform; | 1138 gfx::Transform expectedGreatGrandChildSurfaceDrawTransform; |
| 1153 expectedGreatGrandChildSurfaceDrawTransform.translate(40, 60); | 1139 expectedGreatGrandChildSurfaceDrawTransform.Translate(40, 60); |
| 1154 expectedGreatGrandChildSurfaceDrawTransform.multiply(rotationAboutZ); | 1140 expectedGreatGrandChildSurfaceDrawTransform.PreconcatTransform(rotationAbout
Z); |
| 1155 | 1141 |
| 1156 WebTransformationMatrix expectedGreatGrandChildTransform; | 1142 gfx::Transform expectedGreatGrandChildTransform; |
| 1157 | 1143 |
| 1158 WebTransformationMatrix expectedFixedPositionChildTransform; | 1144 gfx::Transform expectedFixedPositionChildTransform; |
| 1159 | 1145 |
| 1160 ASSERT_TRUE(grandChild->renderSurface()); | 1146 ASSERT_TRUE(grandChild->renderSurface()); |
| 1161 ASSERT_TRUE(greatGrandChild->renderSurface()); | 1147 ASSERT_TRUE(greatGrandChild->renderSurface()); |
| 1162 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 1148 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); |
| 1163 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildSurfaceDrawTransform, gran
dChild->renderSurface()->drawTransform()); | 1149 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildSurfaceDrawTransform, gran
dChild->renderSurface()->drawTransform()); |
| 1164 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 1150 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); |
| 1165 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildSurfaceDrawTransform,
greatGrandChild->renderSurface()->drawTransform()); | 1151 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildSurfaceDrawTransform,
greatGrandChild->renderSurface()->drawTransform()); |
| 1166 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); | 1152 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); |
| 1167 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedFixedPositionChildTransform, fixedPo
sitionChild->drawTransform()); | 1153 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedFixedPositionChildTransform, fixedPo
sitionChild->drawTransform()); |
| 1168 | 1154 |
| 1169 // Case 2: scrollDelta of 10, 30 | 1155 // Case 2: scrollDelta of 10, 30 |
| 1170 child->setScrollDelta(gfx::Vector2d(10, 30)); | 1156 child->setScrollDelta(gfx::Vector2d(10, 30)); |
| 1171 executeCalculateDrawTransformsAndVisibility(root.get()); | 1157 executeCalculateDrawTransformsAndVisibility(root.get()); |
| 1172 | 1158 |
| 1173 expectedChildTransform.makeIdentity(); | 1159 expectedChildTransform.MakeIdentity(); |
| 1174 expectedChildTransform.translate(-10, -30); // scrollDelta | 1160 expectedChildTransform.Translate(-10, -30); // scrollDelta |
| 1175 | 1161 |
| 1176 expectedGrandChildSurfaceDrawTransform.makeIdentity(); | 1162 expectedGrandChildSurfaceDrawTransform.MakeIdentity(); |
| 1177 expectedGrandChildSurfaceDrawTransform.translate(-10, -30); // scrollDelta | 1163 expectedGrandChildSurfaceDrawTransform.Translate(-10, -30); // scrollDelta |
| 1178 expectedGrandChildSurfaceDrawTransform.translate(8, 6); | 1164 expectedGrandChildSurfaceDrawTransform.Translate(8, 6); |
| 1179 expectedGrandChildSurfaceDrawTransform.multiply(rotationAboutZ); | 1165 expectedGrandChildSurfaceDrawTransform.PreconcatTransform(rotationAboutZ); |
| 1180 | 1166 |
| 1181 // grandChild, greatGrandChild, and greatGrandChild's surface are not expect
ed to | 1167 // grandChild, greatGrandChild, and greatGrandChild's surface are not expect
ed to |
| 1182 // change, since they are all not fixed, and they are all drawn with respect
to | 1168 // change, since they are all not fixed, and they are all drawn with respect
to |
| 1183 // grandChild's surface that already has the scrollDelta accounted for. | 1169 // grandChild's surface that already has the scrollDelta accounted for. |
| 1184 | 1170 |
| 1185 // But the great-great grandchild, "fixedPositionChild", should have a trans
form that explicitly cancels out the scrollDelta. | 1171 // But the great-great grandchild, "fixedPositionChild", should have a trans
form that explicitly cancels out the scrollDelta. |
| 1186 // The expected transform is: | 1172 // The expected transform is: |
| 1187 // compoundDrawTransform.inverse() * translate(positive scrollDelta) * com
poundOriginTransform | 1173 // compoundDrawTransform.inverse() * translate(positive scrollDelta) * com
poundOriginTransform |
| 1188 WebTransformationMatrix compoundDrawTransform; // transform from greatGrandC
hildSurface's origin to the root surface. | 1174 gfx::Transform compoundDrawTransform; // transform from greatGrandChildSurfa
ce's origin to the root surface. |
| 1189 compoundDrawTransform.translate(8, 6); // origin translation of grandChild | 1175 compoundDrawTransform.Translate(8, 6); // origin translation of grandChild |
| 1190 compoundDrawTransform.multiply(rotationAboutZ); // rotation of grandChild | 1176 compoundDrawTransform.PreconcatTransform(rotationAboutZ); // rotation of gra
ndChild |
| 1191 compoundDrawTransform.translate(40, 60); // origin translation of greatGrand
Child | 1177 compoundDrawTransform.Translate(40, 60); // origin translation of greatGrand
Child |
| 1192 compoundDrawTransform.multiply(rotationAboutZ); // rotation of greatGrandChi
ld | 1178 compoundDrawTransform.PreconcatTransform(rotationAboutZ); // rotation of gre
atGrandChild |
| 1193 | 1179 |
| 1194 expectedFixedPositionChildTransform.makeIdentity(); | 1180 expectedFixedPositionChildTransform.MakeIdentity(); |
| 1195 expectedFixedPositionChildTransform.multiply(compoundDrawTransform.inverse()
); | 1181 expectedFixedPositionChildTransform.PreconcatTransform(MathUtil::inverse(com
poundDrawTransform)); |
| 1196 expectedFixedPositionChildTransform.translate(10, 30); // explicit canceling
out the scrollDelta that gets embedded in the fixed position layer's surface. | 1182 expectedFixedPositionChildTransform.Translate(10, 30); // explicit canceling
out the scrollDelta that gets embedded in the fixed position layer's surface. |
| 1197 expectedFixedPositionChildTransform.multiply(compoundDrawTransform); | 1183 expectedFixedPositionChildTransform.PreconcatTransform(compoundDrawTransform
); |
| 1198 | 1184 |
| 1199 ASSERT_TRUE(grandChild->renderSurface()); | 1185 ASSERT_TRUE(grandChild->renderSurface()); |
| 1200 ASSERT_TRUE(greatGrandChild->renderSurface()); | 1186 ASSERT_TRUE(greatGrandChild->renderSurface()); |
| 1201 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 1187 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); |
| 1202 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildSurfaceDrawTransform, gran
dChild->renderSurface()->drawTransform()); | 1188 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildSurfaceDrawTransform, gran
dChild->renderSurface()->drawTransform()); |
| 1203 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 1189 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); |
| 1204 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildSurfaceDrawTransform,
greatGrandChild->renderSurface()->drawTransform()); | 1190 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildSurfaceDrawTransform,
greatGrandChild->renderSurface()->drawTransform()); |
| 1205 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); | 1191 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); |
| 1206 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedFixedPositionChildTransform, fixedPo
sitionChild->drawTransform()); | 1192 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedFixedPositionChildTransform, fixedPo
sitionChild->drawTransform()); |
| 1207 } | 1193 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1218 | 1204 |
| 1219 child->setIsContainerForFixedPositionLayers(true); | 1205 child->setIsContainerForFixedPositionLayers(true); |
| 1220 child->setForceRenderSurface(true); | 1206 child->setForceRenderSurface(true); |
| 1221 grandChild->setFixedToContainerLayer(true); | 1207 grandChild->setFixedToContainerLayer(true); |
| 1222 grandChild->setDrawsContent(true); | 1208 grandChild->setDrawsContent(true); |
| 1223 | 1209 |
| 1224 // Case 1: scrollDelta of 0, 0 | 1210 // Case 1: scrollDelta of 0, 0 |
| 1225 child->setScrollDelta(gfx::Vector2d(0, 0)); | 1211 child->setScrollDelta(gfx::Vector2d(0, 0)); |
| 1226 executeCalculateDrawTransformsAndVisibility(root.get()); | 1212 executeCalculateDrawTransformsAndVisibility(root.get()); |
| 1227 | 1213 |
| 1228 WebTransformationMatrix expectedSurfaceDrawTransform; | 1214 gfx::Transform expectedSurfaceDrawTransform; |
| 1229 expectedSurfaceDrawTransform.translate(0, 0); | 1215 expectedSurfaceDrawTransform.Translate(0, 0); |
| 1230 WebTransformationMatrix expectedChildTransform; | 1216 gfx::Transform expectedChildTransform; |
| 1231 WebTransformationMatrix expectedGrandChildTransform; | 1217 gfx::Transform expectedGrandChildTransform; |
| 1232 ASSERT_TRUE(child->renderSurface()); | 1218 ASSERT_TRUE(child->renderSurface()); |
| 1233 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, child->renderS
urface()->drawTransform()); | 1219 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, child->renderS
urface()->drawTransform()); |
| 1234 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 1220 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); |
| 1235 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 1221 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); |
| 1236 | 1222 |
| 1237 // Case 2: scrollDelta of 10, 10 | 1223 // Case 2: scrollDelta of 10, 10 |
| 1238 child->setScrollDelta(gfx::Vector2d(10, 10)); | 1224 child->setScrollDelta(gfx::Vector2d(10, 10)); |
| 1239 executeCalculateDrawTransformsAndVisibility(root.get()); | 1225 executeCalculateDrawTransformsAndVisibility(root.get()); |
| 1240 | 1226 |
| 1241 // The surface is translated by scrollDelta, the child transform doesn't cha
nge | 1227 // The surface is translated by scrollDelta, the child transform doesn't cha
nge |
| 1242 // because it scrolls along with the surface, but the fixed position grandCh
ild | 1228 // because it scrolls along with the surface, but the fixed position grandCh
ild |
| 1243 // needs to compensate for the scroll translation. | 1229 // needs to compensate for the scroll translation. |
| 1244 expectedSurfaceDrawTransform.makeIdentity(); | 1230 expectedSurfaceDrawTransform.MakeIdentity(); |
| 1245 expectedSurfaceDrawTransform.translate(-10, -10); | 1231 expectedSurfaceDrawTransform.Translate(-10, -10); |
| 1246 expectedGrandChildTransform.makeIdentity(); | 1232 expectedGrandChildTransform.MakeIdentity(); |
| 1247 expectedGrandChildTransform.translate(10, 10); | 1233 expectedGrandChildTransform.Translate(10, 10); |
| 1248 | 1234 |
| 1249 ASSERT_TRUE(child->renderSurface()); | 1235 ASSERT_TRUE(child->renderSurface()); |
| 1250 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, child->renderS
urface()->drawTransform()); | 1236 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, child->renderS
urface()->drawTransform()); |
| 1251 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 1237 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); |
| 1252 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 1238 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); |
| 1253 } | 1239 } |
| 1254 | 1240 |
| 1255 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerThatI
sAlsoFixedPositionContainer) | 1241 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerThatI
sAlsoFixedPositionContainer) |
| 1256 { | 1242 { |
| 1257 // This test checks the scenario where a fixed-position layer also happens t
o be a | 1243 // This test checks the scenario where a fixed-position layer also happens t
o be a |
| 1258 // container itself for a descendant fixed position layer. In particular, th
e layer | 1244 // container itself for a descendant fixed position layer. In particular, th
e layer |
| 1259 // should not accidentally be fixed to itself. | 1245 // should not accidentally be fixed to itself. |
| 1260 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); | 1246 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); |
| 1261 LayerImpl* child = root->children()[0]; | 1247 LayerImpl* child = root->children()[0]; |
| 1262 LayerImpl* grandChild = child->children()[0]; | 1248 LayerImpl* grandChild = child->children()[0]; |
| 1263 | 1249 |
| 1264 child->setIsContainerForFixedPositionLayers(true); | 1250 child->setIsContainerForFixedPositionLayers(true); |
| 1265 grandChild->setFixedToContainerLayer(true); | 1251 grandChild->setFixedToContainerLayer(true); |
| 1266 | 1252 |
| 1267 // This should not confuse the grandChild. If correct, the grandChild would
still be considered fixed to its container (i.e. "child"). | 1253 // This should not confuse the grandChild. If correct, the grandChild would
still be considered fixed to its container (i.e. "child"). |
| 1268 grandChild->setIsContainerForFixedPositionLayers(true); | 1254 grandChild->setIsContainerForFixedPositionLayers(true); |
| 1269 | 1255 |
| 1270 // Case 1: scrollDelta of 0, 0 | 1256 // Case 1: scrollDelta of 0, 0 |
| 1271 child->setScrollDelta(gfx::Vector2d(0, 0)); | 1257 child->setScrollDelta(gfx::Vector2d(0, 0)); |
| 1272 executeCalculateDrawTransformsAndVisibility(root.get()); | 1258 executeCalculateDrawTransformsAndVisibility(root.get()); |
| 1273 | 1259 |
| 1274 WebTransformationMatrix expectedChildTransform; | 1260 gfx::Transform expectedChildTransform; |
| 1275 WebTransformationMatrix expectedGrandChildTransform; | 1261 gfx::Transform expectedGrandChildTransform; |
| 1276 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 1262 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); |
| 1277 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 1263 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); |
| 1278 | 1264 |
| 1279 // Case 2: scrollDelta of 10, 10 | 1265 // Case 2: scrollDelta of 10, 10 |
| 1280 child->setScrollDelta(gfx::Vector2d(10, 10)); | 1266 child->setScrollDelta(gfx::Vector2d(10, 10)); |
| 1281 executeCalculateDrawTransformsAndVisibility(root.get()); | 1267 executeCalculateDrawTransformsAndVisibility(root.get()); |
| 1282 | 1268 |
| 1283 // Here the child is affected by scrollDelta, but the fixed position grandCh
ild should not be affected. | 1269 // Here the child is affected by scrollDelta, but the fixed position grandCh
ild should not be affected. |
| 1284 expectedChildTransform.makeIdentity(); | 1270 expectedChildTransform.MakeIdentity(); |
| 1285 expectedChildTransform.translate(-10, -10); | 1271 expectedChildTransform.Translate(-10, -10); |
| 1286 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 1272 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); |
| 1287 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 1273 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); |
| 1288 } | 1274 } |
| 1289 | 1275 |
| 1290 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerThatH
asNoContainer) | 1276 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerThatH
asNoContainer) |
| 1291 { | 1277 { |
| 1292 // This test checks scroll compensation when a fixed-position layer does not
find any | 1278 // This test checks scroll compensation when a fixed-position layer does not
find any |
| 1293 // ancestor that is a "containerForFixedPositionLayers". In this situation,
the layer should | 1279 // ancestor that is a "containerForFixedPositionLayers". In this situation,
the layer should |
| 1294 // be fixed to the viewport -- not the rootLayer, which may have transforms
of its own. | 1280 // be fixed to the viewport -- not the rootLayer, which may have transforms
of its own. |
| 1295 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); | 1281 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); |
| 1296 LayerImpl* child = root->children()[0]; | 1282 LayerImpl* child = root->children()[0]; |
| 1297 LayerImpl* grandChild = child->children()[0]; | 1283 LayerImpl* grandChild = child->children()[0]; |
| 1298 | 1284 |
| 1299 WebTransformationMatrix rotationByZ; | 1285 gfx::Transform rotationByZ; |
| 1300 rotationByZ.rotate3d(0, 0, 90); | 1286 MathUtil::rotateEulerAngles(&rotationByZ, 0, 0, 90); |
| 1301 | 1287 |
| 1302 root->setTransform(rotationByZ); | 1288 root->setTransform(rotationByZ); |
| 1303 grandChild->setFixedToContainerLayer(true); | 1289 grandChild->setFixedToContainerLayer(true); |
| 1304 | 1290 |
| 1305 // Case 1: root scrollDelta of 0, 0 | 1291 // Case 1: root scrollDelta of 0, 0 |
| 1306 root->setScrollDelta(gfx::Vector2d(0, 0)); | 1292 root->setScrollDelta(gfx::Vector2d(0, 0)); |
| 1307 executeCalculateDrawTransformsAndVisibility(root.get()); | 1293 executeCalculateDrawTransformsAndVisibility(root.get()); |
| 1308 | 1294 |
| 1309 WebTransformationMatrix identityMatrix; | 1295 gfx::Transform identityMatrix; |
| 1310 | 1296 |
| 1311 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); | 1297 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); |
| 1312 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->drawTransform())
; | 1298 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->drawTransform())
; |
| 1313 | 1299 |
| 1314 // Case 2: root scrollDelta of 10, 10 | 1300 // Case 2: root scrollDelta of 10, 10 |
| 1315 root->setScrollDelta(gfx::Vector2d(10, 20)); | 1301 root->setScrollDelta(gfx::Vector2d(10, 20)); |
| 1316 executeCalculateDrawTransformsAndVisibility(root.get()); | 1302 executeCalculateDrawTransformsAndVisibility(root.get()); |
| 1317 | 1303 |
| 1318 // The child is affected by scrollDelta, but it is already implcitly account
ed for by | 1304 // The child is affected by scrollDelta, but it is already implcitly account
ed for by |
| 1319 // the child's target surface (i.e. the root renderSurface). The grandChild
is not | 1305 // the child's target surface (i.e. the root renderSurface). The grandChild
is not |
| 1320 // affected by the scrollDelta, so its drawTransform needs to explicitly | 1306 // affected by the scrollDelta, so its drawTransform needs to explicitly |
| 1321 // inverse-compensate for the scroll that's embedded in the target surface. | 1307 // inverse-compensate for the scroll that's embedded in the target surface. |
| 1322 WebTransformationMatrix expectedGrandChildTransform; | 1308 gfx::Transform expectedGrandChildTransform; |
| 1323 expectedGrandChildTransform.multiply(rotationByZ.inverse()); | 1309 expectedGrandChildTransform.PreconcatTransform(MathUtil::inverse(rotationByZ
)); |
| 1324 expectedGrandChildTransform.translate(10, 20); // explicit canceling out the
scrollDelta that gets embedded in the fixed position layer's surface. | 1310 expectedGrandChildTransform.Translate(10, 20); // explicit canceling out the
scrollDelta that gets embedded in the fixed position layer's surface. |
| 1325 expectedGrandChildTransform.multiply(rotationByZ); | 1311 expectedGrandChildTransform.PreconcatTransform(rotationByZ); |
| 1326 | 1312 |
| 1327 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); | 1313 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); |
| 1328 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 1314 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); |
| 1329 } | 1315 } |
| 1330 | 1316 |
| 1331 TEST(LayerTreeHostCommonTest, verifyClipRectCullsRenderSurfaces) | 1317 TEST(LayerTreeHostCommonTest, verifyClipRectCullsRenderSurfaces) |
| 1332 { | 1318 { |
| 1333 // The entire subtree of layers that are outside the clipRect should be cull
ed away, | 1319 // The entire subtree of layers that are outside the clipRect should be cull
ed away, |
| 1334 // and should not affect the renderSurfaceLayerList. | 1320 // and should not affect the renderSurfaceLayerList. |
| 1335 // | 1321 // |
| 1336 // The test tree is set up as follows: | 1322 // The test tree is set up as follows: |
| 1337 // - all layers except the leafNodes are forced to be a new renderSurface t
hat have something to draw. | 1323 // - all layers except the leafNodes are forced to be a new renderSurface t
hat have something to draw. |
| 1338 // - parent is a large container layer. | 1324 // - parent is a large container layer. |
| 1339 // - child has masksToBounds=true to cause clipping. | 1325 // - child has masksToBounds=true to cause clipping. |
| 1340 // - grandChild is positioned outside of the child's bounds | 1326 // - grandChild is positioned outside of the child's bounds |
| 1341 // - greatGrandChild is also kept outside child's bounds. | 1327 // - greatGrandChild is also kept outside child's bounds. |
| 1342 // | 1328 // |
| 1343 // In this configuration, grandChild and greatGrandChild are completely outs
ide the | 1329 // In this configuration, grandChild and greatGrandChild are completely outs
ide the |
| 1344 // clipRect, and they should never get scheduled on the list of renderSurfac
es. | 1330 // clipRect, and they should never get scheduled on the list of renderSurfac
es. |
| 1345 // | 1331 // |
| 1346 | 1332 |
| 1347 const WebTransformationMatrix identityMatrix; | 1333 const gfx::Transform identityMatrix; |
| 1348 scoped_refptr<Layer> parent = Layer::create(); | 1334 scoped_refptr<Layer> parent = Layer::create(); |
| 1349 scoped_refptr<Layer> child = Layer::create(); | 1335 scoped_refptr<Layer> child = Layer::create(); |
| 1350 scoped_refptr<Layer> grandChild = Layer::create(); | 1336 scoped_refptr<Layer> grandChild = Layer::create(); |
| 1351 scoped_refptr<Layer> greatGrandChild = Layer::create(); | 1337 scoped_refptr<Layer> greatGrandChild = Layer::create(); |
| 1352 scoped_refptr<LayerWithForcedDrawsContent> leafNode1 = make_scoped_refptr(ne
w LayerWithForcedDrawsContent()); | 1338 scoped_refptr<LayerWithForcedDrawsContent> leafNode1 = make_scoped_refptr(ne
w LayerWithForcedDrawsContent()); |
| 1353 scoped_refptr<LayerWithForcedDrawsContent> leafNode2 = make_scoped_refptr(ne
w LayerWithForcedDrawsContent()); | 1339 scoped_refptr<LayerWithForcedDrawsContent> leafNode2 = make_scoped_refptr(ne
w LayerWithForcedDrawsContent()); |
| 1354 parent->addChild(child); | 1340 parent->addChild(child); |
| 1355 child->addChild(grandChild); | 1341 child->addChild(grandChild); |
| 1356 grandChild->addChild(greatGrandChild); | 1342 grandChild->addChild(greatGrandChild); |
| 1357 | 1343 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1392 // - parent is a container layer that masksToBounds=true to cause clipping. | 1378 // - parent is a container layer that masksToBounds=true to cause clipping. |
| 1393 // - child is a renderSurface, which has a clipRect set to the bounds of th
e parent. | 1379 // - child is a renderSurface, which has a clipRect set to the bounds of th
e parent. |
| 1394 // - grandChild is a renderSurface, and the only visible content in child.
It is positioned outside of the clipRect from parent. | 1380 // - grandChild is a renderSurface, and the only visible content in child.
It is positioned outside of the clipRect from parent. |
| 1395 | 1381 |
| 1396 // In this configuration, grandChild should be outside the clipped | 1382 // In this configuration, grandChild should be outside the clipped |
| 1397 // contentRect of the child, making grandChild not appear in the | 1383 // contentRect of the child, making grandChild not appear in the |
| 1398 // renderSurfaceLayerList. However, when we place an animation on the child, | 1384 // renderSurfaceLayerList. However, when we place an animation on the child, |
| 1399 // this clipping should be avoided and we should keep the grandChild | 1385 // this clipping should be avoided and we should keep the grandChild |
| 1400 // in the renderSurfaceLayerList. | 1386 // in the renderSurfaceLayerList. |
| 1401 | 1387 |
| 1402 const WebTransformationMatrix identityMatrix; | 1388 const gfx::Transform identityMatrix; |
| 1403 scoped_refptr<Layer> parent = Layer::create(); | 1389 scoped_refptr<Layer> parent = Layer::create(); |
| 1404 scoped_refptr<Layer> child = Layer::create(); | 1390 scoped_refptr<Layer> child = Layer::create(); |
| 1405 scoped_refptr<Layer> grandChild = Layer::create(); | 1391 scoped_refptr<Layer> grandChild = Layer::create(); |
| 1406 scoped_refptr<LayerWithForcedDrawsContent> leafNode = make_scoped_refptr(new
LayerWithForcedDrawsContent()); | 1392 scoped_refptr<LayerWithForcedDrawsContent> leafNode = make_scoped_refptr(new
LayerWithForcedDrawsContent()); |
| 1407 parent->addChild(child); | 1393 parent->addChild(child); |
| 1408 child->addChild(grandChild); | 1394 child->addChild(grandChild); |
| 1409 grandChild->addChild(leafNode); | 1395 grandChild->addChild(leafNode); |
| 1410 | 1396 |
| 1411 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 1397 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 1412 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(20, 20), false); | 1398 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(20, 20), false); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1450 // renderTarget, | 1436 // renderTarget, |
| 1451 // - a surface is clipped by an ancestor that contributes to the same | 1437 // - a surface is clipped by an ancestor that contributes to the same |
| 1452 // renderTarget. | 1438 // renderTarget. |
| 1453 // | 1439 // |
| 1454 // In particular, for a layer that owns a renderSurface: | 1440 // In particular, for a layer that owns a renderSurface: |
| 1455 // - the renderSurfarce inherits any clip from ancestors, and does NOT | 1441 // - the renderSurfarce inherits any clip from ancestors, and does NOT |
| 1456 // pass that clipped status to the layer itself. | 1442 // pass that clipped status to the layer itself. |
| 1457 // - but if the layer itself masks to bounds, it is considered clipped | 1443 // - but if the layer itself masks to bounds, it is considered clipped |
| 1458 // and propagates the clip to the subtree. | 1444 // and propagates the clip to the subtree. |
| 1459 | 1445 |
| 1460 const WebTransformationMatrix identityMatrix; | 1446 const gfx::Transform identityMatrix; |
| 1461 scoped_refptr<Layer> root = Layer::create(); | 1447 scoped_refptr<Layer> root = Layer::create(); |
| 1462 scoped_refptr<Layer> parent = Layer::create(); | 1448 scoped_refptr<Layer> parent = Layer::create(); |
| 1463 scoped_refptr<Layer> child1 = Layer::create(); | 1449 scoped_refptr<Layer> child1 = Layer::create(); |
| 1464 scoped_refptr<Layer> child2 = Layer::create(); | 1450 scoped_refptr<Layer> child2 = Layer::create(); |
| 1465 scoped_refptr<Layer> grandChild = Layer::create(); | 1451 scoped_refptr<Layer> grandChild = Layer::create(); |
| 1466 scoped_refptr<LayerWithForcedDrawsContent> leafNode1 = make_scoped_refptr(ne
w LayerWithForcedDrawsContent()); | 1452 scoped_refptr<LayerWithForcedDrawsContent> leafNode1 = make_scoped_refptr(ne
w LayerWithForcedDrawsContent()); |
| 1467 scoped_refptr<LayerWithForcedDrawsContent> leafNode2 = make_scoped_refptr(ne
w LayerWithForcedDrawsContent()); | 1453 scoped_refptr<LayerWithForcedDrawsContent> leafNode2 = make_scoped_refptr(ne
w LayerWithForcedDrawsContent()); |
| 1468 root->addChild(parent); | 1454 root->addChild(parent); |
| 1469 parent->addChild(child1); | 1455 parent->addChild(child1); |
| 1470 parent->addChild(child2); | 1456 parent->addChild(child2); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1545 TEST(LayerTreeHostCommonTest, verifyDrawableContentRectForLayers) | 1531 TEST(LayerTreeHostCommonTest, verifyDrawableContentRectForLayers) |
| 1546 { | 1532 { |
| 1547 // Verify that layers get the appropriate drawableContentRect when their par
ent masksToBounds is true. | 1533 // Verify that layers get the appropriate drawableContentRect when their par
ent masksToBounds is true. |
| 1548 // | 1534 // |
| 1549 // grandChild1 - completely inside the region; drawableContentRect should
be the layer rect expressed in target space. | 1535 // grandChild1 - completely inside the region; drawableContentRect should
be the layer rect expressed in target space. |
| 1550 // grandChild2 - partially clipped but NOT masksToBounds; the clipRect wil
l be the intersection of layerBounds and the mask region. | 1536 // grandChild2 - partially clipped but NOT masksToBounds; the clipRect wil
l be the intersection of layerBounds and the mask region. |
| 1551 // grandChild3 - partially clipped and masksToBounds; the drawableContentR
ect will still be the intersection of layerBounds and the mask region. | 1537 // grandChild3 - partially clipped and masksToBounds; the drawableContentR
ect will still be the intersection of layerBounds and the mask region. |
| 1552 // grandChild4 - outside parent's clipRect; the drawableContentRect should
be empty. | 1538 // grandChild4 - outside parent's clipRect; the drawableContentRect should
be empty. |
| 1553 // | 1539 // |
| 1554 | 1540 |
| 1555 const WebTransformationMatrix identityMatrix; | 1541 const gfx::Transform identityMatrix; |
| 1556 scoped_refptr<Layer> parent = Layer::create(); | 1542 scoped_refptr<Layer> parent = Layer::create(); |
| 1557 scoped_refptr<Layer> child = Layer::create(); | 1543 scoped_refptr<Layer> child = Layer::create(); |
| 1558 scoped_refptr<Layer> grandChild1 = Layer::create(); | 1544 scoped_refptr<Layer> grandChild1 = Layer::create(); |
| 1559 scoped_refptr<Layer> grandChild2 = Layer::create(); | 1545 scoped_refptr<Layer> grandChild2 = Layer::create(); |
| 1560 scoped_refptr<Layer> grandChild3 = Layer::create(); | 1546 scoped_refptr<Layer> grandChild3 = Layer::create(); |
| 1561 scoped_refptr<Layer> grandChild4 = Layer::create(); | 1547 scoped_refptr<Layer> grandChild4 = Layer::create(); |
| 1562 | 1548 |
| 1563 parent->addChild(child); | 1549 parent->addChild(child); |
| 1564 child->addChild(grandChild1); | 1550 child->addChild(grandChild1); |
| 1565 child->addChild(grandChild2); | 1551 child->addChild(grandChild2); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1595 | 1581 |
| 1596 TEST(LayerTreeHostCommonTest, verifyClipRectIsPropagatedCorrectlyToSurfaces) | 1582 TEST(LayerTreeHostCommonTest, verifyClipRectIsPropagatedCorrectlyToSurfaces) |
| 1597 { | 1583 { |
| 1598 // Verify that renderSurfaces (and their layers) get the appropriate clipRec
ts when their parent masksToBounds is true. | 1584 // Verify that renderSurfaces (and their layers) get the appropriate clipRec
ts when their parent masksToBounds is true. |
| 1599 // | 1585 // |
| 1600 // Layers that own renderSurfaces (at least for now) do not inherit any clip
ping; | 1586 // Layers that own renderSurfaces (at least for now) do not inherit any clip
ping; |
| 1601 // instead the surface will enforce the clip for the entire subtree. They ma
y still | 1587 // instead the surface will enforce the clip for the entire subtree. They ma
y still |
| 1602 // have a clipRect of their own layer bounds, however, if masksToBounds was
true. | 1588 // have a clipRect of their own layer bounds, however, if masksToBounds was
true. |
| 1603 // | 1589 // |
| 1604 | 1590 |
| 1605 const WebTransformationMatrix identityMatrix; | 1591 const gfx::Transform identityMatrix; |
| 1606 scoped_refptr<Layer> parent = Layer::create(); | 1592 scoped_refptr<Layer> parent = Layer::create(); |
| 1607 scoped_refptr<Layer> child = Layer::create(); | 1593 scoped_refptr<Layer> child = Layer::create(); |
| 1608 scoped_refptr<Layer> grandChild1 = Layer::create(); | 1594 scoped_refptr<Layer> grandChild1 = Layer::create(); |
| 1609 scoped_refptr<Layer> grandChild2 = Layer::create(); | 1595 scoped_refptr<Layer> grandChild2 = Layer::create(); |
| 1610 scoped_refptr<Layer> grandChild3 = Layer::create(); | 1596 scoped_refptr<Layer> grandChild3 = Layer::create(); |
| 1611 scoped_refptr<Layer> grandChild4 = Layer::create(); | 1597 scoped_refptr<Layer> grandChild4 = Layer::create(); |
| 1612 scoped_refptr<LayerWithForcedDrawsContent> leafNode1 = make_scoped_refptr(ne
w LayerWithForcedDrawsContent()); | 1598 scoped_refptr<LayerWithForcedDrawsContent> leafNode1 = make_scoped_refptr(ne
w LayerWithForcedDrawsContent()); |
| 1613 scoped_refptr<LayerWithForcedDrawsContent> leafNode2 = make_scoped_refptr(ne
w LayerWithForcedDrawsContent()); | 1599 scoped_refptr<LayerWithForcedDrawsContent> leafNode2 = make_scoped_refptr(ne
w LayerWithForcedDrawsContent()); |
| 1614 scoped_refptr<LayerWithForcedDrawsContent> leafNode3 = make_scoped_refptr(ne
w LayerWithForcedDrawsContent()); | 1600 scoped_refptr<LayerWithForcedDrawsContent> leafNode3 = make_scoped_refptr(ne
w LayerWithForcedDrawsContent()); |
| 1615 scoped_refptr<LayerWithForcedDrawsContent> leafNode4 = make_scoped_refptr(ne
w LayerWithForcedDrawsContent()); | 1601 scoped_refptr<LayerWithForcedDrawsContent> leafNode4 = make_scoped_refptr(ne
w LayerWithForcedDrawsContent()); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1686 // Make our render surfaces. | 1672 // Make our render surfaces. |
| 1687 renderSurface1->setForceRenderSurface(true); | 1673 renderSurface1->setForceRenderSurface(true); |
| 1688 renderSurface2->setForceRenderSurface(true); | 1674 renderSurface2->setForceRenderSurface(true); |
| 1689 | 1675 |
| 1690 // Put an animated opacity on the render surface. | 1676 // Put an animated opacity on the render surface. |
| 1691 addOpacityTransitionToController(*renderSurface1->layerAnimationController()
, 10, 1, 0, false); | 1677 addOpacityTransitionToController(*renderSurface1->layerAnimationController()
, 10, 1, 0, false); |
| 1692 | 1678 |
| 1693 // Also put an animated opacity on a layer without descendants. | 1679 // Also put an animated opacity on a layer without descendants. |
| 1694 addOpacityTransitionToController(*grandChildOfRoot->layerAnimationController
(), 10, 1, 0, false); | 1680 addOpacityTransitionToController(*grandChildOfRoot->layerAnimationController
(), 10, 1, 0, false); |
| 1695 | 1681 |
| 1696 WebTransformationMatrix layerTransform; | 1682 gfx::Transform layerTransform; |
| 1697 layerTransform.translate(1, 1); | 1683 layerTransform.Translate(1, 1); |
| 1698 WebTransformationMatrix sublayerTransform; | 1684 gfx::Transform sublayerTransform; |
| 1699 sublayerTransform.scale3d(10, 1, 1); | 1685 sublayerTransform.Scale3d(10, 1, 1); |
| 1700 | 1686 |
| 1701 // Put a transform animation on the render surface. | 1687 // Put a transform animation on the render surface. |
| 1702 addAnimatedTransformToController(*renderSurface2->layerAnimationController()
, 10, 30, 0); | 1688 addAnimatedTransformToController(*renderSurface2->layerAnimationController()
, 10, 30, 0); |
| 1703 | 1689 |
| 1704 // Also put transform animations on grandChildOfRoot, and grandChildOfRS2 | 1690 // Also put transform animations on grandChildOfRoot, and grandChildOfRS2 |
| 1705 addAnimatedTransformToController(*grandChildOfRoot->layerAnimationController
(), 10, 30, 0); | 1691 addAnimatedTransformToController(*grandChildOfRoot->layerAnimationController
(), 10, 30, 0); |
| 1706 addAnimatedTransformToController(*grandChildOfRS2->layerAnimationController(
), 10, 30, 0); | 1692 addAnimatedTransformToController(*grandChildOfRS2->layerAnimationController(
), 10, 30, 0); |
| 1707 | 1693 |
| 1708 setLayerPropertiesForTesting(parent.get(), layerTransform, sublayerTransform
, gfx::PointF(0.25, 0), gfx::PointF(2.5, 0), gfx::Size(10, 10), false); | 1694 setLayerPropertiesForTesting(parent.get(), layerTransform, sublayerTransform
, gfx::PointF(0.25, 0), gfx::PointF(2.5, 0), gfx::Size(10, 10), false); |
| 1709 setLayerPropertiesForTesting(renderSurface1.get(), layerTransform, sublayerT
ransform, gfx::PointF(0.25, 0), gfx::PointF(2.5, 0), gfx::Size(10, 10), false); | 1695 setLayerPropertiesForTesting(renderSurface1.get(), layerTransform, sublayerT
ransform, gfx::PointF(0.25, 0), gfx::PointF(2.5, 0), gfx::Size(10, 10), false); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1784 EXPECT_FALSE(grandChildOfRS1->screenSpaceTransformIsAnimating()); | 1770 EXPECT_FALSE(grandChildOfRS1->screenSpaceTransformIsAnimating()); |
| 1785 EXPECT_TRUE(renderSurface2->screenSpaceTransformIsAnimating()); | 1771 EXPECT_TRUE(renderSurface2->screenSpaceTransformIsAnimating()); |
| 1786 EXPECT_TRUE(renderSurface2->renderSurface()->screenSpaceTransformsAreAnimati
ng()); | 1772 EXPECT_TRUE(renderSurface2->renderSurface()->screenSpaceTransformsAreAnimati
ng()); |
| 1787 EXPECT_TRUE(childOfRS2->screenSpaceTransformIsAnimating()); | 1773 EXPECT_TRUE(childOfRS2->screenSpaceTransformIsAnimating()); |
| 1788 EXPECT_TRUE(grandChildOfRS2->screenSpaceTransformIsAnimating()); | 1774 EXPECT_TRUE(grandChildOfRS2->screenSpaceTransformIsAnimating()); |
| 1789 | 1775 |
| 1790 | 1776 |
| 1791 // Sanity check. If these fail there is probably a bug in the test itself. | 1777 // Sanity check. If these fail there is probably a bug in the test itself. |
| 1792 // It is expected that we correctly set up transforms so that the y-componen
t of the screen-space transform | 1778 // It is expected that we correctly set up transforms so that the y-componen
t of the screen-space transform |
| 1793 // encodes the "depth" of the layer in the tree. | 1779 // encodes the "depth" of the layer in the tree. |
| 1794 EXPECT_FLOAT_EQ(1, parent->screenSpaceTransform().m42()); | 1780 EXPECT_FLOAT_EQ(1, parent->screenSpaceTransform().matrix().getDouble(1, 3)); |
| 1795 EXPECT_FLOAT_EQ(2, childOfRoot->screenSpaceTransform().m42()); | 1781 EXPECT_FLOAT_EQ(2, childOfRoot->screenSpaceTransform().matrix().getDouble(1,
3)); |
| 1796 EXPECT_FLOAT_EQ(3, grandChildOfRoot->screenSpaceTransform().m42()); | 1782 EXPECT_FLOAT_EQ(3, grandChildOfRoot->screenSpaceTransform().matrix().getDoub
le(1, 3)); |
| 1797 | 1783 |
| 1798 EXPECT_FLOAT_EQ(2, renderSurface1->screenSpaceTransform().m42()); | 1784 EXPECT_FLOAT_EQ(2, renderSurface1->screenSpaceTransform().matrix().getDouble
(1, 3)); |
| 1799 EXPECT_FLOAT_EQ(3, childOfRS1->screenSpaceTransform().m42()); | 1785 EXPECT_FLOAT_EQ(3, childOfRS1->screenSpaceTransform().matrix().getDouble(1,
3)); |
| 1800 EXPECT_FLOAT_EQ(4, grandChildOfRS1->screenSpaceTransform().m42()); | 1786 EXPECT_FLOAT_EQ(4, grandChildOfRS1->screenSpaceTransform().matrix().getDoubl
e(1, 3)); |
| 1801 | 1787 |
| 1802 EXPECT_FLOAT_EQ(3, renderSurface2->screenSpaceTransform().m42()); | 1788 EXPECT_FLOAT_EQ(3, renderSurface2->screenSpaceTransform().matrix().getDouble
(1, 3)); |
| 1803 EXPECT_FLOAT_EQ(4, childOfRS2->screenSpaceTransform().m42()); | 1789 EXPECT_FLOAT_EQ(4, childOfRS2->screenSpaceTransform().matrix().getDouble(1,
3)); |
| 1804 EXPECT_FLOAT_EQ(5, grandChildOfRS2->screenSpaceTransform().m42()); | 1790 EXPECT_FLOAT_EQ(5, grandChildOfRS2->screenSpaceTransform().matrix().getDoubl
e(1, 3)); |
| 1805 } | 1791 } |
| 1806 | 1792 |
| 1807 TEST(LayerTreeHostCommonTest, verifyVisibleRectForIdentityTransform) | 1793 TEST(LayerTreeHostCommonTest, verifyVisibleRectForIdentityTransform) |
| 1808 { | 1794 { |
| 1809 // Test the calculateVisibleRect() function works correctly for identity tra
nsforms. | 1795 // Test the calculateVisibleRect() function works correctly for identity tra
nsforms. |
| 1810 | 1796 |
| 1811 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100
)); | 1797 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100
)); |
| 1812 WebTransformationMatrix layerToSurfaceTransform; | 1798 gfx::Transform layerToSurfaceTransform; |
| 1813 | 1799 |
| 1814 // Case 1: Layer is contained within the surface. | 1800 // Case 1: Layer is contained within the surface. |
| 1815 gfx::Rect layerContentRect = gfx::Rect(gfx::Point(10, 10), gfx::Size(30, 30)
); | 1801 gfx::Rect layerContentRect = gfx::Rect(gfx::Point(10, 10), gfx::Size(30, 30)
); |
| 1816 gfx::Rect expected = gfx::Rect(gfx::Point(10, 10), gfx::Size(30, 30)); | 1802 gfx::Rect expected = gfx::Rect(gfx::Point(10, 10), gfx::Size(30, 30)); |
| 1817 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); | 1803 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); |
| 1818 EXPECT_RECT_EQ(expected, actual); | 1804 EXPECT_RECT_EQ(expected, actual); |
| 1819 | 1805 |
| 1820 // Case 2: Layer is outside the surface rect. | 1806 // Case 2: Layer is outside the surface rect. |
| 1821 layerContentRect = gfx::Rect(gfx::Point(120, 120), gfx::Size(30, 30)); | 1807 layerContentRect = gfx::Rect(gfx::Point(120, 120), gfx::Size(30, 30)); |
| 1822 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC
ontentRect, layerToSurfaceTransform); | 1808 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC
ontentRect, layerToSurfaceTransform); |
| 1823 EXPECT_TRUE(actual.IsEmpty()); | 1809 EXPECT_TRUE(actual.IsEmpty()); |
| 1824 | 1810 |
| 1825 // Case 3: Layer is partially overlapping the surface rect. | 1811 // Case 3: Layer is partially overlapping the surface rect. |
| 1826 layerContentRect = gfx::Rect(gfx::Point(80, 80), gfx::Size(30, 30)); | 1812 layerContentRect = gfx::Rect(gfx::Point(80, 80), gfx::Size(30, 30)); |
| 1827 expected = gfx::Rect(gfx::Point(80, 80), gfx::Size(20, 20)); | 1813 expected = gfx::Rect(gfx::Point(80, 80), gfx::Size(20, 20)); |
| 1828 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC
ontentRect, layerToSurfaceTransform); | 1814 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC
ontentRect, layerToSurfaceTransform); |
| 1829 EXPECT_RECT_EQ(expected, actual); | 1815 EXPECT_RECT_EQ(expected, actual); |
| 1830 } | 1816 } |
| 1831 | 1817 |
| 1832 TEST(LayerTreeHostCommonTest, verifyVisibleRectForTranslations) | 1818 TEST(LayerTreeHostCommonTest, verifyVisibleRectForTranslations) |
| 1833 { | 1819 { |
| 1834 // Test the calculateVisibleRect() function works correctly for scaling tran
sforms. | 1820 // Test the calculateVisibleRect() function works correctly for scaling tran
sforms. |
| 1835 | 1821 |
| 1836 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100
)); | 1822 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100
)); |
| 1837 gfx::Rect layerContentRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(30, 30)); | 1823 gfx::Rect layerContentRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(30, 30)); |
| 1838 WebTransformationMatrix layerToSurfaceTransform; | 1824 gfx::Transform layerToSurfaceTransform; |
| 1839 | 1825 |
| 1840 // Case 1: Layer is contained within the surface. | 1826 // Case 1: Layer is contained within the surface. |
| 1841 layerToSurfaceTransform.makeIdentity(); | 1827 layerToSurfaceTransform.MakeIdentity(); |
| 1842 layerToSurfaceTransform.translate(10, 10); | 1828 layerToSurfaceTransform.Translate(10, 10); |
| 1843 gfx::Rect expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(30, 30)); | 1829 gfx::Rect expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(30, 30)); |
| 1844 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); | 1830 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); |
| 1845 EXPECT_RECT_EQ(expected, actual); | 1831 EXPECT_RECT_EQ(expected, actual); |
| 1846 | 1832 |
| 1847 // Case 2: Layer is outside the surface rect. | 1833 // Case 2: Layer is outside the surface rect. |
| 1848 layerToSurfaceTransform.makeIdentity(); | 1834 layerToSurfaceTransform.MakeIdentity(); |
| 1849 layerToSurfaceTransform.translate(120, 120); | 1835 layerToSurfaceTransform.Translate(120, 120); |
| 1850 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC
ontentRect, layerToSurfaceTransform); | 1836 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC
ontentRect, layerToSurfaceTransform); |
| 1851 EXPECT_TRUE(actual.IsEmpty()); | 1837 EXPECT_TRUE(actual.IsEmpty()); |
| 1852 | 1838 |
| 1853 // Case 3: Layer is partially overlapping the surface rect. | 1839 // Case 3: Layer is partially overlapping the surface rect. |
| 1854 layerToSurfaceTransform.makeIdentity(); | 1840 layerToSurfaceTransform.MakeIdentity(); |
| 1855 layerToSurfaceTransform.translate(80, 80); | 1841 layerToSurfaceTransform.Translate(80, 80); |
| 1856 expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(20, 20)); | 1842 expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(20, 20)); |
| 1857 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC
ontentRect, layerToSurfaceTransform); | 1843 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC
ontentRect, layerToSurfaceTransform); |
| 1858 EXPECT_RECT_EQ(expected, actual); | 1844 EXPECT_RECT_EQ(expected, actual); |
| 1859 } | 1845 } |
| 1860 | 1846 |
| 1861 TEST(LayerTreeHostCommonTest, verifyVisibleRectFor2DRotations) | 1847 TEST(LayerTreeHostCommonTest, verifyVisibleRectFor2DRotations) |
| 1862 { | 1848 { |
| 1863 // Test the calculateVisibleRect() function works correctly for rotations ab
out z-axis (i.e. 2D rotations). | 1849 // Test the calculateVisibleRect() function works correctly for rotations ab
out z-axis (i.e. 2D rotations). |
| 1864 // Remember that calculateVisibleRect() should return the visible rect in th
e layer's space. | 1850 // Remember that calculateVisibleRect() should return the visible rect in th
e layer's space. |
| 1865 | 1851 |
| 1866 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100
)); | 1852 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100
)); |
| 1867 gfx::Rect layerContentRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(30, 30)); | 1853 gfx::Rect layerContentRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(30, 30)); |
| 1868 WebTransformationMatrix layerToSurfaceTransform; | 1854 gfx::Transform layerToSurfaceTransform; |
| 1869 | 1855 |
| 1870 // Case 1: Layer is contained within the surface. | 1856 // Case 1: Layer is contained within the surface. |
| 1871 layerToSurfaceTransform.makeIdentity(); | 1857 layerToSurfaceTransform.MakeIdentity(); |
| 1872 layerToSurfaceTransform.translate(50, 50); | 1858 layerToSurfaceTransform.Translate(50, 50); |
| 1873 layerToSurfaceTransform.rotate(45); | 1859 layerToSurfaceTransform.Rotate(45); |
| 1874 gfx::Rect expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(30, 30)); | 1860 gfx::Rect expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(30, 30)); |
| 1875 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); | 1861 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); |
| 1876 EXPECT_RECT_EQ(expected, actual); | 1862 EXPECT_RECT_EQ(expected, actual); |
| 1877 | 1863 |
| 1878 // Case 2: Layer is outside the surface rect. | 1864 // Case 2: Layer is outside the surface rect. |
| 1879 layerToSurfaceTransform.makeIdentity(); | 1865 layerToSurfaceTransform.MakeIdentity(); |
| 1880 layerToSurfaceTransform.translate(-50, 0); | 1866 layerToSurfaceTransform.Translate(-50, 0); |
| 1881 layerToSurfaceTransform.rotate(45); | 1867 layerToSurfaceTransform.Rotate(45); |
| 1882 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC
ontentRect, layerToSurfaceTransform); | 1868 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC
ontentRect, layerToSurfaceTransform); |
| 1883 EXPECT_TRUE(actual.IsEmpty()); | 1869 EXPECT_TRUE(actual.IsEmpty()); |
| 1884 | 1870 |
| 1885 // Case 3: The layer is rotated about its top-left corner. In surface space,
the layer | 1871 // Case 3: The layer is rotated about its top-left corner. In surface space,
the layer |
| 1886 // is oriented diagonally, with the left half outside of the renderS
urface. In | 1872 // is oriented diagonally, with the left half outside of the renderS
urface. In |
| 1887 // this case, the visible rect should still be the entire layer (rem
ember the | 1873 // this case, the visible rect should still be the entire layer (rem
ember the |
| 1888 // visible rect is computed in layer space); both the top-left and | 1874 // visible rect is computed in layer space); both the top-left and |
| 1889 // bottom-right corners of the layer are still visible. | 1875 // bottom-right corners of the layer are still visible. |
| 1890 layerToSurfaceTransform.makeIdentity(); | 1876 layerToSurfaceTransform.MakeIdentity(); |
| 1891 layerToSurfaceTransform.rotate(45); | 1877 layerToSurfaceTransform.Rotate(45); |
| 1892 expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(30, 30)); | 1878 expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(30, 30)); |
| 1893 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC
ontentRect, layerToSurfaceTransform); | 1879 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC
ontentRect, layerToSurfaceTransform); |
| 1894 EXPECT_RECT_EQ(expected, actual); | 1880 EXPECT_RECT_EQ(expected, actual); |
| 1895 | 1881 |
| 1896 // Case 4: The layer is rotated about its top-left corner, and translated up
wards. In | 1882 // Case 4: The layer is rotated about its top-left corner, and translated up
wards. In |
| 1897 // surface space, the layer is oriented diagonally, with only the to
p corner | 1883 // surface space, the layer is oriented diagonally, with only the to
p corner |
| 1898 // of the surface overlapping the layer. In layer space, the render
surface | 1884 // of the surface overlapping the layer. In layer space, the render
surface |
| 1899 // overlaps the right side of the layer. The visible rect should be
the | 1885 // overlaps the right side of the layer. The visible rect should be
the |
| 1900 // layer's right half. | 1886 // layer's right half. |
| 1901 layerToSurfaceTransform.makeIdentity(); | 1887 layerToSurfaceTransform.MakeIdentity(); |
| 1902 layerToSurfaceTransform.translate(0, -sqrt(2.0) * 15); | 1888 layerToSurfaceTransform.Translate(0, -sqrt(2.0) * 15); |
| 1903 layerToSurfaceTransform.rotate(45); | 1889 layerToSurfaceTransform.Rotate(45); |
| 1904 expected = gfx::Rect(gfx::Point(15, 0), gfx::Size(15, 30)); // right half of
layer bounds. | 1890 expected = gfx::Rect(gfx::Point(15, 0), gfx::Size(15, 30)); // right half of
layer bounds. |
| 1905 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC
ontentRect, layerToSurfaceTransform); | 1891 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC
ontentRect, layerToSurfaceTransform); |
| 1906 EXPECT_RECT_EQ(expected, actual); | 1892 EXPECT_RECT_EQ(expected, actual); |
| 1907 } | 1893 } |
| 1908 | 1894 |
| 1909 TEST(LayerTreeHostCommonTest, verifyVisibleRectFor3dOrthographicTransform) | 1895 TEST(LayerTreeHostCommonTest, verifyVisibleRectFor3dOrthographicTransform) |
| 1910 { | 1896 { |
| 1911 // Test that the calculateVisibleRect() function works correctly for 3d tran
sforms. | 1897 // Test that the calculateVisibleRect() function works correctly for 3d tran
sforms. |
| 1912 | 1898 |
| 1913 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100
)); | 1899 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100
)); |
| 1914 gfx::Rect layerContentRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100)
); | 1900 gfx::Rect layerContentRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100)
); |
| 1915 WebTransformationMatrix layerToSurfaceTransform; | 1901 gfx::Transform layerToSurfaceTransform; |
| 1916 | 1902 |
| 1917 // Case 1: Orthographic projection of a layer rotated about y-axis by 45 deg
rees, should be fully contained in the renderSurface. | 1903 // Case 1: Orthographic projection of a layer rotated about y-axis by 45 deg
rees, should be fully contained in the renderSurface. |
| 1918 layerToSurfaceTransform.makeIdentity(); | 1904 layerToSurfaceTransform.MakeIdentity(); |
| 1919 layerToSurfaceTransform.rotate3d(0, 45, 0); | 1905 MathUtil::rotateEulerAngles(&layerToSurfaceTransform, 0, 45, 0); |
| 1920 gfx::Rect expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100)); | 1906 gfx::Rect expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100)); |
| 1921 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); | 1907 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); |
| 1922 EXPECT_RECT_EQ(expected, actual); | 1908 EXPECT_RECT_EQ(expected, actual); |
| 1923 | 1909 |
| 1924 // Case 2: Orthographic projection of a layer rotated about y-axis by 45 deg
rees, but | 1910 // Case 2: Orthographic projection of a layer rotated about y-axis by 45 deg
rees, but |
| 1925 // shifted to the side so only the right-half the layer would be vis
ible on | 1911 // shifted to the side so only the right-half the layer would be vis
ible on |
| 1926 // the surface. | 1912 // the surface. |
| 1927 double halfWidthOfRotatedLayer = (100 / sqrt(2.0)) * 0.5; // 100 is the un-r
otated layer width; divided by sqrt(2) is the rotated width. | 1913 double halfWidthOfRotatedLayer = (100 / sqrt(2.0)) * 0.5; // 100 is the un-r
otated layer width; divided by sqrt(2) is the rotated width. |
| 1928 layerToSurfaceTransform.makeIdentity(); | 1914 layerToSurfaceTransform.MakeIdentity(); |
| 1929 layerToSurfaceTransform.translate(-halfWidthOfRotatedLayer, 0); | 1915 layerToSurfaceTransform.Translate(-halfWidthOfRotatedLayer, 0); |
| 1930 layerToSurfaceTransform.rotate3d(0, 45, 0); // rotates about the left edge o
f the layer | 1916 MathUtil::rotateEulerAngles(&layerToSurfaceTransform, 0, 45, 0); // rotates
about the left edge of the layer |
| 1931 expected = gfx::Rect(gfx::Point(50, 0), gfx::Size(50, 100)); // right half o
f the layer. | 1917 expected = gfx::Rect(gfx::Point(50, 0), gfx::Size(50, 100)); // right half o
f the layer. |
| 1932 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC
ontentRect, layerToSurfaceTransform); | 1918 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC
ontentRect, layerToSurfaceTransform); |
| 1933 EXPECT_RECT_EQ(expected, actual); | 1919 EXPECT_RECT_EQ(expected, actual); |
| 1934 } | 1920 } |
| 1935 | 1921 |
| 1936 TEST(LayerTreeHostCommonTest, verifyVisibleRectFor3dPerspectiveTransform) | 1922 TEST(LayerTreeHostCommonTest, verifyVisibleRectFor3dPerspectiveTransform) |
| 1937 { | 1923 { |
| 1938 // Test the calculateVisibleRect() function works correctly when the layer h
as a | 1924 // Test the calculateVisibleRect() function works correctly when the layer h
as a |
| 1939 // perspective projection onto the target surface. | 1925 // perspective projection onto the target surface. |
| 1940 | 1926 |
| 1941 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100
)); | 1927 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100
)); |
| 1942 gfx::Rect layerContentRect = gfx::Rect(gfx::Point(-50, -50), gfx::Size(200,
200)); | 1928 gfx::Rect layerContentRect = gfx::Rect(gfx::Point(-50, -50), gfx::Size(200,
200)); |
| 1943 WebTransformationMatrix layerToSurfaceTransform; | 1929 gfx::Transform layerToSurfaceTransform; |
| 1944 | 1930 |
| 1945 // Case 1: Even though the layer is twice as large as the surface, due to pe
rspective | 1931 // Case 1: Even though the layer is twice as large as the surface, due to pe
rspective |
| 1946 // foreshortening, the layer will fit fully in the surface when its
translated | 1932 // foreshortening, the layer will fit fully in the surface when its
translated |
| 1947 // more than the perspective amount. | 1933 // more than the perspective amount. |
| 1948 layerToSurfaceTransform.makeIdentity(); | 1934 layerToSurfaceTransform.MakeIdentity(); |
| 1949 | 1935 |
| 1950 // The following sequence of transforms applies the perspective about the ce
nter of the surface. | 1936 // The following sequence of transforms applies the perspective about the ce
nter of the surface. |
| 1951 layerToSurfaceTransform.translate(50, 50); | 1937 layerToSurfaceTransform.Translate(50, 50); |
| 1952 layerToSurfaceTransform.applyPerspective(9); | 1938 layerToSurfaceTransform.ApplyPerspectiveDepth(9); |
| 1953 layerToSurfaceTransform.translate(-50, -50); | 1939 layerToSurfaceTransform.Translate(-50, -50); |
| 1954 | 1940 |
| 1955 // This translate places the layer in front of the surface's projection plan
e. | 1941 // This translate places the layer in front of the surface's projection plan
e. |
| 1956 layerToSurfaceTransform.translate3d(0, 0, -27); | 1942 layerToSurfaceTransform.Translate3d(0, 0, -27); |
| 1957 | 1943 |
| 1958 gfx::Rect expected = gfx::Rect(gfx::Point(-50, -50), gfx::Size(200, 200)); | 1944 gfx::Rect expected = gfx::Rect(gfx::Point(-50, -50), gfx::Size(200, 200)); |
| 1959 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); | 1945 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); |
| 1960 EXPECT_RECT_EQ(expected, actual); | 1946 EXPECT_RECT_EQ(expected, actual); |
| 1961 | 1947 |
| 1962 // Case 2: same projection as before, except that the layer is also translat
ed to the | 1948 // Case 2: same projection as before, except that the layer is also translat
ed to the |
| 1963 // side, so that only the right half of the layer should be visible. | 1949 // side, so that only the right half of the layer should be visible. |
| 1964 // | 1950 // |
| 1965 // Explanation of expected result: | 1951 // Explanation of expected result: |
| 1966 // The perspective ratio is (z distance between layer and camera origin) / (
z distance between projection plane and camera origin) == ((-27 - 9) / 9) | 1952 // The perspective ratio is (z distance between layer and camera origin) / (
z distance between projection plane and camera origin) == ((-27 - 9) / 9) |
| 1967 // Then, by similar triangles, if we want to move a layer by translating -50
units in projected surface units (so that only half of it is | 1953 // Then, by similar triangles, if we want to move a layer by translating -50
units in projected surface units (so that only half of it is |
| 1968 // visible), then we would need to translate by (-36 / 9) * -50 == -200 in t
he layer's units. | 1954 // visible), then we would need to translate by (-36 / 9) * -50 == -200 in t
he layer's units. |
| 1969 // | 1955 // |
| 1970 layerToSurfaceTransform.translate3d(-200, 0, 0); | 1956 layerToSurfaceTransform.Translate3d(-200, 0, 0); |
| 1971 expected = gfx::Rect(gfx::Point(50, -50), gfx::Size(100, 200)); // The right
half of the layer's bounding rect. | 1957 expected = gfx::Rect(gfx::Point(50, -50), gfx::Size(100, 200)); // The right
half of the layer's bounding rect. |
| 1972 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC
ontentRect, layerToSurfaceTransform); | 1958 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC
ontentRect, layerToSurfaceTransform); |
| 1973 EXPECT_RECT_EQ(expected, actual); | 1959 EXPECT_RECT_EQ(expected, actual); |
| 1974 } | 1960 } |
| 1975 | 1961 |
| 1976 TEST(LayerTreeHostCommonTest, verifyVisibleRectFor3dOrthographicIsNotClippedBehi
ndSurface) | 1962 TEST(LayerTreeHostCommonTest, verifyVisibleRectFor3dOrthographicIsNotClippedBehi
ndSurface) |
| 1977 { | 1963 { |
| 1978 // There is currently no explicit concept of an orthographic projection plan
e in our | 1964 // There is currently no explicit concept of an orthographic projection plan
e in our |
| 1979 // code (nor in the CSS spec to my knowledge). Therefore, layers that are te
chnically | 1965 // code (nor in the CSS spec to my knowledge). Therefore, layers that are te
chnically |
| 1980 // behind the surface in an orthographic world should not be clipped when th
ey are | 1966 // behind the surface in an orthographic world should not be clipped when th
ey are |
| 1981 // flattened to the surface. | 1967 // flattened to the surface. |
| 1982 | 1968 |
| 1983 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100
)); | 1969 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100
)); |
| 1984 gfx::Rect layerContentRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100)
); | 1970 gfx::Rect layerContentRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100)
); |
| 1985 WebTransformationMatrix layerToSurfaceTransform; | 1971 gfx::Transform layerToSurfaceTransform; |
| 1986 | 1972 |
| 1987 // This sequence of transforms effectively rotates the layer about the y-axi
s at the | 1973 // This sequence of transforms effectively rotates the layer about the y-axi
s at the |
| 1988 // center of the layer. | 1974 // center of the layer. |
| 1989 layerToSurfaceTransform.makeIdentity(); | 1975 layerToSurfaceTransform.MakeIdentity(); |
| 1990 layerToSurfaceTransform.translate(50, 0); | 1976 layerToSurfaceTransform.Translate(50, 0); |
| 1991 layerToSurfaceTransform.rotate3d(0, 45, 0); | 1977 MathUtil::rotateEulerAngles(&layerToSurfaceTransform, 0, 45, 0); |
| 1992 layerToSurfaceTransform.translate(-50, 0); | 1978 layerToSurfaceTransform.Translate(-50, 0); |
| 1993 | 1979 |
| 1994 gfx::Rect expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100)); | 1980 gfx::Rect expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100)); |
| 1995 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); | 1981 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); |
| 1996 EXPECT_RECT_EQ(expected, actual); | 1982 EXPECT_RECT_EQ(expected, actual); |
| 1997 } | 1983 } |
| 1998 | 1984 |
| 1999 TEST(LayerTreeHostCommonTest, verifyVisibleRectFor3dPerspectiveWhenClippedByW) | 1985 TEST(LayerTreeHostCommonTest, verifyVisibleRectFor3dPerspectiveWhenClippedByW) |
| 2000 { | 1986 { |
| 2001 // Test the calculateVisibleRect() function works correctly when projecting
a surface | 1987 // Test the calculateVisibleRect() function works correctly when projecting
a surface |
| 2002 // onto a layer, but the layer is partially behind the camera (not just behi
nd the | 1988 // onto a layer, but the layer is partially behind the camera (not just behi
nd the |
| 2003 // projection plane). In this case, the cartesian coordinates may seem to be
valid, | 1989 // projection plane). In this case, the cartesian coordinates may seem to be
valid, |
| 2004 // but actually they are not. The visibleRect needs to be properly clipped b
y the | 1990 // but actually they are not. The visibleRect needs to be properly clipped b
y the |
| 2005 // w = 0 plane in homogeneous coordinates before converting to cartesian coo
rdinates. | 1991 // w = 0 plane in homogeneous coordinates before converting to cartesian coo
rdinates. |
| 2006 | 1992 |
| 2007 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(-50, -50), gfx::Size(100,
100)); | 1993 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(-50, -50), gfx::Size(100,
100)); |
| 2008 gfx::Rect layerContentRect = gfx::Rect(gfx::Point(-10, -1), gfx::Size(20, 2)
); | 1994 gfx::Rect layerContentRect = gfx::Rect(gfx::Point(-10, -1), gfx::Size(20, 2)
); |
| 2009 WebTransformationMatrix layerToSurfaceTransform; | 1995 gfx::Transform layerToSurfaceTransform; |
| 2010 | 1996 |
| 2011 // The layer is positioned so that the right half of the layer should be in
front of | 1997 // The layer is positioned so that the right half of the layer should be in
front of |
| 2012 // the camera, while the other half is behind the surface's projection plane
. The | 1998 // the camera, while the other half is behind the surface's projection plane
. The |
| 2013 // following sequence of transforms applies the perspective and rotation abo
ut the | 1999 // following sequence of transforms applies the perspective and rotation abo
ut the |
| 2014 // center of the layer. | 2000 // center of the layer. |
| 2015 layerToSurfaceTransform.makeIdentity(); | 2001 layerToSurfaceTransform.MakeIdentity(); |
| 2016 layerToSurfaceTransform.applyPerspective(1); | 2002 layerToSurfaceTransform.ApplyPerspectiveDepth(1); |
| 2017 layerToSurfaceTransform.translate3d(-2, 0, 1); | 2003 layerToSurfaceTransform.Translate3d(-2, 0, 1); |
| 2018 layerToSurfaceTransform.rotate3d(0, 45, 0); | 2004 MathUtil::rotateEulerAngles(&layerToSurfaceTransform, 0, 45, 0); |
| 2019 | 2005 |
| 2020 // Sanity check that this transform does indeed cause w < 0 when applying th
e | 2006 // Sanity check that this transform does indeed cause w < 0 when applying th
e |
| 2021 // transform, otherwise this code is not testing the intended scenario. | 2007 // transform, otherwise this code is not testing the intended scenario. |
| 2022 bool clipped = false; | 2008 bool clipped = false; |
| 2023 MathUtil::mapQuad(layerToSurfaceTransform, gfx::QuadF(gfx::RectF(layerConten
tRect)), clipped); | 2009 MathUtil::mapQuad(layerToSurfaceTransform, gfx::QuadF(gfx::RectF(layerConten
tRect)), clipped); |
| 2024 ASSERT_TRUE(clipped); | 2010 ASSERT_TRUE(clipped); |
| 2025 | 2011 |
| 2026 int expectedXPosition = 0; | 2012 int expectedXPosition = 0; |
| 2027 int expectedWidth = 10; | 2013 int expectedWidth = 10; |
| 2028 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); | 2014 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); |
| 2029 EXPECT_EQ(expectedXPosition, actual.x()); | 2015 EXPECT_EQ(expectedXPosition, actual.x()); |
| 2030 EXPECT_EQ(expectedWidth, actual.width()); | 2016 EXPECT_EQ(expectedWidth, actual.width()); |
| 2031 } | 2017 } |
| 2032 | 2018 |
| 2033 TEST(LayerTreeHostCommonTest, verifyVisibleRectForPerspectiveUnprojection) | 2019 TEST(LayerTreeHostCommonTest, verifyVisibleRectForPerspectiveUnprojection) |
| 2034 { | 2020 { |
| 2035 // To determine visibleRect in layer space, there needs to be an un-projecti
on from | 2021 // To determine visibleRect in layer space, there needs to be an un-projecti
on from |
| 2036 // surface space to layer space. When the original transform was a perspecti
ve | 2022 // surface space to layer space. When the original transform was a perspecti
ve |
| 2037 // projection that was clipped, it returns a rect that encloses the clipped
bounds. | 2023 // projection that was clipped, it returns a rect that encloses the clipped
bounds. |
| 2038 // Un-projecting this new rect may require clipping again. | 2024 // Un-projecting this new rect may require clipping again. |
| 2039 | 2025 |
| 2040 // This sequence of transforms causes one corner of the layer to protrude ac
ross the w = 0 plane, and should be clipped. | 2026 // This sequence of transforms causes one corner of the layer to protrude ac
ross the w = 0 plane, and should be clipped. |
| 2041 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(-50, -50), gfx::Size(100,
100)); | 2027 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(-50, -50), gfx::Size(100,
100)); |
| 2042 gfx::Rect layerContentRect = gfx::Rect(gfx::Point(-10, -10), gfx::Size(20, 2
0)); | 2028 gfx::Rect layerContentRect = gfx::Rect(gfx::Point(-10, -10), gfx::Size(20, 2
0)); |
| 2043 WebTransformationMatrix layerToSurfaceTransform; | 2029 gfx::Transform layerToSurfaceTransform; |
| 2044 layerToSurfaceTransform.makeIdentity(); | 2030 layerToSurfaceTransform.MakeIdentity(); |
| 2045 layerToSurfaceTransform.applyPerspective(1); | 2031 layerToSurfaceTransform.ApplyPerspectiveDepth(1); |
| 2046 layerToSurfaceTransform.translate3d(0, 0, -5); | 2032 layerToSurfaceTransform.Translate3d(0, 0, -5); |
| 2047 layerToSurfaceTransform.rotate3d(0, 45, 0); | 2033 MathUtil::rotateEulerAngles(&layerToSurfaceTransform, 0, 45, 0); |
| 2048 layerToSurfaceTransform.rotate3d(80, 0, 0); | 2034 MathUtil::rotateEulerAngles(&layerToSurfaceTransform, 80, 0, 0); |
| 2049 | 2035 |
| 2050 // Sanity check that un-projection does indeed cause w < 0, otherwise this c
ode is not | 2036 // Sanity check that un-projection does indeed cause w < 0, otherwise this c
ode is not |
| 2051 // testing the intended scenario. | 2037 // testing the intended scenario. |
| 2052 bool clipped = false; | 2038 bool clipped = false; |
| 2053 gfx::RectF clippedRect = MathUtil::mapClippedRect(layerToSurfaceTransform, l
ayerContentRect); | 2039 gfx::RectF clippedRect = MathUtil::mapClippedRect(layerToSurfaceTransform, l
ayerContentRect); |
| 2054 MathUtil::projectQuad(layerToSurfaceTransform.inverse(), gfx::QuadF(clippedR
ect), clipped); | 2040 MathUtil::projectQuad(MathUtil::inverse(layerToSurfaceTransform), gfx::QuadF
(clippedRect), clipped); |
| 2055 ASSERT_TRUE(clipped); | 2041 ASSERT_TRUE(clipped); |
| 2056 | 2042 |
| 2057 // Only the corner of the layer is not visible on the surface because of bei
ng | 2043 // Only the corner of the layer is not visible on the surface because of bei
ng |
| 2058 // clipped. But, the net result of rounding visible region to an axis-aligne
d rect is | 2044 // clipped. But, the net result of rounding visible region to an axis-aligne
d rect is |
| 2059 // that the entire layer should still be considered visible. | 2045 // that the entire layer should still be considered visible. |
| 2060 gfx::Rect expected = gfx::Rect(gfx::Point(-10, -10), gfx::Size(20, 20)); | 2046 gfx::Rect expected = gfx::Rect(gfx::Point(-10, -10), gfx::Size(20, 20)); |
| 2061 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); | 2047 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); |
| 2062 EXPECT_RECT_EQ(expected, actual); | 2048 EXPECT_RECT_EQ(expected, actual); |
| 2063 } | 2049 } |
| 2064 | 2050 |
| 2065 TEST(LayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsForSimpleLayer
s) | 2051 TEST(LayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsForSimpleLayer
s) |
| 2066 { | 2052 { |
| 2067 scoped_refptr<Layer> root = Layer::create(); | 2053 scoped_refptr<Layer> root = Layer::create(); |
| 2068 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); | 2054 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
| 2069 scoped_refptr<LayerWithForcedDrawsContent> child2 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); | 2055 scoped_refptr<LayerWithForcedDrawsContent> child2 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
| 2070 scoped_refptr<LayerWithForcedDrawsContent> child3 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); | 2056 scoped_refptr<LayerWithForcedDrawsContent> child3 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
| 2071 root->addChild(child1); | 2057 root->addChild(child1); |
| 2072 root->addChild(child2); | 2058 root->addChild(child2); |
| 2073 root->addChild(child3); | 2059 root->addChild(child3); |
| 2074 | 2060 |
| 2075 WebTransformationMatrix identityMatrix; | 2061 gfx::Transform identityMatrix; |
| 2076 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2062 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 2077 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(50, 50), false); | 2063 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(50, 50), false); |
| 2078 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(75, 75), gfx::Size(50, 50), false); | 2064 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(75, 75), gfx::Size(50, 50), false); |
| 2079 setLayerPropertiesForTesting(child3.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(125, 125), gfx::Size(50, 50), false); | 2065 setLayerPropertiesForTesting(child3.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(125, 125), gfx::Size(50, 50), false); |
| 2080 | 2066 |
| 2081 executeCalculateDrawTransformsAndVisibility(root.get()); | 2067 executeCalculateDrawTransformsAndVisibility(root.get()); |
| 2082 | 2068 |
| 2083 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), root->renderSurface()->drawableCon
tentRect()); | 2069 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), root->renderSurface()->drawableCon
tentRect()); |
| 2084 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawableContentRect()); | 2070 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawableContentRect()); |
| 2085 | 2071 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2102 scoped_refptr<Layer> root = Layer::create(); | 2088 scoped_refptr<Layer> root = Layer::create(); |
| 2103 scoped_refptr<Layer> child = Layer::create(); | 2089 scoped_refptr<Layer> child = Layer::create(); |
| 2104 scoped_refptr<LayerWithForcedDrawsContent> grandChild1 = make_scoped_refptr(
new LayerWithForcedDrawsContent()); | 2090 scoped_refptr<LayerWithForcedDrawsContent> grandChild1 = make_scoped_refptr(
new LayerWithForcedDrawsContent()); |
| 2105 scoped_refptr<LayerWithForcedDrawsContent> grandChild2 = make_scoped_refptr(
new LayerWithForcedDrawsContent()); | 2091 scoped_refptr<LayerWithForcedDrawsContent> grandChild2 = make_scoped_refptr(
new LayerWithForcedDrawsContent()); |
| 2106 scoped_refptr<LayerWithForcedDrawsContent> grandChild3 = make_scoped_refptr(
new LayerWithForcedDrawsContent()); | 2092 scoped_refptr<LayerWithForcedDrawsContent> grandChild3 = make_scoped_refptr(
new LayerWithForcedDrawsContent()); |
| 2107 root->addChild(child); | 2093 root->addChild(child); |
| 2108 child->addChild(grandChild1); | 2094 child->addChild(grandChild1); |
| 2109 child->addChild(grandChild2); | 2095 child->addChild(grandChild2); |
| 2110 child->addChild(grandChild3); | 2096 child->addChild(grandChild3); |
| 2111 | 2097 |
| 2112 WebTransformationMatrix identityMatrix; | 2098 gfx::Transform identityMatrix; |
| 2113 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2099 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 2114 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2100 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 2115 setLayerPropertiesForTesting(grandChild1.get(), identityMatrix, identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(50, 50), false); | 2101 setLayerPropertiesForTesting(grandChild1.get(), identityMatrix, identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(50, 50), false); |
| 2116 setLayerPropertiesForTesting(grandChild2.get(), identityMatrix, identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(75, 75), gfx::Size(50, 50), false); | 2102 setLayerPropertiesForTesting(grandChild2.get(), identityMatrix, identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(75, 75), gfx::Size(50, 50), false); |
| 2117 setLayerPropertiesForTesting(grandChild3.get(), identityMatrix, identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(125, 125), gfx::Size(50, 50), false); | 2103 setLayerPropertiesForTesting(grandChild3.get(), identityMatrix, identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(125, 125), gfx::Size(50, 50), false); |
| 2118 | 2104 |
| 2119 child->setMasksToBounds(true); | 2105 child->setMasksToBounds(true); |
| 2120 executeCalculateDrawTransformsAndVisibility(root.get()); | 2106 executeCalculateDrawTransformsAndVisibility(root.get()); |
| 2121 | 2107 |
| 2122 ASSERT_FALSE(child->renderSurface()); | 2108 ASSERT_FALSE(child->renderSurface()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2144 scoped_refptr<Layer> root = Layer::create(); | 2130 scoped_refptr<Layer> root = Layer::create(); |
| 2145 scoped_refptr<Layer> renderSurface1 = Layer::create(); | 2131 scoped_refptr<Layer> renderSurface1 = Layer::create(); |
| 2146 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); | 2132 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
| 2147 scoped_refptr<LayerWithForcedDrawsContent> child2 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); | 2133 scoped_refptr<LayerWithForcedDrawsContent> child2 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
| 2148 scoped_refptr<LayerWithForcedDrawsContent> child3 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); | 2134 scoped_refptr<LayerWithForcedDrawsContent> child3 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
| 2149 root->addChild(renderSurface1); | 2135 root->addChild(renderSurface1); |
| 2150 renderSurface1->addChild(child1); | 2136 renderSurface1->addChild(child1); |
| 2151 renderSurface1->addChild(child2); | 2137 renderSurface1->addChild(child2); |
| 2152 renderSurface1->addChild(child3); | 2138 renderSurface1->addChild(child3); |
| 2153 | 2139 |
| 2154 WebTransformationMatrix identityMatrix; | 2140 gfx::Transform identityMatrix; |
| 2155 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2141 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 2156 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(3, 4), false); | 2142 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(3, 4), false); |
| 2157 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(50, 50), false); | 2143 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(50, 50), false); |
| 2158 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(75, 75), gfx::Size(50, 50), false); | 2144 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(75, 75), gfx::Size(50, 50), false); |
| 2159 setLayerPropertiesForTesting(child3.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(125, 125), gfx::Size(50, 50), false); | 2145 setLayerPropertiesForTesting(child3.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(125, 125), gfx::Size(50, 50), false); |
| 2160 | 2146 |
| 2161 renderSurface1->setForceRenderSurface(true); | 2147 renderSurface1->setForceRenderSurface(true); |
| 2162 executeCalculateDrawTransformsAndVisibility(root.get()); | 2148 executeCalculateDrawTransformsAndVisibility(root.get()); |
| 2163 | 2149 |
| 2164 ASSERT_TRUE(renderSurface1->renderSurface()); | 2150 ASSERT_TRUE(renderSurface1->renderSurface()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2188 scoped_refptr<Layer> root = Layer::create(); | 2174 scoped_refptr<Layer> root = Layer::create(); |
| 2189 scoped_refptr<Layer> renderSurface1 = Layer::create(); | 2175 scoped_refptr<Layer> renderSurface1 = Layer::create(); |
| 2190 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); | 2176 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
| 2191 scoped_refptr<LayerWithForcedDrawsContent> child2 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); | 2177 scoped_refptr<LayerWithForcedDrawsContent> child2 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
| 2192 scoped_refptr<LayerWithForcedDrawsContent> child3 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); | 2178 scoped_refptr<LayerWithForcedDrawsContent> child3 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
| 2193 root->addChild(renderSurface1); | 2179 root->addChild(renderSurface1); |
| 2194 renderSurface1->addChild(child1); | 2180 renderSurface1->addChild(child1); |
| 2195 renderSurface1->addChild(child2); | 2181 renderSurface1->addChild(child2); |
| 2196 renderSurface1->addChild(child3); | 2182 renderSurface1->addChild(child3); |
| 2197 | 2183 |
| 2198 WebTransformationMatrix identityMatrix; | 2184 gfx::Transform identityMatrix; |
| 2199 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2185 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 2200 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(3, 4), false); | 2186 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(3, 4), false); |
| 2201 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(50, 50), false); | 2187 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(50, 50), false); |
| 2202 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(75, 75), gfx::Size(50, 50), false); | 2188 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(75, 75), gfx::Size(50, 50), false); |
| 2203 setLayerPropertiesForTesting(child3.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(125, 125), gfx::Size(50, 50), false); | 2189 setLayerPropertiesForTesting(child3.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(125, 125), gfx::Size(50, 50), false); |
| 2204 | 2190 |
| 2205 root->setMasksToBounds(true); | 2191 root->setMasksToBounds(true); |
| 2206 renderSurface1->setForceRenderSurface(true); | 2192 renderSurface1->setForceRenderSurface(true); |
| 2207 executeCalculateDrawTransformsAndVisibility(root.get()); | 2193 executeCalculateDrawTransformsAndVisibility(root.get()); |
| 2208 | 2194 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2238 scoped_refptr<Layer> renderSurface2 = Layer::create(); | 2224 scoped_refptr<Layer> renderSurface2 = Layer::create(); |
| 2239 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); | 2225 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
| 2240 scoped_refptr<LayerWithForcedDrawsContent> child2 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); | 2226 scoped_refptr<LayerWithForcedDrawsContent> child2 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
| 2241 scoped_refptr<LayerWithForcedDrawsContent> child3 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); | 2227 scoped_refptr<LayerWithForcedDrawsContent> child3 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
| 2242 root->addChild(renderSurface1); | 2228 root->addChild(renderSurface1); |
| 2243 renderSurface1->addChild(renderSurface2); | 2229 renderSurface1->addChild(renderSurface2); |
| 2244 renderSurface2->addChild(child1); | 2230 renderSurface2->addChild(child1); |
| 2245 renderSurface2->addChild(child2); | 2231 renderSurface2->addChild(child2); |
| 2246 renderSurface2->addChild(child3); | 2232 renderSurface2->addChild(child3); |
| 2247 | 2233 |
| 2248 WebTransformationMatrix identityMatrix; | 2234 gfx::Transform identityMatrix; |
| 2249 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2235 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 2250 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(3, 4), false); | 2236 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(3, 4), false); |
| 2251 setLayerPropertiesForTesting(renderSurface2.get(), identityMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(7, 13), false); | 2237 setLayerPropertiesForTesting(renderSurface2.get(), identityMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(7, 13), false); |
| 2252 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(50, 50), false); | 2238 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(50, 50), false); |
| 2253 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(75, 75), gfx::Size(50, 50), false); | 2239 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(75, 75), gfx::Size(50, 50), false); |
| 2254 setLayerPropertiesForTesting(child3.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(125, 125), gfx::Size(50, 50), false); | 2240 setLayerPropertiesForTesting(child3.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(125, 125), gfx::Size(50, 50), false); |
| 2255 | 2241 |
| 2256 root->setMasksToBounds(true); | 2242 root->setMasksToBounds(true); |
| 2257 renderSurface1->setForceRenderSurface(true); | 2243 renderSurface1->setForceRenderSurface(true); |
| 2258 renderSurface2->setForceRenderSurface(true); | 2244 renderSurface2->setForceRenderSurface(true); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2293 { | 2279 { |
| 2294 // Layers that have non-axis aligned bounds (due to transforms) have an expa
nded, | 2280 // Layers that have non-axis aligned bounds (due to transforms) have an expa
nded, |
| 2295 // axis-aligned drawableContentRect and visibleContentRect. | 2281 // axis-aligned drawableContentRect and visibleContentRect. |
| 2296 | 2282 |
| 2297 scoped_refptr<Layer> root = Layer::create(); | 2283 scoped_refptr<Layer> root = Layer::create(); |
| 2298 scoped_refptr<Layer> renderSurface1 = Layer::create(); | 2284 scoped_refptr<Layer> renderSurface1 = Layer::create(); |
| 2299 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); | 2285 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
| 2300 root->addChild(renderSurface1); | 2286 root->addChild(renderSurface1); |
| 2301 renderSurface1->addChild(child1); | 2287 renderSurface1->addChild(child1); |
| 2302 | 2288 |
| 2303 WebTransformationMatrix identityMatrix; | 2289 gfx::Transform identityMatrix; |
| 2304 WebTransformationMatrix childRotation; | 2290 gfx::Transform childRotation; |
| 2305 childRotation.rotate(45); | 2291 childRotation.Rotate(45); |
| 2306 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2292 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 2307 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(3, 4), false); | 2293 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(3, 4), false); |
| 2308 setLayerPropertiesForTesting(child1.get(), childRotation, identityMatrix, gf
x::PointF(0.5, 0.5), gfx::PointF(25, 25), gfx::Size(50, 50), false); | 2294 setLayerPropertiesForTesting(child1.get(), childRotation, identityMatrix, gf
x::PointF(0.5, 0.5), gfx::PointF(25, 25), gfx::Size(50, 50), false); |
| 2309 | 2295 |
| 2310 renderSurface1->setForceRenderSurface(true); | 2296 renderSurface1->setForceRenderSurface(true); |
| 2311 executeCalculateDrawTransformsAndVisibility(root.get()); | 2297 executeCalculateDrawTransformsAndVisibility(root.get()); |
| 2312 | 2298 |
| 2313 ASSERT_TRUE(renderSurface1->renderSurface()); | 2299 ASSERT_TRUE(renderSurface1->renderSurface()); |
| 2314 | 2300 |
| 2315 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), root->renderSurface()->drawableCon
tentRect()); | 2301 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), root->renderSurface()->drawableCon
tentRect()); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2333 { | 2319 { |
| 2334 // Layers that have non-axis aligned bounds (due to transforms) have an expa
nded, | 2320 // Layers that have non-axis aligned bounds (due to transforms) have an expa
nded, |
| 2335 // axis-aligned drawableContentRect and visibleContentRect. | 2321 // axis-aligned drawableContentRect and visibleContentRect. |
| 2336 | 2322 |
| 2337 scoped_refptr<Layer> root = Layer::create(); | 2323 scoped_refptr<Layer> root = Layer::create(); |
| 2338 scoped_refptr<Layer> renderSurface1 = Layer::create(); | 2324 scoped_refptr<Layer> renderSurface1 = Layer::create(); |
| 2339 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); | 2325 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
| 2340 root->addChild(renderSurface1); | 2326 root->addChild(renderSurface1); |
| 2341 renderSurface1->addChild(child1); | 2327 renderSurface1->addChild(child1); |
| 2342 | 2328 |
| 2343 WebTransformationMatrix identityMatrix; | 2329 gfx::Transform identityMatrix; |
| 2344 WebTransformationMatrix childRotation; | 2330 gfx::Transform childRotation; |
| 2345 childRotation.rotate(45); | 2331 childRotation.Rotate(45); |
| 2346 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(50, 50), false); | 2332 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(50, 50), false); |
| 2347 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(3, 4), false); | 2333 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(3, 4), false); |
| 2348 setLayerPropertiesForTesting(child1.get(), childRotation, identityMatrix, gf
x::PointF(0.5, 0.5), gfx::PointF(25, 25), gfx::Size(50, 50), false); | 2334 setLayerPropertiesForTesting(child1.get(), childRotation, identityMatrix, gf
x::PointF(0.5, 0.5), gfx::PointF(25, 25), gfx::Size(50, 50), false); |
| 2349 | 2335 |
| 2350 root->setMasksToBounds(true); | 2336 root->setMasksToBounds(true); |
| 2351 renderSurface1->setForceRenderSurface(true); | 2337 renderSurface1->setForceRenderSurface(true); |
| 2352 executeCalculateDrawTransformsAndVisibility(root.get()); | 2338 executeCalculateDrawTransformsAndVisibility(root.get()); |
| 2353 | 2339 |
| 2354 ASSERT_TRUE(renderSurface1->renderSurface()); | 2340 ASSERT_TRUE(renderSurface1->renderSurface()); |
| 2355 | 2341 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2377 scoped_refptr<ContentLayer> renderSurface2 = createDrawableContentLayer(&cli
ent); | 2363 scoped_refptr<ContentLayer> renderSurface2 = createDrawableContentLayer(&cli
ent); |
| 2378 scoped_refptr<ContentLayer> child1 = createDrawableContentLayer(&client); | 2364 scoped_refptr<ContentLayer> child1 = createDrawableContentLayer(&client); |
| 2379 scoped_refptr<ContentLayer> child2 = createDrawableContentLayer(&client); | 2365 scoped_refptr<ContentLayer> child2 = createDrawableContentLayer(&client); |
| 2380 scoped_refptr<ContentLayer> child3 = createDrawableContentLayer(&client); | 2366 scoped_refptr<ContentLayer> child3 = createDrawableContentLayer(&client); |
| 2381 root->addChild(renderSurface1); | 2367 root->addChild(renderSurface1); |
| 2382 renderSurface1->addChild(renderSurface2); | 2368 renderSurface1->addChild(renderSurface2); |
| 2383 renderSurface2->addChild(child1); | 2369 renderSurface2->addChild(child1); |
| 2384 renderSurface2->addChild(child2); | 2370 renderSurface2->addChild(child2); |
| 2385 renderSurface2->addChild(child3); | 2371 renderSurface2->addChild(child3); |
| 2386 | 2372 |
| 2387 WebTransformationMatrix identityMatrix; | 2373 gfx::Transform identityMatrix; |
| 2388 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2374 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 2389 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(3, 4), false); | 2375 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(3, 4), false); |
| 2390 setLayerPropertiesForTesting(renderSurface2.get(), identityMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(7, 13), false); | 2376 setLayerPropertiesForTesting(renderSurface2.get(), identityMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(7, 13), false); |
| 2391 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(50, 50), false); | 2377 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(50, 50), false); |
| 2392 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(75, 75), gfx::Size(50, 50), false); | 2378 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(75, 75), gfx::Size(50, 50), false); |
| 2393 setLayerPropertiesForTesting(child3.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(125, 125), gfx::Size(50, 50), false); | 2379 setLayerPropertiesForTesting(child3.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(125, 125), gfx::Size(50, 50), false); |
| 2394 | 2380 |
| 2395 const double deviceScaleFactor = 2; | 2381 const double deviceScaleFactor = 2; |
| 2396 root->setContentsScale(deviceScaleFactor); | 2382 root->setContentsScale(deviceScaleFactor); |
| 2397 renderSurface1->setContentsScale(deviceScaleFactor); | 2383 renderSurface1->setContentsScale(deviceScaleFactor); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2432 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), child2->visibleContentRect()); | 2418 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), child2->visibleContentRect()); |
| 2433 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), child3->visibleContentRect()); | 2419 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), child3->visibleContentRect()); |
| 2434 } | 2420 } |
| 2435 | 2421 |
| 2436 TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithoutPreserves3d) | 2422 TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithoutPreserves3d) |
| 2437 { | 2423 { |
| 2438 // Verify the behavior of back-face culling when there are no preserve-3d la
yers. Note | 2424 // Verify the behavior of back-face culling when there are no preserve-3d la
yers. Note |
| 2439 // that 3d transforms still apply in this case, but they are "flattened" to
each | 2425 // that 3d transforms still apply in this case, but they are "flattened" to
each |
| 2440 // parent layer according to current W3C spec. | 2426 // parent layer according to current W3C spec. |
| 2441 | 2427 |
| 2442 const WebTransformationMatrix identityMatrix; | 2428 const gfx::Transform identityMatrix; |
| 2443 scoped_refptr<Layer> parent = Layer::create(); | 2429 scoped_refptr<Layer> parent = Layer::create(); |
| 2444 scoped_refptr<LayerWithForcedDrawsContent> frontFacingChild = make_scoped_re
fptr(new LayerWithForcedDrawsContent()); | 2430 scoped_refptr<LayerWithForcedDrawsContent> frontFacingChild = make_scoped_re
fptr(new LayerWithForcedDrawsContent()); |
| 2445 scoped_refptr<LayerWithForcedDrawsContent> backFacingChild = make_scoped_ref
ptr(new LayerWithForcedDrawsContent()); | 2431 scoped_refptr<LayerWithForcedDrawsContent> backFacingChild = make_scoped_ref
ptr(new LayerWithForcedDrawsContent()); |
| 2446 scoped_refptr<LayerWithForcedDrawsContent> frontFacingSurface = make_scoped_
refptr(new LayerWithForcedDrawsContent()); | 2432 scoped_refptr<LayerWithForcedDrawsContent> frontFacingSurface = make_scoped_
refptr(new LayerWithForcedDrawsContent()); |
| 2447 scoped_refptr<LayerWithForcedDrawsContent> backFacingSurface = make_scoped_r
efptr(new LayerWithForcedDrawsContent()); | 2433 scoped_refptr<LayerWithForcedDrawsContent> backFacingSurface = make_scoped_r
efptr(new LayerWithForcedDrawsContent()); |
| 2448 scoped_refptr<LayerWithForcedDrawsContent> frontFacingChildOfFrontFacingSurf
ace = make_scoped_refptr(new LayerWithForcedDrawsContent()); | 2434 scoped_refptr<LayerWithForcedDrawsContent> frontFacingChildOfFrontFacingSurf
ace = make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 2449 scoped_refptr<LayerWithForcedDrawsContent> backFacingChildOfFrontFacingSurfa
ce = make_scoped_refptr(new LayerWithForcedDrawsContent()); | 2435 scoped_refptr<LayerWithForcedDrawsContent> backFacingChildOfFrontFacingSurfa
ce = make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 2450 scoped_refptr<LayerWithForcedDrawsContent> frontFacingChildOfBackFacingSurfa
ce = make_scoped_refptr(new LayerWithForcedDrawsContent()); | 2436 scoped_refptr<LayerWithForcedDrawsContent> frontFacingChildOfBackFacingSurfa
ce = make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 2451 scoped_refptr<LayerWithForcedDrawsContent> backFacingChildOfBackFacingSurfac
e = make_scoped_refptr(new LayerWithForcedDrawsContent()); | 2437 scoped_refptr<LayerWithForcedDrawsContent> backFacingChildOfBackFacingSurfac
e = make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 2452 | 2438 |
| 2453 parent->addChild(frontFacingChild); | 2439 parent->addChild(frontFacingChild); |
| 2454 parent->addChild(backFacingChild); | 2440 parent->addChild(backFacingChild); |
| 2455 parent->addChild(frontFacingSurface); | 2441 parent->addChild(frontFacingSurface); |
| 2456 parent->addChild(backFacingSurface); | 2442 parent->addChild(backFacingSurface); |
| 2457 frontFacingSurface->addChild(frontFacingChildOfFrontFacingSurface); | 2443 frontFacingSurface->addChild(frontFacingChildOfFrontFacingSurface); |
| 2458 frontFacingSurface->addChild(backFacingChildOfFrontFacingSurface); | 2444 frontFacingSurface->addChild(backFacingChildOfFrontFacingSurface); |
| 2459 backFacingSurface->addChild(frontFacingChildOfBackFacingSurface); | 2445 backFacingSurface->addChild(frontFacingChildOfBackFacingSurface); |
| 2460 backFacingSurface->addChild(backFacingChildOfBackFacingSurface); | 2446 backFacingSurface->addChild(backFacingChildOfBackFacingSurface); |
| 2461 | 2447 |
| 2462 // Nothing is double-sided | 2448 // Nothing is double-sided |
| 2463 frontFacingChild->setDoubleSided(false); | 2449 frontFacingChild->setDoubleSided(false); |
| 2464 backFacingChild->setDoubleSided(false); | 2450 backFacingChild->setDoubleSided(false); |
| 2465 frontFacingSurface->setDoubleSided(false); | 2451 frontFacingSurface->setDoubleSided(false); |
| 2466 backFacingSurface->setDoubleSided(false); | 2452 backFacingSurface->setDoubleSided(false); |
| 2467 frontFacingChildOfFrontFacingSurface->setDoubleSided(false); | 2453 frontFacingChildOfFrontFacingSurface->setDoubleSided(false); |
| 2468 backFacingChildOfFrontFacingSurface->setDoubleSided(false); | 2454 backFacingChildOfFrontFacingSurface->setDoubleSided(false); |
| 2469 frontFacingChildOfBackFacingSurface->setDoubleSided(false); | 2455 frontFacingChildOfBackFacingSurface->setDoubleSided(false); |
| 2470 backFacingChildOfBackFacingSurface->setDoubleSided(false); | 2456 backFacingChildOfBackFacingSurface->setDoubleSided(false); |
| 2471 | 2457 |
| 2472 WebTransformationMatrix backfaceMatrix; | 2458 gfx::Transform backfaceMatrix; |
| 2473 backfaceMatrix.translate(50, 50); | 2459 backfaceMatrix.Translate(50, 50); |
| 2474 backfaceMatrix.rotate3d(0, 1, 0, 180); | 2460 MathUtil::rotateAxisAngle(&backfaceMatrix, 0, 1, 0, 180); |
| 2475 backfaceMatrix.translate(-50, -50); | 2461 backfaceMatrix.Translate(-50, -50); |
| 2476 | 2462 |
| 2477 // Having a descendant and opacity will force these to have render surfaces. | 2463 // Having a descendant and opacity will force these to have render surfaces. |
| 2478 frontFacingSurface->setOpacity(0.5); | 2464 frontFacingSurface->setOpacity(0.5); |
| 2479 backFacingSurface->setOpacity(0.5); | 2465 backFacingSurface->setOpacity(0.5); |
| 2480 | 2466 |
| 2481 // Nothing preserves 3d. According to current W3C CSS Transforms spec, these
layers | 2467 // Nothing preserves 3d. According to current W3C CSS gfx::Transforms spec,
these layers |
| 2482 // should blindly use their own local transforms to determine back-face cull
ing. | 2468 // should blindly use their own local transforms to determine back-face cull
ing. |
| 2483 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2469 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 2484 setLayerPropertiesForTesting(frontFacingChild.get(), identityMatrix, identit
yMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2470 setLayerPropertiesForTesting(frontFacingChild.get(), identityMatrix, identit
yMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 2485 setLayerPropertiesForTesting(backFacingChild.get(), backfaceMatrix, identity
Matrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2471 setLayerPropertiesForTesting(backFacingChild.get(), backfaceMatrix, identity
Matrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 2486 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident
ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2472 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident
ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 2487 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, identi
tyMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2473 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, identi
tyMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 2488 setLayerPropertiesForTesting(frontFacingChildOfFrontFacingSurface.get(), ide
ntityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100
, 100), false); | 2474 setLayerPropertiesForTesting(frontFacingChildOfFrontFacingSurface.get(), ide
ntityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100
, 100), false); |
| 2489 setLayerPropertiesForTesting(backFacingChildOfFrontFacingSurface.get(), back
faceMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100,
100), false); | 2475 setLayerPropertiesForTesting(backFacingChildOfFrontFacingSurface.get(), back
faceMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100,
100), false); |
| 2490 setLayerPropertiesForTesting(frontFacingChildOfBackFacingSurface.get(), iden
tityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100,
100), false); | 2476 setLayerPropertiesForTesting(frontFacingChildOfBackFacingSurface.get(), iden
tityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100,
100), false); |
| 2491 setLayerPropertiesForTesting(backFacingChildOfBackFacingSurface.get(), backf
aceMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100,
100), false); | 2477 setLayerPropertiesForTesting(backFacingChildOfBackFacingSurface.get(), backf
aceMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100,
100), false); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2524 | 2510 |
| 2525 // Verify backFacingSurface's layerList; its own layer should be culled from
the surface list. | 2511 // Verify backFacingSurface's layerList; its own layer should be culled from
the surface list. |
| 2526 ASSERT_EQ(1u, renderSurfaceLayerList[2]->renderSurface()->layerList().size()
); | 2512 ASSERT_EQ(1u, renderSurfaceLayerList[2]->renderSurface()->layerList().size()
); |
| 2527 EXPECT_EQ(frontFacingChildOfBackFacingSurface->id(), renderSurfaceLayerList[
2]->renderSurface()->layerList()[0]->id()); | 2513 EXPECT_EQ(frontFacingChildOfBackFacingSurface->id(), renderSurfaceLayerList[
2]->renderSurface()->layerList()[0]->id()); |
| 2528 } | 2514 } |
| 2529 | 2515 |
| 2530 TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithPreserves3d) | 2516 TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithPreserves3d) |
| 2531 { | 2517 { |
| 2532 // Verify the behavior of back-face culling when preserves-3d transform styl
e is used. | 2518 // Verify the behavior of back-face culling when preserves-3d transform styl
e is used. |
| 2533 | 2519 |
| 2534 const WebTransformationMatrix identityMatrix; | 2520 const gfx::Transform identityMatrix; |
| 2535 scoped_refptr<Layer> parent = Layer::create(); | 2521 scoped_refptr<Layer> parent = Layer::create(); |
| 2536 scoped_refptr<LayerWithForcedDrawsContent> frontFacingChild = make_scoped_re
fptr(new LayerWithForcedDrawsContent()); | 2522 scoped_refptr<LayerWithForcedDrawsContent> frontFacingChild = make_scoped_re
fptr(new LayerWithForcedDrawsContent()); |
| 2537 scoped_refptr<LayerWithForcedDrawsContent> backFacingChild = make_scoped_ref
ptr(new LayerWithForcedDrawsContent()); | 2523 scoped_refptr<LayerWithForcedDrawsContent> backFacingChild = make_scoped_ref
ptr(new LayerWithForcedDrawsContent()); |
| 2538 scoped_refptr<LayerWithForcedDrawsContent> frontFacingSurface = make_scoped_
refptr(new LayerWithForcedDrawsContent()); | 2524 scoped_refptr<LayerWithForcedDrawsContent> frontFacingSurface = make_scoped_
refptr(new LayerWithForcedDrawsContent()); |
| 2539 scoped_refptr<LayerWithForcedDrawsContent> backFacingSurface = make_scoped_r
efptr(new LayerWithForcedDrawsContent()); | 2525 scoped_refptr<LayerWithForcedDrawsContent> backFacingSurface = make_scoped_r
efptr(new LayerWithForcedDrawsContent()); |
| 2540 scoped_refptr<LayerWithForcedDrawsContent> frontFacingChildOfFrontFacingSurf
ace = make_scoped_refptr(new LayerWithForcedDrawsContent()); | 2526 scoped_refptr<LayerWithForcedDrawsContent> frontFacingChildOfFrontFacingSurf
ace = make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 2541 scoped_refptr<LayerWithForcedDrawsContent> backFacingChildOfFrontFacingSurfa
ce = make_scoped_refptr(new LayerWithForcedDrawsContent()); | 2527 scoped_refptr<LayerWithForcedDrawsContent> backFacingChildOfFrontFacingSurfa
ce = make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 2542 scoped_refptr<LayerWithForcedDrawsContent> frontFacingChildOfBackFacingSurfa
ce = make_scoped_refptr(new LayerWithForcedDrawsContent()); | 2528 scoped_refptr<LayerWithForcedDrawsContent> frontFacingChildOfBackFacingSurfa
ce = make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 2543 scoped_refptr<LayerWithForcedDrawsContent> backFacingChildOfBackFacingSurfac
e = make_scoped_refptr(new LayerWithForcedDrawsContent()); | 2529 scoped_refptr<LayerWithForcedDrawsContent> backFacingChildOfBackFacingSurfac
e = make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 2544 scoped_refptr<LayerWithForcedDrawsContent> dummyReplicaLayer1 = make_scoped_
refptr(new LayerWithForcedDrawsContent()); | 2530 scoped_refptr<LayerWithForcedDrawsContent> dummyReplicaLayer1 = make_scoped_
refptr(new LayerWithForcedDrawsContent()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2556 // Nothing is double-sided | 2542 // Nothing is double-sided |
| 2557 frontFacingChild->setDoubleSided(false); | 2543 frontFacingChild->setDoubleSided(false); |
| 2558 backFacingChild->setDoubleSided(false); | 2544 backFacingChild->setDoubleSided(false); |
| 2559 frontFacingSurface->setDoubleSided(false); | 2545 frontFacingSurface->setDoubleSided(false); |
| 2560 backFacingSurface->setDoubleSided(false); | 2546 backFacingSurface->setDoubleSided(false); |
| 2561 frontFacingChildOfFrontFacingSurface->setDoubleSided(false); | 2547 frontFacingChildOfFrontFacingSurface->setDoubleSided(false); |
| 2562 backFacingChildOfFrontFacingSurface->setDoubleSided(false); | 2548 backFacingChildOfFrontFacingSurface->setDoubleSided(false); |
| 2563 frontFacingChildOfBackFacingSurface->setDoubleSided(false); | 2549 frontFacingChildOfBackFacingSurface->setDoubleSided(false); |
| 2564 backFacingChildOfBackFacingSurface->setDoubleSided(false); | 2550 backFacingChildOfBackFacingSurface->setDoubleSided(false); |
| 2565 | 2551 |
| 2566 WebTransformationMatrix backfaceMatrix; | 2552 gfx::Transform backfaceMatrix; |
| 2567 backfaceMatrix.translate(50, 50); | 2553 backfaceMatrix.Translate(50, 50); |
| 2568 backfaceMatrix.rotate3d(0, 1, 0, 180); | 2554 MathUtil::rotateAxisAngle(&backfaceMatrix, 0, 1, 0, 180); |
| 2569 backfaceMatrix.translate(-50, -50); | 2555 backfaceMatrix.Translate(-50, -50); |
| 2570 | 2556 |
| 2571 // Opacity will not force creation of renderSurfaces in this case because of
the | 2557 // Opacity will not force creation of renderSurfaces in this case because of
the |
| 2572 // preserve-3d transform style. Instead, an example of when a surface would
be | 2558 // preserve-3d transform style. Instead, an example of when a surface would
be |
| 2573 // created with preserve-3d is when there is a replica layer. | 2559 // created with preserve-3d is when there is a replica layer. |
| 2574 frontFacingSurface->setReplicaLayer(dummyReplicaLayer1.get()); | 2560 frontFacingSurface->setReplicaLayer(dummyReplicaLayer1.get()); |
| 2575 backFacingSurface->setReplicaLayer(dummyReplicaLayer2.get()); | 2561 backFacingSurface->setReplicaLayer(dummyReplicaLayer2.get()); |
| 2576 | 2562 |
| 2577 // Each surface creates its own new 3d rendering context (as defined by W3C
spec). | 2563 // Each surface creates its own new 3d rendering context (as defined by W3C
spec). |
| 2578 // According to current W3C CSS Transforms spec, layers in a 3d rendering co
ntext | 2564 // According to current W3C CSS gfx::Transforms spec, layers in a 3d renderi
ng context |
| 2579 // should use the transform with respect to that context. This 3d rendering
context | 2565 // should use the transform with respect to that context. This 3d rendering
context |
| 2580 // occurs when (a) parent's transform style is flat and (b) the layer's tran
sform | 2566 // occurs when (a) parent's transform style is flat and (b) the layer's tran
sform |
| 2581 // style is preserve-3d. | 2567 // style is preserve-3d. |
| 2582 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); // parent tran
sform style is flat. | 2568 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); // parent tran
sform style is flat. |
| 2583 setLayerPropertiesForTesting(frontFacingChild.get(), identityMatrix, identit
yMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2569 setLayerPropertiesForTesting(frontFacingChild.get(), identityMatrix, identit
yMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 2584 setLayerPropertiesForTesting(backFacingChild.get(), backfaceMatrix, identity
Matrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2570 setLayerPropertiesForTesting(backFacingChild.get(), backfaceMatrix, identity
Matrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 2585 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident
ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); //
surface transform style is preserve-3d. | 2571 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident
ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); //
surface transform style is preserve-3d. |
| 2586 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, identi
tyMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); // s
urface transform style is preserve-3d. | 2572 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, identi
tyMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); // s
urface transform style is preserve-3d. |
| 2587 setLayerPropertiesForTesting(frontFacingChildOfFrontFacingSurface.get(), ide
ntityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100
, 100), false); | 2573 setLayerPropertiesForTesting(frontFacingChildOfFrontFacingSurface.get(), ide
ntityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100
, 100), false); |
| 2588 setLayerPropertiesForTesting(backFacingChildOfFrontFacingSurface.get(), back
faceMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100,
100), false); | 2574 setLayerPropertiesForTesting(backFacingChildOfFrontFacingSurface.get(), back
faceMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100,
100), false); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2621 | 2607 |
| 2622 TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithAnimatingTransforms) | 2608 TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithAnimatingTransforms) |
| 2623 { | 2609 { |
| 2624 // Verify that layers are appropriately culled when their back face is showi
ng and | 2610 // Verify that layers are appropriately culled when their back face is showi
ng and |
| 2625 // they are not double sided, while animations are going on. | 2611 // they are not double sided, while animations are going on. |
| 2626 // | 2612 // |
| 2627 // Layers that are animating do not get culled on the main thread, as their
transforms should be | 2613 // Layers that are animating do not get culled on the main thread, as their
transforms should be |
| 2628 // treated as "unknown" so we can not be sure that their back face is really
showing. | 2614 // treated as "unknown" so we can not be sure that their back face is really
showing. |
| 2629 // | 2615 // |
| 2630 | 2616 |
| 2631 const WebTransformationMatrix identityMatrix; | 2617 const gfx::Transform identityMatrix; |
| 2632 scoped_refptr<Layer> parent = Layer::create(); | 2618 scoped_refptr<Layer> parent = Layer::create(); |
| 2633 scoped_refptr<LayerWithForcedDrawsContent> child = make_scoped_refptr(new La
yerWithForcedDrawsContent()); | 2619 scoped_refptr<LayerWithForcedDrawsContent> child = make_scoped_refptr(new La
yerWithForcedDrawsContent()); |
| 2634 scoped_refptr<LayerWithForcedDrawsContent> animatingSurface = make_scoped_re
fptr(new LayerWithForcedDrawsContent()); | 2620 scoped_refptr<LayerWithForcedDrawsContent> animatingSurface = make_scoped_re
fptr(new LayerWithForcedDrawsContent()); |
| 2635 scoped_refptr<LayerWithForcedDrawsContent> childOfAnimatingSurface = make_sc
oped_refptr(new LayerWithForcedDrawsContent()); | 2621 scoped_refptr<LayerWithForcedDrawsContent> childOfAnimatingSurface = make_sc
oped_refptr(new LayerWithForcedDrawsContent()); |
| 2636 scoped_refptr<LayerWithForcedDrawsContent> animatingChild = make_scoped_refp
tr(new LayerWithForcedDrawsContent()); | 2622 scoped_refptr<LayerWithForcedDrawsContent> animatingChild = make_scoped_refp
tr(new LayerWithForcedDrawsContent()); |
| 2637 scoped_refptr<LayerWithForcedDrawsContent> child2 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); | 2623 scoped_refptr<LayerWithForcedDrawsContent> child2 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
| 2638 | 2624 |
| 2639 parent->addChild(child); | 2625 parent->addChild(child); |
| 2640 parent->addChild(animatingSurface); | 2626 parent->addChild(animatingSurface); |
| 2641 animatingSurface->addChild(childOfAnimatingSurface); | 2627 animatingSurface->addChild(childOfAnimatingSurface); |
| 2642 parent->addChild(animatingChild); | 2628 parent->addChild(animatingChild); |
| 2643 parent->addChild(child2); | 2629 parent->addChild(child2); |
| 2644 | 2630 |
| 2645 // Nothing is double-sided | 2631 // Nothing is double-sided |
| 2646 child->setDoubleSided(false); | 2632 child->setDoubleSided(false); |
| 2647 child2->setDoubleSided(false); | 2633 child2->setDoubleSided(false); |
| 2648 animatingSurface->setDoubleSided(false); | 2634 animatingSurface->setDoubleSided(false); |
| 2649 childOfAnimatingSurface->setDoubleSided(false); | 2635 childOfAnimatingSurface->setDoubleSided(false); |
| 2650 animatingChild->setDoubleSided(false); | 2636 animatingChild->setDoubleSided(false); |
| 2651 | 2637 |
| 2652 WebTransformationMatrix backfaceMatrix; | 2638 gfx::Transform backfaceMatrix; |
| 2653 backfaceMatrix.translate(50, 50); | 2639 backfaceMatrix.Translate(50, 50); |
| 2654 backfaceMatrix.rotate3d(0, 1, 0, 180); | 2640 MathUtil::rotateAxisAngle(&backfaceMatrix, 0, 1, 0, 180); |
| 2655 backfaceMatrix.translate(-50, -50); | 2641 backfaceMatrix.Translate(-50, -50); |
| 2656 | 2642 |
| 2657 // Make our render surface. | 2643 // Make our render surface. |
| 2658 animatingSurface->setForceRenderSurface(true); | 2644 animatingSurface->setForceRenderSurface(true); |
| 2659 | 2645 |
| 2660 // Animate the transform on the render surface. | 2646 // Animate the transform on the render surface. |
| 2661 addAnimatedTransformToController(*animatingSurface->layerAnimationController
(), 10, 30, 0); | 2647 addAnimatedTransformToController(*animatingSurface->layerAnimationController
(), 10, 30, 0); |
| 2662 // This is just an animating layer, not a surface. | 2648 // This is just an animating layer, not a surface. |
| 2663 addAnimatedTransformToController(*animatingChild->layerAnimationController()
, 10, 30, 0); | 2649 addAnimatedTransformToController(*animatingChild->layerAnimationController()
, 10, 30, 0); |
| 2664 | 2650 |
| 2665 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2651 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2701 EXPECT_EQ(animatingSurface->visibleContentRect(), gfx::Rect(gfx::Point(), an
imatingSurface->contentBounds())); | 2687 EXPECT_EQ(animatingSurface->visibleContentRect(), gfx::Rect(gfx::Point(), an
imatingSurface->contentBounds())); |
| 2702 // And layers in the subtree of the animating layer should have valid visibl
eContentRects also. | 2688 // And layers in the subtree of the animating layer should have valid visibl
eContentRects also. |
| 2703 EXPECT_EQ(childOfAnimatingSurface->visibleContentRect(), gfx::Rect(gfx::Poin
t(), childOfAnimatingSurface->contentBounds())); | 2689 EXPECT_EQ(childOfAnimatingSurface->visibleContentRect(), gfx::Rect(gfx::Poin
t(), childOfAnimatingSurface->contentBounds())); |
| 2704 } | 2690 } |
| 2705 | 2691 |
| 2706 TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithPreserves3dForFlatteningS
urface) | 2692 TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithPreserves3dForFlatteningS
urface) |
| 2707 { | 2693 { |
| 2708 // Verify the behavior of back-face culling for a renderSurface that is crea
ted | 2694 // Verify the behavior of back-face culling for a renderSurface that is crea
ted |
| 2709 // when it flattens its subtree, and its parent has preserves-3d. | 2695 // when it flattens its subtree, and its parent has preserves-3d. |
| 2710 | 2696 |
| 2711 const WebTransformationMatrix identityMatrix; | 2697 const gfx::Transform identityMatrix; |
| 2712 scoped_refptr<Layer> parent = Layer::create(); | 2698 scoped_refptr<Layer> parent = Layer::create(); |
| 2713 scoped_refptr<LayerWithForcedDrawsContent> frontFacingSurface = make_scoped_
refptr(new LayerWithForcedDrawsContent()); | 2699 scoped_refptr<LayerWithForcedDrawsContent> frontFacingSurface = make_scoped_
refptr(new LayerWithForcedDrawsContent()); |
| 2714 scoped_refptr<LayerWithForcedDrawsContent> backFacingSurface = make_scoped_r
efptr(new LayerWithForcedDrawsContent()); | 2700 scoped_refptr<LayerWithForcedDrawsContent> backFacingSurface = make_scoped_r
efptr(new LayerWithForcedDrawsContent()); |
| 2715 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); | 2701 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
| 2716 scoped_refptr<LayerWithForcedDrawsContent> child2 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); | 2702 scoped_refptr<LayerWithForcedDrawsContent> child2 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
| 2717 | 2703 |
| 2718 parent->addChild(frontFacingSurface); | 2704 parent->addChild(frontFacingSurface); |
| 2719 parent->addChild(backFacingSurface); | 2705 parent->addChild(backFacingSurface); |
| 2720 frontFacingSurface->addChild(child1); | 2706 frontFacingSurface->addChild(child1); |
| 2721 backFacingSurface->addChild(child2); | 2707 backFacingSurface->addChild(child2); |
| 2722 | 2708 |
| 2723 // RenderSurfaces are not double-sided | 2709 // RenderSurfaces are not double-sided |
| 2724 frontFacingSurface->setDoubleSided(false); | 2710 frontFacingSurface->setDoubleSided(false); |
| 2725 backFacingSurface->setDoubleSided(false); | 2711 backFacingSurface->setDoubleSided(false); |
| 2726 | 2712 |
| 2727 WebTransformationMatrix backfaceMatrix; | 2713 gfx::Transform backfaceMatrix; |
| 2728 backfaceMatrix.translate(50, 50); | 2714 backfaceMatrix.Translate(50, 50); |
| 2729 backfaceMatrix.rotate3d(0, 1, 0, 180); | 2715 MathUtil::rotateAxisAngle(&backfaceMatrix, 0, 1, 0, 180); |
| 2730 backfaceMatrix.translate(-50, -50); | 2716 backfaceMatrix.Translate(-50, -50); |
| 2731 | 2717 |
| 2732 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); // parent trans
form style is preserve3d. | 2718 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); // parent trans
form style is preserve3d. |
| 2733 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident
ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); //
surface transform style is flat. | 2719 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident
ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); //
surface transform style is flat. |
| 2734 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, ident
ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); //
surface transform style is flat. | 2720 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, ident
ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); //
surface transform style is flat. |
| 2735 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2721 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 2736 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2722 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 2737 | 2723 |
| 2738 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 2724 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
| 2739 int dummyMaxTextureSize = 512; | 2725 int dummyMaxTextureSize = 512; |
| 2740 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, renderSurfaceLayerList); | 2726 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, renderSurfaceLayerList); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 2771 | 2757 |
| 2772 testPoint = gfx::Point(10, 20); | 2758 testPoint = gfx::Point(10, 20); |
| 2773 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 2759 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
| 2774 EXPECT_FALSE(resultLayer); | 2760 EXPECT_FALSE(resultLayer); |
| 2775 } | 2761 } |
| 2776 | 2762 |
| 2777 TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleLayer) | 2763 TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleLayer) |
| 2778 { | 2764 { |
| 2779 scoped_ptr<LayerImpl> root = LayerImpl::create(12345); | 2765 scoped_ptr<LayerImpl> root = LayerImpl::create(12345); |
| 2780 | 2766 |
| 2781 WebTransformationMatrix identityMatrix; | 2767 gfx::Transform identityMatrix; |
| 2782 gfx::PointF anchor(0, 0); | 2768 gfx::PointF anchor(0, 0); |
| 2783 gfx::PointF position(0, 0); | 2769 gfx::PointF position(0, 0); |
| 2784 gfx::Size bounds(100, 100); | 2770 gfx::Size bounds(100, 100); |
| 2785 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 2771 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
| 2786 root->setDrawsContent(true); | 2772 root->setDrawsContent(true); |
| 2787 | 2773 |
| 2788 std::vector<LayerImpl*> renderSurfaceLayerList; | 2774 std::vector<LayerImpl*> renderSurfaceLayerList; |
| 2789 int dummyMaxTextureSize = 512; | 2775 int dummyMaxTextureSize = 512; |
| 2790 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1,
1, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 2776 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1,
1, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
| 2791 | 2777 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2811 testPoint = gfx::Point(99, 99); | 2797 testPoint = gfx::Point(99, 99); |
| 2812 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 2798 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
| 2813 ASSERT_TRUE(resultLayer); | 2799 ASSERT_TRUE(resultLayer); |
| 2814 EXPECT_EQ(12345, resultLayer->id()); | 2800 EXPECT_EQ(12345, resultLayer->id()); |
| 2815 } | 2801 } |
| 2816 | 2802 |
| 2817 TEST(LayerTreeHostCommonTest, verifyHitTestingForUninvertibleTransform) | 2803 TEST(LayerTreeHostCommonTest, verifyHitTestingForUninvertibleTransform) |
| 2818 { | 2804 { |
| 2819 scoped_ptr<LayerImpl> root = LayerImpl::create(12345); | 2805 scoped_ptr<LayerImpl> root = LayerImpl::create(12345); |
| 2820 | 2806 |
| 2821 WebTransformationMatrix uninvertibleTransform; | 2807 gfx::Transform uninvertibleTransform; |
| 2822 uninvertibleTransform.setM11(0); | 2808 uninvertibleTransform.matrix().setDouble(0, 0, 0); |
| 2823 uninvertibleTransform.setM22(0); | 2809 uninvertibleTransform.matrix().setDouble(1, 1, 0); |
| 2824 uninvertibleTransform.setM33(0); | 2810 uninvertibleTransform.matrix().setDouble(2, 2, 0); |
| 2825 uninvertibleTransform.setM44(0); | 2811 uninvertibleTransform.matrix().setDouble(3, 3, 0); |
| 2826 ASSERT_FALSE(uninvertibleTransform.isInvertible()); | 2812 ASSERT_FALSE(uninvertibleTransform.IsInvertible()); |
| 2827 | 2813 |
| 2828 WebTransformationMatrix identityMatrix; | 2814 gfx::Transform identityMatrix; |
| 2829 gfx::PointF anchor(0, 0); | 2815 gfx::PointF anchor(0, 0); |
| 2830 gfx::PointF position(0, 0); | 2816 gfx::PointF position(0, 0); |
| 2831 gfx::Size bounds(100, 100); | 2817 gfx::Size bounds(100, 100); |
| 2832 setLayerPropertiesForTesting(root.get(), uninvertibleTransform, identityMatr
ix, anchor, position, bounds, false); | 2818 setLayerPropertiesForTesting(root.get(), uninvertibleTransform, identityMatr
ix, anchor, position, bounds, false); |
| 2833 root->setDrawsContent(true); | 2819 root->setDrawsContent(true); |
| 2834 | 2820 |
| 2835 std::vector<LayerImpl*> renderSurfaceLayerList; | 2821 std::vector<LayerImpl*> renderSurfaceLayerList; |
| 2836 int dummyMaxTextureSize = 512; | 2822 int dummyMaxTextureSize = 512; |
| 2837 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1,
1, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 2823 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1,
1, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
| 2838 | 2824 |
| 2839 // Sanity check the scenario we just created. | 2825 // Sanity check the scenario we just created. |
| 2840 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 2826 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
| 2841 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); | 2827 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); |
| 2842 ASSERT_FALSE(root->screenSpaceTransform().isInvertible()); | 2828 ASSERT_FALSE(root->screenSpaceTransform().IsInvertible()); |
| 2843 | 2829 |
| 2844 // Hit testing any point should not hit the layer. If the invertible matrix
is | 2830 // Hit testing any point should not hit the layer. If the invertible matrix
is |
| 2845 // accidentally ignored and treated like an identity, then the hit testing w
ill | 2831 // accidentally ignored and treated like an identity, then the hit testing w
ill |
| 2846 // incorrectly hit the layer when it shouldn't. | 2832 // incorrectly hit the layer when it shouldn't. |
| 2847 gfx::Point testPoint(1, 1); | 2833 gfx::Point testPoint(1, 1); |
| 2848 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); | 2834 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); |
| 2849 EXPECT_FALSE(resultLayer); | 2835 EXPECT_FALSE(resultLayer); |
| 2850 | 2836 |
| 2851 testPoint = gfx::Point(10, 10); | 2837 testPoint = gfx::Point(10, 10); |
| 2852 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 2838 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2870 | 2856 |
| 2871 testPoint = gfx::Point(-1, -1); | 2857 testPoint = gfx::Point(-1, -1); |
| 2872 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 2858 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
| 2873 EXPECT_FALSE(resultLayer); | 2859 EXPECT_FALSE(resultLayer); |
| 2874 } | 2860 } |
| 2875 | 2861 |
| 2876 TEST(LayerTreeHostCommonTest, verifyHitTestingForSinglePositionedLayer) | 2862 TEST(LayerTreeHostCommonTest, verifyHitTestingForSinglePositionedLayer) |
| 2877 { | 2863 { |
| 2878 scoped_ptr<LayerImpl> root = LayerImpl::create(12345); | 2864 scoped_ptr<LayerImpl> root = LayerImpl::create(12345); |
| 2879 | 2865 |
| 2880 WebTransformationMatrix identityMatrix; | 2866 gfx::Transform identityMatrix; |
| 2881 gfx::PointF anchor(0, 0); | 2867 gfx::PointF anchor(0, 0); |
| 2882 gfx::PointF position(50, 50); // this layer is positioned, and hit testing s
hould correctly know where the layer is located. | 2868 gfx::PointF position(50, 50); // this layer is positioned, and hit testing s
hould correctly know where the layer is located. |
| 2883 gfx::Size bounds(100, 100); | 2869 gfx::Size bounds(100, 100); |
| 2884 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 2870 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
| 2885 root->setDrawsContent(true); | 2871 root->setDrawsContent(true); |
| 2886 | 2872 |
| 2887 std::vector<LayerImpl*> renderSurfaceLayerList; | 2873 std::vector<LayerImpl*> renderSurfaceLayerList; |
| 2888 int dummyMaxTextureSize = 512; | 2874 int dummyMaxTextureSize = 512; |
| 2889 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1,
1, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 2875 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1,
1, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
| 2890 | 2876 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2911 testPoint = gfx::Point(99, 99); | 2897 testPoint = gfx::Point(99, 99); |
| 2912 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 2898 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
| 2913 ASSERT_TRUE(resultLayer); | 2899 ASSERT_TRUE(resultLayer); |
| 2914 EXPECT_EQ(12345, resultLayer->id()); | 2900 EXPECT_EQ(12345, resultLayer->id()); |
| 2915 } | 2901 } |
| 2916 | 2902 |
| 2917 TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleRotatedLayer) | 2903 TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleRotatedLayer) |
| 2918 { | 2904 { |
| 2919 scoped_ptr<LayerImpl> root = LayerImpl::create(12345); | 2905 scoped_ptr<LayerImpl> root = LayerImpl::create(12345); |
| 2920 | 2906 |
| 2921 WebTransformationMatrix identityMatrix; | 2907 gfx::Transform identityMatrix; |
| 2922 WebTransformationMatrix rotation45DegreesAboutCenter; | 2908 gfx::Transform rotation45DegreesAboutCenter; |
| 2923 rotation45DegreesAboutCenter.translate(50, 50); | 2909 rotation45DegreesAboutCenter.Translate(50, 50); |
| 2924 rotation45DegreesAboutCenter.rotate3d(0, 0, 45); | 2910 MathUtil::rotateEulerAngles(&rotation45DegreesAboutCenter, 0, 0, 45); |
| 2925 rotation45DegreesAboutCenter.translate(-50, -50); | 2911 rotation45DegreesAboutCenter.Translate(-50, -50); |
| 2926 gfx::PointF anchor(0, 0); | 2912 gfx::PointF anchor(0, 0); |
| 2927 gfx::PointF position(0, 0); | 2913 gfx::PointF position(0, 0); |
| 2928 gfx::Size bounds(100, 100); | 2914 gfx::Size bounds(100, 100); |
| 2929 setLayerPropertiesForTesting(root.get(), rotation45DegreesAboutCenter, ident
ityMatrix, anchor, position, bounds, false); | 2915 setLayerPropertiesForTesting(root.get(), rotation45DegreesAboutCenter, ident
ityMatrix, anchor, position, bounds, false); |
| 2930 root->setDrawsContent(true); | 2916 root->setDrawsContent(true); |
| 2931 | 2917 |
| 2932 std::vector<LayerImpl*> renderSurfaceLayerList; | 2918 std::vector<LayerImpl*> renderSurfaceLayerList; |
| 2933 int dummyMaxTextureSize = 512; | 2919 int dummyMaxTextureSize = 512; |
| 2934 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1,
1, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 2920 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1,
1, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
| 2935 | 2921 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2960 | 2946 |
| 2961 testPoint = gfx::Point(-1, 50); | 2947 testPoint = gfx::Point(-1, 50); |
| 2962 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 2948 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
| 2963 ASSERT_FALSE(resultLayer); | 2949 ASSERT_FALSE(resultLayer); |
| 2964 } | 2950 } |
| 2965 | 2951 |
| 2966 TEST(LayerTreeHostCommonTest, verifyHitTestingForSinglePerspectiveLayer) | 2952 TEST(LayerTreeHostCommonTest, verifyHitTestingForSinglePerspectiveLayer) |
| 2967 { | 2953 { |
| 2968 scoped_ptr<LayerImpl> root = LayerImpl::create(12345); | 2954 scoped_ptr<LayerImpl> root = LayerImpl::create(12345); |
| 2969 | 2955 |
| 2970 WebTransformationMatrix identityMatrix; | 2956 gfx::Transform identityMatrix; |
| 2971 | 2957 |
| 2972 // perspectiveProjectionAboutCenter * translationByZ is designed so that the
100 x 100 layer becomes 50 x 50, and remains centered at (50, 50). | 2958 // perspectiveProjectionAboutCenter * translationByZ is designed so that the
100 x 100 layer becomes 50 x 50, and remains centered at (50, 50). |
| 2973 WebTransformationMatrix perspectiveProjectionAboutCenter; | 2959 gfx::Transform perspectiveProjectionAboutCenter; |
| 2974 perspectiveProjectionAboutCenter.translate(50, 50); | 2960 perspectiveProjectionAboutCenter.Translate(50, 50); |
| 2975 perspectiveProjectionAboutCenter.applyPerspective(1); | 2961 perspectiveProjectionAboutCenter.ApplyPerspectiveDepth(1); |
| 2976 perspectiveProjectionAboutCenter.translate(-50, -50); | 2962 perspectiveProjectionAboutCenter.Translate(-50, -50); |
| 2977 WebTransformationMatrix translationByZ; | 2963 gfx::Transform translationByZ; |
| 2978 translationByZ.translate3d(0, 0, -1); | 2964 translationByZ.Translate3d(0, 0, -1); |
| 2979 | 2965 |
| 2980 gfx::PointF anchor(0, 0); | 2966 gfx::PointF anchor(0, 0); |
| 2981 gfx::PointF position(0, 0); | 2967 gfx::PointF position(0, 0); |
| 2982 gfx::Size bounds(100, 100); | 2968 gfx::Size bounds(100, 100); |
| 2983 setLayerPropertiesForTesting(root.get(), perspectiveProjectionAboutCenter *
translationByZ, identityMatrix, anchor, position, bounds, false); | 2969 setLayerPropertiesForTesting(root.get(), perspectiveProjectionAboutCenter *
translationByZ, identityMatrix, anchor, position, bounds, false); |
| 2984 root->setDrawsContent(true); | 2970 root->setDrawsContent(true); |
| 2985 | 2971 |
| 2986 std::vector<LayerImpl*> renderSurfaceLayerList; | 2972 std::vector<LayerImpl*> renderSurfaceLayerList; |
| 2987 int dummyMaxTextureSize = 512; | 2973 int dummyMaxTextureSize = 512; |
| 2988 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1,
1, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 2974 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1,
1, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3020 // test makes sure that hit testing works correctly accounts for the content
s scale. | 3006 // test makes sure that hit testing works correctly accounts for the content
s scale. |
| 3021 // A contentsScale that is not 1 effectively forces a non-identity transform
between | 3007 // A contentsScale that is not 1 effectively forces a non-identity transform
between |
| 3022 // layer's content space and layer's origin space. The hit testing code must
take this into account. | 3008 // layer's content space and layer's origin space. The hit testing code must
take this into account. |
| 3023 // | 3009 // |
| 3024 // To test this, the layer is positioned at (25, 25), and is size (50, 50).
If | 3010 // To test this, the layer is positioned at (25, 25), and is size (50, 50).
If |
| 3025 // contentsScale is ignored, then hit testing will mis-interpret the visible
ContentRect | 3011 // contentsScale is ignored, then hit testing will mis-interpret the visible
ContentRect |
| 3026 // as being larger than the actual bounds of the layer. | 3012 // as being larger than the actual bounds of the layer. |
| 3027 // | 3013 // |
| 3028 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3014 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
| 3029 | 3015 |
| 3030 WebTransformationMatrix identityMatrix; | 3016 gfx::Transform identityMatrix; |
| 3031 gfx::PointF anchor(0, 0); | 3017 gfx::PointF anchor(0, 0); |
| 3032 | 3018 |
| 3033 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); | 3019 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 3034 | 3020 |
| 3035 { | 3021 { |
| 3036 gfx::PointF position(25, 25); | 3022 gfx::PointF position(25, 25); |
| 3037 gfx::Size bounds(50, 50); | 3023 gfx::Size bounds(50, 50); |
| 3038 scoped_ptr<LayerImpl> testLayer = LayerImpl::create(12345); | 3024 scoped_ptr<LayerImpl> testLayer = LayerImpl::create(12345); |
| 3039 setLayerPropertiesForTesting(testLayer.get(), identityMatrix, identityMa
trix, anchor, position, bounds, false); | 3025 setLayerPropertiesForTesting(testLayer.get(), identityMatrix, identityMa
trix, anchor, position, bounds, false); |
| 3040 | 3026 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3079 testPoint = gfx::Point(74, 74); | 3065 testPoint = gfx::Point(74, 74); |
| 3080 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3066 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
| 3081 ASSERT_TRUE(resultLayer); | 3067 ASSERT_TRUE(resultLayer); |
| 3082 EXPECT_EQ(12345, resultLayer->id()); | 3068 EXPECT_EQ(12345, resultLayer->id()); |
| 3083 } | 3069 } |
| 3084 | 3070 |
| 3085 TEST(LayerTreeHostCommonTest, verifyHitTestingForSimpleClippedLayer) | 3071 TEST(LayerTreeHostCommonTest, verifyHitTestingForSimpleClippedLayer) |
| 3086 { | 3072 { |
| 3087 // Test that hit-testing will only work for the visible portion of a layer,
and not | 3073 // Test that hit-testing will only work for the visible portion of a layer,
and not |
| 3088 // the entire layer bounds. Here we just test the simple axis-aligned case. | 3074 // the entire layer bounds. Here we just test the simple axis-aligned case. |
| 3089 WebTransformationMatrix identityMatrix; | 3075 gfx::Transform identityMatrix; |
| 3090 gfx::PointF anchor(0, 0); | 3076 gfx::PointF anchor(0, 0); |
| 3091 | 3077 |
| 3092 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3078 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
| 3093 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); | 3079 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 3094 | 3080 |
| 3095 { | 3081 { |
| 3096 scoped_ptr<LayerImpl> clippingLayer = LayerImpl::create(123); | 3082 scoped_ptr<LayerImpl> clippingLayer = LayerImpl::create(123); |
| 3097 gfx::PointF position(25, 25); // this layer is positioned, and hit testi
ng should correctly know where the layer is located. | 3083 gfx::PointF position(25, 25); // this layer is positioned, and hit testi
ng should correctly know where the layer is located. |
| 3098 gfx::Size bounds(50, 50); | 3084 gfx::Size bounds(50, 50); |
| 3099 setLayerPropertiesForTesting(clippingLayer.get(), identityMatrix, identi
tyMatrix, anchor, position, bounds, false); | 3085 setLayerPropertiesForTesting(clippingLayer.get(), identityMatrix, identi
tyMatrix, anchor, position, bounds, false); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3147 // algorithm needs to recognize that multiple parent layers may clip the lay
er, and | 3133 // algorithm needs to recognize that multiple parent layers may clip the lay
er, and |
| 3148 // should not actually hit those clipped areas. | 3134 // should not actually hit those clipped areas. |
| 3149 // | 3135 // |
| 3150 // The child and grandChild layers are both initialized to clip the rotatedL
eaf. The | 3136 // The child and grandChild layers are both initialized to clip the rotatedL
eaf. The |
| 3151 // child layer is rotated about the top-left corner, so that the root + chil
d clips | 3137 // child layer is rotated about the top-left corner, so that the root + chil
d clips |
| 3152 // combined create a triangle. The rotatedLeaf will only be visible where it
overlaps | 3138 // combined create a triangle. The rotatedLeaf will only be visible where it
overlaps |
| 3153 // this triangle. | 3139 // this triangle. |
| 3154 // | 3140 // |
| 3155 scoped_ptr<LayerImpl> root = LayerImpl::create(123); | 3141 scoped_ptr<LayerImpl> root = LayerImpl::create(123); |
| 3156 | 3142 |
| 3157 WebTransformationMatrix identityMatrix; | 3143 gfx::Transform identityMatrix; |
| 3158 gfx::PointF anchor(0, 0); | 3144 gfx::PointF anchor(0, 0); |
| 3159 gfx::PointF position(0, 0); | 3145 gfx::PointF position(0, 0); |
| 3160 gfx::Size bounds(100, 100); | 3146 gfx::Size bounds(100, 100); |
| 3161 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 3147 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
| 3162 root->setMasksToBounds(true); | 3148 root->setMasksToBounds(true); |
| 3163 | 3149 |
| 3164 { | 3150 { |
| 3165 scoped_ptr<LayerImpl> child = LayerImpl::create(456); | 3151 scoped_ptr<LayerImpl> child = LayerImpl::create(456); |
| 3166 scoped_ptr<LayerImpl> grandChild = LayerImpl::create(789); | 3152 scoped_ptr<LayerImpl> grandChild = LayerImpl::create(789); |
| 3167 scoped_ptr<LayerImpl> rotatedLeaf = LayerImpl::create(2468); | 3153 scoped_ptr<LayerImpl> rotatedLeaf = LayerImpl::create(2468); |
| 3168 | 3154 |
| 3169 position = gfx::PointF(10, 10); | 3155 position = gfx::PointF(10, 10); |
| 3170 bounds = gfx::Size(80, 80); | 3156 bounds = gfx::Size(80, 80); |
| 3171 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); | 3157 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); |
| 3172 child->setMasksToBounds(true); | 3158 child->setMasksToBounds(true); |
| 3173 | 3159 |
| 3174 WebTransformationMatrix rotation45DegreesAboutCorner; | 3160 gfx::Transform rotation45DegreesAboutCorner; |
| 3175 rotation45DegreesAboutCorner.rotate3d(0, 0, 45); | 3161 MathUtil::rotateEulerAngles(&rotation45DegreesAboutCorner, 0, 0, 45); |
| 3176 | 3162 |
| 3177 position = gfx::PointF(0, 0); // remember, positioned with respect to it
s parent which is already at 10, 10 | 3163 position = gfx::PointF(0, 0); // remember, positioned with respect to it
s parent which is already at 10, 10 |
| 3178 bounds = gfx::Size(200, 200); // to ensure it covers at least sqrt(2) *
100. | 3164 bounds = gfx::Size(200, 200); // to ensure it covers at least sqrt(2) *
100. |
| 3179 setLayerPropertiesForTesting(grandChild.get(), rotation45DegreesAboutCor
ner, identityMatrix, anchor, position, bounds, false); | 3165 setLayerPropertiesForTesting(grandChild.get(), rotation45DegreesAboutCor
ner, identityMatrix, anchor, position, bounds, false); |
| 3180 grandChild->setMasksToBounds(true); | 3166 grandChild->setMasksToBounds(true); |
| 3181 | 3167 |
| 3182 // Rotates about the center of the layer | 3168 // Rotates about the center of the layer |
| 3183 WebTransformationMatrix rotatedLeafTransform; | 3169 gfx::Transform rotatedLeafTransform; |
| 3184 rotatedLeafTransform.translate(-10, -10); // cancel out the grandParent'
s position | 3170 rotatedLeafTransform.Translate(-10, -10); // cancel out the grandParent'
s position |
| 3185 rotatedLeafTransform.rotate3d(0, 0, -45); // cancel out the corner 45-de
gree rotation of the parent. | 3171 MathUtil::rotateEulerAngles(&rotatedLeafTransform, 0, 0, -45); // cancel
out the corner 45-degree rotation of the parent. |
| 3186 rotatedLeafTransform.translate(50, 50); | 3172 rotatedLeafTransform.Translate(50, 50); |
| 3187 rotatedLeafTransform.rotate3d(0, 0, 45); | 3173 MathUtil::rotateEulerAngles(&rotatedLeafTransform, 0, 0, 45); |
| 3188 rotatedLeafTransform.translate(-50, -50); | 3174 rotatedLeafTransform.Translate(-50, -50); |
| 3189 position = gfx::PointF(0, 0); | 3175 position = gfx::PointF(0, 0); |
| 3190 bounds = gfx::Size(100, 100); | 3176 bounds = gfx::Size(100, 100); |
| 3191 setLayerPropertiesForTesting(rotatedLeaf.get(), rotatedLeafTransform, id
entityMatrix, anchor, position, bounds, false); | 3177 setLayerPropertiesForTesting(rotatedLeaf.get(), rotatedLeafTransform, id
entityMatrix, anchor, position, bounds, false); |
| 3192 rotatedLeaf->setDrawsContent(true); | 3178 rotatedLeaf->setDrawsContent(true); |
| 3193 | 3179 |
| 3194 grandChild->addChild(rotatedLeaf.Pass()); | 3180 grandChild->addChild(rotatedLeaf.Pass()); |
| 3195 child->addChild(grandChild.Pass()); | 3181 child->addChild(grandChild.Pass()); |
| 3196 root->addChild(child.Pass()); | 3182 root->addChild(child.Pass()); |
| 3197 } | 3183 } |
| 3198 | 3184 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3243 testPoint = gfx::Point(49, 51); | 3229 testPoint = gfx::Point(49, 51); |
| 3244 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3230 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
| 3245 ASSERT_TRUE(resultLayer); | 3231 ASSERT_TRUE(resultLayer); |
| 3246 EXPECT_EQ(2468, resultLayer->id()); | 3232 EXPECT_EQ(2468, resultLayer->id()); |
| 3247 } | 3233 } |
| 3248 | 3234 |
| 3249 TEST(LayerTreeHostCommonTest, verifyHitTestingForNonClippingIntermediateLayer) | 3235 TEST(LayerTreeHostCommonTest, verifyHitTestingForNonClippingIntermediateLayer) |
| 3250 { | 3236 { |
| 3251 // This test checks that hit testing code does not accidentally clip to laye
r | 3237 // This test checks that hit testing code does not accidentally clip to laye
r |
| 3252 // bounds for a layer that actually does not clip. | 3238 // bounds for a layer that actually does not clip. |
| 3253 WebTransformationMatrix identityMatrix; | 3239 gfx::Transform identityMatrix; |
| 3254 gfx::PointF anchor(0, 0); | 3240 gfx::PointF anchor(0, 0); |
| 3255 | 3241 |
| 3256 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3242 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
| 3257 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); | 3243 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 3258 | 3244 |
| 3259 { | 3245 { |
| 3260 scoped_ptr<LayerImpl> intermediateLayer = LayerImpl::create(123); | 3246 scoped_ptr<LayerImpl> intermediateLayer = LayerImpl::create(123); |
| 3261 gfx::PointF position(10, 10); // this layer is positioned, and hit testi
ng should correctly know where the layer is located. | 3247 gfx::PointF position(10, 10); // this layer is positioned, and hit testi
ng should correctly know where the layer is located. |
| 3262 gfx::Size bounds(50, 50); | 3248 gfx::Size bounds(50, 50); |
| 3263 setLayerPropertiesForTesting(intermediateLayer.get(), identityMatrix, id
entityMatrix, anchor, position, bounds, false); | 3249 setLayerPropertiesForTesting(intermediateLayer.get(), identityMatrix, id
entityMatrix, anchor, position, bounds, false); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3304 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3290 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
| 3305 ASSERT_TRUE(resultLayer); | 3291 ASSERT_TRUE(resultLayer); |
| 3306 EXPECT_EQ(456, resultLayer->id()); | 3292 EXPECT_EQ(456, resultLayer->id()); |
| 3307 } | 3293 } |
| 3308 | 3294 |
| 3309 | 3295 |
| 3310 TEST(LayerTreeHostCommonTest, verifyHitTestingForMultipleLayers) | 3296 TEST(LayerTreeHostCommonTest, verifyHitTestingForMultipleLayers) |
| 3311 { | 3297 { |
| 3312 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3298 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
| 3313 | 3299 |
| 3314 WebTransformationMatrix identityMatrix; | 3300 gfx::Transform identityMatrix; |
| 3315 gfx::PointF anchor(0, 0); | 3301 gfx::PointF anchor(0, 0); |
| 3316 gfx::PointF position(0, 0); | 3302 gfx::PointF position(0, 0); |
| 3317 gfx::Size bounds(100, 100); | 3303 gfx::Size bounds(100, 100); |
| 3318 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 3304 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
| 3319 root->setDrawsContent(true); | 3305 root->setDrawsContent(true); |
| 3320 | 3306 |
| 3321 { | 3307 { |
| 3322 // child 1 and child2 are initialized to overlap between x=50 and x=60. | 3308 // child 1 and child2 are initialized to overlap between x=50 and x=60. |
| 3323 // grandChild is set to overlap both child1 and child2 between y=50 and
y=60. | 3309 // grandChild is set to overlap both child1 and child2 between y=50 and
y=60. |
| 3324 // The expected stacking order is: | 3310 // The expected stacking order is: |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3407 } | 3393 } |
| 3408 | 3394 |
| 3409 TEST(LayerTreeHostCommonTest, verifyHitTestingForMultipleLayerLists) | 3395 TEST(LayerTreeHostCommonTest, verifyHitTestingForMultipleLayerLists) |
| 3410 { | 3396 { |
| 3411 // | 3397 // |
| 3412 // The geometry is set up similarly to the previous case, but | 3398 // The geometry is set up similarly to the previous case, but |
| 3413 // all layers are forced to be renderSurfaces now. | 3399 // all layers are forced to be renderSurfaces now. |
| 3414 // | 3400 // |
| 3415 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3401 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
| 3416 | 3402 |
| 3417 WebTransformationMatrix identityMatrix; | 3403 gfx::Transform identityMatrix; |
| 3418 gfx::PointF anchor(0, 0); | 3404 gfx::PointF anchor(0, 0); |
| 3419 gfx::PointF position(0, 0); | 3405 gfx::PointF position(0, 0); |
| 3420 gfx::Size bounds(100, 100); | 3406 gfx::Size bounds(100, 100); |
| 3421 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 3407 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
| 3422 root->setDrawsContent(true); | 3408 root->setDrawsContent(true); |
| 3423 | 3409 |
| 3424 { | 3410 { |
| 3425 // child 1 and child2 are initialized to overlap between x=50 and x=60. | 3411 // child 1 and child2 are initialized to overlap between x=50 and x=60. |
| 3426 // grandChild is set to overlap both child1 and child2 between y=50 and
y=60. | 3412 // grandChild is set to overlap both child1 and child2 between y=50 and
y=60. |
| 3427 // The expected stacking order is: | 3413 // The expected stacking order is: |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3529 | 3515 |
| 3530 testPoint = gfx::Point(10, 20); | 3516 testPoint = gfx::Point(10, 20); |
| 3531 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 3517 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
| 3532 EXPECT_FALSE(resultLayer); | 3518 EXPECT_FALSE(resultLayer); |
| 3533 } | 3519 } |
| 3534 | 3520 |
| 3535 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSingleLayer
) | 3521 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSingleLayer
) |
| 3536 { | 3522 { |
| 3537 scoped_ptr<LayerImpl> root = LayerImpl::create(12345); | 3523 scoped_ptr<LayerImpl> root = LayerImpl::create(12345); |
| 3538 | 3524 |
| 3539 WebTransformationMatrix identityMatrix; | 3525 gfx::Transform identityMatrix; |
| 3540 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50)); | 3526 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50)); |
| 3541 gfx::PointF anchor(0, 0); | 3527 gfx::PointF anchor(0, 0); |
| 3542 gfx::PointF position(0, 0); | 3528 gfx::PointF position(0, 0); |
| 3543 gfx::Size bounds(100, 100); | 3529 gfx::Size bounds(100, 100); |
| 3544 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 3530 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
| 3545 root->setDrawsContent(true); | 3531 root->setDrawsContent(true); |
| 3546 | 3532 |
| 3547 std::vector<LayerImpl*> renderSurfaceLayerList; | 3533 std::vector<LayerImpl*> renderSurfaceLayerList; |
| 3548 int dummyMaxTextureSize = 512; | 3534 int dummyMaxTextureSize = 512; |
| 3549 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1,
1, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 3535 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1,
1, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3585 testPoint = gfx::Point(59, 59); | 3571 testPoint = gfx::Point(59, 59); |
| 3586 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 3572 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
| 3587 ASSERT_TRUE(resultLayer); | 3573 ASSERT_TRUE(resultLayer); |
| 3588 EXPECT_EQ(12345, resultLayer->id()); | 3574 EXPECT_EQ(12345, resultLayer->id()); |
| 3589 } | 3575 } |
| 3590 | 3576 |
| 3591 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForUninvertibl
eTransform) | 3577 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForUninvertibl
eTransform) |
| 3592 { | 3578 { |
| 3593 scoped_ptr<LayerImpl> root = LayerImpl::create(12345); | 3579 scoped_ptr<LayerImpl> root = LayerImpl::create(12345); |
| 3594 | 3580 |
| 3595 WebTransformationMatrix uninvertibleTransform; | 3581 gfx::Transform uninvertibleTransform; |
| 3596 uninvertibleTransform.setM11(0); | 3582 uninvertibleTransform.matrix().setDouble(0, 0, 0); |
| 3597 uninvertibleTransform.setM22(0); | 3583 uninvertibleTransform.matrix().setDouble(1, 1, 0); |
| 3598 uninvertibleTransform.setM33(0); | 3584 uninvertibleTransform.matrix().setDouble(2, 2, 0); |
| 3599 uninvertibleTransform.setM44(0); | 3585 uninvertibleTransform.matrix().setDouble(3, 3, 0); |
| 3600 ASSERT_FALSE(uninvertibleTransform.isInvertible()); | 3586 ASSERT_FALSE(uninvertibleTransform.IsInvertible()); |
| 3601 | 3587 |
| 3602 WebTransformationMatrix identityMatrix; | 3588 gfx::Transform identityMatrix; |
| 3603 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50)); | 3589 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50)); |
| 3604 gfx::PointF anchor(0, 0); | 3590 gfx::PointF anchor(0, 0); |
| 3605 gfx::PointF position(0, 0); | 3591 gfx::PointF position(0, 0); |
| 3606 gfx::Size bounds(100, 100); | 3592 gfx::Size bounds(100, 100); |
| 3607 setLayerPropertiesForTesting(root.get(), uninvertibleTransform, identityMatr
ix, anchor, position, bounds, false); | 3593 setLayerPropertiesForTesting(root.get(), uninvertibleTransform, identityMatr
ix, anchor, position, bounds, false); |
| 3608 root->setDrawsContent(true); | 3594 root->setDrawsContent(true); |
| 3609 root->setTouchEventHandlerRegion(touchHandlerRegion); | 3595 root->setTouchEventHandlerRegion(touchHandlerRegion); |
| 3610 | 3596 |
| 3611 std::vector<LayerImpl*> renderSurfaceLayerList; | 3597 std::vector<LayerImpl*> renderSurfaceLayerList; |
| 3612 int dummyMaxTextureSize = 512; | 3598 int dummyMaxTextureSize = 512; |
| 3613 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1,
1, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 3599 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1,
1, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
| 3614 | 3600 |
| 3615 // Sanity check the scenario we just created. | 3601 // Sanity check the scenario we just created. |
| 3616 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 3602 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
| 3617 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); | 3603 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); |
| 3618 ASSERT_FALSE(root->screenSpaceTransform().isInvertible()); | 3604 ASSERT_FALSE(root->screenSpaceTransform().IsInvertible()); |
| 3619 | 3605 |
| 3620 // Hit checking any point should not hit the touch handler region on the lay
er. If the invertible matrix is | 3606 // Hit checking any point should not hit the touch handler region on the lay
er. If the invertible matrix is |
| 3621 // accidentally ignored and treated like an identity, then the hit testing w
ill | 3607 // accidentally ignored and treated like an identity, then the hit testing w
ill |
| 3622 // incorrectly hit the layer when it shouldn't. | 3608 // incorrectly hit the layer when it shouldn't. |
| 3623 gfx::Point testPoint(1, 1); | 3609 gfx::Point testPoint(1, 1); |
| 3624 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTou
chHandlerRegion(testPoint, renderSurfaceLayerList); | 3610 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTou
chHandlerRegion(testPoint, renderSurfaceLayerList); |
| 3625 EXPECT_FALSE(resultLayer); | 3611 EXPECT_FALSE(resultLayer); |
| 3626 | 3612 |
| 3627 testPoint = gfx::Point(10, 10); | 3613 testPoint = gfx::Point(10, 10); |
| 3628 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 3614 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3646 | 3632 |
| 3647 testPoint = gfx::Point(-1, -1); | 3633 testPoint = gfx::Point(-1, -1); |
| 3648 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 3634 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
| 3649 EXPECT_FALSE(resultLayer); | 3635 EXPECT_FALSE(resultLayer); |
| 3650 } | 3636 } |
| 3651 | 3637 |
| 3652 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSinglePosit
ionedLayer) | 3638 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSinglePosit
ionedLayer) |
| 3653 { | 3639 { |
| 3654 scoped_ptr<LayerImpl> root = LayerImpl::create(12345); | 3640 scoped_ptr<LayerImpl> root = LayerImpl::create(12345); |
| 3655 | 3641 |
| 3656 WebTransformationMatrix identityMatrix; | 3642 gfx::Transform identityMatrix; |
| 3657 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50)); | 3643 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50)); |
| 3658 gfx::PointF anchor(0, 0); | 3644 gfx::PointF anchor(0, 0); |
| 3659 gfx::PointF position(50, 50); // this layer is positioned, and hit testing s
hould correctly know where the layer is located. | 3645 gfx::PointF position(50, 50); // this layer is positioned, and hit testing s
hould correctly know where the layer is located. |
| 3660 gfx::Size bounds(100, 100); | 3646 gfx::Size bounds(100, 100); |
| 3661 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 3647 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
| 3662 root->setDrawsContent(true); | 3648 root->setDrawsContent(true); |
| 3663 root->setTouchEventHandlerRegion(touchHandlerRegion); | 3649 root->setTouchEventHandlerRegion(touchHandlerRegion); |
| 3664 | 3650 |
| 3665 std::vector<LayerImpl*> renderSurfaceLayerList; | 3651 std::vector<LayerImpl*> renderSurfaceLayerList; |
| 3666 int dummyMaxTextureSize = 512; | 3652 int dummyMaxTextureSize = 512; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3704 // test makes sure that hit testing works correctly accounts for the content
s scale. | 3690 // test makes sure that hit testing works correctly accounts for the content
s scale. |
| 3705 // A contentsScale that is not 1 effectively forces a non-identity transform
between | 3691 // A contentsScale that is not 1 effectively forces a non-identity transform
between |
| 3706 // layer's content space and layer's origin space. The hit testing code must
take this into account. | 3692 // layer's content space and layer's origin space. The hit testing code must
take this into account. |
| 3707 // | 3693 // |
| 3708 // To test this, the layer is positioned at (25, 25), and is size (50, 50).
If | 3694 // To test this, the layer is positioned at (25, 25), and is size (50, 50).
If |
| 3709 // contentsScale is ignored, then hit checking will mis-interpret the visibl
eContentRect | 3695 // contentsScale is ignored, then hit checking will mis-interpret the visibl
eContentRect |
| 3710 // as being larger than the actual bounds of the layer. | 3696 // as being larger than the actual bounds of the layer. |
| 3711 // | 3697 // |
| 3712 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3698 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
| 3713 | 3699 |
| 3714 WebTransformationMatrix identityMatrix; | 3700 gfx::Transform identityMatrix; |
| 3715 gfx::PointF anchor(0, 0); | 3701 gfx::PointF anchor(0, 0); |
| 3716 | 3702 |
| 3717 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); | 3703 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 3718 | 3704 |
| 3719 { | 3705 { |
| 3720 Region touchHandlerRegion(gfx::Rect(10, 10, 30, 30)); | 3706 Region touchHandlerRegion(gfx::Rect(10, 10, 30, 30)); |
| 3721 gfx::PointF position(25, 25); | 3707 gfx::PointF position(25, 25); |
| 3722 gfx::Size bounds(50, 50); | 3708 gfx::Size bounds(50, 50); |
| 3723 scoped_ptr<LayerImpl> testLayer = LayerImpl::create(12345); | 3709 scoped_ptr<LayerImpl> testLayer = LayerImpl::create(12345); |
| 3724 setLayerPropertiesForTesting(testLayer.get(), identityMatrix, identityMa
trix, anchor, position, bounds, false); | 3710 setLayerPropertiesForTesting(testLayer.get(), identityMatrix, identityMa
trix, anchor, position, bounds, false); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3776 ASSERT_TRUE(resultLayer); | 3762 ASSERT_TRUE(resultLayer); |
| 3777 EXPECT_EQ(12345, resultLayer->id()); | 3763 EXPECT_EQ(12345, resultLayer->id()); |
| 3778 } | 3764 } |
| 3779 | 3765 |
| 3780 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSingleLayer
WithDeviceScale) | 3766 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSingleLayer
WithDeviceScale) |
| 3781 { | 3767 { |
| 3782 // The layer's deviceScalefactor and pageScaleFactor should scale the conten
tRect and we should | 3768 // The layer's deviceScalefactor and pageScaleFactor should scale the conten
tRect and we should |
| 3783 // be able to hit the touch handler region by scaling the points accordingly
. | 3769 // be able to hit the touch handler region by scaling the points accordingly
. |
| 3784 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3770 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
| 3785 | 3771 |
| 3786 WebTransformationMatrix identityMatrix; | 3772 gfx::Transform identityMatrix; |
| 3787 gfx::PointF anchor(0, 0); | 3773 gfx::PointF anchor(0, 0); |
| 3788 // Set the bounds of the root layer big enough to fit the child when scaled. | 3774 // Set the bounds of the root layer big enough to fit the child when scaled. |
| 3789 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); | 3775 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 3790 | 3776 |
| 3791 { | 3777 { |
| 3792 Region touchHandlerRegion(gfx::Rect(10, 10, 30, 30)); | 3778 Region touchHandlerRegion(gfx::Rect(10, 10, 30, 30)); |
| 3793 gfx::PointF position(25, 25); | 3779 gfx::PointF position(25, 25); |
| 3794 gfx::Size bounds(50, 50); | 3780 gfx::Size bounds(50, 50); |
| 3795 scoped_ptr<LayerImpl> testLayer = LayerImpl::create(12345); | 3781 scoped_ptr<LayerImpl> testLayer = LayerImpl::create(12345); |
| 3796 setLayerPropertiesForTesting(testLayer.get(), identityMatrix, identityMa
trix, anchor, position, bounds, false); | 3782 setLayerPropertiesForTesting(testLayer.get(), identityMatrix, identityMa
trix, anchor, position, bounds, false); |
| 3797 | 3783 |
| 3798 testLayer->setDrawsContent(true); | 3784 testLayer->setDrawsContent(true); |
| 3799 testLayer->setTouchEventHandlerRegion(touchHandlerRegion); | 3785 testLayer->setTouchEventHandlerRegion(touchHandlerRegion); |
| 3800 root->addChild(testLayer.Pass()); | 3786 root->addChild(testLayer.Pass()); |
| 3801 } | 3787 } |
| 3802 | 3788 |
| 3803 std::vector<LayerImpl*> renderSurfaceLayerList; | 3789 std::vector<LayerImpl*> renderSurfaceLayerList; |
| 3804 int dummyMaxTextureSize = 512; | 3790 int dummyMaxTextureSize = 512; |
| 3805 float deviceScaleFactor = 3.0f; | 3791 float deviceScaleFactor = 3.0f; |
| 3806 float pageScaleFactor = 5.0f; | 3792 float pageScaleFactor = 5.0f; |
| 3807 WebTransformationMatrix pageScaleTransform; | 3793 gfx::Transform pageScaleTransform; |
| 3808 pageScaleTransform.scale(pageScaleFactor); | 3794 pageScaleTransform.Scale(pageScaleFactor, pageScaleFactor); |
| 3809 root->setImplTransform(pageScaleTransform); // Applying the pageScaleFactor
through implTransform. | 3795 root->setImplTransform(pageScaleTransform); // Applying the pageScaleFactor
through implTransform. |
| 3810 gfx::Size scaledBoundsForRoot = gfx::ToCeiledSize(gfx::ScaleSize(root->bound
s(), deviceScaleFactor * pageScaleFactor)); | 3796 gfx::Size scaledBoundsForRoot = gfx::ToCeiledSize(gfx::ScaleSize(root->bound
s(), deviceScaleFactor * pageScaleFactor)); |
| 3811 LayerTreeHostCommon::calculateDrawTransforms(root.get(), scaledBoundsForRoot
, deviceScaleFactor, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 3797 LayerTreeHostCommon::calculateDrawTransforms(root.get(), scaledBoundsForRoot
, deviceScaleFactor, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
| 3812 | 3798 |
| 3813 // Sanity check the scenario we just created. | 3799 // Sanity check the scenario we just created. |
| 3814 // The visibleContentRect for testLayer is actually 100x100, even though its
layout size is 50x50, positioned at 25x25. | 3800 // The visibleContentRect for testLayer is actually 100x100, even though its
layout size is 50x50, positioned at 25x25. |
| 3815 LayerImpl* testLayer = root->children()[0]; | 3801 LayerImpl* testLayer = root->children()[0]; |
| 3816 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 3802 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
| 3817 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); | 3803 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); |
| 3818 | 3804 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3857 testPoint = gfx::ScalePoint(testPoint, deviceScaleFactor * pageScaleFactor); | 3843 testPoint = gfx::ScalePoint(testPoint, deviceScaleFactor * pageScaleFactor); |
| 3858 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 3844 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
| 3859 ASSERT_TRUE(resultLayer); | 3845 ASSERT_TRUE(resultLayer); |
| 3860 EXPECT_EQ(12345, resultLayer->id()); | 3846 EXPECT_EQ(12345, resultLayer->id()); |
| 3861 } | 3847 } |
| 3862 | 3848 |
| 3863 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSimpleClipp
edLayer) | 3849 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSimpleClipp
edLayer) |
| 3864 { | 3850 { |
| 3865 // Test that hit-checking will only work for the visible portion of a layer,
and not | 3851 // Test that hit-checking will only work for the visible portion of a layer,
and not |
| 3866 // the entire layer bounds. Here we just test the simple axis-aligned case. | 3852 // the entire layer bounds. Here we just test the simple axis-aligned case. |
| 3867 WebTransformationMatrix identityMatrix; | 3853 gfx::Transform identityMatrix; |
| 3868 gfx::PointF anchor(0, 0); | 3854 gfx::PointF anchor(0, 0); |
| 3869 | 3855 |
| 3870 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3856 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
| 3871 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); | 3857 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 3872 | 3858 |
| 3873 { | 3859 { |
| 3874 scoped_ptr<LayerImpl> clippingLayer = LayerImpl::create(123); | 3860 scoped_ptr<LayerImpl> clippingLayer = LayerImpl::create(123); |
| 3875 gfx::PointF position(25, 25); // this layer is positioned, and hit testi
ng should correctly know where the layer is located. | 3861 gfx::PointF position(25, 25); // this layer is positioned, and hit testi
ng should correctly know where the layer is located. |
| 3876 gfx::Size bounds(50, 50); | 3862 gfx::Size bounds(50, 50); |
| 3877 setLayerPropertiesForTesting(clippingLayer.get(), identityMatrix, identi
tyMatrix, anchor, position, bounds, false); | 3863 setLayerPropertiesForTesting(clippingLayer.get(), identityMatrix, identi
tyMatrix, anchor, position, bounds, false); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3942 { | 3928 { |
| 3943 scoped_refptr<NoScaleContentLayer> toReturn = NoScaleContentLayer::create(de
legate); | 3929 scoped_refptr<NoScaleContentLayer> toReturn = NoScaleContentLayer::create(de
legate); |
| 3944 toReturn->setIsDrawable(true); | 3930 toReturn->setIsDrawable(true); |
| 3945 return toReturn; | 3931 return toReturn; |
| 3946 } | 3932 } |
| 3947 | 3933 |
| 3948 TEST(LayerTreeHostCommonTest, verifyLayerTransformsInHighDPI) | 3934 TEST(LayerTreeHostCommonTest, verifyLayerTransformsInHighDPI) |
| 3949 { | 3935 { |
| 3950 // Verify draw and screen space transforms of layers not in a surface. | 3936 // Verify draw and screen space transforms of layers not in a surface. |
| 3951 MockContentLayerClient delegate; | 3937 MockContentLayerClient delegate; |
| 3952 WebTransformationMatrix identityMatrix; | 3938 gfx::Transform identityMatrix; |
| 3953 | 3939 |
| 3954 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); | 3940 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); |
| 3955 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); | 3941 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); |
| 3956 | 3942 |
| 3957 scoped_refptr<ContentLayer> child = createDrawableContentLayer(&delegate); | 3943 scoped_refptr<ContentLayer> child = createDrawableContentLayer(&delegate); |
| 3958 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); | 3944 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); |
| 3959 | 3945 |
| 3960 scoped_refptr<ContentLayer> childEmpty = createDrawableContentLayer(&delegat
e); | 3946 scoped_refptr<ContentLayer> childEmpty = createDrawableContentLayer(&delegat
e); |
| 3961 setLayerPropertiesForTesting(childEmpty.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(0, 0), true); | 3947 setLayerPropertiesForTesting(childEmpty.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(0, 0), true); |
| 3962 | 3948 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 3976 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList
); | 3962 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList
); |
| 3977 | 3963 |
| 3978 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, parent); | 3964 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, parent); |
| 3979 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, child); | 3965 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, child); |
| 3980 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, childEmpty); | 3966 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, childEmpty); |
| 3981 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); | 3967 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); |
| 3982 | 3968 |
| 3983 EXPECT_EQ(1u, renderSurfaceLayerList.size()); | 3969 EXPECT_EQ(1u, renderSurfaceLayerList.size()); |
| 3984 | 3970 |
| 3985 // Verify parent transforms | 3971 // Verify parent transforms |
| 3986 WebTransformationMatrix expectedParentTransform; | 3972 gfx::Transform expectedParentTransform; |
| 3987 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpace
Transform()); | 3973 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpace
Transform()); |
| 3988 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->drawTransfo
rm()); | 3974 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->drawTransfo
rm()); |
| 3989 | 3975 |
| 3990 // Verify results of transformed parent rects | 3976 // Verify results of transformed parent rects |
| 3991 gfx::RectF parentContentBounds(gfx::PointF(), gfx::SizeF(parent->contentBoun
ds())); | 3977 gfx::RectF parentContentBounds(gfx::PointF(), gfx::SizeF(parent->contentBoun
ds())); |
| 3992 | 3978 |
| 3993 gfx::RectF parentDrawRect = MathUtil::mapClippedRect(parent->drawTransform()
, parentContentBounds); | 3979 gfx::RectF parentDrawRect = MathUtil::mapClippedRect(parent->drawTransform()
, parentContentBounds); |
| 3994 gfx::RectF parentScreenSpaceRect = MathUtil::mapClippedRect(parent->screenSp
aceTransform(), parentContentBounds); | 3980 gfx::RectF parentScreenSpaceRect = MathUtil::mapClippedRect(parent->screenSp
aceTransform(), parentContentBounds); |
| 3995 | 3981 |
| 3996 gfx::RectF expectedParentDrawRect(gfx::PointF(), parent->bounds()); | 3982 gfx::RectF expectedParentDrawRect(gfx::PointF(), parent->bounds()); |
| 3997 expectedParentDrawRect.Scale(deviceScaleFactor); | 3983 expectedParentDrawRect.Scale(deviceScaleFactor); |
| 3998 EXPECT_FLOAT_RECT_EQ(expectedParentDrawRect, parentDrawRect); | 3984 EXPECT_FLOAT_RECT_EQ(expectedParentDrawRect, parentDrawRect); |
| 3999 EXPECT_FLOAT_RECT_EQ(expectedParentDrawRect, parentScreenSpaceRect); | 3985 EXPECT_FLOAT_RECT_EQ(expectedParentDrawRect, parentScreenSpaceRect); |
| 4000 | 3986 |
| 4001 // Verify child and childEmpty transforms. They should match. | 3987 // Verify child and childEmpty transforms. They should match. |
| 4002 WebTransformationMatrix expectedChildTransform; | 3988 gfx::Transform expectedChildTransform; |
| 4003 expectedChildTransform.translate(deviceScaleFactor * child->position().x(),
deviceScaleFactor * child->position().y()); | 3989 expectedChildTransform.Translate(deviceScaleFactor * child->position().x(),
deviceScaleFactor * child->position().y()); |
| 4004 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 3990 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); |
| 4005 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->screenSpaceTr
ansform()); | 3991 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->screenSpaceTr
ansform()); |
| 4006 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, childEmpty->drawTran
sform()); | 3992 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, childEmpty->drawTran
sform()); |
| 4007 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, childEmpty->screenSp
aceTransform()); | 3993 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, childEmpty->screenSp
aceTransform()); |
| 4008 | 3994 |
| 4009 // Verify results of transformed child and childEmpty rects. They should mat
ch. | 3995 // Verify results of transformed child and childEmpty rects. They should mat
ch. |
| 4010 gfx::RectF childContentBounds(gfx::PointF(), gfx::SizeF(child->contentBounds
())); | 3996 gfx::RectF childContentBounds(gfx::PointF(), gfx::SizeF(child->contentBounds
())); |
| 4011 | 3997 |
| 4012 gfx::RectF childDrawRect = MathUtil::mapClippedRect(child->drawTransform(),
childContentBounds); | 3998 gfx::RectF childDrawRect = MathUtil::mapClippedRect(child->drawTransform(),
childContentBounds); |
| 4013 gfx::RectF childScreenSpaceRect = MathUtil::mapClippedRect(child->screenSpac
eTransform(), childContentBounds); | 3999 gfx::RectF childScreenSpaceRect = MathUtil::mapClippedRect(child->screenSpac
eTransform(), childContentBounds); |
| 4014 | 4000 |
| 4015 gfx::RectF childEmptyDrawRect = MathUtil::mapClippedRect(childEmpty->drawTra
nsform(), childContentBounds); | 4001 gfx::RectF childEmptyDrawRect = MathUtil::mapClippedRect(childEmpty->drawTra
nsform(), childContentBounds); |
| 4016 gfx::RectF childEmptyScreenSpaceRect = MathUtil::mapClippedRect(childEmpty->
screenSpaceTransform(), childContentBounds); | 4002 gfx::RectF childEmptyScreenSpaceRect = MathUtil::mapClippedRect(childEmpty->
screenSpaceTransform(), childContentBounds); |
| 4017 | 4003 |
| 4018 gfx::RectF expectedChildDrawRect(child->position(), child->bounds()); | 4004 gfx::RectF expectedChildDrawRect(child->position(), child->bounds()); |
| 4019 expectedChildDrawRect.Scale(deviceScaleFactor); | 4005 expectedChildDrawRect.Scale(deviceScaleFactor); |
| 4020 EXPECT_FLOAT_RECT_EQ(expectedChildDrawRect, childDrawRect); | 4006 EXPECT_FLOAT_RECT_EQ(expectedChildDrawRect, childDrawRect); |
| 4021 EXPECT_FLOAT_RECT_EQ(expectedChildDrawRect, childScreenSpaceRect); | 4007 EXPECT_FLOAT_RECT_EQ(expectedChildDrawRect, childScreenSpaceRect); |
| 4022 EXPECT_FLOAT_RECT_EQ(expectedChildDrawRect, childEmptyDrawRect); | 4008 EXPECT_FLOAT_RECT_EQ(expectedChildDrawRect, childEmptyDrawRect); |
| 4023 EXPECT_FLOAT_RECT_EQ(expectedChildDrawRect, childEmptyScreenSpaceRect); | 4009 EXPECT_FLOAT_RECT_EQ(expectedChildDrawRect, childEmptyScreenSpaceRect); |
| 4024 | 4010 |
| 4025 // Verify childNoScale transforms | 4011 // Verify childNoScale transforms |
| 4026 WebTransformationMatrix expectedChildNoScaleTransform = child->drawTransform
(); | 4012 gfx::Transform expectedChildNoScaleTransform = child->drawTransform(); |
| 4027 // All transforms operate on content rects. The child's content rect | 4013 // All transforms operate on content rects. The child's content rect |
| 4028 // incorporates device scale, but the childNoScale does not; add it here. | 4014 // incorporates device scale, but the childNoScale does not; add it here. |
| 4029 expectedChildNoScaleTransform.scale(deviceScaleFactor); | 4015 expectedChildNoScaleTransform.Scale(deviceScaleFactor, deviceScaleFactor); |
| 4030 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildNoScaleTransform, childNoScale-
>drawTransform()); | 4016 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildNoScaleTransform, childNoScale-
>drawTransform()); |
| 4031 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildNoScaleTransform, childNoScale-
>screenSpaceTransform()); | 4017 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildNoScaleTransform, childNoScale-
>screenSpaceTransform()); |
| 4032 } | 4018 } |
| 4033 | 4019 |
| 4034 TEST(LayerTreeHostCommonTest, verifyLayerTransformsInHighDPIAccurateScaleZeroChi
ldPosition) | 4020 TEST(LayerTreeHostCommonTest, verifyLayerTransformsInHighDPIAccurateScaleZeroChi
ldPosition) |
| 4035 { | 4021 { |
| 4036 // Verify draw and screen space transforms of layers not in a surface. | 4022 // Verify draw and screen space transforms of layers not in a surface. |
| 4037 MockContentLayerClient delegate; | 4023 MockContentLayerClient delegate; |
| 4038 WebTransformationMatrix identityMatrix; | 4024 gfx::Transform identityMatrix; |
| 4039 | 4025 |
| 4040 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); | 4026 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); |
| 4041 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(133, 133), true); | 4027 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(133, 133), true); |
| 4042 | 4028 |
| 4043 scoped_refptr<ContentLayer> child = createDrawableContentLayer(&delegate); | 4029 scoped_refptr<ContentLayer> child = createDrawableContentLayer(&delegate); |
| 4044 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(13, 13), true); | 4030 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(13, 13), true); |
| 4045 | 4031 |
| 4046 scoped_refptr<NoScaleContentLayer> childNoScale = createNoScaleDrawableConte
ntLayer(&delegate); | 4032 scoped_refptr<NoScaleContentLayer> childNoScale = createNoScaleDrawableConte
ntLayer(&delegate); |
| 4047 setLayerPropertiesForTesting(childNoScale.get(), identityMatrix, identityMat
rix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(13, 13), true); | 4033 setLayerPropertiesForTesting(childNoScale.get(), identityMatrix, identityMat
rix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(13, 13), true); |
| 4048 | 4034 |
| 4049 parent->addChild(child); | 4035 parent->addChild(child); |
| 4050 parent->addChild(childNoScale); | 4036 parent->addChild(childNoScale); |
| 4051 | 4037 |
| 4052 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 4038 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
| 4053 int dummyMaxTextureSize = 512; | 4039 int dummyMaxTextureSize = 512; |
| 4054 | 4040 |
| 4055 const float deviceScaleFactor = 1.7f; | 4041 const float deviceScaleFactor = 1.7f; |
| 4056 const float pageScaleFactor = 1; | 4042 const float pageScaleFactor = 1; |
| 4057 | 4043 |
| 4058 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList
); | 4044 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList
); |
| 4059 | 4045 |
| 4060 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, parent); | 4046 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, parent); |
| 4061 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, child); | 4047 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, child); |
| 4062 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); | 4048 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); |
| 4063 | 4049 |
| 4064 EXPECT_EQ(1u, renderSurfaceLayerList.size()); | 4050 EXPECT_EQ(1u, renderSurfaceLayerList.size()); |
| 4065 | 4051 |
| 4066 // Verify parent transforms | 4052 // Verify parent transforms |
| 4067 WebTransformationMatrix expectedParentTransform; | 4053 gfx::Transform expectedParentTransform; |
| 4068 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpace
Transform()); | 4054 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpace
Transform()); |
| 4069 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->drawTransfo
rm()); | 4055 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->drawTransfo
rm()); |
| 4070 | 4056 |
| 4071 // Verify results of transformed parent rects | 4057 // Verify results of transformed parent rects |
| 4072 gfx::RectF parentContentBounds(gfx::PointF(), gfx::SizeF(parent->contentBoun
ds())); | 4058 gfx::RectF parentContentBounds(gfx::PointF(), gfx::SizeF(parent->contentBoun
ds())); |
| 4073 | 4059 |
| 4074 gfx::RectF parentDrawRect = MathUtil::mapClippedRect(parent->drawTransform()
, parentContentBounds); | 4060 gfx::RectF parentDrawRect = MathUtil::mapClippedRect(parent->drawTransform()
, parentContentBounds); |
| 4075 gfx::RectF parentScreenSpaceRect = MathUtil::mapClippedRect(parent->screenSp
aceTransform(), parentContentBounds); | 4061 gfx::RectF parentScreenSpaceRect = MathUtil::mapClippedRect(parent->screenSp
aceTransform(), parentContentBounds); |
| 4076 | 4062 |
| 4077 gfx::RectF expectedParentDrawRect(gfx::PointF(), parent->bounds()); | 4063 gfx::RectF expectedParentDrawRect(gfx::PointF(), parent->bounds()); |
| 4078 expectedParentDrawRect.Scale(deviceScaleFactor); | 4064 expectedParentDrawRect.Scale(deviceScaleFactor); |
| 4079 expectedParentDrawRect.set_width(ceil(expectedParentDrawRect.width())); | 4065 expectedParentDrawRect.set_width(ceil(expectedParentDrawRect.width())); |
| 4080 expectedParentDrawRect.set_height(ceil(expectedParentDrawRect.height())); | 4066 expectedParentDrawRect.set_height(ceil(expectedParentDrawRect.height())); |
| 4081 EXPECT_FLOAT_RECT_EQ(expectedParentDrawRect, parentDrawRect); | 4067 EXPECT_FLOAT_RECT_EQ(expectedParentDrawRect, parentDrawRect); |
| 4082 EXPECT_FLOAT_RECT_EQ(expectedParentDrawRect, parentScreenSpaceRect); | 4068 EXPECT_FLOAT_RECT_EQ(expectedParentDrawRect, parentScreenSpaceRect); |
| 4083 | 4069 |
| 4084 // Verify child transforms | 4070 // Verify child transforms |
| 4085 WebTransformationMatrix expectedChildTransform; | 4071 gfx::Transform expectedChildTransform; |
| 4086 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 4072 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); |
| 4087 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->screenSpaceTr
ansform()); | 4073 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->screenSpaceTr
ansform()); |
| 4088 | 4074 |
| 4089 // Verify results of transformed child rects | 4075 // Verify results of transformed child rects |
| 4090 gfx::RectF childContentBounds(gfx::PointF(), gfx::SizeF(child->contentBounds
())); | 4076 gfx::RectF childContentBounds(gfx::PointF(), gfx::SizeF(child->contentBounds
())); |
| 4091 | 4077 |
| 4092 gfx::RectF childDrawRect = MathUtil::mapClippedRect(child->drawTransform(),
childContentBounds); | 4078 gfx::RectF childDrawRect = MathUtil::mapClippedRect(child->drawTransform(),
childContentBounds); |
| 4093 gfx::RectF childScreenSpaceRect = MathUtil::mapClippedRect(child->screenSpac
eTransform(), childContentBounds); | 4079 gfx::RectF childScreenSpaceRect = MathUtil::mapClippedRect(child->screenSpac
eTransform(), childContentBounds); |
| 4094 | 4080 |
| 4095 gfx::RectF expectedChildDrawRect(gfx::PointF(), child->bounds()); | 4081 gfx::RectF expectedChildDrawRect(gfx::PointF(), child->bounds()); |
| 4096 expectedChildDrawRect.Scale(deviceScaleFactor); | 4082 expectedChildDrawRect.Scale(deviceScaleFactor); |
| 4097 expectedChildDrawRect.set_width(ceil(expectedChildDrawRect.width())); | 4083 expectedChildDrawRect.set_width(ceil(expectedChildDrawRect.width())); |
| 4098 expectedChildDrawRect.set_height(ceil(expectedChildDrawRect.height())); | 4084 expectedChildDrawRect.set_height(ceil(expectedChildDrawRect.height())); |
| 4099 EXPECT_FLOAT_RECT_EQ(expectedChildDrawRect, childDrawRect); | 4085 EXPECT_FLOAT_RECT_EQ(expectedChildDrawRect, childDrawRect); |
| 4100 EXPECT_FLOAT_RECT_EQ(expectedChildDrawRect, childScreenSpaceRect); | 4086 EXPECT_FLOAT_RECT_EQ(expectedChildDrawRect, childScreenSpaceRect); |
| 4101 | 4087 |
| 4102 // Verify childNoScale transforms | 4088 // Verify childNoScale transforms |
| 4103 WebTransformationMatrix expectedChildNoScaleTransform = child->drawTransform
(); | 4089 gfx::Transform expectedChildNoScaleTransform = child->drawTransform(); |
| 4104 // All transforms operate on content rects. The child's content rect | 4090 // All transforms operate on content rects. The child's content rect |
| 4105 // incorporates device scale, but the childNoScale does not; add it here. | 4091 // incorporates device scale, but the childNoScale does not; add it here. |
| 4106 expectedChildNoScaleTransform.scale(deviceScaleFactor); | 4092 expectedChildNoScaleTransform.Scale(deviceScaleFactor, deviceScaleFactor); |
| 4107 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildNoScaleTransform, childNoScale-
>drawTransform()); | 4093 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildNoScaleTransform, childNoScale-
>drawTransform()); |
| 4108 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildNoScaleTransform, childNoScale-
>screenSpaceTransform()); | 4094 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildNoScaleTransform, childNoScale-
>screenSpaceTransform()); |
| 4109 } | 4095 } |
| 4110 | 4096 |
| 4111 TEST(LayerTreeHostCommonTest, verifyContentsScale) | 4097 TEST(LayerTreeHostCommonTest, verifyContentsScale) |
| 4112 { | 4098 { |
| 4113 MockContentLayerClient delegate; | 4099 MockContentLayerClient delegate; |
| 4114 WebTransformationMatrix identityMatrix; | 4100 gfx::Transform identityMatrix; |
| 4115 | 4101 |
| 4116 WebTransformationMatrix parentScaleMatrix; | 4102 gfx::Transform parentScaleMatrix; |
| 4117 const double initialParentScale = 1.75; | 4103 const double initialParentScale = 1.75; |
| 4118 parentScaleMatrix.scale(initialParentScale); | 4104 parentScaleMatrix.Scale(initialParentScale, initialParentScale); |
| 4119 | 4105 |
| 4120 WebTransformationMatrix childScaleMatrix; | 4106 gfx::Transform childScaleMatrix; |
| 4121 const double initialChildScale = 1.25; | 4107 const double initialChildScale = 1.25; |
| 4122 childScaleMatrix.scale(initialChildScale); | 4108 childScaleMatrix.Scale(initialChildScale, initialChildScale); |
| 4123 | 4109 |
| 4124 float fixedRasterScale = 2.5; | 4110 float fixedRasterScale = 2.5; |
| 4125 | 4111 |
| 4126 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); | 4112 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); |
| 4127 setLayerPropertiesForTesting(parent.get(), parentScaleMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); | 4113 setLayerPropertiesForTesting(parent.get(), parentScaleMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); |
| 4128 | 4114 |
| 4129 scoped_refptr<ContentLayer> childScale = createDrawableContentLayer(&delegat
e); | 4115 scoped_refptr<ContentLayer> childScale = createDrawableContentLayer(&delegat
e); |
| 4130 setLayerPropertiesForTesting(childScale.get(), childScaleMatrix, identityMat
rix, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); | 4116 setLayerPropertiesForTesting(childScale.get(), childScaleMatrix, identityMat
rix, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); |
| 4131 | 4117 |
| 4132 scoped_refptr<ContentLayer> childEmpty = createDrawableContentLayer(&delegat
e); | 4118 scoped_refptr<ContentLayer> childEmpty = createDrawableContentLayer(&delegat
e); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 4149 parent->addChild(childNoScale); | 4135 parent->addChild(childNoScale); |
| 4150 parent->addChild(childNoAutoScale); | 4136 parent->addChild(childNoAutoScale); |
| 4151 | 4137 |
| 4152 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 4138 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
| 4153 int dummyMaxTextureSize = 512; | 4139 int dummyMaxTextureSize = 512; |
| 4154 | 4140 |
| 4155 double deviceScaleFactor = 2.5; | 4141 double deviceScaleFactor = 2.5; |
| 4156 double pageScaleFactor = 1.5; | 4142 double pageScaleFactor = 1.5; |
| 4157 | 4143 |
| 4158 // FIXME: Remove this when pageScaleFactor is applied in the compositor. | 4144 // FIXME: Remove this when pageScaleFactor is applied in the compositor. |
| 4159 WebTransformationMatrix pageScaleMatrix; | 4145 gfx::Transform pageScaleMatrix; |
| 4160 pageScaleMatrix.scale(pageScaleFactor); | 4146 pageScaleMatrix.Scale(pageScaleFactor, pageScaleFactor); |
| 4161 parent->setSublayerTransform(pageScaleMatrix); | 4147 parent->setSublayerTransform(pageScaleMatrix); |
| 4162 | 4148 |
| 4163 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList
); | 4149 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList
); |
| 4164 | 4150 |
| 4165 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); | 4151 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); |
| 4166 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale, childScale); | 4152 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale, childScale); |
| 4167 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale, childEmpty); | 4153 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale, childEmpty); |
| 4168 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); | 4154 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); |
| 4169 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * fixedRasterSc
ale, childNoAutoScale); | 4155 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * fixedRasterSc
ale, childNoAutoScale); |
| 4170 | 4156 |
| 4171 // The parent is scaled up and shouldn't need to scale during draw. The chil
d that can scale its contents should | 4157 // The parent is scaled up and shouldn't need to scale during draw. The chil
d that can scale its contents should |
| 4172 // also not need to scale during draw. This shouldn't change if the child ha
s empty bounds. The other children should. | 4158 // also not need to scale during draw. This shouldn't change if the child ha
s empty bounds. The other children should. |
| 4173 EXPECT_FLOAT_EQ(1, parent->drawTransform().m11()); | 4159 EXPECT_FLOAT_EQ(1, parent->drawTransform().matrix().getDouble(0, 0)); |
| 4174 EXPECT_FLOAT_EQ(1, parent->drawTransform().m22()); | 4160 EXPECT_FLOAT_EQ(1, parent->drawTransform().matrix().getDouble(1, 1)); |
| 4175 EXPECT_FLOAT_EQ(1, childScale->drawTransform().m11()); | 4161 EXPECT_FLOAT_EQ(1, childScale->drawTransform().matrix().getDouble(0, 0)); |
| 4176 EXPECT_FLOAT_EQ(1, childScale->drawTransform().m22()); | 4162 EXPECT_FLOAT_EQ(1, childScale->drawTransform().matrix().getDouble(1, 1)); |
| 4177 EXPECT_FLOAT_EQ(1, childEmpty->drawTransform().m11()); | 4163 EXPECT_FLOAT_EQ(1, childEmpty->drawTransform().matrix().getDouble(0, 0)); |
| 4178 EXPECT_FLOAT_EQ(1, childEmpty->drawTransform().m22()); | 4164 EXPECT_FLOAT_EQ(1, childEmpty->drawTransform().matrix().getDouble(1, 1)); |
| 4179 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale, childNoScale->drawTransform().m11()); | 4165 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale, childNoScale->drawTransform().matrix().getDouble(0, 0)); |
| 4180 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale, childNoScale->drawTransform().m22()); | 4166 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale, childNoScale->drawTransform().matrix().getDouble(1, 1)); |
| 4181 EXPECT_FLOAT_EQ(initialParentScale * initialChildScale / fixedRasterScale, c
hildNoAutoScale->drawTransform().m11()); | 4167 EXPECT_FLOAT_EQ(initialParentScale * initialChildScale / fixedRasterScale, c
hildNoAutoScale->drawTransform().matrix().getDouble(0, 0)); |
| 4182 EXPECT_FLOAT_EQ(initialParentScale * initialChildScale / fixedRasterScale, c
hildNoAutoScale->drawTransform().m22()); | 4168 EXPECT_FLOAT_EQ(initialParentScale * initialChildScale / fixedRasterScale, c
hildNoAutoScale->drawTransform().matrix().getDouble(1, 1)); |
| 4183 | 4169 |
| 4184 // If the transform changes, we expect the contentsScale to remain unchanged
. | 4170 // If the transform changes, we expect the contentsScale to remain unchanged
. |
| 4185 childScale->setTransform(identityMatrix); | 4171 childScale->setTransform(identityMatrix); |
| 4186 childEmpty->setTransform(identityMatrix); | 4172 childEmpty->setTransform(identityMatrix); |
| 4187 | 4173 |
| 4188 renderSurfaceLayerList.clear(); | 4174 renderSurfaceLayerList.clear(); |
| 4189 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList
); | 4175 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList
); |
| 4190 | 4176 |
| 4191 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); | 4177 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); |
| 4192 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale, childScale); | 4178 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale, childScale); |
| 4193 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale, childEmpty); | 4179 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale, childEmpty); |
| 4194 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); | 4180 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); |
| 4195 | 4181 |
| 4196 // But if the deviceScaleFactor or pageScaleFactor changes, then it should b
e updated, but using the initial transform. | 4182 // But if the deviceScaleFactor or pageScaleFactor changes, then it should b
e updated, but using the initial transform. |
| 4197 deviceScaleFactor = 2.25; | 4183 deviceScaleFactor = 2.25; |
| 4198 pageScaleFactor = 1.25; | 4184 pageScaleFactor = 1.25; |
| 4199 | 4185 |
| 4200 // FIXME: Remove this when pageScaleFactor is applied in the compositor. | 4186 // FIXME: Remove this when pageScaleFactor is applied in the compositor. |
| 4201 pageScaleMatrix = identityMatrix; | 4187 pageScaleMatrix = identityMatrix; |
| 4202 pageScaleMatrix.scale(pageScaleFactor); | 4188 pageScaleMatrix.Scale(pageScaleFactor, pageScaleFactor); |
| 4203 parent->setSublayerTransform(pageScaleMatrix); | 4189 parent->setSublayerTransform(pageScaleMatrix); |
| 4204 | 4190 |
| 4205 renderSurfaceLayerList.clear(); | 4191 renderSurfaceLayerList.clear(); |
| 4206 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList
); | 4192 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList
); |
| 4207 | 4193 |
| 4208 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); | 4194 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); |
| 4209 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale, childScale); | 4195 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale, childScale); |
| 4210 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale, childEmpty); | 4196 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale, childEmpty); |
| 4211 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); | 4197 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); |
| 4212 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * fixedRasterSc
ale, childNoAutoScale); | 4198 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * fixedRasterSc
ale, childNoAutoScale); |
| 4213 } | 4199 } |
| 4214 | 4200 |
| 4215 TEST(LayerTreeHostCommonTest, verifySmallContentsScale) | 4201 TEST(LayerTreeHostCommonTest, verifySmallContentsScale) |
| 4216 { | 4202 { |
| 4217 MockContentLayerClient delegate; | 4203 MockContentLayerClient delegate; |
| 4218 WebTransformationMatrix identityMatrix; | 4204 gfx::Transform identityMatrix; |
| 4219 | 4205 |
| 4220 WebTransformationMatrix parentScaleMatrix; | 4206 gfx::Transform parentScaleMatrix; |
| 4221 const double initialParentScale = 1.75; | 4207 const double initialParentScale = 1.75; |
| 4222 parentScaleMatrix.scale(initialParentScale); | 4208 parentScaleMatrix.Scale(initialParentScale, initialParentScale); |
| 4223 | 4209 |
| 4224 WebTransformationMatrix childScaleMatrix; | 4210 gfx::Transform childScaleMatrix; |
| 4225 const double initialChildScale = 0.25; | 4211 const double initialChildScale = 0.25; |
| 4226 childScaleMatrix.scale(initialChildScale); | 4212 childScaleMatrix.Scale(initialChildScale, initialChildScale); |
| 4227 | 4213 |
| 4228 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); | 4214 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); |
| 4229 setLayerPropertiesForTesting(parent.get(), parentScaleMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); | 4215 setLayerPropertiesForTesting(parent.get(), parentScaleMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); |
| 4230 | 4216 |
| 4231 scoped_refptr<ContentLayer> childScale = createDrawableContentLayer(&delegat
e); | 4217 scoped_refptr<ContentLayer> childScale = createDrawableContentLayer(&delegat
e); |
| 4232 setLayerPropertiesForTesting(childScale.get(), childScaleMatrix, identityMat
rix, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); | 4218 setLayerPropertiesForTesting(childScale.get(), childScaleMatrix, identityMat
rix, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); |
| 4233 | 4219 |
| 4234 // FIXME: Remove this when pageScaleFactor is applied in the compositor. | 4220 // FIXME: Remove this when pageScaleFactor is applied in the compositor. |
| 4235 // Page scale should not apply to the parent. | 4221 // Page scale should not apply to the parent. |
| 4236 parent->setBoundsContainPageScale(true); | 4222 parent->setBoundsContainPageScale(true); |
| 4237 | 4223 |
| 4238 parent->addChild(childScale); | 4224 parent->addChild(childScale); |
| 4239 | 4225 |
| 4240 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 4226 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
| 4241 int dummyMaxTextureSize = 512; | 4227 int dummyMaxTextureSize = 512; |
| 4242 | 4228 |
| 4243 double deviceScaleFactor = 2.5; | 4229 double deviceScaleFactor = 2.5; |
| 4244 double pageScaleFactor = 0.01; | 4230 double pageScaleFactor = 0.01; |
| 4245 | 4231 |
| 4246 // FIXME: Remove this when pageScaleFactor is applied in the compositor. | 4232 // FIXME: Remove this when pageScaleFactor is applied in the compositor. |
| 4247 WebTransformationMatrix pageScaleMatrix; | 4233 gfx::Transform pageScaleMatrix; |
| 4248 pageScaleMatrix.scale(pageScaleFactor); | 4234 pageScaleMatrix.Scale(pageScaleFactor, pageScaleFactor); |
| 4249 parent->setSublayerTransform(pageScaleMatrix); | 4235 parent->setSublayerTransform(pageScaleMatrix); |
| 4250 | 4236 |
| 4251 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList
); | 4237 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList
); |
| 4252 | 4238 |
| 4253 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); | 4239 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); |
| 4254 // The child's scale is < 1, so we should not save and use that scale factor
. | 4240 // The child's scale is < 1, so we should not save and use that scale factor
. |
| 4255 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * 1, childScale
); | 4241 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * 1, childScale
); |
| 4256 | 4242 |
| 4257 // When chilld's total scale becomes >= 1, we should save and use that scale
factor. | 4243 // When chilld's total scale becomes >= 1, we should save and use that scale
factor. |
| 4258 childScaleMatrix.makeIdentity(); | 4244 childScaleMatrix.MakeIdentity(); |
| 4259 const double finalChildScale = 0.75; | 4245 const double finalChildScale = 0.75; |
| 4260 childScaleMatrix.scale(finalChildScale); | 4246 childScaleMatrix.Scale(finalChildScale, finalChildScale); |
| 4261 childScale->setTransform(childScaleMatrix); | 4247 childScale->setTransform(childScaleMatrix); |
| 4262 | 4248 |
| 4263 renderSurfaceLayerList.clear(); | 4249 renderSurfaceLayerList.clear(); |
| 4264 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList
); | 4250 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList
); |
| 4265 | 4251 |
| 4266 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); | 4252 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); |
| 4267 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * finalChildScale, childScale); | 4253 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * finalChildScale, childScale); |
| 4268 } | 4254 } |
| 4269 | 4255 |
| 4270 TEST(LayerTreeHostCommonTest, verifyContentsScaleForSurfaces) | 4256 TEST(LayerTreeHostCommonTest, verifyContentsScaleForSurfaces) |
| 4271 { | 4257 { |
| 4272 MockContentLayerClient delegate; | 4258 MockContentLayerClient delegate; |
| 4273 WebTransformationMatrix identityMatrix; | 4259 gfx::Transform identityMatrix; |
| 4274 | 4260 |
| 4275 WebTransformationMatrix parentScaleMatrix; | 4261 gfx::Transform parentScaleMatrix; |
| 4276 const double initialParentScale = 2; | 4262 const double initialParentScale = 2; |
| 4277 parentScaleMatrix.scale(initialParentScale); | 4263 parentScaleMatrix.Scale(initialParentScale, initialParentScale); |
| 4278 | 4264 |
| 4279 WebTransformationMatrix childScaleMatrix; | 4265 gfx::Transform childScaleMatrix; |
| 4280 const double initialChildScale = 3; | 4266 const double initialChildScale = 3; |
| 4281 childScaleMatrix.scale(initialChildScale); | 4267 childScaleMatrix.Scale(initialChildScale, initialChildScale); |
| 4282 | 4268 |
| 4283 float fixedRasterScale = 4; | 4269 float fixedRasterScale = 4; |
| 4284 | 4270 |
| 4285 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); | 4271 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); |
| 4286 setLayerPropertiesForTesting(parent.get(), parentScaleMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); | 4272 setLayerPropertiesForTesting(parent.get(), parentScaleMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); |
| 4287 | 4273 |
| 4288 scoped_refptr<ContentLayer> surfaceScale = createDrawableContentLayer(&deleg
ate); | 4274 scoped_refptr<ContentLayer> surfaceScale = createDrawableContentLayer(&deleg
ate); |
| 4289 setLayerPropertiesForTesting(surfaceScale.get(), childScaleMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); | 4275 setLayerPropertiesForTesting(surfaceScale.get(), childScaleMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); |
| 4290 | 4276 |
| 4291 scoped_refptr<ContentLayer> surfaceScaleChildScale = createDrawableContentLa
yer(&delegate); | 4277 scoped_refptr<ContentLayer> surfaceScaleChildScale = createDrawableContentLa
yer(&delegate); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4334 surfaceNoAutoScale->addChild(surfaceNoAutoScaleChildScale); | 4320 surfaceNoAutoScale->addChild(surfaceNoAutoScaleChildScale); |
| 4335 surfaceNoAutoScale->addChild(surfaceNoAutoScaleChildNoScale); | 4321 surfaceNoAutoScale->addChild(surfaceNoAutoScaleChildNoScale); |
| 4336 | 4322 |
| 4337 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 4323 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
| 4338 int dummyMaxTextureSize = 512; | 4324 int dummyMaxTextureSize = 512; |
| 4339 | 4325 |
| 4340 double deviceScaleFactor = 5; | 4326 double deviceScaleFactor = 5; |
| 4341 double pageScaleFactor = 7; | 4327 double pageScaleFactor = 7; |
| 4342 | 4328 |
| 4343 // FIXME: Remove this when pageScaleFactor is applied in the compositor. | 4329 // FIXME: Remove this when pageScaleFactor is applied in the compositor. |
| 4344 WebTransformationMatrix pageScaleMatrix; | 4330 gfx::Transform pageScaleMatrix; |
| 4345 pageScaleMatrix.scale(pageScaleFactor); | 4331 pageScaleMatrix.Scale(pageScaleFactor, pageScaleFactor); |
| 4346 parent->setSublayerTransform(pageScaleMatrix); | 4332 parent->setSublayerTransform(pageScaleMatrix); |
| 4347 | 4333 |
| 4348 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList
); | 4334 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList
); |
| 4349 | 4335 |
| 4350 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); | 4336 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); |
| 4351 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale, surfaceScale); | 4337 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale, surfaceScale); |
| 4352 EXPECT_CONTENTS_SCALE_EQ(1, surfaceNoScale); | 4338 EXPECT_CONTENTS_SCALE_EQ(1, surfaceNoScale); |
| 4353 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * fixedRasterSc
ale, surfaceNoAutoScale); | 4339 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * fixedRasterSc
ale, surfaceNoAutoScale); |
| 4354 | 4340 |
| 4355 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale * initialChildScale, surfaceScaleChildScale); | 4341 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale * initialChildScale, surfaceScaleChildScale); |
| 4356 EXPECT_CONTENTS_SCALE_EQ(1, surfaceScaleChildNoScale); | 4342 EXPECT_CONTENTS_SCALE_EQ(1, surfaceScaleChildNoScale); |
| 4357 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale * initialChildScale, surfaceNoScaleChildScale); | 4343 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale * initialChildScale, surfaceNoScaleChildScale); |
| 4358 EXPECT_CONTENTS_SCALE_EQ(1, surfaceNoScaleChildNoScale); | 4344 EXPECT_CONTENTS_SCALE_EQ(1, surfaceNoScaleChildNoScale); |
| 4359 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale * initialChildScale, surfaceNoAutoScaleChildScale); | 4345 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale * initialChildScale, surfaceNoAutoScaleChildScale); |
| 4360 EXPECT_CONTENTS_SCALE_EQ(1, surfaceNoAutoScaleChildNoScale); | 4346 EXPECT_CONTENTS_SCALE_EQ(1, surfaceNoAutoScaleChildNoScale); |
| 4361 | 4347 |
| 4362 // The parent is scaled up and shouldn't need to scale during draw. | 4348 // The parent is scaled up and shouldn't need to scale during draw. |
| 4363 EXPECT_FLOAT_EQ(1, parent->drawTransform().m11()); | 4349 EXPECT_FLOAT_EQ(1, parent->drawTransform().matrix().getDouble(0, 0)); |
| 4364 EXPECT_FLOAT_EQ(1, parent->drawTransform().m22()); | 4350 EXPECT_FLOAT_EQ(1, parent->drawTransform().matrix().getDouble(1, 1)); |
| 4365 | 4351 |
| 4366 // RenderSurfaces should always be 1:1 with their target. | 4352 // RenderSurfaces should always be 1:1 with their target. |
| 4367 EXPECT_FLOAT_EQ(1, surfaceScale->renderSurface()->drawTransform().m11()); | 4353 EXPECT_FLOAT_EQ(1, surfaceScale->renderSurface()->drawTransform().matrix().g
etDouble(0, 0)); |
| 4368 EXPECT_FLOAT_EQ(1, surfaceScale->renderSurface()->drawTransform().m22()); | 4354 EXPECT_FLOAT_EQ(1, surfaceScale->renderSurface()->drawTransform().matrix().g
etDouble(1, 1)); |
| 4369 | 4355 |
| 4370 // The surfaceScale can apply contents scale so the layer shouldn't need to
scale during draw. | 4356 // The surfaceScale can apply contents scale so the layer shouldn't need to
scale during draw. |
| 4371 EXPECT_FLOAT_EQ(1, surfaceScale->drawTransform().m11()); | 4357 EXPECT_FLOAT_EQ(1, surfaceScale->drawTransform().matrix().getDouble(0, 0)); |
| 4372 EXPECT_FLOAT_EQ(1, surfaceScale->drawTransform().m22()); | 4358 EXPECT_FLOAT_EQ(1, surfaceScale->drawTransform().matrix().getDouble(1, 1)); |
| 4373 | 4359 |
| 4374 // The surfaceScaleChildScale can apply contents scale so it shouldn't need
to scale during draw. | 4360 // The surfaceScaleChildScale can apply contents scale so it shouldn't need
to scale during draw. |
| 4375 EXPECT_FLOAT_EQ(1, surfaceScaleChildScale->drawTransform().m11()); | 4361 EXPECT_FLOAT_EQ(1, surfaceScaleChildScale->drawTransform().matrix().getDoubl
e(0, 0)); |
| 4376 EXPECT_FLOAT_EQ(1, surfaceScaleChildScale->drawTransform().m22()); | 4362 EXPECT_FLOAT_EQ(1, surfaceScaleChildScale->drawTransform().matrix().getDoubl
e(1, 1)); |
| 4377 | 4363 |
| 4378 // The surfaceScaleChildNoScale can not apply contents scale, so it needs to
be scaled during draw. | 4364 // The surfaceScaleChildNoScale can not apply contents scale, so it needs to
be scaled during draw. |
| 4379 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale * initialChildScale, surfaceScaleChildNoScale->drawTransform().
m11()); | 4365 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale * initialChildScale, surfaceScaleChildNoScale->drawTransform().
matrix().getDouble(0, 0)); |
| 4380 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale * initialChildScale, surfaceScaleChildNoScale->drawTransform().
m22()); | 4366 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale * initialChildScale, surfaceScaleChildNoScale->drawTransform().
matrix().getDouble(1, 1)); |
| 4381 | 4367 |
| 4382 // RenderSurfaces should always be 1:1 with their target. | 4368 // RenderSurfaces should always be 1:1 with their target. |
| 4383 EXPECT_FLOAT_EQ(1, surfaceNoScale->renderSurface()->drawTransform().m11()); | 4369 EXPECT_FLOAT_EQ(1, surfaceNoScale->renderSurface()->drawTransform().matrix()
.getDouble(0, 0)); |
| 4384 EXPECT_FLOAT_EQ(1, surfaceNoScale->renderSurface()->drawTransform().m22()); | 4370 EXPECT_FLOAT_EQ(1, surfaceNoScale->renderSurface()->drawTransform().matrix()
.getDouble(1, 1)); |
| 4385 | 4371 |
| 4386 // The surfaceNoScale layer can not apply contents scale, so it needs to be
scaled during draw. | 4372 // The surfaceNoScale layer can not apply contents scale, so it needs to be
scaled during draw. |
| 4387 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale, surfaceNoScale->drawTransform().m11()); | 4373 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale, surfaceNoScale->drawTransform().matrix().getDouble(0, 0)); |
| 4388 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale, surfaceNoScale->drawTransform().m22()); | 4374 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale, surfaceNoScale->drawTransform().matrix().getDouble(1, 1)); |
| 4389 | 4375 |
| 4390 // The surfaceScaleChildScale can apply contents scale so it shouldn't need
to scale during draw. | 4376 // The surfaceScaleChildScale can apply contents scale so it shouldn't need
to scale during draw. |
| 4391 EXPECT_FLOAT_EQ(1, surfaceNoScaleChildScale->drawTransform().m11()); | 4377 EXPECT_FLOAT_EQ(1, surfaceNoScaleChildScale->drawTransform().matrix().getDou
ble(0, 0)); |
| 4392 EXPECT_FLOAT_EQ(1, surfaceNoScaleChildScale->drawTransform().m22()); | 4378 EXPECT_FLOAT_EQ(1, surfaceNoScaleChildScale->drawTransform().matrix().getDou
ble(1, 1)); |
| 4393 | 4379 |
| 4394 // The surfaceScaleChildNoScale can not apply contents scale, so it needs to
be scaled during draw. | 4380 // The surfaceScaleChildNoScale can not apply contents scale, so it needs to
be scaled during draw. |
| 4395 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale * initialChildScale, surfaceNoScaleChildNoScale->drawTransform(
).m11()); | 4381 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale * initialChildScale, surfaceNoScaleChildNoScale->drawTransform(
).matrix().getDouble(0, 0)); |
| 4396 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale * initialChildScale, surfaceNoScaleChildNoScale->drawTransform(
).m22()); | 4382 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale * initialChildScale, surfaceNoScaleChildNoScale->drawTransform(
).matrix().getDouble(1, 1)); |
| 4397 | 4383 |
| 4398 // RenderSurfaces should always be 1:1 with their target. | 4384 // RenderSurfaces should always be 1:1 with their target. |
| 4399 EXPECT_FLOAT_EQ(1, surfaceNoAutoScale->renderSurface()->drawTransform().m11(
)); | 4385 EXPECT_FLOAT_EQ(1, surfaceNoAutoScale->renderSurface()->drawTransform().matr
ix().getDouble(0, 0)); |
| 4400 EXPECT_FLOAT_EQ(1, surfaceNoAutoScale->renderSurface()->drawTransform().m22(
)); | 4386 EXPECT_FLOAT_EQ(1, surfaceNoAutoScale->renderSurface()->drawTransform().matr
ix().getDouble(1, 1)); |
| 4401 | 4387 |
| 4402 // The surfaceNoAutoScale layer has a fixed contents scale, so it needs to b
e scaled during draw. | 4388 // The surfaceNoAutoScale layer has a fixed contents scale, so it needs to b
e scaled during draw. |
| 4403 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale / (deviceScaleFactor * pageScaleFactor * fixedRasterScale), sur
faceNoAutoScale->drawTransform().m11()); | 4389 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale / (deviceScaleFactor * pageScaleFactor * fixedRasterScale), sur
faceNoAutoScale->drawTransform().matrix().getDouble(0, 0)); |
| 4404 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale / (deviceScaleFactor * pageScaleFactor * fixedRasterScale), sur
faceNoAutoScale->drawTransform().m22()); | 4390 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale / (deviceScaleFactor * pageScaleFactor * fixedRasterScale), sur
faceNoAutoScale->drawTransform().matrix().getDouble(1, 1)); |
| 4405 | 4391 |
| 4406 // The surfaceScaleChildScale can apply contents scale so it shouldn't need
to scale during draw. | 4392 // The surfaceScaleChildScale can apply contents scale so it shouldn't need
to scale during draw. |
| 4407 EXPECT_FLOAT_EQ(1, surfaceNoAutoScaleChildScale->drawTransform().m11()); | 4393 EXPECT_FLOAT_EQ(1, surfaceNoAutoScaleChildScale->drawTransform().matrix().ge
tDouble(0, 0)); |
| 4408 EXPECT_FLOAT_EQ(1, surfaceNoAutoScaleChildScale->drawTransform().m22()); | 4394 EXPECT_FLOAT_EQ(1, surfaceNoAutoScaleChildScale->drawTransform().matrix().ge
tDouble(1, 1)); |
| 4409 | 4395 |
| 4410 // The surfaceScaleChildNoScale can not apply contents scale, so it needs to
be scaled during draw. | 4396 // The surfaceScaleChildNoScale can not apply contents scale, so it needs to
be scaled during draw. |
| 4411 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale * initialChildScale, surfaceNoAutoScaleChildNoScale->drawTransf
orm().m11()); | 4397 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale * initialChildScale, surfaceNoAutoScaleChildNoScale->drawTransf
orm().matrix().getDouble(0, 0)); |
| 4412 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale * initialChildScale, surfaceNoAutoScaleChildNoScale->drawTransf
orm().m22()); | 4398 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale * initialChildScale, surfaceNoAutoScaleChildNoScale->drawTransf
orm().matrix().getDouble(1, 1)); |
| 4413 } | 4399 } |
| 4414 | 4400 |
| 4415 TEST(LayerTreeHostCommonTest, verifyContentsScaleForAnimatingLayer) | 4401 TEST(LayerTreeHostCommonTest, verifyContentsScaleForAnimatingLayer) |
| 4416 { | 4402 { |
| 4417 MockContentLayerClient delegate; | 4403 MockContentLayerClient delegate; |
| 4418 WebTransformationMatrix identityMatrix; | 4404 gfx::Transform identityMatrix; |
| 4419 | 4405 |
| 4420 WebTransformationMatrix parentScaleMatrix; | 4406 gfx::Transform parentScaleMatrix; |
| 4421 const double initialParentScale = 1.75; | 4407 const double initialParentScale = 1.75; |
| 4422 parentScaleMatrix.scale(initialParentScale); | 4408 parentScaleMatrix.Scale(initialParentScale, initialParentScale); |
| 4423 | 4409 |
| 4424 WebTransformationMatrix childScaleMatrix; | 4410 gfx::Transform childScaleMatrix; |
| 4425 const double initialChildScale = 1.25; | 4411 const double initialChildScale = 1.25; |
| 4426 childScaleMatrix.scale(initialChildScale); | 4412 childScaleMatrix.Scale(initialChildScale, initialChildScale); |
| 4427 | 4413 |
| 4428 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); | 4414 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); |
| 4429 setLayerPropertiesForTesting(parent.get(), parentScaleMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); | 4415 setLayerPropertiesForTesting(parent.get(), parentScaleMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); |
| 4430 | 4416 |
| 4431 scoped_refptr<ContentLayer> childScale = createDrawableContentLayer(&delegat
e); | 4417 scoped_refptr<ContentLayer> childScale = createDrawableContentLayer(&delegat
e); |
| 4432 setLayerPropertiesForTesting(childScale.get(), childScaleMatrix, identityMat
rix, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); | 4418 setLayerPropertiesForTesting(childScale.get(), childScaleMatrix, identityMat
rix, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); |
| 4433 | 4419 |
| 4434 parent->addChild(childScale); | 4420 parent->addChild(childScale); |
| 4435 | 4421 |
| 4436 // Now put an animating transform on child. | 4422 // Now put an animating transform on child. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 4452 | 4438 |
| 4453 EXPECT_CONTENTS_SCALE_EQ(initialParentScale, parent); | 4439 EXPECT_CONTENTS_SCALE_EQ(initialParentScale, parent); |
| 4454 // The layers with animating transforms should not compute a contentsScale o
ther than 1 until they finish animating. | 4440 // The layers with animating transforms should not compute a contentsScale o
ther than 1 until they finish animating. |
| 4455 EXPECT_CONTENTS_SCALE_EQ(initialParentScale * initialChildScale, childScale)
; | 4441 EXPECT_CONTENTS_SCALE_EQ(initialParentScale * initialChildScale, childScale)
; |
| 4456 } | 4442 } |
| 4457 | 4443 |
| 4458 | 4444 |
| 4459 TEST(LayerTreeHostCommonTest, verifyRenderSurfaceTransformsInHighDPI) | 4445 TEST(LayerTreeHostCommonTest, verifyRenderSurfaceTransformsInHighDPI) |
| 4460 { | 4446 { |
| 4461 MockContentLayerClient delegate; | 4447 MockContentLayerClient delegate; |
| 4462 WebTransformationMatrix identityMatrix; | 4448 gfx::Transform identityMatrix; |
| 4463 | 4449 |
| 4464 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); | 4450 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); |
| 4465 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(30, 30), true); | 4451 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(30, 30), true); |
| 4466 | 4452 |
| 4467 scoped_refptr<ContentLayer> child = createDrawableContentLayer(&delegate); | 4453 scoped_refptr<ContentLayer> child = createDrawableContentLayer(&delegate); |
| 4468 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); | 4454 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); |
| 4469 | 4455 |
| 4470 WebTransformationMatrix replicaTransform; | 4456 gfx::Transform replicaTransform; |
| 4471 replicaTransform.scaleNonUniform(1, -1); | 4457 replicaTransform.Scale(1, -1); |
| 4472 scoped_refptr<ContentLayer> replica = createDrawableContentLayer(&delegate); | 4458 scoped_refptr<ContentLayer> replica = createDrawableContentLayer(&delegate); |
| 4473 setLayerPropertiesForTesting(replica.get(), replicaTransform, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); | 4459 setLayerPropertiesForTesting(replica.get(), replicaTransform, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); |
| 4474 | 4460 |
| 4475 // This layer should end up in the same surface as child, with the same draw | 4461 // This layer should end up in the same surface as child, with the same draw |
| 4476 // and screen space transforms. | 4462 // and screen space transforms. |
| 4477 scoped_refptr<ContentLayer> duplicateChildNonOwner = createDrawableContentLa
yer(&delegate); | 4463 scoped_refptr<ContentLayer> duplicateChildNonOwner = createDrawableContentLa
yer(&delegate); |
| 4478 setLayerPropertiesForTesting(duplicateChildNonOwner.get(), identityMatrix, i
dentityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), true); | 4464 setLayerPropertiesForTesting(duplicateChildNonOwner.get(), identityMatrix, i
dentityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), true); |
| 4479 | 4465 |
| 4480 parent->addChild(child); | 4466 parent->addChild(child); |
| 4481 child->addChild(duplicateChildNonOwner); | 4467 child->addChild(duplicateChildNonOwner); |
| 4482 child->setReplicaLayer(replica.get()); | 4468 child->setReplicaLayer(replica.get()); |
| 4483 | 4469 |
| 4484 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 4470 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
| 4485 int dummyMaxTextureSize = 512; | 4471 int dummyMaxTextureSize = 512; |
| 4486 | 4472 |
| 4487 const double deviceScaleFactor = 1.5; | 4473 const double deviceScaleFactor = 1.5; |
| 4488 parent->setContentsScale(deviceScaleFactor); | 4474 parent->setContentsScale(deviceScaleFactor); |
| 4489 child->setContentsScale(deviceScaleFactor); | 4475 child->setContentsScale(deviceScaleFactor); |
| 4490 duplicateChildNonOwner->setContentsScale(deviceScaleFactor); | 4476 duplicateChildNonOwner->setContentsScale(deviceScaleFactor); |
| 4491 replica->setContentsScale(deviceScaleFactor); | 4477 replica->setContentsScale(deviceScaleFactor); |
| 4492 | 4478 |
| 4493 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
deviceScaleFactor, 1, dummyMaxTextureSize, renderSurfaceLayerList); | 4479 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
deviceScaleFactor, 1, dummyMaxTextureSize, renderSurfaceLayerList); |
| 4494 | 4480 |
| 4495 // We should have two render surfaces. The root's render surface and child's | 4481 // We should have two render surfaces. The root's render surface and child's |
| 4496 // render surface (it needs one because it has a replica layer). | 4482 // render surface (it needs one because it has a replica layer). |
| 4497 EXPECT_EQ(2u, renderSurfaceLayerList.size()); | 4483 EXPECT_EQ(2u, renderSurfaceLayerList.size()); |
| 4498 | 4484 |
| 4499 WebTransformationMatrix expectedParentTransform; | 4485 gfx::Transform expectedParentTransform; |
| 4500 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpace
Transform()); | 4486 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpace
Transform()); |
| 4501 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->drawTransfo
rm()); | 4487 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->drawTransfo
rm()); |
| 4502 | 4488 |
| 4503 WebTransformationMatrix expectedDrawTransform; | 4489 gfx::Transform expectedDrawTransform; |
| 4504 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedDrawTransform, child->drawTransform(
)); | 4490 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedDrawTransform, child->drawTransform(
)); |
| 4505 | 4491 |
| 4506 WebTransformationMatrix expectedScreenSpaceTransform; | 4492 gfx::Transform expectedScreenSpaceTransform; |
| 4507 expectedScreenSpaceTransform.translate(deviceScaleFactor * child->position()
.x(), deviceScaleFactor * child->position().y()); | 4493 expectedScreenSpaceTransform.Translate(deviceScaleFactor * child->position()
.x(), deviceScaleFactor * child->position().y()); |
| 4508 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedScreenSpaceTransform, child->screenS
paceTransform()); | 4494 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedScreenSpaceTransform, child->screenS
paceTransform()); |
| 4509 | 4495 |
| 4510 WebTransformationMatrix expectedDuplicateChildDrawTransform = child->drawTra
nsform(); | 4496 gfx::Transform expectedDuplicateChildDrawTransform = child->drawTransform(); |
| 4511 EXPECT_TRANSFORMATION_MATRIX_EQ(child->drawTransform(), duplicateChildNonOwn
er->drawTransform()); | 4497 EXPECT_TRANSFORMATION_MATRIX_EQ(child->drawTransform(), duplicateChildNonOwn
er->drawTransform()); |
| 4512 EXPECT_TRANSFORMATION_MATRIX_EQ(child->screenSpaceTransform(), duplicateChil
dNonOwner->screenSpaceTransform()); | 4498 EXPECT_TRANSFORMATION_MATRIX_EQ(child->screenSpaceTransform(), duplicateChil
dNonOwner->screenSpaceTransform()); |
| 4513 EXPECT_RECT_EQ(child->drawableContentRect(), duplicateChildNonOwner->drawabl
eContentRect()); | 4499 EXPECT_RECT_EQ(child->drawableContentRect(), duplicateChildNonOwner->drawabl
eContentRect()); |
| 4514 EXPECT_EQ(child->contentBounds(), duplicateChildNonOwner->contentBounds()); | 4500 EXPECT_EQ(child->contentBounds(), duplicateChildNonOwner->contentBounds()); |
| 4515 | 4501 |
| 4516 WebTransformationMatrix expectedRenderSurfaceDrawTransform; | 4502 gfx::Transform expectedRenderSurfaceDrawTransform; |
| 4517 expectedRenderSurfaceDrawTransform.translate(deviceScaleFactor * child->posi
tion().x(), deviceScaleFactor * child->position().y()); | 4503 expectedRenderSurfaceDrawTransform.Translate(deviceScaleFactor * child->posi
tion().x(), deviceScaleFactor * child->position().y()); |
| 4518 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedRenderSurfaceDrawTransform, child->r
enderSurface()->drawTransform()); | 4504 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedRenderSurfaceDrawTransform, child->r
enderSurface()->drawTransform()); |
| 4519 | 4505 |
| 4520 WebTransformationMatrix expectedSurfaceDrawTransform; | 4506 gfx::Transform expectedSurfaceDrawTransform; |
| 4521 expectedSurfaceDrawTransform.translate(deviceScaleFactor * 2, deviceScaleFac
tor * 2); | 4507 expectedSurfaceDrawTransform.Translate(deviceScaleFactor * 2, deviceScaleFac
tor * 2); |
| 4522 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, child->renderS
urface()->drawTransform()); | 4508 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, child->renderS
urface()->drawTransform()); |
| 4523 | 4509 |
| 4524 WebTransformationMatrix expectedSurfaceScreenSpaceTransform; | 4510 gfx::Transform expectedSurfaceScreenSpaceTransform; |
| 4525 expectedSurfaceScreenSpaceTransform.translate(deviceScaleFactor * 2, deviceS
caleFactor * 2); | 4511 expectedSurfaceScreenSpaceTransform.Translate(deviceScaleFactor * 2, deviceS
caleFactor * 2); |
| 4526 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceScreenSpaceTransform, child->
renderSurface()->screenSpaceTransform()); | 4512 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceScreenSpaceTransform, child->
renderSurface()->screenSpaceTransform()); |
| 4527 | 4513 |
| 4528 WebTransformationMatrix expectedReplicaDrawTransform; | 4514 gfx::Transform expectedReplicaDrawTransform; |
| 4529 expectedReplicaDrawTransform.setM22(-1); | 4515 expectedReplicaDrawTransform.matrix().setDouble(1, 1, -1); |
| 4530 expectedReplicaDrawTransform.setM41(6); | 4516 expectedReplicaDrawTransform.matrix().setDouble(0, 3, 6); |
| 4531 expectedReplicaDrawTransform.setM42(6); | 4517 expectedReplicaDrawTransform.matrix().setDouble(1, 3, 6); |
| 4532 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedReplicaDrawTransform, child->renderS
urface()->replicaDrawTransform()); | 4518 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedReplicaDrawTransform, child->renderS
urface()->replicaDrawTransform()); |
| 4533 | 4519 |
| 4534 WebTransformationMatrix expectedReplicaScreenSpaceTransform; | 4520 gfx::Transform expectedReplicaScreenSpaceTransform; |
| 4535 expectedReplicaScreenSpaceTransform.setM22(-1); | 4521 expectedReplicaScreenSpaceTransform.matrix().setDouble(1, 1, -1); |
| 4536 expectedReplicaScreenSpaceTransform.setM41(6); | 4522 expectedReplicaScreenSpaceTransform.matrix().setDouble(0, 3, 6); |
| 4537 expectedReplicaScreenSpaceTransform.setM42(6); | 4523 expectedReplicaScreenSpaceTransform.matrix().setDouble(1, 3, 6); |
| 4538 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedReplicaScreenSpaceTransform, child->
renderSurface()->replicaScreenSpaceTransform()); | 4524 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedReplicaScreenSpaceTransform, child->
renderSurface()->replicaScreenSpaceTransform()); |
| 4539 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedReplicaScreenSpaceTransform, child->
renderSurface()->replicaScreenSpaceTransform()); | 4525 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedReplicaScreenSpaceTransform, child->
renderSurface()->replicaScreenSpaceTransform()); |
| 4540 } | 4526 } |
| 4541 | 4527 |
| 4542 TEST(LayerTreeHostCommonTest, verifyRenderSurfaceTransformsInHighDPIAccurateScal
eZeroPosition) | 4528 TEST(LayerTreeHostCommonTest, verifyRenderSurfaceTransformsInHighDPIAccurateScal
eZeroPosition) |
| 4543 { | 4529 { |
| 4544 MockContentLayerClient delegate; | 4530 MockContentLayerClient delegate; |
| 4545 WebTransformationMatrix identityMatrix; | 4531 gfx::Transform identityMatrix; |
| 4546 | 4532 |
| 4547 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); | 4533 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); |
| 4548 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(33, 31), true); | 4534 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(33, 31), true); |
| 4549 | 4535 |
| 4550 scoped_refptr<ContentLayer> child = createDrawableContentLayer(&delegate); | 4536 scoped_refptr<ContentLayer> child = createDrawableContentLayer(&delegate); |
| 4551 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(13, 11), true); | 4537 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(13, 11), true); |
| 4552 | 4538 |
| 4553 WebTransformationMatrix replicaTransform; | 4539 gfx::Transform replicaTransform; |
| 4554 replicaTransform.scaleNonUniform(1, -1); | 4540 replicaTransform.Scale(1, -1); |
| 4555 scoped_refptr<ContentLayer> replica = createDrawableContentLayer(&delegate); | 4541 scoped_refptr<ContentLayer> replica = createDrawableContentLayer(&delegate); |
| 4556 setLayerPropertiesForTesting(replica.get(), replicaTransform, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(13, 11), true); | 4542 setLayerPropertiesForTesting(replica.get(), replicaTransform, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(13, 11), true); |
| 4557 | 4543 |
| 4558 // This layer should end up in the same surface as child, with the same draw | 4544 // This layer should end up in the same surface as child, with the same draw |
| 4559 // and screen space transforms. | 4545 // and screen space transforms. |
| 4560 scoped_refptr<ContentLayer> duplicateChildNonOwner = createDrawableContentLa
yer(&delegate); | 4546 scoped_refptr<ContentLayer> duplicateChildNonOwner = createDrawableContentLa
yer(&delegate); |
| 4561 setLayerPropertiesForTesting(duplicateChildNonOwner.get(), identityMatrix, i
dentityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(13, 11), true); | 4547 setLayerPropertiesForTesting(duplicateChildNonOwner.get(), identityMatrix, i
dentityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(13, 11), true); |
| 4562 | 4548 |
| 4563 parent->addChild(child); | 4549 parent->addChild(child); |
| 4564 child->addChild(duplicateChildNonOwner); | 4550 child->addChild(duplicateChildNonOwner); |
| 4565 child->setReplicaLayer(replica.get()); | 4551 child->setReplicaLayer(replica.get()); |
| 4566 | 4552 |
| 4567 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 4553 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
| 4568 int dummyMaxTextureSize = 512; | 4554 int dummyMaxTextureSize = 512; |
| 4569 | 4555 |
| 4570 const float deviceScaleFactor = 1.7f; | 4556 const float deviceScaleFactor = 1.7f; |
| 4571 parent->setContentsScale(deviceScaleFactor); | 4557 parent->setContentsScale(deviceScaleFactor); |
| 4572 child->setContentsScale(deviceScaleFactor); | 4558 child->setContentsScale(deviceScaleFactor); |
| 4573 duplicateChildNonOwner->setContentsScale(deviceScaleFactor); | 4559 duplicateChildNonOwner->setContentsScale(deviceScaleFactor); |
| 4574 replica->setContentsScale(deviceScaleFactor); | 4560 replica->setContentsScale(deviceScaleFactor); |
| 4575 | 4561 |
| 4576 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
deviceScaleFactor, 1, dummyMaxTextureSize, renderSurfaceLayerList); | 4562 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
deviceScaleFactor, 1, dummyMaxTextureSize, renderSurfaceLayerList); |
| 4577 | 4563 |
| 4578 // We should have two render surfaces. The root's render surface and child's | 4564 // We should have two render surfaces. The root's render surface and child's |
| 4579 // render surface (it needs one because it has a replica layer). | 4565 // render surface (it needs one because it has a replica layer). |
| 4580 EXPECT_EQ(2u, renderSurfaceLayerList.size()); | 4566 EXPECT_EQ(2u, renderSurfaceLayerList.size()); |
| 4581 | 4567 |
| 4582 WebTransformationMatrix identityTransform; | 4568 gfx::Transform identityTransform; |
| 4583 | 4569 |
| 4584 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, parent->screenSpaceTransf
orm()); | 4570 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, parent->screenSpaceTransf
orm()); |
| 4585 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, parent->drawTransform()); | 4571 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, parent->drawTransform()); |
| 4586 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, child->drawTransform()); | 4572 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, child->drawTransform()); |
| 4587 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, child->screenSpaceTransfo
rm()); | 4573 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, child->screenSpaceTransfo
rm()); |
| 4588 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, duplicateChildNonOwner->d
rawTransform()); | 4574 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, duplicateChildNonOwner->d
rawTransform()); |
| 4589 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, duplicateChildNonOwner->s
creenSpaceTransform()); | 4575 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, duplicateChildNonOwner->s
creenSpaceTransform()); |
| 4590 EXPECT_RECT_EQ(child->drawableContentRect(), duplicateChildNonOwner->drawabl
eContentRect()); | 4576 EXPECT_RECT_EQ(child->drawableContentRect(), duplicateChildNonOwner->drawabl
eContentRect()); |
| 4591 EXPECT_EQ(child->contentBounds(), duplicateChildNonOwner->contentBounds()); | 4577 EXPECT_EQ(child->contentBounds(), duplicateChildNonOwner->contentBounds()); |
| 4592 | 4578 |
| 4593 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, child->renderSurface()->d
rawTransform()); | 4579 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, child->renderSurface()->d
rawTransform()); |
| 4594 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, child->renderSurface()->d
rawTransform()); | 4580 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, child->renderSurface()->d
rawTransform()); |
| 4595 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, child->renderSurface()->s
creenSpaceTransform()); | 4581 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, child->renderSurface()->s
creenSpaceTransform()); |
| 4596 | 4582 |
| 4597 WebTransformationMatrix expectedReplicaDrawTransform; | 4583 gfx::Transform expectedReplicaDrawTransform; |
| 4598 expectedReplicaDrawTransform.setM22(-1); | 4584 expectedReplicaDrawTransform.matrix().setDouble(1, 1, -1); |
| 4599 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedReplicaDrawTransform, child->renderS
urface()->replicaDrawTransform()); | 4585 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedReplicaDrawTransform, child->renderS
urface()->replicaDrawTransform()); |
| 4600 | 4586 |
| 4601 WebTransformationMatrix expectedReplicaScreenSpaceTransform; | 4587 gfx::Transform expectedReplicaScreenSpaceTransform; |
| 4602 expectedReplicaScreenSpaceTransform.setM22(-1); | 4588 expectedReplicaScreenSpaceTransform.matrix().setDouble(1, 1, -1); |
| 4603 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedReplicaScreenSpaceTransform, child->
renderSurface()->replicaScreenSpaceTransform()); | 4589 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedReplicaScreenSpaceTransform, child->
renderSurface()->replicaScreenSpaceTransform()); |
| 4604 } | 4590 } |
| 4605 | 4591 |
| 4606 TEST(LayerTreeHostCommonTest, verifySubtreeSearch) | 4592 TEST(LayerTreeHostCommonTest, verifySubtreeSearch) |
| 4607 { | 4593 { |
| 4608 scoped_refptr<Layer> root = Layer::create(); | 4594 scoped_refptr<Layer> root = Layer::create(); |
| 4609 scoped_refptr<Layer> child = Layer::create(); | 4595 scoped_refptr<Layer> child = Layer::create(); |
| 4610 scoped_refptr<Layer> grandChild = Layer::create(); | 4596 scoped_refptr<Layer> grandChild = Layer::create(); |
| 4611 scoped_refptr<Layer> maskLayer = Layer::create(); | 4597 scoped_refptr<Layer> maskLayer = Layer::create(); |
| 4612 scoped_refptr<Layer> replicaLayer = Layer::create(); | 4598 scoped_refptr<Layer> replicaLayer = Layer::create(); |
| 4613 | 4599 |
| 4614 grandChild->setReplicaLayer(replicaLayer.get()); | 4600 grandChild->setReplicaLayer(replicaLayer.get()); |
| 4615 child->addChild(grandChild.get()); | 4601 child->addChild(grandChild.get()); |
| 4616 child->setMaskLayer(maskLayer.get()); | 4602 child->setMaskLayer(maskLayer.get()); |
| 4617 root->addChild(child.get()); | 4603 root->addChild(child.get()); |
| 4618 | 4604 |
| 4619 int nonexistentId = -1; | 4605 int nonexistentId = -1; |
| 4620 EXPECT_EQ(root, LayerTreeHostCommon::findLayerInSubtree(root.get(), root->id
())); | 4606 EXPECT_EQ(root, LayerTreeHostCommon::findLayerInSubtree(root.get(), root->id
())); |
| 4621 EXPECT_EQ(child, LayerTreeHostCommon::findLayerInSubtree(root.get(), child->
id())); | 4607 EXPECT_EQ(child, LayerTreeHostCommon::findLayerInSubtree(root.get(), child->
id())); |
| 4622 EXPECT_EQ(grandChild, LayerTreeHostCommon::findLayerInSubtree(root.get(), gr
andChild->id())); | 4608 EXPECT_EQ(grandChild, LayerTreeHostCommon::findLayerInSubtree(root.get(), gr
andChild->id())); |
| 4623 EXPECT_EQ(maskLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), mas
kLayer->id())); | 4609 EXPECT_EQ(maskLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), mas
kLayer->id())); |
| 4624 EXPECT_EQ(replicaLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(),
replicaLayer->id())); | 4610 EXPECT_EQ(replicaLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(),
replicaLayer->id())); |
| 4625 EXPECT_EQ(0, LayerTreeHostCommon::findLayerInSubtree(root.get(), nonexistent
Id)); | 4611 EXPECT_EQ(0, LayerTreeHostCommon::findLayerInSubtree(root.get(), nonexistent
Id)); |
| 4626 } | 4612 } |
| 4627 | 4613 |
| 4628 } // namespace | 4614 } // namespace |
| 4629 } // namespace cc | 4615 } // namespace cc |
| OLD | NEW |