| 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 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1431 contents->SetBounds(content_size); \ | 1406 contents->SetBounds(content_size); \ |
| 1432 contents->SetContentBounds(content_size); \ | 1407 contents->SetContentBounds(content_size); \ |
| 1433 \ | 1408 \ |
| 1434 scoped_ptr<SolidColorScrollbarLayerImpl> scrollbar = \ | 1409 scoped_ptr<SolidColorScrollbarLayerImpl> scrollbar = \ |
| 1435 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 4, \ | 1410 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 4, \ |
| 1436 VERTICAL, 10, 0, false, true); \ | 1411 VERTICAL, 10, 0, false, true); \ |
| 1437 EXPECT_FLOAT_EQ(0.f, scrollbar->opacity()); \ | 1412 EXPECT_FLOAT_EQ(0.f, scrollbar->opacity()); \ |
| 1438 \ | 1413 \ |
| 1439 scroll->AddChild(contents.Pass()); \ | 1414 scroll->AddChild(contents.Pass()); \ |
| 1440 root->AddChild(scroll.Pass()); \ | 1415 root->AddChild(scroll.Pass()); \ |
| 1416 root->SetHasRenderSurface(true); \ |
| 1441 scrollbar->SetScrollLayerAndClipLayerByIds(2, 1); \ | 1417 scrollbar->SetScrollLayerAndClipLayerByIds(2, 1); \ |
| 1442 root->AddChild(scrollbar.Pass()); \ | 1418 root->AddChild(scrollbar.Pass()); \ |
| 1443 \ | 1419 \ |
| 1444 host_impl_->active_tree()->SetRootLayer(root.Pass()); \ | 1420 host_impl_->active_tree()->SetRootLayer(root.Pass()); \ |
| 1445 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 2, \ | 1421 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 2, \ |
| 1446 Layer::INVALID_ID); \ | 1422 Layer::INVALID_ID); \ |
| 1447 host_impl_->active_tree()->DidBecomeActive(); \ | 1423 host_impl_->active_tree()->DidBecomeActive(); \ |
| 1448 DrawFrame(); | 1424 DrawFrame(); |
| 1449 | 1425 |
| 1450 TEST_F(LayerTreeHostImplTest, ScrollbarLinearFadeScheduling) { | 1426 TEST_F(LayerTreeHostImplTest, ScrollbarLinearFadeScheduling) { |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1575 gfx::ScaleSize(viewport_size, device_scale_factor)); | 1551 gfx::ScaleSize(viewport_size, device_scale_factor)); |
| 1576 gfx::Size content_size(1000, 1000); | 1552 gfx::Size content_size(1000, 1000); |
| 1577 | 1553 |
| 1578 CreateHostImpl(settings, CreateOutputSurface()); | 1554 CreateHostImpl(settings, CreateOutputSurface()); |
| 1579 host_impl_->SetDeviceScaleFactor(device_scale_factor); | 1555 host_impl_->SetDeviceScaleFactor(device_scale_factor); |
| 1580 host_impl_->SetViewportSize(device_viewport_size); | 1556 host_impl_->SetViewportSize(device_viewport_size); |
| 1581 | 1557 |
| 1582 scoped_ptr<LayerImpl> root = | 1558 scoped_ptr<LayerImpl> root = |
| 1583 LayerImpl::Create(host_impl_->active_tree(), 1); | 1559 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 1584 root->SetBounds(viewport_size); | 1560 root->SetBounds(viewport_size); |
| 1561 root->SetHasRenderSurface(true); |
| 1585 | 1562 |
| 1586 scoped_ptr<LayerImpl> scroll = | 1563 scoped_ptr<LayerImpl> scroll = |
| 1587 LayerImpl::Create(host_impl_->active_tree(), 2); | 1564 LayerImpl::Create(host_impl_->active_tree(), 2); |
| 1588 scroll->SetScrollClipLayer(root->id()); | 1565 scroll->SetScrollClipLayer(root->id()); |
| 1589 scroll->SetScrollOffset(gfx::ScrollOffset()); | 1566 scroll->SetScrollOffset(gfx::ScrollOffset()); |
| 1590 scroll->SetBounds(content_size); | 1567 scroll->SetBounds(content_size); |
| 1591 scroll->SetContentBounds(content_size); | 1568 scroll->SetContentBounds(content_size); |
| 1592 scroll->SetIsContainerForFixedPositionLayers(true); | 1569 scroll->SetIsContainerForFixedPositionLayers(true); |
| 1593 | 1570 |
| 1594 scoped_ptr<LayerImpl> contents = | 1571 scoped_ptr<LayerImpl> contents = |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1780 | 1757 |
| 1781 TEST_F(LayerTreeHostImplTest, WillDrawReturningFalseDoesNotCall) { | 1758 TEST_F(LayerTreeHostImplTest, WillDrawReturningFalseDoesNotCall) { |
| 1782 // The root layer is always drawn, so run this test on a child layer that | 1759 // The root layer is always drawn, so run this test on a child layer that |
| 1783 // will be masked out by the root layer's bounds. | 1760 // will be masked out by the root layer's bounds. |
| 1784 host_impl_->active_tree()->SetRootLayer( | 1761 host_impl_->active_tree()->SetRootLayer( |
| 1785 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 1762 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
| 1786 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( | 1763 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( |
| 1787 host_impl_->active_tree()->root_layer()); | 1764 host_impl_->active_tree()->root_layer()); |
| 1788 | 1765 |
| 1789 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 1766 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
| 1767 root->SetHasRenderSurface(true); |
| 1790 DidDrawCheckLayer* layer = | 1768 DidDrawCheckLayer* layer = |
| 1791 static_cast<DidDrawCheckLayer*>(root->children()[0]); | 1769 static_cast<DidDrawCheckLayer*>(root->children()[0]); |
| 1792 | 1770 |
| 1793 { | 1771 { |
| 1794 LayerTreeHostImpl::FrameData frame; | 1772 LayerTreeHostImpl::FrameData frame; |
| 1795 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 1773 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 1796 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 1774 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 1797 host_impl_->DidDrawAllLayers(frame); | 1775 host_impl_->DidDrawAllLayers(frame); |
| 1798 | 1776 |
| 1799 EXPECT_TRUE(layer->will_draw_called()); | 1777 EXPECT_TRUE(layer->will_draw_called()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1820 } | 1798 } |
| 1821 | 1799 |
| 1822 TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) { | 1800 TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) { |
| 1823 // The root layer is always drawn, so run this test on a child layer that | 1801 // The root layer is always drawn, so run this test on a child layer that |
| 1824 // will be masked out by the root layer's bounds. | 1802 // will be masked out by the root layer's bounds. |
| 1825 host_impl_->active_tree()->SetRootLayer( | 1803 host_impl_->active_tree()->SetRootLayer( |
| 1826 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 1804 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
| 1827 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( | 1805 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( |
| 1828 host_impl_->active_tree()->root_layer()); | 1806 host_impl_->active_tree()->root_layer()); |
| 1829 root->SetMasksToBounds(true); | 1807 root->SetMasksToBounds(true); |
| 1830 | 1808 root->SetHasRenderSurface(true); |
| 1831 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 1809 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
| 1832 DidDrawCheckLayer* layer = | 1810 DidDrawCheckLayer* layer = |
| 1833 static_cast<DidDrawCheckLayer*>(root->children()[0]); | 1811 static_cast<DidDrawCheckLayer*>(root->children()[0]); |
| 1834 // Ensure visible_content_rect for layer is empty. | 1812 // Ensure visible_content_rect for layer is empty. |
| 1835 layer->SetPosition(gfx::PointF(100.f, 100.f)); | 1813 layer->SetPosition(gfx::PointF(100.f, 100.f)); |
| 1836 layer->SetBounds(gfx::Size(10, 10)); | 1814 layer->SetBounds(gfx::Size(10, 10)); |
| 1837 layer->SetContentBounds(gfx::Size(10, 10)); | 1815 layer->SetContentBounds(gfx::Size(10, 10)); |
| 1838 | 1816 |
| 1839 LayerTreeHostImpl::FrameData frame; | 1817 LayerTreeHostImpl::FrameData frame; |
| 1840 | 1818 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1873 host_impl_->active_tree()->SetRootLayer( | 1851 host_impl_->active_tree()->SetRootLayer( |
| 1874 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 1852 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
| 1875 DidDrawCheckLayer* root = | 1853 DidDrawCheckLayer* root = |
| 1876 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 1854 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 1877 | 1855 |
| 1878 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 1856 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
| 1879 DidDrawCheckLayer* occluded_layer = | 1857 DidDrawCheckLayer* occluded_layer = |
| 1880 static_cast<DidDrawCheckLayer*>(root->children()[0]); | 1858 static_cast<DidDrawCheckLayer*>(root->children()[0]); |
| 1881 | 1859 |
| 1882 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); | 1860 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); |
| 1861 root->SetHasRenderSurface(true); |
| 1883 DidDrawCheckLayer* top_layer = | 1862 DidDrawCheckLayer* top_layer = |
| 1884 static_cast<DidDrawCheckLayer*>(root->children()[1]); | 1863 static_cast<DidDrawCheckLayer*>(root->children()[1]); |
| 1885 // This layer covers the occluded_layer above. Make this layer large so it can | 1864 // This layer covers the occluded_layer above. Make this layer large so it can |
| 1886 // occlude. | 1865 // occlude. |
| 1887 top_layer->SetBounds(big_size); | 1866 top_layer->SetBounds(big_size); |
| 1888 top_layer->SetContentBounds(big_size); | 1867 top_layer->SetContentBounds(big_size); |
| 1889 top_layer->SetContentsOpaque(true); | 1868 top_layer->SetContentsOpaque(true); |
| 1890 | 1869 |
| 1891 LayerTreeHostImpl::FrameData frame; | 1870 LayerTreeHostImpl::FrameData frame; |
| 1892 | 1871 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1905 EXPECT_TRUE(top_layer->did_draw_called()); | 1884 EXPECT_TRUE(top_layer->did_draw_called()); |
| 1906 } | 1885 } |
| 1907 | 1886 |
| 1908 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { | 1887 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { |
| 1909 host_impl_->active_tree()->SetRootLayer( | 1888 host_impl_->active_tree()->SetRootLayer( |
| 1910 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 1889 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
| 1911 DidDrawCheckLayer* root = | 1890 DidDrawCheckLayer* root = |
| 1912 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 1891 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 1913 | 1892 |
| 1914 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 1893 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
| 1894 root->SetHasRenderSurface(true); |
| 1915 DidDrawCheckLayer* layer1 = | 1895 DidDrawCheckLayer* layer1 = |
| 1916 static_cast<DidDrawCheckLayer*>(root->children()[0]); | 1896 static_cast<DidDrawCheckLayer*>(root->children()[0]); |
| 1917 | 1897 |
| 1918 layer1->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); | 1898 layer1->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); |
| 1919 DidDrawCheckLayer* layer2 = | 1899 DidDrawCheckLayer* layer2 = |
| 1920 static_cast<DidDrawCheckLayer*>(layer1->children()[0]); | 1900 static_cast<DidDrawCheckLayer*>(layer1->children()[0]); |
| 1921 | 1901 |
| 1922 layer1->SetOpacity(0.3f); | 1902 layer1->SetHasRenderSurface(true); |
| 1923 layer1->SetShouldFlattenTransform(true); | 1903 layer1->SetShouldFlattenTransform(true); |
| 1924 | 1904 |
| 1925 EXPECT_FALSE(root->did_draw_called()); | 1905 EXPECT_FALSE(root->did_draw_called()); |
| 1926 EXPECT_FALSE(layer1->did_draw_called()); | 1906 EXPECT_FALSE(layer1->did_draw_called()); |
| 1927 EXPECT_FALSE(layer2->did_draw_called()); | 1907 EXPECT_FALSE(layer2->did_draw_called()); |
| 1928 | 1908 |
| 1929 LayerTreeHostImpl::FrameData frame; | 1909 LayerTreeHostImpl::FrameData frame; |
| 1930 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( | 1910 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( |
| 1931 host_impl_->active_tree()->root_layer()); | 1911 host_impl_->active_tree()->root_layer()); |
| 1932 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 1912 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1984 | 1964 |
| 1985 bool tile_missing_; | 1965 bool tile_missing_; |
| 1986 bool had_incomplete_tile_; | 1966 bool had_incomplete_tile_; |
| 1987 }; | 1967 }; |
| 1988 | 1968 |
| 1989 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsOnDefault) { | 1969 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsOnDefault) { |
| 1990 host_impl_->active_tree()->SetRootLayer( | 1970 host_impl_->active_tree()->SetRootLayer( |
| 1991 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 1971 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
| 1992 DidDrawCheckLayer* root = | 1972 DidDrawCheckLayer* root = |
| 1993 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 1973 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 1994 | 1974 root->SetHasRenderSurface(true); |
| 1995 bool tile_missing = false; | 1975 bool tile_missing = false; |
| 1996 bool had_incomplete_tile = false; | 1976 bool had_incomplete_tile = false; |
| 1997 bool is_animating = false; | 1977 bool is_animating = false; |
| 1998 root->AddChild( | 1978 root->AddChild( |
| 1999 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 1979 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
| 2000 2, | 1980 2, |
| 2001 tile_missing, | 1981 tile_missing, |
| 2002 had_incomplete_tile, | 1982 had_incomplete_tile, |
| 2003 is_animating, | 1983 is_animating, |
| 2004 host_impl_->resource_provider())); | 1984 host_impl_->resource_provider())); |
| 2005 | 1985 |
| 2006 LayerTreeHostImpl::FrameData frame; | 1986 LayerTreeHostImpl::FrameData frame; |
| 2007 | 1987 |
| 2008 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 1988 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 2009 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 1989 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2010 host_impl_->DidDrawAllLayers(frame); | 1990 host_impl_->DidDrawAllLayers(frame); |
| 2011 } | 1991 } |
| 2012 | 1992 |
| 2013 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithAnimatedLayer) { | 1993 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithAnimatedLayer) { |
| 2014 host_impl_->active_tree()->SetRootLayer( | 1994 host_impl_->active_tree()->SetRootLayer( |
| 2015 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 1995 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
| 2016 DidDrawCheckLayer* root = | 1996 DidDrawCheckLayer* root = |
| 2017 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 1997 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 1998 root->SetHasRenderSurface(true); |
| 2018 bool tile_missing = false; | 1999 bool tile_missing = false; |
| 2019 bool had_incomplete_tile = false; | 2000 bool had_incomplete_tile = false; |
| 2020 bool is_animating = true; | 2001 bool is_animating = true; |
| 2021 root->AddChild( | 2002 root->AddChild( |
| 2022 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 2003 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
| 2023 2, | 2004 2, |
| 2024 tile_missing, | 2005 tile_missing, |
| 2025 had_incomplete_tile, | 2006 had_incomplete_tile, |
| 2026 is_animating, | 2007 is_animating, |
| 2027 host_impl_->resource_provider())); | 2008 host_impl_->resource_provider())); |
| 2028 | 2009 |
| 2029 LayerTreeHostImpl::FrameData frame; | 2010 LayerTreeHostImpl::FrameData frame; |
| 2030 | 2011 |
| 2031 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2012 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 2032 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2013 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2033 host_impl_->DidDrawAllLayers(frame); | 2014 host_impl_->DidDrawAllLayers(frame); |
| 2034 } | 2015 } |
| 2035 | 2016 |
| 2036 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithMissingTiles) { | 2017 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithMissingTiles) { |
| 2037 host_impl_->active_tree()->SetRootLayer( | 2018 host_impl_->active_tree()->SetRootLayer( |
| 2038 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); | 2019 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); |
| 2039 DidDrawCheckLayer* root = | 2020 DidDrawCheckLayer* root = |
| 2040 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2021 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 2022 root->SetHasRenderSurface(true); |
| 2041 | 2023 |
| 2042 LayerTreeHostImpl::FrameData frame; | 2024 LayerTreeHostImpl::FrameData frame; |
| 2043 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2025 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 2044 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2026 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2045 host_impl_->DidDrawAllLayers(frame); | 2027 host_impl_->DidDrawAllLayers(frame); |
| 2046 host_impl_->SwapBuffers(frame); | 2028 host_impl_->SwapBuffers(frame); |
| 2047 | 2029 |
| 2048 bool tile_missing = true; | 2030 bool tile_missing = true; |
| 2049 bool had_incomplete_tile = false; | 2031 bool had_incomplete_tile = false; |
| 2050 bool is_animating = false; | 2032 bool is_animating = false; |
| 2051 root->AddChild( | 2033 root->AddChild( |
| 2052 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 2034 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
| 2053 4, | 2035 4, |
| 2054 tile_missing, | 2036 tile_missing, |
| 2055 had_incomplete_tile, | 2037 had_incomplete_tile, |
| 2056 is_animating, | 2038 is_animating, |
| 2057 host_impl_->resource_provider())); | 2039 host_impl_->resource_provider())); |
| 2058 LayerTreeHostImpl::FrameData frame2; | 2040 LayerTreeHostImpl::FrameData frame2; |
| 2059 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame2)); | 2041 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame2)); |
| 2060 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); | 2042 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); |
| 2061 host_impl_->DidDrawAllLayers(frame2); | 2043 host_impl_->DidDrawAllLayers(frame2); |
| 2062 } | 2044 } |
| 2063 | 2045 |
| 2064 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithIncompleteTile) { | 2046 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithIncompleteTile) { |
| 2065 host_impl_->active_tree()->SetRootLayer( | 2047 host_impl_->active_tree()->SetRootLayer( |
| 2066 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); | 2048 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); |
| 2067 DidDrawCheckLayer* root = | 2049 DidDrawCheckLayer* root = |
| 2068 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2050 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 2051 root->SetHasRenderSurface(true); |
| 2069 | 2052 |
| 2070 LayerTreeHostImpl::FrameData frame; | 2053 LayerTreeHostImpl::FrameData frame; |
| 2071 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2054 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 2072 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2055 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2073 host_impl_->DidDrawAllLayers(frame); | 2056 host_impl_->DidDrawAllLayers(frame); |
| 2074 host_impl_->SwapBuffers(frame); | 2057 host_impl_->SwapBuffers(frame); |
| 2075 | 2058 |
| 2076 bool tile_missing = false; | 2059 bool tile_missing = false; |
| 2077 bool had_incomplete_tile = true; | 2060 bool had_incomplete_tile = true; |
| 2078 bool is_animating = false; | 2061 bool is_animating = false; |
| 2079 root->AddChild( | 2062 root->AddChild( |
| 2080 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 2063 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
| 2081 4, | 2064 4, |
| 2082 tile_missing, | 2065 tile_missing, |
| 2083 had_incomplete_tile, | 2066 had_incomplete_tile, |
| 2084 is_animating, | 2067 is_animating, |
| 2085 host_impl_->resource_provider())); | 2068 host_impl_->resource_provider())); |
| 2086 LayerTreeHostImpl::FrameData frame2; | 2069 LayerTreeHostImpl::FrameData frame2; |
| 2087 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame2)); | 2070 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame2)); |
| 2088 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); | 2071 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); |
| 2089 host_impl_->DidDrawAllLayers(frame2); | 2072 host_impl_->DidDrawAllLayers(frame2); |
| 2090 } | 2073 } |
| 2091 | 2074 |
| 2092 TEST_F(LayerTreeHostImplTest, | 2075 TEST_F(LayerTreeHostImplTest, |
| 2093 PrepareToDrawFailsWithAnimationAndMissingTilesUsesCheckerboard) { | 2076 PrepareToDrawFailsWithAnimationAndMissingTilesUsesCheckerboard) { |
| 2094 host_impl_->active_tree()->SetRootLayer( | 2077 host_impl_->active_tree()->SetRootLayer( |
| 2095 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); | 2078 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); |
| 2096 DidDrawCheckLayer* root = | 2079 DidDrawCheckLayer* root = |
| 2097 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2080 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 2081 root->SetHasRenderSurface(true); |
| 2098 | 2082 |
| 2099 LayerTreeHostImpl::FrameData frame; | 2083 LayerTreeHostImpl::FrameData frame; |
| 2100 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2084 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 2101 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2085 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2102 host_impl_->DidDrawAllLayers(frame); | 2086 host_impl_->DidDrawAllLayers(frame); |
| 2103 host_impl_->SwapBuffers(frame); | 2087 host_impl_->SwapBuffers(frame); |
| 2104 | 2088 |
| 2105 bool tile_missing = true; | 2089 bool tile_missing = true; |
| 2106 bool had_incomplete_tile = false; | 2090 bool had_incomplete_tile = false; |
| 2107 bool is_animating = true; | 2091 bool is_animating = true; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2118 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); | 2102 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); |
| 2119 host_impl_->DidDrawAllLayers(frame2); | 2103 host_impl_->DidDrawAllLayers(frame2); |
| 2120 } | 2104 } |
| 2121 | 2105 |
| 2122 TEST_F(LayerTreeHostImplTest, | 2106 TEST_F(LayerTreeHostImplTest, |
| 2123 PrepareToDrawSucceedsWithAnimationAndIncompleteTiles) { | 2107 PrepareToDrawSucceedsWithAnimationAndIncompleteTiles) { |
| 2124 host_impl_->active_tree()->SetRootLayer( | 2108 host_impl_->active_tree()->SetRootLayer( |
| 2125 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); | 2109 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); |
| 2126 DidDrawCheckLayer* root = | 2110 DidDrawCheckLayer* root = |
| 2127 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2111 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 2112 root->SetHasRenderSurface(true); |
| 2128 | 2113 |
| 2129 LayerTreeHostImpl::FrameData frame; | 2114 LayerTreeHostImpl::FrameData frame; |
| 2130 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2115 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 2131 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2116 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2132 host_impl_->DidDrawAllLayers(frame); | 2117 host_impl_->DidDrawAllLayers(frame); |
| 2133 host_impl_->SwapBuffers(frame); | 2118 host_impl_->SwapBuffers(frame); |
| 2134 | 2119 |
| 2135 bool tile_missing = false; | 2120 bool tile_missing = false; |
| 2136 bool had_incomplete_tile = true; | 2121 bool had_incomplete_tile = true; |
| 2137 bool is_animating = true; | 2122 bool is_animating = true; |
| 2138 root->AddChild( | 2123 root->AddChild( |
| 2139 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 2124 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
| 2140 6, | 2125 6, |
| 2141 tile_missing, | 2126 tile_missing, |
| 2142 had_incomplete_tile, | 2127 had_incomplete_tile, |
| 2143 is_animating, | 2128 is_animating, |
| 2144 host_impl_->resource_provider())); | 2129 host_impl_->resource_provider())); |
| 2145 LayerTreeHostImpl::FrameData frame2; | 2130 LayerTreeHostImpl::FrameData frame2; |
| 2146 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame2)); | 2131 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame2)); |
| 2147 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); | 2132 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); |
| 2148 host_impl_->DidDrawAllLayers(frame2); | 2133 host_impl_->DidDrawAllLayers(frame2); |
| 2149 } | 2134 } |
| 2150 | 2135 |
| 2151 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWhenHighResRequired) { | 2136 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWhenHighResRequired) { |
| 2152 host_impl_->active_tree()->SetRootLayer( | 2137 host_impl_->active_tree()->SetRootLayer( |
| 2153 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); | 2138 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); |
| 2154 DidDrawCheckLayer* root = | 2139 DidDrawCheckLayer* root = |
| 2155 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2140 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 2141 root->SetHasRenderSurface(true); |
| 2156 | 2142 |
| 2157 LayerTreeHostImpl::FrameData frame; | 2143 LayerTreeHostImpl::FrameData frame; |
| 2158 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2144 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 2159 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2145 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2160 host_impl_->DidDrawAllLayers(frame); | 2146 host_impl_->DidDrawAllLayers(frame); |
| 2161 host_impl_->SwapBuffers(frame); | 2147 host_impl_->SwapBuffers(frame); |
| 2162 | 2148 |
| 2163 bool tile_missing = false; | 2149 bool tile_missing = false; |
| 2164 bool had_incomplete_tile = false; | 2150 bool had_incomplete_tile = false; |
| 2165 bool is_animating = false; | 2151 bool is_animating = false; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2176 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); | 2162 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); |
| 2177 host_impl_->DidDrawAllLayers(frame2); | 2163 host_impl_->DidDrawAllLayers(frame2); |
| 2178 } | 2164 } |
| 2179 | 2165 |
| 2180 TEST_F(LayerTreeHostImplTest, | 2166 TEST_F(LayerTreeHostImplTest, |
| 2181 PrepareToDrawFailsWhenHighResRequiredAndIncompleteTiles) { | 2167 PrepareToDrawFailsWhenHighResRequiredAndIncompleteTiles) { |
| 2182 host_impl_->active_tree()->SetRootLayer( | 2168 host_impl_->active_tree()->SetRootLayer( |
| 2183 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); | 2169 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); |
| 2184 DidDrawCheckLayer* root = | 2170 DidDrawCheckLayer* root = |
| 2185 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2171 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 2172 root->SetHasRenderSurface(true); |
| 2186 | 2173 |
| 2187 LayerTreeHostImpl::FrameData frame; | 2174 LayerTreeHostImpl::FrameData frame; |
| 2188 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2175 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 2189 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2176 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2190 host_impl_->DidDrawAllLayers(frame); | 2177 host_impl_->DidDrawAllLayers(frame); |
| 2191 host_impl_->SwapBuffers(frame); | 2178 host_impl_->SwapBuffers(frame); |
| 2192 | 2179 |
| 2193 bool tile_missing = false; | 2180 bool tile_missing = false; |
| 2194 bool had_incomplete_tile = true; | 2181 bool had_incomplete_tile = true; |
| 2195 bool is_animating = false; | 2182 bool is_animating = false; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2207 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); | 2194 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); |
| 2208 host_impl_->DidDrawAllLayers(frame2); | 2195 host_impl_->DidDrawAllLayers(frame2); |
| 2209 } | 2196 } |
| 2210 | 2197 |
| 2211 TEST_F(LayerTreeHostImplTest, | 2198 TEST_F(LayerTreeHostImplTest, |
| 2212 PrepareToDrawFailsWhenHighResRequiredAndMissingTile) { | 2199 PrepareToDrawFailsWhenHighResRequiredAndMissingTile) { |
| 2213 host_impl_->active_tree()->SetRootLayer( | 2200 host_impl_->active_tree()->SetRootLayer( |
| 2214 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); | 2201 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); |
| 2215 DidDrawCheckLayer* root = | 2202 DidDrawCheckLayer* root = |
| 2216 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2203 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 2204 root->SetHasRenderSurface(true); |
| 2217 | 2205 |
| 2218 LayerTreeHostImpl::FrameData frame; | 2206 LayerTreeHostImpl::FrameData frame; |
| 2219 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2207 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 2220 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2208 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2221 host_impl_->DidDrawAllLayers(frame); | 2209 host_impl_->DidDrawAllLayers(frame); |
| 2222 host_impl_->SwapBuffers(frame); | 2210 host_impl_->SwapBuffers(frame); |
| 2223 | 2211 |
| 2224 bool tile_missing = true; | 2212 bool tile_missing = true; |
| 2225 bool had_incomplete_tile = false; | 2213 bool had_incomplete_tile = false; |
| 2226 bool is_animating = false; | 2214 bool is_animating = false; |
| 2227 root->AddChild( | 2215 root->AddChild( |
| 2228 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 2216 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
| 2229 8, | 2217 8, |
| 2230 tile_missing, | 2218 tile_missing, |
| 2231 had_incomplete_tile, | 2219 had_incomplete_tile, |
| 2232 is_animating, | 2220 is_animating, |
| 2233 host_impl_->resource_provider())); | 2221 host_impl_->resource_provider())); |
| 2234 host_impl_->SetRequiresHighResToDraw(); | 2222 host_impl_->SetRequiresHighResToDraw(); |
| 2235 LayerTreeHostImpl::FrameData frame2; | 2223 LayerTreeHostImpl::FrameData frame2; |
| 2236 EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT, | 2224 EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT, |
| 2237 host_impl_->PrepareToDraw(&frame2)); | 2225 host_impl_->PrepareToDraw(&frame2)); |
| 2238 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); | 2226 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); |
| 2239 host_impl_->DidDrawAllLayers(frame2); | 2227 host_impl_->DidDrawAllLayers(frame2); |
| 2240 } | 2228 } |
| 2241 | 2229 |
| 2242 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { | 2230 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { |
| 2243 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 2231 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 2244 root->SetScrollClipLayer(Layer::INVALID_ID); | 2232 root->SetScrollClipLayer(Layer::INVALID_ID); |
| 2233 root->SetHasRenderSurface(true); |
| 2245 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 2234 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 2246 DrawFrame(); | 2235 DrawFrame(); |
| 2247 | 2236 |
| 2248 // Scroll event is ignored because layer is not scrollable. | 2237 // Scroll event is ignored because layer is not scrollable. |
| 2249 EXPECT_EQ(InputHandler::ScrollIgnored, | 2238 EXPECT_EQ(InputHandler::ScrollIgnored, |
| 2250 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); | 2239 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
| 2251 EXPECT_FALSE(did_request_redraw_); | 2240 EXPECT_FALSE(did_request_redraw_); |
| 2252 EXPECT_FALSE(did_request_commit_); | 2241 EXPECT_FALSE(did_request_commit_); |
| 2253 } | 2242 } |
| 2254 | 2243 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2289 LayerImpl::Create(host_impl_->active_tree(), 2); | 2278 LayerImpl::Create(host_impl_->active_tree(), 2); |
| 2290 root_clip->SetBounds(clip_size_); | 2279 root_clip->SetBounds(clip_size_); |
| 2291 root->SetScrollClipLayer(root_clip->id()); | 2280 root->SetScrollClipLayer(root_clip->id()); |
| 2292 root->SetBounds(layer_size_); | 2281 root->SetBounds(layer_size_); |
| 2293 root->SetContentBounds(layer_size_); | 2282 root->SetContentBounds(layer_size_); |
| 2294 root->SetPosition(gfx::PointF()); | 2283 root->SetPosition(gfx::PointF()); |
| 2295 root->SetDrawsContent(false); | 2284 root->SetDrawsContent(false); |
| 2296 root->SetIsContainerForFixedPositionLayers(true); | 2285 root->SetIsContainerForFixedPositionLayers(true); |
| 2297 int inner_viewport_scroll_layer_id = root->id(); | 2286 int inner_viewport_scroll_layer_id = root->id(); |
| 2298 int page_scale_layer_id = root_clip->id(); | 2287 int page_scale_layer_id = root_clip->id(); |
| 2288 root_clip->SetHasRenderSurface(true); |
| 2299 root_clip->AddChild(root.Pass()); | 2289 root_clip->AddChild(root.Pass()); |
| 2290 root_clip->SetHasRenderSurface(true); |
| 2300 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 2291 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); |
| 2301 host_impl_->active_tree()->SetViewportLayersFromIds( | 2292 host_impl_->active_tree()->SetViewportLayersFromIds( |
| 2302 Layer::INVALID_ID, page_scale_layer_id, inner_viewport_scroll_layer_id, | 2293 Layer::INVALID_ID, page_scale_layer_id, inner_viewport_scroll_layer_id, |
| 2303 Layer::INVALID_ID); | 2294 Layer::INVALID_ID); |
| 2304 // Set a viewport size that is large enough to contain both the top controls | 2295 // Set a viewport size that is large enough to contain both the top controls |
| 2305 // and some content. | 2296 // and some content. |
| 2306 host_impl_->SetViewportSize(viewport_size_); | 2297 host_impl_->SetViewportSize(viewport_size_); |
| 2307 host_impl_->sync_tree()->set_top_controls_shrink_blink_size(true); | 2298 host_impl_->sync_tree()->set_top_controls_shrink_blink_size(true); |
| 2308 | 2299 |
| 2309 host_impl_->DidChangeTopControlsPosition(); | 2300 host_impl_->DidChangeTopControlsPosition(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2354 scoped_ptr<LayerImpl> outer_clip = | 2345 scoped_ptr<LayerImpl> outer_clip = |
| 2355 LayerImpl::Create(host_impl_->active_tree(), 5); | 2346 LayerImpl::Create(host_impl_->active_tree(), 5); |
| 2356 | 2347 |
| 2357 root_clip->SetBounds(inner_viewport_size); | 2348 root_clip->SetBounds(inner_viewport_size); |
| 2358 root->SetScrollClipLayer(root_clip->id()); | 2349 root->SetScrollClipLayer(root_clip->id()); |
| 2359 root->SetBounds(outer_viewport_size); | 2350 root->SetBounds(outer_viewport_size); |
| 2360 root->SetContentBounds(outer_viewport_size); | 2351 root->SetContentBounds(outer_viewport_size); |
| 2361 root->SetPosition(gfx::PointF()); | 2352 root->SetPosition(gfx::PointF()); |
| 2362 root->SetDrawsContent(false); | 2353 root->SetDrawsContent(false); |
| 2363 root->SetIsContainerForFixedPositionLayers(true); | 2354 root->SetIsContainerForFixedPositionLayers(true); |
| 2364 | 2355 root_clip->SetHasRenderSurface(true); |
| 2365 outer_clip->SetBounds(outer_viewport_size); | 2356 outer_clip->SetBounds(outer_viewport_size); |
| 2366 outer_scroll->SetScrollClipLayer(outer_clip->id()); | 2357 outer_scroll->SetScrollClipLayer(outer_clip->id()); |
| 2367 outer_scroll->SetBounds(scroll_layer_size); | 2358 outer_scroll->SetBounds(scroll_layer_size); |
| 2368 outer_scroll->SetContentBounds(scroll_layer_size); | 2359 outer_scroll->SetContentBounds(scroll_layer_size); |
| 2369 outer_scroll->SetPosition(gfx::PointF()); | 2360 outer_scroll->SetPosition(gfx::PointF()); |
| 2370 outer_scroll->SetDrawsContent(false); | 2361 outer_scroll->SetDrawsContent(false); |
| 2371 outer_scroll->SetIsContainerForFixedPositionLayers(true); | 2362 outer_scroll->SetIsContainerForFixedPositionLayers(true); |
| 2372 | 2363 |
| 2373 int inner_viewport_scroll_layer_id = root->id(); | 2364 int inner_viewport_scroll_layer_id = root->id(); |
| 2374 int outer_viewport_scroll_layer_id = outer_scroll->id(); | 2365 int outer_viewport_scroll_layer_id = outer_scroll->id(); |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2927 | 2918 |
| 2928 scoped_ptr<LayerImpl> scroll_layer = | 2919 scoped_ptr<LayerImpl> scroll_layer = |
| 2929 LayerImpl::Create(host_impl_->active_tree(), 2); | 2920 LayerImpl::Create(host_impl_->active_tree(), 2); |
| 2930 scroll_layer->SetScrollClipLayer(3); | 2921 scroll_layer->SetScrollClipLayer(3); |
| 2931 scroll_layer->SetBounds(contents_size); | 2922 scroll_layer->SetBounds(contents_size); |
| 2932 scroll_layer->SetContentBounds(contents_size); | 2923 scroll_layer->SetContentBounds(contents_size); |
| 2933 scroll_layer->SetPosition(gfx::PointF()); | 2924 scroll_layer->SetPosition(gfx::PointF()); |
| 2934 scroll_layer->AddChild(content_layer.Pass()); | 2925 scroll_layer->AddChild(content_layer.Pass()); |
| 2935 scroll_clip_layer->AddChild(scroll_layer.Pass()); | 2926 scroll_clip_layer->AddChild(scroll_layer.Pass()); |
| 2936 | 2927 |
| 2928 scroll_clip_layer->SetHasRenderSurface(true); |
| 2937 host_impl_->active_tree()->SetRootLayer(scroll_clip_layer.Pass()); | 2929 host_impl_->active_tree()->SetRootLayer(scroll_clip_layer.Pass()); |
| 2938 host_impl_->SetViewportSize(surface_size); | 2930 host_impl_->SetViewportSize(surface_size); |
| 2939 DrawFrame(); | 2931 DrawFrame(); |
| 2940 | 2932 |
| 2941 EXPECT_EQ(InputHandler::ScrollStarted, | 2933 EXPECT_EQ(InputHandler::ScrollStarted, |
| 2942 host_impl_->ScrollBegin(gfx::Point(5, 5), | 2934 host_impl_->ScrollBegin(gfx::Point(5, 5), |
| 2943 InputHandler::Wheel)); | 2935 InputHandler::Wheel)); |
| 2944 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 2936 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
| 2945 host_impl_->ScrollEnd(); | 2937 host_impl_->ScrollEnd(); |
| 2946 EXPECT_TRUE(did_request_redraw_); | 2938 EXPECT_TRUE(did_request_redraw_); |
| 2947 EXPECT_TRUE(did_request_commit_); | 2939 EXPECT_TRUE(did_request_commit_); |
| 2948 } | 2940 } |
| 2949 | 2941 |
| 2950 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) { | 2942 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) { |
| 2951 gfx::Size surface_size(10, 10); | 2943 gfx::Size surface_size(10, 10); |
| 2952 gfx::Size contents_size(20, 20); | 2944 gfx::Size contents_size(20, 20); |
| 2953 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 2945 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 2954 root->SetBounds(surface_size); | 2946 root->SetBounds(surface_size); |
| 2955 root->SetContentBounds(contents_size); | 2947 root->SetContentBounds(contents_size); |
| 2956 root->AddChild(CreateScrollableLayer(2, contents_size, root.get())); | 2948 root->AddChild(CreateScrollableLayer(2, contents_size, root.get())); |
| 2949 root->SetHasRenderSurface(true); |
| 2957 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 2950 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 2958 host_impl_->SetViewportSize(surface_size); | 2951 host_impl_->SetViewportSize(surface_size); |
| 2959 DrawFrame(); | 2952 DrawFrame(); |
| 2960 | 2953 |
| 2961 EXPECT_EQ(InputHandler::ScrollStarted, | 2954 EXPECT_EQ(InputHandler::ScrollStarted, |
| 2962 host_impl_->ScrollBegin(gfx::Point(5, 5), | 2955 host_impl_->ScrollBegin(gfx::Point(5, 5), |
| 2963 InputHandler::Wheel)); | 2956 InputHandler::Wheel)); |
| 2964 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 2957 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
| 2965 host_impl_->ScrollEnd(); | 2958 host_impl_->ScrollEnd(); |
| 2966 EXPECT_TRUE(did_request_redraw_); | 2959 EXPECT_TRUE(did_request_redraw_); |
| 2967 EXPECT_TRUE(did_request_commit_); | 2960 EXPECT_TRUE(did_request_commit_); |
| 2968 } | 2961 } |
| 2969 | 2962 |
| 2970 TEST_F(LayerTreeHostImplTest, ScrollMissesChild) { | 2963 TEST_F(LayerTreeHostImplTest, ScrollMissesChild) { |
| 2971 gfx::Size surface_size(10, 10); | 2964 gfx::Size surface_size(10, 10); |
| 2972 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 2965 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 2973 root->AddChild(CreateScrollableLayer(2, surface_size, root.get())); | 2966 root->AddChild(CreateScrollableLayer(2, surface_size, root.get())); |
| 2967 root->SetHasRenderSurface(true); |
| 2974 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 2968 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 2975 host_impl_->SetViewportSize(surface_size); | 2969 host_impl_->SetViewportSize(surface_size); |
| 2976 DrawFrame(); | 2970 DrawFrame(); |
| 2977 | 2971 |
| 2978 // Scroll event is ignored because the input coordinate is outside the layer | 2972 // Scroll event is ignored because the input coordinate is outside the layer |
| 2979 // boundaries. | 2973 // boundaries. |
| 2980 EXPECT_EQ(InputHandler::ScrollIgnored, | 2974 EXPECT_EQ(InputHandler::ScrollIgnored, |
| 2981 host_impl_->ScrollBegin(gfx::Point(15, 5), | 2975 host_impl_->ScrollBegin(gfx::Point(15, 5), |
| 2982 InputHandler::Wheel)); | 2976 InputHandler::Wheel)); |
| 2983 EXPECT_FALSE(did_request_redraw_); | 2977 EXPECT_FALSE(did_request_redraw_); |
| 2984 EXPECT_FALSE(did_request_commit_); | 2978 EXPECT_FALSE(did_request_commit_); |
| 2985 } | 2979 } |
| 2986 | 2980 |
| 2987 TEST_F(LayerTreeHostImplTest, ScrollMissesBackfacingChild) { | 2981 TEST_F(LayerTreeHostImplTest, ScrollMissesBackfacingChild) { |
| 2988 gfx::Size surface_size(10, 10); | 2982 gfx::Size surface_size(10, 10); |
| 2989 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 2983 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 2984 root->SetHasRenderSurface(true); |
| 2990 scoped_ptr<LayerImpl> child = | 2985 scoped_ptr<LayerImpl> child = |
| 2991 CreateScrollableLayer(2, surface_size, root.get()); | 2986 CreateScrollableLayer(2, surface_size, root.get()); |
| 2992 host_impl_->SetViewportSize(surface_size); | 2987 host_impl_->SetViewportSize(surface_size); |
| 2993 | 2988 |
| 2994 gfx::Transform matrix; | 2989 gfx::Transform matrix; |
| 2995 matrix.RotateAboutXAxis(180.0); | 2990 matrix.RotateAboutXAxis(180.0); |
| 2996 child->SetTransform(matrix); | 2991 child->SetTransform(matrix); |
| 2997 child->SetDoubleSided(false); | 2992 child->SetDoubleSided(false); |
| 2998 | 2993 |
| 2999 root->AddChild(child.Pass()); | 2994 root->AddChild(child.Pass()); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3017 CreateScrollableLayer(1, surface_size, clip_layer.get()); | 3012 CreateScrollableLayer(1, surface_size, clip_layer.get()); |
| 3018 content_layer->SetShouldScrollOnMainThread(true); | 3013 content_layer->SetShouldScrollOnMainThread(true); |
| 3019 content_layer->SetScrollClipLayer(Layer::INVALID_ID); | 3014 content_layer->SetScrollClipLayer(Layer::INVALID_ID); |
| 3020 | 3015 |
| 3021 // Note: we can use the same clip layer for both since both calls to | 3016 // Note: we can use the same clip layer for both since both calls to |
| 3022 // CreateScrollableLayer() use the same surface size. | 3017 // CreateScrollableLayer() use the same surface size. |
| 3023 scoped_ptr<LayerImpl> scroll_layer = | 3018 scoped_ptr<LayerImpl> scroll_layer = |
| 3024 CreateScrollableLayer(2, surface_size, clip_layer.get()); | 3019 CreateScrollableLayer(2, surface_size, clip_layer.get()); |
| 3025 scroll_layer->AddChild(content_layer.Pass()); | 3020 scroll_layer->AddChild(content_layer.Pass()); |
| 3026 clip_layer->AddChild(scroll_layer.Pass()); | 3021 clip_layer->AddChild(scroll_layer.Pass()); |
| 3022 clip_layer->SetHasRenderSurface(true); |
| 3027 | 3023 |
| 3028 host_impl_->active_tree()->SetRootLayer(clip_layer.Pass()); | 3024 host_impl_->active_tree()->SetRootLayer(clip_layer.Pass()); |
| 3029 host_impl_->SetViewportSize(surface_size); | 3025 host_impl_->SetViewportSize(surface_size); |
| 3030 DrawFrame(); | 3026 DrawFrame(); |
| 3031 | 3027 |
| 3032 // Scrolling fails because the content layer is asking to be scrolled on the | 3028 // Scrolling fails because the content layer is asking to be scrolled on the |
| 3033 // main thread. | 3029 // main thread. |
| 3034 EXPECT_EQ(InputHandler::ScrollOnMainThread, | 3030 EXPECT_EQ(InputHandler::ScrollOnMainThread, |
| 3035 host_impl_->ScrollBegin(gfx::Point(5, 5), | 3031 host_impl_->ScrollBegin(gfx::Point(5, 5), |
| 3036 InputHandler::Wheel)); | 3032 InputHandler::Wheel)); |
| 3037 } | 3033 } |
| 3038 | 3034 |
| 3039 TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnMainThread) { | 3035 TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnMainThread) { |
| 3040 gfx::Size surface_size(20, 20); | 3036 gfx::Size surface_size(20, 20); |
| 3041 gfx::Size viewport_size(10, 10); | 3037 gfx::Size viewport_size(10, 10); |
| 3042 float page_scale = 2.f; | 3038 float page_scale = 2.f; |
| 3043 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 3039 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 3044 scoped_ptr<LayerImpl> root_clip = | 3040 scoped_ptr<LayerImpl> root_clip = |
| 3045 LayerImpl::Create(host_impl_->active_tree(), 2); | 3041 LayerImpl::Create(host_impl_->active_tree(), 2); |
| 3046 scoped_ptr<LayerImpl> root_scrolling = | 3042 scoped_ptr<LayerImpl> root_scrolling = |
| 3047 CreateScrollableLayer(3, surface_size, root_clip.get()); | 3043 CreateScrollableLayer(3, surface_size, root_clip.get()); |
| 3048 EXPECT_EQ(viewport_size, root_clip->bounds()); | 3044 EXPECT_EQ(viewport_size, root_clip->bounds()); |
| 3049 root_scrolling->SetIsContainerForFixedPositionLayers(true); | 3045 root_scrolling->SetIsContainerForFixedPositionLayers(true); |
| 3050 root_clip->AddChild(root_scrolling.Pass()); | 3046 root_clip->AddChild(root_scrolling.Pass()); |
| 3051 root->AddChild(root_clip.Pass()); | 3047 root->AddChild(root_clip.Pass()); |
| 3048 root->SetHasRenderSurface(true); |
| 3052 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 3049 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 3053 // The behaviour in this test assumes the page scale is applied at a layer | 3050 // The behaviour in this test assumes the page scale is applied at a layer |
| 3054 // above the clip layer. | 3051 // above the clip layer. |
| 3055 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3, | 3052 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3, |
| 3056 Layer::INVALID_ID); | 3053 Layer::INVALID_ID); |
| 3057 host_impl_->active_tree()->DidBecomeActive(); | 3054 host_impl_->active_tree()->DidBecomeActive(); |
| 3058 host_impl_->SetViewportSize(viewport_size); | 3055 host_impl_->SetViewportSize(viewport_size); |
| 3059 DrawFrame(); | 3056 DrawFrame(); |
| 3060 | 3057 |
| 3061 LayerImpl* root_scroll = | 3058 LayerImpl* root_scroll = |
| (...skipping 30 matching lines...) Expand all Loading... |
| 3092 float page_scale = 2.f; | 3089 float page_scale = 2.f; |
| 3093 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 3090 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 3094 scoped_ptr<LayerImpl> root_clip = | 3091 scoped_ptr<LayerImpl> root_clip = |
| 3095 LayerImpl::Create(host_impl_->active_tree(), 2); | 3092 LayerImpl::Create(host_impl_->active_tree(), 2); |
| 3096 scoped_ptr<LayerImpl> root_scrolling = | 3093 scoped_ptr<LayerImpl> root_scrolling = |
| 3097 CreateScrollableLayer(3, surface_size, root_clip.get()); | 3094 CreateScrollableLayer(3, surface_size, root_clip.get()); |
| 3098 EXPECT_EQ(viewport_size, root_clip->bounds()); | 3095 EXPECT_EQ(viewport_size, root_clip->bounds()); |
| 3099 root_scrolling->SetIsContainerForFixedPositionLayers(true); | 3096 root_scrolling->SetIsContainerForFixedPositionLayers(true); |
| 3100 root_clip->AddChild(root_scrolling.Pass()); | 3097 root_clip->AddChild(root_scrolling.Pass()); |
| 3101 root->AddChild(root_clip.Pass()); | 3098 root->AddChild(root_clip.Pass()); |
| 3099 root->SetHasRenderSurface(true); |
| 3102 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 3100 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 3103 // The behaviour in this test assumes the page scale is applied at a layer | 3101 // The behaviour in this test assumes the page scale is applied at a layer |
| 3104 // above the clip layer. | 3102 // above the clip layer. |
| 3105 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3, | 3103 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3, |
| 3106 Layer::INVALID_ID); | 3104 Layer::INVALID_ID); |
| 3107 host_impl_->active_tree()->DidBecomeActive(); | 3105 host_impl_->active_tree()->DidBecomeActive(); |
| 3108 host_impl_->SetViewportSize(viewport_size); | 3106 host_impl_->SetViewportSize(viewport_size); |
| 3109 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, page_scale); | 3107 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, page_scale); |
| 3110 DrawFrame(); | 3108 DrawFrame(); |
| 3111 | 3109 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3197 EXPECT_EQ(new_page_scale, | 3195 EXPECT_EQ(new_page_scale, |
| 3198 grand_child->draw_transform().matrix().getDouble(0, 0)); | 3196 grand_child->draw_transform().matrix().getDouble(0, 0)); |
| 3199 EXPECT_EQ(new_page_scale, | 3197 EXPECT_EQ(new_page_scale, |
| 3200 grand_child->draw_transform().matrix().getDouble(1, 1)); | 3198 grand_child->draw_transform().matrix().getDouble(1, 1)); |
| 3201 } | 3199 } |
| 3202 | 3200 |
| 3203 TEST_F(LayerTreeHostImplTest, ScrollChildAndChangePageScaleOnMainThread) { | 3201 TEST_F(LayerTreeHostImplTest, ScrollChildAndChangePageScaleOnMainThread) { |
| 3204 gfx::Size surface_size(30, 30); | 3202 gfx::Size surface_size(30, 30); |
| 3205 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 3203 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 3206 root->SetBounds(gfx::Size(5, 5)); | 3204 root->SetBounds(gfx::Size(5, 5)); |
| 3205 root->SetHasRenderSurface(true); |
| 3207 scoped_ptr<LayerImpl> root_scrolling = | 3206 scoped_ptr<LayerImpl> root_scrolling = |
| 3208 LayerImpl::Create(host_impl_->active_tree(), 2); | 3207 LayerImpl::Create(host_impl_->active_tree(), 2); |
| 3209 root_scrolling->SetBounds(surface_size); | 3208 root_scrolling->SetBounds(surface_size); |
| 3210 root_scrolling->SetContentBounds(surface_size); | 3209 root_scrolling->SetContentBounds(surface_size); |
| 3211 root_scrolling->SetScrollClipLayer(root->id()); | 3210 root_scrolling->SetScrollClipLayer(root->id()); |
| 3212 root_scrolling->SetIsContainerForFixedPositionLayers(true); | 3211 root_scrolling->SetIsContainerForFixedPositionLayers(true); |
| 3213 LayerImpl* root_scrolling_ptr = root_scrolling.get(); | 3212 LayerImpl* root_scrolling_ptr = root_scrolling.get(); |
| 3214 root->AddChild(root_scrolling.Pass()); | 3213 root->AddChild(root_scrolling.Pass()); |
| 3215 int child_scroll_layer_id = 3; | 3214 int child_scroll_layer_id = 3; |
| 3216 scoped_ptr<LayerImpl> child_scrolling = CreateScrollableLayer( | 3215 scoped_ptr<LayerImpl> child_scrolling = CreateScrollableLayer( |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3252 } | 3251 } |
| 3253 | 3252 |
| 3254 TEST_F(LayerTreeHostImplTest, ScrollChildBeyondLimit) { | 3253 TEST_F(LayerTreeHostImplTest, ScrollChildBeyondLimit) { |
| 3255 // Scroll a child layer beyond its maximum scroll range and make sure the | 3254 // Scroll a child layer beyond its maximum scroll range and make sure the |
| 3256 // parent layer is scrolled on the axis on which the child was unable to | 3255 // parent layer is scrolled on the axis on which the child was unable to |
| 3257 // scroll. | 3256 // scroll. |
| 3258 gfx::Size surface_size(10, 10); | 3257 gfx::Size surface_size(10, 10); |
| 3259 gfx::Size content_size(20, 20); | 3258 gfx::Size content_size(20, 20); |
| 3260 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 3259 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 3261 root->SetBounds(surface_size); | 3260 root->SetBounds(surface_size); |
| 3262 | 3261 root->SetHasRenderSurface(true); |
| 3263 scoped_ptr<LayerImpl> grand_child = | 3262 scoped_ptr<LayerImpl> grand_child = |
| 3264 CreateScrollableLayer(3, content_size, root.get()); | 3263 CreateScrollableLayer(3, content_size, root.get()); |
| 3265 | 3264 |
| 3266 scoped_ptr<LayerImpl> child = | 3265 scoped_ptr<LayerImpl> child = |
| 3267 CreateScrollableLayer(2, content_size, root.get()); | 3266 CreateScrollableLayer(2, content_size, root.get()); |
| 3268 LayerImpl* grand_child_layer = grand_child.get(); | 3267 LayerImpl* grand_child_layer = grand_child.get(); |
| 3269 child->AddChild(grand_child.Pass()); | 3268 child->AddChild(grand_child.Pass()); |
| 3270 | 3269 |
| 3271 LayerImpl* child_layer = child.get(); | 3270 LayerImpl* child_layer = child.get(); |
| 3272 root->AddChild(child.Pass()); | 3271 root->AddChild(child.Pass()); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 3297 ExpectContains(*scroll_info.get(), child->id(), gfx::Vector2d(-3, 0)); | 3296 ExpectContains(*scroll_info.get(), child->id(), gfx::Vector2d(-3, 0)); |
| 3298 } | 3297 } |
| 3299 } | 3298 } |
| 3300 | 3299 |
| 3301 TEST_F(LayerTreeHostImplTest, ScrollWithoutBubbling) { | 3300 TEST_F(LayerTreeHostImplTest, ScrollWithoutBubbling) { |
| 3302 // Scroll a child layer beyond its maximum scroll range and make sure the | 3301 // Scroll a child layer beyond its maximum scroll range and make sure the |
| 3303 // the scroll doesn't bubble up to the parent layer. | 3302 // the scroll doesn't bubble up to the parent layer. |
| 3304 gfx::Size surface_size(20, 20); | 3303 gfx::Size surface_size(20, 20); |
| 3305 gfx::Size viewport_size(10, 10); | 3304 gfx::Size viewport_size(10, 10); |
| 3306 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 3305 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 3306 root->SetHasRenderSurface(true); |
| 3307 scoped_ptr<LayerImpl> root_scrolling = | 3307 scoped_ptr<LayerImpl> root_scrolling = |
| 3308 CreateScrollableLayer(2, surface_size, root.get()); | 3308 CreateScrollableLayer(2, surface_size, root.get()); |
| 3309 root_scrolling->SetIsContainerForFixedPositionLayers(true); | 3309 root_scrolling->SetIsContainerForFixedPositionLayers(true); |
| 3310 | 3310 |
| 3311 scoped_ptr<LayerImpl> grand_child = | 3311 scoped_ptr<LayerImpl> grand_child = |
| 3312 CreateScrollableLayer(4, surface_size, root.get()); | 3312 CreateScrollableLayer(4, surface_size, root.get()); |
| 3313 | 3313 |
| 3314 scoped_ptr<LayerImpl> child = | 3314 scoped_ptr<LayerImpl> child = |
| 3315 CreateScrollableLayer(3, surface_size, root.get()); | 3315 CreateScrollableLayer(3, surface_size, root.get()); |
| 3316 LayerImpl* grand_child_layer = grand_child.get(); | 3316 LayerImpl* grand_child_layer = grand_child.get(); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3406 ExpectContains(*scroll_info.get(), grand_child->id(), gfx::Vector2d(0, 4)); | 3406 ExpectContains(*scroll_info.get(), grand_child->id(), gfx::Vector2d(0, 4)); |
| 3407 } | 3407 } |
| 3408 } | 3408 } |
| 3409 TEST_F(LayerTreeHostImplTest, ScrollEventBubbling) { | 3409 TEST_F(LayerTreeHostImplTest, ScrollEventBubbling) { |
| 3410 // When we try to scroll a non-scrollable child layer, the scroll delta | 3410 // When we try to scroll a non-scrollable child layer, the scroll delta |
| 3411 // should be applied to one of its ancestors if possible. | 3411 // should be applied to one of its ancestors if possible. |
| 3412 gfx::Size surface_size(10, 10); | 3412 gfx::Size surface_size(10, 10); |
| 3413 gfx::Size content_size(20, 20); | 3413 gfx::Size content_size(20, 20); |
| 3414 scoped_ptr<LayerImpl> root_clip = | 3414 scoped_ptr<LayerImpl> root_clip = |
| 3415 LayerImpl::Create(host_impl_->active_tree(), 3); | 3415 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 3416 root_clip->SetHasRenderSurface(true); |
| 3416 scoped_ptr<LayerImpl> root = | 3417 scoped_ptr<LayerImpl> root = |
| 3417 CreateScrollableLayer(1, content_size, root_clip.get()); | 3418 CreateScrollableLayer(1, content_size, root_clip.get()); |
| 3418 // Make 'root' the clip layer for child: since they have the same sizes the | 3419 // Make 'root' the clip layer for child: since they have the same sizes the |
| 3419 // child will have zero max_scroll_offset and scrolls will bubble. | 3420 // child will have zero max_scroll_offset and scrolls will bubble. |
| 3420 scoped_ptr<LayerImpl> child = | 3421 scoped_ptr<LayerImpl> child = |
| 3421 CreateScrollableLayer(2, content_size, root.get()); | 3422 CreateScrollableLayer(2, content_size, root.get()); |
| 3422 child->SetIsContainerForFixedPositionLayers(true); | 3423 child->SetIsContainerForFixedPositionLayers(true); |
| 3423 root->SetBounds(content_size); | 3424 root->SetBounds(content_size); |
| 3424 | 3425 |
| 3425 int root_scroll_id = root->id(); | 3426 int root_scroll_id = root->id(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 3449 } | 3450 } |
| 3450 } | 3451 } |
| 3451 | 3452 |
| 3452 TEST_F(LayerTreeHostImplTest, ScrollBeforeRedraw) { | 3453 TEST_F(LayerTreeHostImplTest, ScrollBeforeRedraw) { |
| 3453 gfx::Size surface_size(10, 10); | 3454 gfx::Size surface_size(10, 10); |
| 3454 scoped_ptr<LayerImpl> root_clip = | 3455 scoped_ptr<LayerImpl> root_clip = |
| 3455 LayerImpl::Create(host_impl_->active_tree(), 1); | 3456 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 3456 scoped_ptr<LayerImpl> root_scroll = | 3457 scoped_ptr<LayerImpl> root_scroll = |
| 3457 CreateScrollableLayer(2, surface_size, root_clip.get()); | 3458 CreateScrollableLayer(2, surface_size, root_clip.get()); |
| 3458 root_scroll->SetIsContainerForFixedPositionLayers(true); | 3459 root_scroll->SetIsContainerForFixedPositionLayers(true); |
| 3460 root_clip->SetHasRenderSurface(true); |
| 3459 root_clip->AddChild(root_scroll.Pass()); | 3461 root_clip->AddChild(root_scroll.Pass()); |
| 3460 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 3462 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); |
| 3461 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 2, | 3463 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 2, |
| 3462 Layer::INVALID_ID); | 3464 Layer::INVALID_ID); |
| 3463 host_impl_->active_tree()->DidBecomeActive(); | 3465 host_impl_->active_tree()->DidBecomeActive(); |
| 3464 host_impl_->SetViewportSize(surface_size); | 3466 host_impl_->SetViewportSize(surface_size); |
| 3465 | 3467 |
| 3466 // Draw one frame and then immediately rebuild the layer tree to mimic a tree | 3468 // Draw one frame and then immediately rebuild the layer tree to mimic a tree |
| 3467 // synchronization. | 3469 // synchronization. |
| 3468 DrawFrame(); | 3470 DrawFrame(); |
| 3469 host_impl_->active_tree()->DetachLayerTree(); | 3471 host_impl_->active_tree()->DetachLayerTree(); |
| 3470 scoped_ptr<LayerImpl> root_clip2 = | 3472 scoped_ptr<LayerImpl> root_clip2 = |
| 3471 LayerImpl::Create(host_impl_->active_tree(), 3); | 3473 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 3472 scoped_ptr<LayerImpl> root_scroll2 = | 3474 scoped_ptr<LayerImpl> root_scroll2 = |
| 3473 CreateScrollableLayer(4, surface_size, root_clip2.get()); | 3475 CreateScrollableLayer(4, surface_size, root_clip2.get()); |
| 3474 root_scroll2->SetIsContainerForFixedPositionLayers(true); | 3476 root_scroll2->SetIsContainerForFixedPositionLayers(true); |
| 3475 root_clip2->AddChild(root_scroll2.Pass()); | 3477 root_clip2->AddChild(root_scroll2.Pass()); |
| 3478 root_clip2->SetHasRenderSurface(true); |
| 3476 host_impl_->active_tree()->SetRootLayer(root_clip2.Pass()); | 3479 host_impl_->active_tree()->SetRootLayer(root_clip2.Pass()); |
| 3477 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 3, 4, | 3480 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 3, 4, |
| 3478 Layer::INVALID_ID); | 3481 Layer::INVALID_ID); |
| 3479 host_impl_->active_tree()->DidBecomeActive(); | 3482 host_impl_->active_tree()->DidBecomeActive(); |
| 3480 | 3483 |
| 3481 // Scrolling should still work even though we did not draw yet. | 3484 // Scrolling should still work even though we did not draw yet. |
| 3482 EXPECT_EQ(InputHandler::ScrollStarted, | 3485 EXPECT_EQ(InputHandler::ScrollStarted, |
| 3483 host_impl_->ScrollBegin(gfx::Point(5, 5), | 3486 host_impl_->ScrollBegin(gfx::Point(5, 5), |
| 3484 InputHandler::Wheel)); | 3487 InputHandler::Wheel)); |
| 3485 } | 3488 } |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3980 host_impl_->ScrollEnd(); | 3983 host_impl_->ScrollEnd(); |
| 3981 } | 3984 } |
| 3982 | 3985 |
| 3983 | 3986 |
| 3984 TEST_F(LayerTreeHostImplTest, OverscrollChildWithoutBubbling) { | 3987 TEST_F(LayerTreeHostImplTest, OverscrollChildWithoutBubbling) { |
| 3985 // Scroll child layers beyond their maximum scroll range and make sure root | 3988 // Scroll child layers beyond their maximum scroll range and make sure root |
| 3986 // overscroll does not accumulate. | 3989 // overscroll does not accumulate. |
| 3987 gfx::Size surface_size(10, 10); | 3990 gfx::Size surface_size(10, 10); |
| 3988 scoped_ptr<LayerImpl> root_clip = | 3991 scoped_ptr<LayerImpl> root_clip = |
| 3989 LayerImpl::Create(host_impl_->active_tree(), 4); | 3992 LayerImpl::Create(host_impl_->active_tree(), 4); |
| 3993 root_clip->SetHasRenderSurface(true); |
| 3994 |
| 3990 scoped_ptr<LayerImpl> root = | 3995 scoped_ptr<LayerImpl> root = |
| 3991 CreateScrollableLayer(1, surface_size, root_clip.get()); | 3996 CreateScrollableLayer(1, surface_size, root_clip.get()); |
| 3992 | 3997 |
| 3993 scoped_ptr<LayerImpl> grand_child = | 3998 scoped_ptr<LayerImpl> grand_child = |
| 3994 CreateScrollableLayer(3, surface_size, root_clip.get()); | 3999 CreateScrollableLayer(3, surface_size, root_clip.get()); |
| 3995 | 4000 |
| 3996 scoped_ptr<LayerImpl> child = | 4001 scoped_ptr<LayerImpl> child = |
| 3997 CreateScrollableLayer(2, surface_size, root_clip.get()); | 4002 CreateScrollableLayer(2, surface_size, root_clip.get()); |
| 3998 LayerImpl* grand_child_layer = grand_child.get(); | 4003 LayerImpl* grand_child_layer = grand_child.get(); |
| 3999 child->AddChild(grand_child.Pass()); | 4004 child->AddChild(grand_child.Pass()); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4044 } | 4049 } |
| 4045 | 4050 |
| 4046 TEST_F(LayerTreeHostImplTest, OverscrollChildEventBubbling) { | 4051 TEST_F(LayerTreeHostImplTest, OverscrollChildEventBubbling) { |
| 4047 // When we try to scroll a non-scrollable child layer, the scroll delta | 4052 // When we try to scroll a non-scrollable child layer, the scroll delta |
| 4048 // should be applied to one of its ancestors if possible. Overscroll should | 4053 // should be applied to one of its ancestors if possible. Overscroll should |
| 4049 // be reflected only when it has bubbled up to the root scrolling layer. | 4054 // be reflected only when it has bubbled up to the root scrolling layer. |
| 4050 gfx::Size surface_size(10, 10); | 4055 gfx::Size surface_size(10, 10); |
| 4051 gfx::Size content_size(20, 20); | 4056 gfx::Size content_size(20, 20); |
| 4052 scoped_ptr<LayerImpl> root_clip = | 4057 scoped_ptr<LayerImpl> root_clip = |
| 4053 LayerImpl::Create(host_impl_->active_tree(), 3); | 4058 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 4059 root_clip->SetHasRenderSurface(true); |
| 4060 |
| 4054 scoped_ptr<LayerImpl> root = | 4061 scoped_ptr<LayerImpl> root = |
| 4055 CreateScrollableLayer(1, content_size, root_clip.get()); | 4062 CreateScrollableLayer(1, content_size, root_clip.get()); |
| 4056 root->SetIsContainerForFixedPositionLayers(true); | 4063 root->SetIsContainerForFixedPositionLayers(true); |
| 4057 scoped_ptr<LayerImpl> child = | 4064 scoped_ptr<LayerImpl> child = |
| 4058 CreateScrollableLayer(2, content_size, root_clip.get()); | 4065 CreateScrollableLayer(2, content_size, root_clip.get()); |
| 4059 | 4066 |
| 4060 child->SetScrollClipLayer(Layer::INVALID_ID); | 4067 child->SetScrollClipLayer(Layer::INVALID_ID); |
| 4061 root->AddChild(child.Pass()); | 4068 root->AddChild(child.Pass()); |
| 4062 root_clip->AddChild(root.Pass()); | 4069 root_clip->AddChild(root.Pass()); |
| 4063 | 4070 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4100 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 4107 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
| 4101 EXPECT_EQ(gfx::Vector2dF(0, 10), host_impl_->accumulated_root_overscroll()); | 4108 EXPECT_EQ(gfx::Vector2dF(0, 10), host_impl_->accumulated_root_overscroll()); |
| 4102 } | 4109 } |
| 4103 | 4110 |
| 4104 TEST_F(LayerTreeHostImplTest, NoOverscrollOnFractionalDeviceScale) { | 4111 TEST_F(LayerTreeHostImplTest, NoOverscrollOnFractionalDeviceScale) { |
| 4105 gfx::Size surface_size(980, 1439); | 4112 gfx::Size surface_size(980, 1439); |
| 4106 gfx::Size content_size(980, 1438); | 4113 gfx::Size content_size(980, 1438); |
| 4107 float device_scale_factor = 1.5f; | 4114 float device_scale_factor = 1.5f; |
| 4108 scoped_ptr<LayerImpl> root_clip = | 4115 scoped_ptr<LayerImpl> root_clip = |
| 4109 LayerImpl::Create(host_impl_->active_tree(), 3); | 4116 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 4117 root_clip->SetHasRenderSurface(true); |
| 4118 |
| 4110 scoped_ptr<LayerImpl> root = | 4119 scoped_ptr<LayerImpl> root = |
| 4111 CreateScrollableLayer(1, content_size, root_clip.get()); | 4120 CreateScrollableLayer(1, content_size, root_clip.get()); |
| 4112 root->SetIsContainerForFixedPositionLayers(true); | 4121 root->SetIsContainerForFixedPositionLayers(true); |
| 4113 scoped_ptr<LayerImpl> child = | 4122 scoped_ptr<LayerImpl> child = |
| 4114 CreateScrollableLayer(2, content_size, root_clip.get()); | 4123 CreateScrollableLayer(2, content_size, root_clip.get()); |
| 4115 root->scroll_clip_layer()->SetBounds(gfx::Size(320, 469)); | 4124 root->scroll_clip_layer()->SetBounds(gfx::Size(320, 469)); |
| 4116 host_impl_->active_tree()->PushPageScaleFromMainThread(0.326531f, 0.326531f, | 4125 host_impl_->active_tree()->PushPageScaleFromMainThread(0.326531f, 0.326531f, |
| 4117 5.f); | 4126 5.f); |
| 4118 host_impl_->SetPageScaleOnActiveTree(0.326531f); | 4127 host_impl_->SetPageScaleOnActiveTree(0.326531f); |
| 4119 child->SetScrollClipLayer(Layer::INVALID_ID); | 4128 child->SetScrollClipLayer(Layer::INVALID_ID); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 4139 | 4148 |
| 4140 host_impl_->ScrollEnd(); | 4149 host_impl_->ScrollEnd(); |
| 4141 } | 4150 } |
| 4142 } | 4151 } |
| 4143 | 4152 |
| 4144 TEST_F(LayerTreeHostImplTest, NoOverscrollWhenNotAtEdge) { | 4153 TEST_F(LayerTreeHostImplTest, NoOverscrollWhenNotAtEdge) { |
| 4145 gfx::Size surface_size(100, 100); | 4154 gfx::Size surface_size(100, 100); |
| 4146 gfx::Size content_size(200, 200); | 4155 gfx::Size content_size(200, 200); |
| 4147 scoped_ptr<LayerImpl> root_clip = | 4156 scoped_ptr<LayerImpl> root_clip = |
| 4148 LayerImpl::Create(host_impl_->active_tree(), 3); | 4157 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 4158 root_clip->SetHasRenderSurface(true); |
| 4159 |
| 4149 scoped_ptr<LayerImpl> root = | 4160 scoped_ptr<LayerImpl> root = |
| 4150 CreateScrollableLayer(1, content_size, root_clip.get()); | 4161 CreateScrollableLayer(1, content_size, root_clip.get()); |
| 4151 root->SetIsContainerForFixedPositionLayers(true); | 4162 root->SetIsContainerForFixedPositionLayers(true); |
| 4152 scoped_ptr<LayerImpl> child = | 4163 scoped_ptr<LayerImpl> child = |
| 4153 CreateScrollableLayer(2, content_size, root_clip.get()); | 4164 CreateScrollableLayer(2, content_size, root_clip.get()); |
| 4154 | 4165 |
| 4155 child->SetScrollClipLayer(Layer::INVALID_ID); | 4166 child->SetScrollClipLayer(Layer::INVALID_ID); |
| 4156 root->AddChild(child.Pass()); | 4167 root->AddChild(child.Pass()); |
| 4157 root_clip->AddChild(root.Pass()); | 4168 root_clip->AddChild(root.Pass()); |
| 4158 | 4169 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4285 ResourceProvider::ResourceId resource_id_; | 4296 ResourceProvider::ResourceId resource_id_; |
| 4286 }; | 4297 }; |
| 4287 | 4298 |
| 4288 TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { | 4299 TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { |
| 4289 { | 4300 { |
| 4290 scoped_ptr<LayerImpl> root = | 4301 scoped_ptr<LayerImpl> root = |
| 4291 LayerImpl::Create(host_impl_->active_tree(), 1); | 4302 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 4292 root->SetBounds(gfx::Size(10, 10)); | 4303 root->SetBounds(gfx::Size(10, 10)); |
| 4293 root->SetContentBounds(root->bounds()); | 4304 root->SetContentBounds(root->bounds()); |
| 4294 root->SetDrawsContent(false); | 4305 root->SetDrawsContent(false); |
| 4306 root->SetHasRenderSurface(true); |
| 4295 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 4307 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 4296 } | 4308 } |
| 4297 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 4309 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 4298 | 4310 |
| 4299 root->AddChild( | 4311 root->AddChild( |
| 4300 BlendStateCheckLayer::Create(host_impl_->active_tree(), | 4312 BlendStateCheckLayer::Create(host_impl_->active_tree(), |
| 4301 2, | 4313 2, |
| 4302 host_impl_->resource_provider())); | 4314 host_impl_->resource_provider())); |
| 4303 BlendStateCheckLayer* layer1 = | 4315 BlendStateCheckLayer* layer1 = |
| 4304 static_cast<BlendStateCheckLayer*>(root->children()[0]); | 4316 static_cast<BlendStateCheckLayer*>(root->children()[0]); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4394 EXPECT_TRUE(layer2->quads_appended()); | 4406 EXPECT_TRUE(layer2->quads_appended()); |
| 4395 host_impl_->DidDrawAllLayers(frame); | 4407 host_impl_->DidDrawAllLayers(frame); |
| 4396 | 4408 |
| 4397 // Parent layer with translucent opacity and opaque content. Since it has a | 4409 // Parent layer with translucent opacity and opaque content. Since it has a |
| 4398 // drawing child, it's drawn to a render surface which carries the opacity, | 4410 // drawing child, it's drawn to a render surface which carries the opacity, |
| 4399 // so it's itself drawn without blending. | 4411 // so it's itself drawn without blending. |
| 4400 // Child layer with opaque content, drawn without blending (parent surface | 4412 // Child layer with opaque content, drawn without blending (parent surface |
| 4401 // carries the inherited opacity). | 4413 // carries the inherited opacity). |
| 4402 layer1->SetContentsOpaque(true); | 4414 layer1->SetContentsOpaque(true); |
| 4403 layer1->SetOpacity(0.5f); | 4415 layer1->SetOpacity(0.5f); |
| 4416 layer1->SetHasRenderSurface(true); |
| 4404 layer1->SetExpectation(false, true); | 4417 layer1->SetExpectation(false, true); |
| 4405 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); | 4418 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); |
| 4406 layer2->SetExpectation(false, false); | 4419 layer2->SetExpectation(false, false); |
| 4407 layer2->SetUpdateRect(gfx::Rect(layer1->content_bounds())); | 4420 layer2->SetUpdateRect(gfx::Rect(layer1->content_bounds())); |
| 4408 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( | 4421 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( |
| 4409 host_impl_->active_tree()->root_layer()); | 4422 host_impl_->active_tree()->root_layer()); |
| 4410 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4423 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 4411 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 4424 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 4412 EXPECT_TRUE(layer1->quads_appended()); | 4425 EXPECT_TRUE(layer1->quads_appended()); |
| 4413 EXPECT_TRUE(layer2->quads_appended()); | 4426 EXPECT_TRUE(layer2->quads_appended()); |
| 4414 host_impl_->DidDrawAllLayers(frame); | 4427 host_impl_->DidDrawAllLayers(frame); |
| 4428 layer1->SetHasRenderSurface(false); |
| 4415 | 4429 |
| 4416 // Draw again, but with child non-opaque, to make sure | 4430 // Draw again, but with child non-opaque, to make sure |
| 4417 // layer1 not culled. | 4431 // layer1 not culled. |
| 4418 layer1->SetContentsOpaque(true); | 4432 layer1->SetContentsOpaque(true); |
| 4419 layer1->SetOpacity(1.f); | 4433 layer1->SetOpacity(1.f); |
| 4420 layer1->SetExpectation(false, false); | 4434 layer1->SetExpectation(false, false); |
| 4421 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); | 4435 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); |
| 4422 layer2->SetContentsOpaque(true); | 4436 layer2->SetContentsOpaque(true); |
| 4423 layer2->SetOpacity(0.5f); | 4437 layer2->SetOpacity(0.5f); |
| 4424 layer2->SetExpectation(true, false); | 4438 layer2->SetExpectation(true, false); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4521 if (always_draw) { | 4535 if (always_draw) { |
| 4522 return FakeOutputSurface::CreateAlwaysDrawAndSwap3d(); | 4536 return FakeOutputSurface::CreateAlwaysDrawAndSwap3d(); |
| 4523 } | 4537 } |
| 4524 return FakeOutputSurface::Create3d(); | 4538 return FakeOutputSurface::Create3d(); |
| 4525 } | 4539 } |
| 4526 | 4540 |
| 4527 void SetupActiveTreeLayers() { | 4541 void SetupActiveTreeLayers() { |
| 4528 host_impl_->active_tree()->set_background_color(SK_ColorGRAY); | 4542 host_impl_->active_tree()->set_background_color(SK_ColorGRAY); |
| 4529 host_impl_->active_tree()->SetRootLayer( | 4543 host_impl_->active_tree()->SetRootLayer( |
| 4530 LayerImpl::Create(host_impl_->active_tree(), 1)); | 4544 LayerImpl::Create(host_impl_->active_tree(), 1)); |
| 4545 host_impl_->active_tree()->root_layer()->SetHasRenderSurface(true); |
| 4531 host_impl_->active_tree()->root_layer()->AddChild( | 4546 host_impl_->active_tree()->root_layer()->AddChild( |
| 4532 BlendStateCheckLayer::Create(host_impl_->active_tree(), | 4547 BlendStateCheckLayer::Create(host_impl_->active_tree(), |
| 4533 2, | 4548 2, |
| 4534 host_impl_->resource_provider())); | 4549 host_impl_->resource_provider())); |
| 4535 child_ = static_cast<BlendStateCheckLayer*>( | 4550 child_ = static_cast<BlendStateCheckLayer*>( |
| 4536 host_impl_->active_tree()->root_layer()->children()[0]); | 4551 host_impl_->active_tree()->root_layer()->children()[0]); |
| 4537 child_->SetExpectation(false, false); | 4552 child_->SetExpectation(false, false); |
| 4538 child_->SetContentsOpaque(true); | 4553 child_->SetContentsOpaque(true); |
| 4539 } | 4554 } |
| 4540 | 4555 |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4811 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); | 4826 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); |
| 4812 scoped_ptr<OutputSurface> output_surface( | 4827 scoped_ptr<OutputSurface> output_surface( |
| 4813 FakeOutputSurface::Create3d(provider)); | 4828 FakeOutputSurface::Create3d(provider)); |
| 4814 CreateHostImpl(DefaultSettings(), output_surface.Pass()); | 4829 CreateHostImpl(DefaultSettings(), output_surface.Pass()); |
| 4815 | 4830 |
| 4816 scoped_ptr<LayerImpl> root = | 4831 scoped_ptr<LayerImpl> root = |
| 4817 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); | 4832 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); |
| 4818 root->SetBounds(gfx::Size(10, 10)); | 4833 root->SetBounds(gfx::Size(10, 10)); |
| 4819 root->SetContentBounds(gfx::Size(10, 10)); | 4834 root->SetContentBounds(gfx::Size(10, 10)); |
| 4820 root->SetDrawsContent(true); | 4835 root->SetDrawsContent(true); |
| 4836 root->SetHasRenderSurface(true); |
| 4821 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 4837 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 4822 EXPECT_FALSE(provider->TestContext3d()->reshape_called()); | 4838 EXPECT_FALSE(provider->TestContext3d()->reshape_called()); |
| 4823 provider->TestContext3d()->clear_reshape_called(); | 4839 provider->TestContext3d()->clear_reshape_called(); |
| 4824 | 4840 |
| 4825 LayerTreeHostImpl::FrameData frame; | 4841 LayerTreeHostImpl::FrameData frame; |
| 4826 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 4842 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
| 4827 host_impl_->SetDeviceScaleFactor(1.f); | 4843 host_impl_->SetDeviceScaleFactor(1.f); |
| 4828 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4844 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 4829 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 4845 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 4830 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); | 4846 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4879 &proxy_, | 4895 &proxy_, |
| 4880 &stats_instrumentation_, | 4896 &stats_instrumentation_, |
| 4881 shared_bitmap_manager.get(), | 4897 shared_bitmap_manager.get(), |
| 4882 NULL, | 4898 NULL, |
| 4883 0); | 4899 0); |
| 4884 layer_tree_host_impl->InitializeRenderer(output_surface.Pass()); | 4900 layer_tree_host_impl->InitializeRenderer(output_surface.Pass()); |
| 4885 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); | 4901 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); |
| 4886 | 4902 |
| 4887 scoped_ptr<LayerImpl> root = | 4903 scoped_ptr<LayerImpl> root = |
| 4888 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); | 4904 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); |
| 4905 root->SetHasRenderSurface(true); |
| 4889 scoped_ptr<LayerImpl> child = | 4906 scoped_ptr<LayerImpl> child = |
| 4890 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); | 4907 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); |
| 4891 child->SetPosition(gfx::PointF(12.f, 13.f)); | 4908 child->SetPosition(gfx::PointF(12.f, 13.f)); |
| 4892 child->SetBounds(gfx::Size(14, 15)); | 4909 child->SetBounds(gfx::Size(14, 15)); |
| 4893 child->SetContentBounds(gfx::Size(14, 15)); | 4910 child->SetContentBounds(gfx::Size(14, 15)); |
| 4894 child->SetDrawsContent(true); | 4911 child->SetDrawsContent(true); |
| 4895 root->SetBounds(gfx::Size(500, 500)); | 4912 root->SetBounds(gfx::Size(500, 500)); |
| 4896 root->SetContentBounds(gfx::Size(500, 500)); | 4913 root->SetContentBounds(gfx::Size(500, 500)); |
| 4897 root->SetDrawsContent(true); | 4914 root->SetDrawsContent(true); |
| 4898 root->AddChild(child.Pass()); | 4915 root->AddChild(child.Pass()); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4945 scoped_ptr<LayerImpl> root = | 4962 scoped_ptr<LayerImpl> root = |
| 4946 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); | 4963 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); |
| 4947 scoped_ptr<LayerImpl> child = | 4964 scoped_ptr<LayerImpl> child = |
| 4948 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2); | 4965 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2); |
| 4949 child->SetBounds(gfx::Size(10, 10)); | 4966 child->SetBounds(gfx::Size(10, 10)); |
| 4950 child->SetContentBounds(gfx::Size(10, 10)); | 4967 child->SetContentBounds(gfx::Size(10, 10)); |
| 4951 child->SetDrawsContent(true); | 4968 child->SetDrawsContent(true); |
| 4952 root->SetBounds(gfx::Size(10, 10)); | 4969 root->SetBounds(gfx::Size(10, 10)); |
| 4953 root->SetContentBounds(gfx::Size(10, 10)); | 4970 root->SetContentBounds(gfx::Size(10, 10)); |
| 4954 root->SetDrawsContent(true); | 4971 root->SetDrawsContent(true); |
| 4955 root->SetForceRenderSurface(true); | 4972 root->SetHasRenderSurface(true); |
| 4956 root->AddChild(child.Pass()); | 4973 root->AddChild(child.Pass()); |
| 4957 | 4974 |
| 4958 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 4975 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 4959 | 4976 |
| 4960 LayerTreeHostImpl::FrameData frame; | 4977 LayerTreeHostImpl::FrameData frame; |
| 4961 | 4978 |
| 4962 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4979 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 4963 EXPECT_EQ(1u, frame.render_surface_layer_list->size()); | 4980 EXPECT_EQ(1u, frame.render_surface_layer_list->size()); |
| 4964 EXPECT_EQ(1u, frame.render_passes.size()); | 4981 EXPECT_EQ(1u, frame.render_passes.size()); |
| 4965 host_impl_->DidDrawAllLayers(frame); | 4982 host_impl_->DidDrawAllLayers(frame); |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5194 LayerImpl::Create(my_host_impl->active_tree(), 1); | 5211 LayerImpl::Create(my_host_impl->active_tree(), 1); |
| 5195 scoped_ptr<LayerImpl> child = | 5212 scoped_ptr<LayerImpl> child = |
| 5196 LayerImpl::Create(my_host_impl->active_tree(), 2); | 5213 LayerImpl::Create(my_host_impl->active_tree(), 2); |
| 5197 scoped_ptr<LayerImpl> grand_child = | 5214 scoped_ptr<LayerImpl> grand_child = |
| 5198 FakeLayerWithQuads::Create(my_host_impl->active_tree(), 3); | 5215 FakeLayerWithQuads::Create(my_host_impl->active_tree(), 3); |
| 5199 | 5216 |
| 5200 gfx::Rect root_rect(0, 0, 100, 100); | 5217 gfx::Rect root_rect(0, 0, 100, 100); |
| 5201 gfx::Rect child_rect(10, 10, 50, 50); | 5218 gfx::Rect child_rect(10, 10, 50, 50); |
| 5202 gfx::Rect grand_child_rect(5, 5, 150, 150); | 5219 gfx::Rect grand_child_rect(5, 5, 150, 150); |
| 5203 | 5220 |
| 5204 root->CreateRenderSurface(); | 5221 root->SetHasRenderSurface(true); |
| 5205 root->SetPosition(root_rect.origin()); | 5222 root->SetPosition(root_rect.origin()); |
| 5206 root->SetBounds(root_rect.size()); | 5223 root->SetBounds(root_rect.size()); |
| 5207 root->SetContentBounds(root->bounds()); | 5224 root->SetContentBounds(root->bounds()); |
| 5208 root->draw_properties().visible_content_rect = root_rect; | 5225 root->draw_properties().visible_content_rect = root_rect; |
| 5209 root->SetDrawsContent(false); | 5226 root->SetDrawsContent(false); |
| 5210 root->render_surface()->SetContentRect(gfx::Rect(root_rect.size())); | 5227 root->render_surface()->SetContentRect(gfx::Rect(root_rect.size())); |
| 5211 | 5228 |
| 5212 child->SetPosition(gfx::PointF(child_rect.x(), child_rect.y())); | 5229 child->SetPosition(gfx::PointF(child_rect.x(), child_rect.y())); |
| 5213 child->SetOpacity(0.5f); | 5230 child->SetOpacity(0.5f); |
| 5214 child->SetBounds(gfx::Size(child_rect.width(), child_rect.height())); | 5231 child->SetBounds(gfx::Size(child_rect.width(), child_rect.height())); |
| 5215 child->SetContentBounds(child->bounds()); | 5232 child->SetContentBounds(child->bounds()); |
| 5216 child->draw_properties().visible_content_rect = child_rect; | 5233 child->draw_properties().visible_content_rect = child_rect; |
| 5217 child->SetDrawsContent(false); | 5234 child->SetDrawsContent(false); |
| 5218 child->SetForceRenderSurface(true); | 5235 child->SetHasRenderSurface(true); |
| 5219 | 5236 |
| 5220 grand_child->SetPosition(grand_child_rect.origin()); | 5237 grand_child->SetPosition(grand_child_rect.origin()); |
| 5221 grand_child->SetBounds(grand_child_rect.size()); | 5238 grand_child->SetBounds(grand_child_rect.size()); |
| 5222 grand_child->SetContentBounds(grand_child->bounds()); | 5239 grand_child->SetContentBounds(grand_child->bounds()); |
| 5223 grand_child->draw_properties().visible_content_rect = grand_child_rect; | 5240 grand_child->draw_properties().visible_content_rect = grand_child_rect; |
| 5224 grand_child->SetDrawsContent(true); | 5241 grand_child->SetDrawsContent(true); |
| 5225 | 5242 |
| 5226 child->AddChild(grand_child.Pass()); | 5243 child->AddChild(grand_child.Pass()); |
| 5227 root->AddChild(child.Pass()); | 5244 root->AddChild(child.Pass()); |
| 5228 | 5245 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5288 scoped_ptr<TestWebGraphicsContext3D> context = | 5305 scoped_ptr<TestWebGraphicsContext3D> context = |
| 5289 TestWebGraphicsContext3D::Create(); | 5306 TestWebGraphicsContext3D::Create(); |
| 5290 TestWebGraphicsContext3D* context3d = context.get(); | 5307 TestWebGraphicsContext3D* context3d = context.get(); |
| 5291 scoped_ptr<OutputSurface> output_surface( | 5308 scoped_ptr<OutputSurface> output_surface( |
| 5292 FakeOutputSurface::Create3d(context.Pass())); | 5309 FakeOutputSurface::Create3d(context.Pass())); |
| 5293 CreateHostImpl(DefaultSettings(), output_surface.Pass()); | 5310 CreateHostImpl(DefaultSettings(), output_surface.Pass()); |
| 5294 | 5311 |
| 5295 scoped_ptr<LayerImpl> root_layer = | 5312 scoped_ptr<LayerImpl> root_layer = |
| 5296 LayerImpl::Create(host_impl_->active_tree(), 1); | 5313 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 5297 root_layer->SetBounds(gfx::Size(10, 10)); | 5314 root_layer->SetBounds(gfx::Size(10, 10)); |
| 5315 root_layer->SetHasRenderSurface(true); |
| 5298 | 5316 |
| 5299 scoped_refptr<VideoFrame> softwareFrame = | 5317 scoped_refptr<VideoFrame> softwareFrame = |
| 5300 media::VideoFrame::CreateColorFrame( | 5318 media::VideoFrame::CreateColorFrame( |
| 5301 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); | 5319 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); |
| 5302 FakeVideoFrameProvider provider; | 5320 FakeVideoFrameProvider provider; |
| 5303 provider.set_frame(softwareFrame); | 5321 provider.set_frame(softwareFrame); |
| 5304 scoped_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( | 5322 scoped_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( |
| 5305 host_impl_->active_tree(), 4, &provider, media::VIDEO_ROTATION_0); | 5323 host_impl_->active_tree(), 4, &provider, media::VIDEO_ROTATION_0); |
| 5306 video_layer->SetBounds(gfx::Size(10, 10)); | 5324 video_layer->SetBounds(gfx::Size(10, 10)); |
| 5307 video_layer->SetContentBounds(gfx::Size(10, 10)); | 5325 video_layer->SetContentBounds(gfx::Size(10, 10)); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5462 } | 5480 } |
| 5463 }; | 5481 }; |
| 5464 | 5482 |
| 5465 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) { | 5483 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) { |
| 5466 scoped_ptr<SolidColorLayerImpl> root = | 5484 scoped_ptr<SolidColorLayerImpl> root = |
| 5467 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 5485 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
| 5468 root->SetPosition(gfx::PointF()); | 5486 root->SetPosition(gfx::PointF()); |
| 5469 root->SetBounds(gfx::Size(10, 10)); | 5487 root->SetBounds(gfx::Size(10, 10)); |
| 5470 root->SetContentBounds(gfx::Size(10, 10)); | 5488 root->SetContentBounds(gfx::Size(10, 10)); |
| 5471 root->SetDrawsContent(true); | 5489 root->SetDrawsContent(true); |
| 5490 root->SetHasRenderSurface(true); |
| 5472 | 5491 |
| 5473 // Child layer is in the bottom right corner. | 5492 // Child layer is in the bottom right corner. |
| 5474 scoped_ptr<SolidColorLayerImpl> child = | 5493 scoped_ptr<SolidColorLayerImpl> child = |
| 5475 SolidColorLayerImpl::Create(host_impl_->active_tree(), 2); | 5494 SolidColorLayerImpl::Create(host_impl_->active_tree(), 2); |
| 5476 child->SetPosition(gfx::PointF(9.f, 9.f)); | 5495 child->SetPosition(gfx::PointF(9.f, 9.f)); |
| 5477 child->SetBounds(gfx::Size(1, 1)); | 5496 child->SetBounds(gfx::Size(1, 1)); |
| 5478 child->SetContentBounds(gfx::Size(1, 1)); | 5497 child->SetContentBounds(gfx::Size(1, 1)); |
| 5479 child->SetDrawsContent(true); | 5498 child->SetDrawsContent(true); |
| 5480 root->AddChild(child.Pass()); | 5499 root->AddChild(child.Pass()); |
| 5481 | 5500 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5528 | 5547 |
| 5529 // Root | 5548 // Root |
| 5530 // | | 5549 // | |
| 5531 // +-- Scaling Layer (adds a 2x scale) | 5550 // +-- Scaling Layer (adds a 2x scale) |
| 5532 // | | 5551 // | |
| 5533 // +-- Content Layer | 5552 // +-- Content Layer |
| 5534 // +--Mask | 5553 // +--Mask |
| 5535 scoped_ptr<LayerImpl> scoped_root = | 5554 scoped_ptr<LayerImpl> scoped_root = |
| 5536 LayerImpl::Create(host_impl_->active_tree(), 1); | 5555 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 5537 LayerImpl* root = scoped_root.get(); | 5556 LayerImpl* root = scoped_root.get(); |
| 5557 root->SetHasRenderSurface(true); |
| 5538 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); | 5558 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); |
| 5539 | 5559 |
| 5540 scoped_ptr<LayerImpl> scoped_scaling_layer = | 5560 scoped_ptr<LayerImpl> scoped_scaling_layer = |
| 5541 LayerImpl::Create(host_impl_->active_tree(), 2); | 5561 LayerImpl::Create(host_impl_->active_tree(), 2); |
| 5542 LayerImpl* scaling_layer = scoped_scaling_layer.get(); | 5562 LayerImpl* scaling_layer = scoped_scaling_layer.get(); |
| 5543 root->AddChild(scoped_scaling_layer.Pass()); | 5563 root->AddChild(scoped_scaling_layer.Pass()); |
| 5544 | 5564 |
| 5545 scoped_ptr<LayerImpl> scoped_content_layer = | 5565 scoped_ptr<LayerImpl> scoped_content_layer = |
| 5546 LayerImpl::Create(host_impl_->active_tree(), 3); | 5566 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 5547 LayerImpl* content_layer = scoped_content_layer.get(); | 5567 LayerImpl* content_layer = scoped_content_layer.get(); |
| 5548 scaling_layer->AddChild(scoped_content_layer.Pass()); | 5568 scaling_layer->AddChild(scoped_content_layer.Pass()); |
| 5549 | 5569 |
| 5550 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = | 5570 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = |
| 5551 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); | 5571 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); |
| 5552 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); | 5572 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); |
| 5573 content_layer->SetHasRenderSurface(true); |
| 5553 content_layer->SetMaskLayer(scoped_mask_layer.Pass()); | 5574 content_layer->SetMaskLayer(scoped_mask_layer.Pass()); |
| 5554 | 5575 |
| 5555 gfx::Size root_size(100, 100); | 5576 gfx::Size root_size(100, 100); |
| 5556 root->SetBounds(root_size); | 5577 root->SetBounds(root_size); |
| 5557 root->SetContentBounds(root_size); | 5578 root->SetContentBounds(root_size); |
| 5558 root->SetPosition(gfx::PointF()); | 5579 root->SetPosition(gfx::PointF()); |
| 5559 | 5580 |
| 5560 gfx::Size scaling_layer_size(50, 50); | 5581 gfx::Size scaling_layer_size(50, 50); |
| 5561 scaling_layer->SetBounds(scaling_layer_size); | 5582 scaling_layer->SetBounds(scaling_layer_size); |
| 5562 scaling_layer->SetContentBounds(scaling_layer_size); | 5583 scaling_layer->SetContentBounds(scaling_layer_size); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5668 } | 5689 } |
| 5669 } | 5690 } |
| 5670 | 5691 |
| 5671 TEST_F(LayerTreeHostImplTest, MaskLayerWithDifferentBounds) { | 5692 TEST_F(LayerTreeHostImplTest, MaskLayerWithDifferentBounds) { |
| 5672 // The mask layer has bounds 100x100 but is attached to a layer with bounds | 5693 // The mask layer has bounds 100x100 but is attached to a layer with bounds |
| 5673 // 50x50. | 5694 // 50x50. |
| 5674 | 5695 |
| 5675 scoped_ptr<LayerImpl> scoped_root = | 5696 scoped_ptr<LayerImpl> scoped_root = |
| 5676 LayerImpl::Create(host_impl_->active_tree(), 1); | 5697 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 5677 LayerImpl* root = scoped_root.get(); | 5698 LayerImpl* root = scoped_root.get(); |
| 5699 root->SetHasRenderSurface(true); |
| 5700 |
| 5678 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); | 5701 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); |
| 5679 | 5702 |
| 5680 scoped_ptr<LayerImpl> scoped_content_layer = | 5703 scoped_ptr<LayerImpl> scoped_content_layer = |
| 5681 LayerImpl::Create(host_impl_->active_tree(), 3); | 5704 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 5682 LayerImpl* content_layer = scoped_content_layer.get(); | 5705 LayerImpl* content_layer = scoped_content_layer.get(); |
| 5683 root->AddChild(scoped_content_layer.Pass()); | 5706 root->AddChild(scoped_content_layer.Pass()); |
| 5684 | 5707 |
| 5685 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = | 5708 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = |
| 5686 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); | 5709 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); |
| 5687 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); | 5710 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); |
| 5688 content_layer->SetMaskLayer(scoped_mask_layer.Pass()); | 5711 content_layer->SetMaskLayer(scoped_mask_layer.Pass()); |
| 5712 content_layer->SetHasRenderSurface(true); |
| 5689 | 5713 |
| 5690 gfx::Size root_size(100, 100); | 5714 gfx::Size root_size(100, 100); |
| 5691 root->SetBounds(root_size); | 5715 root->SetBounds(root_size); |
| 5692 root->SetContentBounds(root_size); | 5716 root->SetContentBounds(root_size); |
| 5693 root->SetPosition(gfx::PointF()); | 5717 root->SetPosition(gfx::PointF()); |
| 5694 | 5718 |
| 5695 gfx::Size layer_size(50, 50); | 5719 gfx::Size layer_size(50, 50); |
| 5696 content_layer->SetBounds(layer_size); | 5720 content_layer->SetBounds(layer_size); |
| 5697 content_layer->SetContentBounds(layer_size); | 5721 content_layer->SetContentBounds(layer_size); |
| 5698 content_layer->SetPosition(gfx::PointF()); | 5722 content_layer->SetPosition(gfx::PointF()); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5822 } | 5846 } |
| 5823 } | 5847 } |
| 5824 | 5848 |
| 5825 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerWithDifferentBounds) { | 5849 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerWithDifferentBounds) { |
| 5826 // The replica's mask layer has bounds 100x100 but the replica is of a | 5850 // The replica's mask layer has bounds 100x100 but the replica is of a |
| 5827 // layer with bounds 50x50. | 5851 // layer with bounds 50x50. |
| 5828 | 5852 |
| 5829 scoped_ptr<LayerImpl> scoped_root = | 5853 scoped_ptr<LayerImpl> scoped_root = |
| 5830 LayerImpl::Create(host_impl_->active_tree(), 1); | 5854 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 5831 LayerImpl* root = scoped_root.get(); | 5855 LayerImpl* root = scoped_root.get(); |
| 5856 root->SetHasRenderSurface(true); |
| 5857 |
| 5832 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); | 5858 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); |
| 5833 | 5859 |
| 5834 scoped_ptr<LayerImpl> scoped_content_layer = | 5860 scoped_ptr<LayerImpl> scoped_content_layer = |
| 5835 LayerImpl::Create(host_impl_->active_tree(), 3); | 5861 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 5836 LayerImpl* content_layer = scoped_content_layer.get(); | 5862 LayerImpl* content_layer = scoped_content_layer.get(); |
| 5837 root->AddChild(scoped_content_layer.Pass()); | 5863 root->AddChild(scoped_content_layer.Pass()); |
| 5838 | 5864 |
| 5839 scoped_ptr<LayerImpl> scoped_replica_layer = | 5865 scoped_ptr<LayerImpl> scoped_replica_layer = |
| 5840 LayerImpl::Create(host_impl_->active_tree(), 2); | 5866 LayerImpl::Create(host_impl_->active_tree(), 2); |
| 5841 LayerImpl* replica_layer = scoped_replica_layer.get(); | 5867 LayerImpl* replica_layer = scoped_replica_layer.get(); |
| 5842 content_layer->SetReplicaLayer(scoped_replica_layer.Pass()); | 5868 content_layer->SetReplicaLayer(scoped_replica_layer.Pass()); |
| 5869 content_layer->SetHasRenderSurface(true); |
| 5843 | 5870 |
| 5844 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = | 5871 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = |
| 5845 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); | 5872 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); |
| 5846 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); | 5873 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); |
| 5847 replica_layer->SetMaskLayer(scoped_mask_layer.Pass()); | 5874 replica_layer->SetMaskLayer(scoped_mask_layer.Pass()); |
| 5875 replica_layer->SetHasRenderSurface(true); |
| 5848 | 5876 |
| 5849 gfx::Size root_size(100, 100); | 5877 gfx::Size root_size(100, 100); |
| 5850 root->SetBounds(root_size); | 5878 root->SetBounds(root_size); |
| 5851 root->SetContentBounds(root_size); | 5879 root->SetContentBounds(root_size); |
| 5852 root->SetPosition(gfx::PointF()); | 5880 root->SetPosition(gfx::PointF()); |
| 5853 | 5881 |
| 5854 gfx::Size layer_size(50, 50); | 5882 gfx::Size layer_size(50, 50); |
| 5855 content_layer->SetBounds(layer_size); | 5883 content_layer->SetBounds(layer_size); |
| 5856 content_layer->SetContentBounds(layer_size); | 5884 content_layer->SetContentBounds(layer_size); |
| 5857 content_layer->SetPosition(gfx::PointF()); | 5885 content_layer->SetPosition(gfx::PointF()); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5977 } | 6005 } |
| 5978 } | 6006 } |
| 5979 | 6007 |
| 5980 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerForSurfaceWithUnclippedChild) { | 6008 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerForSurfaceWithUnclippedChild) { |
| 5981 // The replica is of a layer with bounds 50x50, but it has a child that causes | 6009 // The replica is of a layer with bounds 50x50, but it has a child that causes |
| 5982 // the surface bounds to be larger. | 6010 // the surface bounds to be larger. |
| 5983 | 6011 |
| 5984 scoped_ptr<LayerImpl> scoped_root = | 6012 scoped_ptr<LayerImpl> scoped_root = |
| 5985 LayerImpl::Create(host_impl_->active_tree(), 1); | 6013 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 5986 LayerImpl* root = scoped_root.get(); | 6014 LayerImpl* root = scoped_root.get(); |
| 6015 root->SetHasRenderSurface(true); |
| 5987 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); | 6016 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); |
| 5988 | 6017 |
| 5989 scoped_ptr<LayerImpl> scoped_content_layer = | 6018 scoped_ptr<LayerImpl> scoped_content_layer = |
| 5990 LayerImpl::Create(host_impl_->active_tree(), 2); | 6019 LayerImpl::Create(host_impl_->active_tree(), 2); |
| 5991 LayerImpl* content_layer = scoped_content_layer.get(); | 6020 LayerImpl* content_layer = scoped_content_layer.get(); |
| 5992 root->AddChild(scoped_content_layer.Pass()); | 6021 root->AddChild(scoped_content_layer.Pass()); |
| 5993 | 6022 |
| 5994 scoped_ptr<LayerImpl> scoped_content_child_layer = | 6023 scoped_ptr<LayerImpl> scoped_content_child_layer = |
| 5995 LayerImpl::Create(host_impl_->active_tree(), 3); | 6024 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 5996 LayerImpl* content_child_layer = scoped_content_child_layer.get(); | 6025 LayerImpl* content_child_layer = scoped_content_child_layer.get(); |
| 5997 content_layer->AddChild(scoped_content_child_layer.Pass()); | 6026 content_layer->AddChild(scoped_content_child_layer.Pass()); |
| 5998 | 6027 |
| 5999 scoped_ptr<LayerImpl> scoped_replica_layer = | 6028 scoped_ptr<LayerImpl> scoped_replica_layer = |
| 6000 LayerImpl::Create(host_impl_->active_tree(), 4); | 6029 LayerImpl::Create(host_impl_->active_tree(), 4); |
| 6001 LayerImpl* replica_layer = scoped_replica_layer.get(); | 6030 LayerImpl* replica_layer = scoped_replica_layer.get(); |
| 6002 content_layer->SetReplicaLayer(scoped_replica_layer.Pass()); | 6031 content_layer->SetReplicaLayer(scoped_replica_layer.Pass()); |
| 6032 content_layer->SetHasRenderSurface(true); |
| 6003 | 6033 |
| 6004 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = | 6034 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = |
| 6005 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 5); | 6035 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 5); |
| 6006 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); | 6036 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); |
| 6007 replica_layer->SetMaskLayer(scoped_mask_layer.Pass()); | 6037 replica_layer->SetMaskLayer(scoped_mask_layer.Pass()); |
| 6038 replica_layer->SetHasRenderSurface(true); |
| 6008 | 6039 |
| 6009 gfx::Size root_size(100, 100); | 6040 gfx::Size root_size(100, 100); |
| 6010 root->SetBounds(root_size); | 6041 root->SetBounds(root_size); |
| 6011 root->SetContentBounds(root_size); | 6042 root->SetContentBounds(root_size); |
| 6012 root->SetPosition(gfx::PointF()); | 6043 root->SetPosition(gfx::PointF()); |
| 6013 | 6044 |
| 6014 gfx::Size layer_size(50, 50); | 6045 gfx::Size layer_size(50, 50); |
| 6015 content_layer->SetBounds(layer_size); | 6046 content_layer->SetBounds(layer_size); |
| 6016 content_layer->SetContentBounds(layer_size); | 6047 content_layer->SetContentBounds(layer_size); |
| 6017 content_layer->SetPosition(gfx::PointF()); | 6048 content_layer->SetPosition(gfx::PointF()); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6101 } | 6132 } |
| 6102 | 6133 |
| 6103 TEST_F(LayerTreeHostImplTest, MaskLayerForSurfaceWithClippedLayer) { | 6134 TEST_F(LayerTreeHostImplTest, MaskLayerForSurfaceWithClippedLayer) { |
| 6104 // The masked layer has bounds 50x50, but it has a child that causes | 6135 // The masked layer has bounds 50x50, but it has a child that causes |
| 6105 // the surface bounds to be larger. It also has a parent that clips the | 6136 // the surface bounds to be larger. It also has a parent that clips the |
| 6106 // masked layer and its surface. | 6137 // masked layer and its surface. |
| 6107 | 6138 |
| 6108 scoped_ptr<LayerImpl> scoped_root = | 6139 scoped_ptr<LayerImpl> scoped_root = |
| 6109 LayerImpl::Create(host_impl_->active_tree(), 1); | 6140 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 6110 LayerImpl* root = scoped_root.get(); | 6141 LayerImpl* root = scoped_root.get(); |
| 6142 root->SetHasRenderSurface(true); |
| 6143 |
| 6111 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); | 6144 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); |
| 6112 | 6145 |
| 6113 scoped_ptr<LayerImpl> scoped_clipping_layer = | 6146 scoped_ptr<LayerImpl> scoped_clipping_layer = |
| 6114 LayerImpl::Create(host_impl_->active_tree(), 2); | 6147 LayerImpl::Create(host_impl_->active_tree(), 2); |
| 6115 LayerImpl* clipping_layer = scoped_clipping_layer.get(); | 6148 LayerImpl* clipping_layer = scoped_clipping_layer.get(); |
| 6116 root->AddChild(scoped_clipping_layer.Pass()); | 6149 root->AddChild(scoped_clipping_layer.Pass()); |
| 6117 | 6150 |
| 6118 scoped_ptr<LayerImpl> scoped_content_layer = | 6151 scoped_ptr<LayerImpl> scoped_content_layer = |
| 6119 LayerImpl::Create(host_impl_->active_tree(), 3); | 6152 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 6120 LayerImpl* content_layer = scoped_content_layer.get(); | 6153 LayerImpl* content_layer = scoped_content_layer.get(); |
| 6121 clipping_layer->AddChild(scoped_content_layer.Pass()); | 6154 clipping_layer->AddChild(scoped_content_layer.Pass()); |
| 6122 | 6155 |
| 6123 scoped_ptr<LayerImpl> scoped_content_child_layer = | 6156 scoped_ptr<LayerImpl> scoped_content_child_layer = |
| 6124 LayerImpl::Create(host_impl_->active_tree(), 4); | 6157 LayerImpl::Create(host_impl_->active_tree(), 4); |
| 6125 LayerImpl* content_child_layer = scoped_content_child_layer.get(); | 6158 LayerImpl* content_child_layer = scoped_content_child_layer.get(); |
| 6126 content_layer->AddChild(scoped_content_child_layer.Pass()); | 6159 content_layer->AddChild(scoped_content_child_layer.Pass()); |
| 6127 | 6160 |
| 6128 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = | 6161 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = |
| 6129 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 6); | 6162 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 6); |
| 6130 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); | 6163 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); |
| 6131 content_layer->SetMaskLayer(scoped_mask_layer.Pass()); | 6164 content_layer->SetMaskLayer(scoped_mask_layer.Pass()); |
| 6165 content_layer->SetHasRenderSurface(true); |
| 6132 | 6166 |
| 6133 gfx::Size root_size(100, 100); | 6167 gfx::Size root_size(100, 100); |
| 6134 root->SetBounds(root_size); | 6168 root->SetBounds(root_size); |
| 6135 root->SetContentBounds(root_size); | 6169 root->SetContentBounds(root_size); |
| 6136 root->SetPosition(gfx::PointF()); | 6170 root->SetPosition(gfx::PointF()); |
| 6137 | 6171 |
| 6138 gfx::Rect clipping_rect(20, 10, 10, 20); | 6172 gfx::Rect clipping_rect(20, 10, 10, 20); |
| 6139 clipping_layer->SetBounds(clipping_rect.size()); | 6173 clipping_layer->SetBounds(clipping_rect.size()); |
| 6140 clipping_layer->SetContentBounds(clipping_rect.size()); | 6174 clipping_layer->SetContentBounds(clipping_rect.size()); |
| 6141 clipping_layer->SetPosition(clipping_rect.origin()); | 6175 clipping_layer->SetPosition(clipping_rect.origin()); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6207 gfx::ToCeiledSize(gfx::ScaleSize(root_size, device_scale_factor)); | 6241 gfx::ToCeiledSize(gfx::ScaleSize(root_size, device_scale_factor)); |
| 6208 host_impl_->SetViewportSize(device_viewport_size); | 6242 host_impl_->SetViewportSize(device_viewport_size); |
| 6209 | 6243 |
| 6210 host_impl_->CreatePendingTree(); | 6244 host_impl_->CreatePendingTree(); |
| 6211 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f / 16.f, | 6245 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f / 16.f, |
| 6212 16.f); | 6246 16.f); |
| 6213 | 6247 |
| 6214 scoped_ptr<LayerImpl> scoped_root = | 6248 scoped_ptr<LayerImpl> scoped_root = |
| 6215 LayerImpl::Create(host_impl_->pending_tree(), 1); | 6249 LayerImpl::Create(host_impl_->pending_tree(), 1); |
| 6216 LayerImpl* root = scoped_root.get(); | 6250 LayerImpl* root = scoped_root.get(); |
| 6251 root->SetHasRenderSurface(true); |
| 6217 | 6252 |
| 6218 host_impl_->pending_tree()->SetRootLayer(scoped_root.Pass()); | 6253 host_impl_->pending_tree()->SetRootLayer(scoped_root.Pass()); |
| 6219 | 6254 |
| 6220 scoped_ptr<LayerImpl> scoped_scrolling_layer = | 6255 scoped_ptr<LayerImpl> scoped_scrolling_layer = |
| 6221 LayerImpl::Create(host_impl_->pending_tree(), 2); | 6256 LayerImpl::Create(host_impl_->pending_tree(), 2); |
| 6222 LayerImpl* scrolling_layer = scoped_scrolling_layer.get(); | 6257 LayerImpl* scrolling_layer = scoped_scrolling_layer.get(); |
| 6223 root->AddChild(scoped_scrolling_layer.Pass()); | 6258 root->AddChild(scoped_scrolling_layer.Pass()); |
| 6224 | 6259 |
| 6225 gfx::Size content_layer_bounds(100000, 100); | 6260 gfx::Size content_layer_bounds(100000, 100); |
| 6226 gfx::Size pile_tile_size(3000, 3000); | 6261 gfx::Size pile_tile_size(3000, 3000); |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6708 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures()); | 6743 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures()); |
| 6709 } | 6744 } |
| 6710 | 6745 |
| 6711 TEST_F(LayerTreeHostImplTest, TouchFlingShouldNotBubble) { | 6746 TEST_F(LayerTreeHostImplTest, TouchFlingShouldNotBubble) { |
| 6712 // When flinging via touch, only the child should scroll (we should not | 6747 // When flinging via touch, only the child should scroll (we should not |
| 6713 // bubble). | 6748 // bubble). |
| 6714 gfx::Size surface_size(10, 10); | 6749 gfx::Size surface_size(10, 10); |
| 6715 gfx::Size content_size(20, 20); | 6750 gfx::Size content_size(20, 20); |
| 6716 scoped_ptr<LayerImpl> root_clip = | 6751 scoped_ptr<LayerImpl> root_clip = |
| 6717 LayerImpl::Create(host_impl_->active_tree(), 3); | 6752 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 6753 root_clip->SetHasRenderSurface(true); |
| 6754 |
| 6718 scoped_ptr<LayerImpl> root = | 6755 scoped_ptr<LayerImpl> root = |
| 6719 CreateScrollableLayer(1, content_size, root_clip.get()); | 6756 CreateScrollableLayer(1, content_size, root_clip.get()); |
| 6720 root->SetIsContainerForFixedPositionLayers(true); | 6757 root->SetIsContainerForFixedPositionLayers(true); |
| 6721 scoped_ptr<LayerImpl> child = | 6758 scoped_ptr<LayerImpl> child = |
| 6722 CreateScrollableLayer(2, content_size, root_clip.get()); | 6759 CreateScrollableLayer(2, content_size, root_clip.get()); |
| 6723 | 6760 |
| 6724 root->AddChild(child.Pass()); | 6761 root->AddChild(child.Pass()); |
| 6725 int root_id = root->id(); | 6762 int root_id = root->id(); |
| 6726 root_clip->AddChild(root.Pass()); | 6763 root_clip->AddChild(root.Pass()); |
| 6727 | 6764 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 6752 ASSERT_EQ(1u, scroll_info->scrolls.size()); | 6789 ASSERT_EQ(1u, scroll_info->scrolls.size()); |
| 6753 ExpectNone(*scroll_info.get(), root_id); | 6790 ExpectNone(*scroll_info.get(), root_id); |
| 6754 } | 6791 } |
| 6755 } | 6792 } |
| 6756 | 6793 |
| 6757 TEST_F(LayerTreeHostImplTest, TouchFlingShouldLockToFirstScrolledLayer) { | 6794 TEST_F(LayerTreeHostImplTest, TouchFlingShouldLockToFirstScrolledLayer) { |
| 6758 // Scroll a child layer beyond its maximum scroll range and make sure the | 6795 // Scroll a child layer beyond its maximum scroll range and make sure the |
| 6759 // the scroll doesn't bubble up to the parent layer. | 6796 // the scroll doesn't bubble up to the parent layer. |
| 6760 gfx::Size surface_size(10, 10); | 6797 gfx::Size surface_size(10, 10); |
| 6761 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 6798 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 6799 root->SetHasRenderSurface(true); |
| 6762 scoped_ptr<LayerImpl> root_scrolling = | 6800 scoped_ptr<LayerImpl> root_scrolling = |
| 6763 CreateScrollableLayer(2, surface_size, root.get()); | 6801 CreateScrollableLayer(2, surface_size, root.get()); |
| 6764 | 6802 |
| 6765 scoped_ptr<LayerImpl> grand_child = | 6803 scoped_ptr<LayerImpl> grand_child = |
| 6766 CreateScrollableLayer(4, surface_size, root.get()); | 6804 CreateScrollableLayer(4, surface_size, root.get()); |
| 6767 grand_child->SetScrollOffset(gfx::ScrollOffset(0, 2)); | 6805 grand_child->SetScrollOffset(gfx::ScrollOffset(0, 2)); |
| 6768 | 6806 |
| 6769 scoped_ptr<LayerImpl> child = | 6807 scoped_ptr<LayerImpl> child = |
| 6770 CreateScrollableLayer(3, surface_size, root.get()); | 6808 CreateScrollableLayer(3, surface_size, root.get()); |
| 6771 child->SetScrollOffset(gfx::ScrollOffset(0, 4)); | 6809 child->SetScrollOffset(gfx::ScrollOffset(0, 4)); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6822 } | 6860 } |
| 6823 } | 6861 } |
| 6824 | 6862 |
| 6825 TEST_F(LayerTreeHostImplTest, WheelFlingShouldBubble) { | 6863 TEST_F(LayerTreeHostImplTest, WheelFlingShouldBubble) { |
| 6826 // When flinging via wheel, the root should eventually scroll (we should | 6864 // When flinging via wheel, the root should eventually scroll (we should |
| 6827 // bubble). | 6865 // bubble). |
| 6828 gfx::Size surface_size(10, 10); | 6866 gfx::Size surface_size(10, 10); |
| 6829 gfx::Size content_size(20, 20); | 6867 gfx::Size content_size(20, 20); |
| 6830 scoped_ptr<LayerImpl> root_clip = | 6868 scoped_ptr<LayerImpl> root_clip = |
| 6831 LayerImpl::Create(host_impl_->active_tree(), 3); | 6869 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 6870 root_clip->SetHasRenderSurface(true); |
| 6832 scoped_ptr<LayerImpl> root_scroll = | 6871 scoped_ptr<LayerImpl> root_scroll = |
| 6833 CreateScrollableLayer(1, content_size, root_clip.get()); | 6872 CreateScrollableLayer(1, content_size, root_clip.get()); |
| 6834 int root_scroll_id = root_scroll->id(); | 6873 int root_scroll_id = root_scroll->id(); |
| 6835 scoped_ptr<LayerImpl> child = | 6874 scoped_ptr<LayerImpl> child = |
| 6836 CreateScrollableLayer(2, content_size, root_clip.get()); | 6875 CreateScrollableLayer(2, content_size, root_clip.get()); |
| 6837 | 6876 |
| 6838 root_scroll->AddChild(child.Pass()); | 6877 root_scroll->AddChild(child.Pass()); |
| 6839 root_clip->AddChild(root_scroll.Pass()); | 6878 root_clip->AddChild(root_scroll.Pass()); |
| 6840 | 6879 |
| 6841 host_impl_->SetViewportSize(surface_size); | 6880 host_impl_->SetViewportSize(surface_size); |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7025 | 7064 |
| 7026 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed | 7065 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed |
| 7027 // to CompositorFrameMetadata after SwapBuffers(); | 7066 // to CompositorFrameMetadata after SwapBuffers(); |
| 7028 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { | 7067 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { |
| 7029 scoped_ptr<SolidColorLayerImpl> root = | 7068 scoped_ptr<SolidColorLayerImpl> root = |
| 7030 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 7069 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
| 7031 root->SetPosition(gfx::PointF()); | 7070 root->SetPosition(gfx::PointF()); |
| 7032 root->SetBounds(gfx::Size(10, 10)); | 7071 root->SetBounds(gfx::Size(10, 10)); |
| 7033 root->SetContentBounds(gfx::Size(10, 10)); | 7072 root->SetContentBounds(gfx::Size(10, 10)); |
| 7034 root->SetDrawsContent(true); | 7073 root->SetDrawsContent(true); |
| 7074 root->SetHasRenderSurface(true); |
| 7035 | 7075 |
| 7036 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 7076 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 7037 | 7077 |
| 7038 FakeOutputSurface* fake_output_surface = | 7078 FakeOutputSurface* fake_output_surface = |
| 7039 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); | 7079 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); |
| 7040 | 7080 |
| 7041 const std::vector<ui::LatencyInfo>& metadata_latency_before = | 7081 const std::vector<ui::LatencyInfo>& metadata_latency_before = |
| 7042 fake_output_surface->last_sent_frame().metadata.latency_info; | 7082 fake_output_surface->last_sent_frame().metadata.latency_info; |
| 7043 EXPECT_TRUE(metadata_latency_before.empty()); | 7083 EXPECT_TRUE(metadata_latency_before.empty()); |
| 7044 | 7084 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 7065 } | 7105 } |
| 7066 | 7106 |
| 7067 TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) { | 7107 TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) { |
| 7068 int root_layer_id = 1; | 7108 int root_layer_id = 1; |
| 7069 scoped_ptr<SolidColorLayerImpl> root = | 7109 scoped_ptr<SolidColorLayerImpl> root = |
| 7070 SolidColorLayerImpl::Create(host_impl_->active_tree(), root_layer_id); | 7110 SolidColorLayerImpl::Create(host_impl_->active_tree(), root_layer_id); |
| 7071 root->SetPosition(gfx::PointF()); | 7111 root->SetPosition(gfx::PointF()); |
| 7072 root->SetBounds(gfx::Size(10, 10)); | 7112 root->SetBounds(gfx::Size(10, 10)); |
| 7073 root->SetContentBounds(gfx::Size(10, 10)); | 7113 root->SetContentBounds(gfx::Size(10, 10)); |
| 7074 root->SetDrawsContent(true); | 7114 root->SetDrawsContent(true); |
| 7115 root->SetHasRenderSurface(true); |
| 7075 | 7116 |
| 7076 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 7117 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 7077 | 7118 |
| 7078 // Ensure the default frame selection bounds are empty. | 7119 // Ensure the default frame selection bounds are empty. |
| 7079 FakeOutputSurface* fake_output_surface = | 7120 FakeOutputSurface* fake_output_surface = |
| 7080 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); | 7121 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); |
| 7081 const ViewportSelectionBound& selection_start_before = | 7122 const ViewportSelectionBound& selection_start_before = |
| 7082 fake_output_surface->last_sent_frame().metadata.selection_start; | 7123 fake_output_surface->last_sent_frame().metadata.selection_start; |
| 7083 const ViewportSelectionBound& selection_end_before = | 7124 const ViewportSelectionBound& selection_end_before = |
| 7084 fake_output_surface->last_sent_frame().metadata.selection_end; | 7125 fake_output_surface->last_sent_frame().metadata.selection_end; |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7590 contents->SetBounds(content_size); | 7631 contents->SetBounds(content_size); |
| 7591 contents->SetContentBounds(content_size); | 7632 contents->SetContentBounds(content_size); |
| 7592 contents->SetPosition(gfx::PointF()); | 7633 contents->SetPosition(gfx::PointF()); |
| 7593 | 7634 |
| 7594 outer_scroll->AddChild(contents.Pass()); | 7635 outer_scroll->AddChild(contents.Pass()); |
| 7595 outer_clip->AddChild(outer_scroll.Pass()); | 7636 outer_clip->AddChild(outer_scroll.Pass()); |
| 7596 inner_scroll->AddChild(outer_clip.Pass()); | 7637 inner_scroll->AddChild(outer_clip.Pass()); |
| 7597 page_scale->AddChild(inner_scroll.Pass()); | 7638 page_scale->AddChild(inner_scroll.Pass()); |
| 7598 inner_clip->AddChild(page_scale.Pass()); | 7639 inner_clip->AddChild(page_scale.Pass()); |
| 7599 | 7640 |
| 7641 inner_clip->SetHasRenderSurface(true); |
| 7600 layer_tree_impl->SetRootLayer(inner_clip.Pass()); | 7642 layer_tree_impl->SetRootLayer(inner_clip.Pass()); |
| 7601 layer_tree_impl->SetViewportLayersFromIds( | 7643 layer_tree_impl->SetViewportLayersFromIds( |
| 7602 Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportScrollLayerId, | 7644 Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportScrollLayerId, |
| 7603 kOuterViewportScrollLayerId); | 7645 kOuterViewportScrollLayerId); |
| 7604 | 7646 |
| 7605 host_impl_->active_tree()->DidBecomeActive(); | 7647 host_impl_->active_tree()->DidBecomeActive(); |
| 7606 } | 7648 } |
| 7607 }; | 7649 }; |
| 7608 | 7650 |
| 7609 TEST_F(LayerTreeHostImplVirtualViewportTest, FlingScrollBubblesToInner) { | 7651 TEST_F(LayerTreeHostImplVirtualViewportTest, FlingScrollBubblesToInner) { |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8011 // surface. | 8053 // surface. |
| 8012 EXPECT_EQ(0, num_lost_surfaces_); | 8054 EXPECT_EQ(0, num_lost_surfaces_); |
| 8013 host_impl_->DidLoseOutputSurface(); | 8055 host_impl_->DidLoseOutputSurface(); |
| 8014 EXPECT_EQ(1, num_lost_surfaces_); | 8056 EXPECT_EQ(1, num_lost_surfaces_); |
| 8015 host_impl_->DidLoseOutputSurface(); | 8057 host_impl_->DidLoseOutputSurface(); |
| 8016 EXPECT_LE(1, num_lost_surfaces_); | 8058 EXPECT_LE(1, num_lost_surfaces_); |
| 8017 } | 8059 } |
| 8018 | 8060 |
| 8019 } // namespace | 8061 } // namespace |
| 8020 } // namespace cc | 8062 } // namespace cc |
| OLD | NEW |