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

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

Issue 1950613004: Fix bounds clamping during composited smooth scroll. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add unit test Created 4 years, 7 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/layers/layer_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 10057 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
OLDNEW
« no previous file with comments | « cc/layers/layer_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698