| 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 <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 2160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2171 root->SetIsContainerForFixedPositionLayers(true); | 2171 root->SetIsContainerForFixedPositionLayers(true); |
| 2172 int inner_viewport_scroll_layer_id = root->id(); | 2172 int inner_viewport_scroll_layer_id = root->id(); |
| 2173 int page_scale_layer_id = root_clip->id(); | 2173 int page_scale_layer_id = root_clip->id(); |
| 2174 root_clip->AddChild(root.Pass()); | 2174 root_clip->AddChild(root.Pass()); |
| 2175 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 2175 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); |
| 2176 host_impl_->active_tree()->SetViewportLayersFromIds( | 2176 host_impl_->active_tree()->SetViewportLayersFromIds( |
| 2177 page_scale_layer_id, inner_viewport_scroll_layer_id, Layer::INVALID_ID); | 2177 page_scale_layer_id, inner_viewport_scroll_layer_id, Layer::INVALID_ID); |
| 2178 // Set a viewport size that is large enough to contain both the top controls | 2178 // Set a viewport size that is large enough to contain both the top controls |
| 2179 // and some content. | 2179 // and some content. |
| 2180 host_impl_->SetViewportSize(viewport_size_); | 2180 host_impl_->SetViewportSize(viewport_size_); |
| 2181 host_impl_->active_tree()->set_top_controls_content_offset( | |
| 2182 settings_.top_controls_height); | |
| 2183 host_impl_->SetTopControlsLayoutHeight( | 2181 host_impl_->SetTopControlsLayoutHeight( |
| 2184 settings_.top_controls_height); | 2182 settings_.top_controls_height); |
| 2185 LayerImpl* root_clip_ptr = host_impl_->active_tree()->root_layer(); | 2183 LayerImpl* root_clip_ptr = host_impl_->active_tree()->root_layer(); |
| 2186 EXPECT_EQ(clip_size_, root_clip_ptr->bounds()); | 2184 EXPECT_EQ(clip_size_, root_clip_ptr->bounds()); |
| 2187 | 2185 |
| 2188 host_impl_->CreatePendingTree(); | 2186 host_impl_->CreatePendingTree(); |
| 2189 root = | 2187 root = |
| 2190 LayerImpl::Create(host_impl_->sync_tree(), 1); | 2188 LayerImpl::Create(host_impl_->sync_tree(), 1); |
| 2191 root_clip = | 2189 root_clip = |
| 2192 LayerImpl::Create(host_impl_->sync_tree(), 2); | 2190 LayerImpl::Create(host_impl_->sync_tree(), 2); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2273 inner_viewport_scroll_layer->FixedContainerSizeDelta()).LengthSquared(), | 2271 inner_viewport_scroll_layer->FixedContainerSizeDelta()).LengthSquared(), |
| 2274 tolerance); | 2272 tolerance); |
| 2275 } | 2273 } |
| 2276 | 2274 |
| 2277 // Ensure setting the top controls position explicitly using the setters on the | 2275 // Ensure setting the top controls position explicitly using the setters on the |
| 2278 // TreeImpl correctly affects the top controls manager and viewport bounds. | 2276 // TreeImpl correctly affects the top controls manager and viewport bounds. |
| 2279 TEST_F(LayerTreeHostImplTopControlsTest, PositionTopControlsExplicitly) { | 2277 TEST_F(LayerTreeHostImplTopControlsTest, PositionTopControlsExplicitly) { |
| 2280 SetupTopControlsAndScrollLayer(); | 2278 SetupTopControlsAndScrollLayer(); |
| 2281 DrawFrame(); | 2279 DrawFrame(); |
| 2282 | 2280 |
| 2281 host_impl_->active_tree()->set_top_controls_delta(0.f); |
| 2283 host_impl_->active_tree()->set_top_controls_content_offset(30.f); | 2282 host_impl_->active_tree()->set_top_controls_content_offset(30.f); |
| 2284 EXPECT_EQ(30.f, host_impl_->top_controls_manager()->ContentTopOffset()); | 2283 EXPECT_EQ(30.f, host_impl_->top_controls_manager()->ContentTopOffset()); |
| 2285 EXPECT_EQ(-20.f, host_impl_->top_controls_manager()->ControlsTopOffset()); | 2284 EXPECT_EQ(-20.f, host_impl_->top_controls_manager()->ControlsTopOffset()); |
| 2286 | 2285 |
| 2287 host_impl_->active_tree()->set_top_controls_delta(-30.f); | 2286 host_impl_->active_tree()->set_top_controls_delta(-30.f); |
| 2288 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); | 2287 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); |
| 2289 EXPECT_EQ(-50.f, host_impl_->top_controls_manager()->ControlsTopOffset()); | 2288 EXPECT_EQ(-50.f, host_impl_->top_controls_manager()->ControlsTopOffset()); |
| 2290 | 2289 |
| 2291 host_impl_->DidChangeTopControlsPosition(); | 2290 host_impl_->DidChangeTopControlsPosition(); |
| 2292 | 2291 |
| (...skipping 4878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7171 // surface. | 7170 // surface. |
| 7172 EXPECT_EQ(0, num_lost_surfaces_); | 7171 EXPECT_EQ(0, num_lost_surfaces_); |
| 7173 host_impl_->DidLoseOutputSurface(); | 7172 host_impl_->DidLoseOutputSurface(); |
| 7174 EXPECT_EQ(1, num_lost_surfaces_); | 7173 EXPECT_EQ(1, num_lost_surfaces_); |
| 7175 host_impl_->DidLoseOutputSurface(); | 7174 host_impl_->DidLoseOutputSurface(); |
| 7176 EXPECT_LE(1, num_lost_surfaces_); | 7175 EXPECT_LE(1, num_lost_surfaces_); |
| 7177 } | 7176 } |
| 7178 | 7177 |
| 7179 } // namespace | 7178 } // namespace |
| 7180 } // namespace cc | 7179 } // namespace cc |
| OLD | NEW |