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 "CCAnimationTestCommon.h" | 9 #include "CCAnimationTestCommon.h" |
10 #include "CCGeometryTestUtils.h" | 10 #include "CCGeometryTestUtils.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 { | 44 { |
45 setLayerPropertiesForTesting<LayerChromium>(layer, transform, sublayerTransf
orm, anchor, position, bounds, preserves3D); | 45 setLayerPropertiesForTesting<LayerChromium>(layer, transform, sublayerTransf
orm, anchor, position, bounds, preserves3D); |
46 } | 46 } |
47 | 47 |
48 void setLayerPropertiesForTesting(CCLayerImpl* layer, const WebTransformationMat
rix& transform, const WebTransformationMatrix& sublayerTransform, const FloatPoi
nt& anchor, const FloatPoint& position, const IntSize& bounds, bool preserves3D) | 48 void setLayerPropertiesForTesting(CCLayerImpl* layer, const WebTransformationMat
rix& transform, const WebTransformationMatrix& sublayerTransform, const FloatPoi
nt& anchor, const FloatPoint& position, const IntSize& bounds, bool preserves3D) |
49 { | 49 { |
50 setLayerPropertiesForTesting<CCLayerImpl>(layer, transform, sublayerTransfor
m, anchor, position, bounds, preserves3D); | 50 setLayerPropertiesForTesting<CCLayerImpl>(layer, transform, sublayerTransfor
m, anchor, position, bounds, preserves3D); |
51 layer->setContentBounds(bounds); | 51 layer->setContentBounds(bounds); |
52 } | 52 } |
53 | 53 |
54 void executeCalculateDrawTransformsAndVisibility(LayerChromium* rootLayer, float
deviceScaleFactor = 1) | 54 void executeCalculateDrawTransformsAndVisibility(LayerChromium* rootLayer, float
deviceScaleFactor = 1, float pageScaleFactor = 1) |
55 { | 55 { |
56 WebTransformationMatrix identityMatrix; | 56 WebTransformationMatrix identityMatrix; |
57 std::vector<scoped_refptr<LayerChromium> > dummyRenderSurfaceLayerList; | 57 std::vector<scoped_refptr<LayerChromium> > dummyRenderSurfaceLayerList; |
58 int dummyMaxTextureSize = 512; | 58 int dummyMaxTextureSize = 512; |
59 IntSize deviceViewportSize = IntSize(rootLayer->bounds().width() * deviceSca
leFactor, rootLayer->bounds().height() * deviceScaleFactor); | 59 IntSize deviceViewportSize = IntSize(rootLayer->bounds().width() * deviceSca
leFactor, rootLayer->bounds().height() * deviceScaleFactor); |
60 | 60 |
61 // We are probably not testing what is intended if the rootLayer bounds are
empty. | 61 // We are probably not testing what is intended if the rootLayer bounds are
empty. |
62 ASSERT(!rootLayer->bounds().isEmpty()); | 62 ASSERT(!rootLayer->bounds().isEmpty()); |
63 CCLayerTreeHostCommon::calculateDrawTransforms(rootLayer, deviceViewportSize
, deviceScaleFactor, dummyMaxTextureSize, dummyRenderSurfaceLayerList); | 63 CCLayerTreeHostCommon::calculateDrawTransforms(rootLayer, deviceViewportSize
, deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, dummyRenderSurfaceLay
erList); |
64 } | 64 } |
65 | 65 |
66 void executeCalculateDrawTransformsAndVisibility(CCLayerImpl* rootLayer, float d
eviceScaleFactor = 1) | 66 void executeCalculateDrawTransformsAndVisibility(CCLayerImpl* rootLayer, float d
eviceScaleFactor = 1, float pageScaleFactor = 1) |
67 { | 67 { |
68 // Note: this version skips layer sorting. | 68 // Note: this version skips layer sorting. |
69 | 69 |
70 WebTransformationMatrix identityMatrix; | 70 WebTransformationMatrix identityMatrix; |
71 std::vector<CCLayerImpl*> dummyRenderSurfaceLayerList; | 71 std::vector<CCLayerImpl*> dummyRenderSurfaceLayerList; |
72 int dummyMaxTextureSize = 512; | 72 int dummyMaxTextureSize = 512; |
73 IntSize deviceViewportSize = IntSize(rootLayer->bounds().width() * deviceSca
leFactor, rootLayer->bounds().height() * deviceScaleFactor); | 73 IntSize deviceViewportSize = IntSize(rootLayer->bounds().width() * deviceSca
leFactor, rootLayer->bounds().height() * deviceScaleFactor); |
74 | 74 |
75 // We are probably not testing what is intended if the rootLayer bounds are
empty. | 75 // We are probably not testing what is intended if the rootLayer bounds are
empty. |
76 ASSERT(!rootLayer->bounds().isEmpty()); | 76 ASSERT(!rootLayer->bounds().isEmpty()); |
77 CCLayerTreeHostCommon::calculateDrawTransforms(rootLayer, deviceViewportSize
, deviceScaleFactor, 0, dummyMaxTextureSize, dummyRenderSurfaceLayerList); | 77 CCLayerTreeHostCommon::calculateDrawTransforms(rootLayer, deviceViewportSize
, deviceScaleFactor, pageScaleFactor, 0, dummyMaxTextureSize, dummyRenderSurface
LayerList); |
78 } | 78 } |
79 | 79 |
80 WebTransformationMatrix remove3DComponentOfMatrix(const WebTransformationMatrix&
mat) | 80 WebTransformationMatrix remove3DComponentOfMatrix(const WebTransformationMatrix&
mat) |
81 { | 81 { |
82 WebTransformationMatrix ret = mat; | 82 WebTransformationMatrix ret = mat; |
83 ret.setM13(0); | 83 ret.setM13(0); |
84 ret.setM23(0); | 84 ret.setM23(0); |
85 ret.setM31(0); | 85 ret.setM31(0); |
86 ret.setM32(0); | 86 ret.setM32(0); |
87 ret.setM33(1); | 87 ret.setM33(1); |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 WebTransformationMatrix parentLayerTransform; | 326 WebTransformationMatrix parentLayerTransform; |
327 parentLayerTransform.scale3d(1, 0.9, 1); | 327 parentLayerTransform.scale3d(1, 0.9, 1); |
328 WebTransformationMatrix parentTranslationToAnchor; | 328 WebTransformationMatrix parentTranslationToAnchor; |
329 parentTranslationToAnchor.translate(25, 30); | 329 parentTranslationToAnchor.translate(25, 30); |
330 WebTransformationMatrix parentSublayerMatrix; | 330 WebTransformationMatrix parentSublayerMatrix; |
331 parentSublayerMatrix.scale3d(0.9, 1, 3.3); | 331 parentSublayerMatrix.scale3d(0.9, 1, 3.3); |
332 WebTransformationMatrix parentTranslationToCenter; | 332 WebTransformationMatrix parentTranslationToCenter; |
333 parentTranslationToCenter.translate(50, 60); | 333 parentTranslationToCenter.translate(50, 60); |
334 WebTransformationMatrix parentCompositeTransform = parentTranslationToAnchor
* parentLayerTransform * parentTranslationToAnchor.inverse() | 334 WebTransformationMatrix parentCompositeTransform = parentTranslationToAnchor
* parentLayerTransform * parentTranslationToAnchor.inverse() |
335 * parentTranslationToCenter * parentSublayerMatrix * parentTranslati
onToCenter.inverse(); | 335 * parentTranslationToCenter * parentSublayerMatrix * parentTranslati
onToCenter.inverse(); |
| 336 FloatPoint parentCompositeScale = CCMathUtil::computeTransform2dScaleCompone
nts(parentCompositeTransform); |
| 337 WebTransformationMatrix surfaceSublayerTransform; |
| 338 surfaceSublayerTransform.scaleNonUniform(parentCompositeScale.x(), parentCom
positeScale.y()); |
| 339 WebTransformationMatrix surfaceSublayerCompositeTransform = parentCompositeT
ransform * surfaceSublayerTransform.inverse(); |
336 | 340 |
337 // Child's render surface should not exist yet. | 341 // Child's render surface should not exist yet. |
338 ASSERT_FALSE(child->renderSurface()); | 342 ASSERT_FALSE(child->renderSurface()); |
339 | 343 |
340 setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSubla
yerMatrix, FloatPoint(0.25, 0.25), FloatPoint(0, 0), IntSize(100, 120), false); | 344 setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSubla
yerMatrix, FloatPoint(0.25, 0.25), FloatPoint(0, 0), IntSize(100, 120), false); |
341 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint(0, 0), FloatPoint(0, 0), IntSize(16, 18), false); | 345 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint(0, 0), FloatPoint(0, 0), IntSize(16, 18), false); |
342 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(8, 10), false); | 346 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(8, 10), false); |
343 executeCalculateDrawTransformsAndVisibility(parent.get()); | 347 executeCalculateDrawTransformsAndVisibility(parent.get()); |
344 | 348 |
345 // Render surface should have been created now. | 349 // Render surface should have been created now. |
346 ASSERT_TRUE(child->renderSurface()); | 350 ASSERT_TRUE(child->renderSurface()); |
347 ASSERT_EQ(child, child->renderTarget()); | 351 ASSERT_EQ(child, child->renderTarget()); |
348 | 352 |
349 // The child layer's draw transform should refer to its new render surface. | 353 // The child layer's draw transform should refer to its new render surface. |
350 // The screen-space transform, however, should still refer to the root. | 354 // The screen-space transform, however, should still refer to the root. |
351 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); | 355 EXPECT_TRANSFORMATION_MATRIX_EQ(surfaceSublayerTransform, child->drawTransfo
rm()); |
352 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->screenSpace
Transform()); | 356 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->screenSpace
Transform()); |
353 | 357 |
354 // Because the grandChild is the only drawable content, the child's renderSu
rface will tighten its bounds to the grandChild. | 358 // Because the grandChild is the only drawable content, the child's renderSu
rface will tighten its bounds to the grandChild. |
355 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->renderTarge
t()->renderSurface()->drawTransform()); | 359 // The scale at which the surface's subtree is drawn must be removed from th
e composite transform. |
| 360 EXPECT_TRANSFORMATION_MATRIX_EQ(surfaceSublayerCompositeTransform, child->re
nderTarget()->renderSurface()->drawTransform()); |
356 | 361 |
357 // The screen space is the same as the target since the child surface draws
into the root. | 362 // The screen space is the same as the target since the child surface draws
into the root. |
358 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->renderTarge
t()->renderSurface()->screenSpaceTransform()); | 363 EXPECT_TRANSFORMATION_MATRIX_EQ(surfaceSublayerCompositeTransform, child->re
nderTarget()->renderSurface()->screenSpaceTransform()); |
359 } | 364 } |
360 | 365 |
361 TEST(CCLayerTreeHostCommonTest, verifyTransformsForReplica) | 366 TEST(CCLayerTreeHostCommonTest, verifyTransformsForReplica) |
362 { | 367 { |
363 scoped_refptr<LayerChromium> parent = LayerChromium::create(); | 368 scoped_refptr<LayerChromium> parent = LayerChromium::create(); |
364 scoped_refptr<LayerChromium> child = LayerChromium::create(); | 369 scoped_refptr<LayerChromium> child = LayerChromium::create(); |
365 scoped_refptr<LayerChromium> childReplica = LayerChromium::create(); | 370 scoped_refptr<LayerChromium> childReplica = LayerChromium::create(); |
366 scoped_refptr<LayerChromiumWithForcedDrawsContent> grandChild = make_scoped_
refptr(new LayerChromiumWithForcedDrawsContent()); | 371 scoped_refptr<LayerChromiumWithForcedDrawsContent> grandChild = make_scoped_
refptr(new LayerChromiumWithForcedDrawsContent()); |
367 parent->addChild(child); | 372 parent->addChild(child); |
368 child->addChild(grandChild); | 373 child->addChild(grandChild); |
(...skipping 10 matching lines...) Expand all Loading... |
379 WebTransformationMatrix parentSublayerMatrix; | 384 WebTransformationMatrix parentSublayerMatrix; |
380 parentSublayerMatrix.scale3d(10, 10, 3.3); | 385 parentSublayerMatrix.scale3d(10, 10, 3.3); |
381 WebTransformationMatrix parentTranslationToCenter; | 386 WebTransformationMatrix parentTranslationToCenter; |
382 parentTranslationToCenter.translate(5, 6); | 387 parentTranslationToCenter.translate(5, 6); |
383 WebTransformationMatrix parentCompositeTransform = parentTranslationToAnchor
* parentLayerTransform * parentTranslationToAnchor.inverse() | 388 WebTransformationMatrix parentCompositeTransform = parentTranslationToAnchor
* parentLayerTransform * parentTranslationToAnchor.inverse() |
384 * parentTranslationToCenter * parentSublayerMatrix * parentTranslati
onToCenter.inverse(); | 389 * parentTranslationToCenter * parentSublayerMatrix * parentTranslati
onToCenter.inverse(); |
385 WebTransformationMatrix childTranslationToCenter; | 390 WebTransformationMatrix childTranslationToCenter; |
386 childTranslationToCenter.translate(8, 9); | 391 childTranslationToCenter.translate(8, 9); |
387 WebTransformationMatrix replicaLayerTransform; | 392 WebTransformationMatrix replicaLayerTransform; |
388 replicaLayerTransform.scale3d(3, 3, 1); | 393 replicaLayerTransform.scale3d(3, 3, 1); |
389 WebTransformationMatrix replicaCompositeTransform = parentCompositeTransform
* replicaLayerTransform; | 394 FloatPoint parentCompositeScale = CCMathUtil::computeTransform2dScaleCompone
nts(parentCompositeTransform); |
| 395 WebTransformationMatrix surfaceSublayerTransform; |
| 396 surfaceSublayerTransform.scaleNonUniform(parentCompositeScale.x(), parentCom
positeScale.y()); |
| 397 WebTransformationMatrix replicaCompositeTransform = parentCompositeTransform
* replicaLayerTransform * surfaceSublayerTransform.inverse(); |
390 | 398 |
391 // Child's render surface should not exist yet. | 399 // Child's render surface should not exist yet. |
392 ASSERT_FALSE(child->renderSurface()); | 400 ASSERT_FALSE(child->renderSurface()); |
393 | 401 |
394 setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSubla
yerMatrix, FloatPoint(0.25, 0.25), FloatPoint(0, 0), IntSize(10, 12), false); | 402 setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSubla
yerMatrix, FloatPoint(0.25, 0.25), FloatPoint(0, 0), IntSize(10, 12), false); |
395 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint(0, 0), FloatPoint(0, 0), IntSize(16, 18), false); | 403 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint(0, 0), FloatPoint(0, 0), IntSize(16, 18), false); |
396 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, FloatPoint(0, 0), FloatPoint(-0.5, -0.5), IntSize(1, 1), false); | 404 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, FloatPoint(0, 0), FloatPoint(-0.5, -0.5), IntSize(1, 1), false); |
397 setLayerPropertiesForTesting(childReplica.get(), replicaLayerTransform, iden
tityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(0, 0), false); | 405 setLayerPropertiesForTesting(childReplica.get(), replicaLayerTransform, iden
tityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(0, 0), false); |
398 executeCalculateDrawTransformsAndVisibility(parent.get()); | 406 executeCalculateDrawTransformsAndVisibility(parent.get()); |
399 | 407 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 WebTransformationMatrix sublayerTransform; | 464 WebTransformationMatrix sublayerTransform; |
457 sublayerTransform.scale3d(10, 1, 1); | 465 sublayerTransform.scale3d(10, 1, 1); |
458 WebTransformationMatrix replicaLayerTransform; | 466 WebTransformationMatrix replicaLayerTransform; |
459 replicaLayerTransform.scale3d(-2, 5, 1); | 467 replicaLayerTransform.scale3d(-2, 5, 1); |
460 | 468 |
461 WebTransformationMatrix A = translationToAnchor * layerTransform * translati
onToAnchor.inverse(); | 469 WebTransformationMatrix A = translationToAnchor * layerTransform * translati
onToAnchor.inverse(); |
462 WebTransformationMatrix B = translationToCenter * sublayerTransform * transl
ationToCenter.inverse(); | 470 WebTransformationMatrix B = translationToCenter * sublayerTransform * transl
ationToCenter.inverse(); |
463 WebTransformationMatrix R = A * translationToAnchor * replicaLayerTransform
* translationToAnchor.inverse(); | 471 WebTransformationMatrix R = A * translationToAnchor * replicaLayerTransform
* translationToAnchor.inverse(); |
464 WebTransformationMatrix identityMatrix; | 472 WebTransformationMatrix identityMatrix; |
465 | 473 |
| 474 FloatPoint surface1ParentTransformScale = CCMathUtil::computeTransform2dScal
eComponents(A * B); |
| 475 WebTransformationMatrix surface1SublayerTransform; |
| 476 surface1SublayerTransform.scaleNonUniform(surface1ParentTransformScale.x(),
surface1ParentTransformScale.y()); |
| 477 |
| 478 // SS1 = transform given to the subtree of renderSurface1 |
| 479 WebTransformationMatrix SS1 = surface1SublayerTransform; |
| 480 // S1 = transform to move from renderSurface1 pixels to the layer space of t
he owning layer |
| 481 WebTransformationMatrix S1 = surface1SublayerTransform.inverse(); |
| 482 |
| 483 FloatPoint surface2ParentTransformScale = CCMathUtil::computeTransform2dScal
eComponents(SS1 * A * B); |
| 484 WebTransformationMatrix surface2SublayerTransform; |
| 485 surface2SublayerTransform.scaleNonUniform(surface2ParentTransformScale.x(),
surface2ParentTransformScale.y()); |
| 486 |
| 487 // SS2 = transform given to the subtree of renderSurface2 |
| 488 WebTransformationMatrix SS2 = surface2SublayerTransform; |
| 489 // S2 = transform to move from renderSurface2 pixels to the layer space of t
he owning layer |
| 490 WebTransformationMatrix S2 = surface2SublayerTransform.inverse(); |
| 491 |
466 setLayerPropertiesForTesting(parent.get(), layerTransform, sublayerTransform
, FloatPoint(0.25, 0), FloatPoint(0, 0), IntSize(10, 10), false); | 492 setLayerPropertiesForTesting(parent.get(), layerTransform, sublayerTransform
, FloatPoint(0.25, 0), FloatPoint(0, 0), IntSize(10, 10), false); |
467 setLayerPropertiesForTesting(renderSurface1.get(), layerTransform, sublayerT
ransform, FloatPoint(0.25, 0), FloatPoint(0, 0), IntSize(10, 10), false); | 493 setLayerPropertiesForTesting(renderSurface1.get(), layerTransform, sublayerT
ransform, FloatPoint(0.25, 0), FloatPoint(0, 0), IntSize(10, 10), false); |
468 setLayerPropertiesForTesting(renderSurface2.get(), layerTransform, sublayerT
ransform, FloatPoint(0.25, 0), FloatPoint(0, 0), IntSize(10, 10), false); | 494 setLayerPropertiesForTesting(renderSurface2.get(), layerTransform, sublayerT
ransform, FloatPoint(0.25, 0), FloatPoint(0, 0), IntSize(10, 10), false); |
469 setLayerPropertiesForTesting(childOfRoot.get(), layerTransform, sublayerTran
sform, FloatPoint(0.25, 0), FloatPoint(0, 0), IntSize(10, 10), false); | 495 setLayerPropertiesForTesting(childOfRoot.get(), layerTransform, sublayerTran
sform, FloatPoint(0.25, 0), FloatPoint(0, 0), IntSize(10, 10), false); |
470 setLayerPropertiesForTesting(childOfRS1.get(), layerTransform, sublayerTrans
form, FloatPoint(0.25, 0), FloatPoint(0, 0), IntSize(10, 10), false); | 496 setLayerPropertiesForTesting(childOfRS1.get(), layerTransform, sublayerTrans
form, FloatPoint(0.25, 0), FloatPoint(0, 0), IntSize(10, 10), false); |
471 setLayerPropertiesForTesting(childOfRS2.get(), layerTransform, sublayerTrans
form, FloatPoint(0.25, 0), FloatPoint(0, 0), IntSize(10, 10), false); | 497 setLayerPropertiesForTesting(childOfRS2.get(), layerTransform, sublayerTrans
form, FloatPoint(0.25, 0), FloatPoint(0, 0), IntSize(10, 10), false); |
472 setLayerPropertiesForTesting(grandChildOfRoot.get(), layerTransform, sublaye
rTransform, FloatPoint(0.25, 0), FloatPoint(0, 0), IntSize(10, 10), false); | 498 setLayerPropertiesForTesting(grandChildOfRoot.get(), layerTransform, sublaye
rTransform, FloatPoint(0.25, 0), FloatPoint(0, 0), IntSize(10, 10), false); |
473 setLayerPropertiesForTesting(grandChildOfRS1.get(), layerTransform, sublayer
Transform, FloatPoint(0.25, 0), FloatPoint(0, 0), IntSize(10, 10), false); | 499 setLayerPropertiesForTesting(grandChildOfRS1.get(), layerTransform, sublayer
Transform, FloatPoint(0.25, 0), FloatPoint(0, 0), IntSize(10, 10), false); |
474 setLayerPropertiesForTesting(grandChildOfRS2.get(), layerTransform, sublayer
Transform, FloatPoint(0.25, 0), FloatPoint(0, 0), IntSize(10, 10), false); | 500 setLayerPropertiesForTesting(grandChildOfRS2.get(), layerTransform, sublayer
Transform, FloatPoint(0.25, 0), FloatPoint(0, 0), IntSize(10, 10), false); |
475 setLayerPropertiesForTesting(replicaOfRS1.get(), replicaLayerTransform, subl
ayerTransform, FloatPoint(0.25, 0), FloatPoint(0, 0), IntSize(), false); | 501 setLayerPropertiesForTesting(replicaOfRS1.get(), replicaLayerTransform, subl
ayerTransform, FloatPoint(0.25, 0), FloatPoint(0, 0), IntSize(), false); |
(...skipping 30 matching lines...) Expand all Loading... |
506 EXPECT_EQ(renderSurface2, grandChildOfRS2->renderTarget()); | 532 EXPECT_EQ(renderSurface2, grandChildOfRS2->renderTarget()); |
507 | 533 |
508 // Verify layer draw transforms | 534 // Verify layer draw transforms |
509 // note that draw transforms are described with respect to the nearest ance
stor render surface | 535 // note that draw transforms are described with respect to the nearest ance
stor render surface |
510 // but screen space transforms are described with respect to the root. | 536 // but screen space transforms are described with respect to the root. |
511 // | 537 // |
512 EXPECT_TRANSFORMATION_MATRIX_EQ(A, parent->drawTransform()); | 538 EXPECT_TRANSFORMATION_MATRIX_EQ(A, parent->drawTransform()); |
513 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A, childOfRoot->drawTransform()); | 539 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A, childOfRoot->drawTransform()); |
514 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * A, grandChildOfRoot->drawTra
nsform()); | 540 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * A, grandChildOfRoot->drawTra
nsform()); |
515 | 541 |
516 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, renderSurface1->drawTransfor
m()); | 542 EXPECT_TRANSFORMATION_MATRIX_EQ(SS1, renderSurface1->drawTransform()); |
517 EXPECT_TRANSFORMATION_MATRIX_EQ(B * A, childOfRS1->drawTransform()); | 543 EXPECT_TRANSFORMATION_MATRIX_EQ(SS1 * B * A, childOfRS1->drawTransform()); |
518 EXPECT_TRANSFORMATION_MATRIX_EQ(B * A * B * A, grandChildOfRS1->drawTransfor
m()); | 544 EXPECT_TRANSFORMATION_MATRIX_EQ(SS1 * B * A * B * A, grandChildOfRS1->drawTr
ansform()); |
519 | 545 |
520 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, renderSurface2->drawTransfor
m()); | 546 EXPECT_TRANSFORMATION_MATRIX_EQ(SS2, renderSurface2->drawTransform()); |
521 EXPECT_TRANSFORMATION_MATRIX_EQ(B * A, childOfRS2->drawTransform()); | 547 EXPECT_TRANSFORMATION_MATRIX_EQ(SS2 * B * A, childOfRS2->drawTransform()); |
522 EXPECT_TRANSFORMATION_MATRIX_EQ(B * A * B * A, grandChildOfRS2->drawTransfor
m()); | 548 EXPECT_TRANSFORMATION_MATRIX_EQ(SS2 * B * A * B * A, grandChildOfRS2->drawTr
ansform()); |
523 | 549 |
524 // Verify layer screen-space transforms | 550 // Verify layer screen-space transforms |
525 // | 551 // |
526 EXPECT_TRANSFORMATION_MATRIX_EQ(A, parent->screenSpaceTransform()); | 552 EXPECT_TRANSFORMATION_MATRIX_EQ(A, parent->screenSpaceTransform()); |
527 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A, childOfRoot->screenSpaceTransform
()); | 553 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A, childOfRoot->screenSpaceTransform
()); |
528 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * A, grandChildOfRoot->screenS
paceTransform()); | 554 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * A, grandChildOfRoot->screenS
paceTransform()); |
529 | 555 |
530 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A, renderSurface1->screenSpaceTransf
orm()); | 556 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A, renderSurface1->screenSpaceTransf
orm()); |
531 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * A, childOfRS1->screenSpaceTr
ansform()); | 557 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * A, childOfRS1->screenSpaceTr
ansform()); |
532 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * A * B * A, grandChildOfRS1->
screenSpaceTransform()); | 558 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * A * B * A, grandChildOfRS1->
screenSpaceTransform()); |
533 | 559 |
534 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * A, renderSurface2->screenSpa
ceTransform()); | 560 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * A, renderSurface2->screenSpa
ceTransform()); |
535 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * A * B * A, childOfRS2->scree
nSpaceTransform()); | 561 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * A * B * A, childOfRS2->scree
nSpaceTransform()); |
536 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * A * B * A * B * A, grandChil
dOfRS2->screenSpaceTransform()); | 562 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * A * B * A * B * A, grandChil
dOfRS2->screenSpaceTransform()); |
537 | 563 |
538 // Verify render surface transforms. | 564 // Verify render surface transforms. |
539 // | 565 // |
540 // Draw transform of render surface 1 is described with respect to root. | 566 // Draw transform of render surface 1 is described with respect to root. |
541 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A, renderSurface1->renderSurface()->
drawTransform()); | 567 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * S1, renderSurface1->renderSurfac
e()->drawTransform()); |
542 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * R, renderSurface1->renderSurface()->
replicaDrawTransform()); | 568 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * R * S1, renderSurface1->renderSurfac
e()->replicaDrawTransform()); |
543 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A, renderSurface1->renderSurface()->
screenSpaceTransform()); | 569 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * S1, renderSurface1->renderSurfac
e()->screenSpaceTransform()); |
544 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * R, renderSurface1->renderSurface()->
replicaScreenSpaceTransform()); | 570 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * R * S1, renderSurface1->renderSurfac
e()->replicaScreenSpaceTransform()); |
545 // Draw transform of render surface 2 is described with respect to render su
rface 2. | 571 // Draw transform of render surface 2 is described with respect to render su
rface 1. |
546 EXPECT_TRANSFORMATION_MATRIX_EQ(B * A, renderSurface2->renderSurface()->draw
Transform()); | 572 EXPECT_TRANSFORMATION_MATRIX_EQ(SS1 * B * A * S2, renderSurface2->renderSurf
ace()->drawTransform()); |
547 EXPECT_TRANSFORMATION_MATRIX_EQ(B * R, renderSurface2->renderSurface()->repl
icaDrawTransform()); | 573 EXPECT_TRANSFORMATION_MATRIX_EQ(SS1 * B * R * S2, renderSurface2->renderSurf
ace()->replicaDrawTransform()); |
548 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * A, renderSurface2->renderSur
face()->screenSpaceTransform()); | 574 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * A * S2, renderSurface2->rend
erSurface()->screenSpaceTransform()); |
549 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * R, renderSurface2->renderSur
face()->replicaScreenSpaceTransform()); | 575 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * R * S2, renderSurface2->rend
erSurface()->replicaScreenSpaceTransform()); |
550 | 576 |
551 // Sanity check. If these fail there is probably a bug in the test itself. | 577 // Sanity check. If these fail there is probably a bug in the test itself. |
552 // It is expected that we correctly set up transforms so that the y-componen
t of the screen-space transform | 578 // It is expected that we correctly set up transforms so that the y-componen
t of the screen-space transform |
553 // encodes the "depth" of the layer in the tree. | 579 // encodes the "depth" of the layer in the tree. |
554 EXPECT_FLOAT_EQ(1, parent->screenSpaceTransform().m42()); | 580 EXPECT_FLOAT_EQ(1, parent->screenSpaceTransform().m42()); |
555 EXPECT_FLOAT_EQ(2, childOfRoot->screenSpaceTransform().m42()); | 581 EXPECT_FLOAT_EQ(2, childOfRoot->screenSpaceTransform().m42()); |
556 EXPECT_FLOAT_EQ(3, grandChildOfRoot->screenSpaceTransform().m42()); | 582 EXPECT_FLOAT_EQ(3, grandChildOfRoot->screenSpaceTransform().m42()); |
557 | 583 |
558 EXPECT_FLOAT_EQ(2, renderSurface1->screenSpaceTransform().m42()); | 584 EXPECT_FLOAT_EQ(2, renderSurface1->screenSpaceTransform().m42()); |
559 EXPECT_FLOAT_EQ(3, childOfRS1->screenSpaceTransform().m42()); | 585 EXPECT_FLOAT_EQ(3, childOfRS1->screenSpaceTransform().m42()); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
650 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); |
651 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint::zero(), FloatPoint(30, 30), IntSize(10, 10), false); | 677 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint::zero(), FloatPoint(30, 30), IntSize(10, 10), false); |
652 | 678 |
653 parent->addChild(renderSurface1); | 679 parent->addChild(renderSurface1); |
654 parent->setMasksToBounds(true); | 680 parent->setMasksToBounds(true); |
655 renderSurface1->addChild(child); | 681 renderSurface1->addChild(child); |
656 renderSurface1->setForceRenderSurface(true); | 682 renderSurface1->setForceRenderSurface(true); |
657 | 683 |
658 std::vector<scoped_refptr<LayerChromium> > renderSurfaceLayerList; | 684 std::vector<scoped_refptr<LayerChromium> > renderSurfaceLayerList; |
659 int dummyMaxTextureSize = 512; | 685 int dummyMaxTextureSize = 512; |
660 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, dummyMaxTextureSize, renderSurfaceLayerList); | 686 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); |
661 | 687 |
662 // The child layer's content is entirely outside the parent's clip rect, so
the intermediate | 688 // The child layer's content is entirely outside the parent's clip rect, so
the intermediate |
663 // render surface should not be listed here, even if it was forced to be cre
ated. Render surfaces without children or visible | 689 // render surface should not be listed here, even if it was forced to be cre
ated. Render surfaces without children or visible |
664 // content are unexpected at draw time (e.g. we might try to create a conten
t texture of size 0). | 690 // content are unexpected at draw time (e.g. we might try to create a conten
t texture of size 0). |
665 ASSERT_TRUE(parent->renderSurface()); | 691 ASSERT_TRUE(parent->renderSurface()); |
666 ASSERT_FALSE(renderSurface1->renderSurface()); | 692 ASSERT_FALSE(renderSurface1->renderSurface()); |
667 EXPECT_EQ(1U, renderSurfaceLayerList.size()); | 693 EXPECT_EQ(1U, renderSurfaceLayerList.size()); |
668 } | 694 } |
669 | 695 |
670 TEST(CCLayerTreeHostCommonTest, verifyRenderSurfaceListForTransparentChild) | 696 TEST(CCLayerTreeHostCommonTest, verifyRenderSurfaceListForTransparentChild) |
671 { | 697 { |
672 scoped_refptr<LayerChromium> parent = LayerChromium::create(); | 698 scoped_refptr<LayerChromium> parent = LayerChromium::create(); |
673 scoped_refptr<LayerChromium> renderSurface1 = LayerChromium::create(); | 699 scoped_refptr<LayerChromium> renderSurface1 = LayerChromium::create(); |
674 scoped_refptr<LayerChromiumWithForcedDrawsContent> child = make_scoped_refpt
r(new LayerChromiumWithForcedDrawsContent()); | 700 scoped_refptr<LayerChromiumWithForcedDrawsContent> child = make_scoped_refpt
r(new LayerChromiumWithForcedDrawsContent()); |
675 | 701 |
676 const WebTransformationMatrix identityMatrix; | 702 const WebTransformationMatrix identityMatrix; |
677 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, FloatPoint::zero(), FloatPoint::zero(), IntSize(10, 10), false); | 703 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, FloatPoint::zero(), FloatPoint::zero(), IntSize(10, 10), false); |
678 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint::zero(), FloatPoint::zero(), IntSize(10, 10), false); | 704 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint::zero(), FloatPoint::zero(), IntSize(10, 10), false); |
679 | 705 |
680 parent->addChild(renderSurface1); | 706 parent->addChild(renderSurface1); |
681 renderSurface1->addChild(child); | 707 renderSurface1->addChild(child); |
682 renderSurface1->setForceRenderSurface(true); | 708 renderSurface1->setForceRenderSurface(true); |
683 renderSurface1->setOpacity(0); | 709 renderSurface1->setOpacity(0); |
684 | 710 |
685 std::vector<scoped_refptr<LayerChromium> > renderSurfaceLayerList; | 711 std::vector<scoped_refptr<LayerChromium> > renderSurfaceLayerList; |
686 int dummyMaxTextureSize = 512; | 712 int dummyMaxTextureSize = 512; |
687 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, dummyMaxTextureSize, renderSurfaceLayerList); | 713 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); |
688 | 714 |
689 // Since the layer is transparent, renderSurface1->renderSurface() should no
t have gotten added anywhere. | 715 // Since the layer is transparent, renderSurface1->renderSurface() should no
t have gotten added anywhere. |
690 // Also, the drawable content rect should not have been extended by the chil
dren. | 716 // Also, the drawable content rect should not have been extended by the chil
dren. |
691 ASSERT_TRUE(parent->renderSurface()); | 717 ASSERT_TRUE(parent->renderSurface()); |
692 EXPECT_EQ(0U, parent->renderSurface()->layerList().size()); | 718 EXPECT_EQ(0U, parent->renderSurface()->layerList().size()); |
693 EXPECT_EQ(1U, renderSurfaceLayerList.size()); | 719 EXPECT_EQ(1U, renderSurfaceLayerList.size()); |
694 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); | 720 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); |
695 EXPECT_EQ(IntRect(), parent->drawableContentRect()); | 721 EXPECT_EQ(IntRect(), parent->drawableContentRect()); |
696 } | 722 } |
697 | 723 |
(...skipping 11 matching lines...) Expand all Loading... |
709 | 735 |
710 parent->addChild(renderSurface1); | 736 parent->addChild(renderSurface1); |
711 renderSurface1->addChild(child); | 737 renderSurface1->addChild(child); |
712 | 738 |
713 // Sanity check before the actual test | 739 // Sanity check before the actual test |
714 EXPECT_FALSE(parent->renderSurface()); | 740 EXPECT_FALSE(parent->renderSurface()); |
715 EXPECT_FALSE(renderSurface1->renderSurface()); | 741 EXPECT_FALSE(renderSurface1->renderSurface()); |
716 | 742 |
717 std::vector<scoped_refptr<LayerChromium> > renderSurfaceLayerList; | 743 std::vector<scoped_refptr<LayerChromium> > renderSurfaceLayerList; |
718 int dummyMaxTextureSize = 512; | 744 int dummyMaxTextureSize = 512; |
719 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, dummyMaxTextureSize, renderSurfaceLayerList); | 745 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); |
720 | 746 |
721 // The root layer always creates a renderSurface | 747 // The root layer always creates a renderSurface |
722 EXPECT_TRUE(parent->renderSurface()); | 748 EXPECT_TRUE(parent->renderSurface()); |
723 EXPECT_TRUE(renderSurface1->renderSurface()); | 749 EXPECT_TRUE(renderSurface1->renderSurface()); |
724 EXPECT_EQ(2U, renderSurfaceLayerList.size()); | 750 EXPECT_EQ(2U, renderSurfaceLayerList.size()); |
725 | 751 |
726 renderSurfaceLayerList.clear(); | 752 renderSurfaceLayerList.clear(); |
727 renderSurface1->setForceRenderSurface(false); | 753 renderSurface1->setForceRenderSurface(false); |
728 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, dummyMaxTextureSize, renderSurfaceLayerList); | 754 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); |
729 EXPECT_TRUE(parent->renderSurface()); | 755 EXPECT_TRUE(parent->renderSurface()); |
730 EXPECT_FALSE(renderSurface1->renderSurface()); | 756 EXPECT_FALSE(renderSurface1->renderSurface()); |
731 EXPECT_EQ(1U, renderSurfaceLayerList.size()); | 757 EXPECT_EQ(1U, renderSurfaceLayerList.size()); |
732 } | 758 } |
733 | 759 |
734 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
hDirectContainer) | 760 TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
hDirectContainer) |
735 { | 761 { |
736 // This test checks for correct scroll compensation when the fixed-position
container | 762 // This test checks for correct scroll compensation when the fixed-position
container |
737 // is the direct parent of the fixed-position layer. | 763 // is the direct parent of the fixed-position layer. |
738 | 764 |
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1332 setLayerPropertiesForTesting(leafNode1.get(), identityMatrix, identityMatrix
, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(500, 500), false); | 1358 setLayerPropertiesForTesting(leafNode1.get(), identityMatrix, identityMatrix
, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(500, 500), false); |
1333 setLayerPropertiesForTesting(leafNode2.get(), identityMatrix, identityMatrix
, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(20, 20), false); | 1359 setLayerPropertiesForTesting(leafNode2.get(), identityMatrix, identityMatrix
, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(20, 20), false); |
1334 | 1360 |
1335 child->setMasksToBounds(true); | 1361 child->setMasksToBounds(true); |
1336 child->setOpacity(0.4f); | 1362 child->setOpacity(0.4f); |
1337 grandChild->setOpacity(0.5); | 1363 grandChild->setOpacity(0.5); |
1338 greatGrandChild->setOpacity(0.4f); | 1364 greatGrandChild->setOpacity(0.4f); |
1339 | 1365 |
1340 std::vector<scoped_refptr<LayerChromium> > renderSurfaceLayerList; | 1366 std::vector<scoped_refptr<LayerChromium> > renderSurfaceLayerList; |
1341 int dummyMaxTextureSize = 512; | 1367 int dummyMaxTextureSize = 512; |
1342 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, dummyMaxTextureSize, renderSurfaceLayerList); | 1368 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); |
1343 | 1369 |
1344 ASSERT_EQ(2U, renderSurfaceLayerList.size()); | 1370 ASSERT_EQ(2U, renderSurfaceLayerList.size()); |
1345 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); | 1371 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); |
1346 EXPECT_EQ(child->id(), renderSurfaceLayerList[1]->id()); | 1372 EXPECT_EQ(child->id(), renderSurfaceLayerList[1]->id()); |
1347 } | 1373 } |
1348 | 1374 |
1349 TEST(CCLayerTreeHostCommonTest, verifyClipRectCullsSurfaceWithoutVisibleContent) | 1375 TEST(CCLayerTreeHostCommonTest, verifyClipRectCullsSurfaceWithoutVisibleContent) |
1350 { | 1376 { |
1351 // When a renderSurface has a clipRect, it is used to clip the contentRect | 1377 // When a renderSurface has a clipRect, it is used to clip the contentRect |
1352 // of the surface. When the renderSurface is animating its transforms, then | 1378 // of the surface. When the renderSurface is animating its transforms, then |
(...skipping 24 matching lines...) Expand all Loading... |
1377 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint(0, 0), FloatPoint(0, 0), IntSize(20, 20), false); | 1403 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint(0, 0), FloatPoint(0, 0), IntSize(20, 20), false); |
1378 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, FloatPoint(0, 0), FloatPoint(200, 200), IntSize(10, 10), false); | 1404 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, FloatPoint(0, 0), FloatPoint(200, 200), IntSize(10, 10), false); |
1379 setLayerPropertiesForTesting(leafNode.get(), identityMatrix, identityMatrix,
FloatPoint(0, 0), FloatPoint(0, 0), IntSize(10, 10), false); | 1405 setLayerPropertiesForTesting(leafNode.get(), identityMatrix, identityMatrix,
FloatPoint(0, 0), FloatPoint(0, 0), IntSize(10, 10), false); |
1380 | 1406 |
1381 parent->setMasksToBounds(true); | 1407 parent->setMasksToBounds(true); |
1382 child->setOpacity(0.4f); | 1408 child->setOpacity(0.4f); |
1383 grandChild->setOpacity(0.4f); | 1409 grandChild->setOpacity(0.4f); |
1384 | 1410 |
1385 std::vector<scoped_refptr<LayerChromium> > renderSurfaceLayerList; | 1411 std::vector<scoped_refptr<LayerChromium> > renderSurfaceLayerList; |
1386 int dummyMaxTextureSize = 512; | 1412 int dummyMaxTextureSize = 512; |
1387 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, dummyMaxTextureSize, renderSurfaceLayerList); | 1413 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); |
1388 | 1414 |
1389 // Without an animation, we should cull child and grandChild from the render
SurfaceLayerList. | 1415 // Without an animation, we should cull child and grandChild from the render
SurfaceLayerList. |
1390 ASSERT_EQ(1U, renderSurfaceLayerList.size()); | 1416 ASSERT_EQ(1U, renderSurfaceLayerList.size()); |
1391 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); | 1417 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); |
1392 | 1418 |
1393 // Now put an animating transform on child. | 1419 // Now put an animating transform on child. |
1394 addAnimatedTransformToController(*child->layerAnimationController(), 10, 30,
0); | 1420 addAnimatedTransformToController(*child->layerAnimationController(), 10, 30,
0); |
1395 | 1421 |
1396 parent->clearRenderSurface(); | 1422 parent->clearRenderSurface(); |
1397 child->clearRenderSurface(); | 1423 child->clearRenderSurface(); |
1398 grandChild->clearRenderSurface(); | 1424 grandChild->clearRenderSurface(); |
1399 renderSurfaceLayerList.clear(); | 1425 renderSurfaceLayerList.clear(); |
1400 | 1426 |
1401 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, dummyMaxTextureSize, renderSurfaceLayerList); | 1427 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); |
1402 | 1428 |
1403 // With an animating transform, we should keep child and grandChild in the r
enderSurfaceLayerList. | 1429 // With an animating transform, we should keep child and grandChild in the r
enderSurfaceLayerList. |
1404 ASSERT_EQ(3U, renderSurfaceLayerList.size()); | 1430 ASSERT_EQ(3U, renderSurfaceLayerList.size()); |
1405 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); | 1431 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); |
1406 EXPECT_EQ(child->id(), renderSurfaceLayerList[1]->id()); | 1432 EXPECT_EQ(child->id(), renderSurfaceLayerList[1]->id()); |
1407 EXPECT_EQ(grandChild->id(), renderSurfaceLayerList[2]->id()); | 1433 EXPECT_EQ(grandChild->id(), renderSurfaceLayerList[2]->id()); |
1408 } | 1434 } |
1409 | 1435 |
1410 TEST(CCLayerTreeHostCommonTest, verifyDrawableContentRectForLayers) | 1436 TEST(CCLayerTreeHostCommonTest, verifyDrawableContentRectForLayers) |
1411 { | 1437 { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1443 | 1469 |
1444 // Force everyone to be a render surface. | 1470 // Force everyone to be a render surface. |
1445 child->setOpacity(0.4f); | 1471 child->setOpacity(0.4f); |
1446 grandChild1->setOpacity(0.5); | 1472 grandChild1->setOpacity(0.5); |
1447 grandChild2->setOpacity(0.5); | 1473 grandChild2->setOpacity(0.5); |
1448 grandChild3->setOpacity(0.5); | 1474 grandChild3->setOpacity(0.5); |
1449 grandChild4->setOpacity(0.5); | 1475 grandChild4->setOpacity(0.5); |
1450 | 1476 |
1451 std::vector<scoped_refptr<LayerChromium> > renderSurfaceLayerList; | 1477 std::vector<scoped_refptr<LayerChromium> > renderSurfaceLayerList; |
1452 int dummyMaxTextureSize = 512; | 1478 int dummyMaxTextureSize = 512; |
1453 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, dummyMaxTextureSize, renderSurfaceLayerList); | 1479 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); |
1454 | 1480 |
1455 EXPECT_RECT_EQ(IntRect(IntPoint(5, 5), IntSize(10, 10)), grandChild1->drawab
leContentRect()); | 1481 EXPECT_RECT_EQ(IntRect(IntPoint(5, 5), IntSize(10, 10)), grandChild1->drawab
leContentRect()); |
1456 EXPECT_RECT_EQ(IntRect(IntPoint(15, 15), IntSize(5, 5)), grandChild3->drawab
leContentRect()); | 1482 EXPECT_RECT_EQ(IntRect(IntPoint(15, 15), IntSize(5, 5)), grandChild3->drawab
leContentRect()); |
1457 EXPECT_RECT_EQ(IntRect(IntPoint(15, 15), IntSize(5, 5)), grandChild3->drawab
leContentRect()); | 1483 EXPECT_RECT_EQ(IntRect(IntPoint(15, 15), IntSize(5, 5)), grandChild3->drawab
leContentRect()); |
1458 EXPECT_TRUE(grandChild4->drawableContentRect().isEmpty()); | 1484 EXPECT_TRUE(grandChild4->drawableContentRect().isEmpty()); |
1459 } | 1485 } |
1460 | 1486 |
1461 TEST(CCLayerTreeHostCommonTest, verifyClipRectIsPropagatedCorrectlyToSurfaces) | 1487 TEST(CCLayerTreeHostCommonTest, verifyClipRectIsPropagatedCorrectlyToSurfaces) |
1462 { | 1488 { |
1463 // Verify that renderSurfaces (and their layers) get the appropriate clipRec
ts when their parent masksToBounds is true. | 1489 // Verify that renderSurfaces (and their layers) get the appropriate clipRec
ts when their parent masksToBounds is true. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1508 | 1534 |
1509 // Force everyone to be a render surface. | 1535 // Force everyone to be a render surface. |
1510 child->setOpacity(0.4f); | 1536 child->setOpacity(0.4f); |
1511 grandChild1->setOpacity(0.5); | 1537 grandChild1->setOpacity(0.5); |
1512 grandChild2->setOpacity(0.5); | 1538 grandChild2->setOpacity(0.5); |
1513 grandChild3->setOpacity(0.5); | 1539 grandChild3->setOpacity(0.5); |
1514 grandChild4->setOpacity(0.5); | 1540 grandChild4->setOpacity(0.5); |
1515 | 1541 |
1516 std::vector<scoped_refptr<LayerChromium> > renderSurfaceLayerList; | 1542 std::vector<scoped_refptr<LayerChromium> > renderSurfaceLayerList; |
1517 int dummyMaxTextureSize = 512; | 1543 int dummyMaxTextureSize = 512; |
1518 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, dummyMaxTextureSize, renderSurfaceLayerList); | 1544 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); |
1519 | 1545 |
1520 ASSERT_TRUE(grandChild1->renderSurface()); | 1546 ASSERT_TRUE(grandChild1->renderSurface()); |
1521 ASSERT_TRUE(grandChild2->renderSurface()); | 1547 ASSERT_TRUE(grandChild2->renderSurface()); |
1522 ASSERT_TRUE(grandChild3->renderSurface()); | 1548 ASSERT_TRUE(grandChild3->renderSurface()); |
1523 EXPECT_FALSE(grandChild4->renderSurface()); // Because grandChild4 is entire
ly clipped, it is expected to not have a renderSurface. | 1549 EXPECT_FALSE(grandChild4->renderSurface()); // Because grandChild4 is entire
ly clipped, it is expected to not have a renderSurface. |
1524 | 1550 |
1525 // Surfaces are clipped by their parent, but un-affected by the owning layer
's masksToBounds. | 1551 // Surfaces are clipped by their parent, but un-affected by the owning layer
's masksToBounds. |
1526 EXPECT_RECT_EQ(IntRect(IntPoint(0, 0), IntSize(20, 20)), grandChild1->render
Surface()->clipRect()); | 1552 EXPECT_RECT_EQ(IntRect(IntPoint(0, 0), IntSize(20, 20)), grandChild1->render
Surface()->clipRect()); |
1527 EXPECT_RECT_EQ(IntRect(IntPoint(0, 0), IntSize(20, 20)), grandChild2->render
Surface()->clipRect()); | 1553 EXPECT_RECT_EQ(IntRect(IntPoint(0, 0), IntSize(20, 20)), grandChild2->render
Surface()->clipRect()); |
1528 EXPECT_RECT_EQ(IntRect(IntPoint(0, 0), IntSize(20, 20)), grandChild3->render
Surface()->clipRect()); | 1554 EXPECT_RECT_EQ(IntRect(IntPoint(0, 0), IntSize(20, 20)), grandChild3->render
Surface()->clipRect()); |
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2350 setLayerPropertiesForTesting(backFacingChild.get(), backfaceMatrix, identity
Matrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 2376 setLayerPropertiesForTesting(backFacingChild.get(), backfaceMatrix, identity
Matrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
2351 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident
ityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 2377 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident
ityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
2352 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, identi
tyMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 2378 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, identi
tyMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
2353 setLayerPropertiesForTesting(frontFacingChildOfFrontFacingSurface.get(), ide
ntityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 10
0), false); | 2379 setLayerPropertiesForTesting(frontFacingChildOfFrontFacingSurface.get(), ide
ntityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 10
0), false); |
2354 setLayerPropertiesForTesting(backFacingChildOfFrontFacingSurface.get(), back
faceMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100
), false); | 2380 setLayerPropertiesForTesting(backFacingChildOfFrontFacingSurface.get(), back
faceMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100
), false); |
2355 setLayerPropertiesForTesting(frontFacingChildOfBackFacingSurface.get(), iden
tityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100
), false); | 2381 setLayerPropertiesForTesting(frontFacingChildOfBackFacingSurface.get(), iden
tityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100
), false); |
2356 setLayerPropertiesForTesting(backFacingChildOfBackFacingSurface.get(), backf
aceMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100)
, false); | 2382 setLayerPropertiesForTesting(backFacingChildOfBackFacingSurface.get(), backf
aceMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100)
, false); |
2357 | 2383 |
2358 std::vector<scoped_refptr<LayerChromium> > renderSurfaceLayerList; | 2384 std::vector<scoped_refptr<LayerChromium> > renderSurfaceLayerList; |
2359 int dummyMaxTextureSize = 512; | 2385 int dummyMaxTextureSize = 512; |
2360 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, dummyMaxTextureSize, renderSurfaceLayerList); | 2386 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); |
2361 | 2387 |
2362 // Verify which renderSurfaces were created. | 2388 // Verify which renderSurfaces were created. |
2363 EXPECT_FALSE(frontFacingChild->renderSurface()); | 2389 EXPECT_FALSE(frontFacingChild->renderSurface()); |
2364 EXPECT_FALSE(backFacingChild->renderSurface()); | 2390 EXPECT_FALSE(backFacingChild->renderSurface()); |
2365 EXPECT_TRUE(frontFacingSurface->renderSurface()); | 2391 EXPECT_TRUE(frontFacingSurface->renderSurface()); |
2366 EXPECT_TRUE(backFacingSurface->renderSurface()); | 2392 EXPECT_TRUE(backFacingSurface->renderSurface()); |
2367 EXPECT_FALSE(frontFacingChildOfFrontFacingSurface->renderSurface()); | 2393 EXPECT_FALSE(frontFacingChildOfFrontFacingSurface->renderSurface()); |
2368 EXPECT_FALSE(backFacingChildOfFrontFacingSurface->renderSurface()); | 2394 EXPECT_FALSE(backFacingChildOfFrontFacingSurface->renderSurface()); |
2369 EXPECT_FALSE(frontFacingChildOfBackFacingSurface->renderSurface()); | 2395 EXPECT_FALSE(frontFacingChildOfBackFacingSurface->renderSurface()); |
2370 EXPECT_FALSE(backFacingChildOfBackFacingSurface->renderSurface()); | 2396 EXPECT_FALSE(backFacingChildOfBackFacingSurface->renderSurface()); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2449 setLayerPropertiesForTesting(backFacingChild.get(), backfaceMatrix, identity
Matrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 2475 setLayerPropertiesForTesting(backFacingChild.get(), backfaceMatrix, identity
Matrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
2450 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident
ityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true); // surf
ace transform style is preserve-3d. | 2476 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident
ityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true); // surf
ace transform style is preserve-3d. |
2451 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, identi
tyMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true); // surfa
ce transform style is preserve-3d. | 2477 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, identi
tyMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true); // surfa
ce transform style is preserve-3d. |
2452 setLayerPropertiesForTesting(frontFacingChildOfFrontFacingSurface.get(), ide
ntityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 10
0), false); | 2478 setLayerPropertiesForTesting(frontFacingChildOfFrontFacingSurface.get(), ide
ntityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 10
0), false); |
2453 setLayerPropertiesForTesting(backFacingChildOfFrontFacingSurface.get(), back
faceMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100
), false); | 2479 setLayerPropertiesForTesting(backFacingChildOfFrontFacingSurface.get(), back
faceMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100
), false); |
2454 setLayerPropertiesForTesting(frontFacingChildOfBackFacingSurface.get(), iden
tityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100
), false); | 2480 setLayerPropertiesForTesting(frontFacingChildOfBackFacingSurface.get(), iden
tityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100
), false); |
2455 setLayerPropertiesForTesting(backFacingChildOfBackFacingSurface.get(), backf
aceMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100)
, false); | 2481 setLayerPropertiesForTesting(backFacingChildOfBackFacingSurface.get(), backf
aceMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100)
, false); |
2456 | 2482 |
2457 std::vector<scoped_refptr<LayerChromium> > renderSurfaceLayerList; | 2483 std::vector<scoped_refptr<LayerChromium> > renderSurfaceLayerList; |
2458 int dummyMaxTextureSize = 512; | 2484 int dummyMaxTextureSize = 512; |
2459 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, dummyMaxTextureSize, renderSurfaceLayerList); | 2485 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); |
2460 | 2486 |
2461 // Verify which renderSurfaces were created. | 2487 // Verify which renderSurfaces were created. |
2462 EXPECT_FALSE(frontFacingChild->renderSurface()); | 2488 EXPECT_FALSE(frontFacingChild->renderSurface()); |
2463 EXPECT_FALSE(backFacingChild->renderSurface()); | 2489 EXPECT_FALSE(backFacingChild->renderSurface()); |
2464 EXPECT_TRUE(frontFacingSurface->renderSurface()); | 2490 EXPECT_TRUE(frontFacingSurface->renderSurface()); |
2465 EXPECT_FALSE(backFacingSurface->renderSurface()); | 2491 EXPECT_FALSE(backFacingSurface->renderSurface()); |
2466 EXPECT_FALSE(frontFacingChildOfFrontFacingSurface->renderSurface()); | 2492 EXPECT_FALSE(frontFacingChildOfFrontFacingSurface->renderSurface()); |
2467 EXPECT_FALSE(backFacingChildOfFrontFacingSurface->renderSurface()); | 2493 EXPECT_FALSE(backFacingChildOfFrontFacingSurface->renderSurface()); |
2468 EXPECT_FALSE(frontFacingChildOfBackFacingSurface->renderSurface()); | 2494 EXPECT_FALSE(frontFacingChildOfBackFacingSurface->renderSurface()); |
2469 EXPECT_FALSE(backFacingChildOfBackFacingSurface->renderSurface()); | 2495 EXPECT_FALSE(backFacingChildOfBackFacingSurface->renderSurface()); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2529 | 2555 |
2530 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 2556 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
2531 setLayerPropertiesForTesting(child.get(), backfaceMatrix, identityMatrix, Fl
oatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 2557 setLayerPropertiesForTesting(child.get(), backfaceMatrix, identityMatrix, Fl
oatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
2532 setLayerPropertiesForTesting(animatingSurface.get(), backfaceMatrix, identit
yMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 2558 setLayerPropertiesForTesting(animatingSurface.get(), backfaceMatrix, identit
yMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
2533 setLayerPropertiesForTesting(childOfAnimatingSurface.get(), backfaceMatrix,
identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 2559 setLayerPropertiesForTesting(childOfAnimatingSurface.get(), backfaceMatrix,
identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
2534 setLayerPropertiesForTesting(animatingChild.get(), backfaceMatrix, identityM
atrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 2560 setLayerPropertiesForTesting(animatingChild.get(), backfaceMatrix, identityM
atrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
2535 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 2561 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
2536 | 2562 |
2537 std::vector<scoped_refptr<LayerChromium> > renderSurfaceLayerList; | 2563 std::vector<scoped_refptr<LayerChromium> > renderSurfaceLayerList; |
2538 int dummyMaxTextureSize = 512; | 2564 int dummyMaxTextureSize = 512; |
2539 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, dummyMaxTextureSize, renderSurfaceLayerList); | 2565 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); |
2540 | 2566 |
2541 EXPECT_FALSE(child->renderSurface()); | 2567 EXPECT_FALSE(child->renderSurface()); |
2542 EXPECT_TRUE(animatingSurface->renderSurface()); | 2568 EXPECT_TRUE(animatingSurface->renderSurface()); |
2543 EXPECT_FALSE(childOfAnimatingSurface->renderSurface()); | 2569 EXPECT_FALSE(childOfAnimatingSurface->renderSurface()); |
2544 EXPECT_FALSE(animatingChild->renderSurface()); | 2570 EXPECT_FALSE(animatingChild->renderSurface()); |
2545 EXPECT_FALSE(child2->renderSurface()); | 2571 EXPECT_FALSE(child2->renderSurface()); |
2546 | 2572 |
2547 // Verify that the animatingChild and childOfAnimatingSurface were not culle
d, but that child was. | 2573 // Verify that the animatingChild and childOfAnimatingSurface were not culle
d, but that child was. |
2548 ASSERT_EQ(2u, renderSurfaceLayerList.size()); | 2574 ASSERT_EQ(2u, renderSurfaceLayerList.size()); |
2549 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); | 2575 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2595 backfaceMatrix.translate(-50, -50); | 2621 backfaceMatrix.translate(-50, -50); |
2596 | 2622 |
2597 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true); // parent transform
style is preserve3d. | 2623 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true); // parent transform
style is preserve3d. |
2598 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident
ityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); // sur
face transform style is flat. | 2624 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident
ityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); // sur
face transform style is flat. |
2599 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, ident
ityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); // sur
face transform style is flat. | 2625 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, ident
ityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); // sur
face transform style is flat. |
2600 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 2626 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
2601 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); | 2627 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); |
2602 | 2628 |
2603 std::vector<scoped_refptr<LayerChromium> > renderSurfaceLayerList; | 2629 std::vector<scoped_refptr<LayerChromium> > renderSurfaceLayerList; |
2604 int dummyMaxTextureSize = 512; | 2630 int dummyMaxTextureSize = 512; |
2605 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, dummyMaxTextureSize, renderSurfaceLayerList); | 2631 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList); |
2606 | 2632 |
2607 // Verify which renderSurfaces were created. | 2633 // Verify which renderSurfaces were created. |
2608 EXPECT_TRUE(frontFacingSurface->renderSurface()); | 2634 EXPECT_TRUE(frontFacingSurface->renderSurface()); |
2609 EXPECT_FALSE(backFacingSurface->renderSurface()); // because it should be cu
lled | 2635 EXPECT_FALSE(backFacingSurface->renderSurface()); // because it should be cu
lled |
2610 EXPECT_FALSE(child1->renderSurface()); | 2636 EXPECT_FALSE(child1->renderSurface()); |
2611 EXPECT_FALSE(child2->renderSurface()); | 2637 EXPECT_FALSE(child2->renderSurface()); |
2612 | 2638 |
2613 // Verify the renderSurfaceLayerList. The back-facing surface should be cull
ed. | 2639 // Verify the renderSurfaceLayerList. The back-facing surface should be cull
ed. |
2614 ASSERT_EQ(2u, renderSurfaceLayerList.size()); | 2640 ASSERT_EQ(2u, renderSurfaceLayerList.size()); |
2615 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); | 2641 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2649 | 2675 |
2650 WebTransformationMatrix identityMatrix; | 2676 WebTransformationMatrix identityMatrix; |
2651 FloatPoint anchor(0, 0); | 2677 FloatPoint anchor(0, 0); |
2652 FloatPoint position(0, 0); | 2678 FloatPoint position(0, 0); |
2653 IntSize bounds(100, 100); | 2679 IntSize bounds(100, 100); |
2654 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 2680 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
2655 root->setDrawsContent(true); | 2681 root->setDrawsContent(true); |
2656 | 2682 |
2657 std::vector<CCLayerImpl*> renderSurfaceLayerList; | 2683 std::vector<CCLayerImpl*> renderSurfaceLayerList; |
2658 int dummyMaxTextureSize = 512; | 2684 int dummyMaxTextureSize = 512; |
2659 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 2685 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
2660 | 2686 |
2661 // Sanity check the scenario we just created. | 2687 // Sanity check the scenario we just created. |
2662 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 2688 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
2663 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); | 2689 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); |
2664 | 2690 |
2665 // Hit testing for a point outside the layer should return a null pointer. | 2691 // Hit testing for a point outside the layer should return a null pointer. |
2666 IntPoint testPoint(101, 101); | 2692 IntPoint testPoint(101, 101); |
2667 CCLayerImpl* resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(
testPoint, renderSurfaceLayerList); | 2693 CCLayerImpl* resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(
testPoint, renderSurfaceLayerList); |
2668 EXPECT_FALSE(resultLayer); | 2694 EXPECT_FALSE(resultLayer); |
2669 | 2695 |
(...skipping 28 matching lines...) Expand all Loading... |
2698 | 2724 |
2699 WebTransformationMatrix identityMatrix; | 2725 WebTransformationMatrix identityMatrix; |
2700 FloatPoint anchor(0, 0); | 2726 FloatPoint anchor(0, 0); |
2701 FloatPoint position(0, 0); | 2727 FloatPoint position(0, 0); |
2702 IntSize bounds(100, 100); | 2728 IntSize bounds(100, 100); |
2703 setLayerPropertiesForTesting(root.get(), uninvertibleTransform, identityMatr
ix, anchor, position, bounds, false); | 2729 setLayerPropertiesForTesting(root.get(), uninvertibleTransform, identityMatr
ix, anchor, position, bounds, false); |
2704 root->setDrawsContent(true); | 2730 root->setDrawsContent(true); |
2705 | 2731 |
2706 std::vector<CCLayerImpl*> renderSurfaceLayerList; | 2732 std::vector<CCLayerImpl*> renderSurfaceLayerList; |
2707 int dummyMaxTextureSize = 512; | 2733 int dummyMaxTextureSize = 512; |
2708 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 2734 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
2709 | 2735 |
2710 // Sanity check the scenario we just created. | 2736 // Sanity check the scenario we just created. |
2711 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 2737 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
2712 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); | 2738 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); |
2713 ASSERT_FALSE(root->screenSpaceTransform().isInvertible()); | 2739 ASSERT_FALSE(root->screenSpaceTransform().isInvertible()); |
2714 | 2740 |
2715 // Hit testing any point should not hit the layer. If the invertible matrix
is | 2741 // Hit testing any point should not hit the layer. If the invertible matrix
is |
2716 // accidentally ignored and treated like an identity, then the hit testing w
ill | 2742 // accidentally ignored and treated like an identity, then the hit testing w
ill |
2717 // incorrectly hit the layer when it shouldn't. | 2743 // incorrectly hit the layer when it shouldn't. |
2718 IntPoint testPoint(1, 1); | 2744 IntPoint testPoint(1, 1); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2752 | 2778 |
2753 WebTransformationMatrix identityMatrix; | 2779 WebTransformationMatrix identityMatrix; |
2754 FloatPoint anchor(0, 0); | 2780 FloatPoint anchor(0, 0); |
2755 FloatPoint position(50, 50); // this layer is positioned, and hit testing sh
ould correctly know where the layer is located. | 2781 FloatPoint position(50, 50); // this layer is positioned, and hit testing sh
ould correctly know where the layer is located. |
2756 IntSize bounds(100, 100); | 2782 IntSize bounds(100, 100); |
2757 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 2783 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
2758 root->setDrawsContent(true); | 2784 root->setDrawsContent(true); |
2759 | 2785 |
2760 std::vector<CCLayerImpl*> renderSurfaceLayerList; | 2786 std::vector<CCLayerImpl*> renderSurfaceLayerList; |
2761 int dummyMaxTextureSize = 512; | 2787 int dummyMaxTextureSize = 512; |
2762 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 2788 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
2763 | 2789 |
2764 // Sanity check the scenario we just created. | 2790 // Sanity check the scenario we just created. |
2765 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 2791 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
2766 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); | 2792 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); |
2767 | 2793 |
2768 // Hit testing for a point outside the layer should return a null pointer. | 2794 // Hit testing for a point outside the layer should return a null pointer. |
2769 IntPoint testPoint(49, 49); | 2795 IntPoint testPoint(49, 49); |
2770 CCLayerImpl* resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(
testPoint, renderSurfaceLayerList); | 2796 CCLayerImpl* resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(
testPoint, renderSurfaceLayerList); |
2771 EXPECT_FALSE(resultLayer); | 2797 EXPECT_FALSE(resultLayer); |
2772 | 2798 |
(...skipping 26 matching lines...) Expand all Loading... |
2799 rotation45DegreesAboutCenter.rotate3d(0, 0, 45); | 2825 rotation45DegreesAboutCenter.rotate3d(0, 0, 45); |
2800 rotation45DegreesAboutCenter.translate(-50, -50); | 2826 rotation45DegreesAboutCenter.translate(-50, -50); |
2801 FloatPoint anchor(0, 0); | 2827 FloatPoint anchor(0, 0); |
2802 FloatPoint position(0, 0); | 2828 FloatPoint position(0, 0); |
2803 IntSize bounds(100, 100); | 2829 IntSize bounds(100, 100); |
2804 setLayerPropertiesForTesting(root.get(), rotation45DegreesAboutCenter, ident
ityMatrix, anchor, position, bounds, false); | 2830 setLayerPropertiesForTesting(root.get(), rotation45DegreesAboutCenter, ident
ityMatrix, anchor, position, bounds, false); |
2805 root->setDrawsContent(true); | 2831 root->setDrawsContent(true); |
2806 | 2832 |
2807 std::vector<CCLayerImpl*> renderSurfaceLayerList; | 2833 std::vector<CCLayerImpl*> renderSurfaceLayerList; |
2808 int dummyMaxTextureSize = 512; | 2834 int dummyMaxTextureSize = 512; |
2809 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 2835 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
2810 | 2836 |
2811 // Sanity check the scenario we just created. | 2837 // Sanity check the scenario we just created. |
2812 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 2838 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
2813 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); | 2839 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); |
2814 | 2840 |
2815 // Hit testing for points outside the layer. | 2841 // Hit testing for points outside the layer. |
2816 // These corners would have been inside the un-transformed layer, but they s
hould not hit the correctly transformed layer. | 2842 // These corners would have been inside the un-transformed layer, but they s
hould not hit the correctly transformed layer. |
2817 IntPoint testPoint(99, 99); | 2843 IntPoint testPoint(99, 99); |
2818 CCLayerImpl* resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(
testPoint, renderSurfaceLayerList); | 2844 CCLayerImpl* resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(
testPoint, renderSurfaceLayerList); |
2819 EXPECT_FALSE(resultLayer); | 2845 EXPECT_FALSE(resultLayer); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2855 translationByZ.translate3d(0, 0, -1); | 2881 translationByZ.translate3d(0, 0, -1); |
2856 | 2882 |
2857 FloatPoint anchor(0, 0); | 2883 FloatPoint anchor(0, 0); |
2858 FloatPoint position(0, 0); | 2884 FloatPoint position(0, 0); |
2859 IntSize bounds(100, 100); | 2885 IntSize bounds(100, 100); |
2860 setLayerPropertiesForTesting(root.get(), perspectiveProjectionAboutCenter *
translationByZ, identityMatrix, anchor, position, bounds, false); | 2886 setLayerPropertiesForTesting(root.get(), perspectiveProjectionAboutCenter *
translationByZ, identityMatrix, anchor, position, bounds, false); |
2861 root->setDrawsContent(true); | 2887 root->setDrawsContent(true); |
2862 | 2888 |
2863 std::vector<CCLayerImpl*> renderSurfaceLayerList; | 2889 std::vector<CCLayerImpl*> renderSurfaceLayerList; |
2864 int dummyMaxTextureSize = 512; | 2890 int dummyMaxTextureSize = 512; |
2865 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 2891 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
2866 | 2892 |
2867 // Sanity check the scenario we just created. | 2893 // Sanity check the scenario we just created. |
2868 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 2894 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
2869 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); | 2895 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); |
2870 | 2896 |
2871 // Hit testing for points outside the layer. | 2897 // Hit testing for points outside the layer. |
2872 // These corners would have been inside the un-transformed layer, but they s
hould not hit the correctly transformed layer. | 2898 // These corners would have been inside the un-transformed layer, but they s
hould not hit the correctly transformed layer. |
2873 IntPoint testPoint(24, 24); | 2899 IntPoint testPoint(24, 24); |
2874 CCLayerImpl* resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(
testPoint, renderSurfaceLayerList); | 2900 CCLayerImpl* resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(
testPoint, renderSurfaceLayerList); |
2875 EXPECT_FALSE(resultLayer); | 2901 EXPECT_FALSE(resultLayer); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2919 | 2945 |
2920 // override contentBounds | 2946 // override contentBounds |
2921 testLayer->setContentBounds(IntSize(100, 100)); | 2947 testLayer->setContentBounds(IntSize(100, 100)); |
2922 | 2948 |
2923 testLayer->setDrawsContent(true); | 2949 testLayer->setDrawsContent(true); |
2924 root->addChild(testLayer.Pass()); | 2950 root->addChild(testLayer.Pass()); |
2925 } | 2951 } |
2926 | 2952 |
2927 std::vector<CCLayerImpl*> renderSurfaceLayerList; | 2953 std::vector<CCLayerImpl*> renderSurfaceLayerList; |
2928 int dummyMaxTextureSize = 512; | 2954 int dummyMaxTextureSize = 512; |
2929 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 2955 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
2930 | 2956 |
2931 // Sanity check the scenario we just created. | 2957 // Sanity check the scenario we just created. |
2932 // The visibleContentRect for testLayer is actually 100x100, even though its
layout size is 50x50, positioned at 25x25. | 2958 // The visibleContentRect for testLayer is actually 100x100, even though its
layout size is 50x50, positioned at 25x25. |
2933 CCLayerImpl* testLayer = root->children()[0]; | 2959 CCLayerImpl* testLayer = root->children()[0]; |
2934 EXPECT_RECT_EQ(IntRect(IntPoint::zero(), IntSize(100, 100)), testLayer->visi
bleContentRect()); | 2960 EXPECT_RECT_EQ(IntRect(IntPoint::zero(), IntSize(100, 100)), testLayer->visi
bleContentRect()); |
2935 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 2961 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
2936 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); | 2962 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); |
2937 | 2963 |
2938 // 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). | 2964 // 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). |
2939 IntPoint testPoint(101, 101); | 2965 IntPoint testPoint(101, 101); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2983 position = FloatPoint(-50, -50); | 3009 position = FloatPoint(-50, -50); |
2984 bounds = IntSize(300, 300); | 3010 bounds = IntSize(300, 300); |
2985 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); | 3011 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); |
2986 child->setDrawsContent(true); | 3012 child->setDrawsContent(true); |
2987 clippingLayer->addChild(child.Pass()); | 3013 clippingLayer->addChild(child.Pass()); |
2988 root->addChild(clippingLayer.Pass()); | 3014 root->addChild(clippingLayer.Pass()); |
2989 } | 3015 } |
2990 | 3016 |
2991 std::vector<CCLayerImpl*> renderSurfaceLayerList; | 3017 std::vector<CCLayerImpl*> renderSurfaceLayerList; |
2992 int dummyMaxTextureSize = 512; | 3018 int dummyMaxTextureSize = 512; |
2993 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 3019 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
2994 | 3020 |
2995 // Sanity check the scenario we just created. | 3021 // Sanity check the scenario we just created. |
2996 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 3022 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
2997 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); | 3023 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); |
2998 ASSERT_EQ(456, root->renderSurface()->layerList()[0]->id()); | 3024 ASSERT_EQ(456, root->renderSurface()->layerList()[0]->id()); |
2999 | 3025 |
3000 // Hit testing for a point outside the layer should return a null pointer. | 3026 // Hit testing for a point outside the layer should return a null pointer. |
3001 // Despite the child layer being very large, it should be clipped to the roo
t layer's bounds. | 3027 // Despite the child layer being very large, it should be clipped to the roo
t layer's bounds. |
3002 IntPoint testPoint(24, 24); | 3028 IntPoint testPoint(24, 24); |
3003 CCLayerImpl* resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(
testPoint, renderSurfaceLayerList); | 3029 CCLayerImpl* resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(
testPoint, renderSurfaceLayerList); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3073 setLayerPropertiesForTesting(rotatedLeaf.get(), rotatedLeafTransform, id
entityMatrix, anchor, position, bounds, false); | 3099 setLayerPropertiesForTesting(rotatedLeaf.get(), rotatedLeafTransform, id
entityMatrix, anchor, position, bounds, false); |
3074 rotatedLeaf->setDrawsContent(true); | 3100 rotatedLeaf->setDrawsContent(true); |
3075 | 3101 |
3076 grandChild->addChild(rotatedLeaf.Pass()); | 3102 grandChild->addChild(rotatedLeaf.Pass()); |
3077 child->addChild(grandChild.Pass()); | 3103 child->addChild(grandChild.Pass()); |
3078 root->addChild(child.Pass()); | 3104 root->addChild(child.Pass()); |
3079 } | 3105 } |
3080 | 3106 |
3081 std::vector<CCLayerImpl*> renderSurfaceLayerList; | 3107 std::vector<CCLayerImpl*> renderSurfaceLayerList; |
3082 int dummyMaxTextureSize = 512; | 3108 int dummyMaxTextureSize = 512; |
3083 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 3109 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
3084 | 3110 |
3085 // Sanity check the scenario we just created. | 3111 // Sanity check the scenario we just created. |
3086 // The grandChild is expected to create a renderSurface because it masksToBo
unds and is not axis aligned. | 3112 // The grandChild is expected to create a renderSurface because it masksToBo
unds and is not axis aligned. |
3087 ASSERT_EQ(2u, renderSurfaceLayerList.size()); | 3113 ASSERT_EQ(2u, renderSurfaceLayerList.size()); |
3088 ASSERT_EQ(1u, renderSurfaceLayerList[0]->renderSurface()->layerList().size()
); | 3114 ASSERT_EQ(1u, renderSurfaceLayerList[0]->renderSurface()->layerList().size()
); |
3089 ASSERT_EQ(789, renderSurfaceLayerList[0]->renderSurface()->layerList()[0]->i
d()); // grandChild's surface. | 3115 ASSERT_EQ(789, renderSurfaceLayerList[0]->renderSurface()->layerList()[0]->i
d()); // grandChild's surface. |
3090 ASSERT_EQ(1u, renderSurfaceLayerList[1]->renderSurface()->layerList().size()
); | 3116 ASSERT_EQ(1u, renderSurfaceLayerList[1]->renderSurface()->layerList().size()
); |
3091 ASSERT_EQ(2468, renderSurfaceLayerList[1]->renderSurface()->layerList()[0]->
id()); | 3117 ASSERT_EQ(2468, renderSurfaceLayerList[1]->renderSurface()->layerList()[0]->
id()); |
3092 | 3118 |
3093 // (11, 89) is close to the the bottom left corner within the clip, but it i
s not inside the layer. | 3119 // (11, 89) is close to the the bottom left corner within the clip, but it i
s not inside the layer. |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3155 position = FloatPoint(60, 60); // 70, 70 in screen space | 3181 position = FloatPoint(60, 60); // 70, 70 in screen space |
3156 bounds = IntSize(20, 20); | 3182 bounds = IntSize(20, 20); |
3157 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); | 3183 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); |
3158 child->setDrawsContent(true); | 3184 child->setDrawsContent(true); |
3159 intermediateLayer->addChild(child.Pass()); | 3185 intermediateLayer->addChild(child.Pass()); |
3160 root->addChild(intermediateLayer.Pass()); | 3186 root->addChild(intermediateLayer.Pass()); |
3161 } | 3187 } |
3162 | 3188 |
3163 std::vector<CCLayerImpl*> renderSurfaceLayerList; | 3189 std::vector<CCLayerImpl*> renderSurfaceLayerList; |
3164 int dummyMaxTextureSize = 512; | 3190 int dummyMaxTextureSize = 512; |
3165 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 3191 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
3166 | 3192 |
3167 // Sanity check the scenario we just created. | 3193 // Sanity check the scenario we just created. |
3168 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 3194 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
3169 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); | 3195 ASSERT_EQ(1u, root->renderSurface()->layerList().size()); |
3170 ASSERT_EQ(456, root->renderSurface()->layerList()[0]->id()); | 3196 ASSERT_EQ(456, root->renderSurface()->layerList()[0]->id()); |
3171 | 3197 |
3172 // Hit testing for a point outside the layer should return a null pointer. | 3198 // Hit testing for a point outside the layer should return a null pointer. |
3173 IntPoint testPoint(69, 69); | 3199 IntPoint testPoint(69, 69); |
3174 CCLayerImpl* resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(
testPoint, renderSurfaceLayerList); | 3200 CCLayerImpl* resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(
testPoint, renderSurfaceLayerList); |
3175 EXPECT_FALSE(resultLayer); | 3201 EXPECT_FALSE(resultLayer); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3235 root->addChild(child1.Pass()); | 3261 root->addChild(child1.Pass()); |
3236 root->addChild(child2.Pass()); | 3262 root->addChild(child2.Pass()); |
3237 } | 3263 } |
3238 | 3264 |
3239 CCLayerImpl* child1 = root->children()[0]; | 3265 CCLayerImpl* child1 = root->children()[0]; |
3240 CCLayerImpl* child2 = root->children()[1]; | 3266 CCLayerImpl* child2 = root->children()[1]; |
3241 CCLayerImpl* grandChild1 = child1->children()[0]; | 3267 CCLayerImpl* grandChild1 = child1->children()[0]; |
3242 | 3268 |
3243 std::vector<CCLayerImpl*> renderSurfaceLayerList; | 3269 std::vector<CCLayerImpl*> renderSurfaceLayerList; |
3244 int dummyMaxTextureSize = 512; | 3270 int dummyMaxTextureSize = 512; |
3245 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 3271 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
3246 | 3272 |
3247 // Sanity check the scenario we just created. | 3273 // Sanity check the scenario we just created. |
3248 ASSERT_TRUE(child1); | 3274 ASSERT_TRUE(child1); |
3249 ASSERT_TRUE(child2); | 3275 ASSERT_TRUE(child2); |
3250 ASSERT_TRUE(grandChild1); | 3276 ASSERT_TRUE(grandChild1); |
3251 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 3277 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
3252 ASSERT_EQ(4u, root->renderSurface()->layerList().size()); | 3278 ASSERT_EQ(4u, root->renderSurface()->layerList().size()); |
3253 ASSERT_EQ(1, root->renderSurface()->layerList()[0]->id()); // root layer | 3279 ASSERT_EQ(1, root->renderSurface()->layerList()[0]->id()); // root layer |
3254 ASSERT_EQ(2, root->renderSurface()->layerList()[1]->id()); // child1 | 3280 ASSERT_EQ(2, root->renderSurface()->layerList()[1]->id()); // child1 |
3255 ASSERT_EQ(4, root->renderSurface()->layerList()[2]->id()); // grandChild1 | 3281 ASSERT_EQ(4, root->renderSurface()->layerList()[2]->id()); // grandChild1 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3343 root->addChild(child1.Pass()); | 3369 root->addChild(child1.Pass()); |
3344 root->addChild(child2.Pass()); | 3370 root->addChild(child2.Pass()); |
3345 } | 3371 } |
3346 | 3372 |
3347 CCLayerImpl* child1 = root->children()[0]; | 3373 CCLayerImpl* child1 = root->children()[0]; |
3348 CCLayerImpl* child2 = root->children()[1]; | 3374 CCLayerImpl* child2 = root->children()[1]; |
3349 CCLayerImpl* grandChild1 = child1->children()[0]; | 3375 CCLayerImpl* grandChild1 = child1->children()[0]; |
3350 | 3376 |
3351 std::vector<CCLayerImpl*> renderSurfaceLayerList; | 3377 std::vector<CCLayerImpl*> renderSurfaceLayerList; |
3352 int dummyMaxTextureSize = 512; | 3378 int dummyMaxTextureSize = 512; |
3353 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 0, dummyMaxTextureSize, renderSurfaceLayerList); | 3379 CCLayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1
, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList); |
3354 | 3380 |
3355 // Sanity check the scenario we just created. | 3381 // Sanity check the scenario we just created. |
3356 ASSERT_TRUE(child1); | 3382 ASSERT_TRUE(child1); |
3357 ASSERT_TRUE(child2); | 3383 ASSERT_TRUE(child2); |
3358 ASSERT_TRUE(grandChild1); | 3384 ASSERT_TRUE(grandChild1); |
3359 ASSERT_TRUE(child1->renderSurface()); | 3385 ASSERT_TRUE(child1->renderSurface()); |
3360 ASSERT_TRUE(child2->renderSurface()); | 3386 ASSERT_TRUE(child2->renderSurface()); |
3361 ASSERT_TRUE(grandChild1->renderSurface()); | 3387 ASSERT_TRUE(grandChild1->renderSurface()); |
3362 ASSERT_EQ(4u, renderSurfaceLayerList.size()); | 3388 ASSERT_EQ(4u, renderSurfaceLayerList.size()); |
3363 ASSERT_EQ(3u, root->renderSurface()->layerList().size()); // The root surfac
e has the root layer, and child1's and child2's renderSurfaces. | 3389 ASSERT_EQ(3u, root->renderSurface()->layerList().size()); // The root surfac
e has the root layer, and child1's and child2's renderSurfaces. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3399 ASSERT_TRUE(resultLayer); | 3425 ASSERT_TRUE(resultLayer); |
3400 EXPECT_EQ(3, resultLayer->id()); | 3426 EXPECT_EQ(3, resultLayer->id()); |
3401 | 3427 |
3402 // At (20, 51), child1 and grandChild1 overlap. grandChild1 is expected to b
e on top. | 3428 // At (20, 51), child1 and grandChild1 overlap. grandChild1 is expected to b
e on top. |
3403 testPoint = IntPoint(20, 51); | 3429 testPoint = IntPoint(20, 51); |
3404 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); | 3430 resultLayer = CCLayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, re
nderSurfaceLayerList); |
3405 ASSERT_TRUE(resultLayer); | 3431 ASSERT_TRUE(resultLayer); |
3406 EXPECT_EQ(4, resultLayer->id()); | 3432 EXPECT_EQ(4, resultLayer->id()); |
3407 } | 3433 } |
3408 | 3434 |
| 3435 class NoScaleContentLayerChromium : public ContentLayerChromium |
| 3436 { |
| 3437 public: |
| 3438 static scoped_refptr<NoScaleContentLayerChromium> create(ContentLayerChromiu
mClient* client) { return make_scoped_refptr(new NoScaleContentLayerChromium(cli
ent)); } |
| 3439 |
| 3440 virtual bool needsContentsScale() const OVERRIDE { return false; } |
| 3441 |
| 3442 protected: |
| 3443 explicit NoScaleContentLayerChromium(ContentLayerChromiumClient* client) : C
ontentLayerChromium(client) { } |
| 3444 virtual ~NoScaleContentLayerChromium() { } |
| 3445 }; |
| 3446 |
| 3447 scoped_refptr<NoScaleContentLayerChromium> createNoScaleDrawableContentLayerChro
mium(ContentLayerChromiumClient* delegate) |
| 3448 { |
| 3449 scoped_refptr<NoScaleContentLayerChromium> toReturn = NoScaleContentLayerChr
omium::create(delegate); |
| 3450 toReturn->setIsDrawable(true); |
| 3451 return toReturn; |
| 3452 } |
| 3453 |
3409 TEST(CCLayerTreeHostCommonTest, verifyLayerTransformsInHighDPI) | 3454 TEST(CCLayerTreeHostCommonTest, verifyLayerTransformsInHighDPI) |
3410 { | 3455 { |
3411 // Verify draw and screen space transforms of layers not in a surface. | 3456 // Verify draw and screen space transforms of layers not in a surface. |
3412 MockContentLayerChromiumClient delegate; | 3457 MockContentLayerChromiumClient delegate; |
3413 WebTransformationMatrix identityMatrix; | 3458 WebTransformationMatrix identityMatrix; |
3414 | 3459 |
3415 scoped_refptr<ContentLayerChromium> parent = createDrawableContentLayerChrom
ium(&delegate); | 3460 scoped_refptr<ContentLayerChromium> parent = createDrawableContentLayerChrom
ium(&delegate); |
3416 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true); | 3461 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true); |
3417 | 3462 |
3418 scoped_refptr<ContentLayerChromium> child = createDrawableContentLayerChromi
um(&delegate); | 3463 scoped_refptr<ContentLayerChromium> child = createDrawableContentLayerChromi
um(&delegate); |
3419 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint(0, 0), FloatPoint(2, 2), IntSize(10, 10), true); | 3464 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint(0, 0), FloatPoint(2, 2), IntSize(10, 10), true); |
3420 | 3465 |
3421 scoped_refptr<ContentLayerChromium> childNoScale = createDrawableContentLaye
rChromium(&delegate); | 3466 scoped_refptr<NoScaleContentLayerChromium> childNoScale = createNoScaleDrawa
bleContentLayerChromium(&delegate); |
3422 setLayerPropertiesForTesting(childNoScale.get(), identityMatrix, identityMat
rix, FloatPoint(0, 0), FloatPoint(2, 2), IntSize(10, 10), true); | 3467 setLayerPropertiesForTesting(childNoScale.get(), identityMatrix, identityMat
rix, FloatPoint(0, 0), FloatPoint(2, 2), IntSize(10, 10), true); |
3423 | 3468 |
3424 parent->addChild(child); | 3469 parent->addChild(child); |
3425 parent->addChild(childNoScale); | 3470 parent->addChild(childNoScale); |
3426 | 3471 |
3427 std::vector<scoped_refptr<LayerChromium> > renderSurfaceLayerList; | 3472 std::vector<scoped_refptr<LayerChromium> > renderSurfaceLayerList; |
3428 int dummyMaxTextureSize = 512; | 3473 int dummyMaxTextureSize = 512; |
3429 | 3474 |
3430 const double deviceScaleFactor = 2.5; | 3475 const double deviceScaleFactor = 2.5; |
3431 parent->setContentsScale(deviceScaleFactor); | 3476 const double pageScaleFactor = 1; |
3432 child->setContentsScale(deviceScaleFactor); | |
3433 EXPECT_EQ(childNoScale->contentsScale(), 1); | |
3434 | 3477 |
3435 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), deviceScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList); | 3478 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerLi
st); |
| 3479 |
| 3480 EXPECT_EQ(deviceScaleFactor * pageScaleFactor, parent->contentsScale()); |
| 3481 EXPECT_EQ(deviceScaleFactor * pageScaleFactor, child->contentsScale()); |
| 3482 EXPECT_EQ(1, childNoScale->contentsScale()); |
3436 | 3483 |
3437 EXPECT_EQ(1u, renderSurfaceLayerList.size()); | 3484 EXPECT_EQ(1u, renderSurfaceLayerList.size()); |
3438 | 3485 |
3439 // Verify parent transforms | 3486 // Verify parent transforms |
3440 WebTransformationMatrix expectedParentTransform; | 3487 WebTransformationMatrix expectedParentTransform; |
3441 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpace
Transform()); | 3488 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpace
Transform()); |
3442 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->drawTransfo
rm()); | 3489 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->drawTransfo
rm()); |
3443 | 3490 |
3444 // Verify results of transformed parent rects | 3491 // Verify results of transformed parent rects |
3445 FloatRect parentContentBounds(FloatPoint(), FloatSize(parent->contentBounds(
))); | 3492 FloatRect parentContentBounds(FloatPoint(), FloatSize(parent->contentBounds(
))); |
(...skipping 26 matching lines...) Expand all Loading... |
3472 | 3519 |
3473 // Verify childNoScale transforms | 3520 // Verify childNoScale transforms |
3474 WebTransformationMatrix expectedChildNoScaleTransform = child->drawTransform
(); | 3521 WebTransformationMatrix expectedChildNoScaleTransform = child->drawTransform
(); |
3475 // All transforms operate on content rects. The child's content rect | 3522 // All transforms operate on content rects. The child's content rect |
3476 // incorporates device scale, but the childNoScale does not; add it here. | 3523 // incorporates device scale, but the childNoScale does not; add it here. |
3477 expectedChildNoScaleTransform.scale(deviceScaleFactor); | 3524 expectedChildNoScaleTransform.scale(deviceScaleFactor); |
3478 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildNoScaleTransform, childNoScale-
>drawTransform()); | 3525 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildNoScaleTransform, childNoScale-
>drawTransform()); |
3479 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildNoScaleTransform, childNoScale-
>screenSpaceTransform()); | 3526 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildNoScaleTransform, childNoScale-
>screenSpaceTransform()); |
3480 } | 3527 } |
3481 | 3528 |
| 3529 TEST(CCLayerTreeHostCommonTest, verifyContentsScale) |
| 3530 { |
| 3531 MockContentLayerChromiumClient delegate; |
| 3532 WebTransformationMatrix identityMatrix; |
| 3533 |
| 3534 WebTransformationMatrix parentScaleMatrix; |
| 3535 const double initialParentScale = 1.75; |
| 3536 parentScaleMatrix.scale(initialParentScale); |
| 3537 |
| 3538 WebTransformationMatrix childScaleMatrix; |
| 3539 const double initialChildScale = 1.25; |
| 3540 childScaleMatrix.scale(initialChildScale); |
| 3541 |
| 3542 scoped_refptr<ContentLayerChromium> parent = createDrawableContentLayerChrom
ium(&delegate); |
| 3543 setLayerPropertiesForTesting(parent.get(), parentScaleMatrix, identityMatrix
, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true); |
| 3544 |
| 3545 scoped_refptr<ContentLayerChromium> childScale = createDrawableContentLayerC
hromium(&delegate); |
| 3546 setLayerPropertiesForTesting(childScale.get(), childScaleMatrix, identityMat
rix, FloatPoint(0, 0), FloatPoint(2, 2), IntSize(10, 10), true); |
| 3547 |
| 3548 scoped_refptr<NoScaleContentLayerChromium> childNoScale = createNoScaleDrawa
bleContentLayerChromium(&delegate); |
| 3549 setLayerPropertiesForTesting(childNoScale.get(), childScaleMatrix, identityM
atrix, FloatPoint(0, 0), FloatPoint(12, 12), IntSize(10, 10), true); |
| 3550 |
| 3551 // FIXME: Remove this when pageScaleFactor is applied in the compositor. |
| 3552 // Page scale should not apply to the parent. |
| 3553 parent->setBoundsContainPageScale(true); |
| 3554 |
| 3555 parent->addChild(childScale); |
| 3556 parent->addChild(childNoScale); |
| 3557 |
| 3558 std::vector<scoped_refptr<LayerChromium> > renderSurfaceLayerList; |
| 3559 int dummyMaxTextureSize = 512; |
| 3560 |
| 3561 double deviceScaleFactor = 2.5; |
| 3562 double pageScaleFactor = 1.5; |
| 3563 |
| 3564 // FIXME: Remove this when pageScaleFactor is applied in the compositor. |
| 3565 WebTransformationMatrix pageScaleMatrix; |
| 3566 pageScaleMatrix.scale(pageScaleFactor); |
| 3567 parent->setSublayerTransform(pageScaleMatrix); |
| 3568 |
| 3569 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerLi
st); |
| 3570 |
| 3571 EXPECT_FLOAT_EQ(deviceScaleFactor * initialParentScale, parent->contentsScal
e()); |
| 3572 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale, childScale->contentsScale()); |
| 3573 EXPECT_FLOAT_EQ(1, childNoScale->contentsScale()); |
| 3574 |
| 3575 // The parent is scaled up and shouldn't need to scale during draw. The chil
d that can scale its contents should |
| 3576 // also not need to scale during draw. The other should. |
| 3577 // There is some rounding error due to contentBounds being a rounded integer
. |
| 3578 EXPECT_NEAR(parent->drawTransform().m11(), 1, 0.01); |
| 3579 EXPECT_NEAR(parent->drawTransform().m22(), 1, 0.01); |
| 3580 EXPECT_NEAR(childScale->drawTransform().m11(), 1, 0.01); |
| 3581 EXPECT_NEAR(childScale->drawTransform().m22(), 1, 0.01); |
| 3582 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale, childNoScale->drawTransform().m11()); |
| 3583 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale, childNoScale->drawTransform().m22()); |
| 3584 |
| 3585 // If the transform changes, we expect the contentsScale to remain unchanged
. |
| 3586 childScale->setTransform(identityMatrix); |
| 3587 |
| 3588 renderSurfaceLayerList.clear(); |
| 3589 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerLi
st); |
| 3590 |
| 3591 EXPECT_FLOAT_EQ(deviceScaleFactor * initialParentScale, parent->contentsScal
e()); |
| 3592 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale, childScale->contentsScale()); |
| 3593 EXPECT_FLOAT_EQ(1, childNoScale->contentsScale()); |
| 3594 |
| 3595 // But if the deviceScaleFactor or pageScaleFactor changes, then it should b
e updated, but using the initial transform. |
| 3596 deviceScaleFactor = 2.25; |
| 3597 pageScaleFactor = 1.25; |
| 3598 |
| 3599 // FIXME: Remove this when pageScaleFactor is applied in the compositor. |
| 3600 pageScaleMatrix = identityMatrix; |
| 3601 pageScaleMatrix.scale(pageScaleFactor); |
| 3602 parent->setSublayerTransform(pageScaleMatrix); |
| 3603 |
| 3604 renderSurfaceLayerList.clear(); |
| 3605 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerLi
st); |
| 3606 |
| 3607 EXPECT_FLOAT_EQ(deviceScaleFactor * initialParentScale, parent->contentsScal
e()); |
| 3608 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale, childScale->contentsScale()); |
| 3609 EXPECT_FLOAT_EQ(1, childNoScale->contentsScale()); |
| 3610 } |
| 3611 |
| 3612 TEST(CCLayerTreeHostCommonTest, verifyContentsScaleForSurfaces) |
| 3613 { |
| 3614 MockContentLayerChromiumClient delegate; |
| 3615 WebTransformationMatrix identityMatrix; |
| 3616 |
| 3617 WebTransformationMatrix parentScaleMatrix; |
| 3618 const double initialParentScale = 2; |
| 3619 parentScaleMatrix.scale(initialParentScale); |
| 3620 |
| 3621 WebTransformationMatrix childScaleMatrix; |
| 3622 const double initialChildScale = 3; |
| 3623 childScaleMatrix.scale(initialChildScale); |
| 3624 |
| 3625 scoped_refptr<ContentLayerChromium> parent = createDrawableContentLayerChrom
ium(&delegate); |
| 3626 setLayerPropertiesForTesting(parent.get(), parentScaleMatrix, identityMatrix
, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true); |
| 3627 |
| 3628 scoped_refptr<ContentLayerChromium> surfaceScale = createDrawableContentLaye
rChromium(&delegate); |
| 3629 setLayerPropertiesForTesting(surfaceScale.get(), childScaleMatrix, identityM
atrix, FloatPoint(0, 0), FloatPoint(2, 2), IntSize(10, 10), true); |
| 3630 |
| 3631 scoped_refptr<ContentLayerChromium> surfaceScaleChildScale = createDrawableC
ontentLayerChromium(&delegate); |
| 3632 setLayerPropertiesForTesting(surfaceScaleChildScale.get(), childScaleMatrix,
identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(10, 10), true); |
| 3633 |
| 3634 scoped_refptr<NoScaleContentLayerChromium> surfaceScaleChildNoScale = create
NoScaleDrawableContentLayerChromium(&delegate); |
| 3635 setLayerPropertiesForTesting(surfaceScaleChildNoScale.get(), childScaleMatri
x, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(10, 10), true); |
| 3636 |
| 3637 scoped_refptr<NoScaleContentLayerChromium> surfaceNoScale = createNoScaleDra
wableContentLayerChromium(&delegate); |
| 3638 setLayerPropertiesForTesting(surfaceNoScale.get(), childScaleMatrix, identit
yMatrix, FloatPoint(0, 0), FloatPoint(12, 12), IntSize(10, 10), true); |
| 3639 |
| 3640 scoped_refptr<ContentLayerChromium> surfaceNoScaleChildScale = createDrawabl
eContentLayerChromium(&delegate); |
| 3641 setLayerPropertiesForTesting(surfaceNoScaleChildScale.get(), childScaleMatri
x, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(10, 10), true); |
| 3642 |
| 3643 scoped_refptr<NoScaleContentLayerChromium> surfaceNoScaleChildNoScale = crea
teNoScaleDrawableContentLayerChromium(&delegate); |
| 3644 setLayerPropertiesForTesting(surfaceNoScaleChildNoScale.get(), childScaleMat
rix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(10, 10), true); |
| 3645 |
| 3646 // FIXME: Remove this when pageScaleFactor is applied in the compositor. |
| 3647 // Page scale should not apply to the parent. |
| 3648 parent->setBoundsContainPageScale(true); |
| 3649 |
| 3650 parent->addChild(surfaceScale); |
| 3651 parent->addChild(surfaceNoScale); |
| 3652 |
| 3653 surfaceScale->setForceRenderSurface(true); |
| 3654 surfaceScale->addChild(surfaceScaleChildScale); |
| 3655 surfaceScale->addChild(surfaceScaleChildNoScale); |
| 3656 |
| 3657 surfaceNoScale->setForceRenderSurface(true); |
| 3658 surfaceNoScale->addChild(surfaceNoScaleChildScale); |
| 3659 surfaceNoScale->addChild(surfaceNoScaleChildNoScale); |
| 3660 |
| 3661 std::vector<scoped_refptr<LayerChromium> > renderSurfaceLayerList; |
| 3662 int dummyMaxTextureSize = 512; |
| 3663 |
| 3664 double deviceScaleFactor = 5; |
| 3665 double pageScaleFactor = 7; |
| 3666 |
| 3667 // FIXME: Remove this when pageScaleFactor is applied in the compositor. |
| 3668 WebTransformationMatrix pageScaleMatrix; |
| 3669 pageScaleMatrix.scale(pageScaleFactor); |
| 3670 parent->setSublayerTransform(pageScaleMatrix); |
| 3671 |
| 3672 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerLi
st); |
| 3673 |
| 3674 EXPECT_EQ(deviceScaleFactor * initialParentScale, parent->contentsScale()); |
| 3675 EXPECT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * initial
ChildScale, surfaceScale->contentsScale()); |
| 3676 EXPECT_EQ(1, surfaceNoScale->contentsScale()); |
| 3677 EXPECT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * initial
ChildScale * initialChildScale, surfaceScaleChildScale->contentsScale()); |
| 3678 EXPECT_EQ(1, surfaceScaleChildNoScale->contentsScale()); |
| 3679 EXPECT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * initial
ChildScale * initialChildScale, surfaceNoScaleChildScale->contentsScale()); |
| 3680 EXPECT_EQ(1, surfaceNoScaleChildNoScale->contentsScale()); |
| 3681 |
| 3682 // The parent is scaled up and shouldn't need to scale during draw. |
| 3683 EXPECT_FLOAT_EQ(1, parent->drawTransform().m11()); |
| 3684 EXPECT_FLOAT_EQ(1, parent->drawTransform().m22()); |
| 3685 |
| 3686 // RenderSurfaces should always be 1:1 with their target. |
| 3687 EXPECT_FLOAT_EQ(1, surfaceScale->renderSurface()->drawTransform().m11()); |
| 3688 EXPECT_FLOAT_EQ(1, surfaceScale->renderSurface()->drawTransform().m22()); |
| 3689 |
| 3690 // The surfaceScale can apply contents scale so the layer shouldn't need to
scale during draw. |
| 3691 EXPECT_FLOAT_EQ(1, surfaceScale->drawTransform().m11()); |
| 3692 EXPECT_FLOAT_EQ(1, surfaceScale->drawTransform().m22()); |
| 3693 |
| 3694 // The surfaceScaleChildScale can apply contents scale so it shouldn't need
to scale during draw. |
| 3695 EXPECT_FLOAT_EQ(1, surfaceScaleChildScale->drawTransform().m11()); |
| 3696 EXPECT_FLOAT_EQ(1, surfaceScaleChildScale->drawTransform().m22()); |
| 3697 |
| 3698 // The surfaceScaleChildNoScale can not apply contents scale, so it needs to
be scaled during draw. |
| 3699 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale * initialChildScale, surfaceScaleChildNoScale->drawTransform().
m11()); |
| 3700 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale * initialChildScale, surfaceScaleChildNoScale->drawTransform().
m22()); |
| 3701 |
| 3702 // RenderSurfaces should always be 1:1 with their target. |
| 3703 EXPECT_FLOAT_EQ(1, surfaceNoScale->renderSurface()->drawTransform().m11()); |
| 3704 EXPECT_FLOAT_EQ(1, surfaceNoScale->renderSurface()->drawTransform().m22()); |
| 3705 |
| 3706 // The surfaceScale layer can not apply contents scale, so it needs to be sc
aled during draw. |
| 3707 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale, surfaceNoScale->drawTransform().m11()); |
| 3708 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale, surfaceNoScale->drawTransform().m22()); |
| 3709 |
| 3710 // The surfaceScaleChildScale can apply contents scale so it shouldn't need
to scale during draw. |
| 3711 EXPECT_FLOAT_EQ(1, surfaceNoScaleChildScale->drawTransform().m11()); |
| 3712 EXPECT_FLOAT_EQ(1, surfaceNoScaleChildScale->drawTransform().m22()); |
| 3713 |
| 3714 // The surfaceScaleChildNoScale can not apply contents scale, so it needs to
be scaled during draw. |
| 3715 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale * initialChildScale, surfaceNoScaleChildNoScale->drawTransform(
).m11()); |
| 3716 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale * initialChildScale, surfaceNoScaleChildNoScale->drawTransform(
).m22()); |
| 3717 |
| 3718 } |
| 3719 |
3482 TEST(CCLayerTreeHostCommonTest, verifyRenderSurfaceTransformsInHighDPI) | 3720 TEST(CCLayerTreeHostCommonTest, verifyRenderSurfaceTransformsInHighDPI) |
3483 { | 3721 { |
3484 MockContentLayerChromiumClient delegate; | 3722 MockContentLayerChromiumClient delegate; |
3485 WebTransformationMatrix identityMatrix; | 3723 WebTransformationMatrix identityMatrix; |
3486 | 3724 |
3487 scoped_refptr<ContentLayerChromium> parent = createDrawableContentLayerChrom
ium(&delegate); | 3725 scoped_refptr<ContentLayerChromium> parent = createDrawableContentLayerChrom
ium(&delegate); |
3488 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(30, 30), true); | 3726 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(30, 30), true); |
3489 | 3727 |
3490 scoped_refptr<ContentLayerChromium> child = createDrawableContentLayerChromi
um(&delegate); | 3728 scoped_refptr<ContentLayerChromium> child = createDrawableContentLayerChromi
um(&delegate); |
3491 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint(0, 0), FloatPoint(2, 2), IntSize(10, 10), true); | 3729 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint(0, 0), FloatPoint(2, 2), IntSize(10, 10), true); |
(...skipping 14 matching lines...) Expand all Loading... |
3506 | 3744 |
3507 std::vector<scoped_refptr<LayerChromium> > renderSurfaceLayerList; | 3745 std::vector<scoped_refptr<LayerChromium> > renderSurfaceLayerList; |
3508 int dummyMaxTextureSize = 512; | 3746 int dummyMaxTextureSize = 512; |
3509 | 3747 |
3510 const double deviceScaleFactor = 1.5; | 3748 const double deviceScaleFactor = 1.5; |
3511 parent->setContentsScale(deviceScaleFactor); | 3749 parent->setContentsScale(deviceScaleFactor); |
3512 child->setContentsScale(deviceScaleFactor); | 3750 child->setContentsScale(deviceScaleFactor); |
3513 duplicateChildNonOwner->setContentsScale(deviceScaleFactor); | 3751 duplicateChildNonOwner->setContentsScale(deviceScaleFactor); |
3514 replica->setContentsScale(deviceScaleFactor); | 3752 replica->setContentsScale(deviceScaleFactor); |
3515 | 3753 |
3516 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), deviceScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList); | 3754 CCLayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(
), deviceScaleFactor, 1, dummyMaxTextureSize, renderSurfaceLayerList); |
3517 | 3755 |
3518 // We should have two render surfaces. The root's render surface and child's | 3756 // We should have two render surfaces. The root's render surface and child's |
3519 // render surface (it needs one because it has a replica layer). | 3757 // render surface (it needs one because it has a replica layer). |
3520 EXPECT_EQ(2u, renderSurfaceLayerList.size()); | 3758 EXPECT_EQ(2u, renderSurfaceLayerList.size()); |
3521 | 3759 |
3522 WebTransformationMatrix expectedParentTransform; | 3760 WebTransformationMatrix expectedParentTransform; |
3523 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpace
Transform()); | 3761 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpace
Transform()); |
3524 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->drawTransfo
rm()); | 3762 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->drawTransfo
rm()); |
3525 | 3763 |
3526 WebTransformationMatrix expectedDrawTransform; | 3764 WebTransformationMatrix expectedDrawTransform; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3577 int nonexistentId = -1; | 3815 int nonexistentId = -1; |
3578 EXPECT_EQ(root, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), root->
id())); | 3816 EXPECT_EQ(root, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), root->
id())); |
3579 EXPECT_EQ(child, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), child
->id())); | 3817 EXPECT_EQ(child, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), child
->id())); |
3580 EXPECT_EQ(grandChild, CCLayerTreeHostCommon::findLayerInSubtree(root.get(),
grandChild->id())); | 3818 EXPECT_EQ(grandChild, CCLayerTreeHostCommon::findLayerInSubtree(root.get(),
grandChild->id())); |
3581 EXPECT_EQ(maskLayer, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), m
askLayer->id())); | 3819 EXPECT_EQ(maskLayer, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), m
askLayer->id())); |
3582 EXPECT_EQ(replicaLayer, CCLayerTreeHostCommon::findLayerInSubtree(root.get()
, replicaLayer->id())); | 3820 EXPECT_EQ(replicaLayer, CCLayerTreeHostCommon::findLayerInSubtree(root.get()
, replicaLayer->id())); |
3583 EXPECT_EQ(0, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), nonexiste
ntId)); | 3821 EXPECT_EQ(0, CCLayerTreeHostCommon::findLayerInSubtree(root.get(), nonexiste
ntId)); |
3584 } | 3822 } |
3585 | 3823 |
3586 } // namespace | 3824 } // namespace |
OLD | NEW |