| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/scrollbar_layer.h" | 5 #include "cc/scrollbar_layer.h" |
| 6 | 6 |
| 7 #include "cc/scrollbar_animation_controller.h" | 7 #include "cc/scrollbar_animation_controller.h" |
| 8 #include "cc/scrollbar_layer_impl.h" | 8 #include "cc/scrollbar_layer_impl.h" |
| 9 #include "cc/single_thread_proxy.h" | 9 #include "cc/single_thread_proxy.h" |
| 10 #include "cc/test/fake_impl_proxy.h" | 10 #include "cc/test/fake_impl_proxy.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 TEST(ScrollbarLayerTest, resolveScrollLayerPointer) | 46 TEST(ScrollbarLayerTest, resolveScrollLayerPointer) |
| 47 { | 47 { |
| 48 FakeImplProxy proxy; | 48 FakeImplProxy proxy; |
| 49 FakeLayerTreeHostImpl hostImpl(&proxy); | 49 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 50 WebKit::WebScrollbarThemePainter painter; | 50 WebKit::WebScrollbarThemePainter painter; |
| 51 | 51 |
| 52 { | 52 { |
| 53 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::create()); | 53 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::create()); |
| 54 scoped_refptr<Layer> layerTreeRoot = Layer::create(); | 54 scoped_refptr<Layer> layerTreeRoot = Layer::create(); |
| 55 scoped_refptr<Layer> child1 = Layer::create(); | 55 scoped_refptr<Layer> child1 = Layer::create(); |
| 56 scoped_refptr<Layer> child2 = ScrollbarLayer::create(scrollbar.Pass(), p
ainter, WebKit::FakeWebScrollbarThemeGeometry::create(), child1->id()); | 56 scoped_refptr<Layer> child2 = ScrollbarLayer::create(scrollbar.Pass(), p
ainter, FakeWebScrollbarThemeGeometry::create(), child1->id()); |
| 57 layerTreeRoot->addChild(child1); | 57 layerTreeRoot->addChild(child1); |
| 58 layerTreeRoot->addChild(child2); | 58 layerTreeRoot->addChild(child2); |
| 59 | 59 |
| 60 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeT
rees(layerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl.activeTree()); | 60 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeT
rees(layerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl.activeTree()); |
| 61 | 61 |
| 62 LayerImpl* ccChild1 = layerImplTreeRoot->children()[0]; | 62 LayerImpl* ccChild1 = layerImplTreeRoot->children()[0]; |
| 63 ScrollbarLayerImpl* ccChild2 = static_cast<ScrollbarLayerImpl*>(layerImp
lTreeRoot->children()[1]); | 63 ScrollbarLayerImpl* ccChild2 = static_cast<ScrollbarLayerImpl*>(layerImp
lTreeRoot->children()[1]); |
| 64 | 64 |
| 65 EXPECT_TRUE(ccChild1->scrollbarAnimationController()); | 65 EXPECT_TRUE(ccChild1->scrollbarAnimationController()); |
| 66 EXPECT_EQ(ccChild1->horizontalScrollbarLayer(), ccChild2); | 66 EXPECT_EQ(ccChild1->horizontalScrollbarLayer(), ccChild2); |
| 67 } | 67 } |
| 68 | 68 |
| 69 { // another traverse order | 69 { // another traverse order |
| 70 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::create()); | 70 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::create()); |
| 71 scoped_refptr<Layer> layerTreeRoot = Layer::create(); | 71 scoped_refptr<Layer> layerTreeRoot = Layer::create(); |
| 72 scoped_refptr<Layer> child2 = Layer::create(); | 72 scoped_refptr<Layer> child2 = Layer::create(); |
| 73 scoped_refptr<Layer> child1 = ScrollbarLayer::create(scrollbar.Pass(), p
ainter, WebKit::FakeWebScrollbarThemeGeometry::create(), child2->id()); | 73 scoped_refptr<Layer> child1 = ScrollbarLayer::create(scrollbar.Pass(), p
ainter, FakeWebScrollbarThemeGeometry::create(), child2->id()); |
| 74 layerTreeRoot->addChild(child1); | 74 layerTreeRoot->addChild(child1); |
| 75 layerTreeRoot->addChild(child2); | 75 layerTreeRoot->addChild(child2); |
| 76 | 76 |
| 77 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeT
rees(layerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl.activeTree()); | 77 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeT
rees(layerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl.activeTree()); |
| 78 | 78 |
| 79 ScrollbarLayerImpl* ccChild1 = static_cast<ScrollbarLayerImpl*>(layerImp
lTreeRoot->children()[0]); | 79 ScrollbarLayerImpl* ccChild1 = static_cast<ScrollbarLayerImpl*>(layerImp
lTreeRoot->children()[0]); |
| 80 LayerImpl* ccChild2 = layerImplTreeRoot->children()[1]; | 80 LayerImpl* ccChild2 = layerImplTreeRoot->children()[1]; |
| 81 | 81 |
| 82 EXPECT_TRUE(ccChild2->scrollbarAnimationController()); | 82 EXPECT_TRUE(ccChild2->scrollbarAnimationController()); |
| 83 EXPECT_EQ(ccChild2->horizontalScrollbarLayer(), ccChild1); | 83 EXPECT_EQ(ccChild2->horizontalScrollbarLayer(), ccChild1); |
| 84 } | 84 } |
| 85 } | 85 } |
| 86 | 86 |
| 87 TEST(ScrollbarLayerTest, scrollOffsetSynchronization) | 87 TEST(ScrollbarLayerTest, scrollOffsetSynchronization) |
| 88 { | 88 { |
| 89 FakeImplProxy proxy; | 89 FakeImplProxy proxy; |
| 90 FakeLayerTreeHostImpl hostImpl(&proxy); | 90 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 91 WebKit::WebScrollbarThemePainter painter; | 91 WebKit::WebScrollbarThemePainter painter; |
| 92 | 92 |
| 93 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::create()); | 93 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::create()); |
| 94 scoped_refptr<Layer> layerTreeRoot = Layer::create(); | 94 scoped_refptr<Layer> layerTreeRoot = Layer::create(); |
| 95 scoped_refptr<Layer> contentLayer = Layer::create(); | 95 scoped_refptr<Layer> contentLayer = Layer::create(); |
| 96 scoped_refptr<Layer> scrollbarLayer = ScrollbarLayer::create(scrollbar.Pass(
), painter, WebKit::FakeWebScrollbarThemeGeometry::create(), layerTreeRoot->id()
); | 96 scoped_refptr<Layer> scrollbarLayer = ScrollbarLayer::create(scrollbar.Pass(
), painter, FakeWebScrollbarThemeGeometry::create(), layerTreeRoot->id()); |
| 97 layerTreeRoot->addChild(contentLayer); | 97 layerTreeRoot->addChild(contentLayer); |
| 98 layerTreeRoot->addChild(scrollbarLayer); | 98 layerTreeRoot->addChild(scrollbarLayer); |
| 99 | 99 |
| 100 layerTreeRoot->setScrollOffset(gfx::Vector2d(10, 20)); | 100 layerTreeRoot->setScrollOffset(gfx::Vector2d(10, 20)); |
| 101 layerTreeRoot->setMaxScrollOffset(gfx::Vector2d(30, 50)); | 101 layerTreeRoot->setMaxScrollOffset(gfx::Vector2d(30, 50)); |
| 102 contentLayer->setBounds(gfx::Size(100, 200)); | 102 contentLayer->setBounds(gfx::Size(100, 200)); |
| 103 | 103 |
| 104 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees
(layerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl.activeTree()); | 104 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees
(layerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl.activeTree()); |
| 105 | 105 |
| 106 ScrollbarLayerImpl* ccScrollbarLayer = static_cast<ScrollbarLayerImpl*>(laye
rImplTreeRoot->children()[1]); | 106 ScrollbarLayerImpl* ccScrollbarLayer = static_cast<ScrollbarLayerImpl*>(laye
rImplTreeRoot->children()[1]); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 134 | 134 |
| 135 void setScrollbarBounds(gfx::Size bounds) { | 135 void setScrollbarBounds(gfx::Size bounds) { |
| 136 m_bounds = bounds; | 136 m_bounds = bounds; |
| 137 } | 137 } |
| 138 | 138 |
| 139 virtual void beginTest() OVERRIDE | 139 virtual void beginTest() OVERRIDE |
| 140 { | 140 { |
| 141 m_layerTreeHost->initializeRendererIfNeeded(); | 141 m_layerTreeHost->initializeRendererIfNeeded(); |
| 142 | 142 |
| 143 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::create()); | 143 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::create()); |
| 144 m_scrollbarLayer = ScrollbarLayer::create(scrollbar.Pass(), m_painter, W
ebKit::FakeWebScrollbarThemeGeometry::create(), 1); | 144 m_scrollbarLayer = ScrollbarLayer::create(scrollbar.Pass(), m_painter, F
akeWebScrollbarThemeGeometry::create(), 1); |
| 145 m_scrollbarLayer->setLayerTreeHost(m_layerTreeHost.get()); | 145 m_scrollbarLayer->setLayerTreeHost(m_layerTreeHost.get()); |
| 146 m_scrollbarLayer->setBounds(m_bounds); | 146 m_scrollbarLayer->setBounds(m_bounds); |
| 147 m_layerTreeHost->rootLayer()->addChild(m_scrollbarLayer); | 147 m_layerTreeHost->rootLayer()->addChild(m_scrollbarLayer); |
| 148 | 148 |
| 149 m_scrollLayer = Layer::create(); | 149 m_scrollLayer = Layer::create(); |
| 150 m_scrollbarLayer->setScrollLayerId(m_scrollLayer->id()); | 150 m_scrollbarLayer->setScrollLayerId(m_scrollLayer->id()); |
| 151 m_layerTreeHost->rootLayer()->addChild(m_scrollLayer); | 151 m_layerTreeHost->rootLayer()->addChild(m_scrollLayer); |
| 152 | 152 |
| 153 postSetNeedsCommitToMainThread(); | 153 postSetNeedsCommitToMainThread(); |
| 154 } | 154 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 171 } | 171 } |
| 172 | 172 |
| 173 private: | 173 private: |
| 174 scoped_refptr<ScrollbarLayer> m_scrollbarLayer; | 174 scoped_refptr<ScrollbarLayer> m_scrollbarLayer; |
| 175 scoped_refptr<Layer> m_scrollLayer; | 175 scoped_refptr<Layer> m_scrollLayer; |
| 176 WebKit::WebScrollbarThemePainter m_painter; | 176 WebKit::WebScrollbarThemePainter m_painter; |
| 177 gfx::Size m_bounds; | 177 gfx::Size m_bounds; |
| 178 }; | 178 }; |
| 179 | 179 |
| 180 TEST_F(ScrollbarLayerTestMaxTextureSize, runTest) { | 180 TEST_F(ScrollbarLayerTestMaxTextureSize, runTest) { |
| 181 WebKit::FakeWebGraphicsContext3D context; | 181 FakeWebGraphicsContext3D context; |
| 182 int max_size = 0; | 182 int max_size = 0; |
| 183 context.getIntegerv(GL_MAX_TEXTURE_SIZE, &max_size); | 183 context.getIntegerv(GL_MAX_TEXTURE_SIZE, &max_size); |
| 184 setScrollbarBounds(gfx::Size(max_size + 100, max_size + 100)); | 184 setScrollbarBounds(gfx::Size(max_size + 100, max_size + 100)); |
| 185 runTest(true); | 185 runTest(true); |
| 186 } | 186 } |
| 187 | 187 |
| 188 } // namespace | 188 } // namespace |
| 189 } // namespace cc | 189 } // namespace cc |
| OLD | NEW |