| 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 25 matching lines...) Expand all Loading... |
| 36 #include "platform/testing/FakeGraphicsLayerClient.h" | 36 #include "platform/testing/FakeGraphicsLayerClient.h" |
| 37 #include "platform/testing/WebLayerTreeViewImplForTesting.h" | 37 #include "platform/testing/WebLayerTreeViewImplForTesting.h" |
| 38 #include "platform/transforms/Matrix3DTransformOperation.h" | 38 #include "platform/transforms/Matrix3DTransformOperation.h" |
| 39 #include "platform/transforms/RotateTransformOperation.h" | 39 #include "platform/transforms/RotateTransformOperation.h" |
| 40 #include "platform/transforms/TranslateTransformOperation.h" | 40 #include "platform/transforms/TranslateTransformOperation.h" |
| 41 #include "public/platform/Platform.h" | 41 #include "public/platform/Platform.h" |
| 42 #include "public/platform/WebCompositorSupport.h" | 42 #include "public/platform/WebCompositorSupport.h" |
| 43 #include "public/platform/WebLayer.h" | 43 #include "public/platform/WebLayer.h" |
| 44 #include "public/platform/WebLayerTreeView.h" | 44 #include "public/platform/WebLayerTreeView.h" |
| 45 #include "testing/gtest/include/gtest/gtest.h" | 45 #include "testing/gtest/include/gtest/gtest.h" |
| 46 #include "wtf/PtrUtil.h" | 46 #include "wtf/PassOwnPtr.h" |
| 47 #include <memory> | |
| 48 | 47 |
| 49 namespace blink { | 48 namespace blink { |
| 50 | 49 |
| 51 class GraphicsLayerTest : public testing::Test { | 50 class GraphicsLayerTest : public testing::Test { |
| 52 public: | 51 public: |
| 53 GraphicsLayerTest() | 52 GraphicsLayerTest() |
| 54 { | 53 { |
| 55 m_clipLayer = wrapUnique(new FakeGraphicsLayer(&m_client)); | 54 m_clipLayer = adoptPtr(new FakeGraphicsLayer(&m_client)); |
| 56 m_scrollElasticityLayer = wrapUnique(new FakeGraphicsLayer(&m_client)); | 55 m_scrollElasticityLayer = adoptPtr(new FakeGraphicsLayer(&m_client)); |
| 57 m_graphicsLayer = wrapUnique(new FakeGraphicsLayer(&m_client)); | 56 m_graphicsLayer = adoptPtr(new FakeGraphicsLayer(&m_client)); |
| 58 m_clipLayer->addChild(m_scrollElasticityLayer.get()); | 57 m_clipLayer->addChild(m_scrollElasticityLayer.get()); |
| 59 m_scrollElasticityLayer->addChild(m_graphicsLayer.get()); | 58 m_scrollElasticityLayer->addChild(m_graphicsLayer.get()); |
| 60 m_graphicsLayer->platformLayer()->setScrollClipLayer( | 59 m_graphicsLayer->platformLayer()->setScrollClipLayer( |
| 61 m_clipLayer->platformLayer()); | 60 m_clipLayer->platformLayer()); |
| 62 m_platformLayer = m_graphicsLayer->platformLayer(); | 61 m_platformLayer = m_graphicsLayer->platformLayer(); |
| 63 m_layerTreeView = wrapUnique(new WebLayerTreeViewImplForTesting); | 62 m_layerTreeView = adoptPtr(new WebLayerTreeViewImplForTesting); |
| 64 ASSERT(m_layerTreeView); | 63 ASSERT(m_layerTreeView); |
| 65 m_layerTreeView->setRootLayer(*m_clipLayer->platformLayer()); | 64 m_layerTreeView->setRootLayer(*m_clipLayer->platformLayer()); |
| 66 m_layerTreeView->registerViewportLayers( | 65 m_layerTreeView->registerViewportLayers( |
| 67 m_scrollElasticityLayer->platformLayer(), m_clipLayer->platformLayer
(), m_graphicsLayer->platformLayer(), 0); | 66 m_scrollElasticityLayer->platformLayer(), m_clipLayer->platformLayer
(), m_graphicsLayer->platformLayer(), 0); |
| 68 m_layerTreeView->setViewportSize(WebSize(1, 1)); | 67 m_layerTreeView->setViewportSize(WebSize(1, 1)); |
| 69 } | 68 } |
| 70 | 69 |
| 71 ~GraphicsLayerTest() override | 70 ~GraphicsLayerTest() override |
| 72 { | 71 { |
| 73 m_graphicsLayer.reset(); | 72 m_graphicsLayer.reset(); |
| 74 m_layerTreeView.reset(); | 73 m_layerTreeView.reset(); |
| 75 } | 74 } |
| 76 | 75 |
| 77 WebLayerTreeView* layerTreeView() { return m_layerTreeView.get(); } | 76 WebLayerTreeView* layerTreeView() { return m_layerTreeView.get(); } |
| 78 | 77 |
| 79 protected: | 78 protected: |
| 80 WebLayer* m_platformLayer; | 79 WebLayer* m_platformLayer; |
| 81 std::unique_ptr<FakeGraphicsLayer> m_graphicsLayer; | 80 OwnPtr<FakeGraphicsLayer> m_graphicsLayer; |
| 82 std::unique_ptr<FakeGraphicsLayer> m_scrollElasticityLayer; | 81 OwnPtr<FakeGraphicsLayer> m_scrollElasticityLayer; |
| 83 std::unique_ptr<FakeGraphicsLayer> m_clipLayer; | 82 OwnPtr<FakeGraphicsLayer> m_clipLayer; |
| 84 | 83 |
| 85 private: | 84 private: |
| 86 std::unique_ptr<WebLayerTreeView> m_layerTreeView; | 85 OwnPtr<WebLayerTreeView> m_layerTreeView; |
| 87 FakeGraphicsLayerClient m_client; | 86 FakeGraphicsLayerClient m_client; |
| 88 }; | 87 }; |
| 89 | 88 |
| 90 class AnimationPlayerForTesting : public CompositorAnimationPlayerClient { | 89 class AnimationPlayerForTesting : public CompositorAnimationPlayerClient { |
| 91 public: | 90 public: |
| 92 AnimationPlayerForTesting() | 91 AnimationPlayerForTesting() |
| 93 { | 92 { |
| 94 m_compositorPlayer = CompositorAnimationPlayer::create(); | 93 m_compositorPlayer = CompositorAnimationPlayer::create(); |
| 95 } | 94 } |
| 96 | 95 |
| 97 CompositorAnimationPlayer* compositorPlayer() const override | 96 CompositorAnimationPlayer* compositorPlayer() const override |
| 98 { | 97 { |
| 99 return m_compositorPlayer.get(); | 98 return m_compositorPlayer.get(); |
| 100 } | 99 } |
| 101 | 100 |
| 102 std::unique_ptr<CompositorAnimationPlayer> m_compositorPlayer; | 101 OwnPtr<CompositorAnimationPlayer> m_compositorPlayer; |
| 103 }; | 102 }; |
| 104 | 103 |
| 105 TEST_F(GraphicsLayerTest, updateLayerShouldFlattenTransformWithAnimations) | 104 TEST_F(GraphicsLayerTest, updateLayerShouldFlattenTransformWithAnimations) |
| 106 { | 105 { |
| 107 ASSERT_FALSE(m_platformLayer->hasActiveAnimationForTesting()); | 106 ASSERT_FALSE(m_platformLayer->hasActiveAnimationForTesting()); |
| 108 | 107 |
| 109 std::unique_ptr<CompositorFloatAnimationCurve> curve = CompositorFloatAnimat
ionCurve::create(); | 108 OwnPtr<CompositorFloatAnimationCurve> curve = CompositorFloatAnimationCurve:
:create(); |
| 110 curve->addCubicBezierKeyframe(CompositorFloatKeyframe(0.0, 0.0), CubicBezier
TimingFunction::EaseType::EASE); | 109 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)); | 110 OwnPtr<CompositorAnimation> floatAnimation(CompositorAnimation::create(*curv
e, CompositorTargetProperty::OPACITY, 0, 0)); |
| 112 int animationId = floatAnimation->id(); | 111 int animationId = floatAnimation->id(); |
| 113 | 112 |
| 114 std::unique_ptr<CompositorAnimationTimeline> compositorTimeline = Compositor
AnimationTimeline::create(); | 113 OwnPtr<CompositorAnimationTimeline> compositorTimeline = CompositorAnimation
Timeline::create(); |
| 115 AnimationPlayerForTesting player; | 114 AnimationPlayerForTesting player; |
| 116 | 115 |
| 117 layerTreeView()->attachCompositorAnimationTimeline(compositorTimeline->anima
tionTimeline()); | 116 layerTreeView()->attachCompositorAnimationTimeline(compositorTimeline->anima
tionTimeline()); |
| 118 compositorTimeline->playerAttached(player); | 117 compositorTimeline->playerAttached(player); |
| 119 | 118 |
| 120 player.compositorPlayer()->attachLayer(m_platformLayer); | 119 player.compositorPlayer()->attachLayer(m_platformLayer); |
| 121 ASSERT_TRUE(player.compositorPlayer()->isLayerAttached()); | 120 ASSERT_TRUE(player.compositorPlayer()->isLayerAttached()); |
| 122 | 121 |
| 123 player.compositorPlayer()->addAnimation(floatAnimation.release()); | 122 player.compositorPlayer()->addAnimation(floatAnimation.leakPtr()); |
| 124 | 123 |
| 125 ASSERT_TRUE(m_platformLayer->hasActiveAnimationForTesting()); | 124 ASSERT_TRUE(m_platformLayer->hasActiveAnimationForTesting()); |
| 126 | 125 |
| 127 m_graphicsLayer->setShouldFlattenTransform(false); | 126 m_graphicsLayer->setShouldFlattenTransform(false); |
| 128 | 127 |
| 129 m_platformLayer = m_graphicsLayer->platformLayer(); | 128 m_platformLayer = m_graphicsLayer->platformLayer(); |
| 130 ASSERT_TRUE(m_platformLayer); | 129 ASSERT_TRUE(m_platformLayer); |
| 131 | 130 |
| 132 ASSERT_TRUE(m_platformLayer->hasActiveAnimationForTesting()); | 131 ASSERT_TRUE(m_platformLayer->hasActiveAnimationForTesting()); |
| 133 player.compositorPlayer()->removeAnimation(animationId); | 132 player.compositorPlayer()->removeAnimation(animationId); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 | 194 |
| 196 WebDoublePoint scrollPosition(7, 9); | 195 WebDoublePoint scrollPosition(7, 9); |
| 197 m_platformLayer->setScrollPositionDouble(scrollPosition); | 196 m_platformLayer->setScrollPositionDouble(scrollPosition); |
| 198 m_graphicsLayer->didScroll(); | 197 m_graphicsLayer->didScroll(); |
| 199 | 198 |
| 200 EXPECT_FLOAT_EQ(scrollPosition.x, scrollableArea->scrollPositionDouble().x()
); | 199 EXPECT_FLOAT_EQ(scrollPosition.x, scrollableArea->scrollPositionDouble().x()
); |
| 201 EXPECT_FLOAT_EQ(scrollPosition.y, scrollableArea->scrollPositionDouble().y()
); | 200 EXPECT_FLOAT_EQ(scrollPosition.y, scrollableArea->scrollPositionDouble().y()
); |
| 202 } | 201 } |
| 203 | 202 |
| 204 } // namespace blink | 203 } // namespace blink |
| OLD | NEW |