| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 #include "cc/test/begin_frame_args_test.h" | 43 #include "cc/test/begin_frame_args_test.h" |
| 44 #include "cc/test/fake_layer_tree_host_impl.h" | 44 #include "cc/test/fake_layer_tree_host_impl.h" |
| 45 #include "cc/test/fake_output_surface.h" | 45 #include "cc/test/fake_output_surface.h" |
| 46 #include "cc/test/fake_output_surface_client.h" | 46 #include "cc/test/fake_output_surface_client.h" |
| 47 #include "cc/test/fake_picture_layer_impl.h" | 47 #include "cc/test/fake_picture_layer_impl.h" |
| 48 #include "cc/test/fake_picture_pile_impl.h" | 48 #include "cc/test/fake_picture_pile_impl.h" |
| 49 #include "cc/test/fake_proxy.h" | 49 #include "cc/test/fake_proxy.h" |
| 50 #include "cc/test/fake_video_frame_provider.h" | 50 #include "cc/test/fake_video_frame_provider.h" |
| 51 #include "cc/test/geometry_test_utils.h" | 51 #include "cc/test/geometry_test_utils.h" |
| 52 #include "cc/test/layer_test_common.h" | 52 #include "cc/test/layer_test_common.h" |
| 53 #include "cc/test/layer_tree_test.h" |
| 53 #include "cc/test/render_pass_test_common.h" | 54 #include "cc/test/render_pass_test_common.h" |
| 54 #include "cc/test/test_gpu_memory_buffer_manager.h" | 55 #include "cc/test/test_gpu_memory_buffer_manager.h" |
| 55 #include "cc/test/test_shared_bitmap_manager.h" | 56 #include "cc/test/test_shared_bitmap_manager.h" |
| 56 #include "cc/test/test_web_graphics_context_3d.h" | 57 #include "cc/test/test_web_graphics_context_3d.h" |
| 57 #include "cc/trees/layer_tree_impl.h" | 58 #include "cc/trees/layer_tree_impl.h" |
| 58 #include "cc/trees/single_thread_proxy.h" | 59 #include "cc/trees/single_thread_proxy.h" |
| 59 #include "media/base/media.h" | 60 #include "media/base/media.h" |
| 60 #include "testing/gmock/include/gmock/gmock.h" | 61 #include "testing/gmock/include/gmock/gmock.h" |
| 61 #include "testing/gtest/include/gtest/gtest.h" | 62 #include "testing/gtest/include/gtest/gtest.h" |
| 62 #include "third_party/skia/include/core/SkMallocPixelRef.h" | 63 #include "third_party/skia/include/core/SkMallocPixelRef.h" |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 174 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
| 174 return init; | 175 return init; |
| 175 } | 176 } |
| 176 | 177 |
| 177 void SetupRootLayerImpl(scoped_ptr<LayerImpl> root) { | 178 void SetupRootLayerImpl(scoped_ptr<LayerImpl> root) { |
| 178 root->SetPosition(gfx::PointF()); | 179 root->SetPosition(gfx::PointF()); |
| 179 root->SetBounds(gfx::Size(10, 10)); | 180 root->SetBounds(gfx::Size(10, 10)); |
| 180 root->SetContentBounds(gfx::Size(10, 10)); | 181 root->SetContentBounds(gfx::Size(10, 10)); |
| 181 root->SetDrawsContent(true); | 182 root->SetDrawsContent(true); |
| 182 root->draw_properties().visible_content_rect = gfx::Rect(0, 0, 10, 10); | 183 root->draw_properties().visible_content_rect = gfx::Rect(0, 0, 10, 10); |
| 184 root->SetHasRenderSurface(true); |
| 183 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 185 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 184 } | 186 } |
| 185 | 187 |
| 186 static void ExpectClearedScrollDeltasRecursive(LayerImpl* layer) { | 188 static void ExpectClearedScrollDeltasRecursive(LayerImpl* layer) { |
| 187 ASSERT_EQ(layer->ScrollDelta(), gfx::Vector2d()); | 189 ASSERT_EQ(layer->ScrollDelta(), gfx::Vector2d()); |
| 188 for (size_t i = 0; i < layer->children().size(); ++i) | 190 for (size_t i = 0; i < layer->children().size(); ++i) |
| 189 ExpectClearedScrollDeltasRecursive(layer->children()[i]); | 191 ExpectClearedScrollDeltasRecursive(layer->children()[i]); |
| 190 } | 192 } |
| 191 | 193 |
| 192 static void ExpectContains(const ScrollAndScaleSet& scroll_info, | 194 static void ExpectContains(const ScrollAndScaleSet& scroll_info, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 219 LayerImpl* CreateScrollAndContentsLayers(LayerTreeImpl* layer_tree_impl, | 221 LayerImpl* CreateScrollAndContentsLayers(LayerTreeImpl* layer_tree_impl, |
| 220 const gfx::Size& content_size) { | 222 const gfx::Size& content_size) { |
| 221 const int kInnerViewportScrollLayerId = 2; | 223 const int kInnerViewportScrollLayerId = 2; |
| 222 const int kInnerViewportClipLayerId = 4; | 224 const int kInnerViewportClipLayerId = 4; |
| 223 const int kPageScaleLayerId = 5; | 225 const int kPageScaleLayerId = 5; |
| 224 scoped_ptr<LayerImpl> root = | 226 scoped_ptr<LayerImpl> root = |
| 225 LayerImpl::Create(layer_tree_impl, 1); | 227 LayerImpl::Create(layer_tree_impl, 1); |
| 226 root->SetBounds(content_size); | 228 root->SetBounds(content_size); |
| 227 root->SetContentBounds(content_size); | 229 root->SetContentBounds(content_size); |
| 228 root->SetPosition(gfx::PointF()); | 230 root->SetPosition(gfx::PointF()); |
| 231 root->SetHasRenderSurface(true); |
| 229 | 232 |
| 230 scoped_ptr<LayerImpl> scroll = | 233 scoped_ptr<LayerImpl> scroll = |
| 231 LayerImpl::Create(layer_tree_impl, kInnerViewportScrollLayerId); | 234 LayerImpl::Create(layer_tree_impl, kInnerViewportScrollLayerId); |
| 232 LayerImpl* scroll_layer = scroll.get(); | 235 LayerImpl* scroll_layer = scroll.get(); |
| 233 scroll->SetIsContainerForFixedPositionLayers(true); | 236 scroll->SetIsContainerForFixedPositionLayers(true); |
| 234 scroll->SetScrollOffset(gfx::ScrollOffset()); | 237 scroll->SetScrollOffset(gfx::ScrollOffset()); |
| 235 | 238 |
| 236 scoped_ptr<LayerImpl> clip = | 239 scoped_ptr<LayerImpl> clip = |
| 237 LayerImpl::Create(layer_tree_impl, kInnerViewportClipLayerId); | 240 LayerImpl::Create(layer_tree_impl, kInnerViewportClipLayerId); |
| 238 clip->SetBounds( | 241 clip->SetBounds( |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 | 563 |
| 561 // We should still be scrolling, because the scrolled layer also exists in the | 564 // We should still be scrolling, because the scrolled layer also exists in the |
| 562 // new tree. | 565 // new tree. |
| 563 gfx::Vector2d scroll_delta(0, 10); | 566 gfx::Vector2d scroll_delta(0, 10); |
| 564 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 567 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 565 host_impl_->ScrollEnd(); | 568 host_impl_->ScrollEnd(); |
| 566 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); | 569 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); |
| 567 ExpectContains(*scroll_info, scroll_layer->id(), scroll_delta); | 570 ExpectContains(*scroll_info, scroll_layer->id(), scroll_delta); |
| 568 } | 571 } |
| 569 | 572 |
| 570 TEST_F(LayerTreeHostImplTest, ClearRootRenderSurfaceAndScroll) { | |
| 571 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | |
| 572 host_impl_->SetViewportSize(gfx::Size(50, 50)); | |
| 573 DrawFrame(); | |
| 574 | |
| 575 // We should be able to scroll even if the root layer loses its render surface | |
| 576 // after the most recent render. | |
| 577 host_impl_->active_tree()->root_layer()->ClearRenderSurface(); | |
| 578 host_impl_->active_tree()->set_needs_update_draw_properties(); | |
| 579 | |
| 580 EXPECT_EQ(InputHandler::ScrollStarted, | |
| 581 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); | |
| 582 } | |
| 583 | |
| 584 TEST_F(LayerTreeHostImplTest, WheelEventHandlers) { | 573 TEST_F(LayerTreeHostImplTest, WheelEventHandlers) { |
| 585 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 574 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 586 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 575 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 587 DrawFrame(); | 576 DrawFrame(); |
| 588 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 577 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 589 | 578 |
| 590 root->SetHaveWheelEventHandlers(true); | 579 root->SetHaveWheelEventHandlers(true); |
| 591 | 580 |
| 592 // With registered event handlers, wheel scrolls have to go to the main | 581 // With registered event handlers, wheel scrolls have to go to the main |
| 593 // thread. | 582 // thread. |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 889 host_impl_->ScrollBegin(scroll_position, InputHandler::Wheel)); | 878 host_impl_->ScrollBegin(scroll_position, InputHandler::Wheel)); |
| 890 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 0), scroll_layer->TotalScrollOffset()); | 879 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 0), scroll_layer->TotalScrollOffset()); |
| 891 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->TotalScrollOffset()); | 880 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->TotalScrollOffset()); |
| 892 | 881 |
| 893 host_impl_->ScrollBy(scroll_position, scroll_delta); | 882 host_impl_->ScrollBy(scroll_position, scroll_delta); |
| 894 host_impl_->ScrollEnd(); | 883 host_impl_->ScrollEnd(); |
| 895 EXPECT_VECTOR_EQ(gfx::Vector2dF(20, 10), scroll_layer->TotalScrollOffset()); | 884 EXPECT_VECTOR_EQ(gfx::Vector2dF(20, 10), scroll_layer->TotalScrollOffset()); |
| 896 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->TotalScrollOffset()); | 885 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->TotalScrollOffset()); |
| 897 } | 886 } |
| 898 | 887 |
| 899 TEST_F(LayerTreeHostImplTest, | |
| 900 ClearRootRenderSurfaceAndHitTestTouchHandlerRegion) { | |
| 901 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | |
| 902 host_impl_->SetViewportSize(gfx::Size(50, 50)); | |
| 903 DrawFrame(); | |
| 904 | |
| 905 // We should be able to hit test for touch event handlers even if the root | |
| 906 // layer loses its render surface after the most recent render. | |
| 907 host_impl_->active_tree()->root_layer()->ClearRenderSurface(); | |
| 908 host_impl_->active_tree()->set_needs_update_draw_properties(); | |
| 909 | |
| 910 EXPECT_EQ(host_impl_->HaveTouchEventHandlersAt(gfx::Point()), false); | |
| 911 } | |
| 912 | |
| 913 TEST_F(LayerTreeHostImplTest, ImplPinchZoom) { | 888 TEST_F(LayerTreeHostImplTest, ImplPinchZoom) { |
| 914 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 889 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 915 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 890 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 916 DrawFrame(); | 891 DrawFrame(); |
| 917 | 892 |
| 918 EXPECT_EQ(scroll_layer, host_impl_->InnerViewportScrollLayer()); | 893 EXPECT_EQ(scroll_layer, host_impl_->InnerViewportScrollLayer()); |
| 919 LayerImpl* container_layer = scroll_layer->scroll_clip_layer(); | 894 LayerImpl* container_layer = scroll_layer->scroll_clip_layer(); |
| 920 EXPECT_EQ(gfx::Size(50, 50), container_layer->bounds()); | 895 EXPECT_EQ(gfx::Size(50, 50), container_layer->bounds()); |
| 921 | 896 |
| 922 float min_page_scale = 1.f, max_page_scale = 4.f; | 897 float min_page_scale = 1.f, max_page_scale = 4.f; |
| (...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1442 contents->SetBounds(content_size); \ | 1417 contents->SetBounds(content_size); \ |
| 1443 contents->SetContentBounds(content_size); \ | 1418 contents->SetContentBounds(content_size); \ |
| 1444 \ | 1419 \ |
| 1445 scoped_ptr<SolidColorScrollbarLayerImpl> scrollbar = \ | 1420 scoped_ptr<SolidColorScrollbarLayerImpl> scrollbar = \ |
| 1446 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 4, \ | 1421 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 4, \ |
| 1447 VERTICAL, 10, 0, false, true); \ | 1422 VERTICAL, 10, 0, false, true); \ |
| 1448 EXPECT_FLOAT_EQ(0.f, scrollbar->opacity()); \ | 1423 EXPECT_FLOAT_EQ(0.f, scrollbar->opacity()); \ |
| 1449 \ | 1424 \ |
| 1450 scroll->AddChild(contents.Pass()); \ | 1425 scroll->AddChild(contents.Pass()); \ |
| 1451 root->AddChild(scroll.Pass()); \ | 1426 root->AddChild(scroll.Pass()); \ |
| 1427 root->SetHasRenderSurface(true); \ |
| 1452 scrollbar->SetScrollLayerAndClipLayerByIds(2, 1); \ | 1428 scrollbar->SetScrollLayerAndClipLayerByIds(2, 1); \ |
| 1453 root->AddChild(scrollbar.Pass()); \ | 1429 root->AddChild(scrollbar.Pass()); \ |
| 1454 \ | 1430 \ |
| 1455 host_impl_->active_tree()->SetRootLayer(root.Pass()); \ | 1431 host_impl_->active_tree()->SetRootLayer(root.Pass()); \ |
| 1456 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 2, \ | 1432 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 2, \ |
| 1457 Layer::INVALID_ID); \ | 1433 Layer::INVALID_ID); \ |
| 1458 host_impl_->active_tree()->DidBecomeActive(); \ | 1434 host_impl_->active_tree()->DidBecomeActive(); \ |
| 1459 DrawFrame(); | 1435 DrawFrame(); |
| 1460 | 1436 |
| 1461 TEST_F(LayerTreeHostImplTest, ScrollbarLinearFadeScheduling) { | 1437 TEST_F(LayerTreeHostImplTest, ScrollbarLinearFadeScheduling) { |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1586 gfx::ScaleSize(viewport_size, device_scale_factor)); | 1562 gfx::ScaleSize(viewport_size, device_scale_factor)); |
| 1587 gfx::Size content_size(1000, 1000); | 1563 gfx::Size content_size(1000, 1000); |
| 1588 | 1564 |
| 1589 CreateHostImpl(settings, CreateOutputSurface()); | 1565 CreateHostImpl(settings, CreateOutputSurface()); |
| 1590 host_impl_->SetDeviceScaleFactor(device_scale_factor); | 1566 host_impl_->SetDeviceScaleFactor(device_scale_factor); |
| 1591 host_impl_->SetViewportSize(device_viewport_size); | 1567 host_impl_->SetViewportSize(device_viewport_size); |
| 1592 | 1568 |
| 1593 scoped_ptr<LayerImpl> root = | 1569 scoped_ptr<LayerImpl> root = |
| 1594 LayerImpl::Create(host_impl_->active_tree(), 1); | 1570 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 1595 root->SetBounds(viewport_size); | 1571 root->SetBounds(viewport_size); |
| 1572 root->SetHasRenderSurface(true); |
| 1596 | 1573 |
| 1597 scoped_ptr<LayerImpl> scroll = | 1574 scoped_ptr<LayerImpl> scroll = |
| 1598 LayerImpl::Create(host_impl_->active_tree(), 2); | 1575 LayerImpl::Create(host_impl_->active_tree(), 2); |
| 1599 scroll->SetScrollClipLayer(root->id()); | 1576 scroll->SetScrollClipLayer(root->id()); |
| 1600 scroll->SetScrollOffset(gfx::ScrollOffset()); | 1577 scroll->SetScrollOffset(gfx::ScrollOffset()); |
| 1601 scroll->SetBounds(content_size); | 1578 scroll->SetBounds(content_size); |
| 1602 scroll->SetContentBounds(content_size); | 1579 scroll->SetContentBounds(content_size); |
| 1603 scroll->SetIsContainerForFixedPositionLayers(true); | 1580 scroll->SetIsContainerForFixedPositionLayers(true); |
| 1604 | 1581 |
| 1605 scoped_ptr<LayerImpl> contents = | 1582 scoped_ptr<LayerImpl> contents = |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1791 | 1768 |
| 1792 TEST_F(LayerTreeHostImplTest, WillDrawReturningFalseDoesNotCall) { | 1769 TEST_F(LayerTreeHostImplTest, WillDrawReturningFalseDoesNotCall) { |
| 1793 // The root layer is always drawn, so run this test on a child layer that | 1770 // The root layer is always drawn, so run this test on a child layer that |
| 1794 // will be masked out by the root layer's bounds. | 1771 // will be masked out by the root layer's bounds. |
| 1795 host_impl_->active_tree()->SetRootLayer( | 1772 host_impl_->active_tree()->SetRootLayer( |
| 1796 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 1773 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
| 1797 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( | 1774 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( |
| 1798 host_impl_->active_tree()->root_layer()); | 1775 host_impl_->active_tree()->root_layer()); |
| 1799 | 1776 |
| 1800 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 1777 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
| 1778 root->SetHasRenderSurface(true); |
| 1801 DidDrawCheckLayer* layer = | 1779 DidDrawCheckLayer* layer = |
| 1802 static_cast<DidDrawCheckLayer*>(root->children()[0]); | 1780 static_cast<DidDrawCheckLayer*>(root->children()[0]); |
| 1803 | 1781 |
| 1804 { | 1782 { |
| 1805 LayerTreeHostImpl::FrameData frame; | 1783 LayerTreeHostImpl::FrameData frame; |
| 1806 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 1784 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 1807 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 1785 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 1808 host_impl_->DidDrawAllLayers(frame); | 1786 host_impl_->DidDrawAllLayers(frame); |
| 1809 | 1787 |
| 1810 EXPECT_TRUE(layer->will_draw_called()); | 1788 EXPECT_TRUE(layer->will_draw_called()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1831 } | 1809 } |
| 1832 | 1810 |
| 1833 TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) { | 1811 TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) { |
| 1834 // The root layer is always drawn, so run this test on a child layer that | 1812 // The root layer is always drawn, so run this test on a child layer that |
| 1835 // will be masked out by the root layer's bounds. | 1813 // will be masked out by the root layer's bounds. |
| 1836 host_impl_->active_tree()->SetRootLayer( | 1814 host_impl_->active_tree()->SetRootLayer( |
| 1837 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 1815 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
| 1838 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( | 1816 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( |
| 1839 host_impl_->active_tree()->root_layer()); | 1817 host_impl_->active_tree()->root_layer()); |
| 1840 root->SetMasksToBounds(true); | 1818 root->SetMasksToBounds(true); |
| 1841 | 1819 root->SetHasRenderSurface(true); |
| 1842 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 1820 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
| 1843 DidDrawCheckLayer* layer = | 1821 DidDrawCheckLayer* layer = |
| 1844 static_cast<DidDrawCheckLayer*>(root->children()[0]); | 1822 static_cast<DidDrawCheckLayer*>(root->children()[0]); |
| 1845 // Ensure visible_content_rect for layer is empty. | 1823 // Ensure visible_content_rect for layer is empty. |
| 1846 layer->SetPosition(gfx::PointF(100.f, 100.f)); | 1824 layer->SetPosition(gfx::PointF(100.f, 100.f)); |
| 1847 layer->SetBounds(gfx::Size(10, 10)); | 1825 layer->SetBounds(gfx::Size(10, 10)); |
| 1848 layer->SetContentBounds(gfx::Size(10, 10)); | 1826 layer->SetContentBounds(gfx::Size(10, 10)); |
| 1849 | 1827 |
| 1850 LayerTreeHostImpl::FrameData frame; | 1828 LayerTreeHostImpl::FrameData frame; |
| 1851 | 1829 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1884 host_impl_->active_tree()->SetRootLayer( | 1862 host_impl_->active_tree()->SetRootLayer( |
| 1885 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 1863 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
| 1886 DidDrawCheckLayer* root = | 1864 DidDrawCheckLayer* root = |
| 1887 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 1865 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 1888 | 1866 |
| 1889 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 1867 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
| 1890 DidDrawCheckLayer* occluded_layer = | 1868 DidDrawCheckLayer* occluded_layer = |
| 1891 static_cast<DidDrawCheckLayer*>(root->children()[0]); | 1869 static_cast<DidDrawCheckLayer*>(root->children()[0]); |
| 1892 | 1870 |
| 1893 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); | 1871 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); |
| 1872 root->SetHasRenderSurface(true); |
| 1894 DidDrawCheckLayer* top_layer = | 1873 DidDrawCheckLayer* top_layer = |
| 1895 static_cast<DidDrawCheckLayer*>(root->children()[1]); | 1874 static_cast<DidDrawCheckLayer*>(root->children()[1]); |
| 1896 // This layer covers the occluded_layer above. Make this layer large so it can | 1875 // This layer covers the occluded_layer above. Make this layer large so it can |
| 1897 // occlude. | 1876 // occlude. |
| 1898 top_layer->SetBounds(big_size); | 1877 top_layer->SetBounds(big_size); |
| 1899 top_layer->SetContentBounds(big_size); | 1878 top_layer->SetContentBounds(big_size); |
| 1900 top_layer->SetContentsOpaque(true); | 1879 top_layer->SetContentsOpaque(true); |
| 1901 | 1880 |
| 1902 LayerTreeHostImpl::FrameData frame; | 1881 LayerTreeHostImpl::FrameData frame; |
| 1903 | 1882 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1916 EXPECT_TRUE(top_layer->did_draw_called()); | 1895 EXPECT_TRUE(top_layer->did_draw_called()); |
| 1917 } | 1896 } |
| 1918 | 1897 |
| 1919 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { | 1898 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { |
| 1920 host_impl_->active_tree()->SetRootLayer( | 1899 host_impl_->active_tree()->SetRootLayer( |
| 1921 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 1900 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
| 1922 DidDrawCheckLayer* root = | 1901 DidDrawCheckLayer* root = |
| 1923 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 1902 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 1924 | 1903 |
| 1925 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 1904 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
| 1905 root->SetHasRenderSurface(true); |
| 1926 DidDrawCheckLayer* layer1 = | 1906 DidDrawCheckLayer* layer1 = |
| 1927 static_cast<DidDrawCheckLayer*>(root->children()[0]); | 1907 static_cast<DidDrawCheckLayer*>(root->children()[0]); |
| 1928 | 1908 |
| 1929 layer1->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); | 1909 layer1->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); |
| 1930 DidDrawCheckLayer* layer2 = | 1910 DidDrawCheckLayer* layer2 = |
| 1931 static_cast<DidDrawCheckLayer*>(layer1->children()[0]); | 1911 static_cast<DidDrawCheckLayer*>(layer1->children()[0]); |
| 1932 | 1912 |
| 1933 layer1->SetOpacity(0.3f); | 1913 layer1->SetHasRenderSurface(true); |
| 1934 layer1->SetShouldFlattenTransform(true); | 1914 layer1->SetShouldFlattenTransform(true); |
| 1935 | 1915 |
| 1936 EXPECT_FALSE(root->did_draw_called()); | 1916 EXPECT_FALSE(root->did_draw_called()); |
| 1937 EXPECT_FALSE(layer1->did_draw_called()); | 1917 EXPECT_FALSE(layer1->did_draw_called()); |
| 1938 EXPECT_FALSE(layer2->did_draw_called()); | 1918 EXPECT_FALSE(layer2->did_draw_called()); |
| 1939 | 1919 |
| 1940 LayerTreeHostImpl::FrameData frame; | 1920 LayerTreeHostImpl::FrameData frame; |
| 1941 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( | 1921 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( |
| 1942 host_impl_->active_tree()->root_layer()); | 1922 host_impl_->active_tree()->root_layer()); |
| 1943 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 1923 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1995 | 1975 |
| 1996 bool tile_missing_; | 1976 bool tile_missing_; |
| 1997 bool had_incomplete_tile_; | 1977 bool had_incomplete_tile_; |
| 1998 }; | 1978 }; |
| 1999 | 1979 |
| 2000 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsOnDefault) { | 1980 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsOnDefault) { |
| 2001 host_impl_->active_tree()->SetRootLayer( | 1981 host_impl_->active_tree()->SetRootLayer( |
| 2002 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 1982 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
| 2003 DidDrawCheckLayer* root = | 1983 DidDrawCheckLayer* root = |
| 2004 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 1984 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 2005 | 1985 root->SetHasRenderSurface(true); |
| 2006 bool tile_missing = false; | 1986 bool tile_missing = false; |
| 2007 bool had_incomplete_tile = false; | 1987 bool had_incomplete_tile = false; |
| 2008 bool is_animating = false; | 1988 bool is_animating = false; |
| 2009 root->AddChild( | 1989 root->AddChild( |
| 2010 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 1990 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
| 2011 2, | 1991 2, |
| 2012 tile_missing, | 1992 tile_missing, |
| 2013 had_incomplete_tile, | 1993 had_incomplete_tile, |
| 2014 is_animating, | 1994 is_animating, |
| 2015 host_impl_->resource_provider())); | 1995 host_impl_->resource_provider())); |
| 2016 | 1996 |
| 2017 LayerTreeHostImpl::FrameData frame; | 1997 LayerTreeHostImpl::FrameData frame; |
| 2018 | 1998 |
| 2019 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 1999 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 2020 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2000 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2021 host_impl_->DidDrawAllLayers(frame); | 2001 host_impl_->DidDrawAllLayers(frame); |
| 2022 } | 2002 } |
| 2023 | 2003 |
| 2024 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithAnimatedLayer) { | 2004 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithAnimatedLayer) { |
| 2025 host_impl_->active_tree()->SetRootLayer( | 2005 host_impl_->active_tree()->SetRootLayer( |
| 2026 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 2006 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
| 2027 DidDrawCheckLayer* root = | 2007 DidDrawCheckLayer* root = |
| 2028 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2008 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 2009 root->SetHasRenderSurface(true); |
| 2029 bool tile_missing = false; | 2010 bool tile_missing = false; |
| 2030 bool had_incomplete_tile = false; | 2011 bool had_incomplete_tile = false; |
| 2031 bool is_animating = true; | 2012 bool is_animating = true; |
| 2032 root->AddChild( | 2013 root->AddChild( |
| 2033 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 2014 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
| 2034 2, | 2015 2, |
| 2035 tile_missing, | 2016 tile_missing, |
| 2036 had_incomplete_tile, | 2017 had_incomplete_tile, |
| 2037 is_animating, | 2018 is_animating, |
| 2038 host_impl_->resource_provider())); | 2019 host_impl_->resource_provider())); |
| 2039 | 2020 |
| 2040 LayerTreeHostImpl::FrameData frame; | 2021 LayerTreeHostImpl::FrameData frame; |
| 2041 | 2022 |
| 2042 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2023 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 2043 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2024 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2044 host_impl_->DidDrawAllLayers(frame); | 2025 host_impl_->DidDrawAllLayers(frame); |
| 2045 } | 2026 } |
| 2046 | 2027 |
| 2047 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithMissingTiles) { | 2028 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithMissingTiles) { |
| 2048 host_impl_->active_tree()->SetRootLayer( | 2029 host_impl_->active_tree()->SetRootLayer( |
| 2049 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); | 2030 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); |
| 2050 DidDrawCheckLayer* root = | 2031 DidDrawCheckLayer* root = |
| 2051 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2032 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 2033 root->SetHasRenderSurface(true); |
| 2052 | 2034 |
| 2053 LayerTreeHostImpl::FrameData frame; | 2035 LayerTreeHostImpl::FrameData frame; |
| 2054 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2036 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 2055 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2037 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2056 host_impl_->DidDrawAllLayers(frame); | 2038 host_impl_->DidDrawAllLayers(frame); |
| 2057 host_impl_->SwapBuffers(frame); | 2039 host_impl_->SwapBuffers(frame); |
| 2058 | 2040 |
| 2059 bool tile_missing = true; | 2041 bool tile_missing = true; |
| 2060 bool had_incomplete_tile = false; | 2042 bool had_incomplete_tile = false; |
| 2061 bool is_animating = false; | 2043 bool is_animating = false; |
| 2062 root->AddChild( | 2044 root->AddChild( |
| 2063 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 2045 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
| 2064 4, | 2046 4, |
| 2065 tile_missing, | 2047 tile_missing, |
| 2066 had_incomplete_tile, | 2048 had_incomplete_tile, |
| 2067 is_animating, | 2049 is_animating, |
| 2068 host_impl_->resource_provider())); | 2050 host_impl_->resource_provider())); |
| 2069 LayerTreeHostImpl::FrameData frame2; | 2051 LayerTreeHostImpl::FrameData frame2; |
| 2070 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame2)); | 2052 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame2)); |
| 2071 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); | 2053 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); |
| 2072 host_impl_->DidDrawAllLayers(frame2); | 2054 host_impl_->DidDrawAllLayers(frame2); |
| 2073 } | 2055 } |
| 2074 | 2056 |
| 2075 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithIncompleteTile) { | 2057 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithIncompleteTile) { |
| 2076 host_impl_->active_tree()->SetRootLayer( | 2058 host_impl_->active_tree()->SetRootLayer( |
| 2077 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); | 2059 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); |
| 2078 DidDrawCheckLayer* root = | 2060 DidDrawCheckLayer* root = |
| 2079 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2061 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 2062 root->SetHasRenderSurface(true); |
| 2080 | 2063 |
| 2081 LayerTreeHostImpl::FrameData frame; | 2064 LayerTreeHostImpl::FrameData frame; |
| 2082 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2065 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 2083 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2066 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2084 host_impl_->DidDrawAllLayers(frame); | 2067 host_impl_->DidDrawAllLayers(frame); |
| 2085 host_impl_->SwapBuffers(frame); | 2068 host_impl_->SwapBuffers(frame); |
| 2086 | 2069 |
| 2087 bool tile_missing = false; | 2070 bool tile_missing = false; |
| 2088 bool had_incomplete_tile = true; | 2071 bool had_incomplete_tile = true; |
| 2089 bool is_animating = false; | 2072 bool is_animating = false; |
| 2090 root->AddChild( | 2073 root->AddChild( |
| 2091 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 2074 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
| 2092 4, | 2075 4, |
| 2093 tile_missing, | 2076 tile_missing, |
| 2094 had_incomplete_tile, | 2077 had_incomplete_tile, |
| 2095 is_animating, | 2078 is_animating, |
| 2096 host_impl_->resource_provider())); | 2079 host_impl_->resource_provider())); |
| 2097 LayerTreeHostImpl::FrameData frame2; | 2080 LayerTreeHostImpl::FrameData frame2; |
| 2098 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame2)); | 2081 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame2)); |
| 2099 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); | 2082 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); |
| 2100 host_impl_->DidDrawAllLayers(frame2); | 2083 host_impl_->DidDrawAllLayers(frame2); |
| 2101 } | 2084 } |
| 2102 | 2085 |
| 2103 TEST_F(LayerTreeHostImplTest, | 2086 TEST_F(LayerTreeHostImplTest, |
| 2104 PrepareToDrawFailsWithAnimationAndMissingTilesUsesCheckerboard) { | 2087 PrepareToDrawFailsWithAnimationAndMissingTilesUsesCheckerboard) { |
| 2105 host_impl_->active_tree()->SetRootLayer( | 2088 host_impl_->active_tree()->SetRootLayer( |
| 2106 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); | 2089 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); |
| 2107 DidDrawCheckLayer* root = | 2090 DidDrawCheckLayer* root = |
| 2108 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2091 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 2092 root->SetHasRenderSurface(true); |
| 2109 | 2093 |
| 2110 LayerTreeHostImpl::FrameData frame; | 2094 LayerTreeHostImpl::FrameData frame; |
| 2111 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2095 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 2112 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2096 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2113 host_impl_->DidDrawAllLayers(frame); | 2097 host_impl_->DidDrawAllLayers(frame); |
| 2114 host_impl_->SwapBuffers(frame); | 2098 host_impl_->SwapBuffers(frame); |
| 2115 | 2099 |
| 2116 bool tile_missing = true; | 2100 bool tile_missing = true; |
| 2117 bool had_incomplete_tile = false; | 2101 bool had_incomplete_tile = false; |
| 2118 bool is_animating = true; | 2102 bool is_animating = true; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2129 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); | 2113 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); |
| 2130 host_impl_->DidDrawAllLayers(frame2); | 2114 host_impl_->DidDrawAllLayers(frame2); |
| 2131 } | 2115 } |
| 2132 | 2116 |
| 2133 TEST_F(LayerTreeHostImplTest, | 2117 TEST_F(LayerTreeHostImplTest, |
| 2134 PrepareToDrawSucceedsWithAnimationAndIncompleteTiles) { | 2118 PrepareToDrawSucceedsWithAnimationAndIncompleteTiles) { |
| 2135 host_impl_->active_tree()->SetRootLayer( | 2119 host_impl_->active_tree()->SetRootLayer( |
| 2136 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); | 2120 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); |
| 2137 DidDrawCheckLayer* root = | 2121 DidDrawCheckLayer* root = |
| 2138 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2122 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 2123 root->SetHasRenderSurface(true); |
| 2139 | 2124 |
| 2140 LayerTreeHostImpl::FrameData frame; | 2125 LayerTreeHostImpl::FrameData frame; |
| 2141 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2126 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 2142 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2127 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2143 host_impl_->DidDrawAllLayers(frame); | 2128 host_impl_->DidDrawAllLayers(frame); |
| 2144 host_impl_->SwapBuffers(frame); | 2129 host_impl_->SwapBuffers(frame); |
| 2145 | 2130 |
| 2146 bool tile_missing = false; | 2131 bool tile_missing = false; |
| 2147 bool had_incomplete_tile = true; | 2132 bool had_incomplete_tile = true; |
| 2148 bool is_animating = true; | 2133 bool is_animating = true; |
| 2149 root->AddChild( | 2134 root->AddChild( |
| 2150 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 2135 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
| 2151 6, | 2136 6, |
| 2152 tile_missing, | 2137 tile_missing, |
| 2153 had_incomplete_tile, | 2138 had_incomplete_tile, |
| 2154 is_animating, | 2139 is_animating, |
| 2155 host_impl_->resource_provider())); | 2140 host_impl_->resource_provider())); |
| 2156 LayerTreeHostImpl::FrameData frame2; | 2141 LayerTreeHostImpl::FrameData frame2; |
| 2157 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame2)); | 2142 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame2)); |
| 2158 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); | 2143 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); |
| 2159 host_impl_->DidDrawAllLayers(frame2); | 2144 host_impl_->DidDrawAllLayers(frame2); |
| 2160 } | 2145 } |
| 2161 | 2146 |
| 2162 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWhenHighResRequired) { | 2147 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWhenHighResRequired) { |
| 2163 host_impl_->active_tree()->SetRootLayer( | 2148 host_impl_->active_tree()->SetRootLayer( |
| 2164 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); | 2149 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); |
| 2165 DidDrawCheckLayer* root = | 2150 DidDrawCheckLayer* root = |
| 2166 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2151 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 2152 root->SetHasRenderSurface(true); |
| 2167 | 2153 |
| 2168 LayerTreeHostImpl::FrameData frame; | 2154 LayerTreeHostImpl::FrameData frame; |
| 2169 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2155 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 2170 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2156 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2171 host_impl_->DidDrawAllLayers(frame); | 2157 host_impl_->DidDrawAllLayers(frame); |
| 2172 host_impl_->SwapBuffers(frame); | 2158 host_impl_->SwapBuffers(frame); |
| 2173 | 2159 |
| 2174 bool tile_missing = false; | 2160 bool tile_missing = false; |
| 2175 bool had_incomplete_tile = false; | 2161 bool had_incomplete_tile = false; |
| 2176 bool is_animating = false; | 2162 bool is_animating = false; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2187 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); | 2173 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); |
| 2188 host_impl_->DidDrawAllLayers(frame2); | 2174 host_impl_->DidDrawAllLayers(frame2); |
| 2189 } | 2175 } |
| 2190 | 2176 |
| 2191 TEST_F(LayerTreeHostImplTest, | 2177 TEST_F(LayerTreeHostImplTest, |
| 2192 PrepareToDrawFailsWhenHighResRequiredAndIncompleteTiles) { | 2178 PrepareToDrawFailsWhenHighResRequiredAndIncompleteTiles) { |
| 2193 host_impl_->active_tree()->SetRootLayer( | 2179 host_impl_->active_tree()->SetRootLayer( |
| 2194 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); | 2180 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); |
| 2195 DidDrawCheckLayer* root = | 2181 DidDrawCheckLayer* root = |
| 2196 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2182 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 2183 root->SetHasRenderSurface(true); |
| 2197 | 2184 |
| 2198 LayerTreeHostImpl::FrameData frame; | 2185 LayerTreeHostImpl::FrameData frame; |
| 2199 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2186 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 2200 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2187 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2201 host_impl_->DidDrawAllLayers(frame); | 2188 host_impl_->DidDrawAllLayers(frame); |
| 2202 host_impl_->SwapBuffers(frame); | 2189 host_impl_->SwapBuffers(frame); |
| 2203 | 2190 |
| 2204 bool tile_missing = false; | 2191 bool tile_missing = false; |
| 2205 bool had_incomplete_tile = true; | 2192 bool had_incomplete_tile = true; |
| 2206 bool is_animating = false; | 2193 bool is_animating = false; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2218 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); | 2205 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); |
| 2219 host_impl_->DidDrawAllLayers(frame2); | 2206 host_impl_->DidDrawAllLayers(frame2); |
| 2220 } | 2207 } |
| 2221 | 2208 |
| 2222 TEST_F(LayerTreeHostImplTest, | 2209 TEST_F(LayerTreeHostImplTest, |
| 2223 PrepareToDrawFailsWhenHighResRequiredAndMissingTile) { | 2210 PrepareToDrawFailsWhenHighResRequiredAndMissingTile) { |
| 2224 host_impl_->active_tree()->SetRootLayer( | 2211 host_impl_->active_tree()->SetRootLayer( |
| 2225 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); | 2212 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); |
| 2226 DidDrawCheckLayer* root = | 2213 DidDrawCheckLayer* root = |
| 2227 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2214 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 2215 root->SetHasRenderSurface(true); |
| 2228 | 2216 |
| 2229 LayerTreeHostImpl::FrameData frame; | 2217 LayerTreeHostImpl::FrameData frame; |
| 2230 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2218 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 2231 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2219 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2232 host_impl_->DidDrawAllLayers(frame); | 2220 host_impl_->DidDrawAllLayers(frame); |
| 2233 host_impl_->SwapBuffers(frame); | 2221 host_impl_->SwapBuffers(frame); |
| 2234 | 2222 |
| 2235 bool tile_missing = true; | 2223 bool tile_missing = true; |
| 2236 bool had_incomplete_tile = false; | 2224 bool had_incomplete_tile = false; |
| 2237 bool is_animating = false; | 2225 bool is_animating = false; |
| 2238 root->AddChild( | 2226 root->AddChild( |
| 2239 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 2227 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
| 2240 8, | 2228 8, |
| 2241 tile_missing, | 2229 tile_missing, |
| 2242 had_incomplete_tile, | 2230 had_incomplete_tile, |
| 2243 is_animating, | 2231 is_animating, |
| 2244 host_impl_->resource_provider())); | 2232 host_impl_->resource_provider())); |
| 2245 host_impl_->SetRequiresHighResToDraw(); | 2233 host_impl_->SetRequiresHighResToDraw(); |
| 2246 LayerTreeHostImpl::FrameData frame2; | 2234 LayerTreeHostImpl::FrameData frame2; |
| 2247 EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT, | 2235 EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT, |
| 2248 host_impl_->PrepareToDraw(&frame2)); | 2236 host_impl_->PrepareToDraw(&frame2)); |
| 2249 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); | 2237 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); |
| 2250 host_impl_->DidDrawAllLayers(frame2); | 2238 host_impl_->DidDrawAllLayers(frame2); |
| 2251 } | 2239 } |
| 2252 | 2240 |
| 2253 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { | 2241 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { |
| 2254 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 2242 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 2255 root->SetScrollClipLayer(Layer::INVALID_ID); | 2243 root->SetScrollClipLayer(Layer::INVALID_ID); |
| 2244 root->SetHasRenderSurface(true); |
| 2256 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 2245 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 2257 DrawFrame(); | 2246 DrawFrame(); |
| 2258 | 2247 |
| 2259 // Scroll event is ignored because layer is not scrollable. | 2248 // Scroll event is ignored because layer is not scrollable. |
| 2260 EXPECT_EQ(InputHandler::ScrollIgnored, | 2249 EXPECT_EQ(InputHandler::ScrollIgnored, |
| 2261 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); | 2250 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
| 2262 EXPECT_FALSE(did_request_redraw_); | 2251 EXPECT_FALSE(did_request_redraw_); |
| 2263 EXPECT_FALSE(did_request_commit_); | 2252 EXPECT_FALSE(did_request_commit_); |
| 2264 } | 2253 } |
| 2265 | 2254 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2287 LayerImpl::Create(host_impl_->active_tree(), 2); | 2276 LayerImpl::Create(host_impl_->active_tree(), 2); |
| 2288 root_clip->SetBounds(clip_size_); | 2277 root_clip->SetBounds(clip_size_); |
| 2289 root->SetScrollClipLayer(root_clip->id()); | 2278 root->SetScrollClipLayer(root_clip->id()); |
| 2290 root->SetBounds(layer_size_); | 2279 root->SetBounds(layer_size_); |
| 2291 root->SetContentBounds(layer_size_); | 2280 root->SetContentBounds(layer_size_); |
| 2292 root->SetPosition(gfx::PointF()); | 2281 root->SetPosition(gfx::PointF()); |
| 2293 root->SetDrawsContent(false); | 2282 root->SetDrawsContent(false); |
| 2294 root->SetIsContainerForFixedPositionLayers(true); | 2283 root->SetIsContainerForFixedPositionLayers(true); |
| 2295 int inner_viewport_scroll_layer_id = root->id(); | 2284 int inner_viewport_scroll_layer_id = root->id(); |
| 2296 int page_scale_layer_id = root_clip->id(); | 2285 int page_scale_layer_id = root_clip->id(); |
| 2286 root_clip->SetHasRenderSurface(true); |
| 2297 root_clip->AddChild(root.Pass()); | 2287 root_clip->AddChild(root.Pass()); |
| 2288 root_clip->SetHasRenderSurface(true); |
| 2298 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 2289 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); |
| 2299 host_impl_->active_tree()->SetViewportLayersFromIds( | 2290 host_impl_->active_tree()->SetViewportLayersFromIds( |
| 2300 Layer::INVALID_ID, page_scale_layer_id, inner_viewport_scroll_layer_id, | 2291 Layer::INVALID_ID, page_scale_layer_id, inner_viewport_scroll_layer_id, |
| 2301 Layer::INVALID_ID); | 2292 Layer::INVALID_ID); |
| 2302 // Set a viewport size that is large enough to contain both the top controls | 2293 // Set a viewport size that is large enough to contain both the top controls |
| 2303 // and some content. | 2294 // and some content. |
| 2304 host_impl_->SetViewportSize(viewport_size_); | 2295 host_impl_->SetViewportSize(viewport_size_); |
| 2305 host_impl_->SetTopControlsLayoutHeight( | 2296 host_impl_->SetTopControlsLayoutHeight( |
| 2306 settings_.top_controls_height); | 2297 settings_.top_controls_height); |
| 2307 | 2298 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2351 scoped_ptr<LayerImpl> outer_clip = | 2342 scoped_ptr<LayerImpl> outer_clip = |
| 2352 LayerImpl::Create(host_impl_->active_tree(), 5); | 2343 LayerImpl::Create(host_impl_->active_tree(), 5); |
| 2353 | 2344 |
| 2354 root_clip->SetBounds(inner_viewport_size); | 2345 root_clip->SetBounds(inner_viewport_size); |
| 2355 root->SetScrollClipLayer(root_clip->id()); | 2346 root->SetScrollClipLayer(root_clip->id()); |
| 2356 root->SetBounds(outer_viewport_size); | 2347 root->SetBounds(outer_viewport_size); |
| 2357 root->SetContentBounds(outer_viewport_size); | 2348 root->SetContentBounds(outer_viewport_size); |
| 2358 root->SetPosition(gfx::PointF()); | 2349 root->SetPosition(gfx::PointF()); |
| 2359 root->SetDrawsContent(false); | 2350 root->SetDrawsContent(false); |
| 2360 root->SetIsContainerForFixedPositionLayers(true); | 2351 root->SetIsContainerForFixedPositionLayers(true); |
| 2361 | 2352 root_clip->SetHasRenderSurface(true); |
| 2362 outer_clip->SetBounds(outer_viewport_size); | 2353 outer_clip->SetBounds(outer_viewport_size); |
| 2363 outer_scroll->SetScrollClipLayer(outer_clip->id()); | 2354 outer_scroll->SetScrollClipLayer(outer_clip->id()); |
| 2364 outer_scroll->SetBounds(scroll_layer_size); | 2355 outer_scroll->SetBounds(scroll_layer_size); |
| 2365 outer_scroll->SetContentBounds(scroll_layer_size); | 2356 outer_scroll->SetContentBounds(scroll_layer_size); |
| 2366 outer_scroll->SetPosition(gfx::PointF()); | 2357 outer_scroll->SetPosition(gfx::PointF()); |
| 2367 outer_scroll->SetDrawsContent(false); | 2358 outer_scroll->SetDrawsContent(false); |
| 2368 outer_scroll->SetIsContainerForFixedPositionLayers(true); | 2359 outer_scroll->SetIsContainerForFixedPositionLayers(true); |
| 2369 | 2360 |
| 2370 int inner_viewport_scroll_layer_id = root->id(); | 2361 int inner_viewport_scroll_layer_id = root->id(); |
| 2371 int outer_viewport_scroll_layer_id = outer_scroll->id(); | 2362 int outer_viewport_scroll_layer_id = outer_scroll->id(); |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2877 | 2868 |
| 2878 scoped_ptr<LayerImpl> scroll_layer = | 2869 scoped_ptr<LayerImpl> scroll_layer = |
| 2879 LayerImpl::Create(host_impl_->active_tree(), 2); | 2870 LayerImpl::Create(host_impl_->active_tree(), 2); |
| 2880 scroll_layer->SetScrollClipLayer(3); | 2871 scroll_layer->SetScrollClipLayer(3); |
| 2881 scroll_layer->SetBounds(contents_size); | 2872 scroll_layer->SetBounds(contents_size); |
| 2882 scroll_layer->SetContentBounds(contents_size); | 2873 scroll_layer->SetContentBounds(contents_size); |
| 2883 scroll_layer->SetPosition(gfx::PointF()); | 2874 scroll_layer->SetPosition(gfx::PointF()); |
| 2884 scroll_layer->AddChild(content_layer.Pass()); | 2875 scroll_layer->AddChild(content_layer.Pass()); |
| 2885 scroll_clip_layer->AddChild(scroll_layer.Pass()); | 2876 scroll_clip_layer->AddChild(scroll_layer.Pass()); |
| 2886 | 2877 |
| 2878 scroll_clip_layer->SetHasRenderSurface(true); |
| 2887 host_impl_->active_tree()->SetRootLayer(scroll_clip_layer.Pass()); | 2879 host_impl_->active_tree()->SetRootLayer(scroll_clip_layer.Pass()); |
| 2888 host_impl_->SetViewportSize(surface_size); | 2880 host_impl_->SetViewportSize(surface_size); |
| 2889 DrawFrame(); | 2881 DrawFrame(); |
| 2890 | 2882 |
| 2891 EXPECT_EQ(InputHandler::ScrollStarted, | 2883 EXPECT_EQ(InputHandler::ScrollStarted, |
| 2892 host_impl_->ScrollBegin(gfx::Point(5, 5), | 2884 host_impl_->ScrollBegin(gfx::Point(5, 5), |
| 2893 InputHandler::Wheel)); | 2885 InputHandler::Wheel)); |
| 2894 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 2886 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
| 2895 host_impl_->ScrollEnd(); | 2887 host_impl_->ScrollEnd(); |
| 2896 EXPECT_TRUE(did_request_redraw_); | 2888 EXPECT_TRUE(did_request_redraw_); |
| 2897 EXPECT_TRUE(did_request_commit_); | 2889 EXPECT_TRUE(did_request_commit_); |
| 2898 } | 2890 } |
| 2899 | 2891 |
| 2900 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) { | 2892 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) { |
| 2901 gfx::Size surface_size(10, 10); | 2893 gfx::Size surface_size(10, 10); |
| 2902 gfx::Size contents_size(20, 20); | 2894 gfx::Size contents_size(20, 20); |
| 2903 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 2895 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 2904 root->SetBounds(surface_size); | 2896 root->SetBounds(surface_size); |
| 2905 root->SetContentBounds(contents_size); | 2897 root->SetContentBounds(contents_size); |
| 2906 root->AddChild(CreateScrollableLayer(2, contents_size, root.get())); | 2898 root->AddChild(CreateScrollableLayer(2, contents_size, root.get())); |
| 2899 root->SetHasRenderSurface(true); |
| 2907 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 2900 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 2908 host_impl_->SetViewportSize(surface_size); | 2901 host_impl_->SetViewportSize(surface_size); |
| 2909 DrawFrame(); | 2902 DrawFrame(); |
| 2910 | 2903 |
| 2911 EXPECT_EQ(InputHandler::ScrollStarted, | 2904 EXPECT_EQ(InputHandler::ScrollStarted, |
| 2912 host_impl_->ScrollBegin(gfx::Point(5, 5), | 2905 host_impl_->ScrollBegin(gfx::Point(5, 5), |
| 2913 InputHandler::Wheel)); | 2906 InputHandler::Wheel)); |
| 2914 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 2907 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
| 2915 host_impl_->ScrollEnd(); | 2908 host_impl_->ScrollEnd(); |
| 2916 EXPECT_TRUE(did_request_redraw_); | 2909 EXPECT_TRUE(did_request_redraw_); |
| 2917 EXPECT_TRUE(did_request_commit_); | 2910 EXPECT_TRUE(did_request_commit_); |
| 2918 } | 2911 } |
| 2919 | 2912 |
| 2920 TEST_F(LayerTreeHostImplTest, ScrollMissesChild) { | 2913 TEST_F(LayerTreeHostImplTest, ScrollMissesChild) { |
| 2921 gfx::Size surface_size(10, 10); | 2914 gfx::Size surface_size(10, 10); |
| 2922 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 2915 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 2923 root->AddChild(CreateScrollableLayer(2, surface_size, root.get())); | 2916 root->AddChild(CreateScrollableLayer(2, surface_size, root.get())); |
| 2917 root->SetHasRenderSurface(true); |
| 2924 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 2918 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 2925 host_impl_->SetViewportSize(surface_size); | 2919 host_impl_->SetViewportSize(surface_size); |
| 2926 DrawFrame(); | 2920 DrawFrame(); |
| 2927 | 2921 |
| 2928 // Scroll event is ignored because the input coordinate is outside the layer | 2922 // Scroll event is ignored because the input coordinate is outside the layer |
| 2929 // boundaries. | 2923 // boundaries. |
| 2930 EXPECT_EQ(InputHandler::ScrollIgnored, | 2924 EXPECT_EQ(InputHandler::ScrollIgnored, |
| 2931 host_impl_->ScrollBegin(gfx::Point(15, 5), | 2925 host_impl_->ScrollBegin(gfx::Point(15, 5), |
| 2932 InputHandler::Wheel)); | 2926 InputHandler::Wheel)); |
| 2933 EXPECT_FALSE(did_request_redraw_); | 2927 EXPECT_FALSE(did_request_redraw_); |
| 2934 EXPECT_FALSE(did_request_commit_); | 2928 EXPECT_FALSE(did_request_commit_); |
| 2935 } | 2929 } |
| 2936 | 2930 |
| 2937 TEST_F(LayerTreeHostImplTest, ScrollMissesBackfacingChild) { | 2931 TEST_F(LayerTreeHostImplTest, ScrollMissesBackfacingChild) { |
| 2938 gfx::Size surface_size(10, 10); | 2932 gfx::Size surface_size(10, 10); |
| 2939 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 2933 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 2934 root->SetHasRenderSurface(true); |
| 2940 scoped_ptr<LayerImpl> child = | 2935 scoped_ptr<LayerImpl> child = |
| 2941 CreateScrollableLayer(2, surface_size, root.get()); | 2936 CreateScrollableLayer(2, surface_size, root.get()); |
| 2942 host_impl_->SetViewportSize(surface_size); | 2937 host_impl_->SetViewportSize(surface_size); |
| 2943 | 2938 |
| 2944 gfx::Transform matrix; | 2939 gfx::Transform matrix; |
| 2945 matrix.RotateAboutXAxis(180.0); | 2940 matrix.RotateAboutXAxis(180.0); |
| 2946 child->SetTransform(matrix); | 2941 child->SetTransform(matrix); |
| 2947 child->SetDoubleSided(false); | 2942 child->SetDoubleSided(false); |
| 2948 | 2943 |
| 2949 root->AddChild(child.Pass()); | 2944 root->AddChild(child.Pass()); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2967 CreateScrollableLayer(1, surface_size, clip_layer.get()); | 2962 CreateScrollableLayer(1, surface_size, clip_layer.get()); |
| 2968 content_layer->SetShouldScrollOnMainThread(true); | 2963 content_layer->SetShouldScrollOnMainThread(true); |
| 2969 content_layer->SetScrollClipLayer(Layer::INVALID_ID); | 2964 content_layer->SetScrollClipLayer(Layer::INVALID_ID); |
| 2970 | 2965 |
| 2971 // Note: we can use the same clip layer for both since both calls to | 2966 // Note: we can use the same clip layer for both since both calls to |
| 2972 // CreateScrollableLayer() use the same surface size. | 2967 // CreateScrollableLayer() use the same surface size. |
| 2973 scoped_ptr<LayerImpl> scroll_layer = | 2968 scoped_ptr<LayerImpl> scroll_layer = |
| 2974 CreateScrollableLayer(2, surface_size, clip_layer.get()); | 2969 CreateScrollableLayer(2, surface_size, clip_layer.get()); |
| 2975 scroll_layer->AddChild(content_layer.Pass()); | 2970 scroll_layer->AddChild(content_layer.Pass()); |
| 2976 clip_layer->AddChild(scroll_layer.Pass()); | 2971 clip_layer->AddChild(scroll_layer.Pass()); |
| 2972 clip_layer->SetHasRenderSurface(true); |
| 2977 | 2973 |
| 2978 host_impl_->active_tree()->SetRootLayer(clip_layer.Pass()); | 2974 host_impl_->active_tree()->SetRootLayer(clip_layer.Pass()); |
| 2979 host_impl_->SetViewportSize(surface_size); | 2975 host_impl_->SetViewportSize(surface_size); |
| 2980 DrawFrame(); | 2976 DrawFrame(); |
| 2981 | 2977 |
| 2982 // Scrolling fails because the content layer is asking to be scrolled on the | 2978 // Scrolling fails because the content layer is asking to be scrolled on the |
| 2983 // main thread. | 2979 // main thread. |
| 2984 EXPECT_EQ(InputHandler::ScrollOnMainThread, | 2980 EXPECT_EQ(InputHandler::ScrollOnMainThread, |
| 2985 host_impl_->ScrollBegin(gfx::Point(5, 5), | 2981 host_impl_->ScrollBegin(gfx::Point(5, 5), |
| 2986 InputHandler::Wheel)); | 2982 InputHandler::Wheel)); |
| 2987 } | 2983 } |
| 2988 | 2984 |
| 2989 TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnMainThread) { | 2985 TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnMainThread) { |
| 2990 gfx::Size surface_size(20, 20); | 2986 gfx::Size surface_size(20, 20); |
| 2991 gfx::Size viewport_size(10, 10); | 2987 gfx::Size viewport_size(10, 10); |
| 2992 float page_scale = 2.f; | 2988 float page_scale = 2.f; |
| 2993 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 2989 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 2994 scoped_ptr<LayerImpl> root_clip = | 2990 scoped_ptr<LayerImpl> root_clip = |
| 2995 LayerImpl::Create(host_impl_->active_tree(), 2); | 2991 LayerImpl::Create(host_impl_->active_tree(), 2); |
| 2996 scoped_ptr<LayerImpl> root_scrolling = | 2992 scoped_ptr<LayerImpl> root_scrolling = |
| 2997 CreateScrollableLayer(3, surface_size, root_clip.get()); | 2993 CreateScrollableLayer(3, surface_size, root_clip.get()); |
| 2998 EXPECT_EQ(viewport_size, root_clip->bounds()); | 2994 EXPECT_EQ(viewport_size, root_clip->bounds()); |
| 2999 root_scrolling->SetIsContainerForFixedPositionLayers(true); | 2995 root_scrolling->SetIsContainerForFixedPositionLayers(true); |
| 3000 root_clip->AddChild(root_scrolling.Pass()); | 2996 root_clip->AddChild(root_scrolling.Pass()); |
| 3001 root->AddChild(root_clip.Pass()); | 2997 root->AddChild(root_clip.Pass()); |
| 2998 root->SetHasRenderSurface(true); |
| 3002 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 2999 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 3003 // The behaviour in this test assumes the page scale is applied at a layer | 3000 // The behaviour in this test assumes the page scale is applied at a layer |
| 3004 // above the clip layer. | 3001 // above the clip layer. |
| 3005 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3, | 3002 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3, |
| 3006 Layer::INVALID_ID); | 3003 Layer::INVALID_ID); |
| 3007 host_impl_->active_tree()->DidBecomeActive(); | 3004 host_impl_->active_tree()->DidBecomeActive(); |
| 3008 host_impl_->SetViewportSize(viewport_size); | 3005 host_impl_->SetViewportSize(viewport_size); |
| 3009 DrawFrame(); | 3006 DrawFrame(); |
| 3010 | 3007 |
| 3011 LayerImpl* root_scroll = | 3008 LayerImpl* root_scroll = |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3043 float page_scale = 2.f; | 3040 float page_scale = 2.f; |
| 3044 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 3041 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 3045 scoped_ptr<LayerImpl> root_clip = | 3042 scoped_ptr<LayerImpl> root_clip = |
| 3046 LayerImpl::Create(host_impl_->active_tree(), 2); | 3043 LayerImpl::Create(host_impl_->active_tree(), 2); |
| 3047 scoped_ptr<LayerImpl> root_scrolling = | 3044 scoped_ptr<LayerImpl> root_scrolling = |
| 3048 CreateScrollableLayer(3, surface_size, root_clip.get()); | 3045 CreateScrollableLayer(3, surface_size, root_clip.get()); |
| 3049 EXPECT_EQ(viewport_size, root_clip->bounds()); | 3046 EXPECT_EQ(viewport_size, root_clip->bounds()); |
| 3050 root_scrolling->SetIsContainerForFixedPositionLayers(true); | 3047 root_scrolling->SetIsContainerForFixedPositionLayers(true); |
| 3051 root_clip->AddChild(root_scrolling.Pass()); | 3048 root_clip->AddChild(root_scrolling.Pass()); |
| 3052 root->AddChild(root_clip.Pass()); | 3049 root->AddChild(root_clip.Pass()); |
| 3050 root->SetHasRenderSurface(true); |
| 3053 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 3051 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 3054 // The behaviour in this test assumes the page scale is applied at a layer | 3052 // The behaviour in this test assumes the page scale is applied at a layer |
| 3055 // above the clip layer. | 3053 // above the clip layer. |
| 3056 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3, | 3054 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3, |
| 3057 Layer::INVALID_ID); | 3055 Layer::INVALID_ID); |
| 3058 host_impl_->active_tree()->DidBecomeActive(); | 3056 host_impl_->active_tree()->DidBecomeActive(); |
| 3059 host_impl_->SetViewportSize(viewport_size); | 3057 host_impl_->SetViewportSize(viewport_size); |
| 3060 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 1.f, page_scale); | 3058 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 1.f, page_scale); |
| 3061 DrawFrame(); | 3059 DrawFrame(); |
| 3062 | 3060 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3148 EXPECT_EQ(new_page_scale, | 3146 EXPECT_EQ(new_page_scale, |
| 3149 grand_child->draw_transform().matrix().getDouble(0, 0)); | 3147 grand_child->draw_transform().matrix().getDouble(0, 0)); |
| 3150 EXPECT_EQ(new_page_scale, | 3148 EXPECT_EQ(new_page_scale, |
| 3151 grand_child->draw_transform().matrix().getDouble(1, 1)); | 3149 grand_child->draw_transform().matrix().getDouble(1, 1)); |
| 3152 } | 3150 } |
| 3153 | 3151 |
| 3154 TEST_F(LayerTreeHostImplTest, ScrollChildAndChangePageScaleOnMainThread) { | 3152 TEST_F(LayerTreeHostImplTest, ScrollChildAndChangePageScaleOnMainThread) { |
| 3155 gfx::Size surface_size(30, 30); | 3153 gfx::Size surface_size(30, 30); |
| 3156 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 3154 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 3157 root->SetBounds(gfx::Size(5, 5)); | 3155 root->SetBounds(gfx::Size(5, 5)); |
| 3156 root->SetHasRenderSurface(true); |
| 3158 scoped_ptr<LayerImpl> root_scrolling = | 3157 scoped_ptr<LayerImpl> root_scrolling = |
| 3159 LayerImpl::Create(host_impl_->active_tree(), 2); | 3158 LayerImpl::Create(host_impl_->active_tree(), 2); |
| 3160 root_scrolling->SetBounds(surface_size); | 3159 root_scrolling->SetBounds(surface_size); |
| 3161 root_scrolling->SetContentBounds(surface_size); | 3160 root_scrolling->SetContentBounds(surface_size); |
| 3162 root_scrolling->SetScrollClipLayer(root->id()); | 3161 root_scrolling->SetScrollClipLayer(root->id()); |
| 3163 root_scrolling->SetIsContainerForFixedPositionLayers(true); | 3162 root_scrolling->SetIsContainerForFixedPositionLayers(true); |
| 3164 LayerImpl* root_scrolling_ptr = root_scrolling.get(); | 3163 LayerImpl* root_scrolling_ptr = root_scrolling.get(); |
| 3165 root->AddChild(root_scrolling.Pass()); | 3164 root->AddChild(root_scrolling.Pass()); |
| 3166 int child_scroll_layer_id = 3; | 3165 int child_scroll_layer_id = 3; |
| 3167 scoped_ptr<LayerImpl> child_scrolling = CreateScrollableLayer( | 3166 scoped_ptr<LayerImpl> child_scrolling = CreateScrollableLayer( |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3204 } | 3203 } |
| 3205 | 3204 |
| 3206 TEST_F(LayerTreeHostImplTest, ScrollChildBeyondLimit) { | 3205 TEST_F(LayerTreeHostImplTest, ScrollChildBeyondLimit) { |
| 3207 // Scroll a child layer beyond its maximum scroll range and make sure the | 3206 // Scroll a child layer beyond its maximum scroll range and make sure the |
| 3208 // parent layer is scrolled on the axis on which the child was unable to | 3207 // parent layer is scrolled on the axis on which the child was unable to |
| 3209 // scroll. | 3208 // scroll. |
| 3210 gfx::Size surface_size(10, 10); | 3209 gfx::Size surface_size(10, 10); |
| 3211 gfx::Size content_size(20, 20); | 3210 gfx::Size content_size(20, 20); |
| 3212 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 3211 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 3213 root->SetBounds(surface_size); | 3212 root->SetBounds(surface_size); |
| 3214 | 3213 root->SetHasRenderSurface(true); |
| 3215 scoped_ptr<LayerImpl> grand_child = | 3214 scoped_ptr<LayerImpl> grand_child = |
| 3216 CreateScrollableLayer(3, content_size, root.get()); | 3215 CreateScrollableLayer(3, content_size, root.get()); |
| 3217 | 3216 |
| 3218 scoped_ptr<LayerImpl> child = | 3217 scoped_ptr<LayerImpl> child = |
| 3219 CreateScrollableLayer(2, content_size, root.get()); | 3218 CreateScrollableLayer(2, content_size, root.get()); |
| 3220 LayerImpl* grand_child_layer = grand_child.get(); | 3219 LayerImpl* grand_child_layer = grand_child.get(); |
| 3221 child->AddChild(grand_child.Pass()); | 3220 child->AddChild(grand_child.Pass()); |
| 3222 | 3221 |
| 3223 LayerImpl* child_layer = child.get(); | 3222 LayerImpl* child_layer = child.get(); |
| 3224 root->AddChild(child.Pass()); | 3223 root->AddChild(child.Pass()); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 3249 ExpectContains(*scroll_info.get(), child->id(), gfx::Vector2d(-3, 0)); | 3248 ExpectContains(*scroll_info.get(), child->id(), gfx::Vector2d(-3, 0)); |
| 3250 } | 3249 } |
| 3251 } | 3250 } |
| 3252 | 3251 |
| 3253 TEST_F(LayerTreeHostImplTest, ScrollWithoutBubbling) { | 3252 TEST_F(LayerTreeHostImplTest, ScrollWithoutBubbling) { |
| 3254 // Scroll a child layer beyond its maximum scroll range and make sure the | 3253 // Scroll a child layer beyond its maximum scroll range and make sure the |
| 3255 // the scroll doesn't bubble up to the parent layer. | 3254 // the scroll doesn't bubble up to the parent layer. |
| 3256 gfx::Size surface_size(20, 20); | 3255 gfx::Size surface_size(20, 20); |
| 3257 gfx::Size viewport_size(10, 10); | 3256 gfx::Size viewport_size(10, 10); |
| 3258 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 3257 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 3258 root->SetHasRenderSurface(true); |
| 3259 scoped_ptr<LayerImpl> root_scrolling = | 3259 scoped_ptr<LayerImpl> root_scrolling = |
| 3260 CreateScrollableLayer(2, surface_size, root.get()); | 3260 CreateScrollableLayer(2, surface_size, root.get()); |
| 3261 root_scrolling->SetIsContainerForFixedPositionLayers(true); | 3261 root_scrolling->SetIsContainerForFixedPositionLayers(true); |
| 3262 | 3262 |
| 3263 scoped_ptr<LayerImpl> grand_child = | 3263 scoped_ptr<LayerImpl> grand_child = |
| 3264 CreateScrollableLayer(4, surface_size, root.get()); | 3264 CreateScrollableLayer(4, surface_size, root.get()); |
| 3265 | 3265 |
| 3266 scoped_ptr<LayerImpl> child = | 3266 scoped_ptr<LayerImpl> child = |
| 3267 CreateScrollableLayer(3, surface_size, root.get()); | 3267 CreateScrollableLayer(3, surface_size, root.get()); |
| 3268 LayerImpl* grand_child_layer = grand_child.get(); | 3268 LayerImpl* grand_child_layer = grand_child.get(); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3358 ExpectContains(*scroll_info.get(), grand_child->id(), gfx::Vector2d(0, 4)); | 3358 ExpectContains(*scroll_info.get(), grand_child->id(), gfx::Vector2d(0, 4)); |
| 3359 } | 3359 } |
| 3360 } | 3360 } |
| 3361 TEST_F(LayerTreeHostImplTest, ScrollEventBubbling) { | 3361 TEST_F(LayerTreeHostImplTest, ScrollEventBubbling) { |
| 3362 // When we try to scroll a non-scrollable child layer, the scroll delta | 3362 // When we try to scroll a non-scrollable child layer, the scroll delta |
| 3363 // should be applied to one of its ancestors if possible. | 3363 // should be applied to one of its ancestors if possible. |
| 3364 gfx::Size surface_size(10, 10); | 3364 gfx::Size surface_size(10, 10); |
| 3365 gfx::Size content_size(20, 20); | 3365 gfx::Size content_size(20, 20); |
| 3366 scoped_ptr<LayerImpl> root_clip = | 3366 scoped_ptr<LayerImpl> root_clip = |
| 3367 LayerImpl::Create(host_impl_->active_tree(), 3); | 3367 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 3368 root_clip->SetHasRenderSurface(true); |
| 3368 scoped_ptr<LayerImpl> root = | 3369 scoped_ptr<LayerImpl> root = |
| 3369 CreateScrollableLayer(1, content_size, root_clip.get()); | 3370 CreateScrollableLayer(1, content_size, root_clip.get()); |
| 3370 // Make 'root' the clip layer for child: since they have the same sizes the | 3371 // Make 'root' the clip layer for child: since they have the same sizes the |
| 3371 // child will have zero max_scroll_offset and scrolls will bubble. | 3372 // child will have zero max_scroll_offset and scrolls will bubble. |
| 3372 scoped_ptr<LayerImpl> child = | 3373 scoped_ptr<LayerImpl> child = |
| 3373 CreateScrollableLayer(2, content_size, root.get()); | 3374 CreateScrollableLayer(2, content_size, root.get()); |
| 3374 child->SetIsContainerForFixedPositionLayers(true); | 3375 child->SetIsContainerForFixedPositionLayers(true); |
| 3375 root->SetBounds(content_size); | 3376 root->SetBounds(content_size); |
| 3376 | 3377 |
| 3377 int root_scroll_id = root->id(); | 3378 int root_scroll_id = root->id(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 3401 } | 3402 } |
| 3402 } | 3403 } |
| 3403 | 3404 |
| 3404 TEST_F(LayerTreeHostImplTest, ScrollBeforeRedraw) { | 3405 TEST_F(LayerTreeHostImplTest, ScrollBeforeRedraw) { |
| 3405 gfx::Size surface_size(10, 10); | 3406 gfx::Size surface_size(10, 10); |
| 3406 scoped_ptr<LayerImpl> root_clip = | 3407 scoped_ptr<LayerImpl> root_clip = |
| 3407 LayerImpl::Create(host_impl_->active_tree(), 1); | 3408 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 3408 scoped_ptr<LayerImpl> root_scroll = | 3409 scoped_ptr<LayerImpl> root_scroll = |
| 3409 CreateScrollableLayer(2, surface_size, root_clip.get()); | 3410 CreateScrollableLayer(2, surface_size, root_clip.get()); |
| 3410 root_scroll->SetIsContainerForFixedPositionLayers(true); | 3411 root_scroll->SetIsContainerForFixedPositionLayers(true); |
| 3412 root_clip->SetHasRenderSurface(true); |
| 3411 root_clip->AddChild(root_scroll.Pass()); | 3413 root_clip->AddChild(root_scroll.Pass()); |
| 3412 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 3414 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); |
| 3413 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 2, | 3415 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 2, |
| 3414 Layer::INVALID_ID); | 3416 Layer::INVALID_ID); |
| 3415 host_impl_->active_tree()->DidBecomeActive(); | 3417 host_impl_->active_tree()->DidBecomeActive(); |
| 3416 host_impl_->SetViewportSize(surface_size); | 3418 host_impl_->SetViewportSize(surface_size); |
| 3417 | 3419 |
| 3418 // Draw one frame and then immediately rebuild the layer tree to mimic a tree | 3420 // Draw one frame and then immediately rebuild the layer tree to mimic a tree |
| 3419 // synchronization. | 3421 // synchronization. |
| 3420 DrawFrame(); | 3422 DrawFrame(); |
| 3421 host_impl_->active_tree()->DetachLayerTree(); | 3423 host_impl_->active_tree()->DetachLayerTree(); |
| 3422 scoped_ptr<LayerImpl> root_clip2 = | 3424 scoped_ptr<LayerImpl> root_clip2 = |
| 3423 LayerImpl::Create(host_impl_->active_tree(), 3); | 3425 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 3424 scoped_ptr<LayerImpl> root_scroll2 = | 3426 scoped_ptr<LayerImpl> root_scroll2 = |
| 3425 CreateScrollableLayer(4, surface_size, root_clip2.get()); | 3427 CreateScrollableLayer(4, surface_size, root_clip2.get()); |
| 3426 root_scroll2->SetIsContainerForFixedPositionLayers(true); | 3428 root_scroll2->SetIsContainerForFixedPositionLayers(true); |
| 3427 root_clip2->AddChild(root_scroll2.Pass()); | 3429 root_clip2->AddChild(root_scroll2.Pass()); |
| 3430 root_clip2->SetHasRenderSurface(true); |
| 3428 host_impl_->active_tree()->SetRootLayer(root_clip2.Pass()); | 3431 host_impl_->active_tree()->SetRootLayer(root_clip2.Pass()); |
| 3429 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 3, 4, | 3432 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 3, 4, |
| 3430 Layer::INVALID_ID); | 3433 Layer::INVALID_ID); |
| 3431 host_impl_->active_tree()->DidBecomeActive(); | 3434 host_impl_->active_tree()->DidBecomeActive(); |
| 3432 | 3435 |
| 3433 // Scrolling should still work even though we did not draw yet. | 3436 // Scrolling should still work even though we did not draw yet. |
| 3434 EXPECT_EQ(InputHandler::ScrollStarted, | 3437 EXPECT_EQ(InputHandler::ScrollStarted, |
| 3435 host_impl_->ScrollBegin(gfx::Point(5, 5), | 3438 host_impl_->ScrollBegin(gfx::Point(5, 5), |
| 3436 InputHandler::Wheel)); | 3439 InputHandler::Wheel)); |
| 3437 } | 3440 } |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3932 host_impl_->ScrollEnd(); | 3935 host_impl_->ScrollEnd(); |
| 3933 } | 3936 } |
| 3934 | 3937 |
| 3935 | 3938 |
| 3936 TEST_F(LayerTreeHostImplTest, OverscrollChildWithoutBubbling) { | 3939 TEST_F(LayerTreeHostImplTest, OverscrollChildWithoutBubbling) { |
| 3937 // Scroll child layers beyond their maximum scroll range and make sure root | 3940 // Scroll child layers beyond their maximum scroll range and make sure root |
| 3938 // overscroll does not accumulate. | 3941 // overscroll does not accumulate. |
| 3939 gfx::Size surface_size(10, 10); | 3942 gfx::Size surface_size(10, 10); |
| 3940 scoped_ptr<LayerImpl> root_clip = | 3943 scoped_ptr<LayerImpl> root_clip = |
| 3941 LayerImpl::Create(host_impl_->active_tree(), 4); | 3944 LayerImpl::Create(host_impl_->active_tree(), 4); |
| 3945 root_clip->SetHasRenderSurface(true); |
| 3946 |
| 3942 scoped_ptr<LayerImpl> root = | 3947 scoped_ptr<LayerImpl> root = |
| 3943 CreateScrollableLayer(1, surface_size, root_clip.get()); | 3948 CreateScrollableLayer(1, surface_size, root_clip.get()); |
| 3944 | 3949 |
| 3945 scoped_ptr<LayerImpl> grand_child = | 3950 scoped_ptr<LayerImpl> grand_child = |
| 3946 CreateScrollableLayer(3, surface_size, root_clip.get()); | 3951 CreateScrollableLayer(3, surface_size, root_clip.get()); |
| 3947 | 3952 |
| 3948 scoped_ptr<LayerImpl> child = | 3953 scoped_ptr<LayerImpl> child = |
| 3949 CreateScrollableLayer(2, surface_size, root_clip.get()); | 3954 CreateScrollableLayer(2, surface_size, root_clip.get()); |
| 3950 LayerImpl* grand_child_layer = grand_child.get(); | 3955 LayerImpl* grand_child_layer = grand_child.get(); |
| 3951 child->AddChild(grand_child.Pass()); | 3956 child->AddChild(grand_child.Pass()); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3996 } | 4001 } |
| 3997 | 4002 |
| 3998 TEST_F(LayerTreeHostImplTest, OverscrollChildEventBubbling) { | 4003 TEST_F(LayerTreeHostImplTest, OverscrollChildEventBubbling) { |
| 3999 // When we try to scroll a non-scrollable child layer, the scroll delta | 4004 // When we try to scroll a non-scrollable child layer, the scroll delta |
| 4000 // should be applied to one of its ancestors if possible. Overscroll should | 4005 // should be applied to one of its ancestors if possible. Overscroll should |
| 4001 // be reflected only when it has bubbled up to the root scrolling layer. | 4006 // be reflected only when it has bubbled up to the root scrolling layer. |
| 4002 gfx::Size surface_size(10, 10); | 4007 gfx::Size surface_size(10, 10); |
| 4003 gfx::Size content_size(20, 20); | 4008 gfx::Size content_size(20, 20); |
| 4004 scoped_ptr<LayerImpl> root_clip = | 4009 scoped_ptr<LayerImpl> root_clip = |
| 4005 LayerImpl::Create(host_impl_->active_tree(), 3); | 4010 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 4011 root_clip->SetHasRenderSurface(true); |
| 4012 |
| 4006 scoped_ptr<LayerImpl> root = | 4013 scoped_ptr<LayerImpl> root = |
| 4007 CreateScrollableLayer(1, content_size, root_clip.get()); | 4014 CreateScrollableLayer(1, content_size, root_clip.get()); |
| 4008 root->SetIsContainerForFixedPositionLayers(true); | 4015 root->SetIsContainerForFixedPositionLayers(true); |
| 4009 scoped_ptr<LayerImpl> child = | 4016 scoped_ptr<LayerImpl> child = |
| 4010 CreateScrollableLayer(2, content_size, root_clip.get()); | 4017 CreateScrollableLayer(2, content_size, root_clip.get()); |
| 4011 | 4018 |
| 4012 child->SetScrollClipLayer(Layer::INVALID_ID); | 4019 child->SetScrollClipLayer(Layer::INVALID_ID); |
| 4013 root->AddChild(child.Pass()); | 4020 root->AddChild(child.Pass()); |
| 4014 root_clip->AddChild(root.Pass()); | 4021 root_clip->AddChild(root.Pass()); |
| 4015 | 4022 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4052 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 4059 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
| 4053 EXPECT_EQ(gfx::Vector2dF(0, 10), host_impl_->accumulated_root_overscroll()); | 4060 EXPECT_EQ(gfx::Vector2dF(0, 10), host_impl_->accumulated_root_overscroll()); |
| 4054 } | 4061 } |
| 4055 | 4062 |
| 4056 TEST_F(LayerTreeHostImplTest, NoOverscrollOnFractionalDeviceScale) { | 4063 TEST_F(LayerTreeHostImplTest, NoOverscrollOnFractionalDeviceScale) { |
| 4057 gfx::Size surface_size(980, 1439); | 4064 gfx::Size surface_size(980, 1439); |
| 4058 gfx::Size content_size(980, 1438); | 4065 gfx::Size content_size(980, 1438); |
| 4059 float device_scale_factor = 1.5f; | 4066 float device_scale_factor = 1.5f; |
| 4060 scoped_ptr<LayerImpl> root_clip = | 4067 scoped_ptr<LayerImpl> root_clip = |
| 4061 LayerImpl::Create(host_impl_->active_tree(), 3); | 4068 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 4069 root_clip->SetHasRenderSurface(true); |
| 4070 |
| 4062 scoped_ptr<LayerImpl> root = | 4071 scoped_ptr<LayerImpl> root = |
| 4063 CreateScrollableLayer(1, content_size, root_clip.get()); | 4072 CreateScrollableLayer(1, content_size, root_clip.get()); |
| 4064 root->SetIsContainerForFixedPositionLayers(true); | 4073 root->SetIsContainerForFixedPositionLayers(true); |
| 4065 scoped_ptr<LayerImpl> child = | 4074 scoped_ptr<LayerImpl> child = |
| 4066 CreateScrollableLayer(2, content_size, root_clip.get()); | 4075 CreateScrollableLayer(2, content_size, root_clip.get()); |
| 4067 root->scroll_clip_layer()->SetBounds(gfx::Size(320, 469)); | 4076 root->scroll_clip_layer()->SetBounds(gfx::Size(320, 469)); |
| 4068 host_impl_->active_tree()->SetPageScaleFactorAndLimits( | 4077 host_impl_->active_tree()->SetPageScaleFactorAndLimits( |
| 4069 0.326531f, 0.326531f, 5.f); | 4078 0.326531f, 0.326531f, 5.f); |
| 4070 host_impl_->active_tree()->SetPageScaleDelta(1.f); | 4079 host_impl_->active_tree()->SetPageScaleDelta(1.f); |
| 4071 child->SetScrollClipLayer(Layer::INVALID_ID); | 4080 child->SetScrollClipLayer(Layer::INVALID_ID); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 4091 | 4100 |
| 4092 host_impl_->ScrollEnd(); | 4101 host_impl_->ScrollEnd(); |
| 4093 } | 4102 } |
| 4094 } | 4103 } |
| 4095 | 4104 |
| 4096 TEST_F(LayerTreeHostImplTest, NoOverscrollWhenNotAtEdge) { | 4105 TEST_F(LayerTreeHostImplTest, NoOverscrollWhenNotAtEdge) { |
| 4097 gfx::Size surface_size(100, 100); | 4106 gfx::Size surface_size(100, 100); |
| 4098 gfx::Size content_size(200, 200); | 4107 gfx::Size content_size(200, 200); |
| 4099 scoped_ptr<LayerImpl> root_clip = | 4108 scoped_ptr<LayerImpl> root_clip = |
| 4100 LayerImpl::Create(host_impl_->active_tree(), 3); | 4109 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 4110 root_clip->SetHasRenderSurface(true); |
| 4111 |
| 4101 scoped_ptr<LayerImpl> root = | 4112 scoped_ptr<LayerImpl> root = |
| 4102 CreateScrollableLayer(1, content_size, root_clip.get()); | 4113 CreateScrollableLayer(1, content_size, root_clip.get()); |
| 4103 root->SetIsContainerForFixedPositionLayers(true); | 4114 root->SetIsContainerForFixedPositionLayers(true); |
| 4104 scoped_ptr<LayerImpl> child = | 4115 scoped_ptr<LayerImpl> child = |
| 4105 CreateScrollableLayer(2, content_size, root_clip.get()); | 4116 CreateScrollableLayer(2, content_size, root_clip.get()); |
| 4106 | 4117 |
| 4107 child->SetScrollClipLayer(Layer::INVALID_ID); | 4118 child->SetScrollClipLayer(Layer::INVALID_ID); |
| 4108 root->AddChild(child.Pass()); | 4119 root->AddChild(child.Pass()); |
| 4109 root_clip->AddChild(root.Pass()); | 4120 root_clip->AddChild(root.Pass()); |
| 4110 | 4121 |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4236 ResourceProvider::ResourceId resource_id_; | 4247 ResourceProvider::ResourceId resource_id_; |
| 4237 }; | 4248 }; |
| 4238 | 4249 |
| 4239 TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { | 4250 TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { |
| 4240 { | 4251 { |
| 4241 scoped_ptr<LayerImpl> root = | 4252 scoped_ptr<LayerImpl> root = |
| 4242 LayerImpl::Create(host_impl_->active_tree(), 1); | 4253 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 4243 root->SetBounds(gfx::Size(10, 10)); | 4254 root->SetBounds(gfx::Size(10, 10)); |
| 4244 root->SetContentBounds(root->bounds()); | 4255 root->SetContentBounds(root->bounds()); |
| 4245 root->SetDrawsContent(false); | 4256 root->SetDrawsContent(false); |
| 4257 root->SetHasRenderSurface(true); |
| 4246 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 4258 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 4247 } | 4259 } |
| 4248 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 4260 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 4249 | 4261 |
| 4250 root->AddChild( | 4262 root->AddChild( |
| 4251 BlendStateCheckLayer::Create(host_impl_->active_tree(), | 4263 BlendStateCheckLayer::Create(host_impl_->active_tree(), |
| 4252 2, | 4264 2, |
| 4253 host_impl_->resource_provider())); | 4265 host_impl_->resource_provider())); |
| 4254 BlendStateCheckLayer* layer1 = | 4266 BlendStateCheckLayer* layer1 = |
| 4255 static_cast<BlendStateCheckLayer*>(root->children()[0]); | 4267 static_cast<BlendStateCheckLayer*>(root->children()[0]); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4345 EXPECT_TRUE(layer2->quads_appended()); | 4357 EXPECT_TRUE(layer2->quads_appended()); |
| 4346 host_impl_->DidDrawAllLayers(frame); | 4358 host_impl_->DidDrawAllLayers(frame); |
| 4347 | 4359 |
| 4348 // Parent layer with translucent opacity and opaque content. Since it has a | 4360 // Parent layer with translucent opacity and opaque content. Since it has a |
| 4349 // drawing child, it's drawn to a render surface which carries the opacity, | 4361 // drawing child, it's drawn to a render surface which carries the opacity, |
| 4350 // so it's itself drawn without blending. | 4362 // so it's itself drawn without blending. |
| 4351 // Child layer with opaque content, drawn without blending (parent surface | 4363 // Child layer with opaque content, drawn without blending (parent surface |
| 4352 // carries the inherited opacity). | 4364 // carries the inherited opacity). |
| 4353 layer1->SetContentsOpaque(true); | 4365 layer1->SetContentsOpaque(true); |
| 4354 layer1->SetOpacity(0.5f); | 4366 layer1->SetOpacity(0.5f); |
| 4367 layer1->SetHasRenderSurface(true); |
| 4355 layer1->SetExpectation(false, true); | 4368 layer1->SetExpectation(false, true); |
| 4356 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); | 4369 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); |
| 4357 layer2->SetExpectation(false, false); | 4370 layer2->SetExpectation(false, false); |
| 4358 layer2->SetUpdateRect(gfx::Rect(layer1->content_bounds())); | 4371 layer2->SetUpdateRect(gfx::Rect(layer1->content_bounds())); |
| 4359 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( | 4372 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( |
| 4360 host_impl_->active_tree()->root_layer()); | 4373 host_impl_->active_tree()->root_layer()); |
| 4361 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4374 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 4362 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 4375 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 4363 EXPECT_TRUE(layer1->quads_appended()); | 4376 EXPECT_TRUE(layer1->quads_appended()); |
| 4364 EXPECT_TRUE(layer2->quads_appended()); | 4377 EXPECT_TRUE(layer2->quads_appended()); |
| 4365 host_impl_->DidDrawAllLayers(frame); | 4378 host_impl_->DidDrawAllLayers(frame); |
| 4379 layer1->SetHasRenderSurface(false); |
| 4366 | 4380 |
| 4367 // Draw again, but with child non-opaque, to make sure | 4381 // Draw again, but with child non-opaque, to make sure |
| 4368 // layer1 not culled. | 4382 // layer1 not culled. |
| 4369 layer1->SetContentsOpaque(true); | 4383 layer1->SetContentsOpaque(true); |
| 4370 layer1->SetOpacity(1.f); | 4384 layer1->SetOpacity(1.f); |
| 4371 layer1->SetExpectation(false, false); | 4385 layer1->SetExpectation(false, false); |
| 4372 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); | 4386 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); |
| 4373 layer2->SetContentsOpaque(true); | 4387 layer2->SetContentsOpaque(true); |
| 4374 layer2->SetOpacity(0.5f); | 4388 layer2->SetOpacity(0.5f); |
| 4375 layer2->SetExpectation(true, false); | 4389 layer2->SetExpectation(true, false); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4472 if (always_draw) { | 4486 if (always_draw) { |
| 4473 return FakeOutputSurface::CreateAlwaysDrawAndSwap3d(); | 4487 return FakeOutputSurface::CreateAlwaysDrawAndSwap3d(); |
| 4474 } | 4488 } |
| 4475 return FakeOutputSurface::Create3d(); | 4489 return FakeOutputSurface::Create3d(); |
| 4476 } | 4490 } |
| 4477 | 4491 |
| 4478 void SetupActiveTreeLayers() { | 4492 void SetupActiveTreeLayers() { |
| 4479 host_impl_->active_tree()->set_background_color(SK_ColorGRAY); | 4493 host_impl_->active_tree()->set_background_color(SK_ColorGRAY); |
| 4480 host_impl_->active_tree()->SetRootLayer( | 4494 host_impl_->active_tree()->SetRootLayer( |
| 4481 LayerImpl::Create(host_impl_->active_tree(), 1)); | 4495 LayerImpl::Create(host_impl_->active_tree(), 1)); |
| 4496 host_impl_->active_tree()->root_layer()->SetHasRenderSurface(true); |
| 4482 host_impl_->active_tree()->root_layer()->AddChild( | 4497 host_impl_->active_tree()->root_layer()->AddChild( |
| 4483 BlendStateCheckLayer::Create(host_impl_->active_tree(), | 4498 BlendStateCheckLayer::Create(host_impl_->active_tree(), |
| 4484 2, | 4499 2, |
| 4485 host_impl_->resource_provider())); | 4500 host_impl_->resource_provider())); |
| 4486 child_ = static_cast<BlendStateCheckLayer*>( | 4501 child_ = static_cast<BlendStateCheckLayer*>( |
| 4487 host_impl_->active_tree()->root_layer()->children()[0]); | 4502 host_impl_->active_tree()->root_layer()->children()[0]); |
| 4488 child_->SetExpectation(false, false); | 4503 child_->SetExpectation(false, false); |
| 4489 child_->SetContentsOpaque(true); | 4504 child_->SetContentsOpaque(true); |
| 4490 } | 4505 } |
| 4491 | 4506 |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4762 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); | 4777 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); |
| 4763 scoped_ptr<OutputSurface> output_surface( | 4778 scoped_ptr<OutputSurface> output_surface( |
| 4764 FakeOutputSurface::Create3d(provider)); | 4779 FakeOutputSurface::Create3d(provider)); |
| 4765 CreateHostImpl(DefaultSettings(), output_surface.Pass()); | 4780 CreateHostImpl(DefaultSettings(), output_surface.Pass()); |
| 4766 | 4781 |
| 4767 scoped_ptr<LayerImpl> root = | 4782 scoped_ptr<LayerImpl> root = |
| 4768 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); | 4783 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); |
| 4769 root->SetBounds(gfx::Size(10, 10)); | 4784 root->SetBounds(gfx::Size(10, 10)); |
| 4770 root->SetContentBounds(gfx::Size(10, 10)); | 4785 root->SetContentBounds(gfx::Size(10, 10)); |
| 4771 root->SetDrawsContent(true); | 4786 root->SetDrawsContent(true); |
| 4787 root->SetHasRenderSurface(true); |
| 4772 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 4788 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 4773 EXPECT_FALSE(provider->TestContext3d()->reshape_called()); | 4789 EXPECT_FALSE(provider->TestContext3d()->reshape_called()); |
| 4774 provider->TestContext3d()->clear_reshape_called(); | 4790 provider->TestContext3d()->clear_reshape_called(); |
| 4775 | 4791 |
| 4776 LayerTreeHostImpl::FrameData frame; | 4792 LayerTreeHostImpl::FrameData frame; |
| 4777 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 4793 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
| 4778 host_impl_->SetDeviceScaleFactor(1.f); | 4794 host_impl_->SetDeviceScaleFactor(1.f); |
| 4779 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4795 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 4780 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 4796 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 4781 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); | 4797 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4830 &proxy_, | 4846 &proxy_, |
| 4831 &stats_instrumentation_, | 4847 &stats_instrumentation_, |
| 4832 shared_bitmap_manager.get(), | 4848 shared_bitmap_manager.get(), |
| 4833 NULL, | 4849 NULL, |
| 4834 0); | 4850 0); |
| 4835 layer_tree_host_impl->InitializeRenderer(output_surface.Pass()); | 4851 layer_tree_host_impl->InitializeRenderer(output_surface.Pass()); |
| 4836 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); | 4852 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); |
| 4837 | 4853 |
| 4838 scoped_ptr<LayerImpl> root = | 4854 scoped_ptr<LayerImpl> root = |
| 4839 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); | 4855 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); |
| 4856 root->SetHasRenderSurface(true); |
| 4840 scoped_ptr<LayerImpl> child = | 4857 scoped_ptr<LayerImpl> child = |
| 4841 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); | 4858 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); |
| 4842 child->SetPosition(gfx::PointF(12.f, 13.f)); | 4859 child->SetPosition(gfx::PointF(12.f, 13.f)); |
| 4843 child->SetBounds(gfx::Size(14, 15)); | 4860 child->SetBounds(gfx::Size(14, 15)); |
| 4844 child->SetContentBounds(gfx::Size(14, 15)); | 4861 child->SetContentBounds(gfx::Size(14, 15)); |
| 4845 child->SetDrawsContent(true); | 4862 child->SetDrawsContent(true); |
| 4846 root->SetBounds(gfx::Size(500, 500)); | 4863 root->SetBounds(gfx::Size(500, 500)); |
| 4847 root->SetContentBounds(gfx::Size(500, 500)); | 4864 root->SetContentBounds(gfx::Size(500, 500)); |
| 4848 root->SetDrawsContent(true); | 4865 root->SetDrawsContent(true); |
| 4849 root->AddChild(child.Pass()); | 4866 root->AddChild(child.Pass()); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4896 scoped_ptr<LayerImpl> root = | 4913 scoped_ptr<LayerImpl> root = |
| 4897 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); | 4914 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); |
| 4898 scoped_ptr<LayerImpl> child = | 4915 scoped_ptr<LayerImpl> child = |
| 4899 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2); | 4916 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2); |
| 4900 child->SetBounds(gfx::Size(10, 10)); | 4917 child->SetBounds(gfx::Size(10, 10)); |
| 4901 child->SetContentBounds(gfx::Size(10, 10)); | 4918 child->SetContentBounds(gfx::Size(10, 10)); |
| 4902 child->SetDrawsContent(true); | 4919 child->SetDrawsContent(true); |
| 4903 root->SetBounds(gfx::Size(10, 10)); | 4920 root->SetBounds(gfx::Size(10, 10)); |
| 4904 root->SetContentBounds(gfx::Size(10, 10)); | 4921 root->SetContentBounds(gfx::Size(10, 10)); |
| 4905 root->SetDrawsContent(true); | 4922 root->SetDrawsContent(true); |
| 4906 root->SetForceRenderSurface(true); | 4923 root->SetHasRenderSurface(true); |
| 4907 root->AddChild(child.Pass()); | 4924 root->AddChild(child.Pass()); |
| 4908 | 4925 |
| 4909 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 4926 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 4910 | 4927 |
| 4911 LayerTreeHostImpl::FrameData frame; | 4928 LayerTreeHostImpl::FrameData frame; |
| 4912 | 4929 |
| 4913 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4930 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 4914 EXPECT_EQ(1u, frame.render_surface_layer_list->size()); | 4931 EXPECT_EQ(1u, frame.render_surface_layer_list->size()); |
| 4915 EXPECT_EQ(1u, frame.render_passes.size()); | 4932 EXPECT_EQ(1u, frame.render_passes.size()); |
| 4916 host_impl_->DidDrawAllLayers(frame); | 4933 host_impl_->DidDrawAllLayers(frame); |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5145 LayerImpl::Create(my_host_impl->active_tree(), 1); | 5162 LayerImpl::Create(my_host_impl->active_tree(), 1); |
| 5146 scoped_ptr<LayerImpl> child = | 5163 scoped_ptr<LayerImpl> child = |
| 5147 LayerImpl::Create(my_host_impl->active_tree(), 2); | 5164 LayerImpl::Create(my_host_impl->active_tree(), 2); |
| 5148 scoped_ptr<LayerImpl> grand_child = | 5165 scoped_ptr<LayerImpl> grand_child = |
| 5149 FakeLayerWithQuads::Create(my_host_impl->active_tree(), 3); | 5166 FakeLayerWithQuads::Create(my_host_impl->active_tree(), 3); |
| 5150 | 5167 |
| 5151 gfx::Rect root_rect(0, 0, 100, 100); | 5168 gfx::Rect root_rect(0, 0, 100, 100); |
| 5152 gfx::Rect child_rect(10, 10, 50, 50); | 5169 gfx::Rect child_rect(10, 10, 50, 50); |
| 5153 gfx::Rect grand_child_rect(5, 5, 150, 150); | 5170 gfx::Rect grand_child_rect(5, 5, 150, 150); |
| 5154 | 5171 |
| 5155 root->CreateRenderSurface(); | 5172 root->SetHasRenderSurface(true); |
| 5156 root->SetPosition(root_rect.origin()); | 5173 root->SetPosition(root_rect.origin()); |
| 5157 root->SetBounds(root_rect.size()); | 5174 root->SetBounds(root_rect.size()); |
| 5158 root->SetContentBounds(root->bounds()); | 5175 root->SetContentBounds(root->bounds()); |
| 5159 root->draw_properties().visible_content_rect = root_rect; | 5176 root->draw_properties().visible_content_rect = root_rect; |
| 5160 root->SetDrawsContent(false); | 5177 root->SetDrawsContent(false); |
| 5161 root->render_surface()->SetContentRect(gfx::Rect(root_rect.size())); | 5178 root->render_surface()->SetContentRect(gfx::Rect(root_rect.size())); |
| 5162 | 5179 |
| 5163 child->SetPosition(gfx::PointF(child_rect.x(), child_rect.y())); | 5180 child->SetPosition(gfx::PointF(child_rect.x(), child_rect.y())); |
| 5164 child->SetOpacity(0.5f); | 5181 child->SetOpacity(0.5f); |
| 5165 child->SetBounds(gfx::Size(child_rect.width(), child_rect.height())); | 5182 child->SetBounds(gfx::Size(child_rect.width(), child_rect.height())); |
| 5166 child->SetContentBounds(child->bounds()); | 5183 child->SetContentBounds(child->bounds()); |
| 5167 child->draw_properties().visible_content_rect = child_rect; | 5184 child->draw_properties().visible_content_rect = child_rect; |
| 5168 child->SetDrawsContent(false); | 5185 child->SetDrawsContent(false); |
| 5169 child->SetForceRenderSurface(true); | 5186 child->SetHasRenderSurface(true); |
| 5170 | 5187 |
| 5171 grand_child->SetPosition(grand_child_rect.origin()); | 5188 grand_child->SetPosition(grand_child_rect.origin()); |
| 5172 grand_child->SetBounds(grand_child_rect.size()); | 5189 grand_child->SetBounds(grand_child_rect.size()); |
| 5173 grand_child->SetContentBounds(grand_child->bounds()); | 5190 grand_child->SetContentBounds(grand_child->bounds()); |
| 5174 grand_child->draw_properties().visible_content_rect = grand_child_rect; | 5191 grand_child->draw_properties().visible_content_rect = grand_child_rect; |
| 5175 grand_child->SetDrawsContent(true); | 5192 grand_child->SetDrawsContent(true); |
| 5176 | 5193 |
| 5177 child->AddChild(grand_child.Pass()); | 5194 child->AddChild(grand_child.Pass()); |
| 5178 root->AddChild(child.Pass()); | 5195 root->AddChild(child.Pass()); |
| 5179 | 5196 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5239 scoped_ptr<TestWebGraphicsContext3D> context = | 5256 scoped_ptr<TestWebGraphicsContext3D> context = |
| 5240 TestWebGraphicsContext3D::Create(); | 5257 TestWebGraphicsContext3D::Create(); |
| 5241 TestWebGraphicsContext3D* context3d = context.get(); | 5258 TestWebGraphicsContext3D* context3d = context.get(); |
| 5242 scoped_ptr<OutputSurface> output_surface( | 5259 scoped_ptr<OutputSurface> output_surface( |
| 5243 FakeOutputSurface::Create3d(context.Pass())); | 5260 FakeOutputSurface::Create3d(context.Pass())); |
| 5244 CreateHostImpl(DefaultSettings(), output_surface.Pass()); | 5261 CreateHostImpl(DefaultSettings(), output_surface.Pass()); |
| 5245 | 5262 |
| 5246 scoped_ptr<LayerImpl> root_layer = | 5263 scoped_ptr<LayerImpl> root_layer = |
| 5247 LayerImpl::Create(host_impl_->active_tree(), 1); | 5264 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 5248 root_layer->SetBounds(gfx::Size(10, 10)); | 5265 root_layer->SetBounds(gfx::Size(10, 10)); |
| 5266 root_layer->SetHasRenderSurface(true); |
| 5249 | 5267 |
| 5250 scoped_refptr<VideoFrame> softwareFrame = | 5268 scoped_refptr<VideoFrame> softwareFrame = |
| 5251 media::VideoFrame::CreateColorFrame( | 5269 media::VideoFrame::CreateColorFrame( |
| 5252 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); | 5270 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); |
| 5253 FakeVideoFrameProvider provider; | 5271 FakeVideoFrameProvider provider; |
| 5254 provider.set_frame(softwareFrame); | 5272 provider.set_frame(softwareFrame); |
| 5255 scoped_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( | 5273 scoped_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( |
| 5256 host_impl_->active_tree(), 4, &provider, media::VIDEO_ROTATION_0); | 5274 host_impl_->active_tree(), 4, &provider, media::VIDEO_ROTATION_0); |
| 5257 video_layer->SetBounds(gfx::Size(10, 10)); | 5275 video_layer->SetBounds(gfx::Size(10, 10)); |
| 5258 video_layer->SetContentBounds(gfx::Size(10, 10)); | 5276 video_layer->SetContentBounds(gfx::Size(10, 10)); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5413 } | 5431 } |
| 5414 }; | 5432 }; |
| 5415 | 5433 |
| 5416 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) { | 5434 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) { |
| 5417 scoped_ptr<SolidColorLayerImpl> root = | 5435 scoped_ptr<SolidColorLayerImpl> root = |
| 5418 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 5436 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
| 5419 root->SetPosition(gfx::PointF()); | 5437 root->SetPosition(gfx::PointF()); |
| 5420 root->SetBounds(gfx::Size(10, 10)); | 5438 root->SetBounds(gfx::Size(10, 10)); |
| 5421 root->SetContentBounds(gfx::Size(10, 10)); | 5439 root->SetContentBounds(gfx::Size(10, 10)); |
| 5422 root->SetDrawsContent(true); | 5440 root->SetDrawsContent(true); |
| 5441 root->SetHasRenderSurface(true); |
| 5423 | 5442 |
| 5424 // Child layer is in the bottom right corner. | 5443 // Child layer is in the bottom right corner. |
| 5425 scoped_ptr<SolidColorLayerImpl> child = | 5444 scoped_ptr<SolidColorLayerImpl> child = |
| 5426 SolidColorLayerImpl::Create(host_impl_->active_tree(), 2); | 5445 SolidColorLayerImpl::Create(host_impl_->active_tree(), 2); |
| 5427 child->SetPosition(gfx::PointF(9.f, 9.f)); | 5446 child->SetPosition(gfx::PointF(9.f, 9.f)); |
| 5428 child->SetBounds(gfx::Size(1, 1)); | 5447 child->SetBounds(gfx::Size(1, 1)); |
| 5429 child->SetContentBounds(gfx::Size(1, 1)); | 5448 child->SetContentBounds(gfx::Size(1, 1)); |
| 5430 child->SetDrawsContent(true); | 5449 child->SetDrawsContent(true); |
| 5431 root->AddChild(child.Pass()); | 5450 root->AddChild(child.Pass()); |
| 5432 | 5451 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5479 | 5498 |
| 5480 // Root | 5499 // Root |
| 5481 // | | 5500 // | |
| 5482 // +-- Scaling Layer (adds a 2x scale) | 5501 // +-- Scaling Layer (adds a 2x scale) |
| 5483 // | | 5502 // | |
| 5484 // +-- Content Layer | 5503 // +-- Content Layer |
| 5485 // +--Mask | 5504 // +--Mask |
| 5486 scoped_ptr<LayerImpl> scoped_root = | 5505 scoped_ptr<LayerImpl> scoped_root = |
| 5487 LayerImpl::Create(host_impl_->active_tree(), 1); | 5506 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 5488 LayerImpl* root = scoped_root.get(); | 5507 LayerImpl* root = scoped_root.get(); |
| 5508 root->SetHasRenderSurface(true); |
| 5489 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); | 5509 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); |
| 5490 | 5510 |
| 5491 scoped_ptr<LayerImpl> scoped_scaling_layer = | 5511 scoped_ptr<LayerImpl> scoped_scaling_layer = |
| 5492 LayerImpl::Create(host_impl_->active_tree(), 2); | 5512 LayerImpl::Create(host_impl_->active_tree(), 2); |
| 5493 LayerImpl* scaling_layer = scoped_scaling_layer.get(); | 5513 LayerImpl* scaling_layer = scoped_scaling_layer.get(); |
| 5494 root->AddChild(scoped_scaling_layer.Pass()); | 5514 root->AddChild(scoped_scaling_layer.Pass()); |
| 5495 | 5515 |
| 5496 scoped_ptr<LayerImpl> scoped_content_layer = | 5516 scoped_ptr<LayerImpl> scoped_content_layer = |
| 5497 LayerImpl::Create(host_impl_->active_tree(), 3); | 5517 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 5498 LayerImpl* content_layer = scoped_content_layer.get(); | 5518 LayerImpl* content_layer = scoped_content_layer.get(); |
| 5499 scaling_layer->AddChild(scoped_content_layer.Pass()); | 5519 scaling_layer->AddChild(scoped_content_layer.Pass()); |
| 5500 | 5520 |
| 5501 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = | 5521 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = |
| 5502 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); | 5522 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); |
| 5503 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); | 5523 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); |
| 5524 content_layer->SetHasRenderSurface(true); |
| 5504 content_layer->SetMaskLayer(scoped_mask_layer.Pass()); | 5525 content_layer->SetMaskLayer(scoped_mask_layer.Pass()); |
| 5505 | 5526 |
| 5506 gfx::Size root_size(100, 100); | 5527 gfx::Size root_size(100, 100); |
| 5507 root->SetBounds(root_size); | 5528 root->SetBounds(root_size); |
| 5508 root->SetContentBounds(root_size); | 5529 root->SetContentBounds(root_size); |
| 5509 root->SetPosition(gfx::PointF()); | 5530 root->SetPosition(gfx::PointF()); |
| 5510 | 5531 |
| 5511 gfx::Size scaling_layer_size(50, 50); | 5532 gfx::Size scaling_layer_size(50, 50); |
| 5512 scaling_layer->SetBounds(scaling_layer_size); | 5533 scaling_layer->SetBounds(scaling_layer_size); |
| 5513 scaling_layer->SetContentBounds(scaling_layer_size); | 5534 scaling_layer->SetContentBounds(scaling_layer_size); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5619 } | 5640 } |
| 5620 } | 5641 } |
| 5621 | 5642 |
| 5622 TEST_F(LayerTreeHostImplTest, MaskLayerWithDifferentBounds) { | 5643 TEST_F(LayerTreeHostImplTest, MaskLayerWithDifferentBounds) { |
| 5623 // The mask layer has bounds 100x100 but is attached to a layer with bounds | 5644 // The mask layer has bounds 100x100 but is attached to a layer with bounds |
| 5624 // 50x50. | 5645 // 50x50. |
| 5625 | 5646 |
| 5626 scoped_ptr<LayerImpl> scoped_root = | 5647 scoped_ptr<LayerImpl> scoped_root = |
| 5627 LayerImpl::Create(host_impl_->active_tree(), 1); | 5648 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 5628 LayerImpl* root = scoped_root.get(); | 5649 LayerImpl* root = scoped_root.get(); |
| 5650 root->SetHasRenderSurface(true); |
| 5651 |
| 5629 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); | 5652 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); |
| 5630 | 5653 |
| 5631 scoped_ptr<LayerImpl> scoped_content_layer = | 5654 scoped_ptr<LayerImpl> scoped_content_layer = |
| 5632 LayerImpl::Create(host_impl_->active_tree(), 3); | 5655 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 5633 LayerImpl* content_layer = scoped_content_layer.get(); | 5656 LayerImpl* content_layer = scoped_content_layer.get(); |
| 5634 root->AddChild(scoped_content_layer.Pass()); | 5657 root->AddChild(scoped_content_layer.Pass()); |
| 5635 | 5658 |
| 5636 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = | 5659 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = |
| 5637 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); | 5660 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); |
| 5638 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); | 5661 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); |
| 5639 content_layer->SetMaskLayer(scoped_mask_layer.Pass()); | 5662 content_layer->SetMaskLayer(scoped_mask_layer.Pass()); |
| 5663 content_layer->SetHasRenderSurface(true); |
| 5640 | 5664 |
| 5641 gfx::Size root_size(100, 100); | 5665 gfx::Size root_size(100, 100); |
| 5642 root->SetBounds(root_size); | 5666 root->SetBounds(root_size); |
| 5643 root->SetContentBounds(root_size); | 5667 root->SetContentBounds(root_size); |
| 5644 root->SetPosition(gfx::PointF()); | 5668 root->SetPosition(gfx::PointF()); |
| 5645 | 5669 |
| 5646 gfx::Size layer_size(50, 50); | 5670 gfx::Size layer_size(50, 50); |
| 5647 content_layer->SetBounds(layer_size); | 5671 content_layer->SetBounds(layer_size); |
| 5648 content_layer->SetContentBounds(layer_size); | 5672 content_layer->SetContentBounds(layer_size); |
| 5649 content_layer->SetPosition(gfx::PointF()); | 5673 content_layer->SetPosition(gfx::PointF()); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5773 } | 5797 } |
| 5774 } | 5798 } |
| 5775 | 5799 |
| 5776 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerWithDifferentBounds) { | 5800 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerWithDifferentBounds) { |
| 5777 // The replica's mask layer has bounds 100x100 but the replica is of a | 5801 // The replica's mask layer has bounds 100x100 but the replica is of a |
| 5778 // layer with bounds 50x50. | 5802 // layer with bounds 50x50. |
| 5779 | 5803 |
| 5780 scoped_ptr<LayerImpl> scoped_root = | 5804 scoped_ptr<LayerImpl> scoped_root = |
| 5781 LayerImpl::Create(host_impl_->active_tree(), 1); | 5805 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 5782 LayerImpl* root = scoped_root.get(); | 5806 LayerImpl* root = scoped_root.get(); |
| 5807 root->SetHasRenderSurface(true); |
| 5808 |
| 5783 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); | 5809 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); |
| 5784 | 5810 |
| 5785 scoped_ptr<LayerImpl> scoped_content_layer = | 5811 scoped_ptr<LayerImpl> scoped_content_layer = |
| 5786 LayerImpl::Create(host_impl_->active_tree(), 3); | 5812 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 5787 LayerImpl* content_layer = scoped_content_layer.get(); | 5813 LayerImpl* content_layer = scoped_content_layer.get(); |
| 5788 root->AddChild(scoped_content_layer.Pass()); | 5814 root->AddChild(scoped_content_layer.Pass()); |
| 5789 | 5815 |
| 5790 scoped_ptr<LayerImpl> scoped_replica_layer = | 5816 scoped_ptr<LayerImpl> scoped_replica_layer = |
| 5791 LayerImpl::Create(host_impl_->active_tree(), 2); | 5817 LayerImpl::Create(host_impl_->active_tree(), 2); |
| 5792 LayerImpl* replica_layer = scoped_replica_layer.get(); | 5818 LayerImpl* replica_layer = scoped_replica_layer.get(); |
| 5793 content_layer->SetReplicaLayer(scoped_replica_layer.Pass()); | 5819 content_layer->SetReplicaLayer(scoped_replica_layer.Pass()); |
| 5820 content_layer->SetHasRenderSurface(true); |
| 5794 | 5821 |
| 5795 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = | 5822 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = |
| 5796 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); | 5823 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); |
| 5797 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); | 5824 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); |
| 5798 replica_layer->SetMaskLayer(scoped_mask_layer.Pass()); | 5825 replica_layer->SetMaskLayer(scoped_mask_layer.Pass()); |
| 5826 replica_layer->SetHasRenderSurface(true); |
| 5799 | 5827 |
| 5800 gfx::Size root_size(100, 100); | 5828 gfx::Size root_size(100, 100); |
| 5801 root->SetBounds(root_size); | 5829 root->SetBounds(root_size); |
| 5802 root->SetContentBounds(root_size); | 5830 root->SetContentBounds(root_size); |
| 5803 root->SetPosition(gfx::PointF()); | 5831 root->SetPosition(gfx::PointF()); |
| 5804 | 5832 |
| 5805 gfx::Size layer_size(50, 50); | 5833 gfx::Size layer_size(50, 50); |
| 5806 content_layer->SetBounds(layer_size); | 5834 content_layer->SetBounds(layer_size); |
| 5807 content_layer->SetContentBounds(layer_size); | 5835 content_layer->SetContentBounds(layer_size); |
| 5808 content_layer->SetPosition(gfx::PointF()); | 5836 content_layer->SetPosition(gfx::PointF()); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5928 } | 5956 } |
| 5929 } | 5957 } |
| 5930 | 5958 |
| 5931 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerForSurfaceWithUnclippedChild) { | 5959 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerForSurfaceWithUnclippedChild) { |
| 5932 // The replica is of a layer with bounds 50x50, but it has a child that causes | 5960 // The replica is of a layer with bounds 50x50, but it has a child that causes |
| 5933 // the surface bounds to be larger. | 5961 // the surface bounds to be larger. |
| 5934 | 5962 |
| 5935 scoped_ptr<LayerImpl> scoped_root = | 5963 scoped_ptr<LayerImpl> scoped_root = |
| 5936 LayerImpl::Create(host_impl_->active_tree(), 1); | 5964 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 5937 LayerImpl* root = scoped_root.get(); | 5965 LayerImpl* root = scoped_root.get(); |
| 5966 root->SetHasRenderSurface(true); |
| 5938 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); | 5967 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); |
| 5939 | 5968 |
| 5940 scoped_ptr<LayerImpl> scoped_content_layer = | 5969 scoped_ptr<LayerImpl> scoped_content_layer = |
| 5941 LayerImpl::Create(host_impl_->active_tree(), 2); | 5970 LayerImpl::Create(host_impl_->active_tree(), 2); |
| 5942 LayerImpl* content_layer = scoped_content_layer.get(); | 5971 LayerImpl* content_layer = scoped_content_layer.get(); |
| 5943 root->AddChild(scoped_content_layer.Pass()); | 5972 root->AddChild(scoped_content_layer.Pass()); |
| 5944 | 5973 |
| 5945 scoped_ptr<LayerImpl> scoped_content_child_layer = | 5974 scoped_ptr<LayerImpl> scoped_content_child_layer = |
| 5946 LayerImpl::Create(host_impl_->active_tree(), 3); | 5975 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 5947 LayerImpl* content_child_layer = scoped_content_child_layer.get(); | 5976 LayerImpl* content_child_layer = scoped_content_child_layer.get(); |
| 5948 content_layer->AddChild(scoped_content_child_layer.Pass()); | 5977 content_layer->AddChild(scoped_content_child_layer.Pass()); |
| 5949 | 5978 |
| 5950 scoped_ptr<LayerImpl> scoped_replica_layer = | 5979 scoped_ptr<LayerImpl> scoped_replica_layer = |
| 5951 LayerImpl::Create(host_impl_->active_tree(), 4); | 5980 LayerImpl::Create(host_impl_->active_tree(), 4); |
| 5952 LayerImpl* replica_layer = scoped_replica_layer.get(); | 5981 LayerImpl* replica_layer = scoped_replica_layer.get(); |
| 5953 content_layer->SetReplicaLayer(scoped_replica_layer.Pass()); | 5982 content_layer->SetReplicaLayer(scoped_replica_layer.Pass()); |
| 5983 content_layer->SetHasRenderSurface(true); |
| 5954 | 5984 |
| 5955 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = | 5985 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = |
| 5956 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 5); | 5986 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 5); |
| 5957 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); | 5987 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); |
| 5958 replica_layer->SetMaskLayer(scoped_mask_layer.Pass()); | 5988 replica_layer->SetMaskLayer(scoped_mask_layer.Pass()); |
| 5989 replica_layer->SetHasRenderSurface(true); |
| 5959 | 5990 |
| 5960 gfx::Size root_size(100, 100); | 5991 gfx::Size root_size(100, 100); |
| 5961 root->SetBounds(root_size); | 5992 root->SetBounds(root_size); |
| 5962 root->SetContentBounds(root_size); | 5993 root->SetContentBounds(root_size); |
| 5963 root->SetPosition(gfx::PointF()); | 5994 root->SetPosition(gfx::PointF()); |
| 5964 | 5995 |
| 5965 gfx::Size layer_size(50, 50); | 5996 gfx::Size layer_size(50, 50); |
| 5966 content_layer->SetBounds(layer_size); | 5997 content_layer->SetBounds(layer_size); |
| 5967 content_layer->SetContentBounds(layer_size); | 5998 content_layer->SetContentBounds(layer_size); |
| 5968 content_layer->SetPosition(gfx::PointF()); | 5999 content_layer->SetPosition(gfx::PointF()); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6052 } | 6083 } |
| 6053 | 6084 |
| 6054 TEST_F(LayerTreeHostImplTest, MaskLayerForSurfaceWithClippedLayer) { | 6085 TEST_F(LayerTreeHostImplTest, MaskLayerForSurfaceWithClippedLayer) { |
| 6055 // The masked layer has bounds 50x50, but it has a child that causes | 6086 // The masked layer has bounds 50x50, but it has a child that causes |
| 6056 // the surface bounds to be larger. It also has a parent that clips the | 6087 // the surface bounds to be larger. It also has a parent that clips the |
| 6057 // masked layer and its surface. | 6088 // masked layer and its surface. |
| 6058 | 6089 |
| 6059 scoped_ptr<LayerImpl> scoped_root = | 6090 scoped_ptr<LayerImpl> scoped_root = |
| 6060 LayerImpl::Create(host_impl_->active_tree(), 1); | 6091 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 6061 LayerImpl* root = scoped_root.get(); | 6092 LayerImpl* root = scoped_root.get(); |
| 6093 root->SetHasRenderSurface(true); |
| 6094 |
| 6062 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); | 6095 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); |
| 6063 | 6096 |
| 6064 scoped_ptr<LayerImpl> scoped_clipping_layer = | 6097 scoped_ptr<LayerImpl> scoped_clipping_layer = |
| 6065 LayerImpl::Create(host_impl_->active_tree(), 2); | 6098 LayerImpl::Create(host_impl_->active_tree(), 2); |
| 6066 LayerImpl* clipping_layer = scoped_clipping_layer.get(); | 6099 LayerImpl* clipping_layer = scoped_clipping_layer.get(); |
| 6067 root->AddChild(scoped_clipping_layer.Pass()); | 6100 root->AddChild(scoped_clipping_layer.Pass()); |
| 6068 | 6101 |
| 6069 scoped_ptr<LayerImpl> scoped_content_layer = | 6102 scoped_ptr<LayerImpl> scoped_content_layer = |
| 6070 LayerImpl::Create(host_impl_->active_tree(), 3); | 6103 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 6071 LayerImpl* content_layer = scoped_content_layer.get(); | 6104 LayerImpl* content_layer = scoped_content_layer.get(); |
| 6072 clipping_layer->AddChild(scoped_content_layer.Pass()); | 6105 clipping_layer->AddChild(scoped_content_layer.Pass()); |
| 6073 | 6106 |
| 6074 scoped_ptr<LayerImpl> scoped_content_child_layer = | 6107 scoped_ptr<LayerImpl> scoped_content_child_layer = |
| 6075 LayerImpl::Create(host_impl_->active_tree(), 4); | 6108 LayerImpl::Create(host_impl_->active_tree(), 4); |
| 6076 LayerImpl* content_child_layer = scoped_content_child_layer.get(); | 6109 LayerImpl* content_child_layer = scoped_content_child_layer.get(); |
| 6077 content_layer->AddChild(scoped_content_child_layer.Pass()); | 6110 content_layer->AddChild(scoped_content_child_layer.Pass()); |
| 6078 | 6111 |
| 6079 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = | 6112 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = |
| 6080 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 6); | 6113 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 6); |
| 6081 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); | 6114 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); |
| 6082 content_layer->SetMaskLayer(scoped_mask_layer.Pass()); | 6115 content_layer->SetMaskLayer(scoped_mask_layer.Pass()); |
| 6116 content_layer->SetHasRenderSurface(true); |
| 6083 | 6117 |
| 6084 gfx::Size root_size(100, 100); | 6118 gfx::Size root_size(100, 100); |
| 6085 root->SetBounds(root_size); | 6119 root->SetBounds(root_size); |
| 6086 root->SetContentBounds(root_size); | 6120 root->SetContentBounds(root_size); |
| 6087 root->SetPosition(gfx::PointF()); | 6121 root->SetPosition(gfx::PointF()); |
| 6088 | 6122 |
| 6089 gfx::Rect clipping_rect(20, 10, 10, 20); | 6123 gfx::Rect clipping_rect(20, 10, 10, 20); |
| 6090 clipping_layer->SetBounds(clipping_rect.size()); | 6124 clipping_layer->SetBounds(clipping_rect.size()); |
| 6091 clipping_layer->SetContentBounds(clipping_rect.size()); | 6125 clipping_layer->SetContentBounds(clipping_rect.size()); |
| 6092 clipping_layer->SetPosition(clipping_rect.origin()); | 6126 clipping_layer->SetPosition(clipping_rect.origin()); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6158 gfx::ToCeiledSize(gfx::ScaleSize(root_size, device_scale_factor)); | 6192 gfx::ToCeiledSize(gfx::ScaleSize(root_size, device_scale_factor)); |
| 6159 host_impl_->SetViewportSize(device_viewport_size); | 6193 host_impl_->SetViewportSize(device_viewport_size); |
| 6160 | 6194 |
| 6161 host_impl_->CreatePendingTree(); | 6195 host_impl_->CreatePendingTree(); |
| 6162 host_impl_->pending_tree() | 6196 host_impl_->pending_tree() |
| 6163 ->SetPageScaleFactorAndLimits(1.f, 1.f / 16.f, 16.f); | 6197 ->SetPageScaleFactorAndLimits(1.f, 1.f / 16.f, 16.f); |
| 6164 | 6198 |
| 6165 scoped_ptr<LayerImpl> scoped_root = | 6199 scoped_ptr<LayerImpl> scoped_root = |
| 6166 LayerImpl::Create(host_impl_->pending_tree(), 1); | 6200 LayerImpl::Create(host_impl_->pending_tree(), 1); |
| 6167 LayerImpl* root = scoped_root.get(); | 6201 LayerImpl* root = scoped_root.get(); |
| 6202 root->SetHasRenderSurface(true); |
| 6168 | 6203 |
| 6169 host_impl_->pending_tree()->SetRootLayer(scoped_root.Pass()); | 6204 host_impl_->pending_tree()->SetRootLayer(scoped_root.Pass()); |
| 6170 | 6205 |
| 6171 scoped_ptr<LayerImpl> scoped_scrolling_layer = | 6206 scoped_ptr<LayerImpl> scoped_scrolling_layer = |
| 6172 LayerImpl::Create(host_impl_->pending_tree(), 2); | 6207 LayerImpl::Create(host_impl_->pending_tree(), 2); |
| 6173 LayerImpl* scrolling_layer = scoped_scrolling_layer.get(); | 6208 LayerImpl* scrolling_layer = scoped_scrolling_layer.get(); |
| 6174 root->AddChild(scoped_scrolling_layer.Pass()); | 6209 root->AddChild(scoped_scrolling_layer.Pass()); |
| 6175 | 6210 |
| 6176 gfx::Size content_layer_bounds(100000, 100); | 6211 gfx::Size content_layer_bounds(100000, 100); |
| 6177 gfx::Size pile_tile_size(3000, 3000); | 6212 gfx::Size pile_tile_size(3000, 3000); |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6659 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures()); | 6694 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures()); |
| 6660 } | 6695 } |
| 6661 | 6696 |
| 6662 TEST_F(LayerTreeHostImplTest, TouchFlingShouldNotBubble) { | 6697 TEST_F(LayerTreeHostImplTest, TouchFlingShouldNotBubble) { |
| 6663 // When flinging via touch, only the child should scroll (we should not | 6698 // When flinging via touch, only the child should scroll (we should not |
| 6664 // bubble). | 6699 // bubble). |
| 6665 gfx::Size surface_size(10, 10); | 6700 gfx::Size surface_size(10, 10); |
| 6666 gfx::Size content_size(20, 20); | 6701 gfx::Size content_size(20, 20); |
| 6667 scoped_ptr<LayerImpl> root_clip = | 6702 scoped_ptr<LayerImpl> root_clip = |
| 6668 LayerImpl::Create(host_impl_->active_tree(), 3); | 6703 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 6704 root_clip->SetHasRenderSurface(true); |
| 6705 |
| 6669 scoped_ptr<LayerImpl> root = | 6706 scoped_ptr<LayerImpl> root = |
| 6670 CreateScrollableLayer(1, content_size, root_clip.get()); | 6707 CreateScrollableLayer(1, content_size, root_clip.get()); |
| 6671 root->SetIsContainerForFixedPositionLayers(true); | 6708 root->SetIsContainerForFixedPositionLayers(true); |
| 6672 scoped_ptr<LayerImpl> child = | 6709 scoped_ptr<LayerImpl> child = |
| 6673 CreateScrollableLayer(2, content_size, root_clip.get()); | 6710 CreateScrollableLayer(2, content_size, root_clip.get()); |
| 6674 | 6711 |
| 6675 root->AddChild(child.Pass()); | 6712 root->AddChild(child.Pass()); |
| 6676 int root_id = root->id(); | 6713 int root_id = root->id(); |
| 6677 root_clip->AddChild(root.Pass()); | 6714 root_clip->AddChild(root.Pass()); |
| 6678 | 6715 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 6703 ASSERT_EQ(1u, scroll_info->scrolls.size()); | 6740 ASSERT_EQ(1u, scroll_info->scrolls.size()); |
| 6704 ExpectNone(*scroll_info.get(), root_id); | 6741 ExpectNone(*scroll_info.get(), root_id); |
| 6705 } | 6742 } |
| 6706 } | 6743 } |
| 6707 | 6744 |
| 6708 TEST_F(LayerTreeHostImplTest, TouchFlingShouldLockToFirstScrolledLayer) { | 6745 TEST_F(LayerTreeHostImplTest, TouchFlingShouldLockToFirstScrolledLayer) { |
| 6709 // Scroll a child layer beyond its maximum scroll range and make sure the | 6746 // Scroll a child layer beyond its maximum scroll range and make sure the |
| 6710 // the scroll doesn't bubble up to the parent layer. | 6747 // the scroll doesn't bubble up to the parent layer. |
| 6711 gfx::Size surface_size(10, 10); | 6748 gfx::Size surface_size(10, 10); |
| 6712 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 6749 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 6750 root->SetHasRenderSurface(true); |
| 6713 scoped_ptr<LayerImpl> root_scrolling = | 6751 scoped_ptr<LayerImpl> root_scrolling = |
| 6714 CreateScrollableLayer(2, surface_size, root.get()); | 6752 CreateScrollableLayer(2, surface_size, root.get()); |
| 6715 | 6753 |
| 6716 scoped_ptr<LayerImpl> grand_child = | 6754 scoped_ptr<LayerImpl> grand_child = |
| 6717 CreateScrollableLayer(4, surface_size, root.get()); | 6755 CreateScrollableLayer(4, surface_size, root.get()); |
| 6718 grand_child->SetScrollOffset(gfx::ScrollOffset(0, 2)); | 6756 grand_child->SetScrollOffset(gfx::ScrollOffset(0, 2)); |
| 6719 | 6757 |
| 6720 scoped_ptr<LayerImpl> child = | 6758 scoped_ptr<LayerImpl> child = |
| 6721 CreateScrollableLayer(3, surface_size, root.get()); | 6759 CreateScrollableLayer(3, surface_size, root.get()); |
| 6722 child->SetScrollOffset(gfx::ScrollOffset(0, 4)); | 6760 child->SetScrollOffset(gfx::ScrollOffset(0, 4)); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6773 } | 6811 } |
| 6774 } | 6812 } |
| 6775 | 6813 |
| 6776 TEST_F(LayerTreeHostImplTest, WheelFlingShouldBubble) { | 6814 TEST_F(LayerTreeHostImplTest, WheelFlingShouldBubble) { |
| 6777 // When flinging via wheel, the root should eventually scroll (we should | 6815 // When flinging via wheel, the root should eventually scroll (we should |
| 6778 // bubble). | 6816 // bubble). |
| 6779 gfx::Size surface_size(10, 10); | 6817 gfx::Size surface_size(10, 10); |
| 6780 gfx::Size content_size(20, 20); | 6818 gfx::Size content_size(20, 20); |
| 6781 scoped_ptr<LayerImpl> root_clip = | 6819 scoped_ptr<LayerImpl> root_clip = |
| 6782 LayerImpl::Create(host_impl_->active_tree(), 3); | 6820 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 6821 root_clip->SetHasRenderSurface(true); |
| 6783 scoped_ptr<LayerImpl> root_scroll = | 6822 scoped_ptr<LayerImpl> root_scroll = |
| 6784 CreateScrollableLayer(1, content_size, root_clip.get()); | 6823 CreateScrollableLayer(1, content_size, root_clip.get()); |
| 6785 int root_scroll_id = root_scroll->id(); | 6824 int root_scroll_id = root_scroll->id(); |
| 6786 scoped_ptr<LayerImpl> child = | 6825 scoped_ptr<LayerImpl> child = |
| 6787 CreateScrollableLayer(2, content_size, root_clip.get()); | 6826 CreateScrollableLayer(2, content_size, root_clip.get()); |
| 6788 | 6827 |
| 6789 root_scroll->AddChild(child.Pass()); | 6828 root_scroll->AddChild(child.Pass()); |
| 6790 root_clip->AddChild(root_scroll.Pass()); | 6829 root_clip->AddChild(root_scroll.Pass()); |
| 6791 | 6830 |
| 6792 host_impl_->SetViewportSize(surface_size); | 6831 host_impl_->SetViewportSize(surface_size); |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6976 | 7015 |
| 6977 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed | 7016 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed |
| 6978 // to CompositorFrameMetadata after SwapBuffers(); | 7017 // to CompositorFrameMetadata after SwapBuffers(); |
| 6979 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { | 7018 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { |
| 6980 scoped_ptr<SolidColorLayerImpl> root = | 7019 scoped_ptr<SolidColorLayerImpl> root = |
| 6981 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 7020 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
| 6982 root->SetPosition(gfx::PointF()); | 7021 root->SetPosition(gfx::PointF()); |
| 6983 root->SetBounds(gfx::Size(10, 10)); | 7022 root->SetBounds(gfx::Size(10, 10)); |
| 6984 root->SetContentBounds(gfx::Size(10, 10)); | 7023 root->SetContentBounds(gfx::Size(10, 10)); |
| 6985 root->SetDrawsContent(true); | 7024 root->SetDrawsContent(true); |
| 7025 root->SetHasRenderSurface(true); |
| 6986 | 7026 |
| 6987 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 7027 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 6988 | 7028 |
| 6989 FakeOutputSurface* fake_output_surface = | 7029 FakeOutputSurface* fake_output_surface = |
| 6990 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); | 7030 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); |
| 6991 | 7031 |
| 6992 const std::vector<ui::LatencyInfo>& metadata_latency_before = | 7032 const std::vector<ui::LatencyInfo>& metadata_latency_before = |
| 6993 fake_output_surface->last_sent_frame().metadata.latency_info; | 7033 fake_output_surface->last_sent_frame().metadata.latency_info; |
| 6994 EXPECT_TRUE(metadata_latency_before.empty()); | 7034 EXPECT_TRUE(metadata_latency_before.empty()); |
| 6995 | 7035 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 7016 } | 7056 } |
| 7017 | 7057 |
| 7018 TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) { | 7058 TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) { |
| 7019 int root_layer_id = 1; | 7059 int root_layer_id = 1; |
| 7020 scoped_ptr<SolidColorLayerImpl> root = | 7060 scoped_ptr<SolidColorLayerImpl> root = |
| 7021 SolidColorLayerImpl::Create(host_impl_->active_tree(), root_layer_id); | 7061 SolidColorLayerImpl::Create(host_impl_->active_tree(), root_layer_id); |
| 7022 root->SetPosition(gfx::PointF()); | 7062 root->SetPosition(gfx::PointF()); |
| 7023 root->SetBounds(gfx::Size(10, 10)); | 7063 root->SetBounds(gfx::Size(10, 10)); |
| 7024 root->SetContentBounds(gfx::Size(10, 10)); | 7064 root->SetContentBounds(gfx::Size(10, 10)); |
| 7025 root->SetDrawsContent(true); | 7065 root->SetDrawsContent(true); |
| 7066 root->SetHasRenderSurface(true); |
| 7026 | 7067 |
| 7027 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 7068 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 7028 | 7069 |
| 7029 // Ensure the default frame selection bounds are empty. | 7070 // Ensure the default frame selection bounds are empty. |
| 7030 FakeOutputSurface* fake_output_surface = | 7071 FakeOutputSurface* fake_output_surface = |
| 7031 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); | 7072 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); |
| 7032 const ViewportSelectionBound& selection_start_before = | 7073 const ViewportSelectionBound& selection_start_before = |
| 7033 fake_output_surface->last_sent_frame().metadata.selection_start; | 7074 fake_output_surface->last_sent_frame().metadata.selection_start; |
| 7034 const ViewportSelectionBound& selection_end_before = | 7075 const ViewportSelectionBound& selection_end_before = |
| 7035 fake_output_surface->last_sent_frame().metadata.selection_end; | 7076 fake_output_surface->last_sent_frame().metadata.selection_end; |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7513 contents->SetBounds(content_size); | 7554 contents->SetBounds(content_size); |
| 7514 contents->SetContentBounds(content_size); | 7555 contents->SetContentBounds(content_size); |
| 7515 contents->SetPosition(gfx::PointF()); | 7556 contents->SetPosition(gfx::PointF()); |
| 7516 | 7557 |
| 7517 outer_scroll->AddChild(contents.Pass()); | 7558 outer_scroll->AddChild(contents.Pass()); |
| 7518 outer_clip->AddChild(outer_scroll.Pass()); | 7559 outer_clip->AddChild(outer_scroll.Pass()); |
| 7519 inner_scroll->AddChild(outer_clip.Pass()); | 7560 inner_scroll->AddChild(outer_clip.Pass()); |
| 7520 page_scale->AddChild(inner_scroll.Pass()); | 7561 page_scale->AddChild(inner_scroll.Pass()); |
| 7521 inner_clip->AddChild(page_scale.Pass()); | 7562 inner_clip->AddChild(page_scale.Pass()); |
| 7522 | 7563 |
| 7564 inner_clip->SetHasRenderSurface(true); |
| 7523 layer_tree_impl->SetRootLayer(inner_clip.Pass()); | 7565 layer_tree_impl->SetRootLayer(inner_clip.Pass()); |
| 7524 layer_tree_impl->SetViewportLayersFromIds( | 7566 layer_tree_impl->SetViewportLayersFromIds( |
| 7525 Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportScrollLayerId, | 7567 Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportScrollLayerId, |
| 7526 kOuterViewportScrollLayerId); | 7568 kOuterViewportScrollLayerId); |
| 7527 | 7569 |
| 7528 host_impl_->active_tree()->DidBecomeActive(); | 7570 host_impl_->active_tree()->DidBecomeActive(); |
| 7529 } | 7571 } |
| 7530 }; | 7572 }; |
| 7531 | 7573 |
| 7532 TEST_F(LayerTreeHostImplVirtualViewportTest, FlingScrollBubblesToInner) { | 7574 TEST_F(LayerTreeHostImplVirtualViewportTest, FlingScrollBubblesToInner) { |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7842 // surface. | 7884 // surface. |
| 7843 EXPECT_EQ(0, num_lost_surfaces_); | 7885 EXPECT_EQ(0, num_lost_surfaces_); |
| 7844 host_impl_->DidLoseOutputSurface(); | 7886 host_impl_->DidLoseOutputSurface(); |
| 7845 EXPECT_EQ(1, num_lost_surfaces_); | 7887 EXPECT_EQ(1, num_lost_surfaces_); |
| 7846 host_impl_->DidLoseOutputSurface(); | 7888 host_impl_->DidLoseOutputSurface(); |
| 7847 EXPECT_LE(1, num_lost_surfaces_); | 7889 EXPECT_LE(1, num_lost_surfaces_); |
| 7848 } | 7890 } |
| 7849 | 7891 |
| 7850 } // namespace | 7892 } // namespace |
| 7851 } // namespace cc | 7893 } // namespace cc |
| OLD | NEW |