| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/layer_tree_host_common.h" | 5 #include "cc/layer_tree_host_common.h" |
| 6 | 6 |
| 7 #include "cc/content_layer.h" | 7 #include "cc/content_layer.h" |
| 8 #include "cc/content_layer_client.h" | 8 #include "cc/content_layer_client.h" |
| 9 #include "cc/layer.h" | 9 #include "cc/layer.h" |
| 10 #include "cc/layer_animation_controller.h" | 10 #include "cc/layer_animation_controller.h" |
| (...skipping 2390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2401 | 2401 |
| 2402 gfx::Transform identityMatrix; | 2402 gfx::Transform identityMatrix; |
| 2403 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2403 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 2404 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(3, 4), false); | 2404 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(3, 4), false); |
| 2405 setLayerPropertiesForTesting(renderSurface2.get(), identityMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(7, 13), false); | 2405 setLayerPropertiesForTesting(renderSurface2.get(), identityMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(7, 13), false); |
| 2406 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(50, 50), false); | 2406 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(50, 50), false); |
| 2407 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(75, 75), gfx::Size(50, 50), false); | 2407 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(75, 75), gfx::Size(50, 50), false); |
| 2408 setLayerPropertiesForTesting(child3.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(125, 125), gfx::Size(50, 50), false); | 2408 setLayerPropertiesForTesting(child3.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(125, 125), gfx::Size(50, 50), false); |
| 2409 | 2409 |
| 2410 const double deviceScaleFactor = 2; | 2410 const double deviceScaleFactor = 2; |
| 2411 root->setContentsScale(deviceScaleFactor); | 2411 root->setIdealContentsScale(deviceScaleFactor); |
| 2412 renderSurface1->setContentsScale(deviceScaleFactor); | 2412 renderSurface1->setIdealContentsScale(deviceScaleFactor); |
| 2413 renderSurface2->setContentsScale(deviceScaleFactor); | 2413 renderSurface2->setIdealContentsScale(deviceScaleFactor); |
| 2414 child1->setContentsScale(deviceScaleFactor); | 2414 child1->setIdealContentsScale(deviceScaleFactor); |
| 2415 child2->setContentsScale(deviceScaleFactor); | 2415 child2->setIdealContentsScale(deviceScaleFactor); |
| 2416 child3->setContentsScale(deviceScaleFactor); | 2416 child3->setIdealContentsScale(deviceScaleFactor); |
| 2417 | 2417 |
| 2418 root->setMasksToBounds(true); | 2418 root->setMasksToBounds(true); |
| 2419 renderSurface1->setForceRenderSurface(true); | 2419 renderSurface1->setForceRenderSurface(true); |
| 2420 renderSurface2->setForceRenderSurface(true); | 2420 renderSurface2->setForceRenderSurface(true); |
| 2421 executeCalculateDrawProperties(root.get(), deviceScaleFactor); | 2421 executeCalculateDrawProperties(root.get(), deviceScaleFactor); |
| 2422 | 2422 |
| 2423 ASSERT_TRUE(renderSurface1->renderSurface()); | 2423 ASSERT_TRUE(renderSurface1->renderSurface()); |
| 2424 ASSERT_TRUE(renderSurface2->renderSurface()); | 2424 ASSERT_TRUE(renderSurface2->renderSurface()); |
| 2425 | 2425 |
| 2426 // DrawableContentRects for all layers and surfaces are scaled by deviceScal
eFactor. | 2426 // DrawableContentRects for all layers and surfaces are scaled by deviceScal
eFactor. |
| (...skipping 1544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3971 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 3971 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
| 3972 ASSERT_TRUE(resultLayer); | 3972 ASSERT_TRUE(resultLayer); |
| 3973 EXPECT_EQ(456, resultLayer->id()); | 3973 EXPECT_EQ(456, resultLayer->id()); |
| 3974 } | 3974 } |
| 3975 | 3975 |
| 3976 class NoScaleContentLayer : public ContentLayer | 3976 class NoScaleContentLayer : public ContentLayer |
| 3977 { | 3977 { |
| 3978 public: | 3978 public: |
| 3979 static scoped_refptr<NoScaleContentLayer> create(ContentLayerClient* client)
{ return make_scoped_refptr(new NoScaleContentLayer(client)); } | 3979 static scoped_refptr<NoScaleContentLayer> create(ContentLayerClient* client)
{ return make_scoped_refptr(new NoScaleContentLayer(client)); } |
| 3980 | 3980 |
| 3981 virtual gfx::Size contentBounds() const OVERRIDE { return bounds(); } | 3981 virtual void didUpdateBounds() OVERRIDE |
| 3982 virtual float contentsScaleX() const OVERRIDE { return 1.0; } | 3982 { |
| 3983 virtual float contentsScaleY() const OVERRIDE { return 1.0; } | 3983 Layer::didUpdateBounds(); |
| 3984 } |
| 3985 |
| 3986 virtual void setIdealContentsScale(float idealContentsScale) OVERRIDE |
| 3987 { |
| 3988 Layer::setIdealContentsScale(idealContentsScale); |
| 3989 } |
| 3984 | 3990 |
| 3985 protected: | 3991 protected: |
| 3986 explicit NoScaleContentLayer(ContentLayerClient* client) : ContentLayer(clie
nt) { } | 3992 explicit NoScaleContentLayer(ContentLayerClient* client) : ContentLayer(clie
nt) { } |
| 3987 virtual ~NoScaleContentLayer() { } | 3993 virtual ~NoScaleContentLayer() { } |
| 3988 }; | 3994 }; |
| 3989 | 3995 |
| 3990 scoped_refptr<NoScaleContentLayer> createNoScaleDrawableContentLayer(ContentLaye
rClient* delegate) | 3996 scoped_refptr<NoScaleContentLayer> createNoScaleDrawableContentLayer(ContentLaye
rClient* delegate) |
| 3991 { | 3997 { |
| 3992 scoped_refptr<NoScaleContentLayer> toReturn = NoScaleContentLayer::create(de
legate); | 3998 scoped_refptr<NoScaleContentLayer> toReturn = NoScaleContentLayer::create(de
legate); |
| 3993 toReturn->setIsDrawable(true); | 3999 toReturn->setIsDrawable(true); |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4527 setLayerPropertiesForTesting(duplicateChildNonOwner.get(), identityMatrix, i
dentityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), true); | 4533 setLayerPropertiesForTesting(duplicateChildNonOwner.get(), identityMatrix, i
dentityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), true); |
| 4528 | 4534 |
| 4529 parent->addChild(child); | 4535 parent->addChild(child); |
| 4530 child->addChild(duplicateChildNonOwner); | 4536 child->addChild(duplicateChildNonOwner); |
| 4531 child->setReplicaLayer(replica.get()); | 4537 child->setReplicaLayer(replica.get()); |
| 4532 | 4538 |
| 4533 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 4539 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
| 4534 int dummyMaxTextureSize = 512; | 4540 int dummyMaxTextureSize = 512; |
| 4535 | 4541 |
| 4536 const double deviceScaleFactor = 1.5; | 4542 const double deviceScaleFactor = 1.5; |
| 4537 parent->setContentsScale(deviceScaleFactor); | 4543 parent->setIdealContentsScale(deviceScaleFactor); |
| 4538 child->setContentsScale(deviceScaleFactor); | 4544 child->setIdealContentsScale(deviceScaleFactor); |
| 4539 duplicateChildNonOwner->setContentsScale(deviceScaleFactor); | 4545 duplicateChildNonOwner->setIdealContentsScale(deviceScaleFactor); |
| 4540 replica->setContentsScale(deviceScaleFactor); | 4546 replica->setIdealContentsScale(deviceScaleFactor); |
| 4541 | 4547 |
| 4542 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, 1, dummyMaxTextureSize, renderSurfaceLayerList); | 4548 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, 1, dummyMaxTextureSize, renderSurfaceLayerList); |
| 4543 | 4549 |
| 4544 // We should have two render surfaces. The root's render surface and child's | 4550 // We should have two render surfaces. The root's render surface and child's |
| 4545 // render surface (it needs one because it has a replica layer). | 4551 // render surface (it needs one because it has a replica layer). |
| 4546 EXPECT_EQ(2u, renderSurfaceLayerList.size()); | 4552 EXPECT_EQ(2u, renderSurfaceLayerList.size()); |
| 4547 | 4553 |
| 4548 gfx::Transform expectedParentTransform; | 4554 gfx::Transform expectedParentTransform; |
| 4549 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpace
Transform()); | 4555 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpace
Transform()); |
| 4550 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->drawTransfo
rm()); | 4556 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->drawTransfo
rm()); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4610 setLayerPropertiesForTesting(duplicateChildNonOwner.get(), identityMatrix, i
dentityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(13, 11), true); | 4616 setLayerPropertiesForTesting(duplicateChildNonOwner.get(), identityMatrix, i
dentityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(13, 11), true); |
| 4611 | 4617 |
| 4612 parent->addChild(child); | 4618 parent->addChild(child); |
| 4613 child->addChild(duplicateChildNonOwner); | 4619 child->addChild(duplicateChildNonOwner); |
| 4614 child->setReplicaLayer(replica.get()); | 4620 child->setReplicaLayer(replica.get()); |
| 4615 | 4621 |
| 4616 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 4622 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
| 4617 int dummyMaxTextureSize = 512; | 4623 int dummyMaxTextureSize = 512; |
| 4618 | 4624 |
| 4619 const float deviceScaleFactor = 1.7f; | 4625 const float deviceScaleFactor = 1.7f; |
| 4620 parent->setContentsScale(deviceScaleFactor); | 4626 parent->setIdealContentsScale(deviceScaleFactor); |
| 4621 child->setContentsScale(deviceScaleFactor); | 4627 child->setIdealContentsScale(deviceScaleFactor); |
| 4622 duplicateChildNonOwner->setContentsScale(deviceScaleFactor); | 4628 duplicateChildNonOwner->setIdealContentsScale(deviceScaleFactor); |
| 4623 replica->setContentsScale(deviceScaleFactor); | 4629 replica->setIdealContentsScale(deviceScaleFactor); |
| 4624 | 4630 |
| 4625 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, 1, dummyMaxTextureSize, renderSurfaceLayerList); | 4631 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, 1, dummyMaxTextureSize, renderSurfaceLayerList); |
| 4626 | 4632 |
| 4627 // We should have two render surfaces. The root's render surface and child's | 4633 // We should have two render surfaces. The root's render surface and child's |
| 4628 // render surface (it needs one because it has a replica layer). | 4634 // render surface (it needs one because it has a replica layer). |
| 4629 EXPECT_EQ(2u, renderSurfaceLayerList.size()); | 4635 EXPECT_EQ(2u, renderSurfaceLayerList.size()); |
| 4630 | 4636 |
| 4631 gfx::Transform identityTransform; | 4637 gfx::Transform identityTransform; |
| 4632 | 4638 |
| 4633 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, parent->screenSpaceTransf
orm()); | 4639 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, parent->screenSpaceTransf
orm()); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4689 child->addChild(grandChild); | 4695 child->addChild(grandChild); |
| 4690 child->setOpacity(0.5f); | 4696 child->setOpacity(0.5f); |
| 4691 | 4697 |
| 4692 executeCalculateDrawProperties(root.get()); | 4698 executeCalculateDrawProperties(root.get()); |
| 4693 | 4699 |
| 4694 EXPECT_FALSE(child->renderSurface()); | 4700 EXPECT_FALSE(child->renderSurface()); |
| 4695 } | 4701 } |
| 4696 | 4702 |
| 4697 } // namespace | 4703 } // namespace |
| 4698 } // namespace cc | 4704 } // namespace cc |
| OLD | NEW |