| 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 11 matching lines...) Expand all Loading... |
| 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 23 */ | 23 */ |
| 24 | 24 |
| 25 #include "platform/graphics/GraphicsLayer.h" | 25 #include "platform/graphics/GraphicsLayer.h" |
| 26 | 26 |
| 27 #include "platform/RuntimeEnabledFeatures.h" | 27 #include "platform/RuntimeEnabledFeatures.h" |
| 28 #include "platform/animation/CompositorAnimationPlayer.h" | 28 #include "platform/animation/CompositorAnimationPlayer.h" |
| 29 #include "platform/animation/CompositorAnimationPlayerClient.h" | 29 #include "platform/animation/CompositorAnimationPlayerClient.h" |
| 30 #include "platform/animation/CompositorAnimationTimeline.h" | 30 #include "platform/animation/CompositorAnimationTimeline.h" |
| 31 #include "platform/animation/CompositorFloatAnimationCurve.h" | 31 #include "platform/animation/CompositorFloatAnimationCurve.h" |
| 32 #include "platform/graphics/CompositorElementId.h" |
| 32 #include "platform/graphics/CompositorFactory.h" | 33 #include "platform/graphics/CompositorFactory.h" |
| 33 #include "platform/scroll/ScrollableArea.h" | 34 #include "platform/scroll/ScrollableArea.h" |
| 34 #include "platform/testing/FakeGraphicsLayer.h" | 35 #include "platform/testing/FakeGraphicsLayer.h" |
| 35 #include "platform/testing/FakeGraphicsLayerClient.h" | 36 #include "platform/testing/FakeGraphicsLayerClient.h" |
| 36 #include "platform/testing/WebLayerTreeViewImplForTesting.h" | 37 #include "platform/testing/WebLayerTreeViewImplForTesting.h" |
| 37 #include "platform/transforms/Matrix3DTransformOperation.h" | 38 #include "platform/transforms/Matrix3DTransformOperation.h" |
| 38 #include "platform/transforms/RotateTransformOperation.h" | 39 #include "platform/transforms/RotateTransformOperation.h" |
| 39 #include "platform/transforms/TranslateTransformOperation.h" | 40 #include "platform/transforms/TranslateTransformOperation.h" |
| 40 #include "public/platform/Platform.h" | 41 #include "public/platform/Platform.h" |
| 41 #include "public/platform/WebCompositorSupport.h" | 42 #include "public/platform/WebCompositorSupport.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 curve->addCubicBezierKeyframe(CompositorFloatKeyframe(0.0, 0.0), CubicBezier
TimingFunction::EaseType::EASE); | 109 curve->addCubicBezierKeyframe(CompositorFloatKeyframe(0.0, 0.0), CubicBezier
TimingFunction::EaseType::EASE); |
| 109 OwnPtr<CompositorAnimation> floatAnimation(adoptPtr(CompositorFactory::curre
nt().createAnimation(*curve, CompositorTargetProperty::OPACITY))); | 110 OwnPtr<CompositorAnimation> floatAnimation(adoptPtr(CompositorFactory::curre
nt().createAnimation(*curve, CompositorTargetProperty::OPACITY))); |
| 110 int animationId = floatAnimation->id(); | 111 int animationId = floatAnimation->id(); |
| 111 | 112 |
| 112 OwnPtr<CompositorAnimationTimeline> compositorTimeline = adoptPtr(Compositor
Factory::current().createAnimationTimeline()); | 113 OwnPtr<CompositorAnimationTimeline> compositorTimeline = adoptPtr(Compositor
Factory::current().createAnimationTimeline()); |
| 113 AnimationPlayerForTesting player; | 114 AnimationPlayerForTesting player; |
| 114 | 115 |
| 115 layerTreeView()->attachCompositorAnimationTimeline(compositorTimeline->anima
tionTimeline()); | 116 layerTreeView()->attachCompositorAnimationTimeline(compositorTimeline->anima
tionTimeline()); |
| 116 compositorTimeline->playerAttached(player); | 117 compositorTimeline->playerAttached(player); |
| 117 | 118 |
| 118 player.compositorPlayer()->attachLayer(m_platformLayer); | 119 m_platformLayer->setElementId(CompositorElementId(m_platformLayer->id())); |
| 119 ASSERT_TRUE(player.compositorPlayer()->isLayerAttached()); | 120 |
| 121 player.compositorPlayer()->attachElement(m_platformLayer->elementId()); |
| 122 ASSERT_TRUE(player.compositorPlayer()->isElementAttached()); |
| 120 | 123 |
| 121 player.compositorPlayer()->addAnimation(floatAnimation.leakPtr()); | 124 player.compositorPlayer()->addAnimation(floatAnimation.leakPtr()); |
| 122 | 125 |
| 123 ASSERT_TRUE(m_platformLayer->hasActiveAnimationForTesting()); | 126 ASSERT_TRUE(m_platformLayer->hasActiveAnimationForTesting()); |
| 124 | 127 |
| 125 m_graphicsLayer->setShouldFlattenTransform(false); | 128 m_graphicsLayer->setShouldFlattenTransform(false); |
| 126 | 129 |
| 127 m_platformLayer = m_graphicsLayer->platformLayer(); | 130 m_platformLayer = m_graphicsLayer->platformLayer(); |
| 128 ASSERT_TRUE(m_platformLayer); | 131 ASSERT_TRUE(m_platformLayer); |
| 129 | 132 |
| 130 ASSERT_TRUE(m_platformLayer->hasActiveAnimationForTesting()); | 133 ASSERT_TRUE(m_platformLayer->hasActiveAnimationForTesting()); |
| 131 player.compositorPlayer()->removeAnimation(animationId); | 134 player.compositorPlayer()->removeAnimation(animationId); |
| 132 ASSERT_FALSE(m_platformLayer->hasActiveAnimationForTesting()); | 135 ASSERT_FALSE(m_platformLayer->hasActiveAnimationForTesting()); |
| 133 | 136 |
| 134 m_graphicsLayer->setShouldFlattenTransform(true); | 137 m_graphicsLayer->setShouldFlattenTransform(true); |
| 135 | 138 |
| 136 m_platformLayer = m_graphicsLayer->platformLayer(); | 139 m_platformLayer = m_graphicsLayer->platformLayer(); |
| 137 ASSERT_TRUE(m_platformLayer); | 140 ASSERT_TRUE(m_platformLayer); |
| 138 | 141 |
| 139 ASSERT_FALSE(m_platformLayer->hasActiveAnimationForTesting()); | 142 ASSERT_FALSE(m_platformLayer->hasActiveAnimationForTesting()); |
| 140 | 143 |
| 141 player.compositorPlayer()->detachLayer(); | 144 player.compositorPlayer()->detachElement(); |
| 142 ASSERT_FALSE(player.compositorPlayer()->isLayerAttached()); | 145 ASSERT_FALSE(player.compositorPlayer()->isElementAttached()); |
| 143 | 146 |
| 144 compositorTimeline->playerDestroyed(player); | 147 compositorTimeline->playerDestroyed(player); |
| 145 layerTreeView()->detachCompositorAnimationTimeline(compositorTimeline->anima
tionTimeline()); | 148 layerTreeView()->detachCompositorAnimationTimeline(compositorTimeline->anima
tionTimeline()); |
| 146 } | 149 } |
| 147 | 150 |
| 148 class FakeScrollableArea : public GarbageCollectedFinalized<FakeScrollableArea>,
public ScrollableArea { | 151 class FakeScrollableArea : public GarbageCollectedFinalized<FakeScrollableArea>,
public ScrollableArea { |
| 149 USING_GARBAGE_COLLECTED_MIXIN(FakeScrollableArea); | 152 USING_GARBAGE_COLLECTED_MIXIN(FakeScrollableArea); |
| 150 public: | 153 public: |
| 151 static FakeScrollableArea* create() | 154 static FakeScrollableArea* create() |
| 152 { | 155 { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 | 196 |
| 194 WebDoublePoint scrollPosition(7, 9); | 197 WebDoublePoint scrollPosition(7, 9); |
| 195 m_platformLayer->setScrollPositionDouble(scrollPosition); | 198 m_platformLayer->setScrollPositionDouble(scrollPosition); |
| 196 m_graphicsLayer->didScroll(); | 199 m_graphicsLayer->didScroll(); |
| 197 | 200 |
| 198 EXPECT_FLOAT_EQ(scrollPosition.x, scrollableArea->scrollPositionDouble().x()
); | 201 EXPECT_FLOAT_EQ(scrollPosition.x, scrollableArea->scrollPositionDouble().x()
); |
| 199 EXPECT_FLOAT_EQ(scrollPosition.y, scrollableArea->scrollPositionDouble().y()
); | 202 EXPECT_FLOAT_EQ(scrollPosition.y, scrollableArea->scrollPositionDouble().y()
); |
| 200 } | 203 } |
| 201 | 204 |
| 202 } // namespace blink | 205 } // namespace blink |
| OLD | NEW |