Chromium Code Reviews| 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 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 Loading... | |
| 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( |
|
bokan
2017/01/13 19:23:38
IMO, TestScrollbarStates would be a better name
| |
| 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( | |
|
chaopeng
2017/01/13 19:15:28
Can child layer be not main thread scroll if the p
bokan
2017/01/13 19:23:38
Yes, they're independent so a child that scrolls o
| |
| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11739 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); | 11747 EXPECT_FALSE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); |
| 11740 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_near_scrollbar()); | 11748 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_near_scrollbar()); |
| 11741 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); | 11749 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); |
| 11742 host_impl_->MouseMoveAt(gfx::Point(10, 150)); | 11750 host_impl_->MouseMoveAt(gfx::Point(10, 150)); |
| 11743 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); | 11751 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); |
| 11744 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); | 11752 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); |
| 11745 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_near_scrollbar()); | 11753 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_near_scrollbar()); |
| 11746 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); | 11754 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); |
| 11747 } | 11755 } |
| 11748 | 11756 |
| 11757 TEST_F(LayerTreeHostImplTest, | |
| 11758 LayerTreeHostImplTestScrollbarStatesInMainThreadScorlling) { | |
| 11759 SetupMouseMoveAtTestScrollbarStates(true); | |
| 11760 } | |
| 11761 | |
| 11762 TEST_F(LayerTreeHostImplTest, | |
| 11763 LayerTreeHostImplTestScrollbarStatesInNotMainThreadScorlling) { | |
| 11764 SetupMouseMoveAtTestScrollbarStates(false); | |
| 11765 } | |
| 11766 | |
| 11749 } // namespace | 11767 } // namespace |
| 11750 } // namespace cc | 11768 } // namespace cc |
| OLD | NEW |