| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 2460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2471 | 2471 |
| 2472 // TODO(bokan): Convert these tests to create inner and outer viewports. | 2472 // TODO(bokan): Convert these tests to create inner and outer viewports. |
| 2473 class LayerTreeHostImplTopControlsTest : public LayerTreeHostImplTest { | 2473 class LayerTreeHostImplTopControlsTest : public LayerTreeHostImplTest { |
| 2474 public: | 2474 public: |
| 2475 LayerTreeHostImplTopControlsTest() | 2475 LayerTreeHostImplTopControlsTest() |
| 2476 // Make the clip size the same as the layer (content) size so the layer is | 2476 // Make the clip size the same as the layer (content) size so the layer is |
| 2477 // non-scrollable. | 2477 // non-scrollable. |
| 2478 : layer_size_(10, 10), | 2478 : layer_size_(10, 10), |
| 2479 clip_size_(layer_size_), | 2479 clip_size_(layer_size_), |
| 2480 top_controls_height_(50) { | 2480 top_controls_height_(50) { |
| 2481 settings_.calculate_top_controls_position = true; | |
| 2482 settings_.use_pinch_virtual_viewport = true; | 2481 settings_.use_pinch_virtual_viewport = true; |
| 2483 | 2482 |
| 2484 viewport_size_ = gfx::Size(clip_size_.width(), | 2483 viewport_size_ = gfx::Size(clip_size_.width(), |
| 2485 clip_size_.height() + top_controls_height_); | 2484 clip_size_.height() + top_controls_height_); |
| 2486 } | 2485 } |
| 2487 | 2486 |
| 2488 bool CreateHostImpl(const LayerTreeSettings& settings, | 2487 bool CreateHostImpl(const LayerTreeSettings& settings, |
| 2489 scoped_ptr<OutputSurface> output_surface) override { | 2488 scoped_ptr<OutputSurface> output_surface) override { |
| 2490 bool init = | 2489 bool init = |
| 2491 LayerTreeHostImplTest::CreateHostImpl(settings, output_surface.Pass()); | 2490 LayerTreeHostImplTest::CreateHostImpl(settings, output_surface.Pass()); |
| 2492 if (init && settings.calculate_top_controls_position) { | 2491 if (init) { |
| 2493 host_impl_->active_tree()->set_top_controls_height(top_controls_height_); | 2492 host_impl_->active_tree()->set_top_controls_height(top_controls_height_); |
| 2494 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(1.f); | 2493 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(1.f); |
| 2495 } | 2494 } |
| 2496 return init; | 2495 return init; |
| 2497 } | 2496 } |
| 2498 | 2497 |
| 2499 void SetupTopControlsAndScrollLayer() { | 2498 void SetupTopControlsAndScrollLayer() { |
| 2500 scoped_ptr<LayerImpl> root = | 2499 scoped_ptr<LayerImpl> root = |
| 2501 LayerImpl::Create(host_impl_->active_tree(), 1); | 2500 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 2502 scoped_ptr<LayerImpl> root_clip = | 2501 scoped_ptr<LayerImpl> root_clip = |
| (...skipping 4943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7446 EXPECT_EQ(0, set_needs_commit_count); | 7445 EXPECT_EQ(0, set_needs_commit_count); |
| 7447 EXPECT_EQ(2, set_needs_redraw_count); | 7446 EXPECT_EQ(2, set_needs_redraw_count); |
| 7448 EXPECT_EQ(1, forward_to_main_count); | 7447 EXPECT_EQ(1, forward_to_main_count); |
| 7449 } | 7448 } |
| 7450 } | 7449 } |
| 7451 | 7450 |
| 7452 class LayerTreeHostImplWithTopControlsTest : public LayerTreeHostImplTest { | 7451 class LayerTreeHostImplWithTopControlsTest : public LayerTreeHostImplTest { |
| 7453 public: | 7452 public: |
| 7454 void SetUp() override { | 7453 void SetUp() override { |
| 7455 LayerTreeSettings settings = DefaultSettings(); | 7454 LayerTreeSettings settings = DefaultSettings(); |
| 7456 settings.calculate_top_controls_position = true; | |
| 7457 CreateHostImpl(settings, CreateOutputSurface()); | 7455 CreateHostImpl(settings, CreateOutputSurface()); |
| 7458 host_impl_->active_tree()->set_top_controls_height(top_controls_height_); | 7456 host_impl_->active_tree()->set_top_controls_height(top_controls_height_); |
| 7459 host_impl_->sync_tree()->set_top_controls_height(top_controls_height_); | 7457 host_impl_->sync_tree()->set_top_controls_height(top_controls_height_); |
| 7460 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(1.f); | 7458 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(1.f); |
| 7461 } | 7459 } |
| 7462 | 7460 |
| 7463 protected: | 7461 protected: |
| 7464 static const int top_controls_height_; | 7462 static const int top_controls_height_; |
| 7465 }; | 7463 }; |
| 7466 | 7464 |
| (...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8475 // surface. | 8473 // surface. |
| 8476 EXPECT_EQ(0, num_lost_surfaces_); | 8474 EXPECT_EQ(0, num_lost_surfaces_); |
| 8477 host_impl_->DidLoseOutputSurface(); | 8475 host_impl_->DidLoseOutputSurface(); |
| 8478 EXPECT_EQ(1, num_lost_surfaces_); | 8476 EXPECT_EQ(1, num_lost_surfaces_); |
| 8479 host_impl_->DidLoseOutputSurface(); | 8477 host_impl_->DidLoseOutputSurface(); |
| 8480 EXPECT_LE(1, num_lost_surfaces_); | 8478 EXPECT_LE(1, num_lost_surfaces_); |
| 8481 } | 8479 } |
| 8482 | 8480 |
| 8483 } // namespace | 8481 } // namespace |
| 8484 } // namespace cc | 8482 } // namespace cc |
| OLD | NEW |