| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <unordered_map> | 7 #include <unordered_map> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| 11 #include "cc/animation/animation_host.h" | 11 #include "cc/animation/animation_host.h" |
| 12 #include "cc/input/scrollbar_animation_controller.h" | 12 #include "cc/input/scrollbar_animation_controller.h" |
| 13 #include "cc/layers/append_quads_data.h" | 13 #include "cc/layers/append_quads_data.h" |
| 14 #include "cc/layers/painted_overlay_scrollbar_layer.h" | 14 #include "cc/layers/painted_overlay_scrollbar_layer.h" |
| 15 #include "cc/layers/painted_scrollbar_layer.h" | 15 #include "cc/layers/painted_scrollbar_layer.h" |
| 16 #include "cc/layers/painted_scrollbar_layer_impl.h" | 16 #include "cc/layers/painted_scrollbar_layer_impl.h" |
| 17 #include "cc/layers/scrollbar_layer_interface.h" | 17 #include "cc/layers/scrollbar_layer_interface.h" |
| 18 #include "cc/layers/solid_color_scrollbar_layer.h" | 18 #include "cc/layers/solid_color_scrollbar_layer.h" |
| 19 #include "cc/layers/solid_color_scrollbar_layer_impl.h" | 19 #include "cc/layers/solid_color_scrollbar_layer_impl.h" |
| 20 #include "cc/quads/solid_color_draw_quad.h" | 20 #include "cc/quads/solid_color_draw_quad.h" |
| 21 #include "cc/resources/ui_resource_manager.h" | 21 #include "cc/resources/ui_resource_manager.h" |
| 22 #include "cc/test/fake_impl_task_runner_provider.h" | 22 #include "cc/test/fake_impl_task_runner_provider.h" |
| 23 #include "cc/test/fake_layer_tree_host.h" | 23 #include "cc/test/fake_layer_tree_host.h" |
| 24 #include "cc/test/fake_layer_tree_host_client.h" | 24 #include "cc/test/fake_layer_tree_host_client.h" |
| 25 #include "cc/test/fake_layer_tree_host_impl.h" | 25 #include "cc/test/fake_layer_tree_host_impl.h" |
| 26 #include "cc/test/fake_painted_scrollbar_layer.h" | 26 #include "cc/test/fake_painted_scrollbar_layer.h" |
| 27 #include "cc/test/fake_scrollbar.h" | 27 #include "cc/test/fake_scrollbar.h" |
| 28 #include "cc/test/geometry_test_utils.h" | 28 #include "cc/test/geometry_test_utils.h" |
| 29 #include "cc/test/layer_test_common.h" |
| 29 #include "cc/test/layer_tree_test.h" | 30 #include "cc/test/layer_tree_test.h" |
| 30 #include "cc/test/mock_occlusion_tracker.h" | 31 #include "cc/test/mock_occlusion_tracker.h" |
| 31 #include "cc/test/stub_layer_tree_host_single_thread_client.h" | 32 #include "cc/test/stub_layer_tree_host_single_thread_client.h" |
| 32 #include "cc/test/test_context_provider.h" | 33 #include "cc/test/test_context_provider.h" |
| 33 #include "cc/test/test_task_graph_runner.h" | 34 #include "cc/test/test_task_graph_runner.h" |
| 34 #include "cc/test/test_web_graphics_context_3d.h" | 35 #include "cc/test/test_web_graphics_context_3d.h" |
| 35 #include "cc/trees/effect_node.h" | 36 #include "cc/trees/effect_node.h" |
| 36 #include "cc/trees/layer_tree_host.h" | 37 #include "cc/trees/layer_tree_host.h" |
| 37 #include "cc/trees/layer_tree_impl.h" | 38 #include "cc/trees/layer_tree_impl.h" |
| 38 #include "cc/trees/occlusion_tracker.h" | 39 #include "cc/trees/occlusion_tracker.h" |
| (...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 layer_tree_host_->UpdateLayers(); | 763 layer_tree_host_->UpdateLayers(); |
| 763 host_impl->CreatePendingTree(); | 764 host_impl->CreatePendingTree(); |
| 764 layer_tree_host_->CommitAndCreatePendingTree(); | 765 layer_tree_host_->CommitAndCreatePendingTree(); |
| 765 host_impl->ActivateSyncTree(); | 766 host_impl->ActivateSyncTree(); |
| 766 EffectNode* node = | 767 EffectNode* node = |
| 767 host_impl->active_tree()->property_trees()->effect_tree.Node( | 768 host_impl->active_tree()->property_trees()->effect_tree.Node( |
| 768 scrollbar_layer->effect_tree_index()); | 769 scrollbar_layer->effect_tree_index()); |
| 769 EXPECT_EQ(node->opacity, 1.f); | 770 EXPECT_EQ(node->opacity, 1.f); |
| 770 } | 771 } |
| 771 | 772 |
| 773 TEST_F(ScrollbarLayerTest, SubPixelCanScrollOrientation) { |
| 774 gfx::Size viewport_size(100, 100); |
| 775 |
| 776 LayerTestCommon::LayerImplTest impl; |
| 777 |
| 778 LayerImpl* clip_layer = impl.AddChildToRoot<LayerImpl>(); |
| 779 LayerImpl* scroll_layer = impl.AddChild<LayerImpl>(clip_layer); |
| 780 |
| 781 scroll_layer->SetScrollClipLayer(clip_layer->id()); |
| 782 |
| 783 const int kTrackStart = 0; |
| 784 const int kThumbThickness = 10; |
| 785 const bool kIsLeftSideVerticalScrollbar = false; |
| 786 const bool kIsOverlayScrollbar = false; |
| 787 |
| 788 SolidColorScrollbarLayerImpl* scrollbar_layer = |
| 789 impl.AddChild<SolidColorScrollbarLayerImpl>( |
| 790 scroll_layer, HORIZONTAL, kThumbThickness, kTrackStart, |
| 791 kIsLeftSideVerticalScrollbar, kIsOverlayScrollbar); |
| 792 |
| 793 scrollbar_layer->SetScrollInfo(scroll_layer->id(), |
| 794 scrollbar_layer->element_id()); |
| 795 clip_layer->SetBounds(gfx::Size(100, 100)); |
| 796 scroll_layer->SetBounds(gfx::Size(100, 100)); |
| 797 |
| 798 impl.CalcDrawProps(viewport_size); |
| 799 |
| 800 // Fake device scale. |
| 801 impl.host_impl()->active_tree()->SetDeviceScaleFactor(3); |
| 802 |
| 803 // Fake clip layer length to scrollbar to mock rounding error. |
| 804 scrollbar_layer->SetClipLayerLength(99.99f); |
| 805 |
| 806 EXPECT_FALSE(scrollbar_layer->CanScrollOrientation()); |
| 807 |
| 808 // Fake clip layer length to scrollbar to 1 device pixel shorter than scroll |
| 809 // layer. |
| 810 scrollbar_layer->SetClipLayerLength(99.65f); |
| 811 |
| 812 EXPECT_TRUE(scrollbar_layer->CanScrollOrientation()); |
| 813 } |
| 814 |
| 772 class ScrollbarLayerSolidColorThumbTest : public testing::Test { | 815 class ScrollbarLayerSolidColorThumbTest : public testing::Test { |
| 773 public: | 816 public: |
| 774 ScrollbarLayerSolidColorThumbTest() { | 817 ScrollbarLayerSolidColorThumbTest() { |
| 775 LayerTreeSettings layer_tree_settings; | 818 LayerTreeSettings layer_tree_settings; |
| 776 host_impl_.reset(new FakeLayerTreeHostImpl( | 819 host_impl_.reset(new FakeLayerTreeHostImpl( |
| 777 layer_tree_settings, &task_runner_provider_, &task_graph_runner_)); | 820 layer_tree_settings, &task_runner_provider_, &task_graph_runner_)); |
| 778 | 821 |
| 779 const int kThumbThickness = 3; | 822 const int kThumbThickness = 3; |
| 780 const int kTrackStart = 0; | 823 const int kTrackStart = 0; |
| 781 const bool kIsLeftSideVerticalScrollbar = false; | 824 const bool kIsLeftSideVerticalScrollbar = false; |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1249 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); | 1292 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); |
| 1250 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); | 1293 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); |
| 1251 | 1294 |
| 1252 // Horizontal Scrollbars. | 1295 // Horizontal Scrollbars. |
| 1253 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); | 1296 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); |
| 1254 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); | 1297 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); |
| 1255 } | 1298 } |
| 1256 | 1299 |
| 1257 } // namespace | 1300 } // namespace |
| 1258 } // namespace cc | 1301 } // namespace cc |
| OLD | NEW |