| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 #include "cc/test/test_gpu_memory_buffer_manager.h" | 58 #include "cc/test/test_gpu_memory_buffer_manager.h" |
| 59 #include "cc/test/test_shared_bitmap_manager.h" | 59 #include "cc/test/test_shared_bitmap_manager.h" |
| 60 #include "cc/test/test_task_graph_runner.h" | 60 #include "cc/test/test_task_graph_runner.h" |
| 61 #include "cc/test/test_web_graphics_context_3d.h" | 61 #include "cc/test/test_web_graphics_context_3d.h" |
| 62 #include "cc/trees/layer_tree_impl.h" | 62 #include "cc/trees/layer_tree_impl.h" |
| 63 #include "cc/trees/single_thread_proxy.h" | 63 #include "cc/trees/single_thread_proxy.h" |
| 64 #include "media/base/media.h" | 64 #include "media/base/media.h" |
| 65 #include "testing/gmock/include/gmock/gmock.h" | 65 #include "testing/gmock/include/gmock/gmock.h" |
| 66 #include "testing/gtest/include/gtest/gtest.h" | 66 #include "testing/gtest/include/gtest/gtest.h" |
| 67 #include "third_party/skia/include/core/SkMallocPixelRef.h" | 67 #include "third_party/skia/include/core/SkMallocPixelRef.h" |
| 68 #include "ui/gfx/frame_time.h" | 68 |
| 69 #include "ui/gfx/geometry/rect_conversions.h" | 69 #include "ui/gfx/geometry/rect_conversions.h" |
| 70 #include "ui/gfx/geometry/size_conversions.h" | 70 #include "ui/gfx/geometry/size_conversions.h" |
| 71 #include "ui/gfx/geometry/vector2d_conversions.h" | 71 #include "ui/gfx/geometry/vector2d_conversions.h" |
| 72 | 72 |
| 73 using ::testing::Mock; | 73 using ::testing::Mock; |
| 74 using ::testing::Return; | 74 using ::testing::Return; |
| 75 using ::testing::AnyNumber; | 75 using ::testing::AnyNumber; |
| 76 using ::testing::AtLeast; | 76 using ::testing::AtLeast; |
| 77 using ::testing::_; | 77 using ::testing::_; |
| 78 using media::VideoFrame; | 78 using media::VideoFrame; |
| (...skipping 1563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1642 } | 1642 } |
| 1643 | 1643 |
| 1644 void RunTest(LayerTreeSettings::ScrollbarAnimator animator) { | 1644 void RunTest(LayerTreeSettings::ScrollbarAnimator animator) { |
| 1645 LayerTreeSettings settings; | 1645 LayerTreeSettings settings; |
| 1646 settings.scrollbar_animator = animator; | 1646 settings.scrollbar_animator = animator; |
| 1647 settings.scrollbar_fade_delay_ms = 20; | 1647 settings.scrollbar_fade_delay_ms = 20; |
| 1648 settings.scrollbar_fade_duration_ms = 20; | 1648 settings.scrollbar_fade_duration_ms = 20; |
| 1649 | 1649 |
| 1650 SetupLayers(settings); | 1650 SetupLayers(settings); |
| 1651 | 1651 |
| 1652 base::TimeTicks fake_now = gfx::FrameTime::Now(); | 1652 base::TimeTicks fake_now = base::TimeTicks::Now(); |
| 1653 | 1653 |
| 1654 EXPECT_FALSE(did_request_animate_); | 1654 EXPECT_FALSE(did_request_animate_); |
| 1655 EXPECT_FALSE(did_request_redraw_); | 1655 EXPECT_FALSE(did_request_redraw_); |
| 1656 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); | 1656 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
| 1657 EXPECT_TRUE(animation_task_.Equals(base::Closure())); | 1657 EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
| 1658 | 1658 |
| 1659 // If no scroll happened during a scroll gesture, it should have no effect. | 1659 // If no scroll happened during a scroll gesture, it should have no effect. |
| 1660 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL); | 1660 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL); |
| 1661 host_impl_->ScrollEnd(); | 1661 host_impl_->ScrollEnd(); |
| 1662 EXPECT_FALSE(did_request_animate_); | 1662 EXPECT_FALSE(did_request_animate_); |
| (...skipping 5171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6834 | 6834 |
| 6835 // End the scroll while the controls are still offset from their limit. | 6835 // End the scroll while the controls are still offset from their limit. |
| 6836 host_impl_->ScrollEnd(); | 6836 host_impl_->ScrollEnd(); |
| 6837 ASSERT_TRUE(host_impl_->top_controls_manager()->animation()); | 6837 ASSERT_TRUE(host_impl_->top_controls_manager()->animation()); |
| 6838 EXPECT_TRUE(did_request_animate_); | 6838 EXPECT_TRUE(did_request_animate_); |
| 6839 EXPECT_TRUE(did_request_redraw_); | 6839 EXPECT_TRUE(did_request_redraw_); |
| 6840 EXPECT_FALSE(did_request_commit_); | 6840 EXPECT_FALSE(did_request_commit_); |
| 6841 | 6841 |
| 6842 // The top controls should properly animate until finished, despite the scroll | 6842 // The top controls should properly animate until finished, despite the scroll |
| 6843 // offset being at the origin. | 6843 // offset being at the origin. |
| 6844 base::TimeTicks animation_time = gfx::FrameTime::Now(); | 6844 base::TimeTicks animation_time = base::TimeTicks::Now(); |
| 6845 while (did_request_animate_) { | 6845 while (did_request_animate_) { |
| 6846 did_request_redraw_ = false; | 6846 did_request_redraw_ = false; |
| 6847 did_request_animate_ = false; | 6847 did_request_animate_ = false; |
| 6848 did_request_commit_ = false; | 6848 did_request_commit_ = false; |
| 6849 | 6849 |
| 6850 float old_offset = | 6850 float old_offset = |
| 6851 host_impl_->top_controls_manager()->ControlsTopOffset(); | 6851 host_impl_->top_controls_manager()->ControlsTopOffset(); |
| 6852 | 6852 |
| 6853 animation_time += base::TimeDelta::FromMilliseconds(5); | 6853 animation_time += base::TimeDelta::FromMilliseconds(5); |
| 6854 host_impl_->Animate(animation_time); | 6854 host_impl_->Animate(animation_time); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6904 did_request_commit_ = false; | 6904 did_request_commit_ = false; |
| 6905 | 6905 |
| 6906 // End the scroll while the controls are still offset from the limit. | 6906 // End the scroll while the controls are still offset from the limit. |
| 6907 host_impl_->ScrollEnd(); | 6907 host_impl_->ScrollEnd(); |
| 6908 ASSERT_TRUE(host_impl_->top_controls_manager()->animation()); | 6908 ASSERT_TRUE(host_impl_->top_controls_manager()->animation()); |
| 6909 EXPECT_TRUE(did_request_animate_); | 6909 EXPECT_TRUE(did_request_animate_); |
| 6910 EXPECT_TRUE(did_request_redraw_); | 6910 EXPECT_TRUE(did_request_redraw_); |
| 6911 EXPECT_FALSE(did_request_commit_); | 6911 EXPECT_FALSE(did_request_commit_); |
| 6912 | 6912 |
| 6913 // Animate the top controls to the limit. | 6913 // Animate the top controls to the limit. |
| 6914 base::TimeTicks animation_time = gfx::FrameTime::Now(); | 6914 base::TimeTicks animation_time = base::TimeTicks::Now(); |
| 6915 while (did_request_animate_) { | 6915 while (did_request_animate_) { |
| 6916 did_request_redraw_ = false; | 6916 did_request_redraw_ = false; |
| 6917 did_request_animate_ = false; | 6917 did_request_animate_ = false; |
| 6918 did_request_commit_ = false; | 6918 did_request_commit_ = false; |
| 6919 | 6919 |
| 6920 float old_offset = | 6920 float old_offset = |
| 6921 host_impl_->top_controls_manager()->ControlsTopOffset(); | 6921 host_impl_->top_controls_manager()->ControlsTopOffset(); |
| 6922 | 6922 |
| 6923 animation_time += base::TimeDelta::FromMilliseconds(5); | 6923 animation_time += base::TimeDelta::FromMilliseconds(5); |
| 6924 host_impl_->Animate(animation_time); | 6924 host_impl_->Animate(animation_time); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6968 did_request_commit_ = false; | 6968 did_request_commit_ = false; |
| 6969 | 6969 |
| 6970 // End the fling while the controls are still offset from the limit. | 6970 // End the fling while the controls are still offset from the limit. |
| 6971 host_impl_->MainThreadHasStoppedFlinging(); | 6971 host_impl_->MainThreadHasStoppedFlinging(); |
| 6972 ASSERT_TRUE(host_impl_->top_controls_manager()->animation()); | 6972 ASSERT_TRUE(host_impl_->top_controls_manager()->animation()); |
| 6973 EXPECT_TRUE(did_request_animate_); | 6973 EXPECT_TRUE(did_request_animate_); |
| 6974 EXPECT_TRUE(did_request_redraw_); | 6974 EXPECT_TRUE(did_request_redraw_); |
| 6975 EXPECT_FALSE(did_request_commit_); | 6975 EXPECT_FALSE(did_request_commit_); |
| 6976 | 6976 |
| 6977 // Animate the top controls to the limit. | 6977 // Animate the top controls to the limit. |
| 6978 base::TimeTicks animation_time = gfx::FrameTime::Now(); | 6978 base::TimeTicks animation_time = base::TimeTicks::Now(); |
| 6979 while (did_request_animate_) { | 6979 while (did_request_animate_) { |
| 6980 did_request_redraw_ = false; | 6980 did_request_redraw_ = false; |
| 6981 did_request_animate_ = false; | 6981 did_request_animate_ = false; |
| 6982 did_request_commit_ = false; | 6982 did_request_commit_ = false; |
| 6983 | 6983 |
| 6984 float old_offset = host_impl_->top_controls_manager()->ControlsTopOffset(); | 6984 float old_offset = host_impl_->top_controls_manager()->ControlsTopOffset(); |
| 6985 | 6985 |
| 6986 animation_time += base::TimeDelta::FromMilliseconds(5); | 6986 animation_time += base::TimeDelta::FromMilliseconds(5); |
| 6987 host_impl_->Animate(animation_time); | 6987 host_impl_->Animate(animation_time); |
| 6988 | 6988 |
| (...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7780 host_impl_->set_has_gpu_rasterization_trigger(false); | 7780 host_impl_->set_has_gpu_rasterization_trigger(false); |
| 7781 host_impl_->set_content_is_suitable_for_gpu_rasterization(false); | 7781 host_impl_->set_content_is_suitable_for_gpu_rasterization(false); |
| 7782 host_impl_->UpdateGpuRasterizationStatus(); | 7782 host_impl_->UpdateGpuRasterizationStatus(); |
| 7783 EXPECT_EQ(GpuRasterizationStatus::ON_FORCED, | 7783 EXPECT_EQ(GpuRasterizationStatus::ON_FORCED, |
| 7784 host_impl_->gpu_rasterization_status()); | 7784 host_impl_->gpu_rasterization_status()); |
| 7785 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); | 7785 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); |
| 7786 } | 7786 } |
| 7787 | 7787 |
| 7788 } // namespace | 7788 } // namespace |
| 7789 } // namespace cc | 7789 } // namespace cc |
| OLD | NEW |