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); | |
2412 renderSurface1->setContentsScale(deviceScaleFactor); | |
2413 renderSurface2->setContentsScale(deviceScaleFactor); | |
2414 child1->setContentsScale(deviceScaleFactor); | |
2415 child2->setContentsScale(deviceScaleFactor); | |
2416 child3->setContentsScale(deviceScaleFactor); | |
2417 | 2411 |
2418 root->setMasksToBounds(true); | 2412 root->setMasksToBounds(true); |
2419 renderSurface1->setForceRenderSurface(true); | 2413 renderSurface1->setForceRenderSurface(true); |
2420 renderSurface2->setForceRenderSurface(true); | 2414 renderSurface2->setForceRenderSurface(true); |
2421 executeCalculateDrawProperties(root.get(), deviceScaleFactor); | 2415 executeCalculateDrawProperties(root.get(), deviceScaleFactor); |
2422 | 2416 |
2423 ASSERT_TRUE(renderSurface1->renderSurface()); | 2417 ASSERT_TRUE(renderSurface1->renderSurface()); |
2424 ASSERT_TRUE(renderSurface2->renderSurface()); | 2418 ASSERT_TRUE(renderSurface2->renderSurface()); |
2425 | 2419 |
2426 // DrawableContentRects for all layers and surfaces are scaled by deviceScal
eFactor. | 2420 // 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); | 3965 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
3972 ASSERT_TRUE(resultLayer); | 3966 ASSERT_TRUE(resultLayer); |
3973 EXPECT_EQ(456, resultLayer->id()); | 3967 EXPECT_EQ(456, resultLayer->id()); |
3974 } | 3968 } |
3975 | 3969 |
3976 class NoScaleContentLayer : public ContentLayer | 3970 class NoScaleContentLayer : public ContentLayer |
3977 { | 3971 { |
3978 public: | 3972 public: |
3979 static scoped_refptr<NoScaleContentLayer> create(ContentLayerClient* client)
{ return make_scoped_refptr(new NoScaleContentLayer(client)); } | 3973 static scoped_refptr<NoScaleContentLayer> create(ContentLayerClient* client)
{ return make_scoped_refptr(new NoScaleContentLayer(client)); } |
3980 | 3974 |
3981 virtual gfx::Size contentBounds() const OVERRIDE { return bounds(); } | 3975 virtual void calculateContentsScale( |
3982 virtual float contentsScaleX() const OVERRIDE { return 1.0; } | 3976 float idealContentsScale, |
3983 virtual float contentsScaleY() const OVERRIDE { return 1.0; } | 3977 float* contentsScaleX, |
| 3978 float* contentsScaleY, |
| 3979 gfx::Size* contentBounds) OVERRIDE |
| 3980 { |
| 3981 Layer::calculateContentsScale( |
| 3982 idealContentsScale, |
| 3983 contentsScaleX, |
| 3984 contentsScaleY, |
| 3985 contentBounds); |
| 3986 } |
3984 | 3987 |
3985 protected: | 3988 protected: |
3986 explicit NoScaleContentLayer(ContentLayerClient* client) : ContentLayer(clie
nt) { } | 3989 explicit NoScaleContentLayer(ContentLayerClient* client) : ContentLayer(clie
nt) { } |
3987 virtual ~NoScaleContentLayer() { } | 3990 virtual ~NoScaleContentLayer() { } |
3988 }; | 3991 }; |
3989 | 3992 |
3990 scoped_refptr<NoScaleContentLayer> createNoScaleDrawableContentLayer(ContentLaye
rClient* delegate) | 3993 scoped_refptr<NoScaleContentLayer> createNoScaleDrawableContentLayer(ContentLaye
rClient* delegate) |
3991 { | 3994 { |
3992 scoped_refptr<NoScaleContentLayer> toReturn = NoScaleContentLayer::create(de
legate); | 3995 scoped_refptr<NoScaleContentLayer> toReturn = NoScaleContentLayer::create(de
legate); |
3993 toReturn->setIsDrawable(true); | 3996 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); | 4530 setLayerPropertiesForTesting(duplicateChildNonOwner.get(), identityMatrix, i
dentityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), true); |
4528 | 4531 |
4529 parent->addChild(child); | 4532 parent->addChild(child); |
4530 child->addChild(duplicateChildNonOwner); | 4533 child->addChild(duplicateChildNonOwner); |
4531 child->setReplicaLayer(replica.get()); | 4534 child->setReplicaLayer(replica.get()); |
4532 | 4535 |
4533 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 4536 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
4534 int dummyMaxTextureSize = 512; | 4537 int dummyMaxTextureSize = 512; |
4535 | 4538 |
4536 const double deviceScaleFactor = 1.5; | 4539 const double deviceScaleFactor = 1.5; |
4537 parent->setContentsScale(deviceScaleFactor); | |
4538 child->setContentsScale(deviceScaleFactor); | |
4539 duplicateChildNonOwner->setContentsScale(deviceScaleFactor); | |
4540 replica->setContentsScale(deviceScaleFactor); | |
4541 | |
4542 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); | 4540 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); |
4543 | 4541 |
4544 // We should have two render surfaces. The root's render surface and child's | 4542 // 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). | 4543 // render surface (it needs one because it has a replica layer). |
4546 EXPECT_EQ(2u, renderSurfaceLayerList.size()); | 4544 EXPECT_EQ(2u, renderSurfaceLayerList.size()); |
4547 | 4545 |
4548 gfx::Transform expectedParentTransform; | 4546 gfx::Transform expectedParentTransform; |
4549 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpace
Transform()); | 4547 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpace
Transform()); |
4550 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->drawTransfo
rm()); | 4548 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->drawTransfo
rm()); |
4551 | 4549 |
(...skipping 58 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); | 4608 setLayerPropertiesForTesting(duplicateChildNonOwner.get(), identityMatrix, i
dentityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(13, 11), true); |
4611 | 4609 |
4612 parent->addChild(child); | 4610 parent->addChild(child); |
4613 child->addChild(duplicateChildNonOwner); | 4611 child->addChild(duplicateChildNonOwner); |
4614 child->setReplicaLayer(replica.get()); | 4612 child->setReplicaLayer(replica.get()); |
4615 | 4613 |
4616 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 4614 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
4617 int dummyMaxTextureSize = 512; | 4615 int dummyMaxTextureSize = 512; |
4618 | 4616 |
4619 const float deviceScaleFactor = 1.7f; | 4617 const float deviceScaleFactor = 1.7f; |
4620 parent->setContentsScale(deviceScaleFactor); | |
4621 child->setContentsScale(deviceScaleFactor); | |
4622 duplicateChildNonOwner->setContentsScale(deviceScaleFactor); | |
4623 replica->setContentsScale(deviceScaleFactor); | |
4624 | |
4625 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); | 4618 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); |
4626 | 4619 |
4627 // We should have two render surfaces. The root's render surface and child's | 4620 // 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). | 4621 // render surface (it needs one because it has a replica layer). |
4629 EXPECT_EQ(2u, renderSurfaceLayerList.size()); | 4622 EXPECT_EQ(2u, renderSurfaceLayerList.size()); |
4630 | 4623 |
4631 gfx::Transform identityTransform; | 4624 gfx::Transform identityTransform; |
4632 | 4625 |
4633 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, parent->screenSpaceTransf
orm()); | 4626 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, parent->screenSpaceTransf
orm()); |
4634 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, parent->drawTransform()); | 4627 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, parent->drawTransform()); |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4812 EXPECT_EQ(m_canUseLCDText, m_grandChild->canUseLCDText()); | 4805 EXPECT_EQ(m_canUseLCDText, m_grandChild->canUseLCDText()); |
4813 } | 4806 } |
4814 | 4807 |
4815 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, | 4808 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, |
4816 LCDTextTest, | 4809 LCDTextTest, |
4817 testing::Combine(testing::Bool(), | 4810 testing::Combine(testing::Bool(), |
4818 testing::Bool())); | 4811 testing::Bool())); |
4819 | 4812 |
4820 } // namespace | 4813 } // namespace |
4821 } // namespace cc | 4814 } // namespace cc |
OLD | NEW |