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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "CCLayerTreeHostCommon.h" | 7 #include "CCLayerTreeHostCommon.h" |
8 | 8 |
9 #include "CCLayerAnimationController.h" | 9 #include "CCLayerAnimationController.h" |
10 #include "CCLayerImpl.h" | 10 #include "CCLayerImpl.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 void setLayerPropertiesForTesting(LayerType* layer, const WebTransformationMatri
x& transform, const WebTransformationMatrix& sublayerTransform, const FloatPoint
& anchor, const FloatPoint& position, const IntSize& bounds, bool preserves3D) | 32 void setLayerPropertiesForTesting(LayerType* layer, const WebTransformationMatri
x& transform, const WebTransformationMatrix& sublayerTransform, const FloatPoint
& anchor, const FloatPoint& position, const IntSize& bounds, bool preserves3D) |
33 { | 33 { |
34 layer->setTransform(transform); | 34 layer->setTransform(transform); |
35 layer->setSublayerTransform(sublayerTransform); | 35 layer->setSublayerTransform(sublayerTransform); |
36 layer->setAnchorPoint(anchor); | 36 layer->setAnchorPoint(anchor); |
37 layer->setPosition(position); | 37 layer->setPosition(position); |
38 layer->setBounds(bounds); | 38 layer->setBounds(bounds); |
39 layer->setPreserves3D(preserves3D); | 39 layer->setPreserves3D(preserves3D); |
40 } | 40 } |
41 | 41 |
42 void setLayerPropertiesForTesting(LayerChromium* layer, const WebTransformationM
atrix& transform, const WebTransformationMatrix& sublayerTransform, const FloatP
oint& anchor, const FloatPoint& position, const IntSize& bounds, bool preserves3
D) | 42 void setLayerPropertiesForTesting(Layer* layer, const WebTransformationMatrix& t
ransform, const WebTransformationMatrix& sublayerTransform, const FloatPoint& an
chor, const FloatPoint& position, const IntSize& bounds, bool preserves3D) |
43 { | 43 { |
44 setLayerPropertiesForTesting<LayerChromium>(layer, transform, sublayerTransf
orm, anchor, position, bounds, preserves3D); | 44 setLayerPropertiesForTesting<Layer>(layer, transform, sublayerTransform, anc
hor, position, bounds, preserves3D); |
45 } | 45 } |
46 | 46 |
47 void setLayerPropertiesForTesting(CCLayerImpl* layer, const WebTransformationMat
rix& transform, const WebTransformationMatrix& sublayerTransform, const FloatPoi
nt& anchor, const FloatPoint& position, const IntSize& bounds, bool preserves3D) | 47 void setLayerPropertiesForTesting(LayerImpl* layer, const WebTransformationMatri
x& transform, const WebTransformationMatrix& sublayerTransform, const FloatPoint
& anchor, const FloatPoint& position, const IntSize& bounds, bool preserves3D) |
48 { | 48 { |
49 setLayerPropertiesForTesting<CCLayerImpl>(layer, transform, sublayerTransfor
m, anchor, position, bounds, preserves3D); | 49 setLayerPropertiesForTesting<LayerImpl>(layer, transform, sublayerTransform,
anchor, position, bounds, preserves3D); |
50 layer->setContentBounds(bounds); | 50 layer->setContentBounds(bounds); |
51 } | 51 } |
52 | 52 |
53 void executeCalculateDrawTransformsAndVisibility(LayerChromium* rootLayer, float
deviceScaleFactor = 1) | 53 void executeCalculateDrawTransformsAndVisibility(Layer* rootLayer, float deviceS
caleFactor = 1) |
54 { | 54 { |
55 WebTransformationMatrix identityMatrix; | 55 WebTransformationMatrix identityMatrix; |
56 std::vector<scoped_refptr<LayerChromium> > dummyRenderSurfaceLayerList; | 56 std::vector<scoped_refptr<Layer> > dummyRenderSurfaceLayerList; |
57 int dummyMaxTextureSize = 512; | 57 int dummyMaxTextureSize = 512; |
58 IntSize deviceViewportSize = IntSize(rootLayer->bounds().width() * deviceSca
leFactor, rootLayer->bounds().height() * deviceScaleFactor); | 58 IntSize deviceViewportSize = IntSize(rootLayer->bounds().width() * deviceSca
leFactor, rootLayer->bounds().height() * deviceScaleFactor); |
59 | 59 |
60 // We are probably not testing what is intended if the rootLayer bounds are
empty. | 60 // We are probably not testing what is intended if the rootLayer bounds are
empty. |
61 ASSERT(!rootLayer->bounds().isEmpty()); | 61 ASSERT(!rootLayer->bounds().isEmpty()); |
62 CCLayerTreeHostCommon::calculateDrawTransforms(rootLayer, deviceViewportSize
, deviceScaleFactor, dummyMaxTextureSize, dummyRenderSurfaceLayerList); | 62 LayerTreeHostCommon::calculateDrawTransforms(rootLayer, deviceViewportSize,
deviceScaleFactor, dummyMaxTextureSize, dummyRenderSurfaceLayerList); |
63 } | 63 } |
64 | 64 |
65 void executeCalculateDrawTransformsAndVisibility(CCLayerImpl* rootLayer, float d
eviceScaleFactor = 1) | 65 void executeCalculateDrawTransformsAndVisibility(LayerImpl* rootLayer, float dev
iceScaleFactor = 1) |
66 { | 66 { |
67 // Note: this version skips layer sorting. | 67 // Note: this version skips layer sorting. |
68 | 68 |
69 WebTransformationMatrix identityMatrix; | 69 WebTransformationMatrix identityMatrix; |
70 std::vector<CCLayerImpl*> dummyRenderSurfaceLayerList; | 70 std::vector<LayerImpl*> dummyRenderSurfaceLayerList; |
71 int dummyMaxTextureSize = 512; | 71 int dummyMaxTextureSize = 512; |
72 IntSize deviceViewportSize = IntSize(rootLayer->bounds().width() * deviceSca
leFactor, rootLayer->bounds().height() * deviceScaleFactor); | 72 IntSize deviceViewportSize = IntSize(rootLayer->bounds().width() * deviceSca
leFactor, rootLayer->bounds().height() * deviceScaleFactor); |
73 | 73 |
74 // We are probably not testing what is intended if the rootLayer bounds are
empty. | 74 // We are probably not testing what is intended if the rootLayer bounds are
empty. |
75 ASSERT(!rootLayer->bounds().isEmpty()); | 75 ASSERT(!rootLayer->bounds().isEmpty()); |
76 CCLayerTreeHostCommon::calculateDrawTransforms(rootLayer, deviceViewportSize
, deviceScaleFactor, 0, dummyMaxTextureSize, dummyRenderSurfaceLayerList); | 76 LayerTreeHostCommon::calculateDrawTransforms(rootLayer, deviceViewportSize,
deviceScaleFactor, 0, dummyMaxTextureSize, dummyRenderSurfaceLayerList); |
77 } | 77 } |
78 | 78 |
79 WebTransformationMatrix remove3DComponentOfMatrix(const WebTransformationMatrix&
mat) | 79 WebTransformationMatrix remove3DComponentOfMatrix(const WebTransformationMatrix&
mat) |
80 { | 80 { |
81 WebTransformationMatrix ret = mat; | 81 WebTransformationMatrix ret = mat; |
82 ret.setM13(0); | 82 ret.setM13(0); |
83 ret.setM23(0); | 83 ret.setM23(0); |
84 ret.setM31(0); | 84 ret.setM31(0); |
85 ret.setM32(0); | 85 ret.setM32(0); |
86 ret.setM33(1); | 86 ret.setM33(1); |
87 ret.setM34(0); | 87 ret.setM34(0); |
88 ret.setM43(0); | 88 ret.setM43(0); |
89 return ret; | 89 return ret; |
90 } | 90 } |
91 | 91 |
92 scoped_ptr<CCLayerImpl> createTreeForFixedPositionTests() | 92 scoped_ptr<LayerImpl> createTreeForFixedPositionTests() |
93 { | 93 { |
94 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); | 94 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
95 scoped_ptr<CCLayerImpl> child = CCLayerImpl::create(2); | 95 scoped_ptr<LayerImpl> child = LayerImpl::create(2); |
96 scoped_ptr<CCLayerImpl> grandChild = CCLayerImpl::create(3); | 96 scoped_ptr<LayerImpl> grandChild = LayerImpl::create(3); |
97 scoped_ptr<CCLayerImpl> greatGrandChild = CCLayerImpl::create(4); | 97 scoped_ptr<LayerImpl> greatGrandChild = LayerImpl::create(4); |
98 | 98 |
99 WebTransformationMatrix IdentityMatrix; | 99 WebTransformationMatrix IdentityMatrix; |
100 FloatPoint anchor(0, 0); | 100 FloatPoint anchor(0, 0); |
101 FloatPoint position(0, 0); | 101 FloatPoint position(0, 0); |
102 IntSize bounds(100, 100); | 102 IntSize bounds(100, 100); |
103 setLayerPropertiesForTesting(root.get(), IdentityMatrix, IdentityMatrix, anc
hor, position, bounds, false); | 103 setLayerPropertiesForTesting(root.get(), IdentityMatrix, IdentityMatrix, anc
hor, position, bounds, false); |
104 setLayerPropertiesForTesting(child.get(), IdentityMatrix, IdentityMatrix, an
chor, position, bounds, false); | 104 setLayerPropertiesForTesting(child.get(), IdentityMatrix, IdentityMatrix, an
chor, position, bounds, false); |
105 setLayerPropertiesForTesting(grandChild.get(), IdentityMatrix, IdentityMatri
x, anchor, position, bounds, false); | 105 setLayerPropertiesForTesting(grandChild.get(), IdentityMatrix, IdentityMatri
x, anchor, position, bounds, false); |
106 setLayerPropertiesForTesting(greatGrandChild.get(), IdentityMatrix, Identity
Matrix, anchor, position, bounds, false); | 106 setLayerPropertiesForTesting(greatGrandChild.get(), IdentityMatrix, Identity
Matrix, anchor, position, bounds, false); |
107 | 107 |
108 grandChild->addChild(greatGrandChild.Pass()); | 108 grandChild->addChild(greatGrandChild.Pass()); |
109 child->addChild(grandChild.Pass()); | 109 child->addChild(grandChild.Pass()); |
110 root->addChild(child.Pass()); | 110 root->addChild(child.Pass()); |
111 | 111 |
112 return root.Pass(); | 112 return root.Pass(); |
113 } | 113 } |
114 | 114 |
115 class LayerChromiumWithForcedDrawsContent : public LayerChromium { | 115 class LayerWithForcedDrawsContent : public Layer { |
116 public: | 116 public: |
117 LayerChromiumWithForcedDrawsContent() | 117 LayerWithForcedDrawsContent() |
118 : LayerChromium() | 118 : Layer() |
119 { | 119 { |
120 } | 120 } |
121 | 121 |
122 virtual bool drawsContent() const OVERRIDE { return true; } | 122 virtual bool drawsContent() const OVERRIDE { return true; } |
123 | 123 |
124 private: | 124 private: |
125 virtual ~LayerChromiumWithForcedDrawsContent() | 125 virtual ~LayerWithForcedDrawsContent() |
126 { | 126 { |
127 } | 127 } |
128 }; | 128 }; |
129 | 129 |
130 class MockContentLayerChromiumClient : public ContentLayerChromiumClient { | 130 class MockContentLayerClient : public ContentLayerClient { |
131 public: | 131 public: |
132 MockContentLayerChromiumClient() { } | 132 MockContentLayerClient() { } |
133 virtual ~MockContentLayerChromiumClient() { } | 133 virtual ~MockContentLayerClient() { } |
134 virtual void paintContents(SkCanvas*, const IntRect& clip, FloatRect& opaque
) OVERRIDE { } | 134 virtual void paintContents(SkCanvas*, const IntRect& clip, FloatRect& opaque
) OVERRIDE { } |
135 }; | 135 }; |
136 | 136 |
137 scoped_refptr<ContentLayerChromium> createDrawableContentLayerChromium(ContentLa
yerChromiumClient* delegate) | 137 scoped_refptr<ContentLayer> createDrawableContentLayer(ContentLayerClient* deleg
ate) |
138 { | 138 { |
139 scoped_refptr<ContentLayerChromium> toReturn = ContentLayerChromium::create(
delegate); | 139 scoped_refptr<ContentLayer> toReturn = ContentLayer::create(delegate); |
140 toReturn->setIsDrawable(true); | 140 toReturn->setIsDrawable(true); |
141 return toReturn; | 141 return toReturn; |
142 } | 142 } |
143 | 143 |
144 TEST(CCLayerTreeHostCommonTest, verifyTransformsForNoOpLayer) | 144 TEST(LayerTreeHostCommonTest, verifyTransformsForNoOpLayer) |
145 { | 145 { |
146 // Sanity check: For layers positioned at zero, with zero size, | 146 // Sanity check: For layers positioned at zero, with zero size, |
147 // and with identity transforms, then the drawTransform, | 147 // and with identity transforms, then the drawTransform, |
148 // screenSpaceTransform, and the hierarchy passed on to children | 148 // screenSpaceTransform, and the hierarchy passed on to children |
149 // layers should also be identity transforms. | 149 // layers should also be identity transforms. |
150 | 150 |
151 scoped_refptr<LayerChromium> parent = LayerChromium::create(); | 151 scoped_refptr<Layer> parent = Layer::create(); |
152 scoped_refptr<LayerChromium> child = LayerChromium::create(); | 152 scoped_refptr<Layer> child = Layer::create(); |
153 scoped_refptr<LayerChromium> grandChild = LayerChromium::create(); | 153 scoped_refptr<Layer> grandChild = Layer::create(); |
154 parent->addChild(child); | 154 parent->addChild(child); |
155 child->addChild(grandChild); | 155 child->addChild(grandChild); |
156 | 156 |
157 WebTransformationMatrix identityMatrix; | 157 WebTransformationMatrix identityMatrix; |
158 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 158 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
159 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint(0, 0), FloatPoint(0, 0), IntSize(0, 0), false); | 159 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint(0, 0), FloatPoint(0, 0), IntSize(0, 0), false); |
160 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(0, 0), false); | 160 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(0, 0), false); |
161 | 161 |
162 executeCalculateDrawTransformsAndVisibility(parent.get()); | 162 executeCalculateDrawTransformsAndVisibility(parent.get()); |
163 | 163 |
164 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); | 164 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); |
165 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->screenSpaceTransform(
)); | 165 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->screenSpaceTransform(
)); |
166 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->drawTransform())
; | 166 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->drawTransform())
; |
167 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->screenSpaceTrans
form()); | 167 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->screenSpaceTrans
form()); |
168 } | 168 } |
169 | 169 |
170 TEST(CCLayerTreeHostCommonTest, verifyTransformsForSingleLayer) | 170 TEST(LayerTreeHostCommonTest, verifyTransformsForSingleLayer) |
171 { | 171 { |
172 WebTransformationMatrix identityMatrix; | 172 WebTransformationMatrix identityMatrix; |
173 scoped_refptr<LayerChromium> layer = LayerChromium::create(); | 173 scoped_refptr<Layer> layer = Layer::create(); |
174 | 174 |
175 // Case 1: setting the sublayer transform should not affect this layer's dra
w transform or screen-space transform. | 175 // Case 1: setting the sublayer transform should not affect this layer's dra
w transform or screen-space transform. |
176 WebTransformationMatrix arbitraryTranslation; | 176 WebTransformationMatrix arbitraryTranslation; |
177 arbitraryTranslation.translate(10, 20); | 177 arbitraryTranslation.translate(10, 20); |
178 setLayerPropertiesForTesting(layer.get(), identityMatrix, arbitraryTranslati
on, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 178 setLayerPropertiesForTesting(layer.get(), identityMatrix, arbitraryTranslati
on, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
179 executeCalculateDrawTransformsAndVisibility(layer.get()); | 179 executeCalculateDrawTransformsAndVisibility(layer.get()); |
180 WebTransformationMatrix expectedDrawTransform = identityMatrix; | 180 WebTransformationMatrix expectedDrawTransform = identityMatrix; |
181 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedDrawTransform, layer->drawTransform(
)); | 181 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedDrawTransform, layer->drawTransform(
)); |
182 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, layer->screenSpaceTransform(
)); | 182 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, layer->screenSpaceTransform(
)); |
183 | 183 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 // Case 7: Verify that position pre-multiplies the layer transform. | 224 // Case 7: Verify that position pre-multiplies the layer transform. |
225 // The current implementation of calculateDrawTransforms does this i
mplicitly, but it is | 225 // The current implementation of calculateDrawTransforms does this i
mplicitly, but it is |
226 // still worth testing to detect accidental regressions. | 226 // still worth testing to detect accidental regressions. |
227 expectedResult = positionTransform * translationToAnchor * layerTransform *
translationToAnchor.inverse(); | 227 expectedResult = positionTransform * translationToAnchor * layerTransform *
translationToAnchor.inverse(); |
228 setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, Fl
oatPoint(0.5, 0), FloatPoint(0, 1.2f), IntSize(10, 12), false); | 228 setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, Fl
oatPoint(0.5, 0), FloatPoint(0, 1.2f), IntSize(10, 12), false); |
229 executeCalculateDrawTransformsAndVisibility(layer.get()); | 229 executeCalculateDrawTransformsAndVisibility(layer.get()); |
230 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->drawTransform()); | 230 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->drawTransform()); |
231 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->screenSpaceTransform(
)); | 231 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->screenSpaceTransform(
)); |
232 } | 232 } |
233 | 233 |
234 TEST(CCLayerTreeHostCommonTest, verifyTransformsForSimpleHierarchy) | 234 TEST(LayerTreeHostCommonTest, verifyTransformsForSimpleHierarchy) |
235 { | 235 { |
236 WebTransformationMatrix identityMatrix; | 236 WebTransformationMatrix identityMatrix; |
237 scoped_refptr<LayerChromium> parent = LayerChromium::create(); | 237 scoped_refptr<Layer> parent = Layer::create(); |
238 scoped_refptr<LayerChromium> child = LayerChromium::create(); | 238 scoped_refptr<Layer> child = Layer::create(); |
239 scoped_refptr<LayerChromium> grandChild = LayerChromium::create(); | 239 scoped_refptr<Layer> grandChild = Layer::create(); |
240 parent->addChild(child); | 240 parent->addChild(child); |
241 child->addChild(grandChild); | 241 child->addChild(grandChild); |
242 | 242 |
243 // Case 1: parent's anchorPoint should not affect child or grandChild. | 243 // Case 1: parent's anchorPoint should not affect child or grandChild. |
244 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, F
loatPoint(0.25, 0.25), FloatPoint(0, 0), IntSize(10, 12), false); | 244 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, F
loatPoint(0.25, 0.25), FloatPoint(0, 0), IntSize(10, 12), false); |
245 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint(0, 0), FloatPoint(0, 0), IntSize(16, 18), false); | 245 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint(0, 0), FloatPoint(0, 0), IntSize(16, 18), false); |
246 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(76, 78), false); | 246 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(76, 78), false); |
247 executeCalculateDrawTransformsAndVisibility(parent.get()); | 247 executeCalculateDrawTransformsAndVisibility(parent.get()); |
248 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); | 248 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); |
249 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->screenSpaceTransform(
)); | 249 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->screenSpaceTransform(
)); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSubla
yerMatrix, FloatPoint(0.25, 0.25), FloatPoint(0, 0), IntSize(10, 12), false); | 303 setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSubla
yerMatrix, FloatPoint(0.25, 0.25), FloatPoint(0, 0), IntSize(10, 12), false); |
304 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint(0, 0), FloatPoint(0, 0), IntSize(16, 18), true); | 304 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint(0, 0), FloatPoint(0, 0), IntSize(16, 18), true); |
305 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(76, 78), false); | 305 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(76, 78), false); |
306 executeCalculateDrawTransformsAndVisibility(parent.get()); | 306 executeCalculateDrawTransformsAndVisibility(parent.get()); |
307 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->drawTransfo
rm()); | 307 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->drawTransfo
rm()); |
308 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->screenSpace
Transform()); | 308 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->screenSpace
Transform()); |
309 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, grandChild->drawTr
ansform()); | 309 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, grandChild->drawTr
ansform()); |
310 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, grandChild->screen
SpaceTransform()); | 310 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, grandChild->screen
SpaceTransform()); |
311 } | 311 } |
312 | 312 |
313 TEST(CCLayerTreeHostCommonTest, verifyTransformsForSingleRenderSurface) | 313 TEST(LayerTreeHostCommonTest, verifyTransformsForSingleRenderSurface) |
314 { | 314 { |
315 scoped_refptr<LayerChromium> parent = LayerChromium::create(); | 315 scoped_refptr<Layer> parent = Layer::create(); |
316 scoped_refptr<LayerChromium> child = LayerChromium::create(); | 316 scoped_refptr<Layer> child = Layer::create(); |
317 scoped_refptr<LayerChromiumWithForcedDrawsContent> grandChild = make_scoped_
refptr(new LayerChromiumWithForcedDrawsContent()); | 317 scoped_refptr<LayerWithForcedDrawsContent> grandChild = make_scoped_refptr(n
ew LayerWithForcedDrawsContent()); |
318 parent->addChild(child); | 318 parent->addChild(child); |
319 child->addChild(grandChild); | 319 child->addChild(grandChild); |
320 | 320 |
321 // Child is set up so that a new render surface should be created. | 321 // Child is set up so that a new render surface should be created. |
322 child->setOpacity(0.5); | 322 child->setOpacity(0.5); |
323 | 323 |
324 WebTransformationMatrix identityMatrix; | 324 WebTransformationMatrix identityMatrix; |
325 WebTransformationMatrix parentLayerTransform; | 325 WebTransformationMatrix parentLayerTransform; |
326 parentLayerTransform.scale3d(1, 0.9, 1); | 326 parentLayerTransform.scale3d(1, 0.9, 1); |
327 WebTransformationMatrix parentTranslationToAnchor; | 327 WebTransformationMatrix parentTranslationToAnchor; |
(...skipping 22 matching lines...) Expand all Loading... |
350 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); | 350 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); |
351 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->screenSpace
Transform()); | 351 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->screenSpace
Transform()); |
352 | 352 |
353 // Because the grandChild is the only drawable content, the child's renderSu
rface will tighten its bounds to the grandChild. | 353 // Because the grandChild is the only drawable content, the child's renderSu
rface will tighten its bounds to the grandChild. |
354 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->renderTarge
t()->renderSurface()->drawTransform()); | 354 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->renderTarge
t()->renderSurface()->drawTransform()); |
355 | 355 |
356 // The screen space is the same as the target since the child surface draws
into the root. | 356 // The screen space is the same as the target since the child surface draws
into the root. |
357 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->renderTarge
t()->renderSurface()->screenSpaceTransform()); | 357 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->renderTarge
t()->renderSurface()->screenSpaceTransform()); |
358 } | 358 } |
359 | 359 |
360 TEST(CCLayerTreeHostCommonTest, verifyTransformsForReplica) | 360 TEST(LayerTreeHostCommonTest, verifyTransformsForReplica) |
361 { | 361 { |
362 scoped_refptr<LayerChromium> parent = LayerChromium::create(); | 362 scoped_refptr<Layer> parent = Layer::create(); |
363 scoped_refptr<LayerChromium> child = LayerChromium::create(); | 363 scoped_refptr<Layer> child = Layer::create(); |
364 scoped_refptr<LayerChromium> childReplica = LayerChromium::create(); | 364 scoped_refptr<Layer> childReplica = Layer::create(); |
365 scoped_refptr<LayerChromiumWithForcedDrawsContent> grandChild = make_scoped_
refptr(new LayerChromiumWithForcedDrawsContent()); | 365 scoped_refptr<LayerWithForcedDrawsContent> grandChild = make_scoped_refptr(n
ew LayerWithForcedDrawsContent()); |
366 parent->addChild(child); | 366 parent->addChild(child); |
367 child->addChild(grandChild); | 367 child->addChild(grandChild); |
368 child->setReplicaLayer(childReplica.get()); | 368 child->setReplicaLayer(childReplica.get()); |
369 | 369 |
370 // Child is set up so that a new render surface should be created. | 370 // Child is set up so that a new render surface should be created. |
371 child->setOpacity(0.5); | 371 child->setOpacity(0.5); |
372 | 372 |
373 WebTransformationMatrix identityMatrix; | 373 WebTransformationMatrix identityMatrix; |
374 WebTransformationMatrix parentLayerTransform; | 374 WebTransformationMatrix parentLayerTransform; |
375 parentLayerTransform.scale3d(2, 2, 1); | 375 parentLayerTransform.scale3d(2, 2, 1); |
(...skipping 21 matching lines...) Expand all Loading... |
397 executeCalculateDrawTransformsAndVisibility(parent.get()); | 397 executeCalculateDrawTransformsAndVisibility(parent.get()); |
398 | 398 |
399 // Render surface should have been created now. | 399 // Render surface should have been created now. |
400 ASSERT_TRUE(child->renderSurface()); | 400 ASSERT_TRUE(child->renderSurface()); |
401 ASSERT_EQ(child, child->renderTarget()); | 401 ASSERT_EQ(child, child->renderTarget()); |
402 | 402 |
403 EXPECT_TRANSFORMATION_MATRIX_EQ(replicaCompositeTransform, child->renderTarg
et()->renderSurface()->replicaDrawTransform()); | 403 EXPECT_TRANSFORMATION_MATRIX_EQ(replicaCompositeTransform, child->renderTarg
et()->renderSurface()->replicaDrawTransform()); |
404 EXPECT_TRANSFORMATION_MATRIX_EQ(replicaCompositeTransform, child->renderTarg
et()->renderSurface()->replicaScreenSpaceTransform()); | 404 EXPECT_TRANSFORMATION_MATRIX_EQ(replicaCompositeTransform, child->renderTarg
et()->renderSurface()->replicaScreenSpaceTransform()); |
405 } | 405 } |
406 | 406 |
407 TEST(CCLayerTreeHostCommonTest, verifyTransformsForRenderSurfaceHierarchy) | 407 TEST(LayerTreeHostCommonTest, verifyTransformsForRenderSurfaceHierarchy) |
408 { | 408 { |
409 // This test creates a more complex tree and verifies it all at once. This c
overs the following cases: | 409 // This test creates a more complex tree and verifies it all at once. This c
overs the following cases: |
410 // - layers that are described w.r.t. a render surface: should have draw t
ransforms described w.r.t. that surface | 410 // - layers that are described w.r.t. a render surface: should have draw t
ransforms described w.r.t. that surface |
411 // - A render surface described w.r.t. an ancestor render surface: should
have a draw transform described w.r.t. that ancestor surface | 411 // - A render surface described w.r.t. an ancestor render surface: should
have a draw transform described w.r.t. that ancestor surface |
412 // - Replicas of a render surface are described w.r.t. the replica's trans
form around its anchor, along with the surface itself. | 412 // - Replicas of a render surface are described w.r.t. the replica's trans
form around its anchor, along with the surface itself. |
413 // - Sanity check on recursion: verify transforms of layers described w.r.
t. a render surface that is described w.r.t. an ancestor render surface. | 413 // - Sanity check on recursion: verify transforms of layers described w.r.
t. a render surface that is described w.r.t. an ancestor render surface. |
414 // - verifying that each layer has a reference to the correct renderSurfac
e and renderTarget values. | 414 // - verifying that each layer has a reference to the correct renderSurfac
e and renderTarget values. |
415 | 415 |
416 scoped_refptr<LayerChromium> parent = LayerChromium::create(); | 416 scoped_refptr<Layer> parent = Layer::create(); |
417 scoped_refptr<LayerChromium> renderSurface1 = LayerChromium::create(); | 417 scoped_refptr<Layer> renderSurface1 = Layer::create(); |
418 scoped_refptr<LayerChromium> renderSurface2 = LayerChromium::create(); | 418 scoped_refptr<Layer> renderSurface2 = Layer::create(); |
419 scoped_refptr<LayerChromium> childOfRoot = LayerChromium::create(); | 419 scoped_refptr<Layer> childOfRoot = Layer::create(); |
420 scoped_refptr<LayerChromium> childOfRS1 = LayerChromium::create(); | 420 scoped_refptr<Layer> childOfRS1 = Layer::create(); |
421 scoped_refptr<LayerChromium> childOfRS2 = LayerChromium::create(); | 421 scoped_refptr<Layer> childOfRS2 = Layer::create(); |
422 scoped_refptr<LayerChromium> replicaOfRS1 = LayerChromium::create(); | 422 scoped_refptr<Layer> replicaOfRS1 = Layer::create(); |
423 scoped_refptr<LayerChromium> replicaOfRS2 = LayerChromium::create(); | 423 scoped_refptr<Layer> replicaOfRS2 = Layer::create(); |
424 scoped_refptr<LayerChromium> grandChildOfRoot = LayerChromium::create(); | 424 scoped_refptr<Layer> grandChildOfRoot = Layer::create(); |
425 scoped_refptr<LayerChromiumWithForcedDrawsContent> grandChildOfRS1 = make_sc
oped_refptr(new LayerChromiumWithForcedDrawsContent()); | 425 scoped_refptr<LayerWithForcedDrawsContent> grandChildOfRS1 = make_scoped_ref
ptr(new LayerWithForcedDrawsContent()); |
426 scoped_refptr<LayerChromiumWithForcedDrawsContent> grandChildOfRS2 = make_sc
oped_refptr(new LayerChromiumWithForcedDrawsContent()); | 426 scoped_refptr<LayerWithForcedDrawsContent> grandChildOfRS2 = make_scoped_ref
ptr(new LayerWithForcedDrawsContent()); |
427 parent->addChild(renderSurface1); | 427 parent->addChild(renderSurface1); |
428 parent->addChild(childOfRoot); | 428 parent->addChild(childOfRoot); |
429 renderSurface1->addChild(childOfRS1); | 429 renderSurface1->addChild(childOfRS1); |
430 renderSurface1->addChild(renderSurface2); | 430 renderSurface1->addChild(renderSurface2); |
431 renderSurface2->addChild(childOfRS2); | 431 renderSurface2->addChild(childOfRS2); |
432 childOfRoot->addChild(grandChildOfRoot); | 432 childOfRoot->addChild(grandChildOfRoot); |
433 childOfRS1->addChild(grandChildOfRS1); | 433 childOfRS1->addChild(grandChildOfRS1); |
434 childOfRS2->addChild(grandChildOfRS2); | 434 childOfRS2->addChild(grandChildOfRS2); |
435 renderSurface1->setReplicaLayer(replicaOfRS1.get()); | 435 renderSurface1->setReplicaLayer(replicaOfRS1.get()); |
436 renderSurface2->setReplicaLayer(replicaOfRS2.get()); | 436 renderSurface2->setReplicaLayer(replicaOfRS2.get()); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 | 556 |
557 EXPECT_FLOAT_EQ(2, renderSurface1->screenSpaceTransform().m42()); | 557 EXPECT_FLOAT_EQ(2, renderSurface1->screenSpaceTransform().m42()); |
558 EXPECT_FLOAT_EQ(3, childOfRS1->screenSpaceTransform().m42()); | 558 EXPECT_FLOAT_EQ(3, childOfRS1->screenSpaceTransform().m42()); |
559 EXPECT_FLOAT_EQ(4, grandChildOfRS1->screenSpaceTransform().m42()); | 559 EXPECT_FLOAT_EQ(4, grandChildOfRS1->screenSpaceTransform().m42()); |
560 | 560 |
561 EXPECT_FLOAT_EQ(3, renderSurface2->screenSpaceTransform().m42()); | 561 EXPECT_FLOAT_EQ(3, renderSurface2->screenSpaceTransform().m42()); |
562 EXPECT_FLOAT_EQ(4, childOfRS2->screenSpaceTransform().m42()); | 562 EXPECT_FLOAT_EQ(4, childOfRS2->screenSpaceTransform().m42()); |
563 EXPECT_FLOAT_EQ(5, grandChildOfRS2->screenSpaceTransform().m42()); | 563 EXPECT_FLOAT_EQ(5, grandChildOfRS2->screenSpaceTransform().m42()); |
564 } | 564 } |
565 | 565 |
566 TEST(CCLayerTreeHostCommonTest, verifyTransformsForFlatteningLayer) | 566 TEST(LayerTreeHostCommonTest, verifyTransformsForFlatteningLayer) |
567 { | 567 { |
568 // For layers that flatten their subtree, there should be an orthographic pr
ojection | 568 // For layers that flatten their subtree, there should be an orthographic pr
ojection |
569 // (for x and y values) in the middle of the transform sequence. Note that t
he way the | 569 // (for x and y values) in the middle of the transform sequence. Note that t
he way the |
570 // code is currently implemented, it is not expected to use a canonical orth
ographic | 570 // code is currently implemented, it is not expected to use a canonical orth
ographic |
571 // projection. | 571 // projection. |
572 | 572 |
573 scoped_refptr<LayerChromium> root = LayerChromium::create(); | 573 scoped_refptr<Layer> root = Layer::create(); |
574 scoped_refptr<LayerChromium> child = LayerChromium::create(); | 574 scoped_refptr<Layer> child = Layer::create(); |
575 scoped_refptr<LayerChromiumWithForcedDrawsContent> grandChild = make_scoped_
refptr(new LayerChromiumWithForcedDrawsContent()); | 575 scoped_refptr<LayerWithForcedDrawsContent> grandChild = make_scoped_refptr(n
ew LayerWithForcedDrawsContent()); |
576 | 576 |
577 WebTransformationMatrix rotationAboutYAxis; | 577 WebTransformationMatrix rotationAboutYAxis; |
578 rotationAboutYAxis.rotate3d(0, 30, 0); | 578 rotationAboutYAxis.rotate3d(0, 30, 0); |
579 | 579 |
580 const WebTransformationMatrix identityMatrix; | 580 const WebTransformationMatrix identityMatrix; |
581 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, Flo
atPoint::zero(), FloatPoint::zero(), IntSize(100, 100), false); | 581 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, Flo
atPoint::zero(), FloatPoint::zero(), IntSize(100, 100), false); |
582 setLayerPropertiesForTesting(child.get(), rotationAboutYAxis, identityMatrix
, FloatPoint::zero(), FloatPoint::zero(), IntSize(10, 10), false); | 582 setLayerPropertiesForTesting(child.get(), rotationAboutYAxis, identityMatrix
, FloatPoint::zero(), FloatPoint::zero(), IntSize(10, 10), false); |
583 setLayerPropertiesForTesting(grandChild.get(), rotationAboutYAxis, identityM
atrix, FloatPoint::zero(), FloatPoint::zero(), IntSize(10, 10), false); | 583 setLayerPropertiesForTesting(grandChild.get(), rotationAboutYAxis, identityM
atrix, FloatPoint::zero(), FloatPoint::zero(), IntSize(10, 10), false); |
584 | 584 |
585 root->addChild(child); | 585 root->addChild(child); |
(...skipping 15 matching lines...) Expand all Loading... |
601 // The child's drawTransform should have been taken by its surface. | 601 // The child's drawTransform should have been taken by its surface. |
602 ASSERT_TRUE(child->renderSurface()); | 602 ASSERT_TRUE(child->renderSurface()); |
603 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildDrawTransform, child->renderSur
face()->drawTransform()); | 603 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildDrawTransform, child->renderSur
face()->drawTransform()); |
604 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildScreenSpaceTransform, child->re
nderSurface()->screenSpaceTransform()); | 604 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildScreenSpaceTransform, child->re
nderSurface()->screenSpaceTransform()); |
605 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); | 605 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); |
606 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildScreenSpaceTransform, child->sc
reenSpaceTransform()); | 606 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildScreenSpaceTransform, child->sc
reenSpaceTransform()); |
607 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildDrawTransform, grandChild-
>drawTransform()); | 607 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildDrawTransform, grandChild-
>drawTransform()); |
608 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildScreenSpaceTransform, gran
dChild->screenSpaceTransform()); | 608 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildScreenSpaceTransform, gran
dChild->screenSpaceTransform()); |
609 } | 609 } |
610 | 610 |
611 TEST(CCLayerTreeHostCommonTest, verifyTransformsForDegenerateIntermediateLayer) | 611 TEST(LayerTreeHostCommonTest, verifyTransformsForDegenerateIntermediateLayer) |
612 { | 612 { |
613 // A layer that is empty in one axis, but not the other, was accidentally sk
ipping a necessary translation. | 613 // A layer that is empty in one axis, but not the other, was accidentally sk
ipping a necessary translation. |
614 // Without that translation, the coordinate space of the layer's drawTransfo
rm is incorrect. | 614 // Without that translation, the coordinate space of the layer's drawTransfo
rm is incorrect. |
615 // | 615 // |
616 // Normally this isn't a problem, because the layer wouldn't be drawn anyway
, but if that layer becomes a renderSurface, then | 616 // Normally this isn't a problem, because the layer wouldn't be drawn anyway
, but if that layer becomes a renderSurface, then |
617 // its drawTransform is implicitly inherited by the rest of the subtree, whi
ch then is positioned incorrectly as a result. | 617 // its drawTransform is implicitly inherited by the rest of the subtree, whi
ch then is positioned incorrectly as a result. |
618 | 618 |
619 scoped_refptr<LayerChromium> root = LayerChromium::create(); | 619 scoped_refptr<Layer> root = Layer::create(); |
620 scoped_refptr<LayerChromium> child = LayerChromium::create(); | 620 scoped_refptr<Layer> child = Layer::create(); |
621 scoped_refptr<LayerChromiumWithForcedDrawsContent> grandChild = make_scoped_
refptr(new LayerChromiumWithForcedDrawsContent()); | 621 scoped_refptr<LayerWithForcedDrawsContent> grandChild = make_scoped_refptr(n
ew LayerWithForcedDrawsContent()); |
622 | 622 |
623 // The child height is zero, but has non-zero width that should be accounted
for while computing drawTransforms. | 623 // The child height is zero, but has non-zero width that should be accounted
for while computing drawTransforms. |
624 const WebTransformationMatrix identityMatrix; | 624 const WebTransformationMatrix identityMatrix; |
625 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, Flo
atPoint::zero(), FloatPoint::zero(), IntSize(100, 100), false); | 625 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, Flo
atPoint::zero(), FloatPoint::zero(), IntSize(100, 100), false); |
626 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint::zero(), FloatPoint::zero(), IntSize(10, 0), false); | 626 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint::zero(), FloatPoint::zero(), IntSize(10, 0), false); |
627 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, FloatPoint::zero(), FloatPoint::zero(), IntSize(10, 10), false); | 627 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, FloatPoint::zero(), FloatPoint::zero(), IntSize(10, 10), false); |
628 | 628 |
629 root->addChild(child); | 629 root->addChild(child); |
630 child->addChild(grandChild); | 630 child->addChild(grandChild); |
631 child->setForceRenderSurface(true); | 631 child->setForceRenderSurface(true); |
632 | 632 |
633 executeCalculateDrawTransformsAndVisibility(root.get()); | 633 executeCalculateDrawTransformsAndVisibility(root.get()); |
634 | 634 |
635 ASSERT_TRUE(child->renderSurface()); | 635 ASSERT_TRUE(child->renderSurface()); |
636 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->renderSurface()->draw
Transform()); // This is the real test, the rest are sanity checks. | 636 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->renderSurface()->draw
Transform()); // This is the real test, the rest are sanity checks. |
637 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); | 637 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); |
638 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->drawTransform())
; | 638 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->drawTransform())
; |
639 } | 639 } |
640 | 640 |
641 TEST(CCLayerTreeHostCommonTest, verifyRenderSurfaceListForRenderSurfaceWithClipp
edLayer) | 641 TEST(LayerTreeHostCommonTest, verifyRenderSurfaceListForRenderSurfaceWithClipped
Layer) |
642 { | 642 { |
643 scoped_refptr<LayerChromium> parent = LayerChromium::create(); | 643 scoped_refptr<Layer> parent = Layer::create(); |
644 scoped_refptr<LayerChromium> renderSurface1 = LayerChromium::create(); | 644 scoped_refptr<Layer> renderSurface1 = Layer::create(); |
645 scoped_refptr<LayerChromiumWithForcedDrawsContent> child = make_scoped_refpt
r(new LayerChromiumWithForcedDrawsContent()); | 645 scoped_refptr<LayerWithForcedDrawsContent> child = make_scoped_refptr(new La
yerWithForcedDrawsContent()); |
646 | 646 |
647 const WebTransformationMatrix identityMatrix; | 647 const WebTransformationMatrix identityMatrix; |
648 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, F
loatPoint::zero(), FloatPoint::zero(), IntSize(10, 10), false); | 648 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, F
loatPoint::zero(), FloatPoint::zero(), IntSize(10, 10), false); |
649 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, FloatPoint::zero(), FloatPoint::zero(), IntSize(10, 10), false); | 649 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, FloatPoint::zero(), FloatPoint::zero(), IntSize(10, 10), false); |
650 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint::zero(), FloatPoint(30, 30), IntSize(10, 10), false); | 650 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint::zero(), FloatPoint(30, 30), IntSize(10, 10), false); |
651 | 651 |
652 parent->addChild(renderSurface1); | 652 parent->addChild(renderSurface1); |
653 parent->setMasksToBounds(true); | 653 parent->setMasksToBounds(true); |
654 renderSurface1->addChild(child); | 654 renderSurface1->addChild(child); |
655 renderSurface1->setForceRenderSurface(true); | 655 renderSurface1->setForceRenderSurface(true); |
656 | 656 |
657 std::vector<scoped_refptr<LayerChromium> > renderSurfaceLayerList; | 657 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
658 int dummyMaxTextureSize = 512; | 658 int dummyMaxTextureSize = 512; |
659 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, dummyMaxTextureSize, renderSurfaceLayerList); | 659 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
1, dummyMaxTextureSize, renderSurfaceLayerList); |
660 | 660 |
661 // The child layer's content is entirely outside the parent's clip rect, so
the intermediate | 661 // The child layer's content is entirely outside the parent's clip rect, so
the intermediate |
662 // render surface should not be listed here, even if it was forced to be cre
ated. Render surfaces without children or visible | 662 // render surface should not be listed here, even if it was forced to be cre
ated. Render surfaces without children or visible |
663 // content are unexpected at draw time (e.g. we might try to create a conten
t texture of size 0). | 663 // content are unexpected at draw time (e.g. we might try to create a conten
t texture of size 0). |
664 ASSERT_TRUE(parent->renderSurface()); | 664 ASSERT_TRUE(parent->renderSurface()); |
665 ASSERT_FALSE(renderSurface1->renderSurface()); | 665 ASSERT_FALSE(renderSurface1->renderSurface()); |
666 EXPECT_EQ(1U, renderSurfaceLayerList.size()); | 666 EXPECT_EQ(1U, renderSurfaceLayerList.size()); |
667 } | 667 } |
668 | 668 |
669 TEST(CCLayerTreeHostCommonTest, verifyRenderSurfaceListForTransparentChild) | 669 TEST(LayerTreeHostCommonTest, verifyRenderSurfaceListForTransparentChild) |
670 { | 670 { |
671 scoped_refptr<LayerChromium> parent = LayerChromium::create(); | 671 scoped_refptr<Layer> parent = Layer::create(); |
672 scoped_refptr<LayerChromium> renderSurface1 = LayerChromium::create(); | 672 scoped_refptr<Layer> renderSurface1 = Layer::create(); |
673 scoped_refptr<LayerChromiumWithForcedDrawsContent> child = make_scoped_refpt
r(new LayerChromiumWithForcedDrawsContent()); | 673 scoped_refptr<LayerWithForcedDrawsContent> child = make_scoped_refptr(new La
yerWithForcedDrawsContent()); |
674 | 674 |
675 const WebTransformationMatrix identityMatrix; | 675 const WebTransformationMatrix identityMatrix; |
676 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, FloatPoint::zero(), FloatPoint::zero(), IntSize(10, 10), false); | 676 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, FloatPoint::zero(), FloatPoint::zero(), IntSize(10, 10), false); |
677 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint::zero(), FloatPoint::zero(), IntSize(10, 10), false); | 677 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint::zero(), FloatPoint::zero(), IntSize(10, 10), false); |
678 | 678 |
679 parent->addChild(renderSurface1); | 679 parent->addChild(renderSurface1); |
680 renderSurface1->addChild(child); | 680 renderSurface1->addChild(child); |
681 renderSurface1->setForceRenderSurface(true); | 681 renderSurface1->setForceRenderSurface(true); |
682 renderSurface1->setOpacity(0); | 682 renderSurface1->setOpacity(0); |
683 | 683 |
684 std::vector<scoped_refptr<LayerChromium> > renderSurfaceLayerList; | 684 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
685 int dummyMaxTextureSize = 512; | 685 int dummyMaxTextureSize = 512; |
686 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, dummyMaxTextureSize, renderSurfaceLayerList); | 686 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
1, dummyMaxTextureSize, renderSurfaceLayerList); |
687 | 687 |
688 // Since the layer is transparent, renderSurface1->renderSurface() should no
t have gotten added anywhere. | 688 // Since the layer is transparent, renderSurface1->renderSurface() should no
t have gotten added anywhere. |
689 // Also, the drawable content rect should not have been extended by the chil
dren. | 689 // Also, the drawable content rect should not have been extended by the chil
dren. |
690 ASSERT_TRUE(parent->renderSurface()); | 690 ASSERT_TRUE(parent->renderSurface()); |
691 EXPECT_EQ(0U, parent->renderSurface()->layerList().size()); | 691 EXPECT_EQ(0U, parent->renderSurface()->layerList().size()); |
692 EXPECT_EQ(1U, renderSurfaceLayerList.size()); | 692 EXPECT_EQ(1U, renderSurfaceLayerList.size()); |
693 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); | 693 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); |
694 EXPECT_EQ(IntRect(), parent->drawableContentRect()); | 694 EXPECT_EQ(IntRect(), parent->drawableContentRect()); |
695 } | 695 } |
696 | 696 |
697 TEST(CCLayerTreeHostCommonTest, verifyForceRenderSurface) | 697 TEST(LayerTreeHostCommonTest, verifyForceRenderSurface) |
698 { | 698 { |
699 scoped_refptr<LayerChromium> parent = LayerChromium::create(); | 699 scoped_refptr<Layer> parent = Layer::create(); |
700 scoped_refptr<LayerChromium> renderSurface1 = LayerChromium::create(); | 700 scoped_refptr<Layer> renderSurface1 = Layer::create(); |
701 scoped_refptr<LayerChromiumWithForcedDrawsContent> child = make_scoped_refpt
r(new LayerChromiumWithForcedDrawsContent()); | 701 scoped_refptr<LayerWithForcedDrawsContent> child = make_scoped_refptr(new La
yerWithForcedDrawsContent()); |
702 renderSurface1->setForceRenderSurface(true); | 702 renderSurface1->setForceRenderSurface(true); |
703 | 703 |
704 const WebTransformationMatrix identityMatrix; | 704 const WebTransformationMatrix identityMatrix; |
705 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, F
loatPoint::zero(), FloatPoint::zero(), IntSize(10, 10), false); | 705 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, F
loatPoint::zero(), FloatPoint::zero(), IntSize(10, 10), false); |
706 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, FloatPoint::zero(), FloatPoint::zero(), IntSize(10, 10), false); | 706 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, FloatPoint::zero(), FloatPoint::zero(), IntSize(10, 10), false); |
707 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint::zero(), FloatPoint::zero(), IntSize(10, 10), false); | 707 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint::zero(), FloatPoint::zero(), IntSize(10, 10), false); |
708 | 708 |
709 parent->addChild(renderSurface1); | 709 parent->addChild(renderSurface1); |
710 renderSurface1->addChild(child); | 710 renderSurface1->addChild(child); |
711 | 711 |
712 // Sanity check before the actual test | 712 // Sanity check before the actual test |
713 EXPECT_FALSE(parent->renderSurface()); | 713 EXPECT_FALSE(parent->renderSurface()); |
714 EXPECT_FALSE(renderSurface1->renderSurface()); | 714 EXPECT_FALSE(renderSurface1->renderSurface()); |
715 | 715 |
716 std::vector<scoped_refptr<LayerChromium> > renderSurfaceLayerList; | 716 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
717 int dummyMaxTextureSize = 512; | 717 int dummyMaxTextureSize = 512; |
718 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, dummyMaxTextureSize, renderSurfaceLayerList); | 718 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
1, dummyMaxTextureSize, renderSurfaceLayerList); |
719 | 719 |
720 // The root layer always creates a renderSurface | 720 // The root layer always creates a renderSurface |
721 EXPECT_TRUE(parent->renderSurface()); | 721 EXPECT_TRUE(parent->renderSurface()); |
722 EXPECT_TRUE(renderSurface1->renderSurface()); | 722 EXPECT_TRUE(renderSurface1->renderSurface()); |
723 EXPECT_EQ(2U, renderSurfaceLayerList.size()); | 723 EXPECT_EQ(2U, renderSurfaceLayerList.size()); |
724 | 724 |
725 renderSurfaceLayerList.clear(); | 725 renderSurfaceLayerList.clear(); |
726 renderSurface1->setForceRenderSurface(false); | 726 renderSurface1->setForceRenderSurface(false); |
727 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, dummyMaxTextureSize, renderSurfaceLayerList); | 727 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
1, dummyMaxTextureSize, renderSurfaceLayerList); |
728 EXPECT_TRUE(parent->renderSurface()); | 728 EXPECT_TRUE(parent->renderSurface()); |
729 EXPECT_FALSE(renderSurface1->renderSurface()); | 729 EXPECT_FALSE(renderSurface1->renderSurface()); |
730 EXPECT_EQ(1U, renderSurfaceLayerList.size()); | 730 EXPECT_EQ(1U, renderSurfaceLayerList.size()); |
731 } | 731 } |
732 | 732 |
733 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
hDirectContainer) | 733 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD
irectContainer) |
734 { | 734 { |
735 // This test checks for correct scroll compensation when the fixed-position
container | 735 // This test checks for correct scroll compensation when the fixed-position
container |
736 // is the direct parent of the fixed-position layer. | 736 // is the direct parent of the fixed-position layer. |
737 | 737 |
738 DebugScopedSetImplThread scopedImplThread; | 738 DebugScopedSetImplThread scopedImplThread; |
739 scoped_ptr<CCLayerImpl> root = createTreeForFixedPositionTests(); | 739 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); |
740 CCLayerImpl* child = root->children()[0]; | 740 LayerImpl* child = root->children()[0]; |
741 CCLayerImpl* grandChild = child->children()[0]; | 741 LayerImpl* grandChild = child->children()[0]; |
742 | 742 |
743 child->setIsContainerForFixedPositionLayers(true); | 743 child->setIsContainerForFixedPositionLayers(true); |
744 grandChild->setFixedToContainerLayer(true); | 744 grandChild->setFixedToContainerLayer(true); |
745 | 745 |
746 // Case 1: scrollDelta of 0, 0 | 746 // Case 1: scrollDelta of 0, 0 |
747 child->setScrollDelta(IntSize(0, 0)); | 747 child->setScrollDelta(IntSize(0, 0)); |
748 executeCalculateDrawTransformsAndVisibility(root.get()); | 748 executeCalculateDrawTransformsAndVisibility(root.get()); |
749 | 749 |
750 WebTransformationMatrix expectedChildTransform; | 750 WebTransformationMatrix expectedChildTransform; |
751 WebTransformationMatrix expectedGrandChildTransform = expectedChildTransform
; | 751 WebTransformationMatrix expectedGrandChildTransform = expectedChildTransform
; |
752 | 752 |
753 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 753 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); |
754 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 754 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); |
755 | 755 |
756 // Case 2: scrollDelta of 10, 10 | 756 // Case 2: scrollDelta of 10, 10 |
757 child->setScrollDelta(IntSize(10, 10)); | 757 child->setScrollDelta(IntSize(10, 10)); |
758 executeCalculateDrawTransformsAndVisibility(root.get()); | 758 executeCalculateDrawTransformsAndVisibility(root.get()); |
759 | 759 |
760 // Here the child is affected by scrollDelta, but the fixed position grandCh
ild should not be affected. | 760 // Here the child is affected by scrollDelta, but the fixed position grandCh
ild should not be affected. |
761 expectedChildTransform.makeIdentity(); | 761 expectedChildTransform.makeIdentity(); |
762 expectedChildTransform.translate(-10, -10); | 762 expectedChildTransform.translate(-10, -10); |
763 | 763 |
764 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 764 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); |
765 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 765 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); |
766 } | 766 } |
767 | 767 |
768 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
hTransformedDirectContainer) | 768 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithT
ransformedDirectContainer) |
769 { | 769 { |
770 // This test checks for correct scroll compensation when the fixed-position
container | 770 // This test checks for correct scroll compensation when the fixed-position
container |
771 // is the direct parent of the fixed-position layer, but that container is t
ransformed. | 771 // is the direct parent of the fixed-position layer, but that container is t
ransformed. |
772 // In this case, the fixed position element inherits the container's transfo
rm, | 772 // In this case, the fixed position element inherits the container's transfo
rm, |
773 // but the scrollDelta that has to be undone should not be affected by that
transform. | 773 // but the scrollDelta that has to be undone should not be affected by that
transform. |
774 // | 774 // |
775 // Transforms are in general non-commutative; using something like a non-uni
form scale | 775 // Transforms are in general non-commutative; using something like a non-uni
form scale |
776 // helps to verify that translations and non-uniform scales are applied in t
he correct | 776 // helps to verify that translations and non-uniform scales are applied in t
he correct |
777 // order. | 777 // order. |
778 | 778 |
779 DebugScopedSetImplThread scopedImplThread; | 779 DebugScopedSetImplThread scopedImplThread; |
780 scoped_ptr<CCLayerImpl> root = createTreeForFixedPositionTests(); | 780 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); |
781 CCLayerImpl* child = root->children()[0]; | 781 LayerImpl* child = root->children()[0]; |
782 CCLayerImpl* grandChild = child->children()[0]; | 782 LayerImpl* grandChild = child->children()[0]; |
783 | 783 |
784 // This scale will cause child and grandChild to be effectively 200 x 800 wi
th respect to the renderTarget. | 784 // This scale will cause child and grandChild to be effectively 200 x 800 wi
th respect to the renderTarget. |
785 WebTransformationMatrix nonUniformScale; | 785 WebTransformationMatrix nonUniformScale; |
786 nonUniformScale.scaleNonUniform(2, 8); | 786 nonUniformScale.scaleNonUniform(2, 8); |
787 child->setTransform(nonUniformScale); | 787 child->setTransform(nonUniformScale); |
788 | 788 |
789 child->setIsContainerForFixedPositionLayers(true); | 789 child->setIsContainerForFixedPositionLayers(true); |
790 grandChild->setFixedToContainerLayer(true); | 790 grandChild->setFixedToContainerLayer(true); |
791 | 791 |
792 // Case 1: scrollDelta of 0, 0 | 792 // Case 1: scrollDelta of 0, 0 |
(...skipping 14 matching lines...) Expand all Loading... |
807 | 807 |
808 // The child should be affected by scrollDelta, but the fixed position grand
Child should not be affected. | 808 // The child should be affected by scrollDelta, but the fixed position grand
Child should not be affected. |
809 expectedChildTransform.makeIdentity(); | 809 expectedChildTransform.makeIdentity(); |
810 expectedChildTransform.translate(-10, -20); // scrollDelta | 810 expectedChildTransform.translate(-10, -20); // scrollDelta |
811 expectedChildTransform.multiply(nonUniformScale); | 811 expectedChildTransform.multiply(nonUniformScale); |
812 | 812 |
813 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 813 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); |
814 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 814 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); |
815 } | 815 } |
816 | 816 |
817 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
hDistantContainer) | 817 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD
istantContainer) |
818 { | 818 { |
819 // This test checks for correct scroll compensation when the fixed-position
container | 819 // This test checks for correct scroll compensation when the fixed-position
container |
820 // is NOT the direct parent of the fixed-position layer. | 820 // is NOT the direct parent of the fixed-position layer. |
821 DebugScopedSetImplThread scopedImplThread; | 821 DebugScopedSetImplThread scopedImplThread; |
822 | 822 |
823 scoped_ptr<CCLayerImpl> root = createTreeForFixedPositionTests(); | 823 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); |
824 CCLayerImpl* child = root->children()[0]; | 824 LayerImpl* child = root->children()[0]; |
825 CCLayerImpl* grandChild = child->children()[0]; | 825 LayerImpl* grandChild = child->children()[0]; |
826 CCLayerImpl* greatGrandChild = grandChild->children()[0]; | 826 LayerImpl* greatGrandChild = grandChild->children()[0]; |
827 | 827 |
828 child->setIsContainerForFixedPositionLayers(true); | 828 child->setIsContainerForFixedPositionLayers(true); |
829 grandChild->setPosition(FloatPoint(8, 6)); | 829 grandChild->setPosition(FloatPoint(8, 6)); |
830 greatGrandChild->setFixedToContainerLayer(true); | 830 greatGrandChild->setFixedToContainerLayer(true); |
831 | 831 |
832 // Case 1: scrollDelta of 0, 0 | 832 // Case 1: scrollDelta of 0, 0 |
833 child->setScrollDelta(IntSize(0, 0)); | 833 child->setScrollDelta(IntSize(0, 0)); |
834 executeCalculateDrawTransformsAndVisibility(root.get()); | 834 executeCalculateDrawTransformsAndVisibility(root.get()); |
835 | 835 |
836 WebTransformationMatrix expectedChildTransform; | 836 WebTransformationMatrix expectedChildTransform; |
(...skipping 13 matching lines...) Expand all Loading... |
850 // Here the child and grandChild are affected by scrollDelta, but the fixed
position greatGrandChild should not be affected. | 850 // Here the child and grandChild are affected by scrollDelta, but the fixed
position greatGrandChild should not be affected. |
851 expectedChildTransform.makeIdentity(); | 851 expectedChildTransform.makeIdentity(); |
852 expectedChildTransform.translate(-10, -10); | 852 expectedChildTransform.translate(-10, -10); |
853 expectedGrandChildTransform.makeIdentity(); | 853 expectedGrandChildTransform.makeIdentity(); |
854 expectedGrandChildTransform.translate(-2, -4); | 854 expectedGrandChildTransform.translate(-2, -4); |
855 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 855 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); |
856 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 856 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); |
857 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); | 857 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); |
858 } | 858 } |
859 | 859 |
860 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
hDistantContainerAndTransforms) | 860 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD
istantContainerAndTransforms) |
861 { | 861 { |
862 // This test checks for correct scroll compensation when the fixed-position
container | 862 // This test checks for correct scroll compensation when the fixed-position
container |
863 // is NOT the direct parent of the fixed-position layer, and the hierarchy h
as various | 863 // is NOT the direct parent of the fixed-position layer, and the hierarchy h
as various |
864 // transforms that have to be processed in the correct order. | 864 // transforms that have to be processed in the correct order. |
865 DebugScopedSetImplThread scopedImplThread; | 865 DebugScopedSetImplThread scopedImplThread; |
866 | 866 |
867 scoped_ptr<CCLayerImpl> root = createTreeForFixedPositionTests(); | 867 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); |
868 CCLayerImpl* child = root->children()[0]; | 868 LayerImpl* child = root->children()[0]; |
869 CCLayerImpl* grandChild = child->children()[0]; | 869 LayerImpl* grandChild = child->children()[0]; |
870 CCLayerImpl* greatGrandChild = grandChild->children()[0]; | 870 LayerImpl* greatGrandChild = grandChild->children()[0]; |
871 | 871 |
872 WebTransformationMatrix rotationAboutZ; | 872 WebTransformationMatrix rotationAboutZ; |
873 rotationAboutZ.rotate3d(0, 0, 90); | 873 rotationAboutZ.rotate3d(0, 0, 90); |
874 | 874 |
875 child->setIsContainerForFixedPositionLayers(true); | 875 child->setIsContainerForFixedPositionLayers(true); |
876 child->setTransform(rotationAboutZ); | 876 child->setTransform(rotationAboutZ); |
877 grandChild->setPosition(FloatPoint(8, 6)); | 877 grandChild->setPosition(FloatPoint(8, 6)); |
878 grandChild->setTransform(rotationAboutZ); | 878 grandChild->setTransform(rotationAboutZ); |
879 greatGrandChild->setFixedToContainerLayer(true); // greatGrandChild is posit
ioned upside-down with respect to the renderTarget. | 879 greatGrandChild->setFixedToContainerLayer(true); // greatGrandChild is posit
ioned upside-down with respect to the renderTarget. |
880 | 880 |
(...skipping 28 matching lines...) Expand all Loading... |
909 expectedGrandChildTransform.translate(-10, -20); // child's scrollDelta is i
nherited | 909 expectedGrandChildTransform.translate(-10, -20); // child's scrollDelta is i
nherited |
910 expectedGrandChildTransform.multiply(rotationAboutZ); // child's local trans
form is inherited | 910 expectedGrandChildTransform.multiply(rotationAboutZ); // child's local trans
form is inherited |
911 expectedGrandChildTransform.translate(8, 6); // translation because of posit
ion occurs before layer's local transform. | 911 expectedGrandChildTransform.translate(8, 6); // translation because of posit
ion occurs before layer's local transform. |
912 expectedGrandChildTransform.multiply(rotationAboutZ); // grandChild's local
transform | 912 expectedGrandChildTransform.multiply(rotationAboutZ); // grandChild's local
transform |
913 | 913 |
914 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 914 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); |
915 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 915 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); |
916 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); | 916 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); |
917 } | 917 } |
918 | 918 |
919 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
hMultipleScrollDeltas) | 919 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithM
ultipleScrollDeltas) |
920 { | 920 { |
921 // This test checks for correct scroll compensation when the fixed-position
container | 921 // This test checks for correct scroll compensation when the fixed-position
container |
922 // has multiple ancestors that have nonzero scrollDelta before reaching the
space where the layer is fixed. | 922 // has multiple ancestors that have nonzero scrollDelta before reaching the
space where the layer is fixed. |
923 // In this test, each scrollDelta occurs in a different space because of eac
h layer's local transform. | 923 // In this test, each scrollDelta occurs in a different space because of eac
h layer's local transform. |
924 // This test checks for correct scroll compensation when the fixed-position
container | 924 // This test checks for correct scroll compensation when the fixed-position
container |
925 // is NOT the direct parent of the fixed-position layer, and the hierarchy h
as various | 925 // is NOT the direct parent of the fixed-position layer, and the hierarchy h
as various |
926 // transforms that have to be processed in the correct order. | 926 // transforms that have to be processed in the correct order. |
927 DebugScopedSetImplThread scopedImplThread; | 927 DebugScopedSetImplThread scopedImplThread; |
928 | 928 |
929 scoped_ptr<CCLayerImpl> root = createTreeForFixedPositionTests(); | 929 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); |
930 CCLayerImpl* child = root->children()[0]; | 930 LayerImpl* child = root->children()[0]; |
931 CCLayerImpl* grandChild = child->children()[0]; | 931 LayerImpl* grandChild = child->children()[0]; |
932 CCLayerImpl* greatGrandChild = grandChild->children()[0]; | 932 LayerImpl* greatGrandChild = grandChild->children()[0]; |
933 | 933 |
934 WebTransformationMatrix rotationAboutZ; | 934 WebTransformationMatrix rotationAboutZ; |
935 rotationAboutZ.rotate3d(0, 0, 90); | 935 rotationAboutZ.rotate3d(0, 0, 90); |
936 | 936 |
937 child->setIsContainerForFixedPositionLayers(true); | 937 child->setIsContainerForFixedPositionLayers(true); |
938 child->setTransform(rotationAboutZ); | 938 child->setTransform(rotationAboutZ); |
939 grandChild->setPosition(FloatPoint(8, 6)); | 939 grandChild->setPosition(FloatPoint(8, 6)); |
940 grandChild->setTransform(rotationAboutZ); | 940 grandChild->setTransform(rotationAboutZ); |
941 greatGrandChild->setFixedToContainerLayer(true); // greatGrandChild is posit
ioned upside-down with respect to the renderTarget. | 941 greatGrandChild->setFixedToContainerLayer(true); // greatGrandChild is posit
ioned upside-down with respect to the renderTarget. |
942 | 942 |
(...skipping 30 matching lines...) Expand all Loading... |
973 expectedGrandChildTransform.multiply(rotationAboutZ); // child's local trans
form is inherited | 973 expectedGrandChildTransform.multiply(rotationAboutZ); // child's local trans
form is inherited |
974 expectedGrandChildTransform.translate(-5, 0); // grandChild's scrollDelta | 974 expectedGrandChildTransform.translate(-5, 0); // grandChild's scrollDelta |
975 expectedGrandChildTransform.translate(8, 6); // translation because of posit
ion occurs before layer's local transform. | 975 expectedGrandChildTransform.translate(8, 6); // translation because of posit
ion occurs before layer's local transform. |
976 expectedGrandChildTransform.multiply(rotationAboutZ); // grandChild's local
transform | 976 expectedGrandChildTransform.multiply(rotationAboutZ); // grandChild's local
transform |
977 | 977 |
978 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 978 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); |
979 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 979 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); |
980 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); | 980 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); |
981 } | 981 } |
982 | 982 |
983 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
hIntermediateSurfaceAndTransforms) | 983 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithI
ntermediateSurfaceAndTransforms) |
984 { | 984 { |
985 // This test checks for correct scroll compensation when the fixed-position
container | 985 // This test checks for correct scroll compensation when the fixed-position
container |
986 // contributes to a different renderSurface than the fixed-position layer. I
n this | 986 // contributes to a different renderSurface than the fixed-position layer. I
n this |
987 // case, the surface drawTransforms also have to be accounted for when check
ing the | 987 // case, the surface drawTransforms also have to be accounted for when check
ing the |
988 // scrollDelta. | 988 // scrollDelta. |
989 DebugScopedSetImplThread scopedImplThread; | 989 DebugScopedSetImplThread scopedImplThread; |
990 | 990 |
991 scoped_ptr<CCLayerImpl> root = createTreeForFixedPositionTests(); | 991 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); |
992 CCLayerImpl* child = root->children()[0]; | 992 LayerImpl* child = root->children()[0]; |
993 CCLayerImpl* grandChild = child->children()[0]; | 993 LayerImpl* grandChild = child->children()[0]; |
994 CCLayerImpl* greatGrandChild = grandChild->children()[0]; | 994 LayerImpl* greatGrandChild = grandChild->children()[0]; |
995 | 995 |
996 child->setIsContainerForFixedPositionLayers(true); | 996 child->setIsContainerForFixedPositionLayers(true); |
997 grandChild->setPosition(FloatPoint(8, 6)); | 997 grandChild->setPosition(FloatPoint(8, 6)); |
998 grandChild->setForceRenderSurface(true); | 998 grandChild->setForceRenderSurface(true); |
999 greatGrandChild->setFixedToContainerLayer(true); | 999 greatGrandChild->setFixedToContainerLayer(true); |
1000 greatGrandChild->setDrawsContent(true); | 1000 greatGrandChild->setDrawsContent(true); |
1001 | 1001 |
1002 WebTransformationMatrix rotationAboutZ; | 1002 WebTransformationMatrix rotationAboutZ; |
1003 rotationAboutZ.rotate3d(0, 0, 90); | 1003 rotationAboutZ.rotate3d(0, 0, 90); |
1004 grandChild->setTransform(rotationAboutZ); | 1004 grandChild->setTransform(rotationAboutZ); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1046 expectedGreatGrandChildTransform.translate(10, 30); // explicit canceling ou
t the scrollDelta that gets embedded in the fixed position layer's surface. | 1046 expectedGreatGrandChildTransform.translate(10, 30); // explicit canceling ou
t the scrollDelta that gets embedded in the fixed position layer's surface. |
1047 expectedGreatGrandChildTransform.multiply(rotationAboutZ); | 1047 expectedGreatGrandChildTransform.multiply(rotationAboutZ); |
1048 | 1048 |
1049 ASSERT_TRUE(grandChild->renderSurface()); | 1049 ASSERT_TRUE(grandChild->renderSurface()); |
1050 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 1050 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); |
1051 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, grandChild->re
nderSurface()->drawTransform()); | 1051 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, grandChild->re
nderSurface()->drawTransform()); |
1052 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 1052 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); |
1053 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); | 1053 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); |
1054 } | 1054 } |
1055 | 1055 |
1056 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
hMultipleIntermediateSurfaces) | 1056 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithM
ultipleIntermediateSurfaces) |
1057 { | 1057 { |
1058 // This test checks for correct scroll compensation when the fixed-position
container | 1058 // This test checks for correct scroll compensation when the fixed-position
container |
1059 // contributes to a different renderSurface than the fixed-position layer, w
ith | 1059 // contributes to a different renderSurface than the fixed-position layer, w
ith |
1060 // additional renderSurfaces in-between. This checks that the conversion to
ancestor | 1060 // additional renderSurfaces in-between. This checks that the conversion to
ancestor |
1061 // surfaces is accumulated properly in the final matrix transform. | 1061 // surfaces is accumulated properly in the final matrix transform. |
1062 DebugScopedSetImplThread scopedImplThread; | 1062 DebugScopedSetImplThread scopedImplThread; |
1063 | 1063 |
1064 scoped_ptr<CCLayerImpl> root = createTreeForFixedPositionTests(); | 1064 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); |
1065 CCLayerImpl* child = root->children()[0]; | 1065 LayerImpl* child = root->children()[0]; |
1066 CCLayerImpl* grandChild = child->children()[0]; | 1066 LayerImpl* grandChild = child->children()[0]; |
1067 CCLayerImpl* greatGrandChild = grandChild->children()[0]; | 1067 LayerImpl* greatGrandChild = grandChild->children()[0]; |
1068 | 1068 |
1069 // Add one more layer to the test tree for this scenario. | 1069 // Add one more layer to the test tree for this scenario. |
1070 { | 1070 { |
1071 WebTransformationMatrix identity; | 1071 WebTransformationMatrix identity; |
1072 scoped_ptr<CCLayerImpl> fixedPositionChild = CCLayerImpl::create(5); | 1072 scoped_ptr<LayerImpl> fixedPositionChild = LayerImpl::create(5); |
1073 setLayerPropertiesForTesting(fixedPositionChild.get(), identity, identit
y, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 1073 setLayerPropertiesForTesting(fixedPositionChild.get(), identity, identit
y, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
1074 greatGrandChild->addChild(fixedPositionChild.Pass()); | 1074 greatGrandChild->addChild(fixedPositionChild.Pass()); |
1075 } | 1075 } |
1076 CCLayerImpl* fixedPositionChild = greatGrandChild->children()[0]; | 1076 LayerImpl* fixedPositionChild = greatGrandChild->children()[0]; |
1077 | 1077 |
1078 // Actually set up the scenario here. | 1078 // Actually set up the scenario here. |
1079 child->setIsContainerForFixedPositionLayers(true); | 1079 child->setIsContainerForFixedPositionLayers(true); |
1080 grandChild->setPosition(FloatPoint(8, 6)); | 1080 grandChild->setPosition(FloatPoint(8, 6)); |
1081 grandChild->setForceRenderSurface(true); | 1081 grandChild->setForceRenderSurface(true); |
1082 greatGrandChild->setPosition(FloatPoint(40, 60)); | 1082 greatGrandChild->setPosition(FloatPoint(40, 60)); |
1083 greatGrandChild->setForceRenderSurface(true); | 1083 greatGrandChild->setForceRenderSurface(true); |
1084 fixedPositionChild->setFixedToContainerLayer(true); | 1084 fixedPositionChild->setFixedToContainerLayer(true); |
1085 fixedPositionChild->setDrawsContent(true); | 1085 fixedPositionChild->setDrawsContent(true); |
1086 | 1086 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1157 ASSERT_TRUE(grandChild->renderSurface()); | 1157 ASSERT_TRUE(grandChild->renderSurface()); |
1158 ASSERT_TRUE(greatGrandChild->renderSurface()); | 1158 ASSERT_TRUE(greatGrandChild->renderSurface()); |
1159 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 1159 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); |
1160 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildSurfaceDrawTransform, gran
dChild->renderSurface()->drawTransform()); | 1160 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildSurfaceDrawTransform, gran
dChild->renderSurface()->drawTransform()); |
1161 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 1161 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); |
1162 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildSurfaceDrawTransform,
greatGrandChild->renderSurface()->drawTransform()); | 1162 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildSurfaceDrawTransform,
greatGrandChild->renderSurface()->drawTransform()); |
1163 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); | 1163 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); |
1164 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedFixedPositionChildTransform, fixedPo
sitionChild->drawTransform()); | 1164 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedFixedPositionChildTransform, fixedPo
sitionChild->drawTransform()); |
1165 } | 1165 } |
1166 | 1166 |
1167 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
hContainerLayerThatHasSurface) | 1167 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithC
ontainerLayerThatHasSurface) |
1168 { | 1168 { |
1169 // This test checks for correct scroll compensation when the fixed-position
container | 1169 // This test checks for correct scroll compensation when the fixed-position
container |
1170 // itself has a renderSurface. In this case, the container layer should be t
reated | 1170 // itself has a renderSurface. In this case, the container layer should be t
reated |
1171 // like a layer that contributes to a renderTarget, and that renderTarget | 1171 // like a layer that contributes to a renderTarget, and that renderTarget |
1172 // is completely irrelevant; it should not affect the scroll compensation. | 1172 // is completely irrelevant; it should not affect the scroll compensation. |
1173 DebugScopedSetImplThread scopedImplThread; | 1173 DebugScopedSetImplThread scopedImplThread; |
1174 | 1174 |
1175 scoped_ptr<CCLayerImpl> root = createTreeForFixedPositionTests(); | 1175 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); |
1176 CCLayerImpl* child = root->children()[0]; | 1176 LayerImpl* child = root->children()[0]; |
1177 CCLayerImpl* grandChild = child->children()[0]; | 1177 LayerImpl* grandChild = child->children()[0]; |
1178 | 1178 |
1179 child->setIsContainerForFixedPositionLayers(true); | 1179 child->setIsContainerForFixedPositionLayers(true); |
1180 child->setForceRenderSurface(true); | 1180 child->setForceRenderSurface(true); |
1181 grandChild->setFixedToContainerLayer(true); | 1181 grandChild->setFixedToContainerLayer(true); |
1182 grandChild->setDrawsContent(true); | 1182 grandChild->setDrawsContent(true); |
1183 | 1183 |
1184 // Case 1: scrollDelta of 0, 0 | 1184 // Case 1: scrollDelta of 0, 0 |
1185 child->setScrollDelta(IntSize(0, 0)); | 1185 child->setScrollDelta(IntSize(0, 0)); |
1186 executeCalculateDrawTransformsAndVisibility(root.get()); | 1186 executeCalculateDrawTransformsAndVisibility(root.get()); |
1187 | 1187 |
(...skipping 17 matching lines...) Expand all Loading... |
1205 expectedSurfaceDrawTransform.translate(-10, -10); | 1205 expectedSurfaceDrawTransform.translate(-10, -10); |
1206 expectedGrandChildTransform.makeIdentity(); | 1206 expectedGrandChildTransform.makeIdentity(); |
1207 expectedGrandChildTransform.translate(10, 10); | 1207 expectedGrandChildTransform.translate(10, 10); |
1208 | 1208 |
1209 ASSERT_TRUE(child->renderSurface()); | 1209 ASSERT_TRUE(child->renderSurface()); |
1210 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, child->renderS
urface()->drawTransform()); | 1210 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, child->renderS
urface()->drawTransform()); |
1211 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 1211 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); |
1212 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 1212 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); |
1213 } | 1213 } |
1214 | 1214 |
1215 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerTha
tIsAlsoFixedPositionContainer) | 1215 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerThatI
sAlsoFixedPositionContainer) |
1216 { | 1216 { |
1217 // This test checks the scenario where a fixed-position layer also happens t
o be a | 1217 // This test checks the scenario where a fixed-position layer also happens t
o be a |
1218 // container itself for a descendant fixed position layer. In particular, th
e layer | 1218 // container itself for a descendant fixed position layer. In particular, th
e layer |
1219 // should not accidentally be fixed to itself. | 1219 // should not accidentally be fixed to itself. |
1220 DebugScopedSetImplThread scopedImplThread; | 1220 DebugScopedSetImplThread scopedImplThread; |
1221 | 1221 |
1222 scoped_ptr<CCLayerImpl> root = createTreeForFixedPositionTests(); | 1222 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); |
1223 CCLayerImpl* child = root->children()[0]; | 1223 LayerImpl* child = root->children()[0]; |
1224 CCLayerImpl* grandChild = child->children()[0]; | 1224 LayerImpl* grandChild = child->children()[0]; |
1225 | 1225 |
1226 child->setIsContainerForFixedPositionLayers(true); | 1226 child->setIsContainerForFixedPositionLayers(true); |
1227 grandChild->setFixedToContainerLayer(true); | 1227 grandChild->setFixedToContainerLayer(true); |
1228 | 1228 |
1229 // This should not confuse the grandChild. If correct, the grandChild would
still be considered fixed to its container (i.e. "child"). | 1229 // This should not confuse the grandChild. If correct, the grandChild would
still be considered fixed to its container (i.e. "child"). |
1230 grandChild->setIsContainerForFixedPositionLayers(true); | 1230 grandChild->setIsContainerForFixedPositionLayers(true); |
1231 | 1231 |
1232 // Case 1: scrollDelta of 0, 0 | 1232 // Case 1: scrollDelta of 0, 0 |
1233 child->setScrollDelta(IntSize(0, 0)); | 1233 child->setScrollDelta(IntSize(0, 0)); |
1234 executeCalculateDrawTransformsAndVisibility(root.get()); | 1234 executeCalculateDrawTransformsAndVisibility(root.get()); |
1235 | 1235 |
1236 WebTransformationMatrix expectedChildTransform; | 1236 WebTransformationMatrix expectedChildTransform; |
1237 WebTransformationMatrix expectedGrandChildTransform; | 1237 WebTransformationMatrix expectedGrandChildTransform; |
1238 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 1238 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); |
1239 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 1239 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); |
1240 | 1240 |
1241 // Case 2: scrollDelta of 10, 10 | 1241 // Case 2: scrollDelta of 10, 10 |
1242 child->setScrollDelta(IntSize(10, 10)); | 1242 child->setScrollDelta(IntSize(10, 10)); |
1243 executeCalculateDrawTransformsAndVisibility(root.get()); | 1243 executeCalculateDrawTransformsAndVisibility(root.get()); |
1244 | 1244 |
1245 // Here the child is affected by scrollDelta, but the fixed position grandCh
ild should not be affected. | 1245 // Here the child is affected by scrollDelta, but the fixed position grandCh
ild should not be affected. |
1246 expectedChildTransform.makeIdentity(); | 1246 expectedChildTransform.makeIdentity(); |
1247 expectedChildTransform.translate(-10, -10); | 1247 expectedChildTransform.translate(-10, -10); |
1248 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 1248 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); |
1249 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 1249 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); |
1250 } | 1250 } |
1251 | 1251 |
1252 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerTha
tHasNoContainer) | 1252 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerThatH
asNoContainer) |
1253 { | 1253 { |
1254 // This test checks scroll compensation when a fixed-position layer does not
find any | 1254 // This test checks scroll compensation when a fixed-position layer does not
find any |
1255 // ancestor that is a "containerForFixedPositionLayers". In this situation,
the layer should | 1255 // ancestor that is a "containerForFixedPositionLayers". In this situation,
the layer should |
1256 // be fixed to the viewport -- not the rootLayer, which may have transforms
of its own. | 1256 // be fixed to the viewport -- not the rootLayer, which may have transforms
of its own. |
1257 DebugScopedSetImplThread scopedImplThread; | 1257 DebugScopedSetImplThread scopedImplThread; |
1258 | 1258 |
1259 scoped_ptr<CCLayerImpl> root = createTreeForFixedPositionTests(); | 1259 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); |
1260 CCLayerImpl* child = root->children()[0]; | 1260 LayerImpl* child = root->children()[0]; |
1261 CCLayerImpl* grandChild = child->children()[0]; | 1261 LayerImpl* grandChild = child->children()[0]; |
1262 | 1262 |
1263 WebTransformationMatrix rotationByZ; | 1263 WebTransformationMatrix rotationByZ; |
1264 rotationByZ.rotate3d(0, 0, 90); | 1264 rotationByZ.rotate3d(0, 0, 90); |
1265 | 1265 |
1266 root->setTransform(rotationByZ); | 1266 root->setTransform(rotationByZ); |
1267 grandChild->setFixedToContainerLayer(true); | 1267 grandChild->setFixedToContainerLayer(true); |
1268 | 1268 |
1269 // Case 1: root scrollDelta of 0, 0 | 1269 // Case 1: root scrollDelta of 0, 0 |
1270 root->setScrollDelta(IntSize(0, 0)); | 1270 root->setScrollDelta(IntSize(0, 0)); |
1271 executeCalculateDrawTransformsAndVisibility(root.get()); | 1271 executeCalculateDrawTransformsAndVisibility(root.get()); |
(...skipping 13 matching lines...) Expand all Loading... |
1285 | 1285 |
1286 // Here the child is affected by scrollDelta, but the fixed position grandCh
ild should not be affected. | 1286 // Here the child is affected by scrollDelta, but the fixed position grandCh
ild should not be affected. |
1287 expectedChildTransform.makeIdentity(); | 1287 expectedChildTransform.makeIdentity(); |
1288 expectedChildTransform.translate(-10, -10); // the scrollDelta | 1288 expectedChildTransform.translate(-10, -10); // the scrollDelta |
1289 expectedChildTransform.multiply(rotationByZ); | 1289 expectedChildTransform.multiply(rotationByZ); |
1290 | 1290 |
1291 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 1291 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); |
1292 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 1292 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); |
1293 } | 1293 } |
1294 | 1294 |
1295 TEST(CCLayerTreeHostCommonTest, verifyClipRectCullsRenderSurfaces) | 1295 TEST(LayerTreeHostCommonTest, verifyClipRectCullsRenderSurfaces) |
1296 { | 1296 { |
1297 // The entire subtree of layers that are outside the clipRect should be cull
ed away, | 1297 // The entire subtree of layers that are outside the clipRect should be cull
ed away, |
1298 // and should not affect the renderSurfaceLayerList. | 1298 // and should not affect the renderSurfaceLayerList. |
1299 // | 1299 // |
1300 // The test tree is set up as follows: | 1300 // The test tree is set up as follows: |
1301 // - all layers except the leafNodes are forced to be a new renderSurface t
hat have something to draw. | 1301 // - all layers except the leafNodes are forced to be a new renderSurface t
hat have something to draw. |
1302 // - parent is a large container layer. | 1302 // - parent is a large container layer. |
1303 // - child has masksToBounds=true to cause clipping. | 1303 // - child has masksToBounds=true to cause clipping. |
1304 // - grandChild is positioned outside of the child's bounds | 1304 // - grandChild is positioned outside of the child's bounds |
1305 // - greatGrandChild is also kept outside child's bounds. | 1305 // - greatGrandChild is also kept outside child's bounds. |
1306 // | 1306 // |
1307 // In this configuration, grandChild and greatGrandChild are completely outs
ide the | 1307 // In this configuration, grandChild and greatGrandChild are completely outs
ide the |
1308 // clipRect, and they should never get scheduled on the list of renderSurfac
es. | 1308 // clipRect, and they should never get scheduled on the list of renderSurfac
es. |
1309 // | 1309 // |
1310 | 1310 |
1311 const WebTransformationMatrix identityMatrix; | 1311 const WebTransformationMatrix identityMatrix; |
1312 scoped_refptr<LayerChromium> parent = LayerChromium::create(); | 1312 scoped_refptr<Layer> parent = Layer::create(); |
1313 scoped_refptr<LayerChromium> child = LayerChromium::create(); | 1313 scoped_refptr<Layer> child = Layer::create(); |
1314 scoped_refptr<LayerChromium> grandChild = LayerChromium::create(); | 1314 scoped_refptr<Layer> grandChild = Layer::create(); |
1315 scoped_refptr<LayerChromium> greatGrandChild = LayerChromium::create(); | 1315 scoped_refptr<Layer> greatGrandChild = Layer::create(); |
1316 scoped_refptr<LayerChromiumWithForcedDrawsContent> leafNode1 = make_scoped_r
efptr(new LayerChromiumWithForcedDrawsContent()); | 1316 scoped_refptr<LayerWithForcedDrawsContent> leafNode1 = make_scoped_refptr(ne
w LayerWithForcedDrawsContent()); |
1317 scoped_refptr<LayerChromiumWithForcedDrawsContent> leafNode2 = make_scoped_r
efptr(new LayerChromiumWithForcedDrawsContent()); | 1317 scoped_refptr<LayerWithForcedDrawsContent> leafNode2 = make_scoped_refptr(ne
w LayerWithForcedDrawsContent()); |
1318 parent->addChild(child); | 1318 parent->addChild(child); |
1319 child->addChild(grandChild); | 1319 child->addChild(grandChild); |
1320 grandChild->addChild(greatGrandChild); | 1320 grandChild->addChild(greatGrandChild); |
1321 | 1321 |
1322 // leafNode1 ensures that parent and child are kept on the renderSurfaceLaye
rList, | 1322 // leafNode1 ensures that parent and child are kept on the renderSurfaceLaye
rList, |
1323 // even though grandChild and greatGrandChild should be clipped. | 1323 // even though grandChild and greatGrandChild should be clipped. |
1324 child->addChild(leafNode1); | 1324 child->addChild(leafNode1); |
1325 greatGrandChild->addChild(leafNode2); | 1325 greatGrandChild->addChild(leafNode2); |
1326 | 1326 |
1327 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(500, 500), false); | 1327 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(500, 500), false); |
1328 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint(0, 0), FloatPoint(0, 0), IntSize(20, 20), false); | 1328 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint(0, 0), FloatPoint(0, 0), IntSize(20, 20), false); |
1329 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, FloatPoint(0, 0), FloatPoint(45, 45), IntSize(10, 10), false); | 1329 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, FloatPoint(0, 0), FloatPoint(45, 45), IntSize(10, 10), false); |
1330 setLayerPropertiesForTesting(greatGrandChild.get(), identityMatrix, identity
Matrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(10, 10), false); | 1330 setLayerPropertiesForTesting(greatGrandChild.get(), identityMatrix, identity
Matrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(10, 10), false); |
1331 setLayerPropertiesForTesting(leafNode1.get(), identityMatrix, identityMatrix
, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(500, 500), false); | 1331 setLayerPropertiesForTesting(leafNode1.get(), identityMatrix, identityMatrix
, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(500, 500), false); |
1332 setLayerPropertiesForTesting(leafNode2.get(), identityMatrix, identityMatrix
, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(20, 20), false); | 1332 setLayerPropertiesForTesting(leafNode2.get(), identityMatrix, identityMatrix
, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(20, 20), false); |
1333 | 1333 |
1334 child->setMasksToBounds(true); | 1334 child->setMasksToBounds(true); |
1335 child->setOpacity(0.4f); | 1335 child->setOpacity(0.4f); |
1336 grandChild->setOpacity(0.5); | 1336 grandChild->setOpacity(0.5); |
1337 greatGrandChild->setOpacity(0.4f); | 1337 greatGrandChild->setOpacity(0.4f); |
1338 | 1338 |
1339 std::vector<scoped_refptr<LayerChromium> > renderSurfaceLayerList; | 1339 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
1340 int dummyMaxTextureSize = 512; | 1340 int dummyMaxTextureSize = 512; |
1341 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, dummyMaxTextureSize, renderSurfaceLayerList); | 1341 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
1, dummyMaxTextureSize, renderSurfaceLayerList); |
1342 | 1342 |
1343 ASSERT_EQ(2U, renderSurfaceLayerList.size()); | 1343 ASSERT_EQ(2U, renderSurfaceLayerList.size()); |
1344 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); | 1344 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); |
1345 EXPECT_EQ(child->id(), renderSurfaceLayerList[1]->id()); | 1345 EXPECT_EQ(child->id(), renderSurfaceLayerList[1]->id()); |
1346 } | 1346 } |
1347 | 1347 |
1348 TEST(CCLayerTreeHostCommonTest, verifyClipRectCullsSurfaceWithoutVisibleContent) | 1348 TEST(LayerTreeHostCommonTest, verifyClipRectCullsSurfaceWithoutVisibleContent) |
1349 { | 1349 { |
1350 // When a renderSurface has a clipRect, it is used to clip the contentRect | 1350 // When a renderSurface has a clipRect, it is used to clip the contentRect |
1351 // of the surface. When the renderSurface is animating its transforms, then | 1351 // of the surface. When the renderSurface is animating its transforms, then |
1352 // the contentRect's position in the clipRect is not defined on the main | 1352 // the contentRect's position in the clipRect is not defined on the main |
1353 // thread, and its contentRect should not be clipped. | 1353 // thread, and its contentRect should not be clipped. |
1354 | 1354 |
1355 // The test tree is set up as follows: | 1355 // The test tree is set up as follows: |
1356 // - parent is a container layer that masksToBounds=true to cause clipping. | 1356 // - parent is a container layer that masksToBounds=true to cause clipping. |
1357 // - child is a renderSurface, which has a clipRect set to the bounds of th
e parent. | 1357 // - child is a renderSurface, which has a clipRect set to the bounds of th
e parent. |
1358 // - grandChild is a renderSurface, and the only visible content in child.
It is positioned outside of the clipRect from parent. | 1358 // - grandChild is a renderSurface, and the only visible content in child.
It is positioned outside of the clipRect from parent. |
1359 | 1359 |
1360 // In this configuration, grandChild should be outside the clipped | 1360 // In this configuration, grandChild should be outside the clipped |
1361 // contentRect of the child, making grandChild not appear in the | 1361 // contentRect of the child, making grandChild not appear in the |
1362 // renderSurfaceLayerList. However, when we place an animation on the child, | 1362 // renderSurfaceLayerList. However, when we place an animation on the child, |
1363 // this clipping should be avoided and we should keep the grandChild | 1363 // this clipping should be avoided and we should keep the grandChild |
1364 // in the renderSurfaceLayerList. | 1364 // in the renderSurfaceLayerList. |
1365 | 1365 |
1366 const WebTransformationMatrix identityMatrix; | 1366 const WebTransformationMatrix identityMatrix; |
1367 scoped_refptr<LayerChromium> parent = LayerChromium::create(); | 1367 scoped_refptr<Layer> parent = Layer::create(); |
1368 scoped_refptr<LayerChromium> child = LayerChromium::create(); | 1368 scoped_refptr<Layer> child = Layer::create(); |
1369 scoped_refptr<LayerChromium> grandChild = LayerChromium::create(); | 1369 scoped_refptr<Layer> grandChild = Layer::create(); |
1370 scoped_refptr<LayerChromiumWithForcedDrawsContent> leafNode = make_scoped_re
fptr(new LayerChromiumWithForcedDrawsContent()); | 1370 scoped_refptr<LayerWithForcedDrawsContent> leafNode = make_scoped_refptr(new
LayerWithForcedDrawsContent()); |
1371 parent->addChild(child); | 1371 parent->addChild(child); |
1372 child->addChild(grandChild); | 1372 child->addChild(grandChild); |
1373 grandChild->addChild(leafNode); | 1373 grandChild->addChild(leafNode); |
1374 | 1374 |
1375 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 1375 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
1376 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint(0, 0), FloatPoint(0, 0), IntSize(20, 20), false); | 1376 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint(0, 0), FloatPoint(0, 0), IntSize(20, 20), false); |
1377 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, FloatPoint(0, 0), FloatPoint(200, 200), IntSize(10, 10), false); | 1377 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, FloatPoint(0, 0), FloatPoint(200, 200), IntSize(10, 10), false); |
1378 setLayerPropertiesForTesting(leafNode.get(), identityMatrix, identityMatrix,
FloatPoint(0, 0), FloatPoint(0, 0), IntSize(10, 10), false); | 1378 setLayerPropertiesForTesting(leafNode.get(), identityMatrix, identityMatrix,
FloatPoint(0, 0), FloatPoint(0, 0), IntSize(10, 10), false); |
1379 | 1379 |
1380 parent->setMasksToBounds(true); | 1380 parent->setMasksToBounds(true); |
1381 child->setOpacity(0.4f); | 1381 child->setOpacity(0.4f); |
1382 grandChild->setOpacity(0.4f); | 1382 grandChild->setOpacity(0.4f); |
1383 | 1383 |
1384 std::vector<scoped_refptr<LayerChromium> > renderSurfaceLayerList; | 1384 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
1385 int dummyMaxTextureSize = 512; | 1385 int dummyMaxTextureSize = 512; |
1386 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, dummyMaxTextureSize, renderSurfaceLayerList); | 1386 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
1, dummyMaxTextureSize, renderSurfaceLayerList); |
1387 | 1387 |
1388 // Without an animation, we should cull child and grandChild from the render
SurfaceLayerList. | 1388 // Without an animation, we should cull child and grandChild from the render
SurfaceLayerList. |
1389 ASSERT_EQ(1U, renderSurfaceLayerList.size()); | 1389 ASSERT_EQ(1U, renderSurfaceLayerList.size()); |
1390 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); | 1390 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); |
1391 | 1391 |
1392 // Now put an animating transform on child. | 1392 // Now put an animating transform on child. |
1393 addAnimatedTransformToController(*child->layerAnimationController(), 10, 30,
0); | 1393 addAnimatedTransformToController(*child->layerAnimationController(), 10, 30,
0); |
1394 | 1394 |
1395 parent->clearRenderSurface(); | 1395 parent->clearRenderSurface(); |
1396 child->clearRenderSurface(); | 1396 child->clearRenderSurface(); |
1397 grandChild->clearRenderSurface(); | 1397 grandChild->clearRenderSurface(); |
1398 renderSurfaceLayerList.clear(); | 1398 renderSurfaceLayerList.clear(); |
1399 | 1399 |
1400 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, dummyMaxTextureSize, renderSurfaceLayerList); | 1400 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
1, dummyMaxTextureSize, renderSurfaceLayerList); |
1401 | 1401 |
1402 // With an animating transform, we should keep child and grandChild in the r
enderSurfaceLayerList. | 1402 // With an animating transform, we should keep child and grandChild in the r
enderSurfaceLayerList. |
1403 ASSERT_EQ(3U, renderSurfaceLayerList.size()); | 1403 ASSERT_EQ(3U, renderSurfaceLayerList.size()); |
1404 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); | 1404 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); |
1405 EXPECT_EQ(child->id(), renderSurfaceLayerList[1]->id()); | 1405 EXPECT_EQ(child->id(), renderSurfaceLayerList[1]->id()); |
1406 EXPECT_EQ(grandChild->id(), renderSurfaceLayerList[2]->id()); | 1406 EXPECT_EQ(grandChild->id(), renderSurfaceLayerList[2]->id()); |
1407 } | 1407 } |
1408 | 1408 |
1409 TEST(CCLayerTreeHostCommonTest, verifyDrawableContentRectForLayers) | 1409 TEST(LayerTreeHostCommonTest, verifyDrawableContentRectForLayers) |
1410 { | 1410 { |
1411 // Verify that layers get the appropriate drawableContentRect when their par
ent masksToBounds is true. | 1411 // Verify that layers get the appropriate drawableContentRect when their par
ent masksToBounds is true. |
1412 // | 1412 // |
1413 // grandChild1 - completely inside the region; drawableContentRect should
be the layer rect expressed in target space. | 1413 // grandChild1 - completely inside the region; drawableContentRect should
be the layer rect expressed in target space. |
1414 // grandChild2 - partially clipped but NOT masksToBounds; the clipRect wil
l be the intersection of layerBounds and the mask region. | 1414 // grandChild2 - partially clipped but NOT masksToBounds; the clipRect wil
l be the intersection of layerBounds and the mask region. |
1415 // grandChild3 - partially clipped and masksToBounds; the drawableContentR
ect will still be the intersection of layerBounds and the mask region. | 1415 // grandChild3 - partially clipped and masksToBounds; the drawableContentR
ect will still be the intersection of layerBounds and the mask region. |
1416 // grandChild4 - outside parent's clipRect; the drawableContentRect should
be empty. | 1416 // grandChild4 - outside parent's clipRect; the drawableContentRect should
be empty. |
1417 // | 1417 // |
1418 | 1418 |
1419 const WebTransformationMatrix identityMatrix; | 1419 const WebTransformationMatrix identityMatrix; |
1420 scoped_refptr<LayerChromium> parent = LayerChromium::create(); | 1420 scoped_refptr<Layer> parent = Layer::create(); |
1421 scoped_refptr<LayerChromium> child = LayerChromium::create(); | 1421 scoped_refptr<Layer> child = Layer::create(); |
1422 scoped_refptr<LayerChromium> grandChild1 = LayerChromium::create(); | 1422 scoped_refptr<Layer> grandChild1 = Layer::create(); |
1423 scoped_refptr<LayerChromium> grandChild2 = LayerChromium::create(); | 1423 scoped_refptr<Layer> grandChild2 = Layer::create(); |
1424 scoped_refptr<LayerChromium> grandChild3 = LayerChromium::create(); | 1424 scoped_refptr<Layer> grandChild3 = Layer::create(); |
1425 scoped_refptr<LayerChromium> grandChild4 = LayerChromium::create(); | 1425 scoped_refptr<Layer> grandChild4 = Layer::create(); |
1426 | 1426 |
1427 parent->addChild(child); | 1427 parent->addChild(child); |
1428 child->addChild(grandChild1); | 1428 child->addChild(grandChild1); |
1429 child->addChild(grandChild2); | 1429 child->addChild(grandChild2); |
1430 child->addChild(grandChild3); | 1430 child->addChild(grandChild3); |
1431 child->addChild(grandChild4); | 1431 child->addChild(grandChild4); |
1432 | 1432 |
1433 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(500, 500), false); | 1433 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(500, 500), false); |
1434 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint(0, 0), FloatPoint(0, 0), IntSize(20, 20), false); | 1434 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint(0, 0), FloatPoint(0, 0), IntSize(20, 20), false); |
1435 setLayerPropertiesForTesting(grandChild1.get(), identityMatrix, identityMatr
ix, FloatPoint(0, 0), FloatPoint(5, 5), IntSize(10, 10), false); | 1435 setLayerPropertiesForTesting(grandChild1.get(), identityMatrix, identityMatr
ix, FloatPoint(0, 0), FloatPoint(5, 5), IntSize(10, 10), false); |
1436 setLayerPropertiesForTesting(grandChild2.get(), identityMatrix, identityMatr
ix, FloatPoint(0, 0), FloatPoint(15, 15), IntSize(10, 10), false); | 1436 setLayerPropertiesForTesting(grandChild2.get(), identityMatrix, identityMatr
ix, FloatPoint(0, 0), FloatPoint(15, 15), IntSize(10, 10), false); |
1437 setLayerPropertiesForTesting(grandChild3.get(), identityMatrix, identityMatr
ix, FloatPoint(0, 0), FloatPoint(15, 15), IntSize(10, 10), false); | 1437 setLayerPropertiesForTesting(grandChild3.get(), identityMatrix, identityMatr
ix, FloatPoint(0, 0), FloatPoint(15, 15), IntSize(10, 10), false); |
1438 setLayerPropertiesForTesting(grandChild4.get(), identityMatrix, identityMatr
ix, FloatPoint(0, 0), FloatPoint(45, 45), IntSize(10, 10), false); | 1438 setLayerPropertiesForTesting(grandChild4.get(), identityMatrix, identityMatr
ix, FloatPoint(0, 0), FloatPoint(45, 45), IntSize(10, 10), false); |
1439 | 1439 |
1440 child->setMasksToBounds(true); | 1440 child->setMasksToBounds(true); |
1441 grandChild3->setMasksToBounds(true); | 1441 grandChild3->setMasksToBounds(true); |
1442 | 1442 |
1443 // Force everyone to be a render surface. | 1443 // Force everyone to be a render surface. |
1444 child->setOpacity(0.4f); | 1444 child->setOpacity(0.4f); |
1445 grandChild1->setOpacity(0.5); | 1445 grandChild1->setOpacity(0.5); |
1446 grandChild2->setOpacity(0.5); | 1446 grandChild2->setOpacity(0.5); |
1447 grandChild3->setOpacity(0.5); | 1447 grandChild3->setOpacity(0.5); |
1448 grandChild4->setOpacity(0.5); | 1448 grandChild4->setOpacity(0.5); |
1449 | 1449 |
1450 std::vector<scoped_refptr<LayerChromium> > renderSurfaceLayerList; | 1450 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
1451 int dummyMaxTextureSize = 512; | 1451 int dummyMaxTextureSize = 512; |
1452 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, dummyMaxTextureSize, renderSurfaceLayerList); | 1452 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
1, dummyMaxTextureSize, renderSurfaceLayerList); |
1453 | 1453 |
1454 EXPECT_RECT_EQ(IntRect(IntPoint(5, 5), IntSize(10, 10)), grandChild1->drawab
leContentRect()); | 1454 EXPECT_RECT_EQ(IntRect(IntPoint(5, 5), IntSize(10, 10)), grandChild1->drawab
leContentRect()); |
1455 EXPECT_RECT_EQ(IntRect(IntPoint(15, 15), IntSize(5, 5)), grandChild3->drawab
leContentRect()); | 1455 EXPECT_RECT_EQ(IntRect(IntPoint(15, 15), IntSize(5, 5)), grandChild3->drawab
leContentRect()); |
1456 EXPECT_RECT_EQ(IntRect(IntPoint(15, 15), IntSize(5, 5)), grandChild3->drawab
leContentRect()); | 1456 EXPECT_RECT_EQ(IntRect(IntPoint(15, 15), IntSize(5, 5)), grandChild3->drawab
leContentRect()); |
1457 EXPECT_TRUE(grandChild4->drawableContentRect().isEmpty()); | 1457 EXPECT_TRUE(grandChild4->drawableContentRect().isEmpty()); |
1458 } | 1458 } |
1459 | 1459 |
1460 TEST(CCLayerTreeHostCommonTest, verifyClipRectIsPropagatedCorrectlyToSurfaces) | 1460 TEST(LayerTreeHostCommonTest, verifyClipRectIsPropagatedCorrectlyToSurfaces) |
1461 { | 1461 { |
1462 // Verify that renderSurfaces (and their layers) get the appropriate clipRec
ts when their parent masksToBounds is true. | 1462 // Verify that renderSurfaces (and their layers) get the appropriate clipRec
ts when their parent masksToBounds is true. |
1463 // | 1463 // |
1464 // Layers that own renderSurfaces (at least for now) do not inherit any clip
ping; | 1464 // Layers that own renderSurfaces (at least for now) do not inherit any clip
ping; |
1465 // instead the surface will enforce the clip for the entire subtree. They ma
y still | 1465 // instead the surface will enforce the clip for the entire subtree. They ma
y still |
1466 // have a clipRect of their own layer bounds, however, if masksToBounds was
true. | 1466 // have a clipRect of their own layer bounds, however, if masksToBounds was
true. |
1467 // | 1467 // |
1468 | 1468 |
1469 const WebTransformationMatrix identityMatrix; | 1469 const WebTransformationMatrix identityMatrix; |
1470 scoped_refptr<LayerChromium> parent = LayerChromium::create(); | 1470 scoped_refptr<Layer> parent = Layer::create(); |
1471 scoped_refptr<LayerChromium> child = LayerChromium::create(); | 1471 scoped_refptr<Layer> child = Layer::create(); |
1472 scoped_refptr<LayerChromium> grandChild1 = LayerChromium::create(); | 1472 scoped_refptr<Layer> grandChild1 = Layer::create(); |
1473 scoped_refptr<LayerChromium> grandChild2 = LayerChromium::create(); | 1473 scoped_refptr<Layer> grandChild2 = Layer::create(); |
1474 scoped_refptr<LayerChromium> grandChild3 = LayerChromium::create(); | 1474 scoped_refptr<Layer> grandChild3 = Layer::create(); |
1475 scoped_refptr<LayerChromium> grandChild4 = LayerChromium::create(); | 1475 scoped_refptr<Layer> grandChild4 = Layer::create(); |
1476 scoped_refptr<LayerChromiumWithForcedDrawsContent> leafNode1 = make_scoped_r
efptr(new LayerChromiumWithForcedDrawsContent()); | 1476 scoped_refptr<LayerWithForcedDrawsContent> leafNode1 = make_scoped_refptr(ne
w LayerWithForcedDrawsContent()); |
1477 scoped_refptr<LayerChromiumWithForcedDrawsContent> leafNode2 = make_scoped_r
efptr(new LayerChromiumWithForcedDrawsContent()); | 1477 scoped_refptr<LayerWithForcedDrawsContent> leafNode2 = make_scoped_refptr(ne
w LayerWithForcedDrawsContent()); |
1478 scoped_refptr<LayerChromiumWithForcedDrawsContent> leafNode3 = make_scoped_r
efptr(new LayerChromiumWithForcedDrawsContent()); | 1478 scoped_refptr<LayerWithForcedDrawsContent> leafNode3 = make_scoped_refptr(ne
w LayerWithForcedDrawsContent()); |
1479 scoped_refptr<LayerChromiumWithForcedDrawsContent> leafNode4 = make_scoped_r
efptr(new LayerChromiumWithForcedDrawsContent()); | 1479 scoped_refptr<LayerWithForcedDrawsContent> leafNode4 = make_scoped_refptr(ne
w LayerWithForcedDrawsContent()); |
1480 | 1480 |
1481 parent->addChild(child); | 1481 parent->addChild(child); |
1482 child->addChild(grandChild1); | 1482 child->addChild(grandChild1); |
1483 child->addChild(grandChild2); | 1483 child->addChild(grandChild2); |
1484 child->addChild(grandChild3); | 1484 child->addChild(grandChild3); |
1485 child->addChild(grandChild4); | 1485 child->addChild(grandChild4); |
1486 | 1486 |
1487 // the leaf nodes ensure that these grandChildren become renderSurfaces for
this test. | 1487 // the leaf nodes ensure that these grandChildren become renderSurfaces for
this test. |
1488 grandChild1->addChild(leafNode1); | 1488 grandChild1->addChild(leafNode1); |
1489 grandChild2->addChild(leafNode2); | 1489 grandChild2->addChild(leafNode2); |
(...skipping 15 matching lines...) Expand all Loading... |
1505 grandChild3->setMasksToBounds(true); | 1505 grandChild3->setMasksToBounds(true); |
1506 grandChild4->setMasksToBounds(true); | 1506 grandChild4->setMasksToBounds(true); |
1507 | 1507 |
1508 // Force everyone to be a render surface. | 1508 // Force everyone to be a render surface. |
1509 child->setOpacity(0.4f); | 1509 child->setOpacity(0.4f); |
1510 grandChild1->setOpacity(0.5); | 1510 grandChild1->setOpacity(0.5); |
1511 grandChild2->setOpacity(0.5); | 1511 grandChild2->setOpacity(0.5); |
1512 grandChild3->setOpacity(0.5); | 1512 grandChild3->setOpacity(0.5); |
1513 grandChild4->setOpacity(0.5); | 1513 grandChild4->setOpacity(0.5); |
1514 | 1514 |
1515 std::vector<scoped_refptr<LayerChromium> > renderSurfaceLayerList; | 1515 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
1516 int dummyMaxTextureSize = 512; | 1516 int dummyMaxTextureSize = 512; |
1517 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, dummyMaxTextureSize, renderSurfaceLayerList); | 1517 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
1, dummyMaxTextureSize, renderSurfaceLayerList); |
1518 | 1518 |
1519 ASSERT_TRUE(grandChild1->renderSurface()); | 1519 ASSERT_TRUE(grandChild1->renderSurface()); |
1520 ASSERT_TRUE(grandChild2->renderSurface()); | 1520 ASSERT_TRUE(grandChild2->renderSurface()); |
1521 ASSERT_TRUE(grandChild3->renderSurface()); | 1521 ASSERT_TRUE(grandChild3->renderSurface()); |
1522 EXPECT_FALSE(grandChild4->renderSurface()); // Because grandChild4 is entire
ly clipped, it is expected to not have a renderSurface. | 1522 EXPECT_FALSE(grandChild4->renderSurface()); // Because grandChild4 is entire
ly clipped, it is expected to not have a renderSurface. |
1523 | 1523 |
1524 // Surfaces are clipped by their parent, but un-affected by the owning layer
's masksToBounds. | 1524 // Surfaces are clipped by their parent, but un-affected by the owning layer
's masksToBounds. |
1525 EXPECT_RECT_EQ(IntRect(IntPoint(0, 0), IntSize(20, 20)), grandChild1->render
Surface()->clipRect()); | 1525 EXPECT_RECT_EQ(IntRect(IntPoint(0, 0), IntSize(20, 20)), grandChild1->render
Surface()->clipRect()); |
1526 EXPECT_RECT_EQ(IntRect(IntPoint(0, 0), IntSize(20, 20)), grandChild2->render
Surface()->clipRect()); | 1526 EXPECT_RECT_EQ(IntRect(IntPoint(0, 0), IntSize(20, 20)), grandChild2->render
Surface()->clipRect()); |
1527 EXPECT_RECT_EQ(IntRect(IntPoint(0, 0), IntSize(20, 20)), grandChild3->render
Surface()->clipRect()); | 1527 EXPECT_RECT_EQ(IntRect(IntPoint(0, 0), IntSize(20, 20)), grandChild3->render
Surface()->clipRect()); |
1528 } | 1528 } |
1529 | 1529 |
1530 TEST(CCLayerTreeHostCommonTest, verifyAnimationsForRenderSurfaceHierarchy) | 1530 TEST(LayerTreeHostCommonTest, verifyAnimationsForRenderSurfaceHierarchy) |
1531 { | 1531 { |
1532 scoped_refptr<LayerChromium> parent = LayerChromium::create(); | 1532 scoped_refptr<Layer> parent = Layer::create(); |
1533 scoped_refptr<LayerChromium> renderSurface1 = LayerChromium::create(); | 1533 scoped_refptr<Layer> renderSurface1 = Layer::create(); |
1534 scoped_refptr<LayerChromium> renderSurface2 = LayerChromium::create(); | 1534 scoped_refptr<Layer> renderSurface2 = Layer::create(); |
1535 scoped_refptr<LayerChromium> childOfRoot = LayerChromium::create(); | 1535 scoped_refptr<Layer> childOfRoot = Layer::create(); |
1536 scoped_refptr<LayerChromium> childOfRS1 = LayerChromium::create(); | 1536 scoped_refptr<Layer> childOfRS1 = Layer::create(); |
1537 scoped_refptr<LayerChromium> childOfRS2 = LayerChromium::create(); | 1537 scoped_refptr<Layer> childOfRS2 = Layer::create(); |
1538 scoped_refptr<LayerChromium> grandChildOfRoot = LayerChromium::create(); | 1538 scoped_refptr<Layer> grandChildOfRoot = Layer::create(); |
1539 scoped_refptr<LayerChromiumWithForcedDrawsContent> grandChildOfRS1 = make_sc
oped_refptr(new LayerChromiumWithForcedDrawsContent()); | 1539 scoped_refptr<LayerWithForcedDrawsContent> grandChildOfRS1 = make_scoped_ref
ptr(new LayerWithForcedDrawsContent()); |
1540 scoped_refptr<LayerChromiumWithForcedDrawsContent> grandChildOfRS2 = make_sc
oped_refptr(new LayerChromiumWithForcedDrawsContent()); | 1540 scoped_refptr<LayerWithForcedDrawsContent> grandChildOfRS2 = make_scoped_ref
ptr(new LayerWithForcedDrawsContent()); |
1541 parent->addChild(renderSurface1); | 1541 parent->addChild(renderSurface1); |
1542 parent->addChild(childOfRoot); | 1542 parent->addChild(childOfRoot); |
1543 renderSurface1->addChild(childOfRS1); | 1543 renderSurface1->addChild(childOfRS1); |
1544 renderSurface1->addChild(renderSurface2); | 1544 renderSurface1->addChild(renderSurface2); |
1545 renderSurface2->addChild(childOfRS2); | 1545 renderSurface2->addChild(childOfRS2); |
1546 childOfRoot->addChild(grandChildOfRoot); | 1546 childOfRoot->addChild(grandChildOfRoot); |
1547 childOfRS1->addChild(grandChildOfRS1); | 1547 childOfRS1->addChild(grandChildOfRS1); |
1548 childOfRS2->addChild(grandChildOfRS2); | 1548 childOfRS2->addChild(grandChildOfRS2); |
1549 | 1549 |
1550 // Make our render surfaces. | 1550 // Make our render surfaces. |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1661 | 1661 |
1662 EXPECT_FLOAT_EQ(2, renderSurface1->screenSpaceTransform().m42()); | 1662 EXPECT_FLOAT_EQ(2, renderSurface1->screenSpaceTransform().m42()); |
1663 EXPECT_FLOAT_EQ(3, childOfRS1->screenSpaceTransform().m42()); | 1663 EXPECT_FLOAT_EQ(3, childOfRS1->screenSpaceTransform().m42()); |
1664 EXPECT_FLOAT_EQ(4, grandChildOfRS1->screenSpaceTransform().m42()); | 1664 EXPECT_FLOAT_EQ(4, grandChildOfRS1->screenSpaceTransform().m42()); |
1665 | 1665 |
1666 EXPECT_FLOAT_EQ(3, renderSurface2->screenSpaceTransform().m42()); | 1666 EXPECT_FLOAT_EQ(3, renderSurface2->screenSpaceTransform().m42()); |
1667 EXPECT_FLOAT_EQ(4, childOfRS2->screenSpaceTransform().m42()); | 1667 EXPECT_FLOAT_EQ(4, childOfRS2->screenSpaceTransform().m42()); |
1668 EXPECT_FLOAT_EQ(5, grandChildOfRS2->screenSpaceTransform().m42()); | 1668 EXPECT_FLOAT_EQ(5, grandChildOfRS2->screenSpaceTransform().m42()); |
1669 } | 1669 } |
1670 | 1670 |
1671 TEST(CCLayerTreeHostCommonTest, verifyVisibleRectForIdentityTransform) | 1671 TEST(LayerTreeHostCommonTest, verifyVisibleRectForIdentityTransform) |
1672 { | 1672 { |
1673 // Test the calculateVisibleRect() function works correctly for identity tra
nsforms. | 1673 // Test the calculateVisibleRect() function works correctly for identity tra
nsforms. |
1674 | 1674 |
1675 IntRect targetSurfaceRect = IntRect(IntPoint(0, 0), IntSize(100, 100)); | 1675 IntRect targetSurfaceRect = IntRect(IntPoint(0, 0), IntSize(100, 100)); |
1676 WebTransformationMatrix layerToSurfaceTransform; | 1676 WebTransformationMatrix layerToSurfaceTransform; |
1677 | 1677 |
1678 // Case 1: Layer is contained within the surface. | 1678 // Case 1: Layer is contained within the surface. |
1679 IntRect layerContentRect = IntRect(IntPoint(10, 10), IntSize(30, 30)); | 1679 IntRect layerContentRect = IntRect(IntPoint(10, 10), IntSize(30, 30)); |
1680 IntRect expected = IntRect(IntPoint(10, 10), IntSize(30, 30)); | 1680 IntRect expected = IntRect(IntPoint(10, 10), IntSize(30, 30)); |
1681 IntRect actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); | 1681 IntRect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect
, layerContentRect, layerToSurfaceTransform); |
1682 EXPECT_RECT_EQ(expected, actual); | 1682 EXPECT_RECT_EQ(expected, actual); |
1683 | 1683 |
1684 // Case 2: Layer is outside the surface rect. | 1684 // Case 2: Layer is outside the surface rect. |
1685 layerContentRect = IntRect(IntPoint(120, 120), IntSize(30, 30)); | 1685 layerContentRect = IntRect(IntPoint(120, 120), IntSize(30, 30)); |
1686 actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, laye
rContentRect, layerToSurfaceTransform); | 1686 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC
ontentRect, layerToSurfaceTransform); |
1687 EXPECT_TRUE(actual.isEmpty()); | 1687 EXPECT_TRUE(actual.isEmpty()); |
1688 | 1688 |
1689 // Case 3: Layer is partially overlapping the surface rect. | 1689 // Case 3: Layer is partially overlapping the surface rect. |
1690 layerContentRect = IntRect(IntPoint(80, 80), IntSize(30, 30)); | 1690 layerContentRect = IntRect(IntPoint(80, 80), IntSize(30, 30)); |
1691 expected = IntRect(IntPoint(80, 80), IntSize(20, 20)); | 1691 expected = IntRect(IntPoint(80, 80), IntSize(20, 20)); |
1692 actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, laye
rContentRect, layerToSurfaceTransform); | 1692 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC
ontentRect, layerToSurfaceTransform); |
1693 EXPECT_RECT_EQ(expected, actual); | 1693 EXPECT_RECT_EQ(expected, actual); |
1694 } | 1694 } |
1695 | 1695 |
1696 TEST(CCLayerTreeHostCommonTest, verifyVisibleRectForTranslations) | 1696 TEST(LayerTreeHostCommonTest, verifyVisibleRectForTranslations) |
1697 { | 1697 { |
1698 // Test the calculateVisibleRect() function works correctly for scaling tran
sforms. | 1698 // Test the calculateVisibleRect() function works correctly for scaling tran
sforms. |
1699 | 1699 |
1700 IntRect targetSurfaceRect = IntRect(IntPoint(0, 0), IntSize(100, 100)); | 1700 IntRect targetSurfaceRect = IntRect(IntPoint(0, 0), IntSize(100, 100)); |
1701 IntRect layerContentRect = IntRect(IntPoint(0, 0), IntSize(30, 30)); | 1701 IntRect layerContentRect = IntRect(IntPoint(0, 0), IntSize(30, 30)); |
1702 WebTransformationMatrix layerToSurfaceTransform; | 1702 WebTransformationMatrix layerToSurfaceTransform; |
1703 | 1703 |
1704 // Case 1: Layer is contained within the surface. | 1704 // Case 1: Layer is contained within the surface. |
1705 layerToSurfaceTransform.makeIdentity(); | 1705 layerToSurfaceTransform.makeIdentity(); |
1706 layerToSurfaceTransform.translate(10, 10); | 1706 layerToSurfaceTransform.translate(10, 10); |
1707 IntRect expected = IntRect(IntPoint(0, 0), IntSize(30, 30)); | 1707 IntRect expected = IntRect(IntPoint(0, 0), IntSize(30, 30)); |
1708 IntRect actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); | 1708 IntRect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect
, layerContentRect, layerToSurfaceTransform); |
1709 EXPECT_RECT_EQ(expected, actual); | 1709 EXPECT_RECT_EQ(expected, actual); |
1710 | 1710 |
1711 // Case 2: Layer is outside the surface rect. | 1711 // Case 2: Layer is outside the surface rect. |
1712 layerToSurfaceTransform.makeIdentity(); | 1712 layerToSurfaceTransform.makeIdentity(); |
1713 layerToSurfaceTransform.translate(120, 120); | 1713 layerToSurfaceTransform.translate(120, 120); |
1714 actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, laye
rContentRect, layerToSurfaceTransform); | 1714 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC
ontentRect, layerToSurfaceTransform); |
1715 EXPECT_TRUE(actual.isEmpty()); | 1715 EXPECT_TRUE(actual.isEmpty()); |
1716 | 1716 |
1717 // Case 3: Layer is partially overlapping the surface rect. | 1717 // Case 3: Layer is partially overlapping the surface rect. |
1718 layerToSurfaceTransform.makeIdentity(); | 1718 layerToSurfaceTransform.makeIdentity(); |
1719 layerToSurfaceTransform.translate(80, 80); | 1719 layerToSurfaceTransform.translate(80, 80); |
1720 expected = IntRect(IntPoint(0, 0), IntSize(20, 20)); | 1720 expected = IntRect(IntPoint(0, 0), IntSize(20, 20)); |
1721 actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, laye
rContentRect, layerToSurfaceTransform); | 1721 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC
ontentRect, layerToSurfaceTransform); |
1722 EXPECT_RECT_EQ(expected, actual); | 1722 EXPECT_RECT_EQ(expected, actual); |
1723 } | 1723 } |
1724 | 1724 |
1725 TEST(CCLayerTreeHostCommonTest, verifyVisibleRectFor2DRotations) | 1725 TEST(LayerTreeHostCommonTest, verifyVisibleRectFor2DRotations) |
1726 { | 1726 { |
1727 // Test the calculateVisibleRect() function works correctly for rotations ab
out z-axis (i.e. 2D rotations). | 1727 // Test the calculateVisibleRect() function works correctly for rotations ab
out z-axis (i.e. 2D rotations). |
1728 // Remember that calculateVisibleRect() should return the visible rect in th
e layer's space. | 1728 // Remember that calculateVisibleRect() should return the visible rect in th
e layer's space. |
1729 | 1729 |
1730 IntRect targetSurfaceRect = IntRect(IntPoint(0, 0), IntSize(100, 100)); | 1730 IntRect targetSurfaceRect = IntRect(IntPoint(0, 0), IntSize(100, 100)); |
1731 IntRect layerContentRect = IntRect(IntPoint(0, 0), IntSize(30, 30)); | 1731 IntRect layerContentRect = IntRect(IntPoint(0, 0), IntSize(30, 30)); |
1732 WebTransformationMatrix layerToSurfaceTransform; | 1732 WebTransformationMatrix layerToSurfaceTransform; |
1733 | 1733 |
1734 // Case 1: Layer is contained within the surface. | 1734 // Case 1: Layer is contained within the surface. |
1735 layerToSurfaceTransform.makeIdentity(); | 1735 layerToSurfaceTransform.makeIdentity(); |
1736 layerToSurfaceTransform.translate(50, 50); | 1736 layerToSurfaceTransform.translate(50, 50); |
1737 layerToSurfaceTransform.rotate(45); | 1737 layerToSurfaceTransform.rotate(45); |
1738 IntRect expected = IntRect(IntPoint(0, 0), IntSize(30, 30)); | 1738 IntRect expected = IntRect(IntPoint(0, 0), IntSize(30, 30)); |
1739 IntRect actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); | 1739 IntRect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect
, layerContentRect, layerToSurfaceTransform); |
1740 EXPECT_RECT_EQ(expected, actual); | 1740 EXPECT_RECT_EQ(expected, actual); |
1741 | 1741 |
1742 // Case 2: Layer is outside the surface rect. | 1742 // Case 2: Layer is outside the surface rect. |
1743 layerToSurfaceTransform.makeIdentity(); | 1743 layerToSurfaceTransform.makeIdentity(); |
1744 layerToSurfaceTransform.translate(-50, 0); | 1744 layerToSurfaceTransform.translate(-50, 0); |
1745 layerToSurfaceTransform.rotate(45); | 1745 layerToSurfaceTransform.rotate(45); |
1746 actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, laye
rContentRect, layerToSurfaceTransform); | 1746 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC
ontentRect, layerToSurfaceTransform); |
1747 EXPECT_TRUE(actual.isEmpty()); | 1747 EXPECT_TRUE(actual.isEmpty()); |
1748 | 1748 |
1749 // Case 3: The layer is rotated about its top-left corner. In surface space,
the layer | 1749 // Case 3: The layer is rotated about its top-left corner. In surface space,
the layer |
1750 // is oriented diagonally, with the left half outside of the renderS
urface. In | 1750 // is oriented diagonally, with the left half outside of the renderS
urface. In |
1751 // this case, the visible rect should still be the entire layer (rem
ember the | 1751 // this case, the visible rect should still be the entire layer (rem
ember the |
1752 // visible rect is computed in layer space); both the top-left and | 1752 // visible rect is computed in layer space); both the top-left and |
1753 // bottom-right corners of the layer are still visible. | 1753 // bottom-right corners of the layer are still visible. |
1754 layerToSurfaceTransform.makeIdentity(); | 1754 layerToSurfaceTransform.makeIdentity(); |
1755 layerToSurfaceTransform.rotate(45); | 1755 layerToSurfaceTransform.rotate(45); |
1756 expected = IntRect(IntPoint(0, 0), IntSize(30, 30)); | 1756 expected = IntRect(IntPoint(0, 0), IntSize(30, 30)); |
1757 actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, laye
rContentRect, layerToSurfaceTransform); | 1757 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC
ontentRect, layerToSurfaceTransform); |
1758 EXPECT_RECT_EQ(expected, actual); | 1758 EXPECT_RECT_EQ(expected, actual); |
1759 | 1759 |
1760 // Case 4: The layer is rotated about its top-left corner, and translated up
wards. In | 1760 // Case 4: The layer is rotated about its top-left corner, and translated up
wards. In |
1761 // surface space, the layer is oriented diagonally, with only the to
p corner | 1761 // surface space, the layer is oriented diagonally, with only the to
p corner |
1762 // of the surface overlapping the layer. In layer space, the render
surface | 1762 // of the surface overlapping the layer. In layer space, the render
surface |
1763 // overlaps the right side of the layer. The visible rect should be
the | 1763 // overlaps the right side of the layer. The visible rect should be
the |
1764 // layer's right half. | 1764 // layer's right half. |
1765 layerToSurfaceTransform.makeIdentity(); | 1765 layerToSurfaceTransform.makeIdentity(); |
1766 layerToSurfaceTransform.translate(0, -sqrt(2.0) * 15); | 1766 layerToSurfaceTransform.translate(0, -sqrt(2.0) * 15); |
1767 layerToSurfaceTransform.rotate(45); | 1767 layerToSurfaceTransform.rotate(45); |
1768 expected = IntRect(IntPoint(15, 0), IntSize(15, 30)); // right half of layer
bounds. | 1768 expected = IntRect(IntPoint(15, 0), IntSize(15, 30)); // right half of layer
bounds. |
1769 actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, laye
rContentRect, layerToSurfaceTransform); | 1769 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC
ontentRect, layerToSurfaceTransform); |
1770 EXPECT_RECT_EQ(expected, actual); | 1770 EXPECT_RECT_EQ(expected, actual); |
1771 } | 1771 } |
1772 | 1772 |
1773 TEST(CCLayerTreeHostCommonTest, verifyVisibleRectFor3dOrthographicTransform) | 1773 TEST(LayerTreeHostCommonTest, verifyVisibleRectFor3dOrthographicTransform) |
1774 { | 1774 { |
1775 // Test that the calculateVisibleRect() function works correctly for 3d tran
sforms. | 1775 // Test that the calculateVisibleRect() function works correctly for 3d tran
sforms. |
1776 | 1776 |
1777 IntRect targetSurfaceRect = IntRect(IntPoint(0, 0), IntSize(100, 100)); | 1777 IntRect targetSurfaceRect = IntRect(IntPoint(0, 0), IntSize(100, 100)); |
1778 IntRect layerContentRect = IntRect(IntPoint(0, 0), IntSize(100, 100)); | 1778 IntRect layerContentRect = IntRect(IntPoint(0, 0), IntSize(100, 100)); |
1779 WebTransformationMatrix layerToSurfaceTransform; | 1779 WebTransformationMatrix layerToSurfaceTransform; |
1780 | 1780 |
1781 // Case 1: Orthographic projection of a layer rotated about y-axis by 45 deg
rees, should be fully contained in the renderSurface. | 1781 // Case 1: Orthographic projection of a layer rotated about y-axis by 45 deg
rees, should be fully contained in the renderSurface. |
1782 layerToSurfaceTransform.makeIdentity(); | 1782 layerToSurfaceTransform.makeIdentity(); |
1783 layerToSurfaceTransform.rotate3d(0, 45, 0); | 1783 layerToSurfaceTransform.rotate3d(0, 45, 0); |
1784 IntRect expected = IntRect(IntPoint(0, 0), IntSize(100, 100)); | 1784 IntRect expected = IntRect(IntPoint(0, 0), IntSize(100, 100)); |
1785 IntRect actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); | 1785 IntRect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect
, layerContentRect, layerToSurfaceTransform); |
1786 EXPECT_RECT_EQ(expected, actual); | 1786 EXPECT_RECT_EQ(expected, actual); |
1787 | 1787 |
1788 // Case 2: Orthographic projection of a layer rotated about y-axis by 45 deg
rees, but | 1788 // Case 2: Orthographic projection of a layer rotated about y-axis by 45 deg
rees, but |
1789 // shifted to the side so only the right-half the layer would be vis
ible on | 1789 // shifted to the side so only the right-half the layer would be vis
ible on |
1790 // the surface. | 1790 // the surface. |
1791 double halfWidthOfRotatedLayer = (100 / sqrt(2.0)) * 0.5; // 100 is the un-r
otated layer width; divided by sqrt(2) is the rotated width. | 1791 double halfWidthOfRotatedLayer = (100 / sqrt(2.0)) * 0.5; // 100 is the un-r
otated layer width; divided by sqrt(2) is the rotated width. |
1792 layerToSurfaceTransform.makeIdentity(); | 1792 layerToSurfaceTransform.makeIdentity(); |
1793 layerToSurfaceTransform.translate(-halfWidthOfRotatedLayer, 0); | 1793 layerToSurfaceTransform.translate(-halfWidthOfRotatedLayer, 0); |
1794 layerToSurfaceTransform.rotate3d(0, 45, 0); // rotates about the left edge o
f the layer | 1794 layerToSurfaceTransform.rotate3d(0, 45, 0); // rotates about the left edge o
f the layer |
1795 expected = IntRect(IntPoint(50, 0), IntSize(50, 100)); // right half of the
layer. | 1795 expected = IntRect(IntPoint(50, 0), IntSize(50, 100)); // right half of the
layer. |
1796 actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, laye
rContentRect, layerToSurfaceTransform); | 1796 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC
ontentRect, layerToSurfaceTransform); |
1797 EXPECT_RECT_EQ(expected, actual); | 1797 EXPECT_RECT_EQ(expected, actual); |
1798 } | 1798 } |
1799 | 1799 |
1800 TEST(CCLayerTreeHostCommonTest, verifyVisibleRectFor3dPerspectiveTransform) | 1800 TEST(LayerTreeHostCommonTest, verifyVisibleRectFor3dPerspectiveTransform) |
1801 { | 1801 { |
1802 // Test the calculateVisibleRect() function works correctly when the layer h
as a | 1802 // Test the calculateVisibleRect() function works correctly when the layer h
as a |
1803 // perspective projection onto the target surface. | 1803 // perspective projection onto the target surface. |
1804 | 1804 |
1805 IntRect targetSurfaceRect = IntRect(IntPoint(0, 0), IntSize(100, 100)); | 1805 IntRect targetSurfaceRect = IntRect(IntPoint(0, 0), IntSize(100, 100)); |
1806 IntRect layerContentRect = IntRect(IntPoint(-50, -50), IntSize(200, 200)); | 1806 IntRect layerContentRect = IntRect(IntPoint(-50, -50), IntSize(200, 200)); |
1807 WebTransformationMatrix layerToSurfaceTransform; | 1807 WebTransformationMatrix layerToSurfaceTransform; |
1808 | 1808 |
1809 // Case 1: Even though the layer is twice as large as the surface, due to pe
rspective | 1809 // Case 1: Even though the layer is twice as large as the surface, due to pe
rspective |
1810 // foreshortening, the layer will fit fully in the surface when its
translated | 1810 // foreshortening, the layer will fit fully in the surface when its
translated |
1811 // more than the perspective amount. | 1811 // more than the perspective amount. |
1812 layerToSurfaceTransform.makeIdentity(); | 1812 layerToSurfaceTransform.makeIdentity(); |
1813 | 1813 |
1814 // The following sequence of transforms applies the perspective about the ce
nter of the surface. | 1814 // The following sequence of transforms applies the perspective about the ce
nter of the surface. |
1815 layerToSurfaceTransform.translate(50, 50); | 1815 layerToSurfaceTransform.translate(50, 50); |
1816 layerToSurfaceTransform.applyPerspective(9); | 1816 layerToSurfaceTransform.applyPerspective(9); |
1817 layerToSurfaceTransform.translate(-50, -50); | 1817 layerToSurfaceTransform.translate(-50, -50); |
1818 | 1818 |
1819 // This translate places the layer in front of the surface's projection plan
e. | 1819 // This translate places the layer in front of the surface's projection plan
e. |
1820 layerToSurfaceTransform.translate3d(0, 0, -27); | 1820 layerToSurfaceTransform.translate3d(0, 0, -27); |
1821 | 1821 |
1822 IntRect expected = IntRect(IntPoint(-50, -50), IntSize(200, 200)); | 1822 IntRect expected = IntRect(IntPoint(-50, -50), IntSize(200, 200)); |
1823 IntRect actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); | 1823 IntRect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect
, layerContentRect, layerToSurfaceTransform); |
1824 EXPECT_RECT_EQ(expected, actual); | 1824 EXPECT_RECT_EQ(expected, actual); |
1825 | 1825 |
1826 // Case 2: same projection as before, except that the layer is also translat
ed to the | 1826 // Case 2: same projection as before, except that the layer is also translat
ed to the |
1827 // side, so that only the right half of the layer should be visible. | 1827 // side, so that only the right half of the layer should be visible. |
1828 // | 1828 // |
1829 // Explanation of expected result: | 1829 // Explanation of expected result: |
1830 // The perspective ratio is (z distance between layer and camera origin) / (
z distance between projection plane and camera origin) == ((-27 - 9) / 9) | 1830 // The perspective ratio is (z distance between layer and camera origin) / (
z distance between projection plane and camera origin) == ((-27 - 9) / 9) |
1831 // 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 | 1831 // 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 |
1832 // visible), then we would need to translate by (-36 / 9) * -50 == -200 in t
he layer's units. | 1832 // visible), then we would need to translate by (-36 / 9) * -50 == -200 in t
he layer's units. |
1833 // | 1833 // |
1834 layerToSurfaceTransform.translate3d(-200, 0, 0); | 1834 layerToSurfaceTransform.translate3d(-200, 0, 0); |
1835 expected = IntRect(IntPoint(50, -50), IntSize(100, 200)); // The right half
of the layer's bounding rect. | 1835 expected = IntRect(IntPoint(50, -50), IntSize(100, 200)); // The right half
of the layer's bounding rect. |
1836 actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, laye
rContentRect, layerToSurfaceTransform); | 1836 actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerC
ontentRect, layerToSurfaceTransform); |
1837 EXPECT_RECT_EQ(expected, actual); | 1837 EXPECT_RECT_EQ(expected, actual); |
1838 } | 1838 } |
1839 | 1839 |
1840 TEST(CCLayerTreeHostCommonTest, verifyVisibleRectFor3dOrthographicIsNotClippedBe
hindSurface) | 1840 TEST(LayerTreeHostCommonTest, verifyVisibleRectFor3dOrthographicIsNotClippedBehi
ndSurface) |
1841 { | 1841 { |
1842 // There is currently no explicit concept of an orthographic projection plan
e in our | 1842 // There is currently no explicit concept of an orthographic projection plan
e in our |
1843 // code (nor in the CSS spec to my knowledge). Therefore, layers that are te
chnically | 1843 // code (nor in the CSS spec to my knowledge). Therefore, layers that are te
chnically |
1844 // behind the surface in an orthographic world should not be clipped when th
ey are | 1844 // behind the surface in an orthographic world should not be clipped when th
ey are |
1845 // flattened to the surface. | 1845 // flattened to the surface. |
1846 | 1846 |
1847 IntRect targetSurfaceRect = IntRect(IntPoint(0, 0), IntSize(100, 100)); | 1847 IntRect targetSurfaceRect = IntRect(IntPoint(0, 0), IntSize(100, 100)); |
1848 IntRect layerContentRect = IntRect(IntPoint(0, 0), IntSize(100, 100)); | 1848 IntRect layerContentRect = IntRect(IntPoint(0, 0), IntSize(100, 100)); |
1849 WebTransformationMatrix layerToSurfaceTransform; | 1849 WebTransformationMatrix layerToSurfaceTransform; |
1850 | 1850 |
1851 // This sequence of transforms effectively rotates the layer about the y-axi
s at the | 1851 // This sequence of transforms effectively rotates the layer about the y-axi
s at the |
1852 // center of the layer. | 1852 // center of the layer. |
1853 layerToSurfaceTransform.makeIdentity(); | 1853 layerToSurfaceTransform.makeIdentity(); |
1854 layerToSurfaceTransform.translate(50, 0); | 1854 layerToSurfaceTransform.translate(50, 0); |
1855 layerToSurfaceTransform.rotate3d(0, 45, 0); | 1855 layerToSurfaceTransform.rotate3d(0, 45, 0); |
1856 layerToSurfaceTransform.translate(-50, 0); | 1856 layerToSurfaceTransform.translate(-50, 0); |
1857 | 1857 |
1858 IntRect expected = IntRect(IntPoint(0, 0), IntSize(100, 100)); | 1858 IntRect expected = IntRect(IntPoint(0, 0), IntSize(100, 100)); |
1859 IntRect actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); | 1859 IntRect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect
, layerContentRect, layerToSurfaceTransform); |
1860 EXPECT_RECT_EQ(expected, actual); | 1860 EXPECT_RECT_EQ(expected, actual); |
1861 } | 1861 } |
1862 | 1862 |
1863 TEST(CCLayerTreeHostCommonTest, verifyVisibleRectFor3dPerspectiveWhenClippedByW) | 1863 TEST(LayerTreeHostCommonTest, verifyVisibleRectFor3dPerspectiveWhenClippedByW) |
1864 { | 1864 { |
1865 // Test the calculateVisibleRect() function works correctly when projecting
a surface | 1865 // Test the calculateVisibleRect() function works correctly when projecting
a surface |
1866 // onto a layer, but the layer is partially behind the camera (not just behi
nd the | 1866 // onto a layer, but the layer is partially behind the camera (not just behi
nd the |
1867 // projection plane). In this case, the cartesian coordinates may seem to be
valid, | 1867 // projection plane). In this case, the cartesian coordinates may seem to be
valid, |
1868 // but actually they are not. The visibleRect needs to be properly clipped b
y the | 1868 // but actually they are not. The visibleRect needs to be properly clipped b
y the |
1869 // w = 0 plane in homogeneous coordinates before converting to cartesian coo
rdinates. | 1869 // w = 0 plane in homogeneous coordinates before converting to cartesian coo
rdinates. |
1870 | 1870 |
1871 IntRect targetSurfaceRect = IntRect(IntPoint(-50, -50), IntSize(100, 100)); | 1871 IntRect targetSurfaceRect = IntRect(IntPoint(-50, -50), IntSize(100, 100)); |
1872 IntRect layerContentRect = IntRect(IntPoint(-10, -1), IntSize(20, 2)); | 1872 IntRect layerContentRect = IntRect(IntPoint(-10, -1), IntSize(20, 2)); |
1873 WebTransformationMatrix layerToSurfaceTransform; | 1873 WebTransformationMatrix layerToSurfaceTransform; |
1874 | 1874 |
1875 // The layer is positioned so that the right half of the layer should be in
front of | 1875 // The layer is positioned so that the right half of the layer should be in
front of |
1876 // the camera, while the other half is behind the surface's projection plane
. The | 1876 // the camera, while the other half is behind the surface's projection plane
. The |
1877 // following sequence of transforms applies the perspective and rotation abo
ut the | 1877 // following sequence of transforms applies the perspective and rotation abo
ut the |
1878 // center of the layer. | 1878 // center of the layer. |
1879 layerToSurfaceTransform.makeIdentity(); | 1879 layerToSurfaceTransform.makeIdentity(); |
1880 layerToSurfaceTransform.applyPerspective(1); | 1880 layerToSurfaceTransform.applyPerspective(1); |
1881 layerToSurfaceTransform.translate3d(-2, 0, 1); | 1881 layerToSurfaceTransform.translate3d(-2, 0, 1); |
1882 layerToSurfaceTransform.rotate3d(0, 45, 0); | 1882 layerToSurfaceTransform.rotate3d(0, 45, 0); |
1883 | 1883 |
1884 // Sanity check that this transform does indeed cause w < 0 when applying th
e | 1884 // Sanity check that this transform does indeed cause w < 0 when applying th
e |
1885 // transform, otherwise this code is not testing the intended scenario. | 1885 // transform, otherwise this code is not testing the intended scenario. |
1886 bool clipped = false; | 1886 bool clipped = false; |
1887 CCMathUtil::mapQuad(layerToSurfaceTransform, FloatQuad(FloatRect(layerConten
tRect)), clipped); | 1887 MathUtil::mapQuad(layerToSurfaceTransform, FloatQuad(FloatRect(layerContentR
ect)), clipped); |
1888 ASSERT_TRUE(clipped); | 1888 ASSERT_TRUE(clipped); |
1889 | 1889 |
1890 int expectedXPosition = 0; | 1890 int expectedXPosition = 0; |
1891 int expectedWidth = 10; | 1891 int expectedWidth = 10; |
1892 IntRect actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); | 1892 IntRect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect
, layerContentRect, layerToSurfaceTransform); |
1893 EXPECT_EQ(expectedXPosition, actual.x()); | 1893 EXPECT_EQ(expectedXPosition, actual.x()); |
1894 EXPECT_EQ(expectedWidth, actual.width()); | 1894 EXPECT_EQ(expectedWidth, actual.width()); |
1895 } | 1895 } |
1896 | 1896 |
1897 TEST(CCLayerTreeHostCommonTest, verifyVisibleRectForPerspectiveUnprojection) | 1897 TEST(LayerTreeHostCommonTest, verifyVisibleRectForPerspectiveUnprojection) |
1898 { | 1898 { |
1899 // To determine visibleRect in layer space, there needs to be an un-projecti
on from | 1899 // To determine visibleRect in layer space, there needs to be an un-projecti
on from |
1900 // surface space to layer space. When the original transform was a perspecti
ve | 1900 // surface space to layer space. When the original transform was a perspecti
ve |
1901 // projection that was clipped, it returns a rect that encloses the clipped
bounds. | 1901 // projection that was clipped, it returns a rect that encloses the clipped
bounds. |
1902 // Un-projecting this new rect may require clipping again. | 1902 // Un-projecting this new rect may require clipping again. |
1903 | 1903 |
1904 // This sequence of transforms causes one corner of the layer to protrude ac
ross the w = 0 plane, and should be clipped. | 1904 // This sequence of transforms causes one corner of the layer to protrude ac
ross the w = 0 plane, and should be clipped. |
1905 IntRect targetSurfaceRect = IntRect(IntPoint(-50, -50), IntSize(100, 100)); | 1905 IntRect targetSurfaceRect = IntRect(IntPoint(-50, -50), IntSize(100, 100)); |
1906 IntRect layerContentRect = IntRect(IntPoint(-10, -10), IntSize(20, 20)); | 1906 IntRect layerContentRect = IntRect(IntPoint(-10, -10), IntSize(20, 20)); |
1907 WebTransformationMatrix layerToSurfaceTransform; | 1907 WebTransformationMatrix layerToSurfaceTransform; |
1908 layerToSurfaceTransform.makeIdentity(); | 1908 layerToSurfaceTransform.makeIdentity(); |
1909 layerToSurfaceTransform.applyPerspective(1); | 1909 layerToSurfaceTransform.applyPerspective(1); |
1910 layerToSurfaceTransform.translate3d(0, 0, -5); | 1910 layerToSurfaceTransform.translate3d(0, 0, -5); |
1911 layerToSurfaceTransform.rotate3d(0, 45, 0); | 1911 layerToSurfaceTransform.rotate3d(0, 45, 0); |
1912 layerToSurfaceTransform.rotate3d(80, 0, 0); | 1912 layerToSurfaceTransform.rotate3d(80, 0, 0); |
1913 | 1913 |
1914 // Sanity check that un-projection does indeed cause w < 0, otherwise this c
ode is not | 1914 // Sanity check that un-projection does indeed cause w < 0, otherwise this c
ode is not |
1915 // testing the intended scenario. | 1915 // testing the intended scenario. |
1916 bool clipped = false; | 1916 bool clipped = false; |
1917 FloatRect clippedRect = CCMathUtil::mapClippedRect(layerToSurfaceTransform,
layerContentRect); | 1917 FloatRect clippedRect = MathUtil::mapClippedRect(layerToSurfaceTransform, la
yerContentRect); |
1918 CCMathUtil::projectQuad(layerToSurfaceTransform.inverse(), FloatQuad(clipped
Rect), clipped); | 1918 MathUtil::projectQuad(layerToSurfaceTransform.inverse(), FloatQuad(clippedRe
ct), clipped); |
1919 ASSERT_TRUE(clipped); | 1919 ASSERT_TRUE(clipped); |
1920 | 1920 |
1921 // Only the corner of the layer is not visible on the surface because of bei
ng | 1921 // Only the corner of the layer is not visible on the surface because of bei
ng |
1922 // clipped. But, the net result of rounding visible region to an axis-aligne
d rect is | 1922 // clipped. But, the net result of rounding visible region to an axis-aligne
d rect is |
1923 // that the entire layer should still be considered visible. | 1923 // that the entire layer should still be considered visible. |
1924 IntRect expected = IntRect(IntPoint(-10, -10), IntSize(20, 20)); | 1924 IntRect expected = IntRect(IntPoint(-10, -10), IntSize(20, 20)); |
1925 IntRect actual = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); | 1925 IntRect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect
, layerContentRect, layerToSurfaceTransform); |
1926 EXPECT_RECT_EQ(expected, actual); | 1926 EXPECT_RECT_EQ(expected, actual); |
1927 } | 1927 } |
1928 | 1928 |
1929 TEST(CCLayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsForSimpleLay
ers) | 1929 TEST(LayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsForSimpleLayer
s) |
1930 { | 1930 { |
1931 scoped_refptr<LayerChromium> root = LayerChromium::create(); | 1931 scoped_refptr<Layer> root = Layer::create(); |
1932 scoped_refptr<LayerChromiumWithForcedDrawsContent> child1 = make_scoped_refp
tr(new LayerChromiumWithForcedDrawsContent()); | 1932 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
1933 scoped_refptr<LayerChromiumWithForcedDrawsContent> child2 = make_scoped_refp
tr(new LayerChromiumWithForcedDrawsContent()); | 1933 scoped_refptr<LayerWithForcedDrawsContent> child2 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
1934 scoped_refptr<LayerChromiumWithForcedDrawsContent> child3 = make_scoped_refp
tr(new LayerChromiumWithForcedDrawsContent()); | 1934 scoped_refptr<LayerWithForcedDrawsContent> child3 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
1935 root->addChild(child1); | 1935 root->addChild(child1); |
1936 root->addChild(child2); | 1936 root->addChild(child2); |
1937 root->addChild(child3); | 1937 root->addChild(child3); |
1938 | 1938 |
1939 WebTransformationMatrix identityMatrix; | 1939 WebTransformationMatrix identityMatrix; |
1940 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, Flo
atPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 1940 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, Flo
atPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
1941 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(50, 50), false); | 1941 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(50, 50), false); |
1942 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(75, 75), IntSize(50, 50), false); | 1942 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(75, 75), IntSize(50, 50), false); |
1943 setLayerPropertiesForTesting(child3.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(125, 125), IntSize(50, 50), false); | 1943 setLayerPropertiesForTesting(child3.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(125, 125), IntSize(50, 50), false); |
1944 | 1944 |
1945 executeCalculateDrawTransformsAndVisibility(root.get()); | 1945 executeCalculateDrawTransformsAndVisibility(root.get()); |
1946 | 1946 |
1947 EXPECT_RECT_EQ(IntRect(0, 0, 100, 100), root->renderSurface()->drawableConte
ntRect()); | 1947 EXPECT_RECT_EQ(IntRect(0, 0, 100, 100), root->renderSurface()->drawableConte
ntRect()); |
1948 EXPECT_RECT_EQ(IntRect(0, 0, 100, 100), root->drawableContentRect()); | 1948 EXPECT_RECT_EQ(IntRect(0, 0, 100, 100), root->drawableContentRect()); |
1949 | 1949 |
1950 // Layers that do not draw content should have empty visibleContentRects. | 1950 // Layers that do not draw content should have empty visibleContentRects. |
1951 EXPECT_RECT_EQ(IntRect(0, 0, 0, 0), root->visibleContentRect()); | 1951 EXPECT_RECT_EQ(IntRect(0, 0, 0, 0), root->visibleContentRect()); |
1952 | 1952 |
1953 // layer visibleContentRects are clipped by their targetSurface | 1953 // layer visibleContentRects are clipped by their targetSurface |
1954 EXPECT_RECT_EQ(IntRect(0, 0, 50, 50), child1->visibleContentRect()); | 1954 EXPECT_RECT_EQ(IntRect(0, 0, 50, 50), child1->visibleContentRect()); |
1955 EXPECT_RECT_EQ(IntRect(0, 0, 25, 25), child2->visibleContentRect()); | 1955 EXPECT_RECT_EQ(IntRect(0, 0, 25, 25), child2->visibleContentRect()); |
1956 EXPECT_TRUE(child3->visibleContentRect().isEmpty()); | 1956 EXPECT_TRUE(child3->visibleContentRect().isEmpty()); |
1957 | 1957 |
1958 // layer drawableContentRects are not clipped. | 1958 // layer drawableContentRects are not clipped. |
1959 EXPECT_RECT_EQ(IntRect(0, 0, 50, 50), child1->drawableContentRect()); | 1959 EXPECT_RECT_EQ(IntRect(0, 0, 50, 50), child1->drawableContentRect()); |
1960 EXPECT_RECT_EQ(IntRect(75, 75, 50, 50), child2->drawableContentRect()); | 1960 EXPECT_RECT_EQ(IntRect(75, 75, 50, 50), child2->drawableContentRect()); |
1961 EXPECT_RECT_EQ(IntRect(125, 125, 50, 50), child3->drawableContentRect()); | 1961 EXPECT_RECT_EQ(IntRect(125, 125, 50, 50), child3->drawableContentRect()); |
1962 } | 1962 } |
1963 | 1963 |
1964 TEST(CCLayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsForLayersCli
ppedByLayer) | 1964 TEST(LayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsForLayersClipp
edByLayer) |
1965 { | 1965 { |
1966 scoped_refptr<LayerChromium> root = LayerChromium::create(); | 1966 scoped_refptr<Layer> root = Layer::create(); |
1967 scoped_refptr<LayerChromium> child = LayerChromium::create(); | 1967 scoped_refptr<Layer> child = Layer::create(); |
1968 scoped_refptr<LayerChromiumWithForcedDrawsContent> grandChild1 = make_scoped
_refptr(new LayerChromiumWithForcedDrawsContent()); | 1968 scoped_refptr<LayerWithForcedDrawsContent> grandChild1 = make_scoped_refptr(
new LayerWithForcedDrawsContent()); |
1969 scoped_refptr<LayerChromiumWithForcedDrawsContent> grandChild2 = make_scoped
_refptr(new LayerChromiumWithForcedDrawsContent()); | 1969 scoped_refptr<LayerWithForcedDrawsContent> grandChild2 = make_scoped_refptr(
new LayerWithForcedDrawsContent()); |
1970 scoped_refptr<LayerChromiumWithForcedDrawsContent> grandChild3 = make_scoped
_refptr(new LayerChromiumWithForcedDrawsContent()); | 1970 scoped_refptr<LayerWithForcedDrawsContent> grandChild3 = make_scoped_refptr(
new LayerWithForcedDrawsContent()); |
1971 root->addChild(child); | 1971 root->addChild(child); |
1972 child->addChild(grandChild1); | 1972 child->addChild(grandChild1); |
1973 child->addChild(grandChild2); | 1973 child->addChild(grandChild2); |
1974 child->addChild(grandChild3); | 1974 child->addChild(grandChild3); |
1975 | 1975 |
1976 WebTransformationMatrix identityMatrix; | 1976 WebTransformationMatrix identityMatrix; |
1977 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, Flo
atPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 1977 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, Flo
atPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
1978 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 1978 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
1979 setLayerPropertiesForTesting(grandChild1.get(), identityMatrix, identityMatr
ix, FloatPoint(0, 0), FloatPoint(5, 5), IntSize(50, 50), false); | 1979 setLayerPropertiesForTesting(grandChild1.get(), identityMatrix, identityMatr
ix, FloatPoint(0, 0), FloatPoint(5, 5), IntSize(50, 50), false); |
1980 setLayerPropertiesForTesting(grandChild2.get(), identityMatrix, identityMatr
ix, FloatPoint(0, 0), FloatPoint(75, 75), IntSize(50, 50), false); | 1980 setLayerPropertiesForTesting(grandChild2.get(), identityMatrix, identityMatr
ix, FloatPoint(0, 0), FloatPoint(75, 75), IntSize(50, 50), false); |
(...skipping 15 matching lines...) Expand all Loading... |
1996 EXPECT_RECT_EQ(IntRect(0, 0, 50, 50), grandChild1->visibleContentRect()); | 1996 EXPECT_RECT_EQ(IntRect(0, 0, 50, 50), grandChild1->visibleContentRect()); |
1997 EXPECT_RECT_EQ(IntRect(0, 0, 25, 25), grandChild2->visibleContentRect()); | 1997 EXPECT_RECT_EQ(IntRect(0, 0, 25, 25), grandChild2->visibleContentRect()); |
1998 EXPECT_TRUE(grandChild3->visibleContentRect().isEmpty()); | 1998 EXPECT_TRUE(grandChild3->visibleContentRect().isEmpty()); |
1999 | 1999 |
2000 // All grandchild drawableContentRects should also be clipped by child. | 2000 // All grandchild drawableContentRects should also be clipped by child. |
2001 EXPECT_RECT_EQ(IntRect(5, 5, 50, 50), grandChild1->drawableContentRect()); | 2001 EXPECT_RECT_EQ(IntRect(5, 5, 50, 50), grandChild1->drawableContentRect()); |
2002 EXPECT_RECT_EQ(IntRect(75, 75, 25, 25), grandChild2->drawableContentRect()); | 2002 EXPECT_RECT_EQ(IntRect(75, 75, 25, 25), grandChild2->drawableContentRect()); |
2003 EXPECT_TRUE(grandChild3->drawableContentRect().isEmpty()); | 2003 EXPECT_TRUE(grandChild3->drawableContentRect().isEmpty()); |
2004 } | 2004 } |
2005 | 2005 |
2006 TEST(CCLayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsForLayersInU
nclippedRenderSurface) | 2006 TEST(LayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsForLayersInUnc
lippedRenderSurface) |
2007 { | 2007 { |
2008 scoped_refptr<LayerChromium> root = LayerChromium::create(); | 2008 scoped_refptr<Layer> root = Layer::create(); |
2009 scoped_refptr<LayerChromium> renderSurface1 = LayerChromium::create(); | 2009 scoped_refptr<Layer> renderSurface1 = Layer::create(); |
2010 scoped_refptr<LayerChromiumWithForcedDrawsContent> child1 = make_scoped_refp
tr(new LayerChromiumWithForcedDrawsContent()); | 2010 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
2011 scoped_refptr<LayerChromiumWithForcedDrawsContent> child2 = make_scoped_refp
tr(new LayerChromiumWithForcedDrawsContent()); | 2011 scoped_refptr<LayerWithForcedDrawsContent> child2 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
2012 scoped_refptr<LayerChromiumWithForcedDrawsContent> child3 = make_scoped_refp
tr(new LayerChromiumWithForcedDrawsContent()); | 2012 scoped_refptr<LayerWithForcedDrawsContent> child3 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
2013 root->addChild(renderSurface1); | 2013 root->addChild(renderSurface1); |
2014 renderSurface1->addChild(child1); | 2014 renderSurface1->addChild(child1); |
2015 renderSurface1->addChild(child2); | 2015 renderSurface1->addChild(child2); |
2016 renderSurface1->addChild(child3); | 2016 renderSurface1->addChild(child3); |
2017 | 2017 |
2018 WebTransformationMatrix identityMatrix; | 2018 WebTransformationMatrix identityMatrix; |
2019 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, Flo
atPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 2019 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, Flo
atPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
2020 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(3, 4), false); | 2020 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(3, 4), false); |
2021 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(5, 5), IntSize(50, 50), false); | 2021 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(5, 5), IntSize(50, 50), false); |
2022 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(75, 75), IntSize(50, 50), false); | 2022 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(75, 75), IntSize(50, 50), false); |
(...skipping 17 matching lines...) Expand all Loading... |
2040 // All layers that draw content into the unclipped surface are also unclippe
d. | 2040 // All layers that draw content into the unclipped surface are also unclippe
d. |
2041 EXPECT_RECT_EQ(IntRect(0, 0, 50, 50), child1->visibleContentRect()); | 2041 EXPECT_RECT_EQ(IntRect(0, 0, 50, 50), child1->visibleContentRect()); |
2042 EXPECT_RECT_EQ(IntRect(0, 0, 50, 50), child2->visibleContentRect()); | 2042 EXPECT_RECT_EQ(IntRect(0, 0, 50, 50), child2->visibleContentRect()); |
2043 EXPECT_RECT_EQ(IntRect(0, 0, 50, 50), child3->visibleContentRect()); | 2043 EXPECT_RECT_EQ(IntRect(0, 0, 50, 50), child3->visibleContentRect()); |
2044 | 2044 |
2045 EXPECT_RECT_EQ(IntRect(5, 5, 50, 50), child1->drawableContentRect()); | 2045 EXPECT_RECT_EQ(IntRect(5, 5, 50, 50), child1->drawableContentRect()); |
2046 EXPECT_RECT_EQ(IntRect(75, 75, 50, 50), child2->drawableContentRect()); | 2046 EXPECT_RECT_EQ(IntRect(75, 75, 50, 50), child2->drawableContentRect()); |
2047 EXPECT_RECT_EQ(IntRect(125, 125, 50, 50), child3->drawableContentRect()); | 2047 EXPECT_RECT_EQ(IntRect(125, 125, 50, 50), child3->drawableContentRect()); |
2048 } | 2048 } |
2049 | 2049 |
2050 TEST(CCLayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsForLayersInC
lippedRenderSurface) | 2050 TEST(LayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsForLayersInCli
ppedRenderSurface) |
2051 { | 2051 { |
2052 scoped_refptr<LayerChromium> root = LayerChromium::create(); | 2052 scoped_refptr<Layer> root = Layer::create(); |
2053 scoped_refptr<LayerChromium> renderSurface1 = LayerChromium::create(); | 2053 scoped_refptr<Layer> renderSurface1 = Layer::create(); |
2054 scoped_refptr<LayerChromiumWithForcedDrawsContent> child1 = make_scoped_refp
tr(new LayerChromiumWithForcedDrawsContent()); | 2054 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
2055 scoped_refptr<LayerChromiumWithForcedDrawsContent> child2 = make_scoped_refp
tr(new LayerChromiumWithForcedDrawsContent()); | 2055 scoped_refptr<LayerWithForcedDrawsContent> child2 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
2056 scoped_refptr<LayerChromiumWithForcedDrawsContent> child3 = make_scoped_refp
tr(new LayerChromiumWithForcedDrawsContent()); | 2056 scoped_refptr<LayerWithForcedDrawsContent> child3 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
2057 root->addChild(renderSurface1); | 2057 root->addChild(renderSurface1); |
2058 renderSurface1->addChild(child1); | 2058 renderSurface1->addChild(child1); |
2059 renderSurface1->addChild(child2); | 2059 renderSurface1->addChild(child2); |
2060 renderSurface1->addChild(child3); | 2060 renderSurface1->addChild(child3); |
2061 | 2061 |
2062 WebTransformationMatrix identityMatrix; | 2062 WebTransformationMatrix identityMatrix; |
2063 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, Flo
atPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 2063 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, Flo
atPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
2064 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(3, 4), false); | 2064 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(3, 4), false); |
2065 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(5, 5), IntSize(50, 50), false); | 2065 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(5, 5), IntSize(50, 50), false); |
2066 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(75, 75), IntSize(50, 50), false); | 2066 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(75, 75), IntSize(50, 50), false); |
(...skipping 20 matching lines...) Expand all Loading... |
2087 EXPECT_RECT_EQ(IntRect(0, 0, 50, 50), child1->visibleContentRect()); | 2087 EXPECT_RECT_EQ(IntRect(0, 0, 50, 50), child1->visibleContentRect()); |
2088 EXPECT_RECT_EQ(IntRect(0, 0, 25, 25), child2->visibleContentRect()); | 2088 EXPECT_RECT_EQ(IntRect(0, 0, 25, 25), child2->visibleContentRect()); |
2089 EXPECT_TRUE(child3->visibleContentRect().isEmpty()); | 2089 EXPECT_TRUE(child3->visibleContentRect().isEmpty()); |
2090 | 2090 |
2091 // But the drawableContentRects are unclipped. | 2091 // But the drawableContentRects are unclipped. |
2092 EXPECT_RECT_EQ(IntRect(5, 5, 50, 50), child1->drawableContentRect()); | 2092 EXPECT_RECT_EQ(IntRect(5, 5, 50, 50), child1->drawableContentRect()); |
2093 EXPECT_RECT_EQ(IntRect(75, 75, 50, 50), child2->drawableContentRect()); | 2093 EXPECT_RECT_EQ(IntRect(75, 75, 50, 50), child2->drawableContentRect()); |
2094 EXPECT_RECT_EQ(IntRect(125, 125, 50, 50), child3->drawableContentRect()); | 2094 EXPECT_RECT_EQ(IntRect(125, 125, 50, 50), child3->drawableContentRect()); |
2095 } | 2095 } |
2096 | 2096 |
2097 TEST(CCLayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsForSurfaceHi
erarchy) | 2097 TEST(LayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsForSurfaceHier
archy) |
2098 { | 2098 { |
2099 // Check that clipping does not propagate down surfaces. | 2099 // Check that clipping does not propagate down surfaces. |
2100 scoped_refptr<LayerChromium> root = LayerChromium::create(); | 2100 scoped_refptr<Layer> root = Layer::create(); |
2101 scoped_refptr<LayerChromium> renderSurface1 = LayerChromium::create(); | 2101 scoped_refptr<Layer> renderSurface1 = Layer::create(); |
2102 scoped_refptr<LayerChromium> renderSurface2 = LayerChromium::create(); | 2102 scoped_refptr<Layer> renderSurface2 = Layer::create(); |
2103 scoped_refptr<LayerChromiumWithForcedDrawsContent> child1 = make_scoped_refp
tr(new LayerChromiumWithForcedDrawsContent()); | 2103 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
2104 scoped_refptr<LayerChromiumWithForcedDrawsContent> child2 = make_scoped_refp
tr(new LayerChromiumWithForcedDrawsContent()); | 2104 scoped_refptr<LayerWithForcedDrawsContent> child2 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
2105 scoped_refptr<LayerChromiumWithForcedDrawsContent> child3 = make_scoped_refp
tr(new LayerChromiumWithForcedDrawsContent()); | 2105 scoped_refptr<LayerWithForcedDrawsContent> child3 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
2106 root->addChild(renderSurface1); | 2106 root->addChild(renderSurface1); |
2107 renderSurface1->addChild(renderSurface2); | 2107 renderSurface1->addChild(renderSurface2); |
2108 renderSurface2->addChild(child1); | 2108 renderSurface2->addChild(child1); |
2109 renderSurface2->addChild(child2); | 2109 renderSurface2->addChild(child2); |
2110 renderSurface2->addChild(child3); | 2110 renderSurface2->addChild(child3); |
2111 | 2111 |
2112 WebTransformationMatrix identityMatrix; | 2112 WebTransformationMatrix identityMatrix; |
2113 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, Flo
atPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 2113 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, Flo
atPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
2114 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(3, 4), false); | 2114 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(3, 4), false); |
2115 setLayerPropertiesForTesting(renderSurface2.get(), identityMatrix, identityM
atrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(7, 13), false); | 2115 setLayerPropertiesForTesting(renderSurface2.get(), identityMatrix, identityM
atrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(7, 13), false); |
(...skipping 30 matching lines...) Expand all Loading... |
2146 EXPECT_RECT_EQ(IntRect(0, 0, 50, 50), child1->visibleContentRect()); | 2146 EXPECT_RECT_EQ(IntRect(0, 0, 50, 50), child1->visibleContentRect()); |
2147 EXPECT_RECT_EQ(IntRect(0, 0, 50, 50), child2->visibleContentRect()); | 2147 EXPECT_RECT_EQ(IntRect(0, 0, 50, 50), child2->visibleContentRect()); |
2148 EXPECT_RECT_EQ(IntRect(0, 0, 50, 50), child3->visibleContentRect()); | 2148 EXPECT_RECT_EQ(IntRect(0, 0, 50, 50), child3->visibleContentRect()); |
2149 | 2149 |
2150 // drawableContentRects are also unclipped. | 2150 // drawableContentRects are also unclipped. |
2151 EXPECT_RECT_EQ(IntRect(5, 5, 50, 50), child1->drawableContentRect()); | 2151 EXPECT_RECT_EQ(IntRect(5, 5, 50, 50), child1->drawableContentRect()); |
2152 EXPECT_RECT_EQ(IntRect(75, 75, 50, 50), child2->drawableContentRect()); | 2152 EXPECT_RECT_EQ(IntRect(75, 75, 50, 50), child2->drawableContentRect()); |
2153 EXPECT_RECT_EQ(IntRect(125, 125, 50, 50), child3->drawableContentRect()); | 2153 EXPECT_RECT_EQ(IntRect(125, 125, 50, 50), child3->drawableContentRect()); |
2154 } | 2154 } |
2155 | 2155 |
2156 TEST(CCLayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsWithTransfor
mOnUnclippedSurface) | 2156 TEST(LayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsWithTransformO
nUnclippedSurface) |
2157 { | 2157 { |
2158 // Layers that have non-axis aligned bounds (due to transforms) have an expa
nded, | 2158 // Layers that have non-axis aligned bounds (due to transforms) have an expa
nded, |
2159 // axis-aligned drawableContentRect and visibleContentRect. | 2159 // axis-aligned drawableContentRect and visibleContentRect. |
2160 | 2160 |
2161 scoped_refptr<LayerChromium> root = LayerChromium::create(); | 2161 scoped_refptr<Layer> root = Layer::create(); |
2162 scoped_refptr<LayerChromium> renderSurface1 = LayerChromium::create(); | 2162 scoped_refptr<Layer> renderSurface1 = Layer::create(); |
2163 scoped_refptr<LayerChromiumWithForcedDrawsContent> child1 = make_scoped_refp
tr(new LayerChromiumWithForcedDrawsContent()); | 2163 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
2164 root->addChild(renderSurface1); | 2164 root->addChild(renderSurface1); |
2165 renderSurface1->addChild(child1); | 2165 renderSurface1->addChild(child1); |
2166 | 2166 |
2167 WebTransformationMatrix identityMatrix; | 2167 WebTransformationMatrix identityMatrix; |
2168 WebTransformationMatrix childRotation; | 2168 WebTransformationMatrix childRotation; |
2169 childRotation.rotate(45); | 2169 childRotation.rotate(45); |
2170 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, Flo
atPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 2170 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, Flo
atPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
2171 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(3, 4), false); | 2171 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(3, 4), false); |
2172 setLayerPropertiesForTesting(child1.get(), childRotation, identityMatrix, Fl
oatPoint(0.5, 0.5), FloatPoint(25, 25), IntSize(50, 50), false); | 2172 setLayerPropertiesForTesting(child1.get(), childRotation, identityMatrix, Fl
oatPoint(0.5, 0.5), FloatPoint(25, 25), IntSize(50, 50), false); |
2173 | 2173 |
(...skipping 12 matching lines...) Expand all Loading... |
2186 // The unclipped surface grows its drawableContentRect to include all drawab
le regions of the subtree. | 2186 // The unclipped surface grows its drawableContentRect to include all drawab
le regions of the subtree. |
2187 int diagonalRadius = ceil(sqrt(2.0) * 25); | 2187 int diagonalRadius = ceil(sqrt(2.0) * 25); |
2188 IntRect expectedSurfaceDrawableContent = IntRect(50 - diagonalRadius, 50 - d
iagonalRadius, diagonalRadius * 2, diagonalRadius * 2); | 2188 IntRect expectedSurfaceDrawableContent = IntRect(50 - diagonalRadius, 50 - d
iagonalRadius, diagonalRadius * 2, diagonalRadius * 2); |
2189 EXPECT_RECT_EQ(expectedSurfaceDrawableContent, renderSurface1->renderSurface
()->drawableContentRect()); | 2189 EXPECT_RECT_EQ(expectedSurfaceDrawableContent, renderSurface1->renderSurface
()->drawableContentRect()); |
2190 | 2190 |
2191 // All layers that draw content into the unclipped surface are also unclippe
d. | 2191 // All layers that draw content into the unclipped surface are also unclippe
d. |
2192 EXPECT_RECT_EQ(IntRect(0, 0, 50, 50), child1->visibleContentRect()); | 2192 EXPECT_RECT_EQ(IntRect(0, 0, 50, 50), child1->visibleContentRect()); |
2193 EXPECT_RECT_EQ(expectedSurfaceDrawableContent, child1->drawableContentRect()
); | 2193 EXPECT_RECT_EQ(expectedSurfaceDrawableContent, child1->drawableContentRect()
); |
2194 } | 2194 } |
2195 | 2195 |
2196 TEST(CCLayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsWithTransfor
mOnClippedSurface) | 2196 TEST(LayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsWithTransformO
nClippedSurface) |
2197 { | 2197 { |
2198 // Layers that have non-axis aligned bounds (due to transforms) have an expa
nded, | 2198 // Layers that have non-axis aligned bounds (due to transforms) have an expa
nded, |
2199 // axis-aligned drawableContentRect and visibleContentRect. | 2199 // axis-aligned drawableContentRect and visibleContentRect. |
2200 | 2200 |
2201 scoped_refptr<LayerChromium> root = LayerChromium::create(); | 2201 scoped_refptr<Layer> root = Layer::create(); |
2202 scoped_refptr<LayerChromium> renderSurface1 = LayerChromium::create(); | 2202 scoped_refptr<Layer> renderSurface1 = Layer::create(); |
2203 scoped_refptr<LayerChromiumWithForcedDrawsContent> child1 = make_scoped_refp
tr(new LayerChromiumWithForcedDrawsContent()); | 2203 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
2204 root->addChild(renderSurface1); | 2204 root->addChild(renderSurface1); |
2205 renderSurface1->addChild(child1); | 2205 renderSurface1->addChild(child1); |
2206 | 2206 |
2207 WebTransformationMatrix identityMatrix; | 2207 WebTransformationMatrix identityMatrix; |
2208 WebTransformationMatrix childRotation; | 2208 WebTransformationMatrix childRotation; |
2209 childRotation.rotate(45); | 2209 childRotation.rotate(45); |
2210 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, Flo
atPoint(0, 0), FloatPoint(0, 0), IntSize(50, 50), false); | 2210 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, Flo
atPoint(0, 0), FloatPoint(0, 0), IntSize(50, 50), false); |
2211 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(3, 4), false); | 2211 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(3, 4), false); |
2212 setLayerPropertiesForTesting(child1.get(), childRotation, identityMatrix, Fl
oatPoint(0.5, 0.5), FloatPoint(25, 25), IntSize(50, 50), false); | 2212 setLayerPropertiesForTesting(child1.get(), childRotation, identityMatrix, Fl
oatPoint(0.5, 0.5), FloatPoint(25, 25), IntSize(50, 50), false); |
2213 | 2213 |
(...skipping 11 matching lines...) Expand all Loading... |
2225 | 2225 |
2226 // On the clipped surface, only a quarter of the child1 is visible, but whe
n rotating | 2226 // On the clipped surface, only a quarter of the child1 is visible, but whe
n rotating |
2227 // it back to child1's content space, the actual enclosing rect ends up cov
ering the | 2227 // it back to child1's content space, the actual enclosing rect ends up cov
ering the |
2228 // full left half of child1. | 2228 // full left half of child1. |
2229 EXPECT_RECT_EQ(IntRect(0, 0, 26, 50), child1->visibleContentRect()); | 2229 EXPECT_RECT_EQ(IntRect(0, 0, 26, 50), child1->visibleContentRect()); |
2230 | 2230 |
2231 // The child's drawableContentRect is unclipped. | 2231 // The child's drawableContentRect is unclipped. |
2232 EXPECT_RECT_EQ(unclippedSurfaceContent, child1->drawableContentRect()); | 2232 EXPECT_RECT_EQ(unclippedSurfaceContent, child1->drawableContentRect()); |
2233 } | 2233 } |
2234 | 2234 |
2235 TEST(CCLayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsInHighDPI) | 2235 TEST(LayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsInHighDPI) |
2236 { | 2236 { |
2237 MockContentLayerChromiumClient client; | 2237 MockContentLayerClient client; |
2238 | 2238 |
2239 scoped_refptr<LayerChromium> root = LayerChromium::create(); | 2239 scoped_refptr<Layer> root = Layer::create(); |
2240 scoped_refptr<ContentLayerChromium> renderSurface1 = createDrawableContentLa
yerChromium(&client); | 2240 scoped_refptr<ContentLayer> renderSurface1 = createDrawableContentLayer(&cli
ent); |
2241 scoped_refptr<ContentLayerChromium> renderSurface2 = createDrawableContentLa
yerChromium(&client); | 2241 scoped_refptr<ContentLayer> renderSurface2 = createDrawableContentLayer(&cli
ent); |
2242 scoped_refptr<ContentLayerChromium> child1 = createDrawableContentLayerChrom
ium(&client); | 2242 scoped_refptr<ContentLayer> child1 = createDrawableContentLayer(&client); |
2243 scoped_refptr<ContentLayerChromium> child2 = createDrawableContentLayerChrom
ium(&client); | 2243 scoped_refptr<ContentLayer> child2 = createDrawableContentLayer(&client); |
2244 scoped_refptr<ContentLayerChromium> child3 = createDrawableContentLayerChrom
ium(&client); | 2244 scoped_refptr<ContentLayer> child3 = createDrawableContentLayer(&client); |
2245 root->addChild(renderSurface1); | 2245 root->addChild(renderSurface1); |
2246 renderSurface1->addChild(renderSurface2); | 2246 renderSurface1->addChild(renderSurface2); |
2247 renderSurface2->addChild(child1); | 2247 renderSurface2->addChild(child1); |
2248 renderSurface2->addChild(child2); | 2248 renderSurface2->addChild(child2); |
2249 renderSurface2->addChild(child3); | 2249 renderSurface2->addChild(child3); |
2250 | 2250 |
2251 WebTransformationMatrix identityMatrix; | 2251 WebTransformationMatrix identityMatrix; |
2252 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, Flo
atPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 2252 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, Flo
atPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
2253 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, FloatPoint(0, 0), FloatPoint(5, 5), IntSize(3, 4), false); | 2253 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, FloatPoint(0, 0), FloatPoint(5, 5), IntSize(3, 4), false); |
2254 setLayerPropertiesForTesting(renderSurface2.get(), identityMatrix, identityM
atrix, FloatPoint(0, 0), FloatPoint(5, 5), IntSize(7, 13), false); | 2254 setLayerPropertiesForTesting(renderSurface2.get(), identityMatrix, identityM
atrix, FloatPoint(0, 0), FloatPoint(5, 5), IntSize(7, 13), false); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2290 | 2290 |
2291 // All layer visibleContentRects are expressed in content space of each | 2291 // All layer visibleContentRects are expressed in content space of each |
2292 // layer, so they are also scaled by the deviceScaleFactor. | 2292 // layer, so they are also scaled by the deviceScaleFactor. |
2293 EXPECT_RECT_EQ(IntRect(0, 0, 6, 8), renderSurface1->visibleContentRect()); | 2293 EXPECT_RECT_EQ(IntRect(0, 0, 6, 8), renderSurface1->visibleContentRect()); |
2294 EXPECT_RECT_EQ(IntRect(0, 0, 14, 26), renderSurface2->visibleContentRect()); | 2294 EXPECT_RECT_EQ(IntRect(0, 0, 14, 26), renderSurface2->visibleContentRect()); |
2295 EXPECT_RECT_EQ(IntRect(0, 0, 100, 100), child1->visibleContentRect()); | 2295 EXPECT_RECT_EQ(IntRect(0, 0, 100, 100), child1->visibleContentRect()); |
2296 EXPECT_RECT_EQ(IntRect(0, 0, 100, 100), child2->visibleContentRect()); | 2296 EXPECT_RECT_EQ(IntRect(0, 0, 100, 100), child2->visibleContentRect()); |
2297 EXPECT_RECT_EQ(IntRect(0, 0, 100, 100), child3->visibleContentRect()); | 2297 EXPECT_RECT_EQ(IntRect(0, 0, 100, 100), child3->visibleContentRect()); |
2298 } | 2298 } |
2299 | 2299 |
2300 TEST(CCLayerTreeHostCommonTest, verifyBackFaceCullingWithoutPreserves3d) | 2300 TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithoutPreserves3d) |
2301 { | 2301 { |
2302 // Verify the behavior of back-face culling when there are no preserve-3d la
yers. Note | 2302 // Verify the behavior of back-face culling when there are no preserve-3d la
yers. Note |
2303 // that 3d transforms still apply in this case, but they are "flattened" to
each | 2303 // that 3d transforms still apply in this case, but they are "flattened" to
each |
2304 // parent layer according to current W3C spec. | 2304 // parent layer according to current W3C spec. |
2305 | 2305 |
2306 const WebTransformationMatrix identityMatrix; | 2306 const WebTransformationMatrix identityMatrix; |
2307 scoped_refptr<LayerChromium> parent = LayerChromium::create(); | 2307 scoped_refptr<Layer> parent = Layer::create(); |
2308 scoped_refptr<LayerChromiumWithForcedDrawsContent> frontFacingChild = make_s
coped_refptr(new LayerChromiumWithForcedDrawsContent()); | 2308 scoped_refptr<LayerWithForcedDrawsContent> frontFacingChild = make_scoped_re
fptr(new LayerWithForcedDrawsContent()); |
2309 scoped_refptr<LayerChromiumWithForcedDrawsContent> backFacingChild = make_sc
oped_refptr(new LayerChromiumWithForcedDrawsContent()); | 2309 scoped_refptr<LayerWithForcedDrawsContent> backFacingChild = make_scoped_ref
ptr(new LayerWithForcedDrawsContent()); |
2310 scoped_refptr<LayerChromiumWithForcedDrawsContent> frontFacingSurface = make
_scoped_refptr(new LayerChromiumWithForcedDrawsContent()); | 2310 scoped_refptr<LayerWithForcedDrawsContent> frontFacingSurface = make_scoped_
refptr(new LayerWithForcedDrawsContent()); |
2311 scoped_refptr<LayerChromiumWithForcedDrawsContent> backFacingSurface = make_
scoped_refptr(new LayerChromiumWithForcedDrawsContent()); | 2311 scoped_refptr<LayerWithForcedDrawsContent> backFacingSurface = make_scoped_r
efptr(new LayerWithForcedDrawsContent()); |
2312 scoped_refptr<LayerChromiumWithForcedDrawsContent> frontFacingChildOfFrontFa
cingSurface = make_scoped_refptr(new LayerChromiumWithForcedDrawsContent()); | 2312 scoped_refptr<LayerWithForcedDrawsContent> frontFacingChildOfFrontFacingSurf
ace = make_scoped_refptr(new LayerWithForcedDrawsContent()); |
2313 scoped_refptr<LayerChromiumWithForcedDrawsContent> backFacingChildOfFrontFac
ingSurface = make_scoped_refptr(new LayerChromiumWithForcedDrawsContent()); | 2313 scoped_refptr<LayerWithForcedDrawsContent> backFacingChildOfFrontFacingSurfa
ce = make_scoped_refptr(new LayerWithForcedDrawsContent()); |
2314 scoped_refptr<LayerChromiumWithForcedDrawsContent> frontFacingChildOfBackFac
ingSurface = make_scoped_refptr(new LayerChromiumWithForcedDrawsContent()); | 2314 scoped_refptr<LayerWithForcedDrawsContent> frontFacingChildOfBackFacingSurfa
ce = make_scoped_refptr(new LayerWithForcedDrawsContent()); |
2315 scoped_refptr<LayerChromiumWithForcedDrawsContent> backFacingChildOfBackFaci
ngSurface = make_scoped_refptr(new LayerChromiumWithForcedDrawsContent()); | 2315 scoped_refptr<LayerWithForcedDrawsContent> backFacingChildOfBackFacingSurfac
e = make_scoped_refptr(new LayerWithForcedDrawsContent()); |
2316 | 2316 |
2317 parent->addChild(frontFacingChild); | 2317 parent->addChild(frontFacingChild); |
2318 parent->addChild(backFacingChild); | 2318 parent->addChild(backFacingChild); |
2319 parent->addChild(frontFacingSurface); | 2319 parent->addChild(frontFacingSurface); |
2320 parent->addChild(backFacingSurface); | 2320 parent->addChild(backFacingSurface); |
2321 frontFacingSurface->addChild(frontFacingChildOfFrontFacingSurface); | 2321 frontFacingSurface->addChild(frontFacingChildOfFrontFacingSurface); |
2322 frontFacingSurface->addChild(backFacingChildOfFrontFacingSurface); | 2322 frontFacingSurface->addChild(backFacingChildOfFrontFacingSurface); |
2323 backFacingSurface->addChild(frontFacingChildOfBackFacingSurface); | 2323 backFacingSurface->addChild(frontFacingChildOfBackFacingSurface); |
2324 backFacingSurface->addChild(backFacingChildOfBackFacingSurface); | 2324 backFacingSurface->addChild(backFacingChildOfBackFacingSurface); |
2325 | 2325 |
(...skipping 21 matching lines...) Expand all Loading... |
2347 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 2347 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
2348 setLayerPropertiesForTesting(frontFacingChild.get(), identityMatrix, identit
yMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 2348 setLayerPropertiesForTesting(frontFacingChild.get(), identityMatrix, identit
yMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
2349 setLayerPropertiesForTesting(backFacingChild.get(), backfaceMatrix, identity
Matrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 2349 setLayerPropertiesForTesting(backFacingChild.get(), backfaceMatrix, identity
Matrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
2350 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident
ityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 2350 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident
ityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
2351 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, identi
tyMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 2351 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, identi
tyMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
2352 setLayerPropertiesForTesting(frontFacingChildOfFrontFacingSurface.get(), ide
ntityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 10
0), false); | 2352 setLayerPropertiesForTesting(frontFacingChildOfFrontFacingSurface.get(), ide
ntityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 10
0), false); |
2353 setLayerPropertiesForTesting(backFacingChildOfFrontFacingSurface.get(), back
faceMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100
), false); | 2353 setLayerPropertiesForTesting(backFacingChildOfFrontFacingSurface.get(), back
faceMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100
), false); |
2354 setLayerPropertiesForTesting(frontFacingChildOfBackFacingSurface.get(), iden
tityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100
), false); | 2354 setLayerPropertiesForTesting(frontFacingChildOfBackFacingSurface.get(), iden
tityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100
), false); |
2355 setLayerPropertiesForTesting(backFacingChildOfBackFacingSurface.get(), backf
aceMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100)
, false); | 2355 setLayerPropertiesForTesting(backFacingChildOfBackFacingSurface.get(), backf
aceMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100)
, false); |
2356 | 2356 |
2357 std::vector<scoped_refptr<LayerChromium> > renderSurfaceLayerList; | 2357 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
2358 int dummyMaxTextureSize = 512; | 2358 int dummyMaxTextureSize = 512; |
2359 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, dummyMaxTextureSize, renderSurfaceLayerList); | 2359 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
1, dummyMaxTextureSize, renderSurfaceLayerList); |
2360 | 2360 |
2361 // Verify which renderSurfaces were created. | 2361 // Verify which renderSurfaces were created. |
2362 EXPECT_FALSE(frontFacingChild->renderSurface()); | 2362 EXPECT_FALSE(frontFacingChild->renderSurface()); |
2363 EXPECT_FALSE(backFacingChild->renderSurface()); | 2363 EXPECT_FALSE(backFacingChild->renderSurface()); |
2364 EXPECT_TRUE(frontFacingSurface->renderSurface()); | 2364 EXPECT_TRUE(frontFacingSurface->renderSurface()); |
2365 EXPECT_TRUE(backFacingSurface->renderSurface()); | 2365 EXPECT_TRUE(backFacingSurface->renderSurface()); |
2366 EXPECT_FALSE(frontFacingChildOfFrontFacingSurface->renderSurface()); | 2366 EXPECT_FALSE(frontFacingChildOfFrontFacingSurface->renderSurface()); |
2367 EXPECT_FALSE(backFacingChildOfFrontFacingSurface->renderSurface()); | 2367 EXPECT_FALSE(backFacingChildOfFrontFacingSurface->renderSurface()); |
2368 EXPECT_FALSE(frontFacingChildOfBackFacingSurface->renderSurface()); | 2368 EXPECT_FALSE(frontFacingChildOfBackFacingSurface->renderSurface()); |
2369 EXPECT_FALSE(backFacingChildOfBackFacingSurface->renderSurface()); | 2369 EXPECT_FALSE(backFacingChildOfBackFacingSurface->renderSurface()); |
(...skipping 14 matching lines...) Expand all Loading... |
2384 // Verify frontFacingSurface's layerList. | 2384 // Verify frontFacingSurface's layerList. |
2385 ASSERT_EQ(2u, renderSurfaceLayerList[1]->renderSurface()->layerList().size()
); | 2385 ASSERT_EQ(2u, renderSurfaceLayerList[1]->renderSurface()->layerList().size()
); |
2386 EXPECT_EQ(frontFacingSurface->id(), renderSurfaceLayerList[1]->renderSurface
()->layerList()[0]->id()); | 2386 EXPECT_EQ(frontFacingSurface->id(), renderSurfaceLayerList[1]->renderSurface
()->layerList()[0]->id()); |
2387 EXPECT_EQ(frontFacingChildOfFrontFacingSurface->id(), renderSurfaceLayerList
[1]->renderSurface()->layerList()[1]->id()); | 2387 EXPECT_EQ(frontFacingChildOfFrontFacingSurface->id(), renderSurfaceLayerList
[1]->renderSurface()->layerList()[1]->id()); |
2388 | 2388 |
2389 // Verify backFacingSurface's layerList; its own layer should be culled from
the surface list. | 2389 // Verify backFacingSurface's layerList; its own layer should be culled from
the surface list. |
2390 ASSERT_EQ(1u, renderSurfaceLayerList[2]->renderSurface()->layerList().size()
); | 2390 ASSERT_EQ(1u, renderSurfaceLayerList[2]->renderSurface()->layerList().size()
); |
2391 EXPECT_EQ(frontFacingChildOfBackFacingSurface->id(), renderSurfaceLayerList[
2]->renderSurface()->layerList()[0]->id()); | 2391 EXPECT_EQ(frontFacingChildOfBackFacingSurface->id(), renderSurfaceLayerList[
2]->renderSurface()->layerList()[0]->id()); |
2392 } | 2392 } |
2393 | 2393 |
2394 TEST(CCLayerTreeHostCommonTest, verifyBackFaceCullingWithPreserves3d) | 2394 TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithPreserves3d) |
2395 { | 2395 { |
2396 // Verify the behavior of back-face culling when preserves-3d transform styl
e is used. | 2396 // Verify the behavior of back-face culling when preserves-3d transform styl
e is used. |
2397 | 2397 |
2398 const WebTransformationMatrix identityMatrix; | 2398 const WebTransformationMatrix identityMatrix; |
2399 scoped_refptr<LayerChromium> parent = LayerChromium::create(); | 2399 scoped_refptr<Layer> parent = Layer::create(); |
2400 scoped_refptr<LayerChromiumWithForcedDrawsContent> frontFacingChild = make_s
coped_refptr(new LayerChromiumWithForcedDrawsContent()); | 2400 scoped_refptr<LayerWithForcedDrawsContent> frontFacingChild = make_scoped_re
fptr(new LayerWithForcedDrawsContent()); |
2401 scoped_refptr<LayerChromiumWithForcedDrawsContent> backFacingChild = make_sc
oped_refptr(new LayerChromiumWithForcedDrawsContent()); | 2401 scoped_refptr<LayerWithForcedDrawsContent> backFacingChild = make_scoped_ref
ptr(new LayerWithForcedDrawsContent()); |
2402 scoped_refptr<LayerChromiumWithForcedDrawsContent> frontFacingSurface = make
_scoped_refptr(new LayerChromiumWithForcedDrawsContent()); | 2402 scoped_refptr<LayerWithForcedDrawsContent> frontFacingSurface = make_scoped_
refptr(new LayerWithForcedDrawsContent()); |
2403 scoped_refptr<LayerChromiumWithForcedDrawsContent> backFacingSurface = make_
scoped_refptr(new LayerChromiumWithForcedDrawsContent()); | 2403 scoped_refptr<LayerWithForcedDrawsContent> backFacingSurface = make_scoped_r
efptr(new LayerWithForcedDrawsContent()); |
2404 scoped_refptr<LayerChromiumWithForcedDrawsContent> frontFacingChildOfFrontFa
cingSurface = make_scoped_refptr(new LayerChromiumWithForcedDrawsContent()); | 2404 scoped_refptr<LayerWithForcedDrawsContent> frontFacingChildOfFrontFacingSurf
ace = make_scoped_refptr(new LayerWithForcedDrawsContent()); |
2405 scoped_refptr<LayerChromiumWithForcedDrawsContent> backFacingChildOfFrontFac
ingSurface = make_scoped_refptr(new LayerChromiumWithForcedDrawsContent()); | 2405 scoped_refptr<LayerWithForcedDrawsContent> backFacingChildOfFrontFacingSurfa
ce = make_scoped_refptr(new LayerWithForcedDrawsContent()); |
2406 scoped_refptr<LayerChromiumWithForcedDrawsContent> frontFacingChildOfBackFac
ingSurface = make_scoped_refptr(new LayerChromiumWithForcedDrawsContent()); | 2406 scoped_refptr<LayerWithForcedDrawsContent> frontFacingChildOfBackFacingSurfa
ce = make_scoped_refptr(new LayerWithForcedDrawsContent()); |
2407 scoped_refptr<LayerChromiumWithForcedDrawsContent> backFacingChildOfBackFaci
ngSurface = make_scoped_refptr(new LayerChromiumWithForcedDrawsContent()); | 2407 scoped_refptr<LayerWithForcedDrawsContent> backFacingChildOfBackFacingSurfac
e = make_scoped_refptr(new LayerWithForcedDrawsContent()); |
2408 scoped_refptr<LayerChromiumWithForcedDrawsContent> dummyReplicaLayer1 = make
_scoped_refptr(new LayerChromiumWithForcedDrawsContent()); | 2408 scoped_refptr<LayerWithForcedDrawsContent> dummyReplicaLayer1 = make_scoped_
refptr(new LayerWithForcedDrawsContent()); |
2409 scoped_refptr<LayerChromiumWithForcedDrawsContent> dummyReplicaLayer2 = make
_scoped_refptr(new LayerChromiumWithForcedDrawsContent()); | 2409 scoped_refptr<LayerWithForcedDrawsContent> dummyReplicaLayer2 = make_scoped_
refptr(new LayerWithForcedDrawsContent()); |
2410 | 2410 |
2411 parent->addChild(frontFacingChild); | 2411 parent->addChild(frontFacingChild); |
2412 parent->addChild(backFacingChild); | 2412 parent->addChild(backFacingChild); |
2413 parent->addChild(frontFacingSurface); | 2413 parent->addChild(frontFacingSurface); |
2414 parent->addChild(backFacingSurface); | 2414 parent->addChild(backFacingSurface); |
2415 frontFacingSurface->addChild(frontFacingChildOfFrontFacingSurface); | 2415 frontFacingSurface->addChild(frontFacingChildOfFrontFacingSurface); |
2416 frontFacingSurface->addChild(backFacingChildOfFrontFacingSurface); | 2416 frontFacingSurface->addChild(backFacingChildOfFrontFacingSurface); |
2417 backFacingSurface->addChild(frontFacingChildOfBackFacingSurface); | 2417 backFacingSurface->addChild(frontFacingChildOfBackFacingSurface); |
2418 backFacingSurface->addChild(backFacingChildOfBackFacingSurface); | 2418 backFacingSurface->addChild(backFacingChildOfBackFacingSurface); |
2419 | 2419 |
(...skipping 26 matching lines...) Expand all Loading... |
2446 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); // parent transfor
m style is flat. | 2446 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); // parent transfor
m style is flat. |
2447 setLayerPropertiesForTesting(frontFacingChild.get(), identityMatrix, identit
yMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 2447 setLayerPropertiesForTesting(frontFacingChild.get(), identityMatrix, identit
yMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
2448 setLayerPropertiesForTesting(backFacingChild.get(), backfaceMatrix, identity
Matrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 2448 setLayerPropertiesForTesting(backFacingChild.get(), backfaceMatrix, identity
Matrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
2449 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident
ityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true); // surf
ace transform style is preserve-3d. | 2449 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident
ityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true); // surf
ace transform style is preserve-3d. |
2450 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, identi
tyMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true); // surfa
ce transform style is preserve-3d. | 2450 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, identi
tyMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true); // surfa
ce transform style is preserve-3d. |
2451 setLayerPropertiesForTesting(frontFacingChildOfFrontFacingSurface.get(), ide
ntityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 10
0), false); | 2451 setLayerPropertiesForTesting(frontFacingChildOfFrontFacingSurface.get(), ide
ntityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 10
0), false); |
2452 setLayerPropertiesForTesting(backFacingChildOfFrontFacingSurface.get(), back
faceMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100
), false); | 2452 setLayerPropertiesForTesting(backFacingChildOfFrontFacingSurface.get(), back
faceMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100
), false); |
2453 setLayerPropertiesForTesting(frontFacingChildOfBackFacingSurface.get(), iden
tityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100
), false); | 2453 setLayerPropertiesForTesting(frontFacingChildOfBackFacingSurface.get(), iden
tityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100
), false); |
2454 setLayerPropertiesForTesting(backFacingChildOfBackFacingSurface.get(), backf
aceMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100)
, false); | 2454 setLayerPropertiesForTesting(backFacingChildOfBackFacingSurface.get(), backf
aceMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100)
, false); |
2455 | 2455 |
2456 std::vector<scoped_refptr<LayerChromium> > renderSurfaceLayerList; | 2456 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
2457 int dummyMaxTextureSize = 512; | 2457 int dummyMaxTextureSize = 512; |
2458 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, dummyMaxTextureSize, renderSurfaceLayerList); | 2458 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
1, dummyMaxTextureSize, renderSurfaceLayerList); |
2459 | 2459 |
2460 // Verify which renderSurfaces were created. | 2460 // Verify which renderSurfaces were created. |
2461 EXPECT_FALSE(frontFacingChild->renderSurface()); | 2461 EXPECT_FALSE(frontFacingChild->renderSurface()); |
2462 EXPECT_FALSE(backFacingChild->renderSurface()); | 2462 EXPECT_FALSE(backFacingChild->renderSurface()); |
2463 EXPECT_TRUE(frontFacingSurface->renderSurface()); | 2463 EXPECT_TRUE(frontFacingSurface->renderSurface()); |
2464 EXPECT_FALSE(backFacingSurface->renderSurface()); | 2464 EXPECT_FALSE(backFacingSurface->renderSurface()); |
2465 EXPECT_FALSE(frontFacingChildOfFrontFacingSurface->renderSurface()); | 2465 EXPECT_FALSE(frontFacingChildOfFrontFacingSurface->renderSurface()); |
2466 EXPECT_FALSE(backFacingChildOfFrontFacingSurface->renderSurface()); | 2466 EXPECT_FALSE(backFacingChildOfFrontFacingSurface->renderSurface()); |
2467 EXPECT_FALSE(frontFacingChildOfBackFacingSurface->renderSurface()); | 2467 EXPECT_FALSE(frontFacingChildOfBackFacingSurface->renderSurface()); |
2468 EXPECT_FALSE(backFacingChildOfBackFacingSurface->renderSurface()); | 2468 EXPECT_FALSE(backFacingChildOfBackFacingSurface->renderSurface()); |
2469 | 2469 |
2470 // Verify the renderSurfaceLayerList. The back-facing surface should be cull
ed. | 2470 // Verify the renderSurfaceLayerList. The back-facing surface should be cull
ed. |
2471 ASSERT_EQ(2u, renderSurfaceLayerList.size()); | 2471 ASSERT_EQ(2u, renderSurfaceLayerList.size()); |
2472 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); | 2472 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); |
2473 EXPECT_EQ(frontFacingSurface->id(), renderSurfaceLayerList[1]->id()); | 2473 EXPECT_EQ(frontFacingSurface->id(), renderSurfaceLayerList[1]->id()); |
2474 | 2474 |
2475 // Verify root surface's layerList. | 2475 // Verify root surface's layerList. |
2476 ASSERT_EQ(2u, renderSurfaceLayerList[0]->renderSurface()->layerList().size()
); | 2476 ASSERT_EQ(2u, renderSurfaceLayerList[0]->renderSurface()->layerList().size()
); |
2477 EXPECT_EQ(frontFacingChild->id(), renderSurfaceLayerList[0]->renderSurface()
->layerList()[0]->id()); | 2477 EXPECT_EQ(frontFacingChild->id(), renderSurfaceLayerList[0]->renderSurface()
->layerList()[0]->id()); |
2478 EXPECT_EQ(frontFacingSurface->id(), renderSurfaceLayerList[0]->renderSurface
()->layerList()[1]->id()); | 2478 EXPECT_EQ(frontFacingSurface->id(), renderSurfaceLayerList[0]->renderSurface
()->layerList()[1]->id()); |
2479 | 2479 |
2480 // Verify frontFacingSurface's layerList. | 2480 // Verify frontFacingSurface's layerList. |
2481 ASSERT_EQ(2u, renderSurfaceLayerList[1]->renderSurface()->layerList().size()
); | 2481 ASSERT_EQ(2u, renderSurfaceLayerList[1]->renderSurface()->layerList().size()
); |
2482 EXPECT_EQ(frontFacingSurface->id(), renderSurfaceLayerList[1]->renderSurface
()->layerList()[0]->id()); | 2482 EXPECT_EQ(frontFacingSurface->id(), renderSurfaceLayerList[1]->renderSurface
()->layerList()[0]->id()); |
2483 EXPECT_EQ(frontFacingChildOfFrontFacingSurface->id(), renderSurfaceLayerList
[1]->renderSurface()->layerList()[1]->id()); | 2483 EXPECT_EQ(frontFacingChildOfFrontFacingSurface->id(), renderSurfaceLayerList
[1]->renderSurface()->layerList()[1]->id()); |
2484 } | 2484 } |
2485 | 2485 |
2486 TEST(CCLayerTreeHostCommonTest, verifyBackFaceCullingWithAnimatingTransforms) | 2486 TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithAnimatingTransforms) |
2487 { | 2487 { |
2488 // Verify that layers are appropriately culled when their back face is showi
ng and | 2488 // Verify that layers are appropriately culled when their back face is showi
ng and |
2489 // they are not double sided, while animations are going on. | 2489 // they are not double sided, while animations are going on. |
2490 // | 2490 // |
2491 // Layers that are animating do not get culled on the main thread, as their
transforms should be | 2491 // Layers that are animating do not get culled on the main thread, as their
transforms should be |
2492 // treated as "unknown" so we can not be sure that their back face is really
showing. | 2492 // treated as "unknown" so we can not be sure that their back face is really
showing. |
2493 // | 2493 // |
2494 | 2494 |
2495 const WebTransformationMatrix identityMatrix; | 2495 const WebTransformationMatrix identityMatrix; |
2496 scoped_refptr<LayerChromium> parent = LayerChromium::create(); | 2496 scoped_refptr<Layer> parent = Layer::create(); |
2497 scoped_refptr<LayerChromiumWithForcedDrawsContent> child = make_scoped_refpt
r(new LayerChromiumWithForcedDrawsContent()); | 2497 scoped_refptr<LayerWithForcedDrawsContent> child = make_scoped_refptr(new La
yerWithForcedDrawsContent()); |
2498 scoped_refptr<LayerChromiumWithForcedDrawsContent> animatingSurface = make_s
coped_refptr(new LayerChromiumWithForcedDrawsContent()); | 2498 scoped_refptr<LayerWithForcedDrawsContent> animatingSurface = make_scoped_re
fptr(new LayerWithForcedDrawsContent()); |
2499 scoped_refptr<LayerChromiumWithForcedDrawsContent> childOfAnimatingSurface =
make_scoped_refptr(new LayerChromiumWithForcedDrawsContent()); | 2499 scoped_refptr<LayerWithForcedDrawsContent> childOfAnimatingSurface = make_sc
oped_refptr(new LayerWithForcedDrawsContent()); |
2500 scoped_refptr<LayerChromiumWithForcedDrawsContent> animatingChild = make_sco
ped_refptr(new LayerChromiumWithForcedDrawsContent()); | 2500 scoped_refptr<LayerWithForcedDrawsContent> animatingChild = make_scoped_refp
tr(new LayerWithForcedDrawsContent()); |
2501 scoped_refptr<LayerChromiumWithForcedDrawsContent> child2 = make_scoped_refp
tr(new LayerChromiumWithForcedDrawsContent()); | 2501 scoped_refptr<LayerWithForcedDrawsContent> child2 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
2502 | 2502 |
2503 parent->addChild(child); | 2503 parent->addChild(child); |
2504 parent->addChild(animatingSurface); | 2504 parent->addChild(animatingSurface); |
2505 animatingSurface->addChild(childOfAnimatingSurface); | 2505 animatingSurface->addChild(childOfAnimatingSurface); |
2506 parent->addChild(animatingChild); | 2506 parent->addChild(animatingChild); |
2507 parent->addChild(child2); | 2507 parent->addChild(child2); |
2508 | 2508 |
2509 // Nothing is double-sided | 2509 // Nothing is double-sided |
2510 child->setDoubleSided(false); | 2510 child->setDoubleSided(false); |
2511 child2->setDoubleSided(false); | 2511 child2->setDoubleSided(false); |
(...skipping 14 matching lines...) Expand all Loading... |
2526 // This is just an animating layer, not a surface. | 2526 // This is just an animating layer, not a surface. |
2527 addAnimatedTransformToController(*animatingChild->layerAnimationController()
, 10, 30, 0); | 2527 addAnimatedTransformToController(*animatingChild->layerAnimationController()
, 10, 30, 0); |
2528 | 2528 |
2529 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 2529 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
2530 setLayerPropertiesForTesting(child.get(), backfaceMatrix, identityMatrix, Fl
oatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 2530 setLayerPropertiesForTesting(child.get(), backfaceMatrix, identityMatrix, Fl
oatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
2531 setLayerPropertiesForTesting(animatingSurface.get(), backfaceMatrix, identit
yMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 2531 setLayerPropertiesForTesting(animatingSurface.get(), backfaceMatrix, identit
yMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
2532 setLayerPropertiesForTesting(childOfAnimatingSurface.get(), backfaceMatrix,
identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 2532 setLayerPropertiesForTesting(childOfAnimatingSurface.get(), backfaceMatrix,
identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
2533 setLayerPropertiesForTesting(animatingChild.get(), backfaceMatrix, identityM
atrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 2533 setLayerPropertiesForTesting(animatingChild.get(), backfaceMatrix, identityM
atrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
2534 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 2534 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
2535 | 2535 |
2536 std::vector<scoped_refptr<LayerChromium> > renderSurfaceLayerList; | 2536 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
2537 int dummyMaxTextureSize = 512; | 2537 int dummyMaxTextureSize = 512; |
2538 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, dummyMaxTextureSize, renderSurfaceLayerList); | 2538 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
1, dummyMaxTextureSize, renderSurfaceLayerList); |
2539 | 2539 |
2540 EXPECT_FALSE(child->renderSurface()); | 2540 EXPECT_FALSE(child->renderSurface()); |
2541 EXPECT_TRUE(animatingSurface->renderSurface()); | 2541 EXPECT_TRUE(animatingSurface->renderSurface()); |
2542 EXPECT_FALSE(childOfAnimatingSurface->renderSurface()); | 2542 EXPECT_FALSE(childOfAnimatingSurface->renderSurface()); |
2543 EXPECT_FALSE(animatingChild->renderSurface()); | 2543 EXPECT_FALSE(animatingChild->renderSurface()); |
2544 EXPECT_FALSE(child2->renderSurface()); | 2544 EXPECT_FALSE(child2->renderSurface()); |
2545 | 2545 |
2546 // Verify that the animatingChild and childOfAnimatingSurface were not culle
d, but that child was. | 2546 // Verify that the animatingChild and childOfAnimatingSurface were not culle
d, but that child was. |
2547 ASSERT_EQ(2u, renderSurfaceLayerList.size()); | 2547 ASSERT_EQ(2u, renderSurfaceLayerList.size()); |
2548 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); | 2548 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); |
(...skipping 11 matching lines...) Expand all Loading... |
2560 | 2560 |
2561 EXPECT_FALSE(child2->visibleContentRect().isEmpty()); | 2561 EXPECT_FALSE(child2->visibleContentRect().isEmpty()); |
2562 | 2562 |
2563 // The animating layers should have a visibleContentRect that represents the
area of the front face that is within the viewport. | 2563 // The animating layers should have a visibleContentRect that represents the
area of the front face that is within the viewport. |
2564 EXPECT_EQ(animatingChild->visibleContentRect(), IntRect(IntPoint(), animatin
gChild->contentBounds())); | 2564 EXPECT_EQ(animatingChild->visibleContentRect(), IntRect(IntPoint(), animatin
gChild->contentBounds())); |
2565 EXPECT_EQ(animatingSurface->visibleContentRect(), IntRect(IntPoint(), animat
ingSurface->contentBounds())); | 2565 EXPECT_EQ(animatingSurface->visibleContentRect(), IntRect(IntPoint(), animat
ingSurface->contentBounds())); |
2566 // And layers in the subtree of the animating layer should have valid visibl
eContentRects also. | 2566 // And layers in the subtree of the animating layer should have valid visibl
eContentRects also. |
2567 EXPECT_EQ(childOfAnimatingSurface->visibleContentRect(), IntRect(IntPoint(),
childOfAnimatingSurface->contentBounds())); | 2567 EXPECT_EQ(childOfAnimatingSurface->visibleContentRect(), IntRect(IntPoint(),
childOfAnimatingSurface->contentBounds())); |
2568 } | 2568 } |
2569 | 2569 |
2570 TEST(CCLayerTreeHostCommonTest, verifyBackFaceCullingWithPreserves3dForFlattenin
gSurface) | 2570 TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithPreserves3dForFlatteningS
urface) |
2571 { | 2571 { |
2572 // Verify the behavior of back-face culling for a renderSurface that is crea
ted | 2572 // Verify the behavior of back-face culling for a renderSurface that is crea
ted |
2573 // when it flattens its subtree, and its parent has preserves-3d. | 2573 // when it flattens its subtree, and its parent has preserves-3d. |
2574 | 2574 |
2575 const WebTransformationMatrix identityMatrix; | 2575 const WebTransformationMatrix identityMatrix; |
2576 scoped_refptr<LayerChromium> parent = LayerChromium::create(); | 2576 scoped_refptr<Layer> parent = Layer::create(); |
2577 scoped_refptr<LayerChromiumWithForcedDrawsContent> frontFacingSurface = make
_scoped_refptr(new LayerChromiumWithForcedDrawsContent()); | 2577 scoped_refptr<LayerWithForcedDrawsContent> frontFacingSurface = make_scoped_
refptr(new LayerWithForcedDrawsContent()); |
2578 scoped_refptr<LayerChromiumWithForcedDrawsContent> backFacingSurface = make_
scoped_refptr(new LayerChromiumWithForcedDrawsContent()); | 2578 scoped_refptr<LayerWithForcedDrawsContent> backFacingSurface = make_scoped_r
efptr(new LayerWithForcedDrawsContent()); |
2579 scoped_refptr<LayerChromiumWithForcedDrawsContent> child1 = make_scoped_refp
tr(new LayerChromiumWithForcedDrawsContent()); | 2579 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
2580 scoped_refptr<LayerChromiumWithForcedDrawsContent> child2 = make_scoped_refp
tr(new LayerChromiumWithForcedDrawsContent()); | 2580 scoped_refptr<LayerWithForcedDrawsContent> child2 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
2581 | 2581 |
2582 parent->addChild(frontFacingSurface); | 2582 parent->addChild(frontFacingSurface); |
2583 parent->addChild(backFacingSurface); | 2583 parent->addChild(backFacingSurface); |
2584 frontFacingSurface->addChild(child1); | 2584 frontFacingSurface->addChild(child1); |
2585 backFacingSurface->addChild(child2); | 2585 backFacingSurface->addChild(child2); |
2586 | 2586 |
2587 // RenderSurfaces are not double-sided | 2587 // RenderSurfaces are not double-sided |
2588 frontFacingSurface->setDoubleSided(false); | 2588 frontFacingSurface->setDoubleSided(false); |
2589 backFacingSurface->setDoubleSided(false); | 2589 backFacingSurface->setDoubleSided(false); |
2590 | 2590 |
2591 WebTransformationMatrix backfaceMatrix; | 2591 WebTransformationMatrix backfaceMatrix; |
2592 backfaceMatrix.translate(50, 50); | 2592 backfaceMatrix.translate(50, 50); |
2593 backfaceMatrix.rotate3d(0, 1, 0, 180); | 2593 backfaceMatrix.rotate3d(0, 1, 0, 180); |
2594 backfaceMatrix.translate(-50, -50); | 2594 backfaceMatrix.translate(-50, -50); |
2595 | 2595 |
2596 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true); // parent transform
style is preserve3d. | 2596 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true); // parent transform
style is preserve3d. |
2597 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident
ityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); // sur
face transform style is flat. | 2597 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident
ityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); // sur
face transform style is flat. |
2598 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, ident
ityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); // sur
face transform style is flat. | 2598 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, ident
ityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); // sur
face transform style is flat. |
2599 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 2599 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
2600 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 2600 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
2601 | 2601 |
2602 std::vector<scoped_refptr<LayerChromium> > renderSurfaceLayerList; | 2602 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
2603 int dummyMaxTextureSize = 512; | 2603 int dummyMaxTextureSize = 512; |
2604 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, dummyMaxTextureSize, renderSurfaceLayerList); | 2604 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
1, dummyMaxTextureSize, renderSurfaceLayerList); |
2605 | 2605 |
2606 // Verify which renderSurfaces were created. | 2606 // Verify which renderSurfaces were created. |
2607 EXPECT_TRUE(frontFacingSurface->renderSurface()); | 2607 EXPECT_TRUE(frontFacingSurface->renderSurface()); |
2608 EXPECT_FALSE(backFacingSurface->renderSurface()); // because it should be cu
lled | 2608 EXPECT_FALSE(backFacingSurface->renderSurface()); // because it should be cu
lled |
2609 EXPECT_FALSE(child1->renderSurface()); | 2609 EXPECT_FALSE(child1->renderSurface()); |
2610 EXPECT_FALSE(child2->renderSurface()); | 2610 EXPECT_FALSE(child2->renderSurface()); |
2611 | 2611 |
2612 // Verify the renderSurfaceLayerList. The back-facing surface should be cull
ed. | 2612 // Verify the renderSurfaceLayerList. The back-facing surface should be cull
ed. |
2613 ASSERT_EQ(2u, renderSurfaceLayerList.size()); | 2613 ASSERT_EQ(2u, renderSurfaceLayerList.size()); |
2614 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); | 2614 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); |
2615 EXPECT_EQ(frontFacingSurface->id(), renderSurfaceLayerList[1]->id()); | 2615 EXPECT_EQ(frontFacingSurface->id(), renderSurfaceLayerList[1]->id()); |
2616 | 2616 |
2617 // Verify root surface's layerList. | 2617 // Verify root surface's layerList. |
2618 ASSERT_EQ(1u, renderSurfaceLayerList[0]->renderSurface()->layerList().size()
); | 2618 ASSERT_EQ(1u, renderSurfaceLayerList[0]->renderSurface()->layerList().size()
); |
2619 EXPECT_EQ(frontFacingSurface->id(), renderSurfaceLayerList[0]->renderSurface
()->layerList()[0]->id()); | 2619 EXPECT_EQ(frontFacingSurface->id(), renderSurfaceLayerList[0]->renderSurface
()->layerList()[0]->id()); |
2620 | 2620 |
2621 // Verify frontFacingSurface's layerList. | 2621 // Verify frontFacingSurface's layerList. |
2622 ASSERT_EQ(2u, renderSurfaceLayerList[1]->renderSurface()->layerList().size()
); | 2622 ASSERT_EQ(2u, renderSurfaceLayerList[1]->renderSurface()->layerList().size()
); |
2623 EXPECT_EQ(frontFacingSurface->id(), renderSurfaceLayerList[1]->renderSurface
()->layerList()[0]->id()); | 2623 EXPECT_EQ(frontFacingSurface->id(), renderSurfaceLayerList[1]->renderSurface
()->layerList()[0]->id()); |
2624 EXPECT_EQ(child1->id(), renderSurfaceLayerList[1]->renderSurface()->layerLis
t()[1]->id()); | 2624 EXPECT_EQ(child1->id(), renderSurfaceLayerList[1]->renderSurface()->layerLis
t()[1]->id()); |
2625 } | 2625 } |
2626 | 2626 |
2627 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForEmptyLayerList) | 2627 TEST(LayerTreeHostCommonTest, verifyHitTestingForEmptyLayerList) |
2628 { | 2628 { |
2629 // Hit testing on an empty renderSurfaceLayerList should return a null point
er. | 2629 // Hit testing on an empty renderSurfaceLayerList should return a null point
er. |
2630 DebugScopedSetImplThread thisScopeIsOnImplThread; | 2630 DebugScopedSetImplThread thisScopeIsOnImplThread; |
2631 | 2631 |
2632 std::vector<CCLayerImpl*> renderSurfaceLayerList; | 2632 std::vector<LayerImpl*> renderSurfaceLayerList; |
2633 | 2633 |
2634 IntPoint testPoint(0, 0); | 2634 IntPoint testPoint(0, 0); |
2635 CCLayerImpl* resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(
testPoint, renderSurfaceLayerList); | 2635 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); |
2636 EXPECT_FALSE(resultLayer); | 2636 EXPECT_FALSE(resultLayer); |
2637 | 2637 |
2638 testPoint = IntPoint(10, 20); | 2638 testPoint = IntPoint(10, 20); |
2639 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 2639 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
2640 EXPECT_FALSE(resultLayer); | 2640 EXPECT_FALSE(resultLayer); |
2641 } | 2641 } |
2642 | 2642 |
2643 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForSingleLayer) | 2643 TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleLayer) |
2644 { | 2644 { |
2645 DebugScopedSetImplThread thisScopeIsOnImplThread; | 2645 DebugScopedSetImplThread thisScopeIsOnImplThread; |
2646 | 2646 |
2647 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(12345); | 2647 scoped_ptr<LayerImpl> root = LayerImpl::create(12345); |
2648 | 2648 |
2649 WebTransformationMatrix identityMatrix; | 2649 WebTransformationMatrix identityMatrix; |
2650 FloatPoint anchor(0, 0); | 2650 FloatPoint anchor(0, 0); |
2651 FloatPoint position(0, 0); | 2651 FloatPoint position(0, 0); |
2652 IntSize bounds(100, 100); | 2652 IntSize bounds(100, 100); |
2653 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 2653 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
2654 root->setDrawsContent(true); | 2654 root->setDrawsContent(true); |
2655 | 2655 |
2656 std::vector<CCLayerImpl*> renderSurfaceLayerList; | 2656 std::vector<LayerImpl*> renderSurfaceLayerList; |
2657 int dummyMaxTextureSize = 512; | 2657 int dummyMaxTextureSize = 512; |
2658 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 2658 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1,
0, dummyMaxTextureSize, renderSurfaceLayerList); |
2659 | 2659 |
2660 // Sanity check the scenario we just created. | 2660 // Sanity check the scenario we just created. |
2661 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 2661 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
2662 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); | 2662 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); |
2663 | 2663 |
2664 // Hit testing for a point outside the layer should return a null pointer. | 2664 // Hit testing for a point outside the layer should return a null pointer. |
2665 IntPoint testPoint(101, 101); | 2665 IntPoint testPoint(101, 101); |
2666 CCLayerImpl* resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(
testPoint, renderSurfaceLayerList); | 2666 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); |
2667 EXPECT_FALSE(resultLayer); | 2667 EXPECT_FALSE(resultLayer); |
2668 | 2668 |
2669 testPoint = IntPoint(-1, -1); | 2669 testPoint = IntPoint(-1, -1); |
2670 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 2670 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
2671 EXPECT_FALSE(resultLayer); | 2671 EXPECT_FALSE(resultLayer); |
2672 | 2672 |
2673 // Hit testing for a point inside should return the root layer. | 2673 // Hit testing for a point inside should return the root layer. |
2674 testPoint = IntPoint(1, 1); | 2674 testPoint = IntPoint(1, 1); |
2675 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 2675 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
2676 ASSERT_TRUE(resultLayer); | 2676 ASSERT_TRUE(resultLayer); |
2677 EXPECT_EQ(12345, resultLayer->id()); | 2677 EXPECT_EQ(12345, resultLayer->id()); |
2678 | 2678 |
2679 testPoint = IntPoint(99, 99); | 2679 testPoint = IntPoint(99, 99); |
2680 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 2680 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
2681 ASSERT_TRUE(resultLayer); | 2681 ASSERT_TRUE(resultLayer); |
2682 EXPECT_EQ(12345, resultLayer->id()); | 2682 EXPECT_EQ(12345, resultLayer->id()); |
2683 } | 2683 } |
2684 | 2684 |
2685 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForUninvertibleTransform) | 2685 TEST(LayerTreeHostCommonTest, verifyHitTestingForUninvertibleTransform) |
2686 { | 2686 { |
2687 DebugScopedSetImplThread thisScopeIsOnImplThread; | 2687 DebugScopedSetImplThread thisScopeIsOnImplThread; |
2688 | 2688 |
2689 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(12345); | 2689 scoped_ptr<LayerImpl> root = LayerImpl::create(12345); |
2690 | 2690 |
2691 WebTransformationMatrix uninvertibleTransform; | 2691 WebTransformationMatrix uninvertibleTransform; |
2692 uninvertibleTransform.setM11(0); | 2692 uninvertibleTransform.setM11(0); |
2693 uninvertibleTransform.setM22(0); | 2693 uninvertibleTransform.setM22(0); |
2694 uninvertibleTransform.setM33(0); | 2694 uninvertibleTransform.setM33(0); |
2695 uninvertibleTransform.setM44(0); | 2695 uninvertibleTransform.setM44(0); |
2696 ASSERT_FALSE(uninvertibleTransform.isInvertible()); | 2696 ASSERT_FALSE(uninvertibleTransform.isInvertible()); |
2697 | 2697 |
2698 WebTransformationMatrix identityMatrix; | 2698 WebTransformationMatrix identityMatrix; |
2699 FloatPoint anchor(0, 0); | 2699 FloatPoint anchor(0, 0); |
2700 FloatPoint position(0, 0); | 2700 FloatPoint position(0, 0); |
2701 IntSize bounds(100, 100); | 2701 IntSize bounds(100, 100); |
2702 setLayerPropertiesForTesting(root.get(), uninvertibleTransform, identityMatr
ix, anchor, position, bounds, false); | 2702 setLayerPropertiesForTesting(root.get(), uninvertibleTransform, identityMatr
ix, anchor, position, bounds, false); |
2703 root->setDrawsContent(true); | 2703 root->setDrawsContent(true); |
2704 | 2704 |
2705 std::vector<CCLayerImpl*> renderSurfaceLayerList; | 2705 std::vector<LayerImpl*> renderSurfaceLayerList; |
2706 int dummyMaxTextureSize = 512; | 2706 int dummyMaxTextureSize = 512; |
2707 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 2707 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1,
0, dummyMaxTextureSize, renderSurfaceLayerList); |
2708 | 2708 |
2709 // Sanity check the scenario we just created. | 2709 // Sanity check the scenario we just created. |
2710 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 2710 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
2711 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); | 2711 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); |
2712 ASSERT_FALSE(root->screenSpaceTransform().isInvertible()); | 2712 ASSERT_FALSE(root->screenSpaceTransform().isInvertible()); |
2713 | 2713 |
2714 // Hit testing any point should not hit the layer. If the invertible matrix
is | 2714 // Hit testing any point should not hit the layer. If the invertible matrix
is |
2715 // accidentally ignored and treated like an identity, then the hit testing w
ill | 2715 // accidentally ignored and treated like an identity, then the hit testing w
ill |
2716 // incorrectly hit the layer when it shouldn't. | 2716 // incorrectly hit the layer when it shouldn't. |
2717 IntPoint testPoint(1, 1); | 2717 IntPoint testPoint(1, 1); |
2718 CCLayerImpl* resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(
testPoint, renderSurfaceLayerList); | 2718 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); |
2719 EXPECT_FALSE(resultLayer); | 2719 EXPECT_FALSE(resultLayer); |
2720 | 2720 |
2721 testPoint = IntPoint(10, 10); | 2721 testPoint = IntPoint(10, 10); |
2722 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 2722 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
2723 EXPECT_FALSE(resultLayer); | 2723 EXPECT_FALSE(resultLayer); |
2724 | 2724 |
2725 testPoint = IntPoint(10, 30); | 2725 testPoint = IntPoint(10, 30); |
2726 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 2726 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
2727 EXPECT_FALSE(resultLayer); | 2727 EXPECT_FALSE(resultLayer); |
2728 | 2728 |
2729 testPoint = IntPoint(50, 50); | 2729 testPoint = IntPoint(50, 50); |
2730 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 2730 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
2731 EXPECT_FALSE(resultLayer); | 2731 EXPECT_FALSE(resultLayer); |
2732 | 2732 |
2733 testPoint = IntPoint(67, 48); | 2733 testPoint = IntPoint(67, 48); |
2734 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 2734 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
2735 EXPECT_FALSE(resultLayer); | 2735 EXPECT_FALSE(resultLayer); |
2736 | 2736 |
2737 testPoint = IntPoint(99, 99); | 2737 testPoint = IntPoint(99, 99); |
2738 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 2738 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
2739 EXPECT_FALSE(resultLayer); | 2739 EXPECT_FALSE(resultLayer); |
2740 | 2740 |
2741 testPoint = IntPoint(-1, -1); | 2741 testPoint = IntPoint(-1, -1); |
2742 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 2742 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
2743 EXPECT_FALSE(resultLayer); | 2743 EXPECT_FALSE(resultLayer); |
2744 } | 2744 } |
2745 | 2745 |
2746 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForSinglePositionedLayer) | 2746 TEST(LayerTreeHostCommonTest, verifyHitTestingForSinglePositionedLayer) |
2747 { | 2747 { |
2748 DebugScopedSetImplThread thisScopeIsOnImplThread; | 2748 DebugScopedSetImplThread thisScopeIsOnImplThread; |
2749 | 2749 |
2750 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(12345); | 2750 scoped_ptr<LayerImpl> root = LayerImpl::create(12345); |
2751 | 2751 |
2752 WebTransformationMatrix identityMatrix; | 2752 WebTransformationMatrix identityMatrix; |
2753 FloatPoint anchor(0, 0); | 2753 FloatPoint anchor(0, 0); |
2754 FloatPoint position(50, 50); // this layer is positioned, and hit testing sh
ould correctly know where the layer is located. | 2754 FloatPoint position(50, 50); // this layer is positioned, and hit testing sh
ould correctly know where the layer is located. |
2755 IntSize bounds(100, 100); | 2755 IntSize bounds(100, 100); |
2756 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 2756 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
2757 root->setDrawsContent(true); | 2757 root->setDrawsContent(true); |
2758 | 2758 |
2759 std::vector<CCLayerImpl*> renderSurfaceLayerList; | 2759 std::vector<LayerImpl*> renderSurfaceLayerList; |
2760 int dummyMaxTextureSize = 512; | 2760 int dummyMaxTextureSize = 512; |
2761 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 2761 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1,
0, dummyMaxTextureSize, renderSurfaceLayerList); |
2762 | 2762 |
2763 // Sanity check the scenario we just created. | 2763 // Sanity check the scenario we just created. |
2764 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 2764 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
2765 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); | 2765 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); |
2766 | 2766 |
2767 // Hit testing for a point outside the layer should return a null pointer. | 2767 // Hit testing for a point outside the layer should return a null pointer. |
2768 IntPoint testPoint(49, 49); | 2768 IntPoint testPoint(49, 49); |
2769 CCLayerImpl* resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(
testPoint, renderSurfaceLayerList); | 2769 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); |
2770 EXPECT_FALSE(resultLayer); | 2770 EXPECT_FALSE(resultLayer); |
2771 | 2771 |
2772 // Even though the layer exists at (101, 101), it should not be visible ther
e since the root renderSurface would clamp it. | 2772 // Even though the layer exists at (101, 101), it should not be visible ther
e since the root renderSurface would clamp it. |
2773 testPoint = IntPoint(101, 101); | 2773 testPoint = IntPoint(101, 101); |
2774 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 2774 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
2775 EXPECT_FALSE(resultLayer); | 2775 EXPECT_FALSE(resultLayer); |
2776 | 2776 |
2777 // Hit testing for a point inside should return the root layer. | 2777 // Hit testing for a point inside should return the root layer. |
2778 testPoint = IntPoint(51, 51); | 2778 testPoint = IntPoint(51, 51); |
2779 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 2779 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
2780 ASSERT_TRUE(resultLayer); | 2780 ASSERT_TRUE(resultLayer); |
2781 EXPECT_EQ(12345, resultLayer->id()); | 2781 EXPECT_EQ(12345, resultLayer->id()); |
2782 | 2782 |
2783 testPoint = IntPoint(99, 99); | 2783 testPoint = IntPoint(99, 99); |
2784 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 2784 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
2785 ASSERT_TRUE(resultLayer); | 2785 ASSERT_TRUE(resultLayer); |
2786 EXPECT_EQ(12345, resultLayer->id()); | 2786 EXPECT_EQ(12345, resultLayer->id()); |
2787 } | 2787 } |
2788 | 2788 |
2789 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForSingleRotatedLayer) | 2789 TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleRotatedLayer) |
2790 { | 2790 { |
2791 DebugScopedSetImplThread thisScopeIsOnImplThread; | 2791 DebugScopedSetImplThread thisScopeIsOnImplThread; |
2792 | 2792 |
2793 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(12345); | 2793 scoped_ptr<LayerImpl> root = LayerImpl::create(12345); |
2794 | 2794 |
2795 WebTransformationMatrix identityMatrix; | 2795 WebTransformationMatrix identityMatrix; |
2796 WebTransformationMatrix rotation45DegreesAboutCenter; | 2796 WebTransformationMatrix rotation45DegreesAboutCenter; |
2797 rotation45DegreesAboutCenter.translate(50, 50); | 2797 rotation45DegreesAboutCenter.translate(50, 50); |
2798 rotation45DegreesAboutCenter.rotate3d(0, 0, 45); | 2798 rotation45DegreesAboutCenter.rotate3d(0, 0, 45); |
2799 rotation45DegreesAboutCenter.translate(-50, -50); | 2799 rotation45DegreesAboutCenter.translate(-50, -50); |
2800 FloatPoint anchor(0, 0); | 2800 FloatPoint anchor(0, 0); |
2801 FloatPoint position(0, 0); | 2801 FloatPoint position(0, 0); |
2802 IntSize bounds(100, 100); | 2802 IntSize bounds(100, 100); |
2803 setLayerPropertiesForTesting(root.get(), rotation45DegreesAboutCenter, ident
ityMatrix, anchor, position, bounds, false); | 2803 setLayerPropertiesForTesting(root.get(), rotation45DegreesAboutCenter, ident
ityMatrix, anchor, position, bounds, false); |
2804 root->setDrawsContent(true); | 2804 root->setDrawsContent(true); |
2805 | 2805 |
2806 std::vector<CCLayerImpl*> renderSurfaceLayerList; | 2806 std::vector<LayerImpl*> renderSurfaceLayerList; |
2807 int dummyMaxTextureSize = 512; | 2807 int dummyMaxTextureSize = 512; |
2808 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 2808 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1,
0, dummyMaxTextureSize, renderSurfaceLayerList); |
2809 | 2809 |
2810 // Sanity check the scenario we just created. | 2810 // Sanity check the scenario we just created. |
2811 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 2811 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
2812 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); | 2812 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); |
2813 | 2813 |
2814 // Hit testing for points outside the layer. | 2814 // Hit testing for points outside the layer. |
2815 // These corners would have been inside the un-transformed layer, but they s
hould not hit the correctly transformed layer. | 2815 // These corners would have been inside the un-transformed layer, but they s
hould not hit the correctly transformed layer. |
2816 IntPoint testPoint(99, 99); | 2816 IntPoint testPoint(99, 99); |
2817 CCLayerImpl* resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(
testPoint, renderSurfaceLayerList); | 2817 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); |
2818 EXPECT_FALSE(resultLayer); | 2818 EXPECT_FALSE(resultLayer); |
2819 | 2819 |
2820 testPoint = IntPoint(1, 1); | 2820 testPoint = IntPoint(1, 1); |
2821 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 2821 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
2822 EXPECT_FALSE(resultLayer); | 2822 EXPECT_FALSE(resultLayer); |
2823 | 2823 |
2824 // Hit testing for a point inside should return the root layer. | 2824 // Hit testing for a point inside should return the root layer. |
2825 testPoint = IntPoint(1, 50); | 2825 testPoint = IntPoint(1, 50); |
2826 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 2826 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
2827 ASSERT_TRUE(resultLayer); | 2827 ASSERT_TRUE(resultLayer); |
2828 EXPECT_EQ(12345, resultLayer->id()); | 2828 EXPECT_EQ(12345, resultLayer->id()); |
2829 | 2829 |
2830 // Hit testing the corners that would overlap the unclipped layer, but are o
utside the clipped region. | 2830 // Hit testing the corners that would overlap the unclipped layer, but are o
utside the clipped region. |
2831 testPoint = IntPoint(50, -1); | 2831 testPoint = IntPoint(50, -1); |
2832 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 2832 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
2833 ASSERT_FALSE(resultLayer); | 2833 ASSERT_FALSE(resultLayer); |
2834 | 2834 |
2835 testPoint = IntPoint(-1, 50); | 2835 testPoint = IntPoint(-1, 50); |
2836 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 2836 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
2837 ASSERT_FALSE(resultLayer); | 2837 ASSERT_FALSE(resultLayer); |
2838 } | 2838 } |
2839 | 2839 |
2840 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForSinglePerspectiveLayer) | 2840 TEST(LayerTreeHostCommonTest, verifyHitTestingForSinglePerspectiveLayer) |
2841 { | 2841 { |
2842 DebugScopedSetImplThread thisScopeIsOnImplThread; | 2842 DebugScopedSetImplThread thisScopeIsOnImplThread; |
2843 | 2843 |
2844 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(12345); | 2844 scoped_ptr<LayerImpl> root = LayerImpl::create(12345); |
2845 | 2845 |
2846 WebTransformationMatrix identityMatrix; | 2846 WebTransformationMatrix identityMatrix; |
2847 | 2847 |
2848 // perspectiveProjectionAboutCenter * translationByZ is designed so that the
100 x 100 layer becomes 50 x 50, and remains centered at (50, 50). | 2848 // perspectiveProjectionAboutCenter * translationByZ is designed so that the
100 x 100 layer becomes 50 x 50, and remains centered at (50, 50). |
2849 WebTransformationMatrix perspectiveProjectionAboutCenter; | 2849 WebTransformationMatrix perspectiveProjectionAboutCenter; |
2850 perspectiveProjectionAboutCenter.translate(50, 50); | 2850 perspectiveProjectionAboutCenter.translate(50, 50); |
2851 perspectiveProjectionAboutCenter.applyPerspective(1); | 2851 perspectiveProjectionAboutCenter.applyPerspective(1); |
2852 perspectiveProjectionAboutCenter.translate(-50, -50); | 2852 perspectiveProjectionAboutCenter.translate(-50, -50); |
2853 WebTransformationMatrix translationByZ; | 2853 WebTransformationMatrix translationByZ; |
2854 translationByZ.translate3d(0, 0, -1); | 2854 translationByZ.translate3d(0, 0, -1); |
2855 | 2855 |
2856 FloatPoint anchor(0, 0); | 2856 FloatPoint anchor(0, 0); |
2857 FloatPoint position(0, 0); | 2857 FloatPoint position(0, 0); |
2858 IntSize bounds(100, 100); | 2858 IntSize bounds(100, 100); |
2859 setLayerPropertiesForTesting(root.get(), perspectiveProjectionAboutCenter *
translationByZ, identityMatrix, anchor, position, bounds, false); | 2859 setLayerPropertiesForTesting(root.get(), perspectiveProjectionAboutCenter *
translationByZ, identityMatrix, anchor, position, bounds, false); |
2860 root->setDrawsContent(true); | 2860 root->setDrawsContent(true); |
2861 | 2861 |
2862 std::vector<CCLayerImpl*> renderSurfaceLayerList; | 2862 std::vector<LayerImpl*> renderSurfaceLayerList; |
2863 int dummyMaxTextureSize = 512; | 2863 int dummyMaxTextureSize = 512; |
2864 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 2864 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1,
0, dummyMaxTextureSize, renderSurfaceLayerList); |
2865 | 2865 |
2866 // Sanity check the scenario we just created. | 2866 // Sanity check the scenario we just created. |
2867 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 2867 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
2868 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); | 2868 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); |
2869 | 2869 |
2870 // Hit testing for points outside the layer. | 2870 // Hit testing for points outside the layer. |
2871 // These corners would have been inside the un-transformed layer, but they s
hould not hit the correctly transformed layer. | 2871 // These corners would have been inside the un-transformed layer, but they s
hould not hit the correctly transformed layer. |
2872 IntPoint testPoint(24, 24); | 2872 IntPoint testPoint(24, 24); |
2873 CCLayerImpl* resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(
testPoint, renderSurfaceLayerList); | 2873 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); |
2874 EXPECT_FALSE(resultLayer); | 2874 EXPECT_FALSE(resultLayer); |
2875 | 2875 |
2876 testPoint = IntPoint(76, 76); | 2876 testPoint = IntPoint(76, 76); |
2877 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 2877 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
2878 EXPECT_FALSE(resultLayer); | 2878 EXPECT_FALSE(resultLayer); |
2879 | 2879 |
2880 // Hit testing for a point inside should return the root layer. | 2880 // Hit testing for a point inside should return the root layer. |
2881 testPoint = IntPoint(26, 26); | 2881 testPoint = IntPoint(26, 26); |
2882 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 2882 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
2883 ASSERT_TRUE(resultLayer); | 2883 ASSERT_TRUE(resultLayer); |
2884 EXPECT_EQ(12345, resultLayer->id()); | 2884 EXPECT_EQ(12345, resultLayer->id()); |
2885 | 2885 |
2886 testPoint = IntPoint(74, 74); | 2886 testPoint = IntPoint(74, 74); |
2887 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 2887 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
2888 ASSERT_TRUE(resultLayer); | 2888 ASSERT_TRUE(resultLayer); |
2889 EXPECT_EQ(12345, resultLayer->id()); | 2889 EXPECT_EQ(12345, resultLayer->id()); |
2890 } | 2890 } |
2891 | 2891 |
2892 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForSingleLayerWithScaledContents
) | 2892 TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleLayerWithScaledContents) |
2893 { | 2893 { |
2894 // A layer's visibleContentRect is actually in the layer's content space. Th
e | 2894 // A layer's visibleContentRect is actually in the layer's content space. Th
e |
2895 // screenSpaceTransform converts from the layer's origin space to screen spa
ce. This | 2895 // screenSpaceTransform converts from the layer's origin space to screen spa
ce. This |
2896 // test makes sure that hit testing works correctly accounts for the content
s scale. | 2896 // test makes sure that hit testing works correctly accounts for the content
s scale. |
2897 // A contentsScale that is not 1 effectively forces a non-identity transform
between | 2897 // A contentsScale that is not 1 effectively forces a non-identity transform
between |
2898 // layer's content space and layer's origin space. The hit testing code must
take this into account. | 2898 // layer's content space and layer's origin space. The hit testing code must
take this into account. |
2899 // | 2899 // |
2900 // To test this, the layer is positioned at (25, 25), and is size (50, 50).
If | 2900 // To test this, the layer is positioned at (25, 25), and is size (50, 50).
If |
2901 // contentsScale is ignored, then hit testing will mis-interpret the visible
ContentRect | 2901 // contentsScale is ignored, then hit testing will mis-interpret the visible
ContentRect |
2902 // as being larger than the actual bounds of the layer. | 2902 // as being larger than the actual bounds of the layer. |
2903 // | 2903 // |
2904 DebugScopedSetImplThread thisScopeIsOnImplThread; | 2904 DebugScopedSetImplThread thisScopeIsOnImplThread; |
2905 | 2905 |
2906 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); | 2906 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
2907 | 2907 |
2908 WebTransformationMatrix identityMatrix; | 2908 WebTransformationMatrix identityMatrix; |
2909 FloatPoint anchor(0, 0); | 2909 FloatPoint anchor(0, 0); |
2910 | 2910 |
2911 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, FloatPoint(0, 0), IntSize(100, 100), false); | 2911 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, FloatPoint(0, 0), IntSize(100, 100), false); |
2912 | 2912 |
2913 { | 2913 { |
2914 FloatPoint position(25, 25); | 2914 FloatPoint position(25, 25); |
2915 IntSize bounds(50, 50); | 2915 IntSize bounds(50, 50); |
2916 scoped_ptr<CCLayerImpl> testLayer = CCLayerImpl::create(12345); | 2916 scoped_ptr<LayerImpl> testLayer = LayerImpl::create(12345); |
2917 setLayerPropertiesForTesting(testLayer.get(), identityMatrix, identityMa
trix, anchor, position, bounds, false); | 2917 setLayerPropertiesForTesting(testLayer.get(), identityMatrix, identityMa
trix, anchor, position, bounds, false); |
2918 | 2918 |
2919 // override contentBounds | 2919 // override contentBounds |
2920 testLayer->setContentBounds(IntSize(100, 100)); | 2920 testLayer->setContentBounds(IntSize(100, 100)); |
2921 | 2921 |
2922 testLayer->setDrawsContent(true); | 2922 testLayer->setDrawsContent(true); |
2923 root->addChild(testLayer.Pass()); | 2923 root->addChild(testLayer.Pass()); |
2924 } | 2924 } |
2925 | 2925 |
2926 std::vector<CCLayerImpl*> renderSurfaceLayerList; | 2926 std::vector<LayerImpl*> renderSurfaceLayerList; |
2927 int dummyMaxTextureSize = 512; | 2927 int dummyMaxTextureSize = 512; |
2928 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 2928 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1,
0, dummyMaxTextureSize, renderSurfaceLayerList); |
2929 | 2929 |
2930 // Sanity check the scenario we just created. | 2930 // Sanity check the scenario we just created. |
2931 // The visibleContentRect for testLayer is actually 100x100, even though its
layout size is 50x50, positioned at 25x25. | 2931 // The visibleContentRect for testLayer is actually 100x100, even though its
layout size is 50x50, positioned at 25x25. |
2932 CCLayerImpl* testLayer = root->children()[0]; | 2932 LayerImpl* testLayer = root->children()[0]; |
2933 EXPECT_RECT_EQ(IntRect(IntPoint::zero(), IntSize(100, 100)), testLayer->visi
bleContentRect()); | 2933 EXPECT_RECT_EQ(IntRect(IntPoint::zero(), IntSize(100, 100)), testLayer->visi
bleContentRect()); |
2934 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 2934 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
2935 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); | 2935 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); |
2936 | 2936 |
2937 // Hit testing for a point outside the layer should return a null pointer (t
he root layer does not draw content, so it will not be hit tested either). | 2937 // Hit testing for a point outside the layer should return a null pointer (t
he root layer does not draw content, so it will not be hit tested either). |
2938 IntPoint testPoint(101, 101); | 2938 IntPoint testPoint(101, 101); |
2939 CCLayerImpl* resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(
testPoint, renderSurfaceLayerList); | 2939 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); |
2940 EXPECT_FALSE(resultLayer); | 2940 EXPECT_FALSE(resultLayer); |
2941 | 2941 |
2942 testPoint = IntPoint(24, 24); | 2942 testPoint = IntPoint(24, 24); |
2943 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 2943 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
2944 EXPECT_FALSE(resultLayer); | 2944 EXPECT_FALSE(resultLayer); |
2945 | 2945 |
2946 testPoint = IntPoint(76, 76); | 2946 testPoint = IntPoint(76, 76); |
2947 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 2947 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
2948 EXPECT_FALSE(resultLayer); | 2948 EXPECT_FALSE(resultLayer); |
2949 | 2949 |
2950 // Hit testing for a point inside should return the test layer. | 2950 // Hit testing for a point inside should return the test layer. |
2951 testPoint = IntPoint(26, 26); | 2951 testPoint = IntPoint(26, 26); |
2952 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 2952 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
2953 ASSERT_TRUE(resultLayer); | 2953 ASSERT_TRUE(resultLayer); |
2954 EXPECT_EQ(12345, resultLayer->id()); | 2954 EXPECT_EQ(12345, resultLayer->id()); |
2955 | 2955 |
2956 testPoint = IntPoint(74, 74); | 2956 testPoint = IntPoint(74, 74); |
2957 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 2957 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
2958 ASSERT_TRUE(resultLayer); | 2958 ASSERT_TRUE(resultLayer); |
2959 EXPECT_EQ(12345, resultLayer->id()); | 2959 EXPECT_EQ(12345, resultLayer->id()); |
2960 } | 2960 } |
2961 | 2961 |
2962 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForSimpleClippedLayer) | 2962 TEST(LayerTreeHostCommonTest, verifyHitTestingForSimpleClippedLayer) |
2963 { | 2963 { |
2964 // Test that hit-testing will only work for the visible portion of a layer,
and not | 2964 // Test that hit-testing will only work for the visible portion of a layer,
and not |
2965 // the entire layer bounds. Here we just test the simple axis-aligned case. | 2965 // the entire layer bounds. Here we just test the simple axis-aligned case. |
2966 DebugScopedSetImplThread thisScopeIsOnImplThread; | 2966 DebugScopedSetImplThread thisScopeIsOnImplThread; |
2967 | 2967 |
2968 WebTransformationMatrix identityMatrix; | 2968 WebTransformationMatrix identityMatrix; |
2969 FloatPoint anchor(0, 0); | 2969 FloatPoint anchor(0, 0); |
2970 | 2970 |
2971 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); | 2971 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
2972 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, FloatPoint(0, 0), IntSize(100, 100), false); | 2972 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, FloatPoint(0, 0), IntSize(100, 100), false); |
2973 | 2973 |
2974 { | 2974 { |
2975 scoped_ptr<CCLayerImpl> clippingLayer = CCLayerImpl::create(123); | 2975 scoped_ptr<LayerImpl> clippingLayer = LayerImpl::create(123); |
2976 FloatPoint position(25, 25); // this layer is positioned, and hit testin
g should correctly know where the layer is located. | 2976 FloatPoint position(25, 25); // this layer is positioned, and hit testin
g should correctly know where the layer is located. |
2977 IntSize bounds(50, 50); | 2977 IntSize bounds(50, 50); |
2978 setLayerPropertiesForTesting(clippingLayer.get(), identityMatrix, identi
tyMatrix, anchor, position, bounds, false); | 2978 setLayerPropertiesForTesting(clippingLayer.get(), identityMatrix, identi
tyMatrix, anchor, position, bounds, false); |
2979 clippingLayer->setMasksToBounds(true); | 2979 clippingLayer->setMasksToBounds(true); |
2980 | 2980 |
2981 scoped_ptr<CCLayerImpl> child = CCLayerImpl::create(456); | 2981 scoped_ptr<LayerImpl> child = LayerImpl::create(456); |
2982 position = FloatPoint(-50, -50); | 2982 position = FloatPoint(-50, -50); |
2983 bounds = IntSize(300, 300); | 2983 bounds = IntSize(300, 300); |
2984 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); | 2984 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); |
2985 child->setDrawsContent(true); | 2985 child->setDrawsContent(true); |
2986 clippingLayer->addChild(child.Pass()); | 2986 clippingLayer->addChild(child.Pass()); |
2987 root->addChild(clippingLayer.Pass()); | 2987 root->addChild(clippingLayer.Pass()); |
2988 } | 2988 } |
2989 | 2989 |
2990 std::vector<CCLayerImpl*> renderSurfaceLayerList; | 2990 std::vector<LayerImpl*> renderSurfaceLayerList; |
2991 int dummyMaxTextureSize = 512; | 2991 int dummyMaxTextureSize = 512; |
2992 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 2992 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1,
0, dummyMaxTextureSize, renderSurfaceLayerList); |
2993 | 2993 |
2994 // Sanity check the scenario we just created. | 2994 // Sanity check the scenario we just created. |
2995 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 2995 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
2996 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); | 2996 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); |
2997 ASSERT_EQ(456, root->renderSurface()->layerList()[0]->id()); | 2997 ASSERT_EQ(456, root->renderSurface()->layerList()[0]->id()); |
2998 | 2998 |
2999 // Hit testing for a point outside the layer should return a null pointer. | 2999 // Hit testing for a point outside the layer should return a null pointer. |
3000 // Despite the child layer being very large, it should be clipped to the roo
t layer's bounds. | 3000 // Despite the child layer being very large, it should be clipped to the roo
t layer's bounds. |
3001 IntPoint testPoint(24, 24); | 3001 IntPoint testPoint(24, 24); |
3002 CCLayerImpl* resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(
testPoint, renderSurfaceLayerList); | 3002 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); |
3003 EXPECT_FALSE(resultLayer); | 3003 EXPECT_FALSE(resultLayer); |
3004 | 3004 |
3005 // Even though the layer exists at (101, 101), it should not be visible ther
e since the clippingLayer would clamp it. | 3005 // Even though the layer exists at (101, 101), it should not be visible ther
e since the clippingLayer would clamp it. |
3006 testPoint = IntPoint(76, 76); | 3006 testPoint = IntPoint(76, 76); |
3007 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 3007 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3008 EXPECT_FALSE(resultLayer); | 3008 EXPECT_FALSE(resultLayer); |
3009 | 3009 |
3010 // Hit testing for a point inside should return the child layer. | 3010 // Hit testing for a point inside should return the child layer. |
3011 testPoint = IntPoint(26, 26); | 3011 testPoint = IntPoint(26, 26); |
3012 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 3012 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3013 ASSERT_TRUE(resultLayer); | 3013 ASSERT_TRUE(resultLayer); |
3014 EXPECT_EQ(456, resultLayer->id()); | 3014 EXPECT_EQ(456, resultLayer->id()); |
3015 | 3015 |
3016 testPoint = IntPoint(74, 74); | 3016 testPoint = IntPoint(74, 74); |
3017 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 3017 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3018 ASSERT_TRUE(resultLayer); | 3018 ASSERT_TRUE(resultLayer); |
3019 EXPECT_EQ(456, resultLayer->id()); | 3019 EXPECT_EQ(456, resultLayer->id()); |
3020 } | 3020 } |
3021 | 3021 |
3022 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForMultiClippedRotatedLayer) | 3022 TEST(LayerTreeHostCommonTest, verifyHitTestingForMultiClippedRotatedLayer) |
3023 { | 3023 { |
3024 // This test checks whether hit testing correctly avoids hit testing with mu
ltiple | 3024 // This test checks whether hit testing correctly avoids hit testing with mu
ltiple |
3025 // ancestors that clip in non axis-aligned ways. To pass this test, the hit
testing | 3025 // ancestors that clip in non axis-aligned ways. To pass this test, the hit
testing |
3026 // algorithm needs to recognize that multiple parent layers may clip the lay
er, and | 3026 // algorithm needs to recognize that multiple parent layers may clip the lay
er, and |
3027 // should not actually hit those clipped areas. | 3027 // should not actually hit those clipped areas. |
3028 // | 3028 // |
3029 // The child and grandChild layers are both initialized to clip the rotatedL
eaf. The | 3029 // The child and grandChild layers are both initialized to clip the rotatedL
eaf. The |
3030 // child layer is rotated about the top-left corner, so that the root + chil
d clips | 3030 // child layer is rotated about the top-left corner, so that the root + chil
d clips |
3031 // combined create a triangle. The rotatedLeaf will only be visible where it
overlaps | 3031 // combined create a triangle. The rotatedLeaf will only be visible where it
overlaps |
3032 // this triangle. | 3032 // this triangle. |
3033 // | 3033 // |
3034 DebugScopedSetImplThread thisScopeIsOnImplThread; | 3034 DebugScopedSetImplThread thisScopeIsOnImplThread; |
3035 | 3035 |
3036 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(123); | 3036 scoped_ptr<LayerImpl> root = LayerImpl::create(123); |
3037 | 3037 |
3038 WebTransformationMatrix identityMatrix; | 3038 WebTransformationMatrix identityMatrix; |
3039 FloatPoint anchor(0, 0); | 3039 FloatPoint anchor(0, 0); |
3040 FloatPoint position(0, 0); | 3040 FloatPoint position(0, 0); |
3041 IntSize bounds(100, 100); | 3041 IntSize bounds(100, 100); |
3042 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 3042 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
3043 root->setMasksToBounds(true); | 3043 root->setMasksToBounds(true); |
3044 | 3044 |
3045 { | 3045 { |
3046 scoped_ptr<CCLayerImpl> child = CCLayerImpl::create(456); | 3046 scoped_ptr<LayerImpl> child = LayerImpl::create(456); |
3047 scoped_ptr<CCLayerImpl> grandChild = CCLayerImpl::create(789); | 3047 scoped_ptr<LayerImpl> grandChild = LayerImpl::create(789); |
3048 scoped_ptr<CCLayerImpl> rotatedLeaf = CCLayerImpl::create(2468); | 3048 scoped_ptr<LayerImpl> rotatedLeaf = LayerImpl::create(2468); |
3049 | 3049 |
3050 position = FloatPoint(10, 10); | 3050 position = FloatPoint(10, 10); |
3051 bounds = IntSize(80, 80); | 3051 bounds = IntSize(80, 80); |
3052 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); | 3052 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); |
3053 child->setMasksToBounds(true); | 3053 child->setMasksToBounds(true); |
3054 | 3054 |
3055 WebTransformationMatrix rotation45DegreesAboutCorner; | 3055 WebTransformationMatrix rotation45DegreesAboutCorner; |
3056 rotation45DegreesAboutCorner.rotate3d(0, 0, 45); | 3056 rotation45DegreesAboutCorner.rotate3d(0, 0, 45); |
3057 | 3057 |
3058 position = FloatPoint(0, 0); // remember, positioned with respect to its
parent which is already at 10, 10 | 3058 position = FloatPoint(0, 0); // remember, positioned with respect to its
parent which is already at 10, 10 |
(...skipping 11 matching lines...) Expand all Loading... |
3070 position = FloatPoint(0, 0); | 3070 position = FloatPoint(0, 0); |
3071 bounds = IntSize(100, 100); | 3071 bounds = IntSize(100, 100); |
3072 setLayerPropertiesForTesting(rotatedLeaf.get(), rotatedLeafTransform, id
entityMatrix, anchor, position, bounds, false); | 3072 setLayerPropertiesForTesting(rotatedLeaf.get(), rotatedLeafTransform, id
entityMatrix, anchor, position, bounds, false); |
3073 rotatedLeaf->setDrawsContent(true); | 3073 rotatedLeaf->setDrawsContent(true); |
3074 | 3074 |
3075 grandChild->addChild(rotatedLeaf.Pass()); | 3075 grandChild->addChild(rotatedLeaf.Pass()); |
3076 child->addChild(grandChild.Pass()); | 3076 child->addChild(grandChild.Pass()); |
3077 root->addChild(child.Pass()); | 3077 root->addChild(child.Pass()); |
3078 } | 3078 } |
3079 | 3079 |
3080 std::vector<CCLayerImpl*> renderSurfaceLayerList; | 3080 std::vector<LayerImpl*> renderSurfaceLayerList; |
3081 int dummyMaxTextureSize = 512; | 3081 int dummyMaxTextureSize = 512; |
3082 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 3082 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1,
0, dummyMaxTextureSize, renderSurfaceLayerList); |
3083 | 3083 |
3084 // Sanity check the scenario we just created. | 3084 // Sanity check the scenario we just created. |
3085 // The grandChild is expected to create a renderSurface because it masksToBo
unds and is not axis aligned. | 3085 // The grandChild is expected to create a renderSurface because it masksToBo
unds and is not axis aligned. |
3086 ASSERT_EQ(2u, renderSurfaceLayerList.size()); | 3086 ASSERT_EQ(2u, renderSurfaceLayerList.size()); |
3087 ASSERT_EQ(1u, renderSurfaceLayerList[0]->renderSurface()->layerList().size()
); | 3087 ASSERT_EQ(1u, renderSurfaceLayerList[0]->renderSurface()->layerList().size()
); |
3088 ASSERT_EQ(789, renderSurfaceLayerList[0]->renderSurface()->layerList()[0]->i
d()); // grandChild's surface. | 3088 ASSERT_EQ(789, renderSurfaceLayerList[0]->renderSurface()->layerList()[0]->i
d()); // grandChild's surface. |
3089 ASSERT_EQ(1u, renderSurfaceLayerList[1]->renderSurface()->layerList().size()
); | 3089 ASSERT_EQ(1u, renderSurfaceLayerList[1]->renderSurface()->layerList().size()
); |
3090 ASSERT_EQ(2468, renderSurfaceLayerList[1]->renderSurface()->layerList()[0]->
id()); | 3090 ASSERT_EQ(2468, renderSurfaceLayerList[1]->renderSurface()->layerList()[0]->
id()); |
3091 | 3091 |
3092 // (11, 89) is close to the the bottom left corner within the clip, but it i
s not inside the layer. | 3092 // (11, 89) is close to the the bottom left corner within the clip, but it i
s not inside the layer. |
3093 IntPoint testPoint(11, 89); | 3093 IntPoint testPoint(11, 89); |
3094 CCLayerImpl* resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(
testPoint, renderSurfaceLayerList); | 3094 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); |
3095 EXPECT_FALSE(resultLayer); | 3095 EXPECT_FALSE(resultLayer); |
3096 | 3096 |
3097 // Closer inwards from the bottom left will overlap the layer. | 3097 // Closer inwards from the bottom left will overlap the layer. |
3098 testPoint = IntPoint(25, 75); | 3098 testPoint = IntPoint(25, 75); |
3099 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 3099 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3100 ASSERT_TRUE(resultLayer); | 3100 ASSERT_TRUE(resultLayer); |
3101 EXPECT_EQ(2468, resultLayer->id()); | 3101 EXPECT_EQ(2468, resultLayer->id()); |
3102 | 3102 |
3103 // (4, 50) is inside the unclipped layer, but that corner of the layer shoul
d be | 3103 // (4, 50) is inside the unclipped layer, but that corner of the layer shoul
d be |
3104 // clipped away by the grandParent and should not get hit. If hit testing bl
indly uses | 3104 // clipped away by the grandParent and should not get hit. If hit testing bl
indly uses |
3105 // visibleContentRect without considering how parent may clip the layer, the
n hit | 3105 // visibleContentRect without considering how parent may clip the layer, the
n hit |
3106 // testing would accidentally think that the point successfully hits the lay
er. | 3106 // testing would accidentally think that the point successfully hits the lay
er. |
3107 testPoint = IntPoint(4, 50); | 3107 testPoint = IntPoint(4, 50); |
3108 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 3108 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3109 EXPECT_FALSE(resultLayer); | 3109 EXPECT_FALSE(resultLayer); |
3110 | 3110 |
3111 // (11, 50) is inside the layer and within the clipped area. | 3111 // (11, 50) is inside the layer and within the clipped area. |
3112 testPoint = IntPoint(11, 50); | 3112 testPoint = IntPoint(11, 50); |
3113 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 3113 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3114 ASSERT_TRUE(resultLayer); | 3114 ASSERT_TRUE(resultLayer); |
3115 EXPECT_EQ(2468, resultLayer->id()); | 3115 EXPECT_EQ(2468, resultLayer->id()); |
3116 | 3116 |
3117 // Around the middle, just to the right and up, would have hit the layer exc
ept that | 3117 // Around the middle, just to the right and up, would have hit the layer exc
ept that |
3118 // that area should be clipped away by the parent. | 3118 // that area should be clipped away by the parent. |
3119 testPoint = IntPoint(51, 51); | 3119 testPoint = IntPoint(51, 51); |
3120 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 3120 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3121 EXPECT_FALSE(resultLayer); | 3121 EXPECT_FALSE(resultLayer); |
3122 | 3122 |
3123 // Around the middle, just to the left and down, should successfully hit the
layer. | 3123 // Around the middle, just to the left and down, should successfully hit the
layer. |
3124 testPoint = IntPoint(49, 51); | 3124 testPoint = IntPoint(49, 51); |
3125 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 3125 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3126 ASSERT_TRUE(resultLayer); | 3126 ASSERT_TRUE(resultLayer); |
3127 EXPECT_EQ(2468, resultLayer->id()); | 3127 EXPECT_EQ(2468, resultLayer->id()); |
3128 } | 3128 } |
3129 | 3129 |
3130 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForNonClippingIntermediateLayer) | 3130 TEST(LayerTreeHostCommonTest, verifyHitTestingForNonClippingIntermediateLayer) |
3131 { | 3131 { |
3132 // This test checks that hit testing code does not accidentally clip to laye
r | 3132 // This test checks that hit testing code does not accidentally clip to laye
r |
3133 // bounds for a layer that actually does not clip. | 3133 // bounds for a layer that actually does not clip. |
3134 DebugScopedSetImplThread thisScopeIsOnImplThread; | 3134 DebugScopedSetImplThread thisScopeIsOnImplThread; |
3135 | 3135 |
3136 WebTransformationMatrix identityMatrix; | 3136 WebTransformationMatrix identityMatrix; |
3137 FloatPoint anchor(0, 0); | 3137 FloatPoint anchor(0, 0); |
3138 | 3138 |
3139 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); | 3139 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
3140 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, FloatPoint(0, 0), IntSize(100, 100), false); | 3140 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, FloatPoint(0, 0), IntSize(100, 100), false); |
3141 | 3141 |
3142 { | 3142 { |
3143 scoped_ptr<CCLayerImpl> intermediateLayer = CCLayerImpl::create(123); | 3143 scoped_ptr<LayerImpl> intermediateLayer = LayerImpl::create(123); |
3144 FloatPoint position(10, 10); // this layer is positioned, and hit testin
g should correctly know where the layer is located. | 3144 FloatPoint position(10, 10); // this layer is positioned, and hit testin
g should correctly know where the layer is located. |
3145 IntSize bounds(50, 50); | 3145 IntSize bounds(50, 50); |
3146 setLayerPropertiesForTesting(intermediateLayer.get(), identityMatrix, id
entityMatrix, anchor, position, bounds, false); | 3146 setLayerPropertiesForTesting(intermediateLayer.get(), identityMatrix, id
entityMatrix, anchor, position, bounds, false); |
3147 // Sanity check the intermediate layer should not clip. | 3147 // Sanity check the intermediate layer should not clip. |
3148 ASSERT_FALSE(intermediateLayer->masksToBounds()); | 3148 ASSERT_FALSE(intermediateLayer->masksToBounds()); |
3149 ASSERT_FALSE(intermediateLayer->maskLayer()); | 3149 ASSERT_FALSE(intermediateLayer->maskLayer()); |
3150 | 3150 |
3151 // The child of the intermediateLayer is translated so that it does not
overlap intermediateLayer at all. | 3151 // The child of the intermediateLayer is translated so that it does not
overlap intermediateLayer at all. |
3152 // If child is incorrectly clipped, we would not be able to hit it succe
ssfully. | 3152 // If child is incorrectly clipped, we would not be able to hit it succe
ssfully. |
3153 scoped_ptr<CCLayerImpl> child = CCLayerImpl::create(456); | 3153 scoped_ptr<LayerImpl> child = LayerImpl::create(456); |
3154 position = FloatPoint(60, 60); // 70, 70 in screen space | 3154 position = FloatPoint(60, 60); // 70, 70 in screen space |
3155 bounds = IntSize(20, 20); | 3155 bounds = IntSize(20, 20); |
3156 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); | 3156 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); |
3157 child->setDrawsContent(true); | 3157 child->setDrawsContent(true); |
3158 intermediateLayer->addChild(child.Pass()); | 3158 intermediateLayer->addChild(child.Pass()); |
3159 root->addChild(intermediateLayer.Pass()); | 3159 root->addChild(intermediateLayer.Pass()); |
3160 } | 3160 } |
3161 | 3161 |
3162 std::vector<CCLayerImpl*> renderSurfaceLayerList; | 3162 std::vector<LayerImpl*> renderSurfaceLayerList; |
3163 int dummyMaxTextureSize = 512; | 3163 int dummyMaxTextureSize = 512; |
3164 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 3164 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1,
0, dummyMaxTextureSize, renderSurfaceLayerList); |
3165 | 3165 |
3166 // Sanity check the scenario we just created. | 3166 // Sanity check the scenario we just created. |
3167 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 3167 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
3168 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); | 3168 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); |
3169 ASSERT_EQ(456, root->renderSurface()->layerList()[0]->id()); | 3169 ASSERT_EQ(456, root->renderSurface()->layerList()[0]->id()); |
3170 | 3170 |
3171 // Hit testing for a point outside the layer should return a null pointer. | 3171 // Hit testing for a point outside the layer should return a null pointer. |
3172 IntPoint testPoint(69, 69); | 3172 IntPoint testPoint(69, 69); |
3173 CCLayerImpl* resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(
testPoint, renderSurfaceLayerList); | 3173 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); |
3174 EXPECT_FALSE(resultLayer); | 3174 EXPECT_FALSE(resultLayer); |
3175 | 3175 |
3176 testPoint = IntPoint(91, 91); | 3176 testPoint = IntPoint(91, 91); |
3177 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 3177 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3178 EXPECT_FALSE(resultLayer); | 3178 EXPECT_FALSE(resultLayer); |
3179 | 3179 |
3180 // Hit testing for a point inside should return the child layer. | 3180 // Hit testing for a point inside should return the child layer. |
3181 testPoint = IntPoint(71, 71); | 3181 testPoint = IntPoint(71, 71); |
3182 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 3182 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3183 ASSERT_TRUE(resultLayer); | 3183 ASSERT_TRUE(resultLayer); |
3184 EXPECT_EQ(456, resultLayer->id()); | 3184 EXPECT_EQ(456, resultLayer->id()); |
3185 | 3185 |
3186 testPoint = IntPoint(89, 89); | 3186 testPoint = IntPoint(89, 89); |
3187 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 3187 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3188 ASSERT_TRUE(resultLayer); | 3188 ASSERT_TRUE(resultLayer); |
3189 EXPECT_EQ(456, resultLayer->id()); | 3189 EXPECT_EQ(456, resultLayer->id()); |
3190 } | 3190 } |
3191 | 3191 |
3192 | 3192 |
3193 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForMultipleLayers) | 3193 TEST(LayerTreeHostCommonTest, verifyHitTestingForMultipleLayers) |
3194 { | 3194 { |
3195 DebugScopedSetImplThread thisScopeIsOnImplThread; | 3195 DebugScopedSetImplThread thisScopeIsOnImplThread; |
3196 | 3196 |
3197 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); | 3197 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
3198 | 3198 |
3199 WebTransformationMatrix identityMatrix; | 3199 WebTransformationMatrix identityMatrix; |
3200 FloatPoint anchor(0, 0); | 3200 FloatPoint anchor(0, 0); |
3201 FloatPoint position(0, 0); | 3201 FloatPoint position(0, 0); |
3202 IntSize bounds(100, 100); | 3202 IntSize bounds(100, 100); |
3203 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 3203 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
3204 root->setDrawsContent(true); | 3204 root->setDrawsContent(true); |
3205 | 3205 |
3206 { | 3206 { |
3207 // child 1 and child2 are initialized to overlap between x=50 and x=60. | 3207 // child 1 and child2 are initialized to overlap between x=50 and x=60. |
3208 // grandChild is set to overlap both child1 and child2 between y=50 and
y=60. | 3208 // grandChild is set to overlap both child1 and child2 between y=50 and
y=60. |
3209 // The expected stacking order is: | 3209 // The expected stacking order is: |
3210 // (front) child2, (second) grandChild, (third) child1, and (back) the
root layer behind all other layers. | 3210 // (front) child2, (second) grandChild, (third) child1, and (back) the
root layer behind all other layers. |
3211 | 3211 |
3212 scoped_ptr<CCLayerImpl> child1 = CCLayerImpl::create(2); | 3212 scoped_ptr<LayerImpl> child1 = LayerImpl::create(2); |
3213 scoped_ptr<CCLayerImpl> child2 = CCLayerImpl::create(3); | 3213 scoped_ptr<LayerImpl> child2 = LayerImpl::create(3); |
3214 scoped_ptr<CCLayerImpl> grandChild1 = CCLayerImpl::create(4); | 3214 scoped_ptr<LayerImpl> grandChild1 = LayerImpl::create(4); |
3215 | 3215 |
3216 position = FloatPoint(10, 10); | 3216 position = FloatPoint(10, 10); |
3217 bounds = IntSize(50, 50); | 3217 bounds = IntSize(50, 50); |
3218 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatri
x, anchor, position, bounds, false); | 3218 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatri
x, anchor, position, bounds, false); |
3219 child1->setDrawsContent(true); | 3219 child1->setDrawsContent(true); |
3220 | 3220 |
3221 position = FloatPoint(50, 10); | 3221 position = FloatPoint(50, 10); |
3222 bounds = IntSize(50, 50); | 3222 bounds = IntSize(50, 50); |
3223 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatri
x, anchor, position, bounds, false); | 3223 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatri
x, anchor, position, bounds, false); |
3224 child2->setDrawsContent(true); | 3224 child2->setDrawsContent(true); |
3225 | 3225 |
3226 // Remember that grandChild is positioned with respect to its parent (i.
e. child1). | 3226 // Remember that grandChild is positioned with respect to its parent (i.
e. child1). |
3227 // In screen space, the intended position is (10, 50), with size 100 x 5
0. | 3227 // In screen space, the intended position is (10, 50), with size 100 x 5
0. |
3228 position = FloatPoint(0, 40); | 3228 position = FloatPoint(0, 40); |
3229 bounds = IntSize(100, 50); | 3229 bounds = IntSize(100, 50); |
3230 setLayerPropertiesForTesting(grandChild1.get(), identityMatrix, identity
Matrix, anchor, position, bounds, false); | 3230 setLayerPropertiesForTesting(grandChild1.get(), identityMatrix, identity
Matrix, anchor, position, bounds, false); |
3231 grandChild1->setDrawsContent(true); | 3231 grandChild1->setDrawsContent(true); |
3232 | 3232 |
3233 child1->addChild(grandChild1.Pass()); | 3233 child1->addChild(grandChild1.Pass()); |
3234 root->addChild(child1.Pass()); | 3234 root->addChild(child1.Pass()); |
3235 root->addChild(child2.Pass()); | 3235 root->addChild(child2.Pass()); |
3236 } | 3236 } |
3237 | 3237 |
3238 CCLayerImpl* child1 = root->children()[0]; | 3238 LayerImpl* child1 = root->children()[0]; |
3239 CCLayerImpl* child2 = root->children()[1]; | 3239 LayerImpl* child2 = root->children()[1]; |
3240 CCLayerImpl* grandChild1 = child1->children()[0]; | 3240 LayerImpl* grandChild1 = child1->children()[0]; |
3241 | 3241 |
3242 std::vector<CCLayerImpl*> renderSurfaceLayerList; | 3242 std::vector<LayerImpl*> renderSurfaceLayerList; |
3243 int dummyMaxTextureSize = 512; | 3243 int dummyMaxTextureSize = 512; |
3244 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 3244 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1,
0, dummyMaxTextureSize, renderSurfaceLayerList); |
3245 | 3245 |
3246 // Sanity check the scenario we just created. | 3246 // Sanity check the scenario we just created. |
3247 ASSERT_TRUE(child1); | 3247 ASSERT_TRUE(child1); |
3248 ASSERT_TRUE(child2); | 3248 ASSERT_TRUE(child2); |
3249 ASSERT_TRUE(grandChild1); | 3249 ASSERT_TRUE(grandChild1); |
3250 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 3250 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
3251 ASSERT_EQ(4u, root->renderSurface()->layerList().size()); | 3251 ASSERT_EQ(4u, root->renderSurface()->layerList().size()); |
3252 ASSERT_EQ(1, root->renderSurface()->layerList()[0]->id()); // root layer | 3252 ASSERT_EQ(1, root->renderSurface()->layerList()[0]->id()); // root layer |
3253 ASSERT_EQ(2, root->renderSurface()->layerList()[1]->id()); // child1 | 3253 ASSERT_EQ(2, root->renderSurface()->layerList()[1]->id()); // child1 |
3254 ASSERT_EQ(4, root->renderSurface()->layerList()[2]->id()); // grandChild1 | 3254 ASSERT_EQ(4, root->renderSurface()->layerList()[2]->id()); // grandChild1 |
3255 ASSERT_EQ(3, root->renderSurface()->layerList()[3]->id()); // child2 | 3255 ASSERT_EQ(3, root->renderSurface()->layerList()[3]->id()); // child2 |
3256 | 3256 |
3257 // Nothing overlaps the rootLayer at (1, 1), so hit testing there should fin
d the root layer. | 3257 // Nothing overlaps the rootLayer at (1, 1), so hit testing there should fin
d the root layer. |
3258 IntPoint testPoint = IntPoint(1, 1); | 3258 IntPoint testPoint = IntPoint(1, 1); |
3259 CCLayerImpl* resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(
testPoint, renderSurfaceLayerList); | 3259 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); |
3260 ASSERT_TRUE(resultLayer); | 3260 ASSERT_TRUE(resultLayer); |
3261 EXPECT_EQ(1, resultLayer->id()); | 3261 EXPECT_EQ(1, resultLayer->id()); |
3262 | 3262 |
3263 // At (15, 15), child1 and root are the only layers. child1 is expected to b
e on top. | 3263 // At (15, 15), child1 and root are the only layers. child1 is expected to b
e on top. |
3264 testPoint = IntPoint(15, 15); | 3264 testPoint = IntPoint(15, 15); |
3265 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 3265 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3266 ASSERT_TRUE(resultLayer); | 3266 ASSERT_TRUE(resultLayer); |
3267 EXPECT_EQ(2, resultLayer->id()); | 3267 EXPECT_EQ(2, resultLayer->id()); |
3268 | 3268 |
3269 // At (51, 20), child1 and child2 overlap. child2 is expected to be on top. | 3269 // At (51, 20), child1 and child2 overlap. child2 is expected to be on top. |
3270 testPoint = IntPoint(51, 20); | 3270 testPoint = IntPoint(51, 20); |
3271 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 3271 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3272 ASSERT_TRUE(resultLayer); | 3272 ASSERT_TRUE(resultLayer); |
3273 EXPECT_EQ(3, resultLayer->id()); | 3273 EXPECT_EQ(3, resultLayer->id()); |
3274 | 3274 |
3275 // At (80, 51), child2 and grandChild1 overlap. child2 is expected to be on
top. | 3275 // At (80, 51), child2 and grandChild1 overlap. child2 is expected to be on
top. |
3276 testPoint = IntPoint(80, 51); | 3276 testPoint = IntPoint(80, 51); |
3277 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 3277 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3278 ASSERT_TRUE(resultLayer); | 3278 ASSERT_TRUE(resultLayer); |
3279 EXPECT_EQ(3, resultLayer->id()); | 3279 EXPECT_EQ(3, resultLayer->id()); |
3280 | 3280 |
3281 // At (51, 51), all layers overlap each other. child2 is expected to be on t
op of all other layers. | 3281 // At (51, 51), all layers overlap each other. child2 is expected to be on t
op of all other layers. |
3282 testPoint = IntPoint(51, 51); | 3282 testPoint = IntPoint(51, 51); |
3283 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 3283 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3284 ASSERT_TRUE(resultLayer); | 3284 ASSERT_TRUE(resultLayer); |
3285 EXPECT_EQ(3, resultLayer->id()); | 3285 EXPECT_EQ(3, resultLayer->id()); |
3286 | 3286 |
3287 // At (20, 51), child1 and grandChild1 overlap. grandChild1 is expected to b
e on top. | 3287 // At (20, 51), child1 and grandChild1 overlap. grandChild1 is expected to b
e on top. |
3288 testPoint = IntPoint(20, 51); | 3288 testPoint = IntPoint(20, 51); |
3289 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 3289 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3290 ASSERT_TRUE(resultLayer); | 3290 ASSERT_TRUE(resultLayer); |
3291 EXPECT_EQ(4, resultLayer->id()); | 3291 EXPECT_EQ(4, resultLayer->id()); |
3292 } | 3292 } |
3293 | 3293 |
3294 TEST(CCLayerTreeHostCommonTest, verifyHitTestingForMultipleLayerLists) | 3294 TEST(LayerTreeHostCommonTest, verifyHitTestingForMultipleLayerLists) |
3295 { | 3295 { |
3296 // | 3296 // |
3297 // The geometry is set up similarly to the previous case, but | 3297 // The geometry is set up similarly to the previous case, but |
3298 // all layers are forced to be renderSurfaces now. | 3298 // all layers are forced to be renderSurfaces now. |
3299 // | 3299 // |
3300 DebugScopedSetImplThread thisScopeIsOnImplThread; | 3300 DebugScopedSetImplThread thisScopeIsOnImplThread; |
3301 | 3301 |
3302 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); | 3302 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
3303 | 3303 |
3304 WebTransformationMatrix identityMatrix; | 3304 WebTransformationMatrix identityMatrix; |
3305 FloatPoint anchor(0, 0); | 3305 FloatPoint anchor(0, 0); |
3306 FloatPoint position(0, 0); | 3306 FloatPoint position(0, 0); |
3307 IntSize bounds(100, 100); | 3307 IntSize bounds(100, 100); |
3308 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 3308 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
3309 root->setDrawsContent(true); | 3309 root->setDrawsContent(true); |
3310 | 3310 |
3311 { | 3311 { |
3312 // child 1 and child2 are initialized to overlap between x=50 and x=60. | 3312 // child 1 and child2 are initialized to overlap between x=50 and x=60. |
3313 // grandChild is set to overlap both child1 and child2 between y=50 and
y=60. | 3313 // grandChild is set to overlap both child1 and child2 between y=50 and
y=60. |
3314 // The expected stacking order is: | 3314 // The expected stacking order is: |
3315 // (front) child2, (second) grandChild, (third) child1, and (back) the
root layer behind all other layers. | 3315 // (front) child2, (second) grandChild, (third) child1, and (back) the
root layer behind all other layers. |
3316 | 3316 |
3317 scoped_ptr<CCLayerImpl> child1 = CCLayerImpl::create(2); | 3317 scoped_ptr<LayerImpl> child1 = LayerImpl::create(2); |
3318 scoped_ptr<CCLayerImpl> child2 = CCLayerImpl::create(3); | 3318 scoped_ptr<LayerImpl> child2 = LayerImpl::create(3); |
3319 scoped_ptr<CCLayerImpl> grandChild1 = CCLayerImpl::create(4); | 3319 scoped_ptr<LayerImpl> grandChild1 = LayerImpl::create(4); |
3320 | 3320 |
3321 position = FloatPoint(10, 10); | 3321 position = FloatPoint(10, 10); |
3322 bounds = IntSize(50, 50); | 3322 bounds = IntSize(50, 50); |
3323 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatri
x, anchor, position, bounds, false); | 3323 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatri
x, anchor, position, bounds, false); |
3324 child1->setDrawsContent(true); | 3324 child1->setDrawsContent(true); |
3325 child1->setForceRenderSurface(true); | 3325 child1->setForceRenderSurface(true); |
3326 | 3326 |
3327 position = FloatPoint(50, 10); | 3327 position = FloatPoint(50, 10); |
3328 bounds = IntSize(50, 50); | 3328 bounds = IntSize(50, 50); |
3329 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatri
x, anchor, position, bounds, false); | 3329 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatri
x, anchor, position, bounds, false); |
3330 child2->setDrawsContent(true); | 3330 child2->setDrawsContent(true); |
3331 child2->setForceRenderSurface(true); | 3331 child2->setForceRenderSurface(true); |
3332 | 3332 |
3333 // Remember that grandChild is positioned with respect to its parent (i.
e. child1). | 3333 // Remember that grandChild is positioned with respect to its parent (i.
e. child1). |
3334 // In screen space, the intended position is (10, 50), with size 100 x 5
0. | 3334 // In screen space, the intended position is (10, 50), with size 100 x 5
0. |
3335 position = FloatPoint(0, 40); | 3335 position = FloatPoint(0, 40); |
3336 bounds = IntSize(100, 50); | 3336 bounds = IntSize(100, 50); |
3337 setLayerPropertiesForTesting(grandChild1.get(), identityMatrix, identity
Matrix, anchor, position, bounds, false); | 3337 setLayerPropertiesForTesting(grandChild1.get(), identityMatrix, identity
Matrix, anchor, position, bounds, false); |
3338 grandChild1->setDrawsContent(true); | 3338 grandChild1->setDrawsContent(true); |
3339 grandChild1->setForceRenderSurface(true); | 3339 grandChild1->setForceRenderSurface(true); |
3340 | 3340 |
3341 child1->addChild(grandChild1.Pass()); | 3341 child1->addChild(grandChild1.Pass()); |
3342 root->addChild(child1.Pass()); | 3342 root->addChild(child1.Pass()); |
3343 root->addChild(child2.Pass()); | 3343 root->addChild(child2.Pass()); |
3344 } | 3344 } |
3345 | 3345 |
3346 CCLayerImpl* child1 = root->children()[0]; | 3346 LayerImpl* child1 = root->children()[0]; |
3347 CCLayerImpl* child2 = root->children()[1]; | 3347 LayerImpl* child2 = root->children()[1]; |
3348 CCLayerImpl* grandChild1 = child1->children()[0]; | 3348 LayerImpl* grandChild1 = child1->children()[0]; |
3349 | 3349 |
3350 std::vector<CCLayerImpl*> renderSurfaceLayerList; | 3350 std::vector<LayerImpl*> renderSurfaceLayerList; |
3351 int dummyMaxTextureSize = 512; | 3351 int dummyMaxTextureSize = 512; |
3352 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 3352 LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1,
0, dummyMaxTextureSize, renderSurfaceLayerList); |
3353 | 3353 |
3354 // Sanity check the scenario we just created. | 3354 // Sanity check the scenario we just created. |
3355 ASSERT_TRUE(child1); | 3355 ASSERT_TRUE(child1); |
3356 ASSERT_TRUE(child2); | 3356 ASSERT_TRUE(child2); |
3357 ASSERT_TRUE(grandChild1); | 3357 ASSERT_TRUE(grandChild1); |
3358 ASSERT_TRUE(child1->renderSurface()); | 3358 ASSERT_TRUE(child1->renderSurface()); |
3359 ASSERT_TRUE(child2->renderSurface()); | 3359 ASSERT_TRUE(child2->renderSurface()); |
3360 ASSERT_TRUE(grandChild1->renderSurface()); | 3360 ASSERT_TRUE(grandChild1->renderSurface()); |
3361 ASSERT_EQ(4u, renderSurfaceLayerList.size()); | 3361 ASSERT_EQ(4u, renderSurfaceLayerList.size()); |
3362 ASSERT_EQ(3u, root->renderSurface()->layerList().size()); // The root surfac
e has the root layer, and child1's and child2's renderSurfaces. | 3362 ASSERT_EQ(3u, root->renderSurface()->layerList().size()); // The root surfac
e has the root layer, and child1's and child2's renderSurfaces. |
3363 ASSERT_EQ(2u, child1->renderSurface()->layerList().size()); // The child1 su
rface has the child1 layer and grandChild1's renderSurface. | 3363 ASSERT_EQ(2u, child1->renderSurface()->layerList().size()); // The child1 su
rface has the child1 layer and grandChild1's renderSurface. |
3364 ASSERT_EQ(1u, child2->renderSurface()->layerList().size()); | 3364 ASSERT_EQ(1u, child2->renderSurface()->layerList().size()); |
3365 ASSERT_EQ(1u, grandChild1->renderSurface()->layerList().size()); | 3365 ASSERT_EQ(1u, grandChild1->renderSurface()->layerList().size()); |
3366 ASSERT_EQ(1, renderSurfaceLayerList[0]->id()); // root layer | 3366 ASSERT_EQ(1, renderSurfaceLayerList[0]->id()); // root layer |
3367 ASSERT_EQ(2, renderSurfaceLayerList[1]->id()); // child1 | 3367 ASSERT_EQ(2, renderSurfaceLayerList[1]->id()); // child1 |
3368 ASSERT_EQ(4, renderSurfaceLayerList[2]->id()); // grandChild1 | 3368 ASSERT_EQ(4, renderSurfaceLayerList[2]->id()); // grandChild1 |
3369 ASSERT_EQ(3, renderSurfaceLayerList[3]->id()); // child2 | 3369 ASSERT_EQ(3, renderSurfaceLayerList[3]->id()); // child2 |
3370 | 3370 |
3371 // Nothing overlaps the rootLayer at (1, 1), so hit testing there should fin
d the root layer. | 3371 // Nothing overlaps the rootLayer at (1, 1), so hit testing there should fin
d the root layer. |
3372 IntPoint testPoint = IntPoint(1, 1); | 3372 IntPoint testPoint = IntPoint(1, 1); |
3373 CCLayerImpl* resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(
testPoint, renderSurfaceLayerList); | 3373 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); |
3374 ASSERT_TRUE(resultLayer); | 3374 ASSERT_TRUE(resultLayer); |
3375 EXPECT_EQ(1, resultLayer->id()); | 3375 EXPECT_EQ(1, resultLayer->id()); |
3376 | 3376 |
3377 // At (15, 15), child1 and root are the only layers. child1 is expected to b
e on top. | 3377 // At (15, 15), child1 and root are the only layers. child1 is expected to b
e on top. |
3378 testPoint = IntPoint(15, 15); | 3378 testPoint = IntPoint(15, 15); |
3379 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 3379 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3380 ASSERT_TRUE(resultLayer); | 3380 ASSERT_TRUE(resultLayer); |
3381 EXPECT_EQ(2, resultLayer->id()); | 3381 EXPECT_EQ(2, resultLayer->id()); |
3382 | 3382 |
3383 // At (51, 20), child1 and child2 overlap. child2 is expected to be on top. | 3383 // At (51, 20), child1 and child2 overlap. child2 is expected to be on top. |
3384 testPoint = IntPoint(51, 20); | 3384 testPoint = IntPoint(51, 20); |
3385 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 3385 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3386 ASSERT_TRUE(resultLayer); | 3386 ASSERT_TRUE(resultLayer); |
3387 EXPECT_EQ(3, resultLayer->id()); | 3387 EXPECT_EQ(3, resultLayer->id()); |
3388 | 3388 |
3389 // At (80, 51), child2 and grandChild1 overlap. child2 is expected to be on
top. | 3389 // At (80, 51), child2 and grandChild1 overlap. child2 is expected to be on
top. |
3390 testPoint = IntPoint(80, 51); | 3390 testPoint = IntPoint(80, 51); |
3391 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 3391 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3392 ASSERT_TRUE(resultLayer); | 3392 ASSERT_TRUE(resultLayer); |
3393 EXPECT_EQ(3, resultLayer->id()); | 3393 EXPECT_EQ(3, resultLayer->id()); |
3394 | 3394 |
3395 // At (51, 51), all layers overlap each other. child2 is expected to be on t
op of all other layers. | 3395 // At (51, 51), all layers overlap each other. child2 is expected to be on t
op of all other layers. |
3396 testPoint = IntPoint(51, 51); | 3396 testPoint = IntPoint(51, 51); |
3397 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 3397 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3398 ASSERT_TRUE(resultLayer); | 3398 ASSERT_TRUE(resultLayer); |
3399 EXPECT_EQ(3, resultLayer->id()); | 3399 EXPECT_EQ(3, resultLayer->id()); |
3400 | 3400 |
3401 // At (20, 51), child1 and grandChild1 overlap. grandChild1 is expected to b
e on top. | 3401 // At (20, 51), child1 and grandChild1 overlap. grandChild1 is expected to b
e on top. |
3402 testPoint = IntPoint(20, 51); | 3402 testPoint = IntPoint(20, 51); |
3403 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 3403 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
3404 ASSERT_TRUE(resultLayer); | 3404 ASSERT_TRUE(resultLayer); |
3405 EXPECT_EQ(4, resultLayer->id()); | 3405 EXPECT_EQ(4, resultLayer->id()); |
3406 } | 3406 } |
3407 | 3407 |
3408 TEST(CCLayerTreeHostCommonTest, verifyLayerTransformsInHighDPI) | 3408 TEST(LayerTreeHostCommonTest, verifyLayerTransformsInHighDPI) |
3409 { | 3409 { |
3410 // Verify draw and screen space transforms of layers not in a surface. | 3410 // Verify draw and screen space transforms of layers not in a surface. |
3411 MockContentLayerChromiumClient delegate; | 3411 MockContentLayerClient delegate; |
3412 WebTransformationMatrix identityMatrix; | 3412 WebTransformationMatrix identityMatrix; |
3413 | 3413 |
3414 scoped_refptr<ContentLayerChromium> parent = createDrawableContentLayerChrom
ium(&delegate); | 3414 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); |
3415 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true); | 3415 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true); |
3416 | 3416 |
3417 scoped_refptr<ContentLayerChromium> child = createDrawableContentLayerChromi
um(&delegate); | 3417 scoped_refptr<ContentLayer> child = createDrawableContentLayer(&delegate); |
3418 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint(0, 0), FloatPoint(2, 2), IntSize(10, 10), true); | 3418 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint(0, 0), FloatPoint(2, 2), IntSize(10, 10), true); |
3419 | 3419 |
3420 scoped_refptr<ContentLayerChromium> childNoScale = createDrawableContentLaye
rChromium(&delegate); | 3420 scoped_refptr<ContentLayer> childNoScale = createDrawableContentLayer(&deleg
ate); |
3421 setLayerPropertiesForTesting(childNoScale.get(), identityMatrix, identityMat
rix, FloatPoint(0, 0), FloatPoint(2, 2), IntSize(10, 10), true); | 3421 setLayerPropertiesForTesting(childNoScale.get(), identityMatrix, identityMat
rix, FloatPoint(0, 0), FloatPoint(2, 2), IntSize(10, 10), true); |
3422 | 3422 |
3423 parent->addChild(child); | 3423 parent->addChild(child); |
3424 parent->addChild(childNoScale); | 3424 parent->addChild(childNoScale); |
3425 | 3425 |
3426 std::vector<scoped_refptr<LayerChromium> > renderSurfaceLayerList; | 3426 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
3427 int dummyMaxTextureSize = 512; | 3427 int dummyMaxTextureSize = 512; |
3428 | 3428 |
3429 const double deviceScaleFactor = 2.5; | 3429 const double deviceScaleFactor = 2.5; |
3430 parent->setContentsScale(deviceScaleFactor); | 3430 parent->setContentsScale(deviceScaleFactor); |
3431 child->setContentsScale(deviceScaleFactor); | 3431 child->setContentsScale(deviceScaleFactor); |
3432 EXPECT_EQ(childNoScale->contentsScale(), 1); | 3432 EXPECT_EQ(childNoScale->contentsScale(), 1); |
3433 | 3433 |
3434 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), deviceScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList); | 3434 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
deviceScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList); |
3435 | 3435 |
3436 EXPECT_EQ(1u, renderSurfaceLayerList.size()); | 3436 EXPECT_EQ(1u, renderSurfaceLayerList.size()); |
3437 | 3437 |
3438 // Verify parent transforms | 3438 // Verify parent transforms |
3439 WebTransformationMatrix expectedParentTransform; | 3439 WebTransformationMatrix expectedParentTransform; |
3440 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpace
Transform()); | 3440 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpace
Transform()); |
3441 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->drawTransfo
rm()); | 3441 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->drawTransfo
rm()); |
3442 | 3442 |
3443 // Verify results of transformed parent rects | 3443 // Verify results of transformed parent rects |
3444 FloatRect parentContentBounds(FloatPoint(), FloatSize(parent->contentBounds(
))); | 3444 FloatRect parentContentBounds(FloatPoint(), FloatSize(parent->contentBounds(
))); |
3445 | 3445 |
3446 FloatRect parentDrawRect = CCMathUtil::mapClippedRect(parent->drawTransform(
), parentContentBounds); | 3446 FloatRect parentDrawRect = MathUtil::mapClippedRect(parent->drawTransform(),
parentContentBounds); |
3447 FloatRect parentScreenSpaceRect = CCMathUtil::mapClippedRect(parent->screenS
paceTransform(), parentContentBounds); | 3447 FloatRect parentScreenSpaceRect = MathUtil::mapClippedRect(parent->screenSpa
ceTransform(), parentContentBounds); |
3448 | 3448 |
3449 FloatRect expectedParentDrawRect(FloatPoint(), parent->bounds()); | 3449 FloatRect expectedParentDrawRect(FloatPoint(), parent->bounds()); |
3450 expectedParentDrawRect.scale(deviceScaleFactor); | 3450 expectedParentDrawRect.scale(deviceScaleFactor); |
3451 EXPECT_FLOAT_RECT_EQ(expectedParentDrawRect, parentDrawRect); | 3451 EXPECT_FLOAT_RECT_EQ(expectedParentDrawRect, parentDrawRect); |
3452 EXPECT_FLOAT_RECT_EQ(expectedParentDrawRect, parentScreenSpaceRect); | 3452 EXPECT_FLOAT_RECT_EQ(expectedParentDrawRect, parentScreenSpaceRect); |
3453 | 3453 |
3454 // Verify child transforms | 3454 // Verify child transforms |
3455 WebTransformationMatrix expectedChildTransform; | 3455 WebTransformationMatrix expectedChildTransform; |
3456 expectedChildTransform.translate(deviceScaleFactor * child->position().x(),
deviceScaleFactor * child->position().y()); | 3456 expectedChildTransform.translate(deviceScaleFactor * child->position().x(),
deviceScaleFactor * child->position().y()); |
3457 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 3457 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); |
3458 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->screenSpaceTr
ansform()); | 3458 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->screenSpaceTr
ansform()); |
3459 | 3459 |
3460 // Verify results of transformed child rects | 3460 // Verify results of transformed child rects |
3461 FloatRect childContentBounds(FloatPoint(), FloatSize(child->contentBounds())
); | 3461 FloatRect childContentBounds(FloatPoint(), FloatSize(child->contentBounds())
); |
3462 | 3462 |
3463 FloatRect childDrawRect = CCMathUtil::mapClippedRect(child->drawTransform(),
childContentBounds); | 3463 FloatRect childDrawRect = MathUtil::mapClippedRect(child->drawTransform(), c
hildContentBounds); |
3464 FloatRect childScreenSpaceRect = CCMathUtil::mapClippedRect(child->screenSpa
ceTransform(), childContentBounds); | 3464 FloatRect childScreenSpaceRect = MathUtil::mapClippedRect(child->screenSpace
Transform(), childContentBounds); |
3465 | 3465 |
3466 FloatRect expectedChildDrawRect(FloatPoint(), child->bounds()); | 3466 FloatRect expectedChildDrawRect(FloatPoint(), child->bounds()); |
3467 expectedChildDrawRect.move(child->position().x(), child->position().y()); | 3467 expectedChildDrawRect.move(child->position().x(), child->position().y()); |
3468 expectedChildDrawRect.scale(deviceScaleFactor); | 3468 expectedChildDrawRect.scale(deviceScaleFactor); |
3469 EXPECT_FLOAT_RECT_EQ(expectedChildDrawRect, childDrawRect); | 3469 EXPECT_FLOAT_RECT_EQ(expectedChildDrawRect, childDrawRect); |
3470 EXPECT_FLOAT_RECT_EQ(expectedChildDrawRect, childScreenSpaceRect); | 3470 EXPECT_FLOAT_RECT_EQ(expectedChildDrawRect, childScreenSpaceRect); |
3471 | 3471 |
3472 // Verify childNoScale transforms | 3472 // Verify childNoScale transforms |
3473 WebTransformationMatrix expectedChildNoScaleTransform = child->drawTransform
(); | 3473 WebTransformationMatrix expectedChildNoScaleTransform = child->drawTransform
(); |
3474 // All transforms operate on content rects. The child's content rect | 3474 // All transforms operate on content rects. The child's content rect |
3475 // incorporates device scale, but the childNoScale does not; add it here. | 3475 // incorporates device scale, but the childNoScale does not; add it here. |
3476 expectedChildNoScaleTransform.scale(deviceScaleFactor); | 3476 expectedChildNoScaleTransform.scale(deviceScaleFactor); |
3477 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildNoScaleTransform, childNoScale-
>drawTransform()); | 3477 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildNoScaleTransform, childNoScale-
>drawTransform()); |
3478 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildNoScaleTransform, childNoScale-
>screenSpaceTransform()); | 3478 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildNoScaleTransform, childNoScale-
>screenSpaceTransform()); |
3479 } | 3479 } |
3480 | 3480 |
3481 TEST(CCLayerTreeHostCommonTest, verifyRenderSurfaceTransformsInHighDPI) | 3481 TEST(LayerTreeHostCommonTest, verifyRenderSurfaceTransformsInHighDPI) |
3482 { | 3482 { |
3483 MockContentLayerChromiumClient delegate; | 3483 MockContentLayerClient delegate; |
3484 WebTransformationMatrix identityMatrix; | 3484 WebTransformationMatrix identityMatrix; |
3485 | 3485 |
3486 scoped_refptr<ContentLayerChromium> parent = createDrawableContentLayerChrom
ium(&delegate); | 3486 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); |
3487 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(30, 30), true); | 3487 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(30, 30), true); |
3488 | 3488 |
3489 scoped_refptr<ContentLayerChromium> child = createDrawableContentLayerChromi
um(&delegate); | 3489 scoped_refptr<ContentLayer> child = createDrawableContentLayer(&delegate); |
3490 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint(0, 0), FloatPoint(2, 2), IntSize(10, 10), true); | 3490 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint(0, 0), FloatPoint(2, 2), IntSize(10, 10), true); |
3491 | 3491 |
3492 WebTransformationMatrix replicaTransform; | 3492 WebTransformationMatrix replicaTransform; |
3493 replicaTransform.scaleNonUniform(1, -1); | 3493 replicaTransform.scaleNonUniform(1, -1); |
3494 scoped_refptr<ContentLayerChromium> replica = createDrawableContentLayerChro
mium(&delegate); | 3494 scoped_refptr<ContentLayer> replica = createDrawableContentLayer(&delegate); |
3495 setLayerPropertiesForTesting(replica.get(), replicaTransform, identityMatrix
, FloatPoint(0, 0), FloatPoint(2, 2), IntSize(10, 10), true); | 3495 setLayerPropertiesForTesting(replica.get(), replicaTransform, identityMatrix
, FloatPoint(0, 0), FloatPoint(2, 2), IntSize(10, 10), true); |
3496 | 3496 |
3497 // This layer should end up in the same surface as child, with the same draw | 3497 // This layer should end up in the same surface as child, with the same draw |
3498 // and screen space transforms. | 3498 // and screen space transforms. |
3499 scoped_refptr<ContentLayerChromium> duplicateChildNonOwner = createDrawableC
ontentLayerChromium(&delegate); | 3499 scoped_refptr<ContentLayer> duplicateChildNonOwner = createDrawableContentLa
yer(&delegate); |
3500 setLayerPropertiesForTesting(duplicateChildNonOwner.get(), identityMatrix, i
dentityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(10, 10), true); | 3500 setLayerPropertiesForTesting(duplicateChildNonOwner.get(), identityMatrix, i
dentityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(10, 10), true); |
3501 | 3501 |
3502 parent->addChild(child); | 3502 parent->addChild(child); |
3503 child->addChild(duplicateChildNonOwner); | 3503 child->addChild(duplicateChildNonOwner); |
3504 child->setReplicaLayer(replica.get()); | 3504 child->setReplicaLayer(replica.get()); |
3505 | 3505 |
3506 std::vector<scoped_refptr<LayerChromium> > renderSurfaceLayerList; | 3506 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
3507 int dummyMaxTextureSize = 512; | 3507 int dummyMaxTextureSize = 512; |
3508 | 3508 |
3509 const double deviceScaleFactor = 1.5; | 3509 const double deviceScaleFactor = 1.5; |
3510 parent->setContentsScale(deviceScaleFactor); | 3510 parent->setContentsScale(deviceScaleFactor); |
3511 child->setContentsScale(deviceScaleFactor); | 3511 child->setContentsScale(deviceScaleFactor); |
3512 duplicateChildNonOwner->setContentsScale(deviceScaleFactor); | 3512 duplicateChildNonOwner->setContentsScale(deviceScaleFactor); |
3513 replica->setContentsScale(deviceScaleFactor); | 3513 replica->setContentsScale(deviceScaleFactor); |
3514 | 3514 |
3515 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), deviceScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList); | 3515 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
deviceScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList); |
3516 | 3516 |
3517 // We should have two render surfaces. The root's render surface and child's | 3517 // We should have two render surfaces. The root's render surface and child's |
3518 // render surface (it needs one because it has a replica layer). | 3518 // render surface (it needs one because it has a replica layer). |
3519 EXPECT_EQ(2u, renderSurfaceLayerList.size()); | 3519 EXPECT_EQ(2u, renderSurfaceLayerList.size()); |
3520 | 3520 |
3521 WebTransformationMatrix expectedParentTransform; | 3521 WebTransformationMatrix expectedParentTransform; |
3522 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpace
Transform()); | 3522 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpace
Transform()); |
3523 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->drawTransfo
rm()); | 3523 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->drawTransfo
rm()); |
3524 | 3524 |
3525 WebTransformationMatrix expectedDrawTransform; | 3525 WebTransformationMatrix expectedDrawTransform; |
(...skipping 27 matching lines...) Expand all Loading... |
3553 expectedReplicaDrawTransform.setM42(6); | 3553 expectedReplicaDrawTransform.setM42(6); |
3554 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedReplicaDrawTransform, child->renderS
urface()->replicaDrawTransform()); | 3554 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedReplicaDrawTransform, child->renderS
urface()->replicaDrawTransform()); |
3555 | 3555 |
3556 WebTransformationMatrix expectedReplicaScreenSpaceTransform; | 3556 WebTransformationMatrix expectedReplicaScreenSpaceTransform; |
3557 expectedReplicaScreenSpaceTransform.setM22(-1); | 3557 expectedReplicaScreenSpaceTransform.setM22(-1); |
3558 expectedReplicaScreenSpaceTransform.setM41(6); | 3558 expectedReplicaScreenSpaceTransform.setM41(6); |
3559 expectedReplicaScreenSpaceTransform.setM42(6); | 3559 expectedReplicaScreenSpaceTransform.setM42(6); |
3560 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedReplicaScreenSpaceTransform, child->
renderSurface()->replicaScreenSpaceTransform()); | 3560 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedReplicaScreenSpaceTransform, child->
renderSurface()->replicaScreenSpaceTransform()); |
3561 } | 3561 } |
3562 | 3562 |
3563 TEST(CCLayerTreeHostCommonTest, verifySubtreeSearch) | 3563 TEST(LayerTreeHostCommonTest, verifySubtreeSearch) |
3564 { | 3564 { |
3565 scoped_refptr<LayerChromium> root = LayerChromium::create(); | 3565 scoped_refptr<Layer> root = Layer::create(); |
3566 scoped_refptr<LayerChromium> child = LayerChromium::create(); | 3566 scoped_refptr<Layer> child = Layer::create(); |
3567 scoped_refptr<LayerChromium> grandChild = LayerChromium::create(); | 3567 scoped_refptr<Layer> grandChild = Layer::create(); |
3568 scoped_refptr<LayerChromium> maskLayer = LayerChromium::create(); | 3568 scoped_refptr<Layer> maskLayer = Layer::create(); |
3569 scoped_refptr<LayerChromium> replicaLayer = LayerChromium::create(); | 3569 scoped_refptr<Layer> replicaLayer = Layer::create(); |
3570 | 3570 |
3571 grandChild->setReplicaLayer(replicaLayer.get()); | 3571 grandChild->setReplicaLayer(replicaLayer.get()); |
3572 child->addChild(grandChild.get()); | 3572 child->addChild(grandChild.get()); |
3573 child->setMaskLayer(maskLayer.get()); | 3573 child->setMaskLayer(maskLayer.get()); |
3574 root->addChild(child.get()); | 3574 root->addChild(child.get()); |
3575 | 3575 |
3576 int nonexistentId = -1; | 3576 int nonexistentId = -1; |
3577 EXPECT_EQ(root, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), root->
id())); | 3577 EXPECT_EQ(root, LayerTreeHostCommon::findLayerInSubtree(root.get(), root->id
())); |
3578 EXPECT_EQ(child, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), child
->id())); | 3578 EXPECT_EQ(child, LayerTreeHostCommon::findLayerInSubtree(root.get(), child->
id())); |
3579 EXPECT_EQ(grandChild, CCLayerTreeHostCommon::findLayerInSubtree(root.get(),
grandChild->id())); | 3579 EXPECT_EQ(grandChild, LayerTreeHostCommon::findLayerInSubtree(root.get(), gr
andChild->id())); |
3580 EXPECT_EQ(maskLayer, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), m
askLayer->id())); | 3580 EXPECT_EQ(maskLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), mas
kLayer->id())); |
3581 EXPECT_EQ(replicaLayer, CCLayerTreeHostCommon::findLayerInSubtree(root.get()
, replicaLayer->id())); | 3581 EXPECT_EQ(replicaLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(),
replicaLayer->id())); |
3582 EXPECT_EQ(0, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), nonexiste
ntId)); | 3582 EXPECT_EQ(0, LayerTreeHostCommon::findLayerInSubtree(root.get(), nonexistent
Id)); |
3583 } | 3583 } |
3584 | 3584 |
3585 } // namespace | 3585 } // namespace |
OLD | NEW |