| 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 10057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10068 host_impl_->WillBeginImplFrame(begin_frame_args); | 10068 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 10069 host_impl_->Animate(); | 10069 host_impl_->Animate(); |
| 10070 host_impl_->UpdateAnimationState(true); | 10070 host_impl_->UpdateAnimationState(true); |
| 10071 | 10071 |
| 10072 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100), | 10072 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100), |
| 10073 scrolling_layer->CurrentScrollOffset()); | 10073 scrolling_layer->CurrentScrollOffset()); |
| 10074 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); | 10074 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); |
| 10075 host_impl_->DidFinishImplFrame(); | 10075 host_impl_->DidFinishImplFrame(); |
| 10076 } | 10076 } |
| 10077 | 10077 |
| 10078 // Test that smooth scrolls clamp correctly when bounds change mid-animation. |
| 10079 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimatedChangingBounds) { |
| 10080 const gfx::Size old_content_size(1000, 1000); |
| 10081 const gfx::Size new_content_size(750, 750); |
| 10082 const gfx::Size viewport_size(500, 500); |
| 10083 |
| 10084 LayerImpl* content_layer = |
| 10085 CreateBasicVirtualViewportLayers(viewport_size, old_content_size); |
| 10086 SetNeedsRebuildPropertyTrees(); |
| 10087 DrawFrame(); |
| 10088 |
| 10089 base::TimeTicks start_time = |
| 10090 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); |
| 10091 BeginFrameArgs begin_frame_args = |
| 10092 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); |
| 10093 |
| 10094 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(500, 500)); |
| 10095 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); |
| 10096 |
| 10097 begin_frame_args.frame_time = start_time; |
| 10098 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 10099 host_impl_->Animate(); |
| 10100 host_impl_->UpdateAnimationState(true); |
| 10101 host_impl_->DidFinishImplFrame(); |
| 10102 |
| 10103 content_layer->SetBounds(new_content_size); |
| 10104 scrolling_layer->SetBounds(new_content_size); |
| 10105 SetNeedsRebuildPropertyTrees(); |
| 10106 DrawFrame(); |
| 10107 |
| 10108 begin_frame_args.frame_time = |
| 10109 start_time + base::TimeDelta::FromMilliseconds(200); |
| 10110 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 10111 host_impl_->Animate(); |
| 10112 host_impl_->UpdateAnimationState(true); |
| 10113 host_impl_->DidFinishImplFrame(); |
| 10114 |
| 10115 EXPECT_EQ(gfx::ScrollOffset(250, 250), |
| 10116 scrolling_layer->CurrentScrollOffset()); |
| 10117 } |
| 10118 |
| 10078 TEST_F(LayerTreeHostImplTest, InvalidLayerNotAddedToRasterQueue) { | 10119 TEST_F(LayerTreeHostImplTest, InvalidLayerNotAddedToRasterQueue) { |
| 10079 host_impl_->CreatePendingTree(); | 10120 host_impl_->CreatePendingTree(); |
| 10080 | 10121 |
| 10081 Region empty_invalidation; | 10122 Region empty_invalidation; |
| 10082 scoped_refptr<RasterSource> raster_source_with_tiles( | 10123 scoped_refptr<RasterSource> raster_source_with_tiles( |
| 10083 FakeRasterSource::CreateFilled(gfx::Size(10, 10))); | 10124 FakeRasterSource::CreateFilled(gfx::Size(10, 10))); |
| 10084 | 10125 |
| 10085 std::unique_ptr<FakePictureLayerImpl> layer = | 10126 std::unique_ptr<FakePictureLayerImpl> layer = |
| 10086 FakePictureLayerImpl::Create(host_impl_->pending_tree(), 11); | 10127 FakePictureLayerImpl::Create(host_impl_->pending_tree(), 11); |
| 10087 layer->SetBounds(gfx::Size(10, 10)); | 10128 layer->SetBounds(gfx::Size(10, 10)); |
| (...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10705 | 10746 |
| 10706 // Re-initialize with a software output surface. | 10747 // Re-initialize with a software output surface. |
| 10707 output_surface_ = FakeOutputSurface::CreateSoftware( | 10748 output_surface_ = FakeOutputSurface::CreateSoftware( |
| 10708 base::WrapUnique(new SoftwareOutputDevice)); | 10749 base::WrapUnique(new SoftwareOutputDevice)); |
| 10709 host_impl_->InitializeRenderer(output_surface_.get()); | 10750 host_impl_->InitializeRenderer(output_surface_.get()); |
| 10710 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 10751 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
| 10711 } | 10752 } |
| 10712 | 10753 |
| 10713 } // namespace | 10754 } // namespace |
| 10714 } // namespace cc | 10755 } // namespace cc |
| OLD | NEW |