| 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 10050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10061 host_impl_->DidFinishImplFrame(); | 10061 host_impl_->DidFinishImplFrame(); |
| 10062 | 10062 |
| 10063 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 10063 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); |
| 10064 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), scrolling_layer); | 10064 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), scrolling_layer); |
| 10065 | 10065 |
| 10066 // Verify no jump. | 10066 // Verify no jump. |
| 10067 float y = scrolling_layer->CurrentScrollOffset().y(); | 10067 float y = scrolling_layer->CurrentScrollOffset().y(); |
| 10068 EXPECT_TRUE(y > 1 && y < 49); | 10068 EXPECT_TRUE(y > 1 && y < 49); |
| 10069 } | 10069 } |
| 10070 | 10070 |
| 10071 TEST_F(LayerTreeHostImplTest, ScrollAnimatedWithDelay) { |
| 10072 const gfx::Size content_size(1000, 1000); |
| 10073 const gfx::Size viewport_size(50, 100); |
| 10074 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
| 10075 |
| 10076 DrawFrame(); |
| 10077 |
| 10078 base::TimeTicks start_time = |
| 10079 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); |
| 10080 BeginFrameArgs begin_frame_args = |
| 10081 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); |
| 10082 |
| 10083 // Create animation with a 100ms delay. |
| 10084 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 10085 host_impl_ |
| 10086 ->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100), |
| 10087 base::TimeDelta::FromMilliseconds(100)) |
| 10088 .thread); |
| 10089 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); |
| 10090 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), scrolling_layer); |
| 10091 |
| 10092 // First tick, animation is started. |
| 10093 begin_frame_args.frame_time = start_time; |
| 10094 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 10095 host_impl_->UpdateAnimationState(true); |
| 10096 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); |
| 10097 host_impl_->DidFinishImplFrame(); |
| 10098 |
| 10099 // Second tick after 50ms, animation should be half way done since |
| 10100 // the duration due to delay is 100ms. |
| 10101 begin_frame_args.frame_time = |
| 10102 start_time + base::TimeDelta::FromMilliseconds(50); |
| 10103 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 10104 host_impl_->UpdateAnimationState(true); |
| 10105 EXPECT_EQ(50, scrolling_layer->CurrentScrollOffset().y()); |
| 10106 host_impl_->DidFinishImplFrame(); |
| 10107 |
| 10108 // Update target. |
| 10109 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 10110 host_impl_ |
| 10111 ->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100), |
| 10112 base::TimeDelta::FromMilliseconds(150)) |
| 10113 .thread); |
| 10114 |
| 10115 // Third tick after 100ms, should be at the target position since update |
| 10116 // target was called with a large value of jank. |
| 10117 begin_frame_args.frame_time = |
| 10118 start_time + base::TimeDelta::FromMilliseconds(100); |
| 10119 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 10120 host_impl_->UpdateAnimationState(true); |
| 10121 EXPECT_LT(100, scrolling_layer->CurrentScrollOffset().y()); |
| 10122 } |
| 10123 |
| 10071 // Test that a smooth scroll offset animation is aborted when followed by a | 10124 // Test that a smooth scroll offset animation is aborted when followed by a |
| 10072 // non-smooth scroll offset animation. | 10125 // non-smooth scroll offset animation. |
| 10073 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimatedAborted) { | 10126 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimatedAborted) { |
| 10074 const gfx::Size content_size(1000, 1000); | 10127 const gfx::Size content_size(1000, 1000); |
| 10075 const gfx::Size viewport_size(500, 500); | 10128 const gfx::Size viewport_size(500, 500); |
| 10076 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 10129 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
| 10077 | 10130 |
| 10078 DrawFrame(); | 10131 DrawFrame(); |
| 10079 | 10132 |
| 10080 base::TimeTicks start_time = | 10133 base::TimeTicks start_time = |
| (...skipping 1081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11162 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); | 11215 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); |
| 11163 | 11216 |
| 11164 // Re-initialize with a software output surface. | 11217 // Re-initialize with a software output surface. |
| 11165 output_surface_ = FakeOutputSurface::CreateDelegatingSoftware(); | 11218 output_surface_ = FakeOutputSurface::CreateDelegatingSoftware(); |
| 11166 host_impl_->InitializeRenderer(output_surface_.get()); | 11219 host_impl_->InitializeRenderer(output_surface_.get()); |
| 11167 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 11220 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
| 11168 } | 11221 } |
| 11169 | 11222 |
| 11170 } // namespace | 11223 } // namespace |
| 11171 } // namespace cc | 11224 } // namespace cc |
| OLD | NEW |