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

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

Issue 2621133002: Return main thread scroll layer in FindScrollLayerForDeviceViewportPoint (Closed)
Patch Set: return current layer when it is main thread scrolling Created 3 years, 11 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
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 } 457 }
458 458
459 void pinch_zoom_pan_viewport_forces_commit_redraw(float device_scale_factor); 459 void pinch_zoom_pan_viewport_forces_commit_redraw(float device_scale_factor);
460 void pinch_zoom_pan_viewport_test(float device_scale_factor); 460 void pinch_zoom_pan_viewport_test(float device_scale_factor);
461 void pinch_zoom_pan_viewport_and_scroll_test(float device_scale_factor); 461 void pinch_zoom_pan_viewport_and_scroll_test(float device_scale_factor);
462 void pinch_zoom_pan_viewport_and_scroll_boundary_test( 462 void pinch_zoom_pan_viewport_and_scroll_boundary_test(
463 float device_scale_factor); 463 float device_scale_factor);
464 464
465 void SetupMouseMoveAtWithDeviceScale(float device_scale_factor); 465 void SetupMouseMoveAtWithDeviceScale(float device_scale_factor);
466 466
467 void SetupMouseMoveAtTestScrollbarStates(bool main_thread_scrolling);
468
467 scoped_refptr<AnimationTimeline> timeline() { return timeline_; } 469 scoped_refptr<AnimationTimeline> timeline() { return timeline_; }
468 470
469 protected: 471 protected:
470 virtual std::unique_ptr<CompositorFrameSink> CreateCompositorFrameSink() { 472 virtual std::unique_ptr<CompositorFrameSink> CreateCompositorFrameSink() {
471 return FakeCompositorFrameSink::Create3d(); 473 return FakeCompositorFrameSink::Create3d();
472 } 474 }
473 475
474 void DrawOneFrame() { 476 void DrawOneFrame() {
475 LayerTreeHostImpl::FrameData frame_data; 477 LayerTreeHostImpl::FrameData frame_data;
476 host_impl_->PrepareToDraw(&frame_data); 478 host_impl_->PrepareToDraw(&frame_data);
(...skipping 11137 matching lines...) Expand 10 before | Expand all | Expand 10 after
11614 FakeCompositorFrameSink::Create3d(TestWebGraphicsContext3D::Create()); 11616 FakeCompositorFrameSink::Create3d(TestWebGraphicsContext3D::Create());
11615 host_impl_->InitializeRenderer(gpu_raster_compositor_frame_sink.get()); 11617 host_impl_->InitializeRenderer(gpu_raster_compositor_frame_sink.get());
11616 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); 11618 EXPECT_TRUE(host_impl_->use_gpu_rasterization());
11617 11619
11618 // Re-initialize with a software output surface. 11620 // Re-initialize with a software output surface.
11619 compositor_frame_sink_ = FakeCompositorFrameSink::CreateSoftware(); 11621 compositor_frame_sink_ = FakeCompositorFrameSink::CreateSoftware();
11620 host_impl_->InitializeRenderer(compositor_frame_sink_.get()); 11622 host_impl_->InitializeRenderer(compositor_frame_sink_.get());
11621 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); 11623 EXPECT_FALSE(host_impl_->use_gpu_rasterization());
11622 } 11624 }
11623 11625
11624 TEST_F(LayerTreeHostImplTest, LayerTreeHostImplTestScrollbarStates) { 11626 void LayerTreeHostImplTest::SetupMouseMoveAtTestScrollbarStates(
11627 bool main_thread_scrolling) {
11625 LayerTreeSettings settings = DefaultSettings(); 11628 LayerTreeSettings settings = DefaultSettings();
11626 settings.scrollbar_fade_delay = base::TimeDelta::FromMilliseconds(500); 11629 settings.scrollbar_fade_delay = base::TimeDelta::FromMilliseconds(500);
11627 settings.scrollbar_fade_duration = base::TimeDelta::FromMilliseconds(300); 11630 settings.scrollbar_fade_duration = base::TimeDelta::FromMilliseconds(300);
11628 settings.scrollbar_animator = LayerTreeSettings::THINNING; 11631 settings.scrollbar_animator = LayerTreeSettings::THINNING;
11629 11632
11630 gfx::Size viewport_size(300, 200); 11633 gfx::Size viewport_size(300, 200);
11631 gfx::Size content_size(1000, 1000); 11634 gfx::Size content_size(1000, 1000);
11632 gfx::Size child_layer_size(250, 150); 11635 gfx::Size child_layer_size(250, 150);
11633 gfx::Size scrollbar_size_1(gfx::Size(15, viewport_size.height())); 11636 gfx::Size scrollbar_size_1(gfx::Size(15, viewport_size.height()));
11634 gfx::Size scrollbar_size_2(gfx::Size(15, child_layer_size.height())); 11637 gfx::Size scrollbar_size_2(gfx::Size(15, child_layer_size.height()));
11635 11638
11636 const int scrollbar_1_id = 10; 11639 const int scrollbar_1_id = 10;
11637 const int scrollbar_2_id = 11; 11640 const int scrollbar_2_id = 11;
11638 const int child_clip_id = 12; 11641 const int child_clip_id = 12;
11639 const int child_scroll_id = 13; 11642 const int child_scroll_id = 13;
11640 11643
11641 CreateHostImpl(settings, CreateCompositorFrameSink()); 11644 CreateHostImpl(settings, CreateCompositorFrameSink());
11642 host_impl_->active_tree()->SetDeviceScaleFactor(1); 11645 host_impl_->active_tree()->SetDeviceScaleFactor(1);
11643 host_impl_->SetViewportSize(viewport_size); 11646 host_impl_->SetViewportSize(viewport_size);
11644 CreateScrollAndContentsLayers(host_impl_->active_tree(), content_size); 11647 CreateScrollAndContentsLayers(host_impl_->active_tree(), content_size);
11645 host_impl_->active_tree()->InnerViewportContainerLayer()->SetBounds( 11648 host_impl_->active_tree()->InnerViewportContainerLayer()->SetBounds(
11646 viewport_size); 11649 viewport_size);
11647 LayerImpl* root_scroll = 11650 LayerImpl* root_scroll =
11648 host_impl_->active_tree()->OuterViewportScrollLayer(); 11651 host_impl_->active_tree()->OuterViewportScrollLayer();
11649 11652
11653 if (main_thread_scrolling) {
11654 root_scroll->set_main_thread_scrolling_reasons(
11655 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects);
11656 }
11657
11650 // scrollbar_1 on root scroll. 11658 // scrollbar_1 on root scroll.
11651 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar_1 = 11659 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar_1 =
11652 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 11660 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(),
11653 scrollbar_1_id, VERTICAL, 5, 5, true, 11661 scrollbar_1_id, VERTICAL, 5, 5, true,
11654 true); 11662 true);
11655 scrollbar_1->SetScrollLayerId(root_scroll->id()); 11663 scrollbar_1->SetScrollLayerId(root_scroll->id());
11656 scrollbar_1->SetDrawsContent(true); 11664 scrollbar_1->SetDrawsContent(true);
11657 scrollbar_1->SetBounds(scrollbar_size_1); 11665 scrollbar_1->SetBounds(scrollbar_size_1);
11658 scrollbar_1->SetTouchEventHandlerRegion(gfx::Rect(scrollbar_size_1)); 11666 scrollbar_1->SetTouchEventHandlerRegion(gfx::Rect(scrollbar_size_1));
11659 host_impl_->active_tree() 11667 host_impl_->active_tree()
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
11698 true); 11706 true);
11699 std::unique_ptr<LayerImpl> child_clip = 11707 std::unique_ptr<LayerImpl> child_clip =
11700 LayerImpl::Create(host_impl_->active_tree(), child_clip_id); 11708 LayerImpl::Create(host_impl_->active_tree(), child_clip_id);
11701 std::unique_ptr<LayerImpl> child = 11709 std::unique_ptr<LayerImpl> child =
11702 LayerImpl::Create(host_impl_->active_tree(), child_scroll_id); 11710 LayerImpl::Create(host_impl_->active_tree(), child_scroll_id);
11703 child->SetPosition(gfx::PointF(50, 50)); 11711 child->SetPosition(gfx::PointF(50, 50));
11704 child->SetBounds(child_layer_size); 11712 child->SetBounds(child_layer_size);
11705 child->SetDrawsContent(true); 11713 child->SetDrawsContent(true);
11706 child->SetScrollClipLayer(child_clip_id); 11714 child->SetScrollClipLayer(child_clip_id);
11707 11715
11716 if (main_thread_scrolling) {
11717 child->set_main_thread_scrolling_reasons(
11718 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects);
11719 }
11720
11708 scrollbar_2->SetScrollLayerId(child_scroll_id); 11721 scrollbar_2->SetScrollLayerId(child_scroll_id);
11709 scrollbar_2->SetDrawsContent(true); 11722 scrollbar_2->SetDrawsContent(true);
11710 scrollbar_2->SetBounds(scrollbar_size_2); 11723 scrollbar_2->SetBounds(scrollbar_size_2);
11711 11724
11712 child->test_properties()->AddChild(std::move(scrollbar_2)); 11725 child->test_properties()->AddChild(std::move(scrollbar_2));
11713 child_clip->test_properties()->AddChild(std::move(child)); 11726 child_clip->test_properties()->AddChild(std::move(child));
11714 root_scroll->test_properties()->AddChild(std::move(child_clip)); 11727 root_scroll->test_properties()->AddChild(std::move(child_clip));
11715 11728
11716 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 11729 host_impl_->active_tree()->BuildPropertyTreesForTesting();
11717 host_impl_->active_tree()->DidBecomeActive(); 11730 host_impl_->active_tree()->DidBecomeActive();
(...skipping 21 matching lines...) Expand all
11739 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); 11752 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_over_scrollbar());
11740 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_near_scrollbar()); 11753 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_near_scrollbar());
11741 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); 11754 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar());
11742 host_impl_->MouseMoveAt(gfx::Point(10, 150)); 11755 host_impl_->MouseMoveAt(gfx::Point(10, 150));
11743 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); 11756 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar());
11744 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); 11757 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_over_scrollbar());
11745 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_near_scrollbar()); 11758 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_near_scrollbar());
11746 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); 11759 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar());
11747 } 11760 }
11748 11761
11762 TEST_F(LayerTreeHostImplTest,
11763 LayerTreeHostImplTestScrollbarStatesInMainThreadScorlling) {
11764 SetupMouseMoveAtTestScrollbarStates(true);
11765 }
11766
11767 TEST_F(LayerTreeHostImplTest,
11768 LayerTreeHostImplTestScrollbarStatesInNotMainThreadScorlling) {
11769 SetupMouseMoveAtTestScrollbarStates(false);
11770 }
11771
11749 } // namespace 11772 } // namespace
11750 } // namespace cc 11773 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698