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