| 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/threading/thread_task_runner_handle.h" | 9 #include "base/threading/thread_task_runner_handle.h" |
| 10 #include "cc/input/scrollbar_animation_controller.h" | 10 #include "cc/input/scrollbar_animation_controller.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 int next_id_; | 92 int next_id_; |
| 93 int total_ui_resource_created_; | 93 int total_ui_resource_created_; |
| 94 int total_ui_resource_deleted_; | 94 int total_ui_resource_deleted_; |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 class ScrollbarLayerTest : public testing::Test { | 97 class ScrollbarLayerTest : public testing::Test { |
| 98 public: | 98 public: |
| 99 ScrollbarLayerTest() : fake_client_(FakeLayerTreeHostClient::DIRECT_3D) { | 99 ScrollbarLayerTest() : fake_client_(FakeLayerTreeHostClient::DIRECT_3D) { |
| 100 layer_tree_settings_.single_thread_proxy_scheduler = false; | 100 layer_tree_settings_.single_thread_proxy_scheduler = false; |
| 101 layer_tree_settings_.use_zero_copy = true; | 101 layer_tree_settings_.use_zero_copy = true; |
| 102 layer_tree_settings_.scrollbar_animator = LayerTreeSettings::LINEAR_FADE; |
| 103 layer_tree_settings_.scrollbar_fade_delay_ms = 20; |
| 104 layer_tree_settings_.scrollbar_fade_duration_ms = 20; |
| 102 | 105 |
| 103 scrollbar_layer_id_ = -1; | 106 scrollbar_layer_id_ = -1; |
| 104 | 107 |
| 105 LayerTreeHost::InitParams params; | 108 LayerTreeHost::InitParams params; |
| 106 params.client = &fake_client_; | 109 params.client = &fake_client_; |
| 107 params.settings = &layer_tree_settings_; | 110 params.settings = &layer_tree_settings_; |
| 108 params.task_graph_runner = &task_graph_runner_; | 111 params.task_graph_runner = &task_graph_runner_; |
| 109 | 112 |
| 110 layer_tree_host_.reset( | 113 layer_tree_host_.reset( |
| 111 new FakeResourceTrackingLayerTreeHost(&fake_client_, ¶ms)); | 114 new FakeResourceTrackingLayerTreeHost(&fake_client_, ¶ms)); |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 EXPECT_EQ(node->data.opacity, 0.5f); | 546 EXPECT_EQ(node->data.opacity, 0.5f); |
| 544 // The active tree opacity should not change with activation for scrollbar | 547 // The active tree opacity should not change with activation for scrollbar |
| 545 // layer. | 548 // layer. |
| 546 host_impl->ActivateSyncTree(); | 549 host_impl->ActivateSyncTree(); |
| 547 layer_tree_impl = host_impl->active_tree(); | 550 layer_tree_impl = host_impl->active_tree(); |
| 548 node = layer_tree_impl->property_trees()->effect_tree.Node( | 551 node = layer_tree_impl->property_trees()->effect_tree.Node( |
| 549 scrollbar_layer->effect_tree_index()); | 552 scrollbar_layer->effect_tree_index()); |
| 550 EXPECT_EQ(node->data.opacity, 1.f); | 553 EXPECT_EQ(node->data.opacity, 1.f); |
| 551 } | 554 } |
| 552 | 555 |
| 556 TEST_F(ScrollbarLayerTest, ScrollbarLayerPushProperties) { |
| 557 // Pushing changed bounds of scroll layer can lead to calling |
| 558 // OnOpacityAnimated on scrollbar layer which means OnOpacityAnimated should |
| 559 // be independent of scrollbar layer's properties as scrollbar layer can push |
| 560 // its properties after scroll layer. |
| 561 const int kThumbThickness = 3; |
| 562 const int kTrackStart = 0; |
| 563 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, true)); |
| 564 |
| 565 scoped_refptr<Layer> layer_tree_root = Layer::Create(); |
| 566 scoped_refptr<Layer> scroll_layer = Layer::Create(); |
| 567 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); |
| 568 scoped_refptr<Layer> child1 = Layer::Create(); |
| 569 scoped_refptr<Layer> scrollbar_layer; |
| 570 const bool kIsLeftSideVerticalScrollbar = false; |
| 571 scrollbar_layer = SolidColorScrollbarLayer::Create( |
| 572 scrollbar->Orientation(), kThumbThickness, kTrackStart, |
| 573 kIsLeftSideVerticalScrollbar, child1->id()); |
| 574 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); |
| 575 scrollbar_layer->ToScrollbarLayer()->SetScrollLayer(scroll_layer->id()); |
| 576 scroll_layer->AddChild(child1); |
| 577 scroll_layer->InsertChild(scrollbar_layer, 1); |
| 578 layer_tree_root->AddChild(scroll_layer); |
| 579 layer_tree_host_->SetRootLayer(layer_tree_root); |
| 580 |
| 581 layer_tree_root->SetBounds(gfx::Size(2, 2)); |
| 582 scroll_layer->SetBounds(gfx::Size(10, 10)); |
| 583 layer_tree_host_->UpdateLayers(); |
| 584 layer_tree_host_->CommitAndCreateLayerImplTree(); |
| 585 LayerTreeHostImpl* host_impl = layer_tree_host_->host_impl(); |
| 586 EXPECT_TRUE(host_impl->ScrollbarAnimationControllerForId(scroll_layer->id())); |
| 587 |
| 588 scroll_layer->SetBounds(gfx::Size(20, 20)); |
| 589 scroll_layer->SetForceRenderSurfaceForTesting(true); |
| 590 layer_tree_host_->UpdateLayers(); |
| 591 host_impl->CreatePendingTree(); |
| 592 layer_tree_host_->CommitAndCreatePendingTree(); |
| 593 host_impl->ActivateSyncTree(); |
| 594 EffectNode* node = |
| 595 host_impl->active_tree()->property_trees()->effect_tree.Node( |
| 596 scrollbar_layer->effect_tree_index()); |
| 597 EXPECT_EQ(node->data.opacity, 1.f); |
| 598 } |
| 599 |
| 553 class ScrollbarLayerSolidColorThumbTest : public testing::Test { | 600 class ScrollbarLayerSolidColorThumbTest : public testing::Test { |
| 554 public: | 601 public: |
| 555 ScrollbarLayerSolidColorThumbTest() { | 602 ScrollbarLayerSolidColorThumbTest() { |
| 556 LayerTreeSettings layer_tree_settings; | 603 LayerTreeSettings layer_tree_settings; |
| 557 host_impl_.reset(new FakeLayerTreeHostImpl( | 604 host_impl_.reset(new FakeLayerTreeHostImpl( |
| 558 layer_tree_settings, &task_runner_provider_, &shared_bitmap_manager_, | 605 layer_tree_settings, &task_runner_provider_, &shared_bitmap_manager_, |
| 559 &task_graph_runner_)); | 606 &task_graph_runner_)); |
| 560 | 607 |
| 561 const int kThumbThickness = 3; | 608 const int kThumbThickness = 3; |
| 562 const int kTrackStart = 0; | 609 const int kTrackStart = 0; |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1072 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); | 1119 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); |
| 1073 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); | 1120 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); |
| 1074 | 1121 |
| 1075 // Horizontal Scrollbars. | 1122 // Horizontal Scrollbars. |
| 1076 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); | 1123 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); |
| 1077 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); | 1124 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); |
| 1078 } | 1125 } |
| 1079 | 1126 |
| 1080 } // namespace | 1127 } // namespace |
| 1081 } // namespace cc | 1128 } // namespace cc |
| OLD | NEW |