| 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" |
| (...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 | 636 |
| 637 TEST_F(ScrollbarLayerTest, ScrollbarLayerOpacity) { | 637 TEST_F(ScrollbarLayerTest, ScrollbarLayerOpacity) { |
| 638 const int kThumbThickness = 3; | 638 const int kThumbThickness = 3; |
| 639 const int kTrackStart = 0; | 639 const int kTrackStart = 0; |
| 640 | 640 |
| 641 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, true)); | 641 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, true)); |
| 642 | 642 |
| 643 scoped_refptr<Layer> layer_tree_root = Layer::Create(); | 643 scoped_refptr<Layer> layer_tree_root = Layer::Create(); |
| 644 scoped_refptr<Layer> scroll_layer = Layer::Create(); | 644 scoped_refptr<Layer> scroll_layer = Layer::Create(); |
| 645 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); | 645 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); |
| 646 scroll_layer->SetElementId(ElementId(200)); |
| 646 scoped_refptr<Layer> child1 = Layer::Create(); | 647 scoped_refptr<Layer> child1 = Layer::Create(); |
| 647 scoped_refptr<Layer> scrollbar_layer; | 648 scoped_refptr<SolidColorScrollbarLayer> scrollbar_layer; |
| 648 const bool kIsLeftSideVerticalScrollbar = false; | 649 const bool kIsLeftSideVerticalScrollbar = false; |
| 649 scrollbar_layer = SolidColorScrollbarLayer::Create( | 650 scrollbar_layer = SolidColorScrollbarLayer::Create( |
| 650 scrollbar->Orientation(), kThumbThickness, kTrackStart, | 651 scrollbar->Orientation(), kThumbThickness, kTrackStart, |
| 651 kIsLeftSideVerticalScrollbar, scroll_layer->element_id()); | 652 kIsLeftSideVerticalScrollbar, scroll_layer->element_id()); |
| 653 scrollbar_layer->SetElementId(ElementId(300)); |
| 652 scroll_layer->AddChild(child1); | 654 scroll_layer->AddChild(child1); |
| 653 scroll_layer->InsertChild(scrollbar_layer, 1); | 655 scroll_layer->InsertChild(scrollbar_layer, 1); |
| 654 layer_tree_root->AddChild(scroll_layer); | 656 layer_tree_root->AddChild(scroll_layer); |
| 655 layer_tree_host_->SetRootLayer(layer_tree_root); | 657 layer_tree_host_->SetRootLayer(layer_tree_root); |
| 658 scrollbar_layer->SetScrollElementId(scroll_layer->element_id()); |
| 656 | 659 |
| 657 // Choose layer bounds to give max_scroll_offset = (8, 8). | 660 // Choose layer bounds to give max_scroll_offset = (8, 8). |
| 658 layer_tree_root->SetBounds(gfx::Size(2, 2)); | 661 layer_tree_root->SetBounds(gfx::Size(2, 2)); |
| 659 scroll_layer->SetBounds(gfx::Size(10, 10)); | 662 scroll_layer->SetBounds(gfx::Size(10, 10)); |
| 660 | 663 |
| 661 // Building property trees twice shouldn't change the size of | 664 // Building property trees twice shouldn't change the size of |
| 662 // PropertyTrees::always_use_active_tree_opacity_effect_ids. | 665 // PropertyTrees::always_use_active_tree_opacity_effect_ids. |
| 663 layer_tree_host_->BuildPropertyTreesForTesting(); | 666 layer_tree_host_->BuildPropertyTreesForTesting(); |
| 664 EXPECT_EQ(layer_tree_host_->property_trees() | |
| 665 ->always_use_active_tree_opacity_effect_ids.size(), | |
| 666 1u); | |
| 667 layer_tree_host_->property_trees()->needs_rebuild = true; | 667 layer_tree_host_->property_trees()->needs_rebuild = true; |
| 668 layer_tree_host_->BuildPropertyTreesForTesting(); | 668 layer_tree_host_->BuildPropertyTreesForTesting(); |
| 669 EXPECT_EQ(layer_tree_host_->property_trees() | |
| 670 ->always_use_active_tree_opacity_effect_ids.size(), | |
| 671 1u); | |
| 672 | 669 |
| 673 // A solid color scrollbar layer's opacity is initialized to 0 on main thread | 670 // A solid color scrollbar layer's opacity is initialized to 0 on main thread |
| 674 layer_tree_host_->UpdateLayers(); | 671 layer_tree_host_->UpdateLayers(); |
| 675 EffectNode* node = layer_tree_host_->property_trees()->effect_tree.Node( | 672 EffectNode* node = layer_tree_host_->property_trees()->effect_tree.Node( |
| 676 scrollbar_layer->effect_tree_index()); | 673 scrollbar_layer->effect_tree_index()); |
| 677 EXPECT_EQ(node->opacity, 0.f); | 674 EXPECT_EQ(node->opacity, 0.f); |
| 678 | 675 |
| 679 // This tests that the initial opacity(0) of the scrollbar gets pushed onto | 676 // This tests that the initial opacity(0) of the scrollbar gets pushed onto |
| 680 // the pending tree and then onto the active tree. | 677 // the pending tree and then onto the active tree. |
| 681 LayerTreeHostImpl* host_impl = layer_tree_host_->host_impl(); | 678 LayerTreeHostImpl* host_impl = layer_tree_host_->host_impl(); |
| (...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1270 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); | 1267 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); |
| 1271 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); | 1268 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); |
| 1272 | 1269 |
| 1273 // Horizontal Scrollbars. | 1270 // Horizontal Scrollbars. |
| 1274 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); | 1271 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); |
| 1275 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); | 1272 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); |
| 1276 } | 1273 } |
| 1277 | 1274 |
| 1278 } // namespace | 1275 } // namespace |
| 1279 } // namespace cc | 1276 } // namespace cc |
| OLD | NEW |