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