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 5223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5234 wheel_scroll_delta)); | 5234 wheel_scroll_delta)); |
5235 } | 5235 } |
5236 | 5236 |
5237 TEST_F(LayerTreeHostImplTest, ScrollViewportRounding) { | 5237 TEST_F(LayerTreeHostImplTest, ScrollViewportRounding) { |
5238 int width = 332; | 5238 int width = 332; |
5239 int height = 20; | 5239 int height = 20; |
5240 int scale = 3; | 5240 int scale = 3; |
5241 SetupScrollAndContentsLayers(gfx::Size(width, height)); | 5241 SetupScrollAndContentsLayers(gfx::Size(width, height)); |
5242 host_impl_->active_tree()->InnerViewportContainerLayer()->SetBounds( | 5242 host_impl_->active_tree()->InnerViewportContainerLayer()->SetBounds( |
5243 gfx::Size(width * scale - 1, height * scale)); | 5243 gfx::Size(width * scale - 1, height * scale)); |
| 5244 RebuildPropertyTrees(); |
5244 host_impl_->active_tree()->SetDeviceScaleFactor(scale); | 5245 host_impl_->active_tree()->SetDeviceScaleFactor(scale); |
5245 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); | 5246 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); |
5246 | 5247 |
5247 LayerImpl* inner_viewport_scroll_layer = | 5248 LayerImpl* inner_viewport_scroll_layer = |
5248 host_impl_->active_tree()->InnerViewportScrollLayer(); | 5249 host_impl_->active_tree()->InnerViewportScrollLayer(); |
5249 EXPECT_EQ(gfx::ScrollOffset(0, 0), | 5250 EXPECT_EQ(gfx::ScrollOffset(0, 0), |
5250 inner_viewport_scroll_layer->MaxScrollOffset()); | 5251 inner_viewport_scroll_layer->MaxScrollOffset()); |
5251 } | 5252 } |
5252 | 5253 |
5253 class TestInputHandlerClient : public InputHandlerClient { | 5254 class TestInputHandlerClient : public InputHandlerClient { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5312 float min_page_scale_factor_; | 5313 float min_page_scale_factor_; |
5313 float max_page_scale_factor_; | 5314 float max_page_scale_factor_; |
5314 }; | 5315 }; |
5315 | 5316 |
5316 TEST_F(LayerTreeHostImplTest, RootLayerScrollOffsetDelegation) { | 5317 TEST_F(LayerTreeHostImplTest, RootLayerScrollOffsetDelegation) { |
5317 TestInputHandlerClient scroll_watcher; | 5318 TestInputHandlerClient scroll_watcher; |
5318 host_impl_->SetViewportSize(gfx::Size(10, 20)); | 5319 host_impl_->SetViewportSize(gfx::Size(10, 20)); |
5319 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 5320 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
5320 LayerImpl* clip_layer = scroll_layer->parent()->parent(); | 5321 LayerImpl* clip_layer = scroll_layer->parent()->parent(); |
5321 clip_layer->SetBounds(gfx::Size(10, 20)); | 5322 clip_layer->SetBounds(gfx::Size(10, 20)); |
| 5323 RebuildPropertyTrees(); |
5322 | 5324 |
5323 host_impl_->BindToClient(&scroll_watcher); | 5325 host_impl_->BindToClient(&scroll_watcher); |
5324 | 5326 |
5325 gfx::Vector2dF initial_scroll_delta(10.f, 10.f); | 5327 gfx::Vector2dF initial_scroll_delta(10.f, 10.f); |
5326 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); | 5328 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); |
5327 scroll_layer->SetScrollDelta(initial_scroll_delta); | 5329 scroll_layer->SetScrollDelta(initial_scroll_delta); |
5328 | 5330 |
5329 EXPECT_EQ(gfx::ScrollOffset(), scroll_watcher.last_set_scroll_offset()); | 5331 EXPECT_EQ(gfx::ScrollOffset(), scroll_watcher.last_set_scroll_offset()); |
5330 | 5332 |
5331 // Requesting an update results in the current scroll offset being set. | 5333 // Requesting an update results in the current scroll offset being set. |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5682 } | 5684 } |
5683 | 5685 |
5684 TEST_F(LayerTreeHostImplTest, OverscrollAlways) { | 5686 TEST_F(LayerTreeHostImplTest, OverscrollAlways) { |
5685 InputHandlerScrollResult scroll_result; | 5687 InputHandlerScrollResult scroll_result; |
5686 LayerTreeSettings settings = DefaultSettings(); | 5688 LayerTreeSettings settings = DefaultSettings(); |
5687 CreateHostImpl(settings, CreateOutputSurface()); | 5689 CreateHostImpl(settings, CreateOutputSurface()); |
5688 | 5690 |
5689 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(50, 50)); | 5691 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(50, 50)); |
5690 LayerImpl* clip_layer = scroll_layer->parent()->parent(); | 5692 LayerImpl* clip_layer = scroll_layer->parent()->parent(); |
5691 clip_layer->SetBounds(gfx::Size(50, 50)); | 5693 clip_layer->SetBounds(gfx::Size(50, 50)); |
| 5694 RebuildPropertyTrees(); |
5692 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 5695 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
5693 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); | 5696 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); |
5694 DrawFrame(); | 5697 DrawFrame(); |
5695 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 5698 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
5696 | 5699 |
5697 // Even though the layer can't scroll the overscroll still happens. | 5700 // Even though the layer can't scroll the overscroll still happens. |
5698 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5701 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
5699 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 5702 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
5700 InputHandler::WHEEL) | 5703 InputHandler::WHEEL) |
5701 .thread); | 5704 .thread); |
(...skipping 4193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9895 host_impl_->ActivateSyncTree(); | 9898 host_impl_->ActivateSyncTree(); |
9896 DrawFrame(); | 9899 DrawFrame(); |
9897 | 9900 |
9898 host_impl_->CreatePendingTree(); | 9901 host_impl_->CreatePendingTree(); |
9899 host_impl_->active_tree()->SetPageScaleOnActiveTree(2.f); | 9902 host_impl_->active_tree()->SetPageScaleOnActiveTree(2.f); |
9900 LayerImpl* page_scale_layer = host_impl_->active_tree()->PageScaleLayer(); | 9903 LayerImpl* page_scale_layer = host_impl_->active_tree()->PageScaleLayer(); |
9901 | 9904 |
9902 TransformNode* active_tree_node = | 9905 TransformNode* active_tree_node = |
9903 host_impl_->active_tree()->property_trees()->transform_tree.Node( | 9906 host_impl_->active_tree()->property_trees()->transform_tree.Node( |
9904 page_scale_layer->transform_tree_index()); | 9907 page_scale_layer->transform_tree_index()); |
9905 EXPECT_EQ(active_tree_node->data.post_local_scale_factor, 1.f); | 9908 // SetPageScaleOnActiveTree also updates the factors in property trees. |
| 9909 EXPECT_EQ(active_tree_node->data.post_local_scale_factor, 2.f); |
9906 EXPECT_EQ(host_impl_->active_tree()->current_page_scale_factor(), 2.f); | 9910 EXPECT_EQ(host_impl_->active_tree()->current_page_scale_factor(), 2.f); |
9907 | 9911 |
9908 TransformNode* pending_tree_node = | 9912 TransformNode* pending_tree_node = |
9909 host_impl_->pending_tree()->property_trees()->transform_tree.Node( | 9913 host_impl_->pending_tree()->property_trees()->transform_tree.Node( |
9910 page_scale_layer->transform_tree_index()); | 9914 page_scale_layer->transform_tree_index()); |
9911 EXPECT_EQ(pending_tree_node->data.post_local_scale_factor, 1.f); | 9915 EXPECT_EQ(pending_tree_node->data.post_local_scale_factor, 1.f); |
9912 EXPECT_EQ(host_impl_->pending_tree()->current_page_scale_factor(), 2.f); | 9916 EXPECT_EQ(host_impl_->pending_tree()->current_page_scale_factor(), 2.f); |
9913 | 9917 |
9914 host_impl_->pending_tree()->UpdateDrawProperties(false); | 9918 host_impl_->pending_tree()->UpdateDrawProperties(false); |
9915 pending_tree_node = | 9919 pending_tree_node = |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9997 // There should not be any jitter measured till we hit the fixed point hits | 10001 // There should not be any jitter measured till we hit the fixed point hits |
9998 // threshold. | 10002 // threshold. |
9999 float expected_jitter = | 10003 float expected_jitter = |
10000 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0; | 10004 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0; |
10001 EXPECT_EQ(jitter, expected_jitter); | 10005 EXPECT_EQ(jitter, expected_jitter); |
10002 } | 10006 } |
10003 } | 10007 } |
10004 | 10008 |
10005 } // namespace | 10009 } // namespace |
10006 } // namespace cc | 10010 } // namespace cc |
OLD | NEW |