| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 namespace blink { | 47 namespace blink { |
| 48 | 48 |
| 49 class GraphicsLayerTest : public testing::Test { | 49 class GraphicsLayerTest : public testing::Test { |
| 50 public: | 50 public: |
| 51 GraphicsLayerTest() | 51 GraphicsLayerTest() |
| 52 { | 52 { |
| 53 m_clipLayer = adoptPtr(new FakeGraphicsLayer(&m_client)); | 53 m_clipLayer = adoptPtr(new FakeGraphicsLayer(&m_client)); |
| 54 m_scrollElasticityLayer = adoptPtr(new FakeGraphicsLayer(&m_client)); | 54 m_scrollElasticityLayer = adoptPtr(new FakeGraphicsLayer(&m_client)); |
| 55 m_graphicsLayer = adoptPtr(new FakeGraphicsLayer(&m_client)); | 55 m_graphicsLayer = adoptPtr(new FakeGraphicsLayer(&m_client)); |
| 56 m_graphicsLayer->setElementId(nextCompositorElementId()); |
| 56 m_clipLayer->addChild(m_scrollElasticityLayer.get()); | 57 m_clipLayer->addChild(m_scrollElasticityLayer.get()); |
| 57 m_scrollElasticityLayer->addChild(m_graphicsLayer.get()); | 58 m_scrollElasticityLayer->addChild(m_graphicsLayer.get()); |
| 58 m_graphicsLayer->platformLayer()->setScrollClipLayer( | 59 m_graphicsLayer->platformLayer()->setScrollClipLayer( |
| 59 m_clipLayer->platformLayer()); | 60 m_clipLayer->platformLayer()); |
| 60 m_platformLayer = m_graphicsLayer->platformLayer(); | 61 m_platformLayer = m_graphicsLayer->platformLayer(); |
| 62 |
| 61 m_layerTreeView = adoptPtr(new WebLayerTreeViewImplForTesting); | 63 m_layerTreeView = adoptPtr(new WebLayerTreeViewImplForTesting); |
| 62 ASSERT(m_layerTreeView); | 64 ASSERT(m_layerTreeView); |
| 63 m_layerTreeView->setRootLayer(*m_clipLayer->platformLayer()); | 65 m_layerTreeView->setRootLayer(*m_clipLayer->platformLayer()); |
| 64 m_layerTreeView->registerViewportLayers( | 66 m_layerTreeView->registerViewportLayers( |
| 65 m_scrollElasticityLayer->platformLayer(), m_clipLayer->platformLayer
(), m_graphicsLayer->platformLayer(), 0); | 67 m_scrollElasticityLayer->platformLayer(), m_clipLayer->platformLayer
(), m_graphicsLayer->platformLayer(), 0); |
| 66 m_layerTreeView->setViewportSize(WebSize(1, 1)); | 68 m_layerTreeView->setViewportSize(WebSize(1, 1)); |
| 67 } | 69 } |
| 68 | 70 |
| 69 ~GraphicsLayerTest() override | 71 ~GraphicsLayerTest() override |
| 70 { | 72 { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 curve->add(CompositorFloatKeyframe(0.0, 0.0)); | 110 curve->add(CompositorFloatKeyframe(0.0, 0.0)); |
| 109 OwnPtr<CompositorAnimation> floatAnimation(adoptPtr(CompositorFactory::curre
nt().createAnimation(*curve, CompositorTargetProperty::OPACITY))); | 111 OwnPtr<CompositorAnimation> floatAnimation(adoptPtr(CompositorFactory::curre
nt().createAnimation(*curve, CompositorTargetProperty::OPACITY))); |
| 110 int animationId = floatAnimation->id(); | 112 int animationId = floatAnimation->id(); |
| 111 | 113 |
| 112 OwnPtr<CompositorAnimationTimeline> compositorTimeline = adoptPtr(Compositor
Factory::current().createAnimationTimeline()); | 114 OwnPtr<CompositorAnimationTimeline> compositorTimeline = adoptPtr(Compositor
Factory::current().createAnimationTimeline()); |
| 113 AnimationPlayerForTesting player; | 115 AnimationPlayerForTesting player; |
| 114 | 116 |
| 115 layerTreeView()->attachCompositorAnimationTimeline(compositorTimeline->anima
tionTimeline()); | 117 layerTreeView()->attachCompositorAnimationTimeline(compositorTimeline->anima
tionTimeline()); |
| 116 compositorTimeline->playerAttached(player); | 118 compositorTimeline->playerAttached(player); |
| 117 | 119 |
| 118 player.compositorPlayer()->attachLayer(m_platformLayer); | 120 player.compositorPlayer()->attachElement(m_platformLayer->elementId()); |
| 119 ASSERT_TRUE(player.compositorPlayer()->isLayerAttached()); | 121 ASSERT_TRUE(player.compositorPlayer()->isElementAttached()); |
| 120 | 122 |
| 121 player.compositorPlayer()->addAnimation(floatAnimation.leakPtr()); | 123 player.compositorPlayer()->addAnimation(floatAnimation.leakPtr()); |
| 122 | 124 |
| 123 ASSERT_TRUE(m_platformLayer->hasActiveAnimationForTesting()); | 125 ASSERT_TRUE(m_platformLayer->hasActiveAnimationForTesting()); |
| 124 | 126 |
| 125 m_graphicsLayer->setShouldFlattenTransform(false); | 127 m_graphicsLayer->setShouldFlattenTransform(false); |
| 126 | 128 |
| 127 m_platformLayer = m_graphicsLayer->platformLayer(); | 129 m_platformLayer = m_graphicsLayer->platformLayer(); |
| 128 ASSERT_TRUE(m_platformLayer); | 130 ASSERT_TRUE(m_platformLayer); |
| 129 | 131 |
| 130 ASSERT_TRUE(m_platformLayer->hasActiveAnimationForTesting()); | 132 ASSERT_TRUE(m_platformLayer->hasActiveAnimationForTesting()); |
| 131 player.compositorPlayer()->removeAnimation(animationId); | 133 player.compositorPlayer()->removeAnimation(animationId); |
| 132 ASSERT_FALSE(m_platformLayer->hasActiveAnimationForTesting()); | 134 ASSERT_FALSE(m_platformLayer->hasActiveAnimationForTesting()); |
| 133 | 135 |
| 134 m_graphicsLayer->setShouldFlattenTransform(true); | 136 m_graphicsLayer->setShouldFlattenTransform(true); |
| 135 | 137 |
| 136 m_platformLayer = m_graphicsLayer->platformLayer(); | 138 m_platformLayer = m_graphicsLayer->platformLayer(); |
| 137 ASSERT_TRUE(m_platformLayer); | 139 ASSERT_TRUE(m_platformLayer); |
| 138 | 140 |
| 139 ASSERT_FALSE(m_platformLayer->hasActiveAnimationForTesting()); | 141 ASSERT_FALSE(m_platformLayer->hasActiveAnimationForTesting()); |
| 140 | 142 |
| 141 player.compositorPlayer()->detachLayer(); | 143 player.compositorPlayer()->detachElement(); |
| 142 ASSERT_FALSE(player.compositorPlayer()->isLayerAttached()); | 144 ASSERT_FALSE(player.compositorPlayer()->isElementAttached()); |
| 143 | 145 |
| 144 compositorTimeline->playerDestroyed(player); | 146 compositorTimeline->playerDestroyed(player); |
| 145 layerTreeView()->detachCompositorAnimationTimeline(compositorTimeline->anima
tionTimeline()); | 147 layerTreeView()->detachCompositorAnimationTimeline(compositorTimeline->anima
tionTimeline()); |
| 146 } | 148 } |
| 147 | 149 |
| 148 class FakeScrollableArea : public GarbageCollectedFinalized<FakeScrollableArea>,
public ScrollableArea { | 150 class FakeScrollableArea : public GarbageCollectedFinalized<FakeScrollableArea>,
public ScrollableArea { |
| 149 USING_GARBAGE_COLLECTED_MIXIN(FakeScrollableArea); | 151 USING_GARBAGE_COLLECTED_MIXIN(FakeScrollableArea); |
| 150 public: | 152 public: |
| 151 static FakeScrollableArea* create() | 153 static FakeScrollableArea* create() |
| 152 { | 154 { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 | 195 |
| 194 WebDoublePoint scrollPosition(7, 9); | 196 WebDoublePoint scrollPosition(7, 9); |
| 195 m_platformLayer->setScrollPositionDouble(scrollPosition); | 197 m_platformLayer->setScrollPositionDouble(scrollPosition); |
| 196 m_graphicsLayer->didScroll(); | 198 m_graphicsLayer->didScroll(); |
| 197 | 199 |
| 198 EXPECT_FLOAT_EQ(scrollPosition.x, scrollableArea->scrollPositionDouble().x()
); | 200 EXPECT_FLOAT_EQ(scrollPosition.x, scrollableArea->scrollPositionDouble().x()
); |
| 199 EXPECT_FLOAT_EQ(scrollPosition.y, scrollableArea->scrollPositionDouble().y()
); | 201 EXPECT_FLOAT_EQ(scrollPosition.y, scrollableArea->scrollPositionDouble().y()
); |
| 200 } | 202 } |
| 201 | 203 |
| 202 } // namespace blink | 204 } // namespace blink |
| OLD | NEW |