| 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 2428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2439 | 2439 |
| 2440 // TODO(bokan): Convert these tests to create inner and outer viewports. | 2440 // TODO(bokan): Convert these tests to create inner and outer viewports. |
| 2441 class LayerTreeHostImplTopControlsTest : public LayerTreeHostImplTest { | 2441 class LayerTreeHostImplTopControlsTest : public LayerTreeHostImplTest { |
| 2442 public: | 2442 public: |
| 2443 LayerTreeHostImplTopControlsTest() | 2443 LayerTreeHostImplTopControlsTest() |
| 2444 // Make the clip size the same as the layer (content) size so the layer is | 2444 // Make the clip size the same as the layer (content) size so the layer is |
| 2445 // non-scrollable. | 2445 // non-scrollable. |
| 2446 : layer_size_(10, 10), | 2446 : layer_size_(10, 10), |
| 2447 clip_size_(layer_size_), | 2447 clip_size_(layer_size_), |
| 2448 top_controls_height_(50) { | 2448 top_controls_height_(50) { |
| 2449 settings_.calculate_top_controls_position = true; | |
| 2450 settings_.use_pinch_virtual_viewport = true; | 2449 settings_.use_pinch_virtual_viewport = true; |
| 2451 | 2450 |
| 2452 viewport_size_ = gfx::Size(clip_size_.width(), | 2451 viewport_size_ = gfx::Size(clip_size_.width(), |
| 2453 clip_size_.height() + top_controls_height_); | 2452 clip_size_.height() + top_controls_height_); |
| 2454 } | 2453 } |
| 2455 | 2454 |
| 2456 bool CreateHostImpl(const LayerTreeSettings& settings, | 2455 bool CreateHostImpl(const LayerTreeSettings& settings, |
| 2457 scoped_ptr<OutputSurface> output_surface) override { | 2456 scoped_ptr<OutputSurface> output_surface) override { |
| 2458 bool init = | 2457 bool init = |
| 2459 LayerTreeHostImplTest::CreateHostImpl(settings, output_surface.Pass()); | 2458 LayerTreeHostImplTest::CreateHostImpl(settings, output_surface.Pass()); |
| 2460 if (init && settings.calculate_top_controls_position) { | 2459 if (init) { |
| 2461 host_impl_->active_tree()->set_top_controls_height(top_controls_height_); | 2460 host_impl_->active_tree()->set_top_controls_height(top_controls_height_); |
| 2462 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(1.f); | 2461 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(1.f); |
| 2463 } | 2462 } |
| 2464 return init; | 2463 return init; |
| 2465 } | 2464 } |
| 2466 | 2465 |
| 2467 void SetupTopControlsAndScrollLayer() { | 2466 void SetupTopControlsAndScrollLayer() { |
| 2468 scoped_ptr<LayerImpl> root = | 2467 scoped_ptr<LayerImpl> root = |
| 2469 LayerImpl::Create(host_impl_->active_tree(), 1); | 2468 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 2470 scoped_ptr<LayerImpl> root_clip = | 2469 scoped_ptr<LayerImpl> root_clip = |
| (...skipping 4977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7448 EXPECT_EQ(0, set_needs_commit_count); | 7447 EXPECT_EQ(0, set_needs_commit_count); |
| 7449 EXPECT_EQ(2, set_needs_redraw_count); | 7448 EXPECT_EQ(2, set_needs_redraw_count); |
| 7450 EXPECT_EQ(1, forward_to_main_count); | 7449 EXPECT_EQ(1, forward_to_main_count); |
| 7451 } | 7450 } |
| 7452 } | 7451 } |
| 7453 | 7452 |
| 7454 class LayerTreeHostImplWithTopControlsTest : public LayerTreeHostImplTest { | 7453 class LayerTreeHostImplWithTopControlsTest : public LayerTreeHostImplTest { |
| 7455 public: | 7454 public: |
| 7456 void SetUp() override { | 7455 void SetUp() override { |
| 7457 LayerTreeSettings settings = DefaultSettings(); | 7456 LayerTreeSettings settings = DefaultSettings(); |
| 7458 settings.calculate_top_controls_position = true; | |
| 7459 CreateHostImpl(settings, CreateOutputSurface()); | 7457 CreateHostImpl(settings, CreateOutputSurface()); |
| 7460 host_impl_->active_tree()->set_top_controls_height(top_controls_height_); | 7458 host_impl_->active_tree()->set_top_controls_height(top_controls_height_); |
| 7461 host_impl_->sync_tree()->set_top_controls_height(top_controls_height_); | 7459 host_impl_->sync_tree()->set_top_controls_height(top_controls_height_); |
| 7462 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(1.f); | 7460 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(1.f); |
| 7463 } | 7461 } |
| 7464 | 7462 |
| 7465 protected: | 7463 protected: |
| 7466 static const int top_controls_height_; | 7464 static const int top_controls_height_; |
| 7467 }; | 7465 }; |
| 7468 | 7466 |
| (...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8477 // surface. | 8475 // surface. |
| 8478 EXPECT_EQ(0, num_lost_surfaces_); | 8476 EXPECT_EQ(0, num_lost_surfaces_); |
| 8479 host_impl_->DidLoseOutputSurface(); | 8477 host_impl_->DidLoseOutputSurface(); |
| 8480 EXPECT_EQ(1, num_lost_surfaces_); | 8478 EXPECT_EQ(1, num_lost_surfaces_); |
| 8481 host_impl_->DidLoseOutputSurface(); | 8479 host_impl_->DidLoseOutputSurface(); |
| 8482 EXPECT_LE(1, num_lost_surfaces_); | 8480 EXPECT_LE(1, num_lost_surfaces_); |
| 8483 } | 8481 } |
| 8484 | 8482 |
| 8485 } // namespace | 8483 } // namespace |
| 8486 } // namespace cc | 8484 } // namespace cc |
| OLD | NEW |