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/trees/layer_tree_host_common.h" | 5 #include "cc/trees/layer_tree_host_common.h" |
6 | 6 |
7 #include "cc/animation/layer_animation_controller.h" | 7 #include "cc/animation/layer_animation_controller.h" |
8 #include "cc/base/math_util.h" | 8 #include "cc/base/math_util.h" |
9 #include "cc/base/thread.h" | 9 #include "cc/base/thread.h" |
10 #include "cc/layers/content_layer.h" | 10 #include "cc/layers/content_layer.h" |
(...skipping 1609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1620 | 1620 |
1621 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 1621 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
1622 int dummyMaxTextureSize = 512; | 1622 int dummyMaxTextureSize = 512; |
1623 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); | 1623 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); |
1624 | 1624 |
1625 // Without an animation, we should cull child and grandChild from the render
SurfaceLayerList. | 1625 // Without an animation, we should cull child and grandChild from the render
SurfaceLayerList. |
1626 ASSERT_EQ(1U, renderSurfaceLayerList.size()); | 1626 ASSERT_EQ(1U, renderSurfaceLayerList.size()); |
1627 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); | 1627 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); |
1628 | 1628 |
1629 // Now put an animating transform on child. | 1629 // Now put an animating transform on child. |
1630 addAnimatedTransformToController(*child->layer_animation_controller(), 10, 3
0, 0); | 1630 AddAnimatedTransformToController(child->layer_animation_controller(), 10, 30
, 0); |
1631 | 1631 |
1632 parent->ClearRenderSurface(); | 1632 parent->ClearRenderSurface(); |
1633 child->ClearRenderSurface(); | 1633 child->ClearRenderSurface(); |
1634 grandChild->ClearRenderSurface(); | 1634 grandChild->ClearRenderSurface(); |
1635 renderSurfaceLayerList.clear(); | 1635 renderSurfaceLayerList.clear(); |
1636 | 1636 |
1637 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); | 1637 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); |
1638 | 1638 |
1639 // With an animating transform, we should keep child and grandChild in the r
enderSurfaceLayerList. | 1639 // With an animating transform, we should keep child and grandChild in the r
enderSurfaceLayerList. |
1640 ASSERT_EQ(3U, renderSurfaceLayerList.size()); | 1640 ASSERT_EQ(3U, renderSurfaceLayerList.size()); |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1902 setLayerPropertiesForTesting(renderSurface1.get(), layerTransform, sublayerT
ransform, gfx::PointF(0.25, 0), gfx::PointF(2.5, 0), gfx::Size(10, 10), false); | 1902 setLayerPropertiesForTesting(renderSurface1.get(), layerTransform, sublayerT
ransform, gfx::PointF(0.25, 0), gfx::PointF(2.5, 0), gfx::Size(10, 10), false); |
1903 setLayerPropertiesForTesting(renderSurface2.get(), layerTransform, sublayerT
ransform, gfx::PointF(0.25, 0), gfx::PointF(2.5, 0), gfx::Size(10, 10), false); | 1903 setLayerPropertiesForTesting(renderSurface2.get(), layerTransform, sublayerT
ransform, gfx::PointF(0.25, 0), gfx::PointF(2.5, 0), gfx::Size(10, 10), false); |
1904 setLayerPropertiesForTesting(childOfRoot.get(), layerTransform, sublayerTran
sform, gfx::PointF(0.25, 0), gfx::PointF(2.5, 0), gfx::Size(10, 10), false); | 1904 setLayerPropertiesForTesting(childOfRoot.get(), layerTransform, sublayerTran
sform, gfx::PointF(0.25, 0), gfx::PointF(2.5, 0), gfx::Size(10, 10), false); |
1905 setLayerPropertiesForTesting(childOfRS1.get(), layerTransform, sublayerTrans
form, gfx::PointF(0.25, 0), gfx::PointF(2.5, 0), gfx::Size(10, 10), false); | 1905 setLayerPropertiesForTesting(childOfRS1.get(), layerTransform, sublayerTrans
form, gfx::PointF(0.25, 0), gfx::PointF(2.5, 0), gfx::Size(10, 10), false); |
1906 setLayerPropertiesForTesting(childOfRS2.get(), layerTransform, sublayerTrans
form, gfx::PointF(0.25, 0), gfx::PointF(2.5, 0), gfx::Size(10, 10), false); | 1906 setLayerPropertiesForTesting(childOfRS2.get(), layerTransform, sublayerTrans
form, gfx::PointF(0.25, 0), gfx::PointF(2.5, 0), gfx::Size(10, 10), false); |
1907 setLayerPropertiesForTesting(grandChildOfRoot.get(), layerTransform, sublaye
rTransform, gfx::PointF(0.25, 0), gfx::PointF(2.5, 0), gfx::Size(10, 10), false)
; | 1907 setLayerPropertiesForTesting(grandChildOfRoot.get(), layerTransform, sublaye
rTransform, gfx::PointF(0.25, 0), gfx::PointF(2.5, 0), gfx::Size(10, 10), false)
; |
1908 setLayerPropertiesForTesting(grandChildOfRS1.get(), layerTransform, sublayer
Transform, gfx::PointF(0.25, 0), gfx::PointF(2.5, 0), gfx::Size(10, 10), false); | 1908 setLayerPropertiesForTesting(grandChildOfRS1.get(), layerTransform, sublayer
Transform, gfx::PointF(0.25, 0), gfx::PointF(2.5, 0), gfx::Size(10, 10), false); |
1909 setLayerPropertiesForTesting(grandChildOfRS2.get(), layerTransform, sublayer
Transform, gfx::PointF(0.25, 0), gfx::PointF(2.5, 0), gfx::Size(10, 10), false); | 1909 setLayerPropertiesForTesting(grandChildOfRS2.get(), layerTransform, sublayer
Transform, gfx::PointF(0.25, 0), gfx::PointF(2.5, 0), gfx::Size(10, 10), false); |
1910 | 1910 |
1911 // Put an animated opacity on the render surface. | 1911 // Put an animated opacity on the render surface. |
1912 addOpacityTransitionToController(*renderSurface1->layer_animation_controller
(), 10, 1, 0, false); | 1912 AddOpacityTransitionToController(renderSurface1->layer_animation_controller(
), 10, 1, 0, false); |
1913 | 1913 |
1914 // Also put an animated opacity on a layer without descendants. | 1914 // Also put an animated opacity on a layer without descendants. |
1915 addOpacityTransitionToController(*grandChildOfRoot->layer_animation_controll
er(), 10, 1, 0, false); | 1915 AddOpacityTransitionToController(grandChildOfRoot->layer_animation_controlle
r(), 10, 1, 0, false); |
1916 | 1916 |
1917 // Put a transform animation on the render surface. | 1917 // Put a transform animation on the render surface. |
1918 addAnimatedTransformToController(*renderSurface2->layer_animation_controller
(), 10, 30, 0); | 1918 AddAnimatedTransformToController(renderSurface2->layer_animation_controller(
), 10, 30, 0); |
1919 | 1919 |
1920 // Also put transform animations on grandChildOfRoot, and grandChildOfRS2 | 1920 // Also put transform animations on grandChildOfRoot, and grandChildOfRS2 |
1921 addAnimatedTransformToController(*grandChildOfRoot->layer_animation_controll
er(), 10, 30, 0); | 1921 AddAnimatedTransformToController(grandChildOfRoot->layer_animation_controlle
r(), 10, 30, 0); |
1922 addAnimatedTransformToController(*grandChildOfRS2->layer_animation_controlle
r(), 10, 30, 0); | 1922 AddAnimatedTransformToController(grandChildOfRS2->layer_animation_controller
(), 10, 30, 0); |
1923 | 1923 |
1924 executeCalculateDrawProperties(parent.get()); | 1924 executeCalculateDrawProperties(parent.get()); |
1925 | 1925 |
1926 // Only layers that are associated with render surfaces should have an actua
l RenderSurface() value. | 1926 // Only layers that are associated with render surfaces should have an actua
l RenderSurface() value. |
1927 // | 1927 // |
1928 ASSERT_TRUE(parent->render_surface()); | 1928 ASSERT_TRUE(parent->render_surface()); |
1929 ASSERT_FALSE(childOfRoot->render_surface()); | 1929 ASSERT_FALSE(childOfRoot->render_surface()); |
1930 ASSERT_FALSE(grandChildOfRoot->render_surface()); | 1930 ASSERT_FALSE(grandChildOfRoot->render_surface()); |
1931 | 1931 |
1932 ASSERT_TRUE(renderSurface1->render_surface()); | 1932 ASSERT_TRUE(renderSurface1->render_surface()); |
(...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2851 | 2851 |
2852 gfx::Transform backfaceMatrix; | 2852 gfx::Transform backfaceMatrix; |
2853 backfaceMatrix.Translate(50, 50); | 2853 backfaceMatrix.Translate(50, 50); |
2854 backfaceMatrix.RotateAboutYAxis(180); | 2854 backfaceMatrix.RotateAboutYAxis(180); |
2855 backfaceMatrix.Translate(-50, -50); | 2855 backfaceMatrix.Translate(-50, -50); |
2856 | 2856 |
2857 // Make our render surface. | 2857 // Make our render surface. |
2858 animatingSurface->SetForceRenderSurface(true); | 2858 animatingSurface->SetForceRenderSurface(true); |
2859 | 2859 |
2860 // Animate the transform on the render surface. | 2860 // Animate the transform on the render surface. |
2861 addAnimatedTransformToController(*animatingSurface->layer_animation_controll
er(), 10, 30, 0); | 2861 AddAnimatedTransformToController(animatingSurface->layer_animation_controlle
r(), 10, 30, 0); |
2862 // This is just an animating layer, not a surface. | 2862 // This is just an animating layer, not a surface. |
2863 addAnimatedTransformToController(*animatingChild->layer_animation_controller
(), 10, 30, 0); | 2863 AddAnimatedTransformToController(animatingChild->layer_animation_controller(
), 10, 30, 0); |
2864 | 2864 |
2865 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2865 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
2866 setLayerPropertiesForTesting(child.get(), backfaceMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2866 setLayerPropertiesForTesting(child.get(), backfaceMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
2867 setLayerPropertiesForTesting(animatingSurface.get(), backfaceMatrix, identit
yMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2867 setLayerPropertiesForTesting(animatingSurface.get(), backfaceMatrix, identit
yMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
2868 setLayerPropertiesForTesting(childOfAnimatingSurface.get(), backfaceMatrix,
identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false
); | 2868 setLayerPropertiesForTesting(childOfAnimatingSurface.get(), backfaceMatrix,
identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false
); |
2869 setLayerPropertiesForTesting(animatingChild.get(), backfaceMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2869 setLayerPropertiesForTesting(animatingChild.get(), backfaceMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
2870 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2870 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
2871 | 2871 |
2872 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 2872 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
2873 int dummyMaxTextureSize = 512; | 2873 int dummyMaxTextureSize = 512; |
(...skipping 1942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4816 | 4816 |
4817 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); | 4817 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); |
4818 setLayerPropertiesForTesting(parent.get(), parentScaleMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); | 4818 setLayerPropertiesForTesting(parent.get(), parentScaleMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); |
4819 | 4819 |
4820 scoped_refptr<ContentLayer> childScale = createDrawableContentLayer(&delegat
e); | 4820 scoped_refptr<ContentLayer> childScale = createDrawableContentLayer(&delegat
e); |
4821 setLayerPropertiesForTesting(childScale.get(), childScaleMatrix, identityMat
rix, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); | 4821 setLayerPropertiesForTesting(childScale.get(), childScaleMatrix, identityMat
rix, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); |
4822 | 4822 |
4823 parent->AddChild(childScale); | 4823 parent->AddChild(childScale); |
4824 | 4824 |
4825 // Now put an animating transform on child. | 4825 // Now put an animating transform on child. |
4826 int animationId = addAnimatedTransformToController(*childScale->layer_animat
ion_controller(), 10, 30, 0); | 4826 int animationId = AddAnimatedTransformToController(childScale->layer_animati
on_controller(), 10, 30, 0); |
4827 | 4827 |
4828 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 4828 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
4829 int dummyMaxTextureSize = 512; | 4829 int dummyMaxTextureSize = 512; |
4830 | 4830 |
4831 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); | 4831 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); |
4832 | 4832 |
4833 EXPECT_CONTENTS_SCALE_EQ(initialParentScale, parent); | 4833 EXPECT_CONTENTS_SCALE_EQ(initialParentScale, parent); |
4834 // The layers with animating transforms should not compute a contentsScale o
ther than 1 until they finish animating. | 4834 // The layers with animating transforms should not compute a contentsScale o
ther than 1 until they finish animating. |
4835 EXPECT_CONTENTS_SCALE_EQ(1, childScale); | 4835 EXPECT_CONTENTS_SCALE_EQ(1, childScale); |
4836 | 4836 |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5125 TEST_P(LCDTextTest, verifycan_use_lcd_textWithAnimation) | 5125 TEST_P(LCDTextTest, verifycan_use_lcd_textWithAnimation) |
5126 { | 5126 { |
5127 // Sanity check: Make sure m_canUseLCDText is set on each node. | 5127 // Sanity check: Make sure m_canUseLCDText is set on each node. |
5128 executeCalculateDrawProperties(m_root, 1, 1, m_canUseLCDText); | 5128 executeCalculateDrawProperties(m_root, 1, 1, m_canUseLCDText); |
5129 EXPECT_EQ(m_canUseLCDText, m_root->can_use_lcd_text()); | 5129 EXPECT_EQ(m_canUseLCDText, m_root->can_use_lcd_text()); |
5130 EXPECT_EQ(m_canUseLCDText, m_child->can_use_lcd_text()); | 5130 EXPECT_EQ(m_canUseLCDText, m_child->can_use_lcd_text()); |
5131 EXPECT_EQ(m_canUseLCDText, m_grandChild->can_use_lcd_text()); | 5131 EXPECT_EQ(m_canUseLCDText, m_grandChild->can_use_lcd_text()); |
5132 | 5132 |
5133 // Add opacity animation. | 5133 // Add opacity animation. |
5134 m_child->SetOpacity(0.9f); | 5134 m_child->SetOpacity(0.9f); |
5135 addOpacityTransitionToController(*(m_child->layer_animation_controller()), 1
0, 0.9f, 0.1f, false); | 5135 AddOpacityTransitionToController(m_child->layer_animation_controller(), 10,
0.9f, 0.1f, false); |
5136 | 5136 |
5137 executeCalculateDrawProperties(m_root, 1, 1, m_canUseLCDText); | 5137 executeCalculateDrawProperties(m_root, 1, 1, m_canUseLCDText); |
5138 // Text AA should not be adjusted while animation is active. | 5138 // Text AA should not be adjusted while animation is active. |
5139 // Make sure LCD text AA setting remains unchanged. | 5139 // Make sure LCD text AA setting remains unchanged. |
5140 EXPECT_EQ(m_canUseLCDText, m_root->can_use_lcd_text()); | 5140 EXPECT_EQ(m_canUseLCDText, m_root->can_use_lcd_text()); |
5141 EXPECT_EQ(m_canUseLCDText, m_child->can_use_lcd_text()); | 5141 EXPECT_EQ(m_canUseLCDText, m_child->can_use_lcd_text()); |
5142 EXPECT_EQ(m_canUseLCDText, m_grandChild->can_use_lcd_text()); | 5142 EXPECT_EQ(m_canUseLCDText, m_grandChild->can_use_lcd_text()); |
5143 } | 5143 } |
5144 | 5144 |
5145 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, | 5145 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, |
5146 LCDTextTest, | 5146 LCDTextTest, |
5147 testing::Combine(testing::Bool(), | 5147 testing::Combine(testing::Bool(), |
5148 testing::Bool())); | 5148 testing::Bool())); |
5149 | 5149 |
5150 } // namespace | 5150 } // namespace |
5151 } // namespace cc | 5151 } // namespace cc |
OLD | NEW |