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

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

Issue 786123002: Update from https://crrev.com/307330 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest.cc » ('j') | 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 <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 5355 matching lines...) Expand 10 before | Expand all | Expand 10 after
5366 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 5366 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
5367 5367
5368 if (!expect_to_draw) { 5368 if (!expect_to_draw) {
5369 // With no damage, we don't draw, and no quads are created. 5369 // With no damage, we don't draw, and no quads are created.
5370 ASSERT_EQ(0u, frame.render_passes.size()); 5370 ASSERT_EQ(0u, frame.render_passes.size());
5371 } else { 5371 } else {
5372 ASSERT_EQ(1u, frame.render_passes.size()); 5372 ASSERT_EQ(1u, frame.render_passes.size());
5373 5373
5374 // Verify the damage rect for the root render pass. 5374 // Verify the damage rect for the root render pass.
5375 const RenderPass* root_render_pass = frame.render_passes.back(); 5375 const RenderPass* root_render_pass = frame.render_passes.back();
5376 EXPECT_RECT_EQ(expected_damage, root_render_pass->damage_rect); 5376 EXPECT_EQ(expected_damage, root_render_pass->damage_rect);
5377 5377
5378 // Verify the root and child layers' quads are generated and not being 5378 // Verify the root and child layers' quads are generated and not being
5379 // culled. 5379 // culled.
5380 ASSERT_EQ(2u, root_render_pass->quad_list.size()); 5380 ASSERT_EQ(2u, root_render_pass->quad_list.size());
5381 5381
5382 LayerImpl* child = host_impl_->active_tree()->root_layer()->children()[0]; 5382 LayerImpl* child = host_impl_->active_tree()->root_layer()->children()[0];
5383 gfx::RectF expected_child_visible_rect(child->content_bounds()); 5383 gfx::RectF expected_child_visible_rect(child->content_bounds());
5384 EXPECT_RECT_EQ(expected_child_visible_rect, 5384 EXPECT_EQ(expected_child_visible_rect,
5385 root_render_pass->quad_list.front()->visible_rect); 5385 root_render_pass->quad_list.front()->visible_rect);
5386 5386
5387 LayerImpl* root = host_impl_->active_tree()->root_layer(); 5387 LayerImpl* root = host_impl_->active_tree()->root_layer();
5388 gfx::RectF expected_root_visible_rect(root->content_bounds()); 5388 gfx::RectF expected_root_visible_rect(root->content_bounds());
5389 EXPECT_RECT_EQ(expected_root_visible_rect, 5389 EXPECT_EQ(expected_root_visible_rect,
5390 root_render_pass->quad_list.ElementAt(1)->visible_rect); 5390 root_render_pass->quad_list.ElementAt(1)->visible_rect);
5391 } 5391 }
5392 5392
5393 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 5393 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
5394 host_impl_->DidDrawAllLayers(frame); 5394 host_impl_->DidDrawAllLayers(frame);
5395 EXPECT_EQ(expect_to_draw, host_impl_->SwapBuffers(frame)); 5395 EXPECT_EQ(expect_to_draw, host_impl_->SwapBuffers(frame));
5396 } 5396 }
5397 }; 5397 };
5398 5398
5399 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) { 5399 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) {
5400 scoped_ptr<SolidColorLayerImpl> root = 5400 scoped_ptr<SolidColorLayerImpl> root =
(...skipping 2213 matching lines...) Expand 10 before | Expand all | Expand 10 after
7614 host_impl_->ScrollBy(gfx::Point(), gfx::ScaleVector2d(scroll_delta, 2)); 7614 host_impl_->ScrollBy(gfx::Point(), gfx::ScaleVector2d(scroll_delta, 2));
7615 outer_expected += scroll_delta; 7615 outer_expected += scroll_delta;
7616 inner_expected += scroll_delta; 7616 inner_expected += scroll_delta;
7617 host_impl_->ScrollEnd(); 7617 host_impl_->ScrollEnd();
7618 7618
7619 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->TotalScrollOffset()); 7619 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->TotalScrollOffset());
7620 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->TotalScrollOffset()); 7620 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->TotalScrollOffset());
7621 } 7621 }
7622 } 7622 }
7623 7623
7624 TEST_F(LayerTreeHostImplVirtualViewportTest,
7625 TouchFlingCanLockToViewportLayerAfterBubbling) {
7626 gfx::Size content_size = gfx::Size(100, 160);
7627 gfx::Size outer_viewport = gfx::Size(50, 80);
7628 gfx::Size inner_viewport = gfx::Size(25, 40);
7629
7630 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport);
7631
7632 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer();
7633 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer();
7634
7635 scoped_ptr<LayerImpl> child =
7636 CreateScrollableLayer(10, outer_viewport, outer_scroll);
7637 LayerImpl* child_scroll = child.get();
7638 outer_scroll->children()[0]->AddChild(child.Pass());
7639
7640 DrawFrame();
7641 {
7642 scoped_ptr<ScrollAndScaleSet> scroll_info;
7643
7644 gfx::Vector2d scroll_delta(0, inner_viewport.height());
7645 EXPECT_EQ(InputHandler::ScrollStarted,
7646 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture));
7647 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll);
7648
7649 // The child should have scrolled up to its limit.
7650 scroll_info = host_impl_->ProcessScrollDeltas();
7651 ASSERT_EQ(1u, scroll_info->scrolls.size());
7652 ExpectContains(*scroll_info, child_scroll->id(), scroll_delta);
7653 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_scroll);
7654
7655 // The first |ScrollBy| after the fling should re-lock the scrolling
7656 // layer to the first layer that scrolled, the inner viewport scroll layer.
7657 EXPECT_EQ(InputHandler::ScrollStarted, host_impl_->FlingScrollBegin());
7658 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll);
7659 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), inner_scroll);
7660
7661 // The inner viewport should have scrolled up to its limit.
7662 scroll_info = host_impl_->ProcessScrollDeltas();
7663 ASSERT_EQ(2u, scroll_info->scrolls.size());
7664 ExpectContains(*scroll_info, child_scroll->id(), scroll_delta);
7665 ExpectContains(*scroll_info, inner_scroll->id(), scroll_delta);
7666
7667 // As the locked layer is at its limit, no further scrolling can occur.
7668 EXPECT_FALSE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll);
7669 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), inner_scroll);
7670 host_impl_->ScrollEnd();
7671 }
7672 }
7673
7624 class LayerTreeHostImplWithImplicitLimitsTest : public LayerTreeHostImplTest { 7674 class LayerTreeHostImplWithImplicitLimitsTest : public LayerTreeHostImplTest {
7625 public: 7675 public:
7626 void SetUp() override { 7676 void SetUp() override {
7627 LayerTreeSettings settings = DefaultSettings(); 7677 LayerTreeSettings settings = DefaultSettings();
7628 settings.max_memory_for_prepaint_percentage = 50; 7678 settings.max_memory_for_prepaint_percentage = 50;
7629 CreateHostImpl(settings, CreateOutputSurface()); 7679 CreateHostImpl(settings, CreateOutputSurface());
7630 } 7680 }
7631 }; 7681 };
7632 7682
7633 TEST_F(LayerTreeHostImplWithImplicitLimitsTest, ImplicitMemoryLimits) { 7683 TEST_F(LayerTreeHostImplWithImplicitLimitsTest, ImplicitMemoryLimits) {
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
7878 // surface. 7928 // surface.
7879 EXPECT_EQ(0, num_lost_surfaces_); 7929 EXPECT_EQ(0, num_lost_surfaces_);
7880 host_impl_->DidLoseOutputSurface(); 7930 host_impl_->DidLoseOutputSurface();
7881 EXPECT_EQ(1, num_lost_surfaces_); 7931 EXPECT_EQ(1, num_lost_surfaces_);
7882 host_impl_->DidLoseOutputSurface(); 7932 host_impl_->DidLoseOutputSurface();
7883 EXPECT_LE(1, num_lost_surfaces_); 7933 EXPECT_LE(1, num_lost_surfaces_);
7884 } 7934 }
7885 7935
7886 } // namespace 7936 } // namespace
7887 } // namespace cc 7937 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698