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

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

Issue 737883002: Allow perfect scroll bubbling between outer/inner viewports (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Restore layer locking logic Created 6 years, 1 month 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
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 7461 matching lines...) Expand 10 before | Expand all | Expand 10 after
7472 host_impl_->ScrollBy(gfx::Point(), scroll_delta); 7472 host_impl_->ScrollBy(gfx::Point(), scroll_delta);
7473 inner_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); 7473 inner_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y());
7474 7474
7475 host_impl_->ScrollEnd(); 7475 host_impl_->ScrollEnd();
7476 7476
7477 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->TotalScrollOffset()); 7477 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->TotalScrollOffset());
7478 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->TotalScrollOffset()); 7478 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->TotalScrollOffset());
7479 } 7479 }
7480 } 7480 }
7481 7481
7482 TEST_F(LayerTreeHostImplVirtualViewportTest,
7483 DiagonalScrollBubblesPerfectlyToInner) {
7484 gfx::Size content_size = gfx::Size(100, 160);
7485 gfx::Size outer_viewport = gfx::Size(50, 80);
7486 gfx::Size inner_viewport = gfx::Size(25, 40);
7487
7488 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport);
7489
7490 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer();
7491 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer();
7492 DrawFrame();
7493 {
7494 gfx::Vector2dF inner_expected;
7495 gfx::Vector2dF outer_expected;
7496 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->TotalScrollOffset());
7497 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->TotalScrollOffset());
7498
7499 // Make sure the scroll goes to the outer viewport first.
7500 EXPECT_EQ(InputHandler::ScrollStarted,
7501 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture));
7502 EXPECT_EQ(InputHandler::ScrollStarted, host_impl_->FlingScrollBegin());
7503
7504 // Scroll near the edge of the outer viewport.
7505 gfx::Vector2d scroll_delta(inner_viewport.width(), inner_viewport.height());
7506 host_impl_->ScrollBy(gfx::Point(), scroll_delta);
7507 outer_expected += scroll_delta;
7508
7509 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->TotalScrollOffset());
7510 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->TotalScrollOffset());
7511
7512 // Now diagonal scroll across the outer viewport boundary in a single event.
7513 // The entirety of the scroll should be consumed, as bubbling between inner
7514 // and outer viewport layers is perfect.
7515 host_impl_->ScrollBy(gfx::Point(), gfx::ScaleVector2d(scroll_delta, 2));
7516 outer_expected += scroll_delta;
7517 inner_expected += scroll_delta;
7518 host_impl_->ScrollEnd();
7519
7520 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->TotalScrollOffset());
7521 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->TotalScrollOffset());
7522 }
7523 }
7524
7482 class LayerTreeHostImplWithImplicitLimitsTest : public LayerTreeHostImplTest { 7525 class LayerTreeHostImplWithImplicitLimitsTest : public LayerTreeHostImplTest {
7483 public: 7526 public:
7484 void SetUp() override { 7527 void SetUp() override {
7485 LayerTreeSettings settings = DefaultSettings(); 7528 LayerTreeSettings settings = DefaultSettings();
7486 settings.max_memory_for_prepaint_percentage = 50; 7529 settings.max_memory_for_prepaint_percentage = 50;
7487 CreateHostImpl(settings, CreateOutputSurface()); 7530 CreateHostImpl(settings, CreateOutputSurface());
7488 } 7531 }
7489 }; 7532 };
7490 7533
7491 TEST_F(LayerTreeHostImplWithImplicitLimitsTest, ImplicitMemoryLimits) { 7534 TEST_F(LayerTreeHostImplWithImplicitLimitsTest, ImplicitMemoryLimits) {
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
7701 // surface. 7744 // surface.
7702 EXPECT_EQ(0, num_lost_surfaces_); 7745 EXPECT_EQ(0, num_lost_surfaces_);
7703 host_impl_->DidLoseOutputSurface(); 7746 host_impl_->DidLoseOutputSurface();
7704 EXPECT_EQ(1, num_lost_surfaces_); 7747 EXPECT_EQ(1, num_lost_surfaces_);
7705 host_impl_->DidLoseOutputSurface(); 7748 host_impl_->DidLoseOutputSurface();
7706 EXPECT_LE(1, num_lost_surfaces_); 7749 EXPECT_LE(1, num_lost_surfaces_);
7707 } 7750 }
7708 7751
7709 } // namespace 7752 } // namespace
7710 } // namespace cc 7753 } // namespace cc
OLDNEW
« cc/trees/layer_tree_host_impl.cc ('K') | « cc/trees/layer_tree_host_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698