OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/layer_tree_host_common.h" | 5 #include "cc/layer_tree_host_common.h" |
6 | 6 |
7 #include "cc/content_layer.h" | 7 #include "cc/content_layer.h" |
8 #include "cc/content_layer_client.h" | 8 #include "cc/content_layer_client.h" |
9 #include "cc/layer.h" | 9 #include "cc/layer.h" |
10 #include "cc/layer_animation_controller.h" | 10 #include "cc/layer_animation_controller.h" |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 gfx::Transform layerTransform; | 202 gfx::Transform layerTransform; |
203 layerTransform.Scale3d(2, 2, 1); | 203 layerTransform.Scale3d(2, 2, 1); |
204 setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 12), false); | 204 setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 12), false); |
205 executeCalculateDrawProperties(root.get()); | 205 executeCalculateDrawProperties(root.get()); |
206 EXPECT_TRANSFORMATION_MATRIX_EQ(layerTransform, layer->drawTransform()); | 206 EXPECT_TRANSFORMATION_MATRIX_EQ(layerTransform, layer->drawTransform()); |
207 EXPECT_TRANSFORMATION_MATRIX_EQ(layerTransform, layer->screenSpaceTransform(
)); | 207 EXPECT_TRANSFORMATION_MATRIX_EQ(layerTransform, layer->screenSpaceTransform(
)); |
208 | 208 |
209 // Case 6: The layer transform should occur with respect to the anchor point
. | 209 // Case 6: The layer transform should occur with respect to the anchor point
. |
210 gfx::Transform translationToAnchor; | 210 gfx::Transform translationToAnchor; |
211 translationToAnchor.Translate(5, 0); | 211 translationToAnchor.Translate(5, 0); |
212 gfx::Transform expectedResult = translationToAnchor * layerTransform * MathU
til::inverse(translationToAnchor); | 212 gfx::Transform expectedResult = translationToAnchor * layerTransform * inver
se(translationToAnchor); |
213 setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, gf
x::PointF(0.5, 0), gfx::PointF(0, 0), gfx::Size(10, 12), false); | 213 setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, gf
x::PointF(0.5, 0), gfx::PointF(0, 0), gfx::Size(10, 12), false); |
214 executeCalculateDrawProperties(root.get()); | 214 executeCalculateDrawProperties(root.get()); |
215 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->drawTransform()); | 215 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->drawTransform()); |
216 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->screenSpaceTransform(
)); | 216 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->screenSpaceTransform(
)); |
217 | 217 |
218 // Case 7: Verify that position pre-multiplies the layer transform. | 218 // Case 7: Verify that position pre-multiplies the layer transform. |
219 // The current implementation of calculateDrawProperties does this i
mplicitly, but it is | 219 // The current implementation of calculateDrawProperties does this i
mplicitly, but it is |
220 // still worth testing to detect accidental regressions. | 220 // still worth testing to detect accidental regressions. |
221 expectedResult = positionTransform * translationToAnchor * layerTransform *
MathUtil::inverse(translationToAnchor); | 221 expectedResult = positionTransform * translationToAnchor * layerTransform *
inverse(translationToAnchor); |
222 setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, gf
x::PointF(0.5, 0), gfx::PointF(0, 1.2f), gfx::Size(10, 12), false); | 222 setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, gf
x::PointF(0.5, 0), gfx::PointF(0, 1.2f), gfx::Size(10, 12), false); |
223 executeCalculateDrawProperties(root.get()); | 223 executeCalculateDrawProperties(root.get()); |
224 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->drawTransform()); | 224 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->drawTransform()); |
225 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->screenSpaceTransform(
)); | 225 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->screenSpaceTransform(
)); |
226 } | 226 } |
227 | 227 |
228 TEST(LayerTreeHostCommonTest, verifyTransformsForSimpleHierarchy) | 228 TEST(LayerTreeHostCommonTest, verifyTransformsForSimpleHierarchy) |
229 { | 229 { |
230 gfx::Transform identityMatrix; | 230 gfx::Transform identityMatrix; |
231 scoped_refptr<Layer> root = Layer::create(); | 231 scoped_refptr<Layer> root = Layer::create(); |
(...skipping 27 matching lines...) Expand all Loading... |
259 EXPECT_TRANSFORMATION_MATRIX_EQ(parentPositionTransform, child->drawTransfor
m()); | 259 EXPECT_TRANSFORMATION_MATRIX_EQ(parentPositionTransform, child->drawTransfor
m()); |
260 EXPECT_TRANSFORMATION_MATRIX_EQ(parentPositionTransform, child->screenSpaceT
ransform()); | 260 EXPECT_TRANSFORMATION_MATRIX_EQ(parentPositionTransform, child->screenSpaceT
ransform()); |
261 EXPECT_TRANSFORMATION_MATRIX_EQ(parentPositionTransform, grandChild->drawTra
nsform()); | 261 EXPECT_TRANSFORMATION_MATRIX_EQ(parentPositionTransform, grandChild->drawTra
nsform()); |
262 EXPECT_TRANSFORMATION_MATRIX_EQ(parentPositionTransform, grandChild->screenS
paceTransform()); | 262 EXPECT_TRANSFORMATION_MATRIX_EQ(parentPositionTransform, grandChild->screenS
paceTransform()); |
263 | 263 |
264 // Case 3: parent's local transform affects child and grandchild | 264 // Case 3: parent's local transform affects child and grandchild |
265 gfx::Transform parentLayerTransform; | 265 gfx::Transform parentLayerTransform; |
266 parentLayerTransform.Scale3d(2, 2, 1); | 266 parentLayerTransform.Scale3d(2, 2, 1); |
267 gfx::Transform parentTranslationToAnchor; | 267 gfx::Transform parentTranslationToAnchor; |
268 parentTranslationToAnchor.Translate(2.5, 3); | 268 parentTranslationToAnchor.Translate(2.5, 3); |
269 gfx::Transform parentCompositeTransform = parentTranslationToAnchor * parent
LayerTransform * MathUtil::inverse(parentTranslationToAnchor); | 269 gfx::Transform parentCompositeTransform = parentTranslationToAnchor * parent
LayerTransform * inverse(parentTranslationToAnchor); |
270 setLayerPropertiesForTesting(parent.get(), parentLayerTransform, identityMat
rix, gfx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(10, 12), false); | 270 setLayerPropertiesForTesting(parent.get(), parentLayerTransform, identityMat
rix, gfx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(10, 12), false); |
271 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); | 271 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); |
272 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(76, 78), false); | 272 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(76, 78), false); |
273 executeCalculateDrawProperties(root.get()); | 273 executeCalculateDrawProperties(root.get()); |
274 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->drawTransfo
rm()); | 274 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->drawTransfo
rm()); |
275 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->screenSpace
Transform()); | 275 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->screenSpace
Transform()); |
276 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, grandChild->drawTr
ansform()); | 276 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, grandChild->drawTr
ansform()); |
277 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, grandChild->screen
SpaceTransform()); | 277 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, grandChild->screen
SpaceTransform()); |
278 | 278 |
279 // Case 4: parent's sublayerMatrix affects child and grandchild | 279 // Case 4: parent's sublayerMatrix affects child and grandchild |
280 // scaling is used here again so that the correct sequence of transf
orms is properly tested. | 280 // scaling is used here again so that the correct sequence of transf
orms is properly tested. |
281 // Note that preserves3D is false, but the sublayer matrix should re
tain its 3D properties when given to child. | 281 // Note that preserves3D is false, but the sublayer matrix should re
tain its 3D properties when given to child. |
282 // But then, the child also does not preserve3D. When it gives its h
ierarchy to the grandChild, it should be flattened to 2D. | 282 // But then, the child also does not preserve3D. When it gives its h
ierarchy to the grandChild, it should be flattened to 2D. |
283 gfx::Transform parentSublayerMatrix; | 283 gfx::Transform parentSublayerMatrix; |
284 parentSublayerMatrix.Scale3d(10, 10, 3.3); | 284 parentSublayerMatrix.Scale3d(10, 10, 3.3); |
285 gfx::Transform parentTranslationToCenter; | 285 gfx::Transform parentTranslationToCenter; |
286 parentTranslationToCenter.Translate(5, 6); | 286 parentTranslationToCenter.Translate(5, 6); |
287 // Sublayer matrix is applied to the center of the parent layer. | 287 // Sublayer matrix is applied to the center of the parent layer. |
288 parentCompositeTransform = parentTranslationToAnchor * parentLayerTransform
* MathUtil::inverse(parentTranslationToAnchor) | 288 parentCompositeTransform = parentTranslationToAnchor * parentLayerTransform
* inverse(parentTranslationToAnchor) |
289 * parentTranslationToCenter * parentSublayerMatrix * MathUtil::inver
se(parentTranslationToCenter); | 289 * parentTranslationToCenter * parentSublayerMatrix * inverse(parentT
ranslationToCenter); |
290 gfx::Transform flattenedCompositeTransform = MathUtil::to2dTransform(parentC
ompositeTransform); | 290 gfx::Transform flattenedCompositeTransform = MathUtil::to2dTransform(parentC
ompositeTransform); |
291 setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSubla
yerMatrix, gfx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(10, 12), false)
; | 291 setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSubla
yerMatrix, gfx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(10, 12), false)
; |
292 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); | 292 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); |
293 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(76, 78), false); | 293 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(76, 78), false); |
294 executeCalculateDrawProperties(root.get()); | 294 executeCalculateDrawProperties(root.get()); |
295 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->drawTransfo
rm()); | 295 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->drawTransfo
rm()); |
296 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->screenSpace
Transform()); | 296 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->screenSpace
Transform()); |
297 EXPECT_TRANSFORMATION_MATRIX_EQ(flattenedCompositeTransform, grandChild->dra
wTransform()); | 297 EXPECT_TRANSFORMATION_MATRIX_EQ(flattenedCompositeTransform, grandChild->dra
wTransform()); |
298 EXPECT_TRANSFORMATION_MATRIX_EQ(flattenedCompositeTransform, grandChild->scr
eenSpaceTransform()); | 298 EXPECT_TRANSFORMATION_MATRIX_EQ(flattenedCompositeTransform, grandChild->scr
eenSpaceTransform()); |
299 | 299 |
(...skipping 28 matching lines...) Expand all Loading... |
328 child->setForceRenderSurface(true); | 328 child->setForceRenderSurface(true); |
329 | 329 |
330 gfx::Transform parentLayerTransform; | 330 gfx::Transform parentLayerTransform; |
331 parentLayerTransform.Scale3d(1, 0.9, 1); | 331 parentLayerTransform.Scale3d(1, 0.9, 1); |
332 gfx::Transform parentTranslationToAnchor; | 332 gfx::Transform parentTranslationToAnchor; |
333 parentTranslationToAnchor.Translate(25, 30); | 333 parentTranslationToAnchor.Translate(25, 30); |
334 gfx::Transform parentSublayerMatrix; | 334 gfx::Transform parentSublayerMatrix; |
335 parentSublayerMatrix.Scale3d(0.9, 1, 3.3); | 335 parentSublayerMatrix.Scale3d(0.9, 1, 3.3); |
336 gfx::Transform parentTranslationToCenter; | 336 gfx::Transform parentTranslationToCenter; |
337 parentTranslationToCenter.Translate(50, 60); | 337 parentTranslationToCenter.Translate(50, 60); |
338 gfx::Transform parentCompositeTransform = parentTranslationToAnchor * parent
LayerTransform * MathUtil::inverse(parentTranslationToAnchor) | 338 gfx::Transform parentCompositeTransform = parentTranslationToAnchor * parent
LayerTransform * inverse(parentTranslationToAnchor) |
339 * parentTranslationToCenter * parentSublayerMatrix * MathUtil::inver
se(parentTranslationToCenter); | 339 * parentTranslationToCenter * parentSublayerMatrix * inverse(parentT
ranslationToCenter); |
340 gfx::Vector2dF parentCompositeScale = MathUtil::computeTransform2dScaleCompo
nents(parentCompositeTransform); | 340 gfx::Vector2dF parentCompositeScale = MathUtil::computeTransform2dScaleCompo
nents(parentCompositeTransform); |
341 gfx::Transform surfaceSublayerTransform; | 341 gfx::Transform surfaceSublayerTransform; |
342 surfaceSublayerTransform.Scale(parentCompositeScale.x(), parentCompositeScal
e.y()); | 342 surfaceSublayerTransform.Scale(parentCompositeScale.x(), parentCompositeScal
e.y()); |
343 gfx::Transform surfaceSublayerCompositeTransform = parentCompositeTransform
* MathUtil::inverse(surfaceSublayerTransform); | 343 gfx::Transform surfaceSublayerCompositeTransform = parentCompositeTransform
* inverse(surfaceSublayerTransform); |
344 | 344 |
345 // Child's render surface should not exist yet. | 345 // Child's render surface should not exist yet. |
346 ASSERT_FALSE(child->renderSurface()); | 346 ASSERT_FALSE(child->renderSurface()); |
347 | 347 |
348 setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSubla
yerMatrix, gfx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(100, 120), fals
e); | 348 setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSubla
yerMatrix, gfx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(100, 120), fals
e); |
349 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); | 349 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); |
350 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(8, 10), false); | 350 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(8, 10), false); |
351 executeCalculateDrawProperties(root.get()); | 351 executeCalculateDrawProperties(root.get()); |
352 | 352 |
353 // Render surface should have been created now. | 353 // Render surface should have been created now. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 child->setOpacity(0.5); | 387 child->setOpacity(0.5); |
388 | 388 |
389 gfx::Transform parentLayerTransform; | 389 gfx::Transform parentLayerTransform; |
390 parentLayerTransform.Scale3d(2, 2, 1); | 390 parentLayerTransform.Scale3d(2, 2, 1); |
391 gfx::Transform parentTranslationToAnchor; | 391 gfx::Transform parentTranslationToAnchor; |
392 parentTranslationToAnchor.Translate(2.5, 3); | 392 parentTranslationToAnchor.Translate(2.5, 3); |
393 gfx::Transform parentSublayerMatrix; | 393 gfx::Transform parentSublayerMatrix; |
394 parentSublayerMatrix.Scale3d(10, 10, 3.3); | 394 parentSublayerMatrix.Scale3d(10, 10, 3.3); |
395 gfx::Transform parentTranslationToCenter; | 395 gfx::Transform parentTranslationToCenter; |
396 parentTranslationToCenter.Translate(5, 6); | 396 parentTranslationToCenter.Translate(5, 6); |
397 gfx::Transform parentCompositeTransform = parentTranslationToAnchor * parent
LayerTransform * MathUtil::inverse(parentTranslationToAnchor) | 397 gfx::Transform parentCompositeTransform = parentTranslationToAnchor * parent
LayerTransform * inverse(parentTranslationToAnchor) |
398 * parentTranslationToCenter * parentSublayerMatrix * MathUtil::inver
se(parentTranslationToCenter); | 398 * parentTranslationToCenter * parentSublayerMatrix * inverse(parentT
ranslationToCenter); |
399 gfx::Transform childTranslationToCenter; | 399 gfx::Transform childTranslationToCenter; |
400 childTranslationToCenter.Translate(8, 9); | 400 childTranslationToCenter.Translate(8, 9); |
401 gfx::Transform replicaLayerTransform; | 401 gfx::Transform replicaLayerTransform; |
402 replicaLayerTransform.Scale3d(3, 3, 1); | 402 replicaLayerTransform.Scale3d(3, 3, 1); |
403 gfx::Vector2dF parentCompositeScale = MathUtil::computeTransform2dScaleCompo
nents(parentCompositeTransform); | 403 gfx::Vector2dF parentCompositeScale = MathUtil::computeTransform2dScaleCompo
nents(parentCompositeTransform); |
404 gfx::Transform surfaceSublayerTransform; | 404 gfx::Transform surfaceSublayerTransform; |
405 surfaceSublayerTransform.Scale(parentCompositeScale.x(), parentCompositeScal
e.y()); | 405 surfaceSublayerTransform.Scale(parentCompositeScale.x(), parentCompositeScal
e.y()); |
406 gfx::Transform replicaCompositeTransform = parentCompositeTransform * replic
aLayerTransform * MathUtil::inverse(surfaceSublayerTransform); | 406 gfx::Transform replicaCompositeTransform = parentCompositeTransform * replic
aLayerTransform * inverse(surfaceSublayerTransform); |
407 | 407 |
408 // Child's render surface should not exist yet. | 408 // Child's render surface should not exist yet. |
409 ASSERT_FALSE(child->renderSurface()); | 409 ASSERT_FALSE(child->renderSurface()); |
410 | 410 |
411 setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSubla
yerMatrix, gfx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(10, 12), false)
; | 411 setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSubla
yerMatrix, gfx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(10, 12), false)
; |
412 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); | 412 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); |
413 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(-0.5, -0.5), gfx::Size(1, 1), false); | 413 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(-0.5, -0.5), gfx::Size(1, 1), false); |
414 setLayerPropertiesForTesting(childReplica.get(), replicaLayerTransform, iden
tityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(0, 0), false); | 414 setLayerPropertiesForTesting(childReplica.get(), replicaLayerTransform, iden
tityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(0, 0), false); |
415 executeCalculateDrawProperties(root.get()); | 415 executeCalculateDrawProperties(root.get()); |
416 | 416 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 translationToAnchor.Translate(2.5, 0); | 474 translationToAnchor.Translate(2.5, 0); |
475 gfx::Transform translationToCenter; | 475 gfx::Transform translationToCenter; |
476 translationToCenter.Translate(5, 5); | 476 translationToCenter.Translate(5, 5); |
477 gfx::Transform layerTransform; | 477 gfx::Transform layerTransform; |
478 layerTransform.Translate(1, 1); | 478 layerTransform.Translate(1, 1); |
479 gfx::Transform sublayerTransform; | 479 gfx::Transform sublayerTransform; |
480 sublayerTransform.Scale3d(10, 1, 1); | 480 sublayerTransform.Scale3d(10, 1, 1); |
481 gfx::Transform replicaLayerTransform; | 481 gfx::Transform replicaLayerTransform; |
482 replicaLayerTransform.Scale3d(-2, 5, 1); | 482 replicaLayerTransform.Scale3d(-2, 5, 1); |
483 | 483 |
484 gfx::Transform A = translationToAnchor * layerTransform * MathUtil::inverse(
translationToAnchor); | 484 gfx::Transform A = translationToAnchor * layerTransform * inverse(translatio
nToAnchor); |
485 gfx::Transform B = translationToCenter * sublayerTransform * MathUtil::inver
se(translationToCenter); | 485 gfx::Transform B = translationToCenter * sublayerTransform * inverse(transla
tionToCenter); |
486 gfx::Transform R = A * translationToAnchor * replicaLayerTransform * MathUti
l::inverse(translationToAnchor); | 486 gfx::Transform R = A * translationToAnchor * replicaLayerTransform * inverse
(translationToAnchor); |
487 | 487 |
488 gfx::Vector2dF surface1ParentTransformScale = MathUtil::computeTransform2dSc
aleComponents(A * B); | 488 gfx::Vector2dF surface1ParentTransformScale = MathUtil::computeTransform2dSc
aleComponents(A * B); |
489 gfx::Transform surface1SublayerTransform; | 489 gfx::Transform surface1SublayerTransform; |
490 surface1SublayerTransform.Scale(surface1ParentTransformScale.x(), surface1Pa
rentTransformScale.y()); | 490 surface1SublayerTransform.Scale(surface1ParentTransformScale.x(), surface1Pa
rentTransformScale.y()); |
491 | 491 |
492 // SS1 = transform given to the subtree of renderSurface1 | 492 // SS1 = transform given to the subtree of renderSurface1 |
493 gfx::Transform SS1 = surface1SublayerTransform; | 493 gfx::Transform SS1 = surface1SublayerTransform; |
494 // S1 = transform to move from renderSurface1 pixels to the layer space of t
he owning layer | 494 // S1 = transform to move from renderSurface1 pixels to the layer space of t
he owning layer |
495 gfx::Transform S1 = MathUtil::inverse(surface1SublayerTransform); | 495 gfx::Transform S1 = inverse(surface1SublayerTransform); |
496 | 496 |
497 gfx::Vector2dF surface2ParentTransformScale = MathUtil::computeTransform2dSc
aleComponents(SS1 * A * B); | 497 gfx::Vector2dF surface2ParentTransformScale = MathUtil::computeTransform2dSc
aleComponents(SS1 * A * B); |
498 gfx::Transform surface2SublayerTransform; | 498 gfx::Transform surface2SublayerTransform; |
499 surface2SublayerTransform.Scale(surface2ParentTransformScale.x(), surface2Pa
rentTransformScale.y()); | 499 surface2SublayerTransform.Scale(surface2ParentTransformScale.x(), surface2Pa
rentTransformScale.y()); |
500 | 500 |
501 // SS2 = transform given to the subtree of renderSurface2 | 501 // SS2 = transform given to the subtree of renderSurface2 |
502 gfx::Transform SS2 = surface2SublayerTransform; | 502 gfx::Transform SS2 = surface2SublayerTransform; |
503 // S2 = transform to move from renderSurface2 pixels to the layer space of t
he owning layer | 503 // S2 = transform to move from renderSurface2 pixels to the layer space of t
he owning layer |
504 gfx::Transform S2 = MathUtil::inverse(surface2SublayerTransform); | 504 gfx::Transform S2 = inverse(surface2SublayerTransform); |
505 | 505 |
506 setLayerPropertiesForTesting(parent.get(), layerTransform, sublayerTransform
, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 506 setLayerPropertiesForTesting(parent.get(), layerTransform, sublayerTransform
, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
507 setLayerPropertiesForTesting(renderSurface1.get(), layerTransform, sublayerT
ransform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 507 setLayerPropertiesForTesting(renderSurface1.get(), layerTransform, sublayerT
ransform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
508 setLayerPropertiesForTesting(renderSurface2.get(), layerTransform, sublayerT
ransform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 508 setLayerPropertiesForTesting(renderSurface2.get(), layerTransform, sublayerT
ransform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
509 setLayerPropertiesForTesting(childOfRoot.get(), layerTransform, sublayerTran
sform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 509 setLayerPropertiesForTesting(childOfRoot.get(), layerTransform, sublayerTran
sform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
510 setLayerPropertiesForTesting(childOfRS1.get(), layerTransform, sublayerTrans
form, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 510 setLayerPropertiesForTesting(childOfRS1.get(), layerTransform, sublayerTrans
form, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
511 setLayerPropertiesForTesting(childOfRS2.get(), layerTransform, sublayerTrans
form, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 511 setLayerPropertiesForTesting(childOfRS2.get(), layerTransform, sublayerTrans
form, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
512 setLayerPropertiesForTesting(grandChildOfRoot.get(), layerTransform, sublaye
rTransform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 512 setLayerPropertiesForTesting(grandChildOfRoot.get(), layerTransform, sublaye
rTransform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
513 setLayerPropertiesForTesting(grandChildOfRS1.get(), layerTransform, sublayer
Transform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 513 setLayerPropertiesForTesting(grandChildOfRS1.get(), layerTransform, sublayer
Transform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
514 setLayerPropertiesForTesting(grandChildOfRS2.get(), layerTransform, sublayer
Transform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 514 setLayerPropertiesForTesting(grandChildOfRS2.get(), layerTransform, sublayer
Transform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1076 | 1076 |
1077 expectedSurfaceDrawTransform.MakeIdentity(); | 1077 expectedSurfaceDrawTransform.MakeIdentity(); |
1078 expectedSurfaceDrawTransform.Translate(-10, -30); // scrollDelta | 1078 expectedSurfaceDrawTransform.Translate(-10, -30); // scrollDelta |
1079 expectedSurfaceDrawTransform.Translate(8, 6); | 1079 expectedSurfaceDrawTransform.Translate(8, 6); |
1080 expectedSurfaceDrawTransform.PreconcatTransform(rotationAboutZ); | 1080 expectedSurfaceDrawTransform.PreconcatTransform(rotationAboutZ); |
1081 | 1081 |
1082 // The rotation and its inverse are needed to place the scrollDelta compensa
tion in | 1082 // The rotation and its inverse are needed to place the scrollDelta compensa
tion in |
1083 // the correct space. This test will fail if the rotation/inverse are backwa
rds, too, | 1083 // the correct space. This test will fail if the rotation/inverse are backwa
rds, too, |
1084 // so it requires perfect order of operations. | 1084 // so it requires perfect order of operations. |
1085 expectedGreatGrandChildTransform.MakeIdentity(); | 1085 expectedGreatGrandChildTransform.MakeIdentity(); |
1086 expectedGreatGrandChildTransform.PreconcatTransform(MathUtil::inverse(rotati
onAboutZ)); | 1086 expectedGreatGrandChildTransform.PreconcatTransform(inverse(rotationAboutZ))
; |
1087 expectedGreatGrandChildTransform.Translate(10, 30); // explicit canceling ou
t the scrollDelta that gets embedded in the fixed position layer's surface. | 1087 expectedGreatGrandChildTransform.Translate(10, 30); // explicit canceling ou
t the scrollDelta that gets embedded in the fixed position layer's surface. |
1088 expectedGreatGrandChildTransform.PreconcatTransform(rotationAboutZ); | 1088 expectedGreatGrandChildTransform.PreconcatTransform(rotationAboutZ); |
1089 | 1089 |
1090 ASSERT_TRUE(grandChild->renderSurface()); | 1090 ASSERT_TRUE(grandChild->renderSurface()); |
1091 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 1091 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); |
1092 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, grandChild->re
nderSurface()->drawTransform()); | 1092 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, grandChild->re
nderSurface()->drawTransform()); |
1093 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 1093 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); |
1094 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); | 1094 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); |
1095 } | 1095 } |
1096 | 1096 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1184 // But the great-great grandchild, "fixedPositionChild", should have a trans
form that explicitly cancels out the scrollDelta. | 1184 // But the great-great grandchild, "fixedPositionChild", should have a trans
form that explicitly cancels out the scrollDelta. |
1185 // The expected transform is: | 1185 // The expected transform is: |
1186 // compoundDrawTransform.inverse() * translate(positive scrollDelta) * com
poundOriginTransform | 1186 // compoundDrawTransform.inverse() * translate(positive scrollDelta) * com
poundOriginTransform |
1187 gfx::Transform compoundDrawTransform; // transform from greatGrandChildSurfa
ce's origin to the root surface. | 1187 gfx::Transform compoundDrawTransform; // transform from greatGrandChildSurfa
ce's origin to the root surface. |
1188 compoundDrawTransform.Translate(8, 6); // origin translation of grandChild | 1188 compoundDrawTransform.Translate(8, 6); // origin translation of grandChild |
1189 compoundDrawTransform.PreconcatTransform(rotationAboutZ); // rotation of gra
ndChild | 1189 compoundDrawTransform.PreconcatTransform(rotationAboutZ); // rotation of gra
ndChild |
1190 compoundDrawTransform.Translate(40, 60); // origin translation of greatGrand
Child | 1190 compoundDrawTransform.Translate(40, 60); // origin translation of greatGrand
Child |
1191 compoundDrawTransform.PreconcatTransform(rotationAboutZ); // rotation of gre
atGrandChild | 1191 compoundDrawTransform.PreconcatTransform(rotationAboutZ); // rotation of gre
atGrandChild |
1192 | 1192 |
1193 expectedFixedPositionChildTransform.MakeIdentity(); | 1193 expectedFixedPositionChildTransform.MakeIdentity(); |
1194 expectedFixedPositionChildTransform.PreconcatTransform(MathUtil::inverse(com
poundDrawTransform)); | 1194 expectedFixedPositionChildTransform.PreconcatTransform(inverse(compoundDrawT
ransform)); |
1195 expectedFixedPositionChildTransform.Translate(10, 30); // explicit canceling
out the scrollDelta that gets embedded in the fixed position layer's surface. | 1195 expectedFixedPositionChildTransform.Translate(10, 30); // explicit canceling
out the scrollDelta that gets embedded in the fixed position layer's surface. |
1196 expectedFixedPositionChildTransform.PreconcatTransform(compoundDrawTransform
); | 1196 expectedFixedPositionChildTransform.PreconcatTransform(compoundDrawTransform
); |
1197 | 1197 |
1198 ASSERT_TRUE(grandChild->renderSurface()); | 1198 ASSERT_TRUE(grandChild->renderSurface()); |
1199 ASSERT_TRUE(greatGrandChild->renderSurface()); | 1199 ASSERT_TRUE(greatGrandChild->renderSurface()); |
1200 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 1200 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); |
1201 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildSurfaceDrawTransform, gran
dChild->renderSurface()->drawTransform()); | 1201 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildSurfaceDrawTransform, gran
dChild->renderSurface()->drawTransform()); |
1202 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 1202 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); |
1203 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildSurfaceDrawTransform,
greatGrandChild->renderSurface()->drawTransform()); | 1203 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildSurfaceDrawTransform,
greatGrandChild->renderSurface()->drawTransform()); |
1204 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); | 1204 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1318 | 1318 |
1319 // Case 2: root scrollDelta of 10, 10 | 1319 // Case 2: root scrollDelta of 10, 10 |
1320 root->setScrollDelta(gfx::Vector2d(10, 20)); | 1320 root->setScrollDelta(gfx::Vector2d(10, 20)); |
1321 executeCalculateDrawProperties(root.get()); | 1321 executeCalculateDrawProperties(root.get()); |
1322 | 1322 |
1323 // The child is affected by scrollDelta, but it is already implcitly account
ed for by | 1323 // The child is affected by scrollDelta, but it is already implcitly account
ed for by |
1324 // the child's target surface (i.e. the root renderSurface). The grandChild
is not | 1324 // the child's target surface (i.e. the root renderSurface). The grandChild
is not |
1325 // affected by the scrollDelta, so its drawTransform needs to explicitly | 1325 // affected by the scrollDelta, so its drawTransform needs to explicitly |
1326 // inverse-compensate for the scroll that's embedded in the target surface. | 1326 // inverse-compensate for the scroll that's embedded in the target surface. |
1327 gfx::Transform expectedGrandChildTransform; | 1327 gfx::Transform expectedGrandChildTransform; |
1328 expectedGrandChildTransform.PreconcatTransform(MathUtil::inverse(rotationByZ
)); | 1328 expectedGrandChildTransform.PreconcatTransform(inverse(rotationByZ)); |
1329 expectedGrandChildTransform.Translate(10, 20); // explicit canceling out the
scrollDelta that gets embedded in the fixed position layer's surface. | 1329 expectedGrandChildTransform.Translate(10, 20); // explicit canceling out the
scrollDelta that gets embedded in the fixed position layer's surface. |
1330 expectedGrandChildTransform.PreconcatTransform(rotationByZ); | 1330 expectedGrandChildTransform.PreconcatTransform(rotationByZ); |
1331 | 1331 |
1332 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); | 1332 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); |
1333 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 1333 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); |
1334 } | 1334 } |
1335 | 1335 |
1336 TEST(LayerTreeHostCommonTest, verifyClipRectCullsRenderSurfaces) | 1336 TEST(LayerTreeHostCommonTest, verifyClipRectCullsRenderSurfaces) |
1337 { | 1337 { |
1338 // The entire subtree of layers that are outside the clipRect should be cull
ed away, | 1338 // The entire subtree of layers that are outside the clipRect should be cull
ed away, |
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2057 layerToSurfaceTransform.MakeIdentity(); | 2057 layerToSurfaceTransform.MakeIdentity(); |
2058 layerToSurfaceTransform.ApplyPerspectiveDepth(1); | 2058 layerToSurfaceTransform.ApplyPerspectiveDepth(1); |
2059 layerToSurfaceTransform.Translate3d(0, 0, -5); | 2059 layerToSurfaceTransform.Translate3d(0, 0, -5); |
2060 MathUtil::rotateEulerAngles(&layerToSurfaceTransform, 0, 45, 0); | 2060 MathUtil::rotateEulerAngles(&layerToSurfaceTransform, 0, 45, 0); |
2061 MathUtil::rotateEulerAngles(&layerToSurfaceTransform, 80, 0, 0); | 2061 MathUtil::rotateEulerAngles(&layerToSurfaceTransform, 80, 0, 0); |
2062 | 2062 |
2063 // Sanity check that un-projection does indeed cause w < 0, otherwise this c
ode is not | 2063 // Sanity check that un-projection does indeed cause w < 0, otherwise this c
ode is not |
2064 // testing the intended scenario. | 2064 // testing the intended scenario. |
2065 bool clipped = false; | 2065 bool clipped = false; |
2066 gfx::RectF clippedRect = MathUtil::mapClippedRect(layerToSurfaceTransform, l
ayerContentRect); | 2066 gfx::RectF clippedRect = MathUtil::mapClippedRect(layerToSurfaceTransform, l
ayerContentRect); |
2067 MathUtil::projectQuad(MathUtil::inverse(layerToSurfaceTransform), gfx::QuadF
(clippedRect), clipped); | 2067 MathUtil::projectQuad(inverse(layerToSurfaceTransform), gfx::QuadF(clippedRe
ct), clipped); |
2068 ASSERT_TRUE(clipped); | 2068 ASSERT_TRUE(clipped); |
2069 | 2069 |
2070 // Only the corner of the layer is not visible on the surface because of bei
ng | 2070 // Only the corner of the layer is not visible on the surface because of bei
ng |
2071 // clipped. But, the net result of rounding visible region to an axis-aligne
d rect is | 2071 // clipped. But, the net result of rounding visible region to an axis-aligne
d rect is |
2072 // that the entire layer should still be considered visible. | 2072 // that the entire layer should still be considered visible. |
2073 gfx::Rect expected = gfx::Rect(gfx::Point(-10, -10), gfx::Size(20, 20)); | 2073 gfx::Rect expected = gfx::Rect(gfx::Point(-10, -10), gfx::Size(20, 20)); |
2074 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); | 2074 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); |
2075 EXPECT_RECT_EQ(expected, actual); | 2075 EXPECT_RECT_EQ(expected, actual); |
2076 } | 2076 } |
2077 | 2077 |
(...skipping 2725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4803 EXPECT_EQ(m_canUseLCDText, m_grandChild->canUseLCDText()); | 4803 EXPECT_EQ(m_canUseLCDText, m_grandChild->canUseLCDText()); |
4804 } | 4804 } |
4805 | 4805 |
4806 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, | 4806 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, |
4807 LCDTextTest, | 4807 LCDTextTest, |
4808 testing::Combine(testing::Bool(), | 4808 testing::Combine(testing::Bool(), |
4809 testing::Bool())); | 4809 testing::Bool())); |
4810 | 4810 |
4811 } // namespace | 4811 } // namespace |
4812 } // namespace cc | 4812 } // namespace cc |
OLD | NEW |