summaryrefslogtreecommitdiff
path: root/chromium/cc/trees/layer_tree_host_impl_unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/cc/trees/layer_tree_host_impl_unittest.cc')
-rw-r--r--chromium/cc/trees/layer_tree_host_impl_unittest.cc121
1 files changed, 118 insertions, 3 deletions
diff --git a/chromium/cc/trees/layer_tree_host_impl_unittest.cc b/chromium/cc/trees/layer_tree_host_impl_unittest.cc
index 814279ebc22..e1aa12df7e5 100644
--- a/chromium/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/chromium/cc/trees/layer_tree_host_impl_unittest.cc
@@ -8945,6 +8945,45 @@ TEST_F(ResourcelessSoftwareLayerTreeHostImplTest,
EXPECT_FALSE(last_on_draw_frame_->has_no_damage);
}
+TEST_F(ResourcelessSoftwareLayerTreeHostImplTest,
+ ResourcelessSoftwareDrawSkipsUpdateTiles) {
+ const gfx::Size viewport_size(100, 100);
+ host_impl_->SetViewportSize(viewport_size);
+
+ host_impl_->CreatePendingTree();
+ scoped_refptr<FakeDisplayListRasterSource> raster_source(
+ FakeDisplayListRasterSource::CreateFilled(viewport_size));
+ scoped_ptr<FakePictureLayerImpl> layer(
+ FakePictureLayerImpl::CreateWithRasterSource(host_impl_->pending_tree(),
+ 11, raster_source));
+ layer->SetBounds(viewport_size);
+ layer->SetDrawsContent(true);
+ host_impl_->pending_tree()->SetRootLayer(std::move(layer));
+
+ host_impl_->pending_tree()->BuildPropertyTreesForTesting();
+ host_impl_->ActivateSyncTree();
+
+ const gfx::Transform draw_transform;
+ const gfx::Rect draw_viewport(viewport_size);
+ const gfx::Rect clip(viewport_size);
+ bool resourceless_software_draw = false;
+
+ // Regular draw causes UpdateTiles.
+ did_request_prepare_tiles_ = false;
+ host_impl_->OnDraw(draw_transform, draw_viewport, clip,
+ resourceless_software_draw);
+ EXPECT_TRUE(did_request_prepare_tiles_);
+ host_impl_->PrepareTiles();
+
+ // Resourceless draw skips UpdateTiles.
+ const gfx::Rect new_draw_viewport(50, 50);
+ resourceless_software_draw = true;
+ did_request_prepare_tiles_ = false;
+ host_impl_->OnDraw(draw_transform, new_draw_viewport, clip,
+ resourceless_software_draw);
+ EXPECT_FALSE(did_request_prepare_tiles_);
+}
+
TEST_F(LayerTreeHostImplTest, ExternalViewportAffectsVisibleRects) {
const gfx::Size layer_size(100, 100);
SetupScrollAndContentsLayers(layer_size);
@@ -9143,7 +9182,10 @@ TEST_F(LayerTreeHostImplTest, ScrollAnimated) {
// Test that a smooth scroll offset animation is aborted when followed by a
// non-smooth scroll offset animation.
TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimatedAborted) {
- SetupScrollAndContentsLayers(gfx::Size(100, 200));
+ const gfx::Size content_size(1000, 1000);
+ const gfx::Size viewport_size(500, 500);
+ CreateBasicVirtualViewportLayers(viewport_size, content_size);
+
DrawFrame();
base::TimeTicks start_time =
@@ -9208,7 +9250,10 @@ TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimatedAborted) {
// Evolved from LayerTreeHostImplTest.ScrollAnimated.
TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimated) {
- SetupScrollAndContentsLayers(gfx::Size(100, 200));
+ const gfx::Size content_size(1000, 1000);
+ const gfx::Size viewport_size(500, 500);
+ CreateBasicVirtualViewportLayers(viewport_size, content_size);
+
DrawFrame();
base::TimeTicks start_time =
@@ -9221,7 +9266,6 @@ TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimated) {
host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)));
LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer();
-
begin_frame_args.frame_time = start_time;
host_impl_->WillBeginImplFrame(begin_frame_args);
host_impl_->Animate();
@@ -9267,6 +9311,77 @@ TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimated) {
host_impl_->DidFinishImplFrame();
}
+// Test that smooth scroll offset animation doesn't happen for non user
+// scrollable layers.
+TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimatedNotUserScrollable) {
+ const gfx::Size content_size(1000, 1000);
+ const gfx::Size viewport_size(500, 500);
+ CreateBasicVirtualViewportLayers(viewport_size, content_size);
+
+ host_impl_->OuterViewportScrollLayer()->set_user_scrollable_vertical(true);
+ host_impl_->OuterViewportScrollLayer()->set_user_scrollable_horizontal(false);
+
+ DrawFrame();
+
+ base::TimeTicks start_time =
+ base::TimeTicks() + base::TimeDelta::FromMilliseconds(100);
+
+ BeginFrameArgs begin_frame_args =
+ CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE);
+
+ EXPECT_EQ(
+ InputHandler::SCROLL_STARTED,
+ host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(50, 50)));
+
+ LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer();
+ begin_frame_args.frame_time = start_time;
+ host_impl_->WillBeginImplFrame(begin_frame_args);
+ host_impl_->Animate();
+ host_impl_->UpdateAnimationState(true);
+
+ EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset());
+ host_impl_->DidFinishImplFrame();
+
+ begin_frame_args.frame_time =
+ start_time + base::TimeDelta::FromMilliseconds(50);
+ host_impl_->WillBeginImplFrame(begin_frame_args);
+ host_impl_->Animate();
+ host_impl_->UpdateAnimationState(true);
+
+ // Should not have scrolled horizontally.
+ EXPECT_EQ(0, scrolling_layer->CurrentScrollOffset().x());
+ float y = scrolling_layer->CurrentScrollOffset().y();
+ EXPECT_TRUE(y > 1 && y < 49);
+
+ // Update target.
+ EXPECT_EQ(
+ InputHandler::SCROLL_STARTED,
+ host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(50, 50)));
+ host_impl_->DidFinishImplFrame();
+
+ begin_frame_args.frame_time =
+ start_time + base::TimeDelta::FromMilliseconds(200);
+ host_impl_->WillBeginImplFrame(begin_frame_args);
+ host_impl_->Animate();
+ host_impl_->UpdateAnimationState(true);
+
+ y = scrolling_layer->CurrentScrollOffset().y();
+ EXPECT_TRUE(y > 50 && y < 100);
+ EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer());
+ host_impl_->DidFinishImplFrame();
+
+ begin_frame_args.frame_time =
+ start_time + base::TimeDelta::FromMilliseconds(250);
+ host_impl_->WillBeginImplFrame(begin_frame_args);
+ host_impl_->Animate();
+ host_impl_->UpdateAnimationState(true);
+
+ EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100),
+ scrolling_layer->CurrentScrollOffset());
+ EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer());
+ host_impl_->DidFinishImplFrame();
+}
+
TEST_F(LayerTreeHostImplTest, InvalidLayerNotAddedToRasterQueue) {
host_impl_->CreatePendingTree();