| 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 11 matching lines...) Expand all Loading... |
| 22 namespace cc { | 22 namespace cc { |
| 23 namespace { | 23 namespace { |
| 24 | 24 |
| 25 scoped_ptr<LayerImpl> layerImplForScrollAreaAndScrollbar( | 25 scoped_ptr<LayerImpl> layerImplForScrollAreaAndScrollbar( |
| 26 FakeLayerTreeHostImpl* host_impl, | 26 FakeLayerTreeHostImpl* host_impl, |
| 27 scoped_ptr<WebKit::WebScrollbar> scrollbar, | 27 scoped_ptr<WebKit::WebScrollbar> scrollbar, |
| 28 bool reverse_order) | 28 bool reverse_order) |
| 29 { | 29 { |
| 30 scoped_refptr<Layer> layerTreeRoot = Layer::create(); | 30 scoped_refptr<Layer> layerTreeRoot = Layer::create(); |
| 31 scoped_refptr<Layer> child1 = Layer::create(); | 31 scoped_refptr<Layer> child1 = Layer::create(); |
| 32 scoped_refptr<Layer> child2 = ScrollbarLayer::create(scrollbar.Pass(), FakeS
crollbarThemePainter::Create(false).PassAs<ScrollbarThemePainter>(), FakeWebScro
llbarThemeGeometry::create(), child1->id()); | 32 scoped_refptr<Layer> child2 = ScrollbarLayer::create(scrollbar.Pass(), FakeS
crollbarThemePainter::Create(false).PassAs<ScrollbarThemePainter>(), FakeWebScro
llbarThemeGeometry::create(true), child1->id()); |
| 33 layerTreeRoot->addChild(child1); | 33 layerTreeRoot->addChild(child1); |
| 34 layerTreeRoot->insertChild(child2, reverse_order ? 0 : 1); | 34 layerTreeRoot->insertChild(child2, reverse_order ? 0 : 1); |
| 35 return TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), scoped_ptr<La
yerImpl>(), host_impl->activeTree()).Pass(); | 35 return TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), scoped_ptr<La
yerImpl>(), host_impl->activeTree()).Pass(); |
| 36 } | 36 } |
| 37 | 37 |
| 38 TEST(ScrollbarLayerTest, resolveScrollLayerPointer) | 38 TEST(ScrollbarLayerTest, resolveScrollLayerPointer) |
| 39 { | 39 { |
| 40 FakeImplProxy proxy; | 40 FakeImplProxy proxy; |
| 41 FakeLayerTreeHostImpl hostImpl(&proxy); | 41 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 42 | 42 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 } | 92 } |
| 93 | 93 |
| 94 TEST(ScrollbarLayerTest, scrollOffsetSynchronization) | 94 TEST(ScrollbarLayerTest, scrollOffsetSynchronization) |
| 95 { | 95 { |
| 96 FakeImplProxy proxy; | 96 FakeImplProxy proxy; |
| 97 FakeLayerTreeHostImpl hostImpl(&proxy); | 97 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 98 | 98 |
| 99 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::create()); | 99 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::create()); |
| 100 scoped_refptr<Layer> layerTreeRoot = Layer::create(); | 100 scoped_refptr<Layer> layerTreeRoot = Layer::create(); |
| 101 scoped_refptr<Layer> contentLayer = Layer::create(); | 101 scoped_refptr<Layer> contentLayer = Layer::create(); |
| 102 scoped_refptr<Layer> scrollbarLayer = ScrollbarLayer::create(scrollbar.Pass(
), FakeScrollbarThemePainter::Create(false).PassAs<ScrollbarThemePainter>(), Fak
eWebScrollbarThemeGeometry::create(), layerTreeRoot->id()); | 102 scoped_refptr<Layer> scrollbarLayer = ScrollbarLayer::create(scrollbar.Pass(
), FakeScrollbarThemePainter::Create(false).PassAs<ScrollbarThemePainter>(), Fak
eWebScrollbarThemeGeometry::create(true), layerTreeRoot->id()); |
| 103 layerTreeRoot->addChild(contentLayer); | 103 layerTreeRoot->addChild(contentLayer); |
| 104 layerTreeRoot->addChild(scrollbarLayer); | 104 layerTreeRoot->addChild(scrollbarLayer); |
| 105 | 105 |
| 106 layerTreeRoot->setScrollOffset(gfx::Vector2d(10, 20)); | 106 layerTreeRoot->setScrollOffset(gfx::Vector2d(10, 20)); |
| 107 layerTreeRoot->setMaxScrollOffset(gfx::Vector2d(30, 50)); | 107 layerTreeRoot->setMaxScrollOffset(gfx::Vector2d(30, 50)); |
| 108 contentLayer->setBounds(gfx::Size(100, 200)); | 108 contentLayer->setBounds(gfx::Size(100, 200)); |
| 109 | 109 |
| 110 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees
(layerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl.activeTree()); | 110 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees
(layerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl.activeTree()); |
| 111 | 111 |
| 112 ScrollbarLayerImpl* ccScrollbarLayer = static_cast<ScrollbarLayerImpl*>(laye
rImplTreeRoot->children()[1]); | 112 ScrollbarLayerImpl* ccScrollbarLayer = static_cast<ScrollbarLayerImpl*>(laye
rImplTreeRoot->children()[1]); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 140 | 140 |
| 141 void setScrollbarBounds(gfx::Size bounds) { | 141 void setScrollbarBounds(gfx::Size bounds) { |
| 142 m_bounds = bounds; | 142 m_bounds = bounds; |
| 143 } | 143 } |
| 144 | 144 |
| 145 virtual void beginTest() OVERRIDE | 145 virtual void beginTest() OVERRIDE |
| 146 { | 146 { |
| 147 m_layerTreeHost->initializeRendererIfNeeded(); | 147 m_layerTreeHost->initializeRendererIfNeeded(); |
| 148 | 148 |
| 149 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::create()); | 149 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::create()); |
| 150 m_scrollbarLayer = ScrollbarLayer::create(scrollbar.Pass(), FakeScrollba
rThemePainter::Create(false).PassAs<ScrollbarThemePainter>(), FakeWebScrollbarTh
emeGeometry::create(), 1); | 150 m_scrollbarLayer = ScrollbarLayer::create(scrollbar.Pass(), FakeScrollba
rThemePainter::Create(false).PassAs<ScrollbarThemePainter>(), FakeWebScrollbarTh
emeGeometry::create(true), 1); |
| 151 m_scrollbarLayer->setLayerTreeHost(m_layerTreeHost.get()); | 151 m_scrollbarLayer->setLayerTreeHost(m_layerTreeHost.get()); |
| 152 m_scrollbarLayer->setBounds(m_bounds); | 152 m_scrollbarLayer->setBounds(m_bounds); |
| 153 m_layerTreeHost->rootLayer()->addChild(m_scrollbarLayer); | 153 m_layerTreeHost->rootLayer()->addChild(m_scrollbarLayer); |
| 154 | 154 |
| 155 m_scrollLayer = Layer::create(); | 155 m_scrollLayer = Layer::create(); |
| 156 m_scrollbarLayer->setScrollLayerId(m_scrollLayer->id()); | 156 m_scrollbarLayer->setScrollLayerId(m_scrollLayer->id()); |
| 157 m_layerTreeHost->rootLayer()->addChild(m_scrollLayer); | 157 m_layerTreeHost->rootLayer()->addChild(m_scrollLayer); |
| 158 | 158 |
| 159 postSetNeedsCommitToMainThread(); | 159 postSetNeedsCommitToMainThread(); |
| 160 } | 160 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 185 TEST_F(ScrollbarLayerTestMaxTextureSize, runTest) { | 185 TEST_F(ScrollbarLayerTestMaxTextureSize, runTest) { |
| 186 scoped_ptr<FakeWebGraphicsContext3D> context = FakeWebGraphicsContext3D::Cre
ate(); | 186 scoped_ptr<FakeWebGraphicsContext3D> context = FakeWebGraphicsContext3D::Cre
ate(); |
| 187 int max_size = 0; | 187 int max_size = 0; |
| 188 context->getIntegerv(GL_MAX_TEXTURE_SIZE, &max_size); | 188 context->getIntegerv(GL_MAX_TEXTURE_SIZE, &max_size); |
| 189 setScrollbarBounds(gfx::Size(max_size + 100, max_size + 100)); | 189 setScrollbarBounds(gfx::Size(max_size + 100, max_size + 100)); |
| 190 runTest(true); | 190 runTest(true); |
| 191 } | 191 } |
| 192 | 192 |
| 193 } // namespace | 193 } // namespace |
| 194 } // namespace cc | 194 } // namespace cc |
| OLD | NEW |