| 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 4218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4229 host_impl_->top_controls_manager()->ScrollBegin(); | 4229 host_impl_->top_controls_manager()->ScrollBegin(); |
| 4230 host_impl_->top_controls_manager()->ScrollBy(-top_controls_scroll_delta); | 4230 host_impl_->top_controls_manager()->ScrollBy(-top_controls_scroll_delta); |
| 4231 EXPECT_EQ(top_controls_scroll_delta.y(), | 4231 EXPECT_EQ(top_controls_scroll_delta.y(), |
| 4232 host_impl_->top_controls_manager()->ContentTopOffset()); | 4232 host_impl_->top_controls_manager()->ContentTopOffset()); |
| 4233 EXPECT_VECTOR_EQ( | 4233 EXPECT_VECTOR_EQ( |
| 4234 gfx::Vector2dF(0, top_controls_height_ - top_controls_scroll_delta.y()), | 4234 gfx::Vector2dF(0, top_controls_height_ - top_controls_scroll_delta.y()), |
| 4235 outer_viewport_scroll_layer->FixedContainerSizeDelta()); | 4235 outer_viewport_scroll_layer->FixedContainerSizeDelta()); |
| 4236 host_impl_->top_controls_manager()->ScrollEnd(); | 4236 host_impl_->top_controls_manager()->ScrollEnd(); |
| 4237 } | 4237 } |
| 4238 | 4238 |
| 4239 // Push a top controls ratio from the main thread that we didn't send as a delta |
| 4240 // and make sure that the ratio is clamped to the [0, 1] range. |
| 4241 TEST_F(LayerTreeHostImplTopControlsTest, TopControlsPushUnsentRatio) { |
| 4242 SetupTopControlsAndScrollLayerWithVirtualViewport( |
| 4243 gfx::Size(10, 50), gfx::Size(10, 50), gfx::Size(10, 100)); |
| 4244 DrawFrame(); |
| 4245 |
| 4246 // Need SetDrawsContent so ScrollBegin's hit test finds an actual layer. |
| 4247 LayerImpl* inner_scroll = |
| 4248 host_impl_->active_tree()->InnerViewportScrollLayer(); |
| 4249 inner_scroll->SetDrawsContent(true); |
| 4250 LayerImpl* outer_scroll = |
| 4251 host_impl_->active_tree()->OuterViewportScrollLayer(); |
| 4252 outer_scroll->SetDrawsContent(true); |
| 4253 |
| 4254 host_impl_->active_tree()->PushTopControlsFromMainThread(1); |
| 4255 ASSERT_EQ(1.0f, host_impl_->active_tree()->CurrentTopControlsShownRatio()); |
| 4256 |
| 4257 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(0.5f); |
| 4258 ASSERT_EQ(0.5f, host_impl_->active_tree()->CurrentTopControlsShownRatio()); |
| 4259 |
| 4260 host_impl_->active_tree()->PushTopControlsFromMainThread(0); |
| 4261 |
| 4262 ASSERT_EQ(0, host_impl_->active_tree()->CurrentTopControlsShownRatio()); |
| 4263 } |
| 4264 |
| 4239 // Test that if only the top controls are scrolled, we shouldn't request a | 4265 // Test that if only the top controls are scrolled, we shouldn't request a |
| 4240 // commit. | 4266 // commit. |
| 4241 TEST_F(LayerTreeHostImplTopControlsTest, TopControlsDontTriggerCommit) { | 4267 TEST_F(LayerTreeHostImplTopControlsTest, TopControlsDontTriggerCommit) { |
| 4242 SetupTopControlsAndScrollLayerWithVirtualViewport( | 4268 SetupTopControlsAndScrollLayerWithVirtualViewport( |
| 4243 gfx::Size(100, 50), gfx::Size(100, 100), gfx::Size(100, 100)); | 4269 gfx::Size(100, 50), gfx::Size(100, 100), gfx::Size(100, 100)); |
| 4244 DrawFrame(); | 4270 DrawFrame(); |
| 4245 | 4271 |
| 4246 // Show top controls | 4272 // Show top controls |
| 4247 EXPECT_EQ(1.f, host_impl_->active_tree()->CurrentTopControlsShownRatio()); | 4273 EXPECT_EQ(1.f, host_impl_->active_tree()->CurrentTopControlsShownRatio()); |
| 4248 | 4274 |
| (...skipping 6628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10877 | 10903 |
| 10878 // Re-initialize with a software output surface. | 10904 // Re-initialize with a software output surface. |
| 10879 output_surface_ = FakeOutputSurface::CreateSoftware( | 10905 output_surface_ = FakeOutputSurface::CreateSoftware( |
| 10880 base::WrapUnique(new SoftwareOutputDevice)); | 10906 base::WrapUnique(new SoftwareOutputDevice)); |
| 10881 host_impl_->InitializeRenderer(output_surface_.get()); | 10907 host_impl_->InitializeRenderer(output_surface_.get()); |
| 10882 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 10908 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
| 10883 } | 10909 } |
| 10884 | 10910 |
| 10885 } // namespace | 10911 } // namespace |
| 10886 } // namespace cc | 10912 } // namespace cc |
| OLD | NEW |