| 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 1821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1832 DrawFrame(); | 1832 DrawFrame(); |
| 1833 { | 1833 { |
| 1834 CompositorFrameMetadata metadata = | 1834 CompositorFrameMetadata metadata = |
| 1835 host_impl_->MakeCompositorFrameMetadata(); | 1835 host_impl_->MakeCompositorFrameMetadata(); |
| 1836 EXPECT_EQ(gfx::Vector2dF(), metadata.root_scroll_offset); | 1836 EXPECT_EQ(gfx::Vector2dF(), metadata.root_scroll_offset); |
| 1837 EXPECT_EQ(1.f, metadata.page_scale_factor); | 1837 EXPECT_EQ(1.f, metadata.page_scale_factor); |
| 1838 EXPECT_EQ(gfx::SizeF(50.f, 50.f), metadata.scrollable_viewport_size); | 1838 EXPECT_EQ(gfx::SizeF(50.f, 50.f), metadata.scrollable_viewport_size); |
| 1839 EXPECT_EQ(gfx::SizeF(100.f, 100.f), metadata.root_layer_size); | 1839 EXPECT_EQ(gfx::SizeF(100.f, 100.f), metadata.root_layer_size); |
| 1840 EXPECT_EQ(0.5f, metadata.min_page_scale_factor); | 1840 EXPECT_EQ(0.5f, metadata.min_page_scale_factor); |
| 1841 EXPECT_EQ(4.f, metadata.max_page_scale_factor); | 1841 EXPECT_EQ(4.f, metadata.max_page_scale_factor); |
| 1842 EXPECT_FALSE(metadata.root_overflow_x_hidden); |
| 1843 EXPECT_FALSE(metadata.root_overflow_y_hidden); |
| 1842 } | 1844 } |
| 1843 | 1845 |
| 1844 // Scrolling should update metadata immediately. | 1846 // Scrolling should update metadata immediately. |
| 1845 EXPECT_EQ(InputHandler::ScrollStarted, | 1847 EXPECT_EQ(InputHandler::ScrollStarted, |
| 1846 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); | 1848 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
| 1847 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 1849 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
| 1848 { | 1850 { |
| 1849 CompositorFrameMetadata metadata = | 1851 CompositorFrameMetadata metadata = |
| 1850 host_impl_->MakeCompositorFrameMetadata(); | 1852 host_impl_->MakeCompositorFrameMetadata(); |
| 1851 EXPECT_EQ(gfx::Vector2dF(0.f, 10.f), metadata.root_scroll_offset); | 1853 EXPECT_EQ(gfx::Vector2dF(0.f, 10.f), metadata.root_scroll_offset); |
| 1852 } | 1854 } |
| 1853 host_impl_->ScrollEnd(); | 1855 host_impl_->ScrollEnd(); |
| 1854 { | 1856 { |
| 1855 CompositorFrameMetadata metadata = | 1857 CompositorFrameMetadata metadata = |
| 1856 host_impl_->MakeCompositorFrameMetadata(); | 1858 host_impl_->MakeCompositorFrameMetadata(); |
| 1857 EXPECT_EQ(gfx::Vector2dF(0.f, 10.f), metadata.root_scroll_offset); | 1859 EXPECT_EQ(gfx::Vector2dF(0.f, 10.f), metadata.root_scroll_offset); |
| 1858 } | 1860 } |
| 1859 | 1861 |
| 1862 // Root "overflow: hidden" properties should be reflected. |
| 1863 { |
| 1864 host_impl_->active_tree() |
| 1865 ->InnerViewportScrollLayer() |
| 1866 ->set_user_scrollable_horizontal(false); |
| 1867 CompositorFrameMetadata metadata = |
| 1868 host_impl_->MakeCompositorFrameMetadata(); |
| 1869 EXPECT_TRUE(metadata.root_overflow_x_hidden); |
| 1870 EXPECT_FALSE(metadata.root_overflow_y_hidden); |
| 1871 |
| 1872 host_impl_->active_tree() |
| 1873 ->InnerViewportScrollLayer() |
| 1874 ->set_user_scrollable_vertical(false); |
| 1875 metadata = host_impl_->MakeCompositorFrameMetadata(); |
| 1876 EXPECT_TRUE(metadata.root_overflow_x_hidden); |
| 1877 EXPECT_TRUE(metadata.root_overflow_y_hidden); |
| 1878 } |
| 1879 |
| 1860 // Page scale should update metadata correctly (shrinking only the viewport). | 1880 // Page scale should update metadata correctly (shrinking only the viewport). |
| 1861 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture); | 1881 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture); |
| 1862 host_impl_->PinchGestureBegin(); | 1882 host_impl_->PinchGestureBegin(); |
| 1863 host_impl_->PinchGestureUpdate(2.f, gfx::Point()); | 1883 host_impl_->PinchGestureUpdate(2.f, gfx::Point()); |
| 1864 host_impl_->PinchGestureEnd(); | 1884 host_impl_->PinchGestureEnd(); |
| 1865 host_impl_->ScrollEnd(); | 1885 host_impl_->ScrollEnd(); |
| 1866 { | 1886 { |
| 1867 CompositorFrameMetadata metadata = | 1887 CompositorFrameMetadata metadata = |
| 1868 host_impl_->MakeCompositorFrameMetadata(); | 1888 host_impl_->MakeCompositorFrameMetadata(); |
| 1869 EXPECT_EQ(gfx::Vector2dF(0.f, 10.f), metadata.root_scroll_offset); | 1889 EXPECT_EQ(gfx::Vector2dF(0.f, 10.f), metadata.root_scroll_offset); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1897 } | 1917 } |
| 1898 | 1918 |
| 1899 bool WillDraw(DrawMode draw_mode, ResourceProvider* provider) override { | 1919 bool WillDraw(DrawMode draw_mode, ResourceProvider* provider) override { |
| 1900 will_draw_called_ = true; | 1920 will_draw_called_ = true; |
| 1901 if (will_draw_returns_false_) | 1921 if (will_draw_returns_false_) |
| 1902 return false; | 1922 return false; |
| 1903 return LayerImpl::WillDraw(draw_mode, provider); | 1923 return LayerImpl::WillDraw(draw_mode, provider); |
| 1904 } | 1924 } |
| 1905 | 1925 |
| 1906 void AppendQuads(RenderPass* render_pass, | 1926 void AppendQuads(RenderPass* render_pass, |
| 1907 const Occlusion& occlusion_in_content_space, | |
| 1908 AppendQuadsData* append_quads_data) override { | 1927 AppendQuadsData* append_quads_data) override { |
| 1909 append_quads_called_ = true; | 1928 append_quads_called_ = true; |
| 1910 LayerImpl::AppendQuads( | 1929 LayerImpl::AppendQuads(render_pass, append_quads_data); |
| 1911 render_pass, occlusion_in_content_space, append_quads_data); | |
| 1912 } | 1930 } |
| 1913 | 1931 |
| 1914 void DidDraw(ResourceProvider* provider) override { | 1932 void DidDraw(ResourceProvider* provider) override { |
| 1915 did_draw_called_ = true; | 1933 did_draw_called_ = true; |
| 1916 LayerImpl::DidDraw(provider); | 1934 LayerImpl::DidDraw(provider); |
| 1917 } | 1935 } |
| 1918 | 1936 |
| 1919 bool will_draw_called() const { return will_draw_called_; } | 1937 bool will_draw_called() const { return will_draw_called_; } |
| 1920 bool append_quads_called() const { return append_quads_called_; } | 1938 bool append_quads_called() const { return append_quads_called_; } |
| 1921 bool did_draw_called() const { return did_draw_called_; } | 1939 bool did_draw_called() const { return did_draw_called_; } |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2124 ResourceProvider* resource_provider) { | 2142 ResourceProvider* resource_provider) { |
| 2125 return make_scoped_ptr(new MissingTextureAnimatingLayer(tree_impl, | 2143 return make_scoped_ptr(new MissingTextureAnimatingLayer(tree_impl, |
| 2126 id, | 2144 id, |
| 2127 tile_missing, | 2145 tile_missing, |
| 2128 had_incomplete_tile, | 2146 had_incomplete_tile, |
| 2129 animating, | 2147 animating, |
| 2130 resource_provider)); | 2148 resource_provider)); |
| 2131 } | 2149 } |
| 2132 | 2150 |
| 2133 void AppendQuads(RenderPass* render_pass, | 2151 void AppendQuads(RenderPass* render_pass, |
| 2134 const Occlusion& occlusion_in_content_space, | |
| 2135 AppendQuadsData* append_quads_data) override { | 2152 AppendQuadsData* append_quads_data) override { |
| 2136 LayerImpl::AppendQuads( | 2153 LayerImpl::AppendQuads(render_pass, append_quads_data); |
| 2137 render_pass, occlusion_in_content_space, append_quads_data); | |
| 2138 if (had_incomplete_tile_) | 2154 if (had_incomplete_tile_) |
| 2139 append_quads_data->num_incomplete_tiles++; | 2155 append_quads_data->num_incomplete_tiles++; |
| 2140 if (tile_missing_) | 2156 if (tile_missing_) |
| 2141 append_quads_data->num_missing_tiles++; | 2157 append_quads_data->num_missing_tiles++; |
| 2142 } | 2158 } |
| 2143 | 2159 |
| 2144 private: | 2160 private: |
| 2145 MissingTextureAnimatingLayer(LayerTreeImpl* tree_impl, | 2161 MissingTextureAnimatingLayer(LayerTreeImpl* tree_impl, |
| 2146 int id, | 2162 int id, |
| 2147 bool tile_missing, | 2163 bool tile_missing, |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2449 viewport_size_ = gfx::Size(clip_size_.width(), | 2465 viewport_size_ = gfx::Size(clip_size_.width(), |
| 2450 clip_size_.height() + top_controls_height_); | 2466 clip_size_.height() + top_controls_height_); |
| 2451 } | 2467 } |
| 2452 | 2468 |
| 2453 bool CreateHostImpl(const LayerTreeSettings& settings, | 2469 bool CreateHostImpl(const LayerTreeSettings& settings, |
| 2454 scoped_ptr<OutputSurface> output_surface) override { | 2470 scoped_ptr<OutputSurface> output_surface) override { |
| 2455 bool init = | 2471 bool init = |
| 2456 LayerTreeHostImplTest::CreateHostImpl(settings, output_surface.Pass()); | 2472 LayerTreeHostImplTest::CreateHostImpl(settings, output_surface.Pass()); |
| 2457 if (init && settings.calculate_top_controls_position) { | 2473 if (init && settings.calculate_top_controls_position) { |
| 2458 host_impl_->active_tree()->set_top_controls_height(top_controls_height_); | 2474 host_impl_->active_tree()->set_top_controls_height(top_controls_height_); |
| 2459 host_impl_->active_tree()->set_top_controls_delta(top_controls_height_); | 2475 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(1.f); |
| 2460 host_impl_->top_controls_manager()->SetTopControlsHeight( | |
| 2461 top_controls_height_); | |
| 2462 host_impl_->DidChangeTopControlsPosition(); | |
| 2463 } | 2476 } |
| 2464 return init; | 2477 return init; |
| 2465 } | 2478 } |
| 2466 | 2479 |
| 2467 void SetupTopControlsAndScrollLayer() { | 2480 void SetupTopControlsAndScrollLayer() { |
| 2468 scoped_ptr<LayerImpl> root = | 2481 scoped_ptr<LayerImpl> root = |
| 2469 LayerImpl::Create(host_impl_->active_tree(), 1); | 2482 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 2470 scoped_ptr<LayerImpl> root_clip = | 2483 scoped_ptr<LayerImpl> root_clip = |
| 2471 LayerImpl::Create(host_impl_->active_tree(), 2); | 2484 LayerImpl::Create(host_impl_->active_tree(), 2); |
| 2472 root_clip->SetBounds(clip_size_); | 2485 root_clip->SetBounds(clip_size_); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2486 Layer::INVALID_ID, page_scale_layer_id, inner_viewport_scroll_layer_id, | 2499 Layer::INVALID_ID, page_scale_layer_id, inner_viewport_scroll_layer_id, |
| 2487 Layer::INVALID_ID); | 2500 Layer::INVALID_ID); |
| 2488 // Set a viewport size that is large enough to contain both the top controls | 2501 // Set a viewport size that is large enough to contain both the top controls |
| 2489 // and some content. | 2502 // and some content. |
| 2490 host_impl_->SetViewportSize(viewport_size_); | 2503 host_impl_->SetViewportSize(viewport_size_); |
| 2491 host_impl_->sync_tree()->set_top_controls_shrink_blink_size(true); | 2504 host_impl_->sync_tree()->set_top_controls_shrink_blink_size(true); |
| 2492 | 2505 |
| 2493 host_impl_->DidChangeTopControlsPosition(); | 2506 host_impl_->DidChangeTopControlsPosition(); |
| 2494 | 2507 |
| 2495 host_impl_->CreatePendingTree(); | 2508 host_impl_->CreatePendingTree(); |
| 2509 host_impl_->sync_tree()->set_top_controls_height(top_controls_height_); |
| 2496 root = | 2510 root = |
| 2497 LayerImpl::Create(host_impl_->sync_tree(), 1); | 2511 LayerImpl::Create(host_impl_->sync_tree(), 1); |
| 2498 root_clip = | 2512 root_clip = |
| 2499 LayerImpl::Create(host_impl_->sync_tree(), 2); | 2513 LayerImpl::Create(host_impl_->sync_tree(), 2); |
| 2500 root_clip->SetBounds(clip_size_); | 2514 root_clip->SetBounds(clip_size_); |
| 2501 root->SetScrollClipLayer(root_clip->id()); | 2515 root->SetScrollClipLayer(root_clip->id()); |
| 2502 root->SetBounds(layer_size_); | 2516 root->SetBounds(layer_size_); |
| 2503 root->SetContentBounds(layer_size_); | 2517 root->SetContentBounds(layer_size_); |
| 2504 root->SetPosition(gfx::PointF()); | 2518 root->SetPosition(gfx::PointF()); |
| 2505 root->SetDrawsContent(false); | 2519 root->SetDrawsContent(false); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2517 host_impl_->sync_tree()->set_top_controls_shrink_blink_size(true); | 2531 host_impl_->sync_tree()->set_top_controls_shrink_blink_size(true); |
| 2518 host_impl_->DidChangeTopControlsPosition(); | 2532 host_impl_->DidChangeTopControlsPosition(); |
| 2519 } | 2533 } |
| 2520 | 2534 |
| 2521 void SetupTopControlsAndScrollLayerWithVirtualViewport( | 2535 void SetupTopControlsAndScrollLayerWithVirtualViewport( |
| 2522 const gfx::Size& inner_viewport_size, | 2536 const gfx::Size& inner_viewport_size, |
| 2523 const gfx::Size& outer_viewport_size, | 2537 const gfx::Size& outer_viewport_size, |
| 2524 const gfx::Size& scroll_layer_size) { | 2538 const gfx::Size& scroll_layer_size) { |
| 2525 CreateHostImpl(settings_, CreateOutputSurface()); | 2539 CreateHostImpl(settings_, CreateOutputSurface()); |
| 2526 host_impl_->sync_tree()->set_top_controls_shrink_blink_size(true); | 2540 host_impl_->sync_tree()->set_top_controls_shrink_blink_size(true); |
| 2541 host_impl_->sync_tree()->set_top_controls_height(top_controls_height_); |
| 2527 host_impl_->DidChangeTopControlsPosition(); | 2542 host_impl_->DidChangeTopControlsPosition(); |
| 2528 | 2543 |
| 2529 scoped_ptr<LayerImpl> root = | 2544 scoped_ptr<LayerImpl> root = |
| 2530 LayerImpl::Create(host_impl_->active_tree(), 1); | 2545 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 2531 scoped_ptr<LayerImpl> root_clip = | 2546 scoped_ptr<LayerImpl> root_clip = |
| 2532 LayerImpl::Create(host_impl_->active_tree(), 2); | 2547 LayerImpl::Create(host_impl_->active_tree(), 2); |
| 2533 scoped_ptr<LayerImpl> page_scale = | 2548 scoped_ptr<LayerImpl> page_scale = |
| 2534 LayerImpl::Create(host_impl_->active_tree(), 3); | 2549 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 2535 | 2550 |
| 2536 scoped_ptr<LayerImpl> outer_scroll = | 2551 scoped_ptr<LayerImpl> outer_scroll = |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2595 // (3) matches the movement of the top controls. | 2610 // (3) matches the movement of the top controls. |
| 2596 gfx::Vector2dF top_controls_scroll_delta(0.f, 5.25f); | 2611 gfx::Vector2dF top_controls_scroll_delta(0.f, 5.25f); |
| 2597 host_impl_->top_controls_manager()->ScrollBegin(); | 2612 host_impl_->top_controls_manager()->ScrollBegin(); |
| 2598 host_impl_->top_controls_manager()->ScrollBy(top_controls_scroll_delta); | 2613 host_impl_->top_controls_manager()->ScrollBy(top_controls_scroll_delta); |
| 2599 host_impl_->top_controls_manager()->ScrollEnd(); | 2614 host_impl_->top_controls_manager()->ScrollEnd(); |
| 2600 | 2615 |
| 2601 LayerImpl* inner_viewport_scroll_layer = | 2616 LayerImpl* inner_viewport_scroll_layer = |
| 2602 host_impl_->active_tree()->InnerViewportScrollLayer(); | 2617 host_impl_->active_tree()->InnerViewportScrollLayer(); |
| 2603 DCHECK(inner_viewport_scroll_layer); | 2618 DCHECK(inner_viewport_scroll_layer); |
| 2604 host_impl_->ScrollEnd(); | 2619 host_impl_->ScrollEnd(); |
| 2605 EXPECT_EQ(top_controls_scroll_delta, | 2620 EXPECT_FLOAT_EQ(top_controls_scroll_delta.y(), |
| 2606 inner_viewport_scroll_layer->FixedContainerSizeDelta()); | 2621 inner_viewport_scroll_layer->FixedContainerSizeDelta().y()); |
| 2607 } | 2622 } |
| 2608 | 2623 |
| 2609 // In this test, the outer viewport is initially unscrollable. We test that a | 2624 // In this test, the outer viewport is initially unscrollable. We test that a |
| 2610 // scroll initiated on the inner viewport, causing the top controls to show and | 2625 // scroll initiated on the inner viewport, causing the top controls to show and |
| 2611 // thus making the outer viewport scrollable, still scrolls the outer viewport. | 2626 // thus making the outer viewport scrollable, still scrolls the outer viewport. |
| 2612 TEST_F(LayerTreeHostImplTopControlsTest, | 2627 TEST_F(LayerTreeHostImplTopControlsTest, |
| 2613 TopControlsOuterViewportBecomesScrollable) { | 2628 TopControlsOuterViewportBecomesScrollable) { |
| 2614 SetupTopControlsAndScrollLayerWithVirtualViewport( | 2629 SetupTopControlsAndScrollLayerWithVirtualViewport( |
| 2615 gfx::Size(10, 50), gfx::Size(10, 50), gfx::Size(10, 100)); | 2630 gfx::Size(10, 50), gfx::Size(10, 50), gfx::Size(10, 100)); |
| 2616 DrawFrame(); | 2631 DrawFrame(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2627 // Need SetDrawsContent so ScrollBegin's hit test finds an actual layer. | 2642 // Need SetDrawsContent so ScrollBegin's hit test finds an actual layer. |
| 2628 outer_scroll->SetDrawsContent(true); | 2643 outer_scroll->SetDrawsContent(true); |
| 2629 host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 1.f, 2.f); | 2644 host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 1.f, 2.f); |
| 2630 | 2645 |
| 2631 EXPECT_EQ(InputHandler::ScrollStarted, | 2646 EXPECT_EQ(InputHandler::ScrollStarted, |
| 2632 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); | 2647 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 2633 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, 50.f)); | 2648 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, 50.f)); |
| 2634 | 2649 |
| 2635 // The entire scroll delta should have been used to hide the top controls. | 2650 // The entire scroll delta should have been used to hide the top controls. |
| 2636 // The viewport layers should be resized back to their full sizes. | 2651 // The viewport layers should be resized back to their full sizes. |
| 2637 EXPECT_EQ(0.f, | 2652 EXPECT_EQ(0.f, host_impl_->active_tree()->CurrentTopControlsShownRatio()); |
| 2638 host_impl_->active_tree()->total_top_controls_content_offset()); | |
| 2639 EXPECT_EQ(0.f, inner_scroll->CurrentScrollOffset().y()); | 2653 EXPECT_EQ(0.f, inner_scroll->CurrentScrollOffset().y()); |
| 2640 EXPECT_EQ(100.f, inner_container->BoundsForScrolling().height()); | 2654 EXPECT_EQ(100.f, inner_container->BoundsForScrolling().height()); |
| 2641 EXPECT_EQ(100.f, outer_container->BoundsForScrolling().height()); | 2655 EXPECT_EQ(100.f, outer_container->BoundsForScrolling().height()); |
| 2642 | 2656 |
| 2643 // The inner viewport should be scrollable by 50px * page_scale. | 2657 // The inner viewport should be scrollable by 50px * page_scale. |
| 2644 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, 100.f)); | 2658 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, 100.f)); |
| 2645 EXPECT_EQ(50.f, inner_scroll->CurrentScrollOffset().y()); | 2659 EXPECT_EQ(50.f, inner_scroll->CurrentScrollOffset().y()); |
| 2646 EXPECT_EQ(0.f, outer_scroll->CurrentScrollOffset().y()); | 2660 EXPECT_EQ(0.f, outer_scroll->CurrentScrollOffset().y()); |
| 2647 EXPECT_EQ(gfx::ScrollOffset(), outer_scroll->MaxScrollOffset()); | 2661 EXPECT_EQ(gfx::ScrollOffset(), outer_scroll->MaxScrollOffset()); |
| 2648 | 2662 |
| 2649 host_impl_->ScrollEnd(); | 2663 host_impl_->ScrollEnd(); |
| 2650 | 2664 |
| 2651 EXPECT_EQ(InputHandler::ScrollStarted, | 2665 EXPECT_EQ(InputHandler::ScrollStarted, |
| 2652 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); | 2666 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 2653 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), inner_scroll); | 2667 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), inner_scroll); |
| 2654 | 2668 |
| 2655 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, -50.f)); | 2669 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, -50.f)); |
| 2656 | 2670 |
| 2657 // The entire scroll delta should have been used to show the top controls. | 2671 // The entire scroll delta should have been used to show the top controls. |
| 2658 // The outer viewport should be resized to accomodate and scrolled to the | 2672 // The outer viewport should be resized to accomodate and scrolled to the |
| 2659 // bottom of the document to keep the viewport in place. | 2673 // bottom of the document to keep the viewport in place. |
| 2660 EXPECT_EQ(50.f, | 2674 EXPECT_EQ(1.f, host_impl_->active_tree()->CurrentTopControlsShownRatio()); |
| 2661 host_impl_->active_tree()->total_top_controls_content_offset()); | |
| 2662 EXPECT_EQ(50.f, outer_container->BoundsForScrolling().height()); | 2675 EXPECT_EQ(50.f, outer_container->BoundsForScrolling().height()); |
| 2663 EXPECT_EQ(50.f, inner_container->BoundsForScrolling().height()); | 2676 EXPECT_EQ(50.f, inner_container->BoundsForScrolling().height()); |
| 2664 EXPECT_EQ(25.f, outer_scroll->CurrentScrollOffset().y()); | 2677 EXPECT_EQ(25.f, outer_scroll->CurrentScrollOffset().y()); |
| 2665 EXPECT_EQ(25.f, inner_scroll->CurrentScrollOffset().y()); | 2678 EXPECT_EQ(25.f, inner_scroll->CurrentScrollOffset().y()); |
| 2666 | 2679 |
| 2667 // Now when we continue scrolling, make sure the outer viewport gets scrolled | 2680 // Now when we continue scrolling, make sure the outer viewport gets scrolled |
| 2668 // since it wasn't scrollable when the scroll began. | 2681 // since it wasn't scrollable when the scroll began. |
| 2669 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, -20.f)); | 2682 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, -20.f)); |
| 2670 EXPECT_EQ(15.f, outer_scroll->CurrentScrollOffset().y()); | 2683 EXPECT_EQ(15.f, outer_scroll->CurrentScrollOffset().y()); |
| 2671 EXPECT_EQ(25.f, inner_scroll->CurrentScrollOffset().y()); | 2684 EXPECT_EQ(25.f, inner_scroll->CurrentScrollOffset().y()); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2697 host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, 1.f, 2.f); | 2710 host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, 1.f, 2.f); |
| 2698 | 2711 |
| 2699 EXPECT_EQ(InputHandler::ScrollStarted, | 2712 EXPECT_EQ(InputHandler::ScrollStarted, |
| 2700 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); | 2713 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 2701 | 2714 |
| 2702 // Scroll down, the top controls hiding should expand the viewport size so | 2715 // Scroll down, the top controls hiding should expand the viewport size so |
| 2703 // the delta should be equal to the scroll distance. | 2716 // the delta should be equal to the scroll distance. |
| 2704 gfx::Vector2dF top_controls_scroll_delta(0.f, 20.f); | 2717 gfx::Vector2dF top_controls_scroll_delta(0.f, 20.f); |
| 2705 host_impl_->top_controls_manager()->ScrollBegin(); | 2718 host_impl_->top_controls_manager()->ScrollBegin(); |
| 2706 host_impl_->top_controls_manager()->ScrollBy(top_controls_scroll_delta); | 2719 host_impl_->top_controls_manager()->ScrollBy(top_controls_scroll_delta); |
| 2707 EXPECT_EQ(top_controls_height_ - top_controls_scroll_delta.y(), | 2720 EXPECT_FLOAT_EQ(top_controls_height_ - top_controls_scroll_delta.y(), |
| 2708 host_impl_->top_controls_manager()->ContentTopOffset()); | 2721 host_impl_->top_controls_manager()->ContentTopOffset()); |
| 2709 EXPECT_VECTOR_EQ(top_controls_scroll_delta, | 2722 EXPECT_VECTOR_EQ(top_controls_scroll_delta, |
| 2710 outer_viewport_scroll_layer->FixedContainerSizeDelta()); | 2723 outer_viewport_scroll_layer->FixedContainerSizeDelta()); |
| 2711 host_impl_->ScrollEnd(); | 2724 host_impl_->ScrollEnd(); |
| 2712 | 2725 |
| 2713 // Scroll past the maximum extent. The delta shouldn't be greater than the | 2726 // Scroll past the maximum extent. The delta shouldn't be greater than the |
| 2714 // top controls height. | 2727 // top controls height. |
| 2715 host_impl_->top_controls_manager()->ScrollBegin(); | 2728 host_impl_->top_controls_manager()->ScrollBegin(); |
| 2716 host_impl_->top_controls_manager()->ScrollBy(top_controls_scroll_delta); | 2729 host_impl_->top_controls_manager()->ScrollBy(top_controls_scroll_delta); |
| 2717 host_impl_->top_controls_manager()->ScrollBy(top_controls_scroll_delta); | 2730 host_impl_->top_controls_manager()->ScrollBy(top_controls_scroll_delta); |
| 2718 host_impl_->top_controls_manager()->ScrollBy(top_controls_scroll_delta); | 2731 host_impl_->top_controls_manager()->ScrollBy(top_controls_scroll_delta); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2735 // Test that if a scrollable sublayer doesn't consume the scroll, | 2748 // Test that if a scrollable sublayer doesn't consume the scroll, |
| 2736 // top controls should hide when scrolling down. | 2749 // top controls should hide when scrolling down. |
| 2737 TEST_F(LayerTreeHostImplTopControlsTest, TopControlsScrollableSublayer) { | 2750 TEST_F(LayerTreeHostImplTopControlsTest, TopControlsScrollableSublayer) { |
| 2738 gfx::Size sub_content_size(100, 400); | 2751 gfx::Size sub_content_size(100, 400); |
| 2739 gfx::Size sub_content_layer_size(100, 300); | 2752 gfx::Size sub_content_layer_size(100, 300); |
| 2740 SetupTopControlsAndScrollLayerWithVirtualViewport( | 2753 SetupTopControlsAndScrollLayerWithVirtualViewport( |
| 2741 gfx::Size(100, 50), gfx::Size(100, 100), gfx::Size(100, 100)); | 2754 gfx::Size(100, 50), gfx::Size(100, 100), gfx::Size(100, 100)); |
| 2742 DrawFrame(); | 2755 DrawFrame(); |
| 2743 | 2756 |
| 2744 // Show top controls | 2757 // Show top controls |
| 2745 EXPECT_EQ(top_controls_height_, | 2758 EXPECT_EQ(1.f, host_impl_->active_tree()->CurrentTopControlsShownRatio()); |
| 2746 host_impl_->active_tree()->total_top_controls_content_offset()); | |
| 2747 | 2759 |
| 2748 LayerImpl* outer_viewport_scroll_layer = | 2760 LayerImpl* outer_viewport_scroll_layer = |
| 2749 host_impl_->active_tree()->OuterViewportScrollLayer(); | 2761 host_impl_->active_tree()->OuterViewportScrollLayer(); |
| 2750 int id = outer_viewport_scroll_layer->id(); | 2762 int id = outer_viewport_scroll_layer->id(); |
| 2751 | 2763 |
| 2752 scoped_ptr<LayerImpl> child = | 2764 scoped_ptr<LayerImpl> child = |
| 2753 LayerImpl::Create(host_impl_->active_tree(), id + 2); | 2765 LayerImpl::Create(host_impl_->active_tree(), id + 2); |
| 2754 scoped_ptr<LayerImpl> child_clip = | 2766 scoped_ptr<LayerImpl> child_clip = |
| 2755 LayerImpl::Create(host_impl_->active_tree(), id + 3); | 2767 LayerImpl::Create(host_impl_->active_tree(), id + 3); |
| 2756 | 2768 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2770 // Scroll 25px to hide top controls | 2782 // Scroll 25px to hide top controls |
| 2771 gfx::Vector2dF scroll_delta(0.f, 25.f); | 2783 gfx::Vector2dF scroll_delta(0.f, 25.f); |
| 2772 EXPECT_EQ(InputHandler::ScrollStarted, | 2784 EXPECT_EQ(InputHandler::ScrollStarted, |
| 2773 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); | 2785 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 2774 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 2786 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 2775 host_impl_->ScrollEnd(); | 2787 host_impl_->ScrollEnd(); |
| 2776 | 2788 |
| 2777 // Top controls should be hidden | 2789 // Top controls should be hidden |
| 2778 EXPECT_EQ(scroll_delta.y(), | 2790 EXPECT_EQ(scroll_delta.y(), |
| 2779 top_controls_height_ - | 2791 top_controls_height_ - |
| 2780 host_impl_->active_tree()->total_top_controls_content_offset()); | 2792 host_impl_->top_controls_manager()->ContentTopOffset()); |
| 2781 } | 2793 } |
| 2782 | 2794 |
| 2783 // Ensure setting the top controls position explicitly using the setters on the | 2795 // Ensure setting the top controls position explicitly using the setters on the |
| 2784 // TreeImpl correctly affects the top controls manager and viewport bounds. | 2796 // TreeImpl correctly affects the top controls manager and viewport bounds. |
| 2785 TEST_F(LayerTreeHostImplTopControlsTest, PositionTopControlsExplicitly) { | 2797 TEST_F(LayerTreeHostImplTopControlsTest, PositionTopControlsExplicitly) { |
| 2786 CreateHostImpl(settings_, CreateOutputSurface()); | 2798 CreateHostImpl(settings_, CreateOutputSurface()); |
| 2787 SetupTopControlsAndScrollLayer(); | 2799 SetupTopControlsAndScrollLayer(); |
| 2788 DrawFrame(); | 2800 DrawFrame(); |
| 2789 | 2801 |
| 2790 host_impl_->active_tree()->set_top_controls_delta(0.f); | 2802 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(0.f); |
| 2791 host_impl_->active_tree()->set_top_controls_content_offset(30.f); | 2803 host_impl_->active_tree()->top_controls_shown_ratio()->PushFromMainThread( |
| 2792 EXPECT_EQ(30.f, host_impl_->top_controls_manager()->ContentTopOffset()); | 2804 30.f / top_controls_height_); |
| 2793 EXPECT_EQ(-20.f, host_impl_->top_controls_manager()->ControlsTopOffset()); | 2805 host_impl_->active_tree()->top_controls_shown_ratio()->PushPendingToActive(); |
| 2806 EXPECT_FLOAT_EQ(30.f, host_impl_->top_controls_manager()->ContentTopOffset()); |
| 2807 EXPECT_FLOAT_EQ(-20.f, |
| 2808 host_impl_->top_controls_manager()->ControlsTopOffset()); |
| 2794 | 2809 |
| 2795 host_impl_->active_tree()->set_top_controls_delta(-30.f); | 2810 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(0.f); |
| 2796 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); | 2811 EXPECT_FLOAT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); |
| 2797 EXPECT_EQ(-50.f, host_impl_->top_controls_manager()->ControlsTopOffset()); | 2812 EXPECT_FLOAT_EQ(-50.f, |
| 2813 host_impl_->top_controls_manager()->ControlsTopOffset()); |
| 2798 | 2814 |
| 2799 host_impl_->DidChangeTopControlsPosition(); | 2815 host_impl_->DidChangeTopControlsPosition(); |
| 2800 | 2816 |
| 2801 // Now that top controls have moved, expect the clip to resize. | 2817 // Now that top controls have moved, expect the clip to resize. |
| 2802 LayerImpl* root_clip_ptr = host_impl_->active_tree()->root_layer(); | 2818 LayerImpl* root_clip_ptr = host_impl_->active_tree()->root_layer(); |
| 2803 EXPECT_EQ(viewport_size_, root_clip_ptr->bounds()); | 2819 EXPECT_EQ(viewport_size_, root_clip_ptr->bounds()); |
| 2804 } | 2820 } |
| 2805 | 2821 |
| 2806 // Test that the top_controls delta and sent delta are appropriately | 2822 // Test that the top_controls delta and sent delta are appropriately |
| 2807 // applied on sync tree activation. The total top controls offset shouldn't | 2823 // applied on sync tree activation. The total top controls offset shouldn't |
| 2808 // change after the activation. | 2824 // change after the activation. |
| 2809 TEST_F(LayerTreeHostImplTopControlsTest, ApplyDeltaOnTreeActivation) { | 2825 TEST_F(LayerTreeHostImplTopControlsTest, ApplyDeltaOnTreeActivation) { |
| 2810 CreateHostImpl(settings_, CreateOutputSurface()); | 2826 CreateHostImpl(settings_, CreateOutputSurface()); |
| 2811 SetupTopControlsAndScrollLayer(); | 2827 SetupTopControlsAndScrollLayer(); |
| 2812 DrawFrame(); | 2828 DrawFrame(); |
| 2813 | 2829 |
| 2814 host_impl_->sync_tree()->set_top_controls_content_offset(15.f); | 2830 host_impl_->active_tree()->top_controls_shown_ratio()->PushFromMainThread( |
| 2815 | 2831 20.f / top_controls_height_); |
| 2816 host_impl_->active_tree()->set_top_controls_content_offset(20.f); | 2832 host_impl_->active_tree()->top_controls_shown_ratio()->PushPendingToActive(); |
| 2817 host_impl_->active_tree()->set_top_controls_delta(-20.f); | 2833 host_impl_->active_tree()->SetCurrentTopControlsShownRatio( |
| 2818 host_impl_->active_tree()->set_sent_top_controls_delta(-5.f); | 2834 15.f / top_controls_height_); |
| 2835 host_impl_->active_tree() |
| 2836 ->top_controls_shown_ratio() |
| 2837 ->PullDeltaForMainThread(); |
| 2838 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(0.f); |
| 2839 host_impl_->sync_tree()->PushTopControlsFromMainThread(15.f / |
| 2840 top_controls_height_); |
| 2819 | 2841 |
| 2820 host_impl_->DidChangeTopControlsPosition(); | 2842 host_impl_->DidChangeTopControlsPosition(); |
| 2821 LayerImpl* root_clip_ptr = host_impl_->active_tree()->root_layer(); | 2843 LayerImpl* root_clip_ptr = host_impl_->active_tree()->root_layer(); |
| 2822 EXPECT_EQ(viewport_size_, root_clip_ptr->bounds()); | 2844 EXPECT_EQ(viewport_size_, root_clip_ptr->bounds()); |
| 2823 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); | 2845 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); |
| 2824 EXPECT_EQ(0.f, | |
| 2825 host_impl_->active_tree()->total_top_controls_content_offset()); | |
| 2826 | 2846 |
| 2827 host_impl_->ActivateSyncTree(); | 2847 host_impl_->ActivateSyncTree(); |
| 2828 | 2848 |
| 2829 root_clip_ptr = host_impl_->active_tree()->root_layer(); | 2849 root_clip_ptr = host_impl_->active_tree()->root_layer(); |
| 2830 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); | 2850 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); |
| 2831 EXPECT_EQ(viewport_size_, root_clip_ptr->bounds()); | 2851 EXPECT_EQ(viewport_size_, root_clip_ptr->bounds()); |
| 2832 | 2852 |
| 2833 EXPECT_EQ(0.f, host_impl_->active_tree()->sent_top_controls_delta()); | 2853 EXPECT_FLOAT_EQ( |
| 2834 EXPECT_EQ(-15.f, host_impl_->active_tree()->top_controls_delta()); | 2854 -15.f, host_impl_->active_tree()->top_controls_shown_ratio()->Delta() * |
| 2835 EXPECT_EQ(15.f, host_impl_->active_tree()->top_controls_content_offset()); | 2855 top_controls_height_); |
| 2836 EXPECT_EQ(0.f, | 2856 EXPECT_FLOAT_EQ( |
| 2837 host_impl_->active_tree()->total_top_controls_content_offset()); | 2857 15.f, |
| 2858 host_impl_->active_tree()->top_controls_shown_ratio()->ActiveBase() * |
| 2859 top_controls_height_); |
| 2838 } | 2860 } |
| 2839 | 2861 |
| 2840 // Test that changing the top controls layout height is correctly applied to | 2862 // Test that changing the top controls layout height is correctly applied to |
| 2841 // the inner viewport container bounds. That is, the top controls layout | 2863 // the inner viewport container bounds. That is, the top controls layout |
| 2842 // height is the amount that the inner viewport container was shrunk outside | 2864 // height is the amount that the inner viewport container was shrunk outside |
| 2843 // the compositor to accommodate the top controls. | 2865 // the compositor to accommodate the top controls. |
| 2844 TEST_F(LayerTreeHostImplTopControlsTest, TopControlsLayoutHeightChanged) { | 2866 TEST_F(LayerTreeHostImplTopControlsTest, TopControlsLayoutHeightChanged) { |
| 2845 CreateHostImpl(settings_, CreateOutputSurface()); | 2867 CreateHostImpl(settings_, CreateOutputSurface()); |
| 2846 SetupTopControlsAndScrollLayer(); | 2868 SetupTopControlsAndScrollLayer(); |
| 2847 DrawFrame(); | 2869 DrawFrame(); |
| 2848 | 2870 |
| 2849 host_impl_->sync_tree()->set_top_controls_content_offset(50.f); | 2871 host_impl_->sync_tree()->PushTopControlsFromMainThread(1.f); |
| 2850 host_impl_->sync_tree()->set_top_controls_shrink_blink_size(true); | 2872 host_impl_->sync_tree()->set_top_controls_shrink_blink_size(true); |
| 2851 | 2873 |
| 2852 host_impl_->active_tree()->set_top_controls_content_offset(50.f); | 2874 host_impl_->active_tree()->top_controls_shown_ratio()->PushFromMainThread( |
| 2853 host_impl_->active_tree()->set_top_controls_delta(-50.f); | 2875 1.f); |
| 2876 host_impl_->active_tree()->top_controls_shown_ratio()->PushPendingToActive(); |
| 2877 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(0.f); |
| 2854 | 2878 |
| 2855 host_impl_->DidChangeTopControlsPosition(); | 2879 host_impl_->DidChangeTopControlsPosition(); |
| 2856 LayerImpl* root_clip_ptr = host_impl_->active_tree()->root_layer(); | 2880 LayerImpl* root_clip_ptr = host_impl_->active_tree()->root_layer(); |
| 2857 EXPECT_EQ(viewport_size_, root_clip_ptr->bounds()); | 2881 EXPECT_EQ(viewport_size_, root_clip_ptr->bounds()); |
| 2858 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); | 2882 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); |
| 2859 | 2883 |
| 2860 host_impl_->sync_tree()->root_layer()->SetBounds( | 2884 host_impl_->sync_tree()->root_layer()->SetBounds( |
| 2861 gfx::Size(root_clip_ptr->bounds().width(), | 2885 gfx::Size(root_clip_ptr->bounds().width(), |
| 2862 root_clip_ptr->bounds().height() - 50.f)); | 2886 root_clip_ptr->bounds().height() - 50.f)); |
| 2863 | 2887 |
| 2864 host_impl_->ActivateSyncTree(); | 2888 host_impl_->ActivateSyncTree(); |
| 2865 | 2889 |
| 2866 root_clip_ptr = host_impl_->active_tree()->root_layer(); | 2890 root_clip_ptr = host_impl_->active_tree()->root_layer(); |
| 2867 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); | 2891 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); |
| 2868 | 2892 |
| 2869 // The total bounds should remain unchanged since the bounds delta should | 2893 // The total bounds should remain unchanged since the bounds delta should |
| 2870 // account for the difference between the layout height and the current | 2894 // account for the difference between the layout height and the current |
| 2871 // top controls offset. | 2895 // top controls offset. |
| 2872 EXPECT_EQ(viewport_size_, root_clip_ptr->bounds()); | 2896 EXPECT_EQ(viewport_size_, root_clip_ptr->bounds()); |
| 2873 EXPECT_VECTOR_EQ(gfx::Vector2dF(0.f, 50.f), root_clip_ptr->bounds_delta()); | 2897 EXPECT_VECTOR_EQ(gfx::Vector2dF(0.f, 50.f), root_clip_ptr->bounds_delta()); |
| 2874 | 2898 |
| 2875 host_impl_->active_tree()->set_top_controls_delta(0.f); | 2899 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(1.f); |
| 2876 host_impl_->DidChangeTopControlsPosition(); | 2900 host_impl_->DidChangeTopControlsPosition(); |
| 2877 | 2901 |
| 2902 EXPECT_EQ(1.f, host_impl_->top_controls_manager()->TopControlsShownRatio()); |
| 2903 EXPECT_EQ(50.f, host_impl_->top_controls_manager()->TopControlsHeight()); |
| 2878 EXPECT_EQ(50.f, host_impl_->top_controls_manager()->ContentTopOffset()); | 2904 EXPECT_EQ(50.f, host_impl_->top_controls_manager()->ContentTopOffset()); |
| 2879 EXPECT_VECTOR_EQ(gfx::Vector2dF(0.f, 0.f), root_clip_ptr->bounds_delta()); | 2905 EXPECT_VECTOR_EQ(gfx::Vector2dF(0.f, 0.f), root_clip_ptr->bounds_delta()); |
| 2880 EXPECT_EQ(gfx::Size(viewport_size_.width(), viewport_size_.height() - 50.f), | 2906 EXPECT_EQ(gfx::Size(viewport_size_.width(), viewport_size_.height() - 50.f), |
| 2881 root_clip_ptr->bounds()); | 2907 root_clip_ptr->bounds()); |
| 2882 } | 2908 } |
| 2883 | 2909 |
| 2884 // Test that showing/hiding the top controls when the viewport is fully scrolled | 2910 // Test that showing/hiding the top controls when the viewport is fully scrolled |
| 2885 // doesn't incorrectly change the viewport offset due to clamping from changing | 2911 // doesn't incorrectly change the viewport offset due to clamping from changing |
| 2886 // viewport bounds. | 2912 // viewport bounds. |
| 2887 TEST_F(LayerTreeHostImplTopControlsTest, TopControlsViewportOffsetClamping) { | 2913 TEST_F(LayerTreeHostImplTopControlsTest, TopControlsViewportOffsetClamping) { |
| 2888 SetupTopControlsAndScrollLayerWithVirtualViewport( | 2914 SetupTopControlsAndScrollLayerWithVirtualViewport( |
| 2889 gfx::Size(100, 100), gfx::Size(200, 200), gfx::Size(200, 400)); | 2915 gfx::Size(100, 100), gfx::Size(200, 200), gfx::Size(200, 400)); |
| 2890 DrawFrame(); | 2916 DrawFrame(); |
| 2891 | 2917 |
| 2892 EXPECT_EQ(top_controls_height_, | 2918 EXPECT_EQ(1.f, host_impl_->active_tree()->CurrentTopControlsShownRatio()); |
| 2893 host_impl_->active_tree()->total_top_controls_content_offset()); | |
| 2894 | 2919 |
| 2895 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); | 2920 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); |
| 2896 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); | 2921 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); |
| 2897 | 2922 |
| 2898 // Scroll the viewports to max scroll offset. | 2923 // Scroll the viewports to max scroll offset. |
| 2899 outer_scroll->SetScrollDelta(gfx::Vector2dF(0, 200.f)); | 2924 outer_scroll->SetScrollDelta(gfx::Vector2dF(0, 200.f)); |
| 2900 inner_scroll->SetScrollDelta(gfx::Vector2dF(100, 100.f)); | 2925 inner_scroll->SetScrollDelta(gfx::Vector2dF(100, 100.f)); |
| 2901 | 2926 |
| 2902 gfx::ScrollOffset viewport_offset = | 2927 gfx::ScrollOffset viewport_offset = |
| 2903 host_impl_->active_tree()->TotalScrollOffset(); | 2928 host_impl_->active_tree()->TotalScrollOffset(); |
| 2904 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(), viewport_offset); | 2929 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(), viewport_offset); |
| 2905 | 2930 |
| 2906 // Hide the top controls by 25px. | 2931 // Hide the top controls by 25px. |
| 2907 gfx::Vector2dF scroll_delta(0.f, 25.f); | 2932 gfx::Vector2dF scroll_delta(0.f, 25.f); |
| 2908 EXPECT_EQ(InputHandler::ScrollStarted, | 2933 EXPECT_EQ(InputHandler::ScrollStarted, |
| 2909 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); | 2934 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 2910 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 2935 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 2911 | 2936 |
| 2912 // scrolling down at the max extents no longer hides the top controls | 2937 // scrolling down at the max extents no longer hides the top controls |
| 2913 EXPECT_EQ(0.f, | 2938 EXPECT_EQ(1.f, host_impl_->active_tree()->CurrentTopControlsShownRatio()); |
| 2914 top_controls_height_ - | |
| 2915 host_impl_->active_tree()->total_top_controls_content_offset()); | |
| 2916 | 2939 |
| 2917 // forcefully hide the top controls by 25px | 2940 // forcefully hide the top controls by 25px |
| 2918 host_impl_->top_controls_manager()->ScrollBy(scroll_delta); | 2941 host_impl_->top_controls_manager()->ScrollBy(scroll_delta); |
| 2919 host_impl_->ScrollEnd(); | 2942 host_impl_->ScrollEnd(); |
| 2920 | 2943 |
| 2921 EXPECT_EQ(scroll_delta.y(), | 2944 EXPECT_FLOAT_EQ(scroll_delta.y(), |
| 2922 top_controls_height_ - | 2945 top_controls_height_ - |
| 2923 host_impl_->active_tree()->total_top_controls_content_offset()); | 2946 host_impl_->top_controls_manager()->ContentTopOffset()); |
| 2924 | 2947 |
| 2925 inner_scroll->ClampScrollToMaxScrollOffset(); | 2948 inner_scroll->ClampScrollToMaxScrollOffset(); |
| 2926 outer_scroll->ClampScrollToMaxScrollOffset(); | 2949 outer_scroll->ClampScrollToMaxScrollOffset(); |
| 2927 | 2950 |
| 2928 // We should still be fully scrolled. | 2951 // We should still be fully scrolled. |
| 2929 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(), | 2952 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(), |
| 2930 host_impl_->active_tree()->TotalScrollOffset()); | 2953 host_impl_->active_tree()->TotalScrollOffset()); |
| 2931 | 2954 |
| 2932 viewport_offset = host_impl_->active_tree()->TotalScrollOffset(); | 2955 viewport_offset = host_impl_->active_tree()->TotalScrollOffset(); |
| 2933 | 2956 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2949 host_impl_->active_tree()->TotalScrollOffset()); | 2972 host_impl_->active_tree()->TotalScrollOffset()); |
| 2950 } | 2973 } |
| 2951 | 2974 |
| 2952 // Test that the top controls coming in and out maintains the same aspect ratio | 2975 // Test that the top controls coming in and out maintains the same aspect ratio |
| 2953 // between the inner and outer viewports. | 2976 // between the inner and outer viewports. |
| 2954 TEST_F(LayerTreeHostImplTopControlsTest, TopControlsAspectRatio) { | 2977 TEST_F(LayerTreeHostImplTopControlsTest, TopControlsAspectRatio) { |
| 2955 SetupTopControlsAndScrollLayerWithVirtualViewport( | 2978 SetupTopControlsAndScrollLayerWithVirtualViewport( |
| 2956 gfx::Size(100, 100), gfx::Size(200, 200), gfx::Size(200, 400)); | 2979 gfx::Size(100, 100), gfx::Size(200, 200), gfx::Size(200, 400)); |
| 2957 DrawFrame(); | 2980 DrawFrame(); |
| 2958 | 2981 |
| 2959 EXPECT_EQ(top_controls_height_, | 2982 EXPECT_FLOAT_EQ(top_controls_height_, |
| 2960 host_impl_->active_tree()->total_top_controls_content_offset()); | 2983 host_impl_->top_controls_manager()->ContentTopOffset()); |
| 2961 | 2984 |
| 2962 gfx::Vector2dF scroll_delta(0.f, 25.f); | 2985 gfx::Vector2dF scroll_delta(0.f, 25.f); |
| 2963 EXPECT_EQ(InputHandler::ScrollStarted, | 2986 EXPECT_EQ(InputHandler::ScrollStarted, |
| 2964 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); | 2987 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 2965 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 2988 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 2966 host_impl_->ScrollEnd(); | 2989 host_impl_->ScrollEnd(); |
| 2967 | 2990 |
| 2968 EXPECT_EQ(scroll_delta.y(), | 2991 EXPECT_FLOAT_EQ(scroll_delta.y(), |
| 2969 top_controls_height_ - | 2992 top_controls_height_ - |
| 2970 host_impl_->active_tree()->total_top_controls_content_offset()); | 2993 host_impl_->top_controls_manager()->ContentTopOffset()); |
| 2971 | 2994 |
| 2972 // Top controls were hidden by 25px so the inner viewport should have expanded | 2995 // Top controls were hidden by 25px so the inner viewport should have expanded |
| 2973 // by that much. | 2996 // by that much. |
| 2974 LayerImpl* outer_container = | 2997 LayerImpl* outer_container = |
| 2975 host_impl_->active_tree()->OuterViewportContainerLayer(); | 2998 host_impl_->active_tree()->OuterViewportContainerLayer(); |
| 2976 LayerImpl* inner_container = | 2999 LayerImpl* inner_container = |
| 2977 host_impl_->active_tree()->InnerViewportContainerLayer(); | 3000 host_impl_->active_tree()->InnerViewportContainerLayer(); |
| 2978 EXPECT_EQ(gfx::Size(100, 100+25), inner_container->BoundsForScrolling()); | 3001 EXPECT_EQ(gfx::Size(100, 100+25), inner_container->BoundsForScrolling()); |
| 2979 | 3002 |
| 2980 // Outer viewport should match inner's aspect ratio. The bounds are ceiled. | 3003 // Outer viewport should match inner's aspect ratio. The bounds are ceiled. |
| 2981 float aspect_ratio = inner_container->BoundsForScrolling().width() / | 3004 float aspect_ratio = inner_container->BoundsForScrolling().width() / |
| 2982 inner_container->BoundsForScrolling().height(); | 3005 inner_container->BoundsForScrolling().height(); |
| 2983 gfx::Size expected = gfx::ToCeiledSize(gfx::SizeF(200, 200 / aspect_ratio)); | 3006 gfx::Size expected = gfx::ToCeiledSize(gfx::SizeF(200, 200 / aspect_ratio)); |
| 2984 EXPECT_EQ(expected, outer_container->BoundsForScrolling()); | 3007 EXPECT_EQ(expected, outer_container->BoundsForScrolling()); |
| 2985 EXPECT_EQ(expected, | 3008 EXPECT_EQ(expected, |
| 2986 host_impl_->InnerViewportScrollLayer()->BoundsForScrolling()); | 3009 host_impl_->InnerViewportScrollLayer()->BoundsForScrolling()); |
| 2987 } | 3010 } |
| 2988 | 3011 |
| 2989 // Test that scrolling the outer viewport affects the top controls. | 3012 // Test that scrolling the outer viewport affects the top controls. |
| 2990 TEST_F(LayerTreeHostImplTopControlsTest, TopControlsScrollOuterViewport) { | 3013 TEST_F(LayerTreeHostImplTopControlsTest, TopControlsScrollOuterViewport) { |
| 2991 SetupTopControlsAndScrollLayerWithVirtualViewport( | 3014 SetupTopControlsAndScrollLayerWithVirtualViewport( |
| 2992 gfx::Size(100, 100), gfx::Size(200, 200), gfx::Size(200, 400)); | 3015 gfx::Size(100, 100), gfx::Size(200, 200), gfx::Size(200, 400)); |
| 2993 DrawFrame(); | 3016 DrawFrame(); |
| 2994 | 3017 |
| 2995 EXPECT_EQ(top_controls_height_, | 3018 EXPECT_EQ(top_controls_height_, |
| 2996 host_impl_->active_tree()->total_top_controls_content_offset()); | 3019 host_impl_->top_controls_manager()->ContentTopOffset()); |
| 2997 | 3020 |
| 2998 // Send a gesture scroll that will scroll the outer viewport, make sure the | 3021 // Send a gesture scroll that will scroll the outer viewport, make sure the |
| 2999 // top controls get scrolled. | 3022 // top controls get scrolled. |
| 3000 gfx::Vector2dF scroll_delta(0.f, 15.f); | 3023 gfx::Vector2dF scroll_delta(0.f, 15.f); |
| 3001 EXPECT_EQ(InputHandler::ScrollStarted, | 3024 EXPECT_EQ(InputHandler::ScrollStarted, |
| 3002 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); | 3025 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 3003 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 3026 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 3004 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), | 3027 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), |
| 3005 host_impl_->CurrentlyScrollingLayer()); | 3028 host_impl_->CurrentlyScrollingLayer()); |
| 3006 host_impl_->ScrollEnd(); | 3029 host_impl_->ScrollEnd(); |
| 3007 | 3030 |
| 3008 EXPECT_EQ(scroll_delta.y(), | 3031 EXPECT_FLOAT_EQ(scroll_delta.y(), |
| 3009 top_controls_height_ - | 3032 top_controls_height_ - |
| 3010 host_impl_->active_tree()->total_top_controls_content_offset()); | 3033 host_impl_->top_controls_manager()->ContentTopOffset()); |
| 3011 | 3034 |
| 3012 scroll_delta = gfx::Vector2dF(0.f, 50.f); | 3035 scroll_delta = gfx::Vector2dF(0.f, 50.f); |
| 3013 EXPECT_EQ(InputHandler::ScrollStarted, | 3036 EXPECT_EQ(InputHandler::ScrollStarted, |
| 3014 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); | 3037 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 3015 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 3038 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 3016 | 3039 |
| 3017 EXPECT_EQ(0, host_impl_->active_tree()->total_top_controls_content_offset()); | 3040 EXPECT_EQ(0, host_impl_->top_controls_manager()->ContentTopOffset()); |
| 3018 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), | 3041 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), |
| 3019 host_impl_->CurrentlyScrollingLayer()); | 3042 host_impl_->CurrentlyScrollingLayer()); |
| 3020 | 3043 |
| 3021 host_impl_->ScrollEnd(); | 3044 host_impl_->ScrollEnd(); |
| 3022 | 3045 |
| 3023 // Position the viewports such that the inner viewport will be scrolled. | 3046 // Position the viewports such that the inner viewport will be scrolled. |
| 3024 gfx::Vector2dF inner_viewport_offset(0.f, 25.f); | 3047 gfx::Vector2dF inner_viewport_offset(0.f, 25.f); |
| 3025 host_impl_->OuterViewportScrollLayer()->SetScrollDelta(gfx::Vector2dF()); | 3048 host_impl_->OuterViewportScrollLayer()->SetScrollDelta(gfx::Vector2dF()); |
| 3026 host_impl_->InnerViewportScrollLayer()->SetScrollDelta(inner_viewport_offset); | 3049 host_impl_->InnerViewportScrollLayer()->SetScrollDelta(inner_viewport_offset); |
| 3027 | 3050 |
| 3028 scroll_delta = gfx::Vector2dF(0.f, -65.f); | 3051 scroll_delta = gfx::Vector2dF(0.f, -65.f); |
| 3029 EXPECT_EQ(InputHandler::ScrollStarted, | 3052 EXPECT_EQ(InputHandler::ScrollStarted, |
| 3030 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); | 3053 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 3031 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 3054 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 3032 | 3055 |
| 3033 EXPECT_EQ(top_controls_height_, | 3056 EXPECT_EQ(top_controls_height_, |
| 3034 host_impl_->active_tree()->total_top_controls_content_offset()); | 3057 host_impl_->top_controls_manager()->ContentTopOffset()); |
| 3035 EXPECT_EQ( | 3058 EXPECT_FLOAT_EQ( |
| 3036 inner_viewport_offset.y() + (scroll_delta.y() + top_controls_height_), | 3059 inner_viewport_offset.y() + (scroll_delta.y() + top_controls_height_), |
| 3037 host_impl_->InnerViewportScrollLayer()->ScrollDelta().y()); | 3060 host_impl_->InnerViewportScrollLayer()->ScrollDelta().y()); |
| 3038 | 3061 |
| 3039 host_impl_->ScrollEnd(); | 3062 host_impl_->ScrollEnd(); |
| 3040 } | 3063 } |
| 3041 | 3064 |
| 3042 TEST_F(LayerTreeHostImplTopControlsTest, | 3065 TEST_F(LayerTreeHostImplTopControlsTest, |
| 3043 ScrollNonScrollableRootWithTopControls) { | 3066 ScrollNonScrollableRootWithTopControls) { |
| 3044 CreateHostImpl(settings_, CreateOutputSurface()); | 3067 CreateHostImpl(settings_, CreateOutputSurface()); |
| 3045 SetupTopControlsAndScrollLayer(); | 3068 SetupTopControlsAndScrollLayer(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 3058 | 3081 |
| 3059 host_impl_->ScrollEnd(); | 3082 host_impl_->ScrollEnd(); |
| 3060 | 3083 |
| 3061 EXPECT_EQ(InputHandler::ScrollStarted, | 3084 EXPECT_EQ(InputHandler::ScrollStarted, |
| 3062 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); | 3085 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 3063 | 3086 |
| 3064 float scroll_increment_y = -25.f; | 3087 float scroll_increment_y = -25.f; |
| 3065 host_impl_->top_controls_manager()->ScrollBegin(); | 3088 host_impl_->top_controls_manager()->ScrollBegin(); |
| 3066 host_impl_->top_controls_manager()->ScrollBy( | 3089 host_impl_->top_controls_manager()->ScrollBy( |
| 3067 gfx::Vector2dF(0.f, scroll_increment_y)); | 3090 gfx::Vector2dF(0.f, scroll_increment_y)); |
| 3068 EXPECT_EQ(-scroll_increment_y, | 3091 EXPECT_FLOAT_EQ(-scroll_increment_y, |
| 3069 host_impl_->top_controls_manager()->ContentTopOffset()); | 3092 host_impl_->top_controls_manager()->ContentTopOffset()); |
| 3070 // Now that top controls have moved, expect the clip to resize. | 3093 // Now that top controls have moved, expect the clip to resize. |
| 3071 EXPECT_EQ(gfx::Size(viewport_size_.width(), | 3094 EXPECT_EQ(gfx::Size(viewport_size_.width(), |
| 3072 viewport_size_.height() + scroll_increment_y), | 3095 viewport_size_.height() + scroll_increment_y), |
| 3073 root_clip_ptr->bounds()); | 3096 root_clip_ptr->bounds()); |
| 3074 | 3097 |
| 3075 host_impl_->top_controls_manager()->ScrollBy( | 3098 host_impl_->top_controls_manager()->ScrollBy( |
| 3076 gfx::Vector2dF(0.f, scroll_increment_y)); | 3099 gfx::Vector2dF(0.f, scroll_increment_y)); |
| 3077 host_impl_->top_controls_manager()->ScrollEnd(); | 3100 host_impl_->top_controls_manager()->ScrollEnd(); |
| 3078 EXPECT_EQ(-2 * scroll_increment_y, | 3101 EXPECT_FLOAT_EQ(-2 * scroll_increment_y, |
| 3079 host_impl_->top_controls_manager()->ContentTopOffset()); | 3102 host_impl_->top_controls_manager()->ContentTopOffset()); |
| 3080 // Now that top controls have moved, expect the clip to resize. | 3103 // Now that top controls have moved, expect the clip to resize. |
| 3081 EXPECT_EQ(clip_size_, root_clip_ptr->bounds()); | 3104 EXPECT_EQ(clip_size_, root_clip_ptr->bounds()); |
| 3082 | 3105 |
| 3083 host_impl_->ScrollEnd(); | 3106 host_impl_->ScrollEnd(); |
| 3084 | 3107 |
| 3085 // Verify the layer is once-again non-scrollable. | 3108 // Verify the layer is once-again non-scrollable. |
| 3086 EXPECT_EQ( | 3109 EXPECT_EQ( |
| 3087 gfx::ScrollOffset(), | 3110 gfx::ScrollOffset(), |
| 3088 host_impl_->active_tree()->InnerViewportScrollLayer()->MaxScrollOffset()); | 3111 host_impl_->active_tree()->InnerViewportScrollLayer()->MaxScrollOffset()); |
| 3089 | 3112 |
| (...skipping 1316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4406 class BlendStateCheckLayer : public LayerImpl { | 4429 class BlendStateCheckLayer : public LayerImpl { |
| 4407 public: | 4430 public: |
| 4408 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, | 4431 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, |
| 4409 int id, | 4432 int id, |
| 4410 ResourceProvider* resource_provider) { | 4433 ResourceProvider* resource_provider) { |
| 4411 return make_scoped_ptr( | 4434 return make_scoped_ptr( |
| 4412 new BlendStateCheckLayer(tree_impl, id, resource_provider)); | 4435 new BlendStateCheckLayer(tree_impl, id, resource_provider)); |
| 4413 } | 4436 } |
| 4414 | 4437 |
| 4415 void AppendQuads(RenderPass* render_pass, | 4438 void AppendQuads(RenderPass* render_pass, |
| 4416 const Occlusion& occlusion_in_content_space, | |
| 4417 AppendQuadsData* append_quads_data) override { | 4439 AppendQuadsData* append_quads_data) override { |
| 4418 quads_appended_ = true; | 4440 quads_appended_ = true; |
| 4419 | 4441 |
| 4420 gfx::Rect opaque_rect; | 4442 gfx::Rect opaque_rect; |
| 4421 if (contents_opaque()) | 4443 if (contents_opaque()) |
| 4422 opaque_rect = quad_rect_; | 4444 opaque_rect = quad_rect_; |
| 4423 else | 4445 else |
| 4424 opaque_rect = opaque_content_rect_; | 4446 opaque_rect = opaque_content_rect_; |
| 4425 gfx::Rect visible_quad_rect = quad_rect_; | 4447 gfx::Rect visible_quad_rect = quad_rect_; |
| 4426 | 4448 |
| (...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5131 host_impl_->DidDrawAllLayers(frame); | 5153 host_impl_->DidDrawAllLayers(frame); |
| 5132 } | 5154 } |
| 5133 | 5155 |
| 5134 class FakeLayerWithQuads : public LayerImpl { | 5156 class FakeLayerWithQuads : public LayerImpl { |
| 5135 public: | 5157 public: |
| 5136 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { | 5158 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { |
| 5137 return make_scoped_ptr(new FakeLayerWithQuads(tree_impl, id)); | 5159 return make_scoped_ptr(new FakeLayerWithQuads(tree_impl, id)); |
| 5138 } | 5160 } |
| 5139 | 5161 |
| 5140 void AppendQuads(RenderPass* render_pass, | 5162 void AppendQuads(RenderPass* render_pass, |
| 5141 const Occlusion& occlusion_in_content_space, | |
| 5142 AppendQuadsData* append_quads_data) override { | 5163 AppendQuadsData* append_quads_data) override { |
| 5143 SharedQuadState* shared_quad_state = | 5164 SharedQuadState* shared_quad_state = |
| 5144 render_pass->CreateAndAppendSharedQuadState(); | 5165 render_pass->CreateAndAppendSharedQuadState(); |
| 5145 PopulateSharedQuadState(shared_quad_state); | 5166 PopulateSharedQuadState(shared_quad_state); |
| 5146 | 5167 |
| 5147 SkColor gray = SkColorSetRGB(100, 100, 100); | 5168 SkColor gray = SkColorSetRGB(100, 100, 100); |
| 5148 gfx::Rect quad_rect(content_bounds()); | 5169 gfx::Rect quad_rect(content_bounds()); |
| 5149 gfx::Rect visible_quad_rect(quad_rect); | 5170 gfx::Rect visible_quad_rect(quad_rect); |
| 5150 SolidColorDrawQuad* my_quad = | 5171 SolidColorDrawQuad* my_quad = |
| 5151 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 5172 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
| (...skipping 1433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6585 | 6606 |
| 6586 | 6607 |
| 6587 TEST_F(LayerTreeHostImplTestDeferredInitialize, Success) { | 6608 TEST_F(LayerTreeHostImplTestDeferredInitialize, Success) { |
| 6588 // Software draw. | 6609 // Software draw. |
| 6589 DrawFrame(); | 6610 DrawFrame(); |
| 6590 | 6611 |
| 6591 EXPECT_FALSE(host_impl_->output_surface()->context_provider()); | 6612 EXPECT_FALSE(host_impl_->output_surface()->context_provider()); |
| 6592 | 6613 |
| 6593 // DeferredInitialize and hardware draw. | 6614 // DeferredInitialize and hardware draw. |
| 6594 did_update_renderer_capabilities_ = false; | 6615 did_update_renderer_capabilities_ = false; |
| 6595 EXPECT_TRUE( | 6616 EXPECT_TRUE(output_surface_->InitializeAndSetContext3d( |
| 6596 output_surface_->InitializeAndSetContext3d(onscreen_context_provider_)); | 6617 onscreen_context_provider_, nullptr)); |
| 6597 EXPECT_EQ(onscreen_context_provider_.get(), | 6618 EXPECT_EQ(onscreen_context_provider_.get(), |
| 6598 host_impl_->output_surface()->context_provider()); | 6619 host_impl_->output_surface()->context_provider()); |
| 6599 EXPECT_TRUE(did_update_renderer_capabilities_); | 6620 EXPECT_TRUE(did_update_renderer_capabilities_); |
| 6600 | 6621 |
| 6601 // Defer intialized GL draw. | 6622 // Defer intialized GL draw. |
| 6602 DrawFrame(); | 6623 DrawFrame(); |
| 6603 | 6624 |
| 6604 // Revert back to software. | 6625 // Revert back to software. |
| 6605 did_update_renderer_capabilities_ = false; | 6626 did_update_renderer_capabilities_ = false; |
| 6606 output_surface_->ReleaseGL(); | 6627 output_surface_->ReleaseGL(); |
| 6607 EXPECT_FALSE(host_impl_->output_surface()->context_provider()); | 6628 EXPECT_FALSE(host_impl_->output_surface()->context_provider()); |
| 6608 EXPECT_TRUE(did_update_renderer_capabilities_); | 6629 EXPECT_TRUE(did_update_renderer_capabilities_); |
| 6609 | 6630 |
| 6610 // Software draw again. | 6631 // Software draw again. |
| 6611 DrawFrame(); | 6632 DrawFrame(); |
| 6612 } | 6633 } |
| 6613 | 6634 |
| 6614 TEST_F(LayerTreeHostImplTestDeferredInitialize, Fails) { | 6635 TEST_F(LayerTreeHostImplTestDeferredInitialize, Fails) { |
| 6615 // Software draw. | 6636 // Software draw. |
| 6616 DrawFrame(); | 6637 DrawFrame(); |
| 6617 | 6638 |
| 6618 // Fail initialization of the onscreen context before the OutputSurface binds | 6639 // Fail initialization of the onscreen context before the OutputSurface binds |
| 6619 // it to the thread. | 6640 // it to the thread. |
| 6620 onscreen_context_provider_->UnboundTestContext3d()->set_context_lost(true); | 6641 onscreen_context_provider_->UnboundTestContext3d()->set_context_lost(true); |
| 6621 | 6642 |
| 6622 EXPECT_FALSE(host_impl_->output_surface()->context_provider()); | 6643 EXPECT_FALSE(host_impl_->output_surface()->context_provider()); |
| 6623 | 6644 |
| 6624 // DeferredInitialize fails. | 6645 // DeferredInitialize fails. |
| 6625 did_update_renderer_capabilities_ = false; | 6646 did_update_renderer_capabilities_ = false; |
| 6626 EXPECT_FALSE( | 6647 EXPECT_FALSE(output_surface_->InitializeAndSetContext3d( |
| 6627 output_surface_->InitializeAndSetContext3d(onscreen_context_provider_)); | 6648 onscreen_context_provider_, nullptr)); |
| 6628 EXPECT_FALSE(host_impl_->output_surface()->context_provider()); | 6649 EXPECT_FALSE(host_impl_->output_surface()->context_provider()); |
| 6629 EXPECT_FALSE(did_update_renderer_capabilities_); | 6650 EXPECT_FALSE(did_update_renderer_capabilities_); |
| 6630 | 6651 |
| 6631 // Software draw again. | 6652 // Software draw again. |
| 6632 DrawFrame(); | 6653 DrawFrame(); |
| 6633 } | 6654 } |
| 6634 | 6655 |
| 6635 // Checks that we have a non-0 default allocation if we pass a context that | 6656 // Checks that we have a non-0 default allocation if we pass a context that |
| 6636 // doesn't support memory management extensions. | 6657 // doesn't support memory management extensions. |
| 6637 TEST_F(LayerTreeHostImplTest, DefaultMemoryAllocation) { | 6658 TEST_F(LayerTreeHostImplTest, DefaultMemoryAllocation) { |
| (...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7405 } | 7426 } |
| 7406 } | 7427 } |
| 7407 | 7428 |
| 7408 class LayerTreeHostImplWithTopControlsTest : public LayerTreeHostImplTest { | 7429 class LayerTreeHostImplWithTopControlsTest : public LayerTreeHostImplTest { |
| 7409 public: | 7430 public: |
| 7410 void SetUp() override { | 7431 void SetUp() override { |
| 7411 LayerTreeSettings settings = DefaultSettings(); | 7432 LayerTreeSettings settings = DefaultSettings(); |
| 7412 settings.calculate_top_controls_position = true; | 7433 settings.calculate_top_controls_position = true; |
| 7413 CreateHostImpl(settings, CreateOutputSurface()); | 7434 CreateHostImpl(settings, CreateOutputSurface()); |
| 7414 host_impl_->active_tree()->set_top_controls_height(top_controls_height_); | 7435 host_impl_->active_tree()->set_top_controls_height(top_controls_height_); |
| 7415 host_impl_->active_tree()->set_top_controls_delta(top_controls_height_); | 7436 host_impl_->sync_tree()->set_top_controls_height(top_controls_height_); |
| 7416 host_impl_->top_controls_manager()->SetTopControlsHeight( | 7437 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(1.f); |
| 7417 top_controls_height_); | |
| 7418 } | 7438 } |
| 7419 | 7439 |
| 7420 protected: | 7440 protected: |
| 7421 static const int top_controls_height_; | 7441 static const int top_controls_height_; |
| 7422 }; | 7442 }; |
| 7423 | 7443 |
| 7424 const int LayerTreeHostImplWithTopControlsTest::top_controls_height_ = 50; | 7444 const int LayerTreeHostImplWithTopControlsTest::top_controls_height_ = 50; |
| 7425 | 7445 |
| 7426 TEST_F(LayerTreeHostImplWithTopControlsTest, NoIdleAnimations) { | 7446 TEST_F(LayerTreeHostImplWithTopControlsTest, NoIdleAnimations) { |
| 7427 SetupScrollAndContentsLayers(gfx::Size(100, 100)) | 7447 SetupScrollAndContentsLayers(gfx::Size(100, 100)) |
| 7428 ->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 10)); | 7448 ->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 10)); |
| 7429 host_impl_->Animate(base::TimeTicks()); | 7449 host_impl_->Animate(base::TimeTicks()); |
| 7430 EXPECT_FALSE(did_request_redraw_); | 7450 EXPECT_FALSE(did_request_redraw_); |
| 7431 } | 7451 } |
| 7432 | 7452 |
| 7433 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsHeightIsCommitted) { | 7453 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsHeightIsCommitted) { |
| 7434 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 7454 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 7435 EXPECT_FALSE(did_request_redraw_); | 7455 EXPECT_FALSE(did_request_redraw_); |
| 7436 host_impl_->CreatePendingTree(); | 7456 host_impl_->CreatePendingTree(); |
| 7437 host_impl_->sync_tree()->set_top_controls_height(100); | 7457 host_impl_->sync_tree()->set_top_controls_height(100); |
| 7438 host_impl_->ActivateSyncTree(); | 7458 host_impl_->ActivateSyncTree(); |
| 7439 EXPECT_EQ(100, host_impl_->top_controls_manager()->top_controls_height()); | 7459 EXPECT_EQ(100, host_impl_->top_controls_manager()->TopControlsHeight()); |
| 7440 } | 7460 } |
| 7441 | 7461 |
| 7442 TEST_F(LayerTreeHostImplWithTopControlsTest, | 7462 TEST_F(LayerTreeHostImplWithTopControlsTest, |
| 7443 TopControlsStayFullyVisibleOnHeightChange) { | 7463 TopControlsStayFullyVisibleOnHeightChange) { |
| 7444 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 7464 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 7445 EXPECT_EQ(0.f, host_impl_->ControlsTopOffset()); | 7465 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ControlsTopOffset()); |
| 7446 | 7466 |
| 7447 host_impl_->CreatePendingTree(); | 7467 host_impl_->CreatePendingTree(); |
| 7448 host_impl_->sync_tree()->set_top_controls_height(0); | 7468 host_impl_->sync_tree()->set_top_controls_height(0); |
| 7449 host_impl_->ActivateSyncTree(); | 7469 host_impl_->ActivateSyncTree(); |
| 7450 EXPECT_EQ(0.f, host_impl_->ControlsTopOffset()); | 7470 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ControlsTopOffset()); |
| 7451 | 7471 |
| 7452 host_impl_->CreatePendingTree(); | 7472 host_impl_->CreatePendingTree(); |
| 7453 host_impl_->sync_tree()->set_top_controls_height(50); | 7473 host_impl_->sync_tree()->set_top_controls_height(50); |
| 7454 host_impl_->ActivateSyncTree(); | 7474 host_impl_->ActivateSyncTree(); |
| 7455 EXPECT_EQ(0.f, host_impl_->ControlsTopOffset()); | 7475 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ControlsTopOffset()); |
| 7456 } | 7476 } |
| 7457 | 7477 |
| 7458 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationScheduling) { | 7478 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationScheduling) { |
| 7459 SetupScrollAndContentsLayers(gfx::Size(100, 100)) | 7479 SetupScrollAndContentsLayers(gfx::Size(100, 100)) |
| 7460 ->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 10)); | 7480 ->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 10)); |
| 7461 host_impl_->DidChangeTopControlsPosition(); | 7481 host_impl_->DidChangeTopControlsPosition(); |
| 7462 EXPECT_TRUE(did_request_animate_); | 7482 EXPECT_TRUE(did_request_animate_); |
| 7463 EXPECT_TRUE(did_request_redraw_); | 7483 EXPECT_TRUE(did_request_redraw_); |
| 7464 } | 7484 } |
| 7465 | 7485 |
| (...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8010 scrolling_layer->CurrentScrollOffset()); | 8030 scrolling_layer->CurrentScrollOffset()); |
| 8011 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); | 8031 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); |
| 8012 } | 8032 } |
| 8013 | 8033 |
| 8014 TEST_F(LayerTreeHostImplTest, GetPictureLayerImplPairs) { | 8034 TEST_F(LayerTreeHostImplTest, GetPictureLayerImplPairs) { |
| 8015 host_impl_->CreatePendingTree(); | 8035 host_impl_->CreatePendingTree(); |
| 8016 | 8036 |
| 8017 scoped_ptr<PictureLayerImpl> layer = | 8037 scoped_ptr<PictureLayerImpl> layer = |
| 8018 FakePictureLayerImpl::Create(host_impl_->pending_tree(), 10); | 8038 FakePictureLayerImpl::Create(host_impl_->pending_tree(), 10); |
| 8019 layer->SetBounds(gfx::Size(10, 10)); | 8039 layer->SetBounds(gfx::Size(10, 10)); |
| 8040 scoped_ptr<FakePictureLayerImpl> nondraw_layer = |
| 8041 FakePictureLayerImpl::Create(host_impl_->pending_tree(), 12); |
| 8042 nondraw_layer->SetBounds(gfx::Size(10, 10)); |
| 8020 | 8043 |
| 8021 scoped_refptr<RasterSource> pile(FakePicturePileImpl::CreateEmptyPile( | 8044 scoped_refptr<RasterSource> pile(FakePicturePileImpl::CreateEmptyPile( |
| 8022 gfx::Size(10, 10), gfx::Size(10, 10))); | 8045 gfx::Size(10, 10), gfx::Size(10, 10))); |
| 8023 Region empty_invalidation; | 8046 Region empty_invalidation; |
| 8024 const PictureLayerTilingSet* null_tiling_set = nullptr; | 8047 const PictureLayerTilingSet* null_tiling_set = nullptr; |
| 8025 layer->UpdateRasterSource(pile, &empty_invalidation, null_tiling_set); | 8048 layer->UpdateRasterSource(pile, &empty_invalidation, null_tiling_set); |
| 8049 nondraw_layer->UpdateRasterSource(pile, &empty_invalidation, null_tiling_set); |
| 8026 | 8050 |
| 8051 layer->AddChild(nondraw_layer.Pass()); |
| 8027 host_impl_->pending_tree()->SetRootLayer(layer.Pass()); | 8052 host_impl_->pending_tree()->SetRootLayer(layer.Pass()); |
| 8028 | 8053 |
| 8029 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); | 8054 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); |
| 8030 LayerImpl* pending_layer = pending_tree->root_layer(); | 8055 LayerImpl* pending_layer = pending_tree->root_layer(); |
| 8056 FakePictureLayerImpl* pending_nondraw_layer = |
| 8057 static_cast<FakePictureLayerImpl*>(pending_layer->children()[0]); |
| 8058 |
| 8059 pending_nondraw_layer->SetIsDrawnRenderSurfaceLayerListMember(false); |
| 8031 | 8060 |
| 8032 std::vector<PictureLayerImpl::Pair> layer_pairs; | 8061 std::vector<PictureLayerImpl::Pair> layer_pairs; |
| 8033 host_impl_->GetPictureLayerImplPairs(&layer_pairs, true); | 8062 host_impl_->GetPictureLayerImplPairs(&layer_pairs, true); |
| 8034 EXPECT_EQ(1u, layer_pairs.size()); | 8063 EXPECT_EQ(1u, layer_pairs.size()); |
| 8035 EXPECT_EQ(pending_layer, layer_pairs[0].pending); | 8064 EXPECT_EQ(pending_layer, layer_pairs[0].pending); |
| 8036 EXPECT_EQ(nullptr, layer_pairs[0].active); | 8065 EXPECT_EQ(nullptr, layer_pairs[0].active); |
| 8037 | 8066 |
| 8038 host_impl_->ActivateSyncTree(); | 8067 host_impl_->ActivateSyncTree(); |
| 8039 | 8068 |
| 8040 LayerTreeImpl* active_tree = host_impl_->active_tree(); | 8069 LayerTreeImpl* active_tree = host_impl_->active_tree(); |
| 8041 LayerImpl* active_layer = active_tree->root_layer(); | 8070 LayerImpl* active_layer = active_tree->root_layer(); |
| 8071 FakePictureLayerImpl* active_nondraw_layer = |
| 8072 static_cast<FakePictureLayerImpl*>(active_layer->children()[0]); |
| 8042 EXPECT_NE(active_tree, pending_tree); | 8073 EXPECT_NE(active_tree, pending_tree); |
| 8043 EXPECT_NE(active_layer, pending_layer); | 8074 EXPECT_NE(active_layer, pending_layer); |
| 8075 EXPECT_NE(active_nondraw_layer, pending_nondraw_layer); |
| 8044 EXPECT_NE(nullptr, active_tree); | 8076 EXPECT_NE(nullptr, active_tree); |
| 8045 EXPECT_NE(nullptr, active_layer); | 8077 EXPECT_NE(nullptr, active_layer); |
| 8078 EXPECT_NE(nullptr, active_nondraw_layer); |
| 8079 |
| 8080 active_nondraw_layer->SetIsDrawnRenderSurfaceLayerListMember(false); |
| 8046 | 8081 |
| 8047 host_impl_->CreatePendingTree(); | 8082 host_impl_->CreatePendingTree(); |
| 8048 | 8083 |
| 8049 layer_pairs.clear(); | 8084 layer_pairs.clear(); |
| 8050 host_impl_->GetPictureLayerImplPairs(&layer_pairs, true); | 8085 host_impl_->GetPictureLayerImplPairs(&layer_pairs, true); |
| 8051 EXPECT_EQ(1u, layer_pairs.size()); | 8086 EXPECT_EQ(1u, layer_pairs.size()); |
| 8052 EXPECT_EQ(active_layer, layer_pairs[0].active); | 8087 EXPECT_EQ(active_layer, layer_pairs[0].active); |
| 8053 EXPECT_EQ(pending_layer, layer_pairs[0].pending); | 8088 EXPECT_EQ(pending_layer, layer_pairs[0].pending); |
| 8054 | 8089 |
| 8055 // Activate, the active layer has no twin now. | 8090 // Activate, the active layer has no twin now. |
| 8056 host_impl_->ActivateSyncTree(); | 8091 host_impl_->ActivateSyncTree(); |
| 8057 | 8092 |
| 8058 layer_pairs.clear(); | 8093 layer_pairs.clear(); |
| 8059 host_impl_->GetPictureLayerImplPairs(&layer_pairs, true); | 8094 host_impl_->GetPictureLayerImplPairs(&layer_pairs, true); |
| 8060 EXPECT_EQ(1u, layer_pairs.size()); | 8095 EXPECT_EQ(1u, layer_pairs.size()); |
| 8061 EXPECT_EQ(active_layer, layer_pairs[0].active); | 8096 EXPECT_EQ(active_layer, layer_pairs[0].active); |
| 8062 EXPECT_EQ(nullptr, layer_pairs[0].pending); | 8097 EXPECT_EQ(nullptr, layer_pairs[0].pending); |
| 8063 | 8098 |
| 8064 // Create another layer in the pending tree that's not in the active tree. We | 8099 // Create another layer in the pending tree that's not in the active tree. We |
| 8065 // should get two pairs. | 8100 // should get two pairs. |
| 8066 host_impl_->CreatePendingTree(); | 8101 host_impl_->CreatePendingTree(); |
| 8067 host_impl_->pending_tree()->root_layer()->AddChild( | 8102 host_impl_->pending_tree()->root_layer()->AddChild( |
| 8068 FakePictureLayerImpl::Create(host_impl_->pending_tree(), 11)); | 8103 FakePictureLayerImpl::Create(host_impl_->pending_tree(), 11)); |
| 8069 | 8104 |
| 8070 LayerImpl* new_pending_layer = pending_tree->root_layer()->children()[0]; | 8105 LayerImpl* new_pending_layer = pending_tree->root_layer()->children()[1]; |
| 8071 | 8106 |
| 8072 layer_pairs.clear(); | 8107 layer_pairs.clear(); |
| 8073 host_impl_->GetPictureLayerImplPairs(&layer_pairs, true); | 8108 host_impl_->GetPictureLayerImplPairs(&layer_pairs, true); |
| 8074 EXPECT_EQ(2u, layer_pairs.size()); | 8109 EXPECT_EQ(2u, layer_pairs.size()); |
| 8075 | |
| 8076 // The pair ordering is flaky, so make it consistent. | 8110 // The pair ordering is flaky, so make it consistent. |
| 8077 if (layer_pairs[0].active != active_layer) | 8111 if (layer_pairs[0].active != active_layer) |
| 8078 std::swap(layer_pairs[0], layer_pairs[1]); | 8112 std::swap(layer_pairs[0], layer_pairs[1]); |
| 8079 | |
| 8080 EXPECT_EQ(active_layer, layer_pairs[0].active); | 8113 EXPECT_EQ(active_layer, layer_pairs[0].active); |
| 8081 EXPECT_EQ(pending_layer, layer_pairs[0].pending); | 8114 EXPECT_EQ(pending_layer, layer_pairs[0].pending); |
| 8082 EXPECT_EQ(new_pending_layer, layer_pairs[1].pending); | 8115 EXPECT_EQ(new_pending_layer, layer_pairs[1].pending); |
| 8083 EXPECT_EQ(nullptr, layer_pairs[1].active); | 8116 EXPECT_EQ(nullptr, layer_pairs[1].active); |
| 8117 |
| 8118 host_impl_->pending_tree()->root_layer()->RemoveChild(new_pending_layer); |
| 8119 |
| 8120 // Have the pending layer be part of the RSLL now. It should appear in the |
| 8121 // list without an active twin. |
| 8122 pending_nondraw_layer->SetIsDrawnRenderSurfaceLayerListMember(true); |
| 8123 |
| 8124 layer_pairs.clear(); |
| 8125 host_impl_->GetPictureLayerImplPairs(&layer_pairs, true); |
| 8126 EXPECT_EQ(2u, layer_pairs.size()); |
| 8127 // The pair ordering is flaky, so make it consistent. |
| 8128 if (layer_pairs[0].active != active_layer) |
| 8129 std::swap(layer_pairs[0], layer_pairs[1]); |
| 8130 EXPECT_EQ(active_layer, layer_pairs[0].active); |
| 8131 EXPECT_EQ(pending_layer, layer_pairs[0].pending); |
| 8132 EXPECT_EQ(pending_nondraw_layer, layer_pairs[1].pending); |
| 8133 EXPECT_EQ(nullptr, layer_pairs[1].active); |
| 8134 |
| 8135 // Have the active layer be part of the RSLL now instead. It should appear in |
| 8136 // the list without a pending twin. |
| 8137 pending_nondraw_layer->SetIsDrawnRenderSurfaceLayerListMember(false); |
| 8138 active_nondraw_layer->SetIsDrawnRenderSurfaceLayerListMember(true); |
| 8139 |
| 8140 layer_pairs.clear(); |
| 8141 host_impl_->GetPictureLayerImplPairs(&layer_pairs, true); |
| 8142 EXPECT_EQ(2u, layer_pairs.size()); |
| 8143 // The pair ordering is flaky, so make it consistent. |
| 8144 if (layer_pairs[0].active != active_layer) |
| 8145 std::swap(layer_pairs[0], layer_pairs[1]); |
| 8146 EXPECT_EQ(active_layer, layer_pairs[0].active); |
| 8147 EXPECT_EQ(pending_layer, layer_pairs[0].pending); |
| 8148 EXPECT_EQ(nullptr, layer_pairs[1].pending); |
| 8149 EXPECT_EQ(active_nondraw_layer, layer_pairs[1].active); |
| 8150 } |
| 8151 |
| 8152 TEST_F(LayerTreeHostImplTest, GetPictureLayerImplPairsWithNonRSLLMembers) { |
| 8153 host_impl_->CreatePendingTree(); |
| 8154 |
| 8155 scoped_ptr<PictureLayerImpl> layer = |
| 8156 FakePictureLayerImpl::Create(host_impl_->pending_tree(), 10); |
| 8157 layer->SetBounds(gfx::Size(10, 10)); |
| 8158 scoped_ptr<FakePictureLayerImpl> nondraw_layer = |
| 8159 FakePictureLayerImpl::Create(host_impl_->pending_tree(), 12); |
| 8160 nondraw_layer->SetBounds(gfx::Size(10, 10)); |
| 8161 |
| 8162 scoped_refptr<RasterSource> pile(FakePicturePileImpl::CreateEmptyPile( |
| 8163 gfx::Size(10, 10), gfx::Size(10, 10))); |
| 8164 Region empty_invalidation; |
| 8165 const PictureLayerTilingSet* null_tiling_set = nullptr; |
| 8166 layer->UpdateRasterSource(pile, &empty_invalidation, null_tiling_set); |
| 8167 nondraw_layer->UpdateRasterSource(pile, &empty_invalidation, null_tiling_set); |
| 8168 |
| 8169 layer->AddChild(nondraw_layer.Pass()); |
| 8170 host_impl_->pending_tree()->SetRootLayer(layer.Pass()); |
| 8171 |
| 8172 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); |
| 8173 LayerImpl* pending_layer = pending_tree->root_layer(); |
| 8174 FakePictureLayerImpl* pending_nondraw_layer = |
| 8175 static_cast<FakePictureLayerImpl*>(pending_layer->children()[0]); |
| 8176 |
| 8177 pending_nondraw_layer->SetIsDrawnRenderSurfaceLayerListMember(false); |
| 8178 |
| 8179 std::vector<PictureLayerImpl::Pair> layer_pairs; |
| 8180 host_impl_->GetPictureLayerImplPairs(&layer_pairs, false); |
| 8181 EXPECT_EQ(2u, layer_pairs.size()); |
| 8182 // The pair ordering is flaky, so make it consistent. |
| 8183 if (layer_pairs[0].pending != pending_layer) |
| 8184 std::swap(layer_pairs[0], layer_pairs[1]); |
| 8185 EXPECT_EQ(pending_layer, layer_pairs[0].pending); |
| 8186 EXPECT_EQ(nullptr, layer_pairs[0].active); |
| 8187 EXPECT_EQ(pending_nondraw_layer, layer_pairs[1].pending); |
| 8188 EXPECT_EQ(nullptr, layer_pairs[1].active); |
| 8189 |
| 8190 host_impl_->ActivateSyncTree(); |
| 8191 |
| 8192 LayerTreeImpl* active_tree = host_impl_->active_tree(); |
| 8193 LayerImpl* active_layer = active_tree->root_layer(); |
| 8194 FakePictureLayerImpl* active_nondraw_layer = |
| 8195 static_cast<FakePictureLayerImpl*>(active_layer->children()[0]); |
| 8196 EXPECT_NE(active_tree, pending_tree); |
| 8197 EXPECT_NE(active_layer, pending_layer); |
| 8198 EXPECT_NE(active_nondraw_layer, pending_nondraw_layer); |
| 8199 EXPECT_NE(nullptr, active_tree); |
| 8200 EXPECT_NE(nullptr, active_layer); |
| 8201 EXPECT_NE(nullptr, active_nondraw_layer); |
| 8202 |
| 8203 active_nondraw_layer->SetIsDrawnRenderSurfaceLayerListMember(false); |
| 8204 |
| 8205 host_impl_->CreatePendingTree(); |
| 8206 |
| 8207 layer_pairs.clear(); |
| 8208 host_impl_->GetPictureLayerImplPairs(&layer_pairs, false); |
| 8209 EXPECT_EQ(2u, layer_pairs.size()); |
| 8210 // The pair ordering is flaky, so make it consistent. |
| 8211 if (layer_pairs[0].active != active_layer) |
| 8212 std::swap(layer_pairs[0], layer_pairs[1]); |
| 8213 EXPECT_EQ(active_layer, layer_pairs[0].active); |
| 8214 EXPECT_EQ(pending_layer, layer_pairs[0].pending); |
| 8215 EXPECT_EQ(pending_nondraw_layer, layer_pairs[1].pending); |
| 8216 EXPECT_EQ(active_nondraw_layer, layer_pairs[1].active); |
| 8217 |
| 8218 // Activate, the active layer has no twin now. |
| 8219 host_impl_->ActivateSyncTree(); |
| 8220 |
| 8221 layer_pairs.clear(); |
| 8222 host_impl_->GetPictureLayerImplPairs(&layer_pairs, false); |
| 8223 EXPECT_EQ(2u, layer_pairs.size()); |
| 8224 // The pair ordering is flaky, so make it consistent. |
| 8225 if (layer_pairs[0].active != active_layer) |
| 8226 std::swap(layer_pairs[0], layer_pairs[1]); |
| 8227 EXPECT_EQ(active_layer, layer_pairs[0].active); |
| 8228 EXPECT_EQ(nullptr, layer_pairs[0].pending); |
| 8229 EXPECT_EQ(active_nondraw_layer, layer_pairs[1].active); |
| 8230 EXPECT_EQ(nullptr, layer_pairs[1].pending); |
| 8231 |
| 8232 // Create another layer in the pending tree that's not in the active tree. We |
| 8233 // should get three pairs including the nondraw layers. |
| 8234 host_impl_->CreatePendingTree(); |
| 8235 host_impl_->pending_tree()->root_layer()->AddChild( |
| 8236 FakePictureLayerImpl::Create(host_impl_->pending_tree(), 11)); |
| 8237 |
| 8238 LayerImpl* new_pending_layer = pending_tree->root_layer()->children()[1]; |
| 8239 |
| 8240 layer_pairs.clear(); |
| 8241 host_impl_->GetPictureLayerImplPairs(&layer_pairs, false); |
| 8242 EXPECT_EQ(3u, layer_pairs.size()); |
| 8243 // The pair ordering is flaky, so make it consistent. |
| 8244 if (layer_pairs[0].active != active_layer) |
| 8245 std::swap(layer_pairs[0], layer_pairs[1]); |
| 8246 if (layer_pairs[0].active != active_layer) |
| 8247 std::swap(layer_pairs[0], layer_pairs[2]); |
| 8248 if (layer_pairs[1].pending != new_pending_layer) |
| 8249 std::swap(layer_pairs[1], layer_pairs[2]); |
| 8250 EXPECT_EQ(active_layer, layer_pairs[0].active); |
| 8251 EXPECT_EQ(pending_layer, layer_pairs[0].pending); |
| 8252 EXPECT_EQ(new_pending_layer, layer_pairs[1].pending); |
| 8253 EXPECT_EQ(nullptr, layer_pairs[1].active); |
| 8254 EXPECT_EQ(active_nondraw_layer, layer_pairs[2].active); |
| 8255 EXPECT_EQ(pending_nondraw_layer, layer_pairs[2].pending); |
| 8256 |
| 8257 host_impl_->pending_tree()->root_layer()->RemoveChild(new_pending_layer); |
| 8258 |
| 8259 // Have the pending layer be part of the RSLL now. It should appear in the |
| 8260 // list, as should its active twin since we don't request only layers with |
| 8261 // valid draw properties. |
| 8262 pending_nondraw_layer->SetIsDrawnRenderSurfaceLayerListMember(true); |
| 8263 |
| 8264 layer_pairs.clear(); |
| 8265 host_impl_->GetPictureLayerImplPairs(&layer_pairs, false); |
| 8266 EXPECT_EQ(2u, layer_pairs.size()); |
| 8267 // The pair ordering is flaky, so make it consistent. |
| 8268 if (layer_pairs[0].active != active_layer) |
| 8269 std::swap(layer_pairs[0], layer_pairs[1]); |
| 8270 EXPECT_EQ(active_layer, layer_pairs[0].active); |
| 8271 EXPECT_EQ(pending_layer, layer_pairs[0].pending); |
| 8272 EXPECT_EQ(pending_nondraw_layer, layer_pairs[1].pending); |
| 8273 EXPECT_EQ(active_nondraw_layer, layer_pairs[1].active); |
| 8274 |
| 8275 // Have the active layer be part of the RSLL now instead. It should appear in |
| 8276 // the list, as should its pending twin since we don't request only layers |
| 8277 // with valid draw properties. |
| 8278 pending_nondraw_layer->SetIsDrawnRenderSurfaceLayerListMember(false); |
| 8279 active_nondraw_layer->SetIsDrawnRenderSurfaceLayerListMember(true); |
| 8280 |
| 8281 layer_pairs.clear(); |
| 8282 host_impl_->GetPictureLayerImplPairs(&layer_pairs, false); |
| 8283 EXPECT_EQ(2u, layer_pairs.size()); |
| 8284 // The pair ordering is flaky, so make it consistent. |
| 8285 if (layer_pairs[0].active != active_layer) |
| 8286 std::swap(layer_pairs[0], layer_pairs[1]); |
| 8287 EXPECT_EQ(active_layer, layer_pairs[0].active); |
| 8288 EXPECT_EQ(pending_layer, layer_pairs[0].pending); |
| 8289 EXPECT_EQ(active_nondraw_layer, layer_pairs[1].active); |
| 8290 EXPECT_EQ(pending_nondraw_layer, layer_pairs[1].pending); |
| 8084 } | 8291 } |
| 8085 | 8292 |
| 8086 TEST_F(LayerTreeHostImplTest, DidBecomeActive) { | 8293 TEST_F(LayerTreeHostImplTest, DidBecomeActive) { |
| 8087 host_impl_->CreatePendingTree(); | 8294 host_impl_->CreatePendingTree(); |
| 8088 host_impl_->ActivateSyncTree(); | 8295 host_impl_->ActivateSyncTree(); |
| 8089 host_impl_->CreatePendingTree(); | 8296 host_impl_->CreatePendingTree(); |
| 8090 | 8297 |
| 8091 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); | 8298 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); |
| 8092 | 8299 |
| 8093 scoped_ptr<FakePictureLayerImpl> pending_layer = | 8300 scoped_ptr<FakePictureLayerImpl> pending_layer = |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8182 // surface. | 8389 // surface. |
| 8183 EXPECT_EQ(0, num_lost_surfaces_); | 8390 EXPECT_EQ(0, num_lost_surfaces_); |
| 8184 host_impl_->DidLoseOutputSurface(); | 8391 host_impl_->DidLoseOutputSurface(); |
| 8185 EXPECT_EQ(1, num_lost_surfaces_); | 8392 EXPECT_EQ(1, num_lost_surfaces_); |
| 8186 host_impl_->DidLoseOutputSurface(); | 8393 host_impl_->DidLoseOutputSurface(); |
| 8187 EXPECT_LE(1, num_lost_surfaces_); | 8394 EXPECT_LE(1, num_lost_surfaces_); |
| 8188 } | 8395 } |
| 8189 | 8396 |
| 8190 } // namespace | 8397 } // namespace |
| 8191 } // namespace cc | 8398 } // namespace cc |
| OLD | NEW |