OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cmath> | 10 #include <cmath> |
(...skipping 2847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2858 gfx::Size content_size(100, 100); | 2858 gfx::Size content_size(100, 100); |
2859 | 2859 |
2860 CreateHostImpl(settings, CreateOutputSurface()); | 2860 CreateHostImpl(settings, CreateOutputSurface()); |
2861 host_impl_->CreatePendingTree(); | 2861 host_impl_->CreatePendingTree(); |
2862 CreateScrollAndContentsLayers(host_impl_->pending_tree(), content_size); | 2862 CreateScrollAndContentsLayers(host_impl_->pending_tree(), content_size); |
2863 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar = | 2863 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar = |
2864 SolidColorScrollbarLayerImpl::Create(host_impl_->pending_tree(), 400, | 2864 SolidColorScrollbarLayerImpl::Create(host_impl_->pending_tree(), 400, |
2865 VERTICAL, 10, 0, false, true); | 2865 VERTICAL, 10, 0, false, true); |
2866 scrollbar->test_properties()->opacity = 0.f; | 2866 scrollbar->test_properties()->opacity = 0.f; |
2867 LayerImpl* scroll = host_impl_->pending_tree()->OuterViewportScrollLayer(); | 2867 LayerImpl* scroll = host_impl_->pending_tree()->OuterViewportScrollLayer(); |
2868 LayerImpl* root = host_impl_->pending_tree()->InnerViewportContainerLayer(); | 2868 LayerImpl* container = |
| 2869 host_impl_->pending_tree()->InnerViewportContainerLayer(); |
2869 scrollbar->SetScrollLayerId(scroll->id()); | 2870 scrollbar->SetScrollLayerId(scroll->id()); |
2870 root->AddChild(std::move(scrollbar)); | 2871 container->AddChild(std::move(scrollbar)); |
2871 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); | 2872 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); |
2872 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); | 2873 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); |
2873 host_impl_->ActivateSyncTree(); | 2874 host_impl_->ActivateSyncTree(); |
2874 | 2875 |
2875 LayerImpl* scrollbar_layer = host_impl_->active_tree()->LayerById(400); | 2876 LayerImpl* active_scrollbar_layer = |
| 2877 host_impl_->active_tree()->LayerById(400); |
2876 | 2878 |
2877 EffectNode* active_tree_node = | 2879 EffectNode* active_tree_node = |
2878 host_impl_->active_tree()->property_trees()->effect_tree.Node( | 2880 host_impl_->active_tree()->property_trees()->effect_tree.Node( |
2879 scrollbar_layer->effect_tree_index()); | 2881 active_scrollbar_layer->effect_tree_index()); |
2880 EXPECT_FLOAT_EQ(scrollbar_layer->Opacity(), active_tree_node->data.opacity); | 2882 EXPECT_FLOAT_EQ(active_scrollbar_layer->Opacity(), |
| 2883 active_tree_node->data.opacity); |
2881 | 2884 |
2882 host_impl_->ScrollbarAnimationControllerForId(scroll->id()) | 2885 host_impl_->ScrollbarAnimationControllerForId(scroll->id()) |
2883 ->DidMouseMoveNear(0); | 2886 ->DidMouseMoveNear(0); |
2884 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 2887 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
2885 InputHandler::WHEEL); | 2888 InputHandler::WHEEL); |
2886 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(0, 5)).get()); | 2889 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(0, 5)).get()); |
2887 host_impl_->ScrollEnd(EndState().get()); | 2890 host_impl_->ScrollEnd(EndState().get()); |
2888 host_impl_->CreatePendingTree(); | 2891 host_impl_->CreatePendingTree(); |
| 2892 // To test the case where the effect tree index of scrollbar layer changes, |
| 2893 // we force the container layer to create a render surface. |
| 2894 container = host_impl_->pending_tree()->InnerViewportContainerLayer(); |
| 2895 container->test_properties()->force_render_surface = true; |
| 2896 container->SetBounds(gfx::Size(10, 10)); |
| 2897 host_impl_->pending_tree()->property_trees()->needs_rebuild = true; |
| 2898 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); |
| 2899 |
| 2900 LayerImpl* pending_scrollbar_layer = |
| 2901 host_impl_->pending_tree()->LayerById(400); |
2889 EffectNode* pending_tree_node = | 2902 EffectNode* pending_tree_node = |
2890 host_impl_->pending_tree()->property_trees()->effect_tree.Node( | 2903 host_impl_->pending_tree()->property_trees()->effect_tree.Node( |
2891 scrollbar_layer->effect_tree_index()); | 2904 pending_scrollbar_layer->effect_tree_index()); |
2892 host_impl_->pending_tree() | 2905 host_impl_->pending_tree() |
2893 ->property_trees() | 2906 ->property_trees() |
2894 ->always_use_active_tree_opacity_effect_ids.push_back(400); | 2907 ->always_use_active_tree_opacity_effect_ids.push_back(400); |
2895 EXPECT_FLOAT_EQ(1.f, active_tree_node->data.opacity); | 2908 EXPECT_FLOAT_EQ(1.f, active_tree_node->data.opacity); |
2896 EXPECT_FLOAT_EQ(1.f, scrollbar_layer->Opacity()); | 2909 EXPECT_FLOAT_EQ(1.f, active_scrollbar_layer->Opacity()); |
2897 EXPECT_FLOAT_EQ(0.f, pending_tree_node->data.opacity); | 2910 EXPECT_FLOAT_EQ(0.f, pending_tree_node->data.opacity); |
2898 host_impl_->ActivateSyncTree(); | 2911 host_impl_->ActivateSyncTree(); |
2899 active_tree_node = | 2912 active_tree_node = |
2900 host_impl_->active_tree()->property_trees()->effect_tree.Node( | 2913 host_impl_->active_tree()->property_trees()->effect_tree.Node( |
2901 scrollbar_layer->effect_tree_index()); | 2914 active_scrollbar_layer->effect_tree_index()); |
2902 EXPECT_FLOAT_EQ(1.f, active_tree_node->data.opacity); | 2915 EXPECT_FLOAT_EQ(1.f, active_tree_node->data.opacity); |
2903 EXPECT_FLOAT_EQ(1.f, scrollbar_layer->Opacity()); | 2916 EXPECT_FLOAT_EQ(1.f, active_scrollbar_layer->Opacity()); |
2904 } | 2917 } |
2905 }; | 2918 }; |
2906 | 2919 |
2907 TEST_F(LayerTreeHostImplTestScrollbarOpacity, LinearFade) { | 2920 TEST_F(LayerTreeHostImplTestScrollbarOpacity, LinearFade) { |
2908 RunTest(LayerTreeSettings::LINEAR_FADE); | 2921 RunTest(LayerTreeSettings::LINEAR_FADE); |
2909 } | 2922 } |
2910 | 2923 |
2911 TEST_F(LayerTreeHostImplTestScrollbarOpacity, Thinning) { | 2924 TEST_F(LayerTreeHostImplTestScrollbarOpacity, Thinning) { |
2912 RunTest(LayerTreeSettings::THINNING); | 2925 RunTest(LayerTreeSettings::THINNING); |
2913 } | 2926 } |
(...skipping 7832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10746 | 10759 |
10747 // Re-initialize with a software output surface. | 10760 // Re-initialize with a software output surface. |
10748 output_surface_ = FakeOutputSurface::CreateSoftware( | 10761 output_surface_ = FakeOutputSurface::CreateSoftware( |
10749 base::WrapUnique(new SoftwareOutputDevice)); | 10762 base::WrapUnique(new SoftwareOutputDevice)); |
10750 host_impl_->InitializeRenderer(output_surface_.get()); | 10763 host_impl_->InitializeRenderer(output_surface_.get()); |
10751 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 10764 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
10752 } | 10765 } |
10753 | 10766 |
10754 } // namespace | 10767 } // namespace |
10755 } // namespace cc | 10768 } // namespace cc |
OLD | NEW |