| 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 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 layer_tree_host_->UpdateLayers(); | 756 layer_tree_host_->UpdateLayers(); |
| 756 host_impl->CreatePendingTree(); | 757 host_impl->CreatePendingTree(); |
| 757 layer_tree_host_->CommitAndCreatePendingTree(); | 758 layer_tree_host_->CommitAndCreatePendingTree(); |
| 758 host_impl->ActivateSyncTree(); | 759 host_impl->ActivateSyncTree(); |
| 759 EffectNode* node = | 760 EffectNode* node = |
| 760 host_impl->active_tree()->property_trees()->effect_tree.Node( | 761 host_impl->active_tree()->property_trees()->effect_tree.Node( |
| 761 scrollbar_layer->effect_tree_index()); | 762 scrollbar_layer->effect_tree_index()); |
| 762 EXPECT_EQ(node->opacity, 1.f); | 763 EXPECT_EQ(node->opacity, 1.f); |
| 763 } | 764 } |
| 764 | 765 |
| 766 TEST_F(ScrollbarLayerTest, SubPixelCanScrollOrientation) { |
| 767 gfx::Size viewport_size(980, 980); |
| 768 |
| 769 LayerTestCommon::LayerImplTest impl; |
| 770 |
| 771 LayerImpl* clip_layer = impl.AddChildToRoot<LayerImpl>(); |
| 772 LayerImpl* scroll_layer = impl.AddChild<LayerImpl>(clip_layer); |
| 773 |
| 774 scroll_layer->SetScrollClipLayer(clip_layer->id()); |
| 775 scroll_layer->SetElementId(LayerIdToElementIdForTesting(scroll_layer->id())); |
| 776 |
| 777 const int kTrackStart = 0; |
| 778 const int kThumbThickness = 10; |
| 779 const bool kIsLeftSideVerticalScrollbar = false; |
| 780 const bool kIsOverlayScrollbar = false; |
| 781 |
| 782 SolidColorScrollbarLayerImpl* scrollbar_layer = |
| 783 impl.AddChild<SolidColorScrollbarLayerImpl>( |
| 784 scroll_layer, HORIZONTAL, kThumbThickness, kTrackStart, |
| 785 kIsLeftSideVerticalScrollbar, kIsOverlayScrollbar); |
| 786 |
| 787 scrollbar_layer->SetScrollElementId(scroll_layer->element_id()); |
| 788 clip_layer->SetBounds(gfx::Size(980, 980)); |
| 789 scroll_layer->SetBounds(gfx::Size(980, 980)); |
| 790 |
| 791 impl.CalcDrawProps(viewport_size); |
| 792 |
| 793 // Fake clip layer length to scrollbar to mock rounding error. |
| 794 scrollbar_layer->SetClipLayerLength(979.999939f); |
| 795 |
| 796 EXPECT_FALSE(scrollbar_layer->CanScrollOrientation()); |
| 797 |
| 798 // Fake clip layer length to scrollable. |
| 799 scrollbar_layer->SetClipLayerLength(979.0f); |
| 800 |
| 801 EXPECT_TRUE(scrollbar_layer->CanScrollOrientation()); |
| 802 } |
| 803 |
| 765 class ScrollbarLayerSolidColorThumbTest : public testing::Test { | 804 class ScrollbarLayerSolidColorThumbTest : public testing::Test { |
| 766 public: | 805 public: |
| 767 ScrollbarLayerSolidColorThumbTest() { | 806 ScrollbarLayerSolidColorThumbTest() { |
| 768 LayerTreeSettings layer_tree_settings; | 807 LayerTreeSettings layer_tree_settings; |
| 769 host_impl_.reset(new FakeLayerTreeHostImpl( | 808 host_impl_.reset(new FakeLayerTreeHostImpl( |
| 770 layer_tree_settings, &task_runner_provider_, &task_graph_runner_)); | 809 layer_tree_settings, &task_runner_provider_, &task_graph_runner_)); |
| 771 | 810 |
| 772 const int kThumbThickness = 3; | 811 const int kThumbThickness = 3; |
| 773 const int kTrackStart = 0; | 812 const int kTrackStart = 0; |
| 774 const bool kIsLeftSideVerticalScrollbar = false; | 813 const bool kIsLeftSideVerticalScrollbar = false; |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1239 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); | 1278 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); |
| 1240 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); | 1279 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); |
| 1241 | 1280 |
| 1242 // Horizontal Scrollbars. | 1281 // Horizontal Scrollbars. |
| 1243 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); | 1282 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); |
| 1244 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); | 1283 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); |
| 1245 } | 1284 } |
| 1246 | 1285 |
| 1247 } // namespace | 1286 } // namespace |
| 1248 } // namespace cc | 1287 } // namespace cc |
| OLD | NEW |