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; |
2481 settings_.use_pinch_virtual_viewport = true; | 2482 settings_.use_pinch_virtual_viewport = true; |
2482 | 2483 |
2483 viewport_size_ = gfx::Size(clip_size_.width(), | 2484 viewport_size_ = gfx::Size(clip_size_.width(), |
2484 clip_size_.height() + top_controls_height_); | 2485 clip_size_.height() + top_controls_height_); |
2485 } | 2486 } |
2486 | 2487 |
2487 bool CreateHostImpl(const LayerTreeSettings& settings, | 2488 bool CreateHostImpl(const LayerTreeSettings& settings, |
2488 scoped_ptr<OutputSurface> output_surface) override { | 2489 scoped_ptr<OutputSurface> output_surface) override { |
2489 bool init = | 2490 bool init = |
2490 LayerTreeHostImplTest::CreateHostImpl(settings, output_surface.Pass()); | 2491 LayerTreeHostImplTest::CreateHostImpl(settings, output_surface.Pass()); |
2491 if (init) { | 2492 if (init && settings.calculate_top_controls_position) { |
2492 host_impl_->active_tree()->set_top_controls_height(top_controls_height_); | 2493 host_impl_->active_tree()->set_top_controls_height(top_controls_height_); |
2493 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(1.f); | 2494 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(1.f); |
2494 } | 2495 } |
2495 return init; | 2496 return init; |
2496 } | 2497 } |
2497 | 2498 |
2498 void SetupTopControlsAndScrollLayer() { | 2499 void SetupTopControlsAndScrollLayer() { |
2499 scoped_ptr<LayerImpl> root = | 2500 scoped_ptr<LayerImpl> root = |
2500 LayerImpl::Create(host_impl_->active_tree(), 1); | 2501 LayerImpl::Create(host_impl_->active_tree(), 1); |
2501 scoped_ptr<LayerImpl> root_clip = | 2502 scoped_ptr<LayerImpl> root_clip = |
(...skipping 4943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7445 EXPECT_EQ(0, set_needs_commit_count); | 7446 EXPECT_EQ(0, set_needs_commit_count); |
7446 EXPECT_EQ(2, set_needs_redraw_count); | 7447 EXPECT_EQ(2, set_needs_redraw_count); |
7447 EXPECT_EQ(1, forward_to_main_count); | 7448 EXPECT_EQ(1, forward_to_main_count); |
7448 } | 7449 } |
7449 } | 7450 } |
7450 | 7451 |
7451 class LayerTreeHostImplWithTopControlsTest : public LayerTreeHostImplTest { | 7452 class LayerTreeHostImplWithTopControlsTest : public LayerTreeHostImplTest { |
7452 public: | 7453 public: |
7453 void SetUp() override { | 7454 void SetUp() override { |
7454 LayerTreeSettings settings = DefaultSettings(); | 7455 LayerTreeSettings settings = DefaultSettings(); |
| 7456 settings.calculate_top_controls_position = true; |
7455 CreateHostImpl(settings, CreateOutputSurface()); | 7457 CreateHostImpl(settings, CreateOutputSurface()); |
7456 host_impl_->active_tree()->set_top_controls_height(top_controls_height_); | 7458 host_impl_->active_tree()->set_top_controls_height(top_controls_height_); |
7457 host_impl_->sync_tree()->set_top_controls_height(top_controls_height_); | 7459 host_impl_->sync_tree()->set_top_controls_height(top_controls_height_); |
7458 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(1.f); | 7460 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(1.f); |
7459 } | 7461 } |
7460 | 7462 |
7461 protected: | 7463 protected: |
7462 static const int top_controls_height_; | 7464 static const int top_controls_height_; |
7463 }; | 7465 }; |
7464 | 7466 |
(...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8473 // surface. | 8475 // surface. |
8474 EXPECT_EQ(0, num_lost_surfaces_); | 8476 EXPECT_EQ(0, num_lost_surfaces_); |
8475 host_impl_->DidLoseOutputSurface(); | 8477 host_impl_->DidLoseOutputSurface(); |
8476 EXPECT_EQ(1, num_lost_surfaces_); | 8478 EXPECT_EQ(1, num_lost_surfaces_); |
8477 host_impl_->DidLoseOutputSurface(); | 8479 host_impl_->DidLoseOutputSurface(); |
8478 EXPECT_LE(1, num_lost_surfaces_); | 8480 EXPECT_LE(1, num_lost_surfaces_); |
8479 } | 8481 } |
8480 | 8482 |
8481 } // namespace | 8483 } // namespace |
8482 } // namespace cc | 8484 } // namespace cc |
OLD | NEW |