Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(400)

Side by Side Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 1675963002: Move MaxScrollOffset to property_trees (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Apply comments. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
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 2701 matching lines...) Expand 10 before | Expand all | Expand 10 after
8403 EXPECT_EQ(-top_controls_height_, 8406 EXPECT_EQ(-top_controls_height_,
8404 host_impl_->top_controls_manager()->ControlsTopOffset()); 8407 host_impl_->top_controls_manager()->ControlsTopOffset());
8405 } 8408 }
8406 8409
8407 TEST_F(LayerTreeHostImplWithTopControlsTest, 8410 TEST_F(LayerTreeHostImplWithTopControlsTest,
8408 TopControlsScrollDeltaInOverScroll) { 8411 TopControlsScrollDeltaInOverScroll) {
8409 // Verifies that the overscroll delta should not have accumulated in 8412 // Verifies that the overscroll delta should not have accumulated in
8410 // the top controls if we do a hide and show without releasing finger. 8413 // the top controls if we do a hide and show without releasing finger.
8411 8414
8412 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); 8415 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200));
8413 host_impl_->SetViewportSize(gfx::Size(100, 100)); 8416 host_impl_->SetViewportSize(gfx::Size(100, 100));
ajuma 2016/02/09 22:35:05 If you build property trees here, you shouldn't ne
sunxd 2016/02/10 16:56:36 DrawFrame() forces a rebuild of property trees her
ajuma 2016/02/10 17:54:58 How about making a version of DrawFrame that doesn
8414 host_impl_->top_controls_manager()->UpdateTopControlsState(BOTH, SHOWN, 8417 host_impl_->top_controls_manager()->UpdateTopControlsState(BOTH, SHOWN,
8415 false); 8418 false);
8419
8420 LayerImpl* inner_clip_layer = scroll_layer->scroll_clip_layer();
8421 LayerImpl* outer_clip_layer = host_impl_->active_tree()
8422 ->OuterViewportScrollLayer()
8423 ->scroll_clip_layer();
8424
8425 gfx::Vector2dF scroll_bounds_delta = scroll_layer->bounds_delta();
8426 scroll_layer->SetBoundsDelta(gfx::Vector2dF());
8427
8428 gfx::Vector2dF inner_clip_bounds_delta = inner_clip_layer->bounds_delta();
8429 inner_clip_layer->SetBoundsDelta(gfx::Vector2dF());
8430
8431 gfx::Vector2dF outer_clip_bounds_delta = outer_clip_layer->bounds_delta();
8432 outer_clip_layer->SetBoundsDelta(gfx::Vector2dF());
8433
8416 DrawFrame(); 8434 DrawFrame();
8417 8435
8436 scroll_layer->SetBoundsDelta(scroll_bounds_delta);
8437 inner_clip_layer->SetBoundsDelta(inner_clip_bounds_delta);
8438 outer_clip_layer->SetBoundsDelta(outer_clip_bounds_delta);
8439
8418 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 8440 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
8419 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 8441 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
8420 InputHandler::GESTURE) 8442 InputHandler::GESTURE)
8421 .thread); 8443 .thread);
8422 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); 8444 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset());
8423 8445
8424 float offset = 50; 8446 float offset = 50;
8425 EXPECT_TRUE( 8447 EXPECT_TRUE(
8426 host_impl_->ScrollBy( 8448 host_impl_->ScrollBy(
8427 UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) 8449 UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get())
(...skipping 1467 matching lines...) Expand 10 before | Expand all | Expand 10 after
9895 host_impl_->ActivateSyncTree(); 9917 host_impl_->ActivateSyncTree();
9896 DrawFrame(); 9918 DrawFrame();
9897 9919
9898 host_impl_->CreatePendingTree(); 9920 host_impl_->CreatePendingTree();
9899 host_impl_->active_tree()->SetPageScaleOnActiveTree(2.f); 9921 host_impl_->active_tree()->SetPageScaleOnActiveTree(2.f);
9900 LayerImpl* page_scale_layer = host_impl_->active_tree()->PageScaleLayer(); 9922 LayerImpl* page_scale_layer = host_impl_->active_tree()->PageScaleLayer();
9901 9923
9902 TransformNode* active_tree_node = 9924 TransformNode* active_tree_node =
9903 host_impl_->active_tree()->property_trees()->transform_tree.Node( 9925 host_impl_->active_tree()->property_trees()->transform_tree.Node(
9904 page_scale_layer->transform_tree_index()); 9926 page_scale_layer->transform_tree_index());
9905 EXPECT_EQ(active_tree_node->data.post_local_scale_factor, 1.f); 9927 // SetPageScaleOnActiveTree also updates the factors in property trees.
9928 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); 9929 EXPECT_EQ(host_impl_->active_tree()->current_page_scale_factor(), 2.f);
9907 9930
9908 TransformNode* pending_tree_node = 9931 TransformNode* pending_tree_node =
9909 host_impl_->pending_tree()->property_trees()->transform_tree.Node( 9932 host_impl_->pending_tree()->property_trees()->transform_tree.Node(
9910 page_scale_layer->transform_tree_index()); 9933 page_scale_layer->transform_tree_index());
9911 EXPECT_EQ(pending_tree_node->data.post_local_scale_factor, 1.f); 9934 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); 9935 EXPECT_EQ(host_impl_->pending_tree()->current_page_scale_factor(), 2.f);
9913 9936
9914 host_impl_->pending_tree()->UpdateDrawProperties(false); 9937 host_impl_->pending_tree()->UpdateDrawProperties(false);
9915 pending_tree_node = 9938 pending_tree_node =
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
9997 // There should not be any jitter measured till we hit the fixed point hits 10020 // There should not be any jitter measured till we hit the fixed point hits
9998 // threshold. 10021 // threshold.
9999 float expected_jitter = 10022 float expected_jitter =
10000 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0; 10023 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0;
10001 EXPECT_EQ(jitter, expected_jitter); 10024 EXPECT_EQ(jitter, expected_jitter);
10002 } 10025 }
10003 } 10026 }
10004 10027
10005 } // namespace 10028 } // namespace
10006 } // namespace cc 10029 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698