| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 } | 95 } |
| 96 | 96 |
| 97 CompositorAnimationPlayer* compositorPlayer() const override { | 97 CompositorAnimationPlayer* compositorPlayer() const override { |
| 98 return m_compositorPlayer.get(); | 98 return m_compositorPlayer.get(); |
| 99 } | 99 } |
| 100 | 100 |
| 101 std::unique_ptr<CompositorAnimationPlayer> m_compositorPlayer; | 101 std::unique_ptr<CompositorAnimationPlayer> m_compositorPlayer; |
| 102 }; | 102 }; |
| 103 | 103 |
| 104 TEST_F(GraphicsLayerTest, updateLayerShouldFlattenTransformWithAnimations) { | 104 TEST_F(GraphicsLayerTest, updateLayerShouldFlattenTransformWithAnimations) { |
| 105 ASSERT_FALSE(m_platformLayer->hasActiveAnimationForTesting()); | 105 ASSERT_FALSE(m_platformLayer->hasTickingAnimationForTesting()); |
| 106 | 106 |
| 107 std::unique_ptr<CompositorFloatAnimationCurve> curve = | 107 std::unique_ptr<CompositorFloatAnimationCurve> curve = |
| 108 CompositorFloatAnimationCurve::create(); | 108 CompositorFloatAnimationCurve::create(); |
| 109 curve->addKeyframe(CompositorFloatKeyframe( | 109 curve->addKeyframe(CompositorFloatKeyframe( |
| 110 0.0, 0.0, *CubicBezierTimingFunction::preset( | 110 0.0, 0.0, *CubicBezierTimingFunction::preset( |
| 111 CubicBezierTimingFunction::EaseType::EASE))); | 111 CubicBezierTimingFunction::EaseType::EASE))); |
| 112 std::unique_ptr<CompositorAnimation> floatAnimation( | 112 std::unique_ptr<CompositorAnimation> floatAnimation( |
| 113 CompositorAnimation::create(*curve, CompositorTargetProperty::OPACITY, 0, | 113 CompositorAnimation::create(*curve, CompositorTargetProperty::OPACITY, 0, |
| 114 0)); | 114 0)); |
| 115 int animationId = floatAnimation->id(); | 115 int animationId = floatAnimation->id(); |
| 116 | 116 |
| 117 std::unique_ptr<CompositorAnimationTimeline> compositorTimeline = | 117 std::unique_ptr<CompositorAnimationTimeline> compositorTimeline = |
| 118 CompositorAnimationTimeline::create(); | 118 CompositorAnimationTimeline::create(); |
| 119 AnimationPlayerForTesting player; | 119 AnimationPlayerForTesting player; |
| 120 | 120 |
| 121 layerTreeView()->attachCompositorAnimationTimeline( | 121 layerTreeView()->attachCompositorAnimationTimeline( |
| 122 compositorTimeline->animationTimeline()); | 122 compositorTimeline->animationTimeline()); |
| 123 compositorTimeline->playerAttached(player); | 123 compositorTimeline->playerAttached(player); |
| 124 | 124 |
| 125 m_platformLayer->setElementId(CompositorElementId(m_platformLayer->id(), 0)); | 125 m_platformLayer->setElementId(CompositorElementId(m_platformLayer->id(), 0)); |
| 126 | 126 |
| 127 player.compositorPlayer()->attachElement(m_platformLayer->elementId()); | 127 player.compositorPlayer()->attachElement(m_platformLayer->elementId()); |
| 128 ASSERT_TRUE(player.compositorPlayer()->isElementAttached()); | 128 ASSERT_TRUE(player.compositorPlayer()->isElementAttached()); |
| 129 | 129 |
| 130 player.compositorPlayer()->addAnimation(std::move(floatAnimation)); | 130 player.compositorPlayer()->addAnimation(std::move(floatAnimation)); |
| 131 | 131 |
| 132 ASSERT_TRUE(m_platformLayer->hasActiveAnimationForTesting()); | 132 ASSERT_TRUE(m_platformLayer->hasTickingAnimationForTesting()); |
| 133 | 133 |
| 134 m_graphicsLayer->setShouldFlattenTransform(false); | 134 m_graphicsLayer->setShouldFlattenTransform(false); |
| 135 | 135 |
| 136 m_platformLayer = m_graphicsLayer->platformLayer(); | 136 m_platformLayer = m_graphicsLayer->platformLayer(); |
| 137 ASSERT_TRUE(m_platformLayer); | 137 ASSERT_TRUE(m_platformLayer); |
| 138 | 138 |
| 139 ASSERT_TRUE(m_platformLayer->hasActiveAnimationForTesting()); | 139 ASSERT_TRUE(m_platformLayer->hasTickingAnimationForTesting()); |
| 140 player.compositorPlayer()->removeAnimation(animationId); | 140 player.compositorPlayer()->removeAnimation(animationId); |
| 141 ASSERT_FALSE(m_platformLayer->hasActiveAnimationForTesting()); | 141 ASSERT_FALSE(m_platformLayer->hasTickingAnimationForTesting()); |
| 142 | 142 |
| 143 m_graphicsLayer->setShouldFlattenTransform(true); | 143 m_graphicsLayer->setShouldFlattenTransform(true); |
| 144 | 144 |
| 145 m_platformLayer = m_graphicsLayer->platformLayer(); | 145 m_platformLayer = m_graphicsLayer->platformLayer(); |
| 146 ASSERT_TRUE(m_platformLayer); | 146 ASSERT_TRUE(m_platformLayer); |
| 147 | 147 |
| 148 ASSERT_FALSE(m_platformLayer->hasActiveAnimationForTesting()); | 148 ASSERT_FALSE(m_platformLayer->hasTickingAnimationForTesting()); |
| 149 | 149 |
| 150 player.compositorPlayer()->detachElement(); | 150 player.compositorPlayer()->detachElement(); |
| 151 ASSERT_FALSE(player.compositorPlayer()->isElementAttached()); | 151 ASSERT_FALSE(player.compositorPlayer()->isElementAttached()); |
| 152 | 152 |
| 153 compositorTimeline->playerDestroyed(player); | 153 compositorTimeline->playerDestroyed(player); |
| 154 layerTreeView()->detachCompositorAnimationTimeline( | 154 layerTreeView()->detachCompositorAnimationTimeline( |
| 155 compositorTimeline->animationTimeline()); | 155 compositorTimeline->animationTimeline()); |
| 156 } | 156 } |
| 157 | 157 |
| 158 class FakeScrollableArea : public GarbageCollectedFinalized<FakeScrollableArea>, | 158 class FakeScrollableArea : public GarbageCollectedFinalized<FakeScrollableArea>, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 | 203 |
| 204 WebDoublePoint scrollPosition(7, 9); | 204 WebDoublePoint scrollPosition(7, 9); |
| 205 m_platformLayer->setScrollPositionDouble(scrollPosition); | 205 m_platformLayer->setScrollPositionDouble(scrollPosition); |
| 206 m_graphicsLayer->didScroll(); | 206 m_graphicsLayer->didScroll(); |
| 207 | 207 |
| 208 EXPECT_FLOAT_EQ(scrollPosition.x, scrollableArea->scrollOffset().width()); | 208 EXPECT_FLOAT_EQ(scrollPosition.x, scrollableArea->scrollOffset().width()); |
| 209 EXPECT_FLOAT_EQ(scrollPosition.y, scrollableArea->scrollOffset().height()); | 209 EXPECT_FLOAT_EQ(scrollPosition.y, scrollableArea->scrollOffset().height()); |
| 210 } | 210 } |
| 211 | 211 |
| 212 } // namespace blink | 212 } // namespace blink |
| OLD | NEW |