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 30 matching lines...) Expand all Loading... |
41 #include "cc/test/animation_test_common.h" | 41 #include "cc/test/animation_test_common.h" |
42 #include "cc/test/begin_frame_args_test.h" | 42 #include "cc/test/begin_frame_args_test.h" |
43 #include "cc/test/fake_layer_tree_host_impl.h" | 43 #include "cc/test/fake_layer_tree_host_impl.h" |
44 #include "cc/test/fake_output_surface.h" | 44 #include "cc/test/fake_output_surface.h" |
45 #include "cc/test/fake_output_surface_client.h" | 45 #include "cc/test/fake_output_surface_client.h" |
46 #include "cc/test/fake_picture_layer_impl.h" | 46 #include "cc/test/fake_picture_layer_impl.h" |
47 #include "cc/test/fake_picture_pile_impl.h" | 47 #include "cc/test/fake_picture_pile_impl.h" |
48 #include "cc/test/fake_proxy.h" | 48 #include "cc/test/fake_proxy.h" |
49 #include "cc/test/geometry_test_utils.h" | 49 #include "cc/test/geometry_test_utils.h" |
50 #include "cc/test/layer_test_common.h" | 50 #include "cc/test/layer_test_common.h" |
| 51 #include "cc/test/layer_tree_test.h" |
51 #include "cc/test/render_pass_test_common.h" | 52 #include "cc/test/render_pass_test_common.h" |
52 #include "cc/test/test_gpu_memory_buffer_manager.h" | 53 #include "cc/test/test_gpu_memory_buffer_manager.h" |
53 #include "cc/test/test_shared_bitmap_manager.h" | 54 #include "cc/test/test_shared_bitmap_manager.h" |
54 #include "cc/test/test_web_graphics_context_3d.h" | 55 #include "cc/test/test_web_graphics_context_3d.h" |
55 #include "cc/trees/layer_tree_impl.h" | 56 #include "cc/trees/layer_tree_impl.h" |
56 #include "cc/trees/single_thread_proxy.h" | 57 #include "cc/trees/single_thread_proxy.h" |
57 #include "testing/gmock/include/gmock/gmock.h" | 58 #include "testing/gmock/include/gmock/gmock.h" |
58 #include "testing/gtest/include/gtest/gtest.h" | 59 #include "testing/gtest/include/gtest/gtest.h" |
59 #include "third_party/skia/include/core/SkMallocPixelRef.h" | 60 #include "third_party/skia/include/core/SkMallocPixelRef.h" |
60 #include "ui/gfx/frame_time.h" | 61 #include "ui/gfx/frame_time.h" |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 169 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
169 return init; | 170 return init; |
170 } | 171 } |
171 | 172 |
172 void SetupRootLayerImpl(scoped_ptr<LayerImpl> root) { | 173 void SetupRootLayerImpl(scoped_ptr<LayerImpl> root) { |
173 root->SetPosition(gfx::PointF()); | 174 root->SetPosition(gfx::PointF()); |
174 root->SetBounds(gfx::Size(10, 10)); | 175 root->SetBounds(gfx::Size(10, 10)); |
175 root->SetContentBounds(gfx::Size(10, 10)); | 176 root->SetContentBounds(gfx::Size(10, 10)); |
176 root->SetDrawsContent(true); | 177 root->SetDrawsContent(true); |
177 root->draw_properties().visible_content_rect = gfx::Rect(0, 0, 10, 10); | 178 root->draw_properties().visible_content_rect = gfx::Rect(0, 0, 10, 10); |
| 179 root->SetHasRenderSurface(true); |
178 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 180 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
179 } | 181 } |
180 | 182 |
181 static void ExpectClearedScrollDeltasRecursive(LayerImpl* layer) { | 183 static void ExpectClearedScrollDeltasRecursive(LayerImpl* layer) { |
182 ASSERT_EQ(layer->ScrollDelta(), gfx::Vector2d()); | 184 ASSERT_EQ(layer->ScrollDelta(), gfx::Vector2d()); |
183 for (size_t i = 0; i < layer->children().size(); ++i) | 185 for (size_t i = 0; i < layer->children().size(); ++i) |
184 ExpectClearedScrollDeltasRecursive(layer->children()[i]); | 186 ExpectClearedScrollDeltasRecursive(layer->children()[i]); |
185 } | 187 } |
186 | 188 |
187 static void ExpectContains(const ScrollAndScaleSet& scroll_info, | 189 static void ExpectContains(const ScrollAndScaleSet& scroll_info, |
(...skipping 26 matching lines...) Expand all Loading... |
214 LayerImpl* CreateScrollAndContentsLayers(LayerTreeImpl* layer_tree_impl, | 216 LayerImpl* CreateScrollAndContentsLayers(LayerTreeImpl* layer_tree_impl, |
215 const gfx::Size& content_size) { | 217 const gfx::Size& content_size) { |
216 const int kInnerViewportScrollLayerId = 2; | 218 const int kInnerViewportScrollLayerId = 2; |
217 const int kInnerViewportClipLayerId = 4; | 219 const int kInnerViewportClipLayerId = 4; |
218 const int kPageScaleLayerId = 5; | 220 const int kPageScaleLayerId = 5; |
219 scoped_ptr<LayerImpl> root = | 221 scoped_ptr<LayerImpl> root = |
220 LayerImpl::Create(layer_tree_impl, 1); | 222 LayerImpl::Create(layer_tree_impl, 1); |
221 root->SetBounds(content_size); | 223 root->SetBounds(content_size); |
222 root->SetContentBounds(content_size); | 224 root->SetContentBounds(content_size); |
223 root->SetPosition(gfx::PointF()); | 225 root->SetPosition(gfx::PointF()); |
| 226 root->SetHasRenderSurface(true); |
224 | 227 |
225 scoped_ptr<LayerImpl> scroll = | 228 scoped_ptr<LayerImpl> scroll = |
226 LayerImpl::Create(layer_tree_impl, kInnerViewportScrollLayerId); | 229 LayerImpl::Create(layer_tree_impl, kInnerViewportScrollLayerId); |
227 LayerImpl* scroll_layer = scroll.get(); | 230 LayerImpl* scroll_layer = scroll.get(); |
228 scroll->SetIsContainerForFixedPositionLayers(true); | 231 scroll->SetIsContainerForFixedPositionLayers(true); |
229 scroll->SetScrollOffset(gfx::ScrollOffset()); | 232 scroll->SetScrollOffset(gfx::ScrollOffset()); |
230 | 233 |
231 scoped_ptr<LayerImpl> clip = | 234 scoped_ptr<LayerImpl> clip = |
232 LayerImpl::Create(layer_tree_impl, kInnerViewportClipLayerId); | 235 LayerImpl::Create(layer_tree_impl, kInnerViewportClipLayerId); |
233 clip->SetBounds( | 236 clip->SetBounds( |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 | 558 |
556 // We should still be scrolling, because the scrolled layer also exists in the | 559 // We should still be scrolling, because the scrolled layer also exists in the |
557 // new tree. | 560 // new tree. |
558 gfx::Vector2d scroll_delta(0, 10); | 561 gfx::Vector2d scroll_delta(0, 10); |
559 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 562 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
560 host_impl_->ScrollEnd(); | 563 host_impl_->ScrollEnd(); |
561 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); | 564 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); |
562 ExpectContains(*scroll_info, scroll_layer->id(), scroll_delta); | 565 ExpectContains(*scroll_info, scroll_layer->id(), scroll_delta); |
563 } | 566 } |
564 | 567 |
565 TEST_F(LayerTreeHostImplTest, ClearRootRenderSurfaceAndScroll) { | |
566 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | |
567 host_impl_->SetViewportSize(gfx::Size(50, 50)); | |
568 DrawFrame(); | |
569 | |
570 // We should be able to scroll even if the root layer loses its render surface | |
571 // after the most recent render. | |
572 host_impl_->active_tree()->root_layer()->ClearRenderSurface(); | |
573 host_impl_->active_tree()->set_needs_update_draw_properties(); | |
574 | |
575 EXPECT_EQ(InputHandler::ScrollStarted, | |
576 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); | |
577 } | |
578 | |
579 TEST_F(LayerTreeHostImplTest, WheelEventHandlers) { | 568 TEST_F(LayerTreeHostImplTest, WheelEventHandlers) { |
580 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 569 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
581 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 570 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
582 DrawFrame(); | 571 DrawFrame(); |
583 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 572 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
584 | 573 |
585 root->SetHaveWheelEventHandlers(true); | 574 root->SetHaveWheelEventHandlers(true); |
586 | 575 |
587 // With registered event handlers, wheel scrolls have to go to the main | 576 // With registered event handlers, wheel scrolls have to go to the main |
588 // thread. | 577 // thread. |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
884 host_impl_->ScrollBegin(scroll_position, InputHandler::Wheel)); | 873 host_impl_->ScrollBegin(scroll_position, InputHandler::Wheel)); |
885 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 0), scroll_layer->TotalScrollOffset()); | 874 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 0), scroll_layer->TotalScrollOffset()); |
886 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->TotalScrollOffset()); | 875 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->TotalScrollOffset()); |
887 | 876 |
888 host_impl_->ScrollBy(scroll_position, scroll_delta); | 877 host_impl_->ScrollBy(scroll_position, scroll_delta); |
889 host_impl_->ScrollEnd(); | 878 host_impl_->ScrollEnd(); |
890 EXPECT_VECTOR_EQ(gfx::Vector2dF(20, 10), scroll_layer->TotalScrollOffset()); | 879 EXPECT_VECTOR_EQ(gfx::Vector2dF(20, 10), 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 | 882 |
894 TEST_F(LayerTreeHostImplTest, | |
895 ClearRootRenderSurfaceAndHitTestTouchHandlerRegion) { | |
896 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | |
897 host_impl_->SetViewportSize(gfx::Size(50, 50)); | |
898 DrawFrame(); | |
899 | |
900 // We should be able to hit test for touch event handlers even if the root | |
901 // layer loses its render surface after the most recent render. | |
902 host_impl_->active_tree()->root_layer()->ClearRenderSurface(); | |
903 host_impl_->active_tree()->set_needs_update_draw_properties(); | |
904 | |
905 EXPECT_EQ(host_impl_->HaveTouchEventHandlersAt(gfx::Point()), false); | |
906 } | |
907 | |
908 TEST_F(LayerTreeHostImplTest, ImplPinchZoom) { | 883 TEST_F(LayerTreeHostImplTest, ImplPinchZoom) { |
909 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 884 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
910 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 885 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
911 DrawFrame(); | 886 DrawFrame(); |
912 | 887 |
913 EXPECT_EQ(scroll_layer, host_impl_->InnerViewportScrollLayer()); | 888 EXPECT_EQ(scroll_layer, host_impl_->InnerViewportScrollLayer()); |
914 LayerImpl* container_layer = scroll_layer->scroll_clip_layer(); | 889 LayerImpl* container_layer = scroll_layer->scroll_clip_layer(); |
915 EXPECT_EQ(gfx::Size(50, 50), container_layer->bounds()); | 890 EXPECT_EQ(gfx::Size(50, 50), container_layer->bounds()); |
916 | 891 |
917 float min_page_scale = 1.f, max_page_scale = 4.f; | 892 float min_page_scale = 1.f, max_page_scale = 4.f; |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1426 contents->SetBounds(content_size); \ | 1401 contents->SetBounds(content_size); \ |
1427 contents->SetContentBounds(content_size); \ | 1402 contents->SetContentBounds(content_size); \ |
1428 \ | 1403 \ |
1429 scoped_ptr<SolidColorScrollbarLayerImpl> scrollbar = \ | 1404 scoped_ptr<SolidColorScrollbarLayerImpl> scrollbar = \ |
1430 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 4, \ | 1405 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 4, \ |
1431 VERTICAL, 10, 0, false, true); \ | 1406 VERTICAL, 10, 0, false, true); \ |
1432 EXPECT_FLOAT_EQ(0.f, scrollbar->opacity()); \ | 1407 EXPECT_FLOAT_EQ(0.f, scrollbar->opacity()); \ |
1433 \ | 1408 \ |
1434 scroll->AddChild(contents.Pass()); \ | 1409 scroll->AddChild(contents.Pass()); \ |
1435 root->AddChild(scroll.Pass()); \ | 1410 root->AddChild(scroll.Pass()); \ |
| 1411 root->SetHasRenderSurface(true); \ |
1436 scrollbar->SetScrollLayerAndClipLayerByIds(2, 1); \ | 1412 scrollbar->SetScrollLayerAndClipLayerByIds(2, 1); \ |
1437 root->AddChild(scrollbar.Pass()); \ | 1413 root->AddChild(scrollbar.Pass()); \ |
1438 \ | 1414 \ |
1439 host_impl_->active_tree()->SetRootLayer(root.Pass()); \ | 1415 host_impl_->active_tree()->SetRootLayer(root.Pass()); \ |
1440 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 2, \ | 1416 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 2, \ |
1441 Layer::INVALID_ID); \ | 1417 Layer::INVALID_ID); \ |
1442 host_impl_->active_tree()->DidBecomeActive(); \ | 1418 host_impl_->active_tree()->DidBecomeActive(); \ |
1443 DrawFrame(); | 1419 DrawFrame(); |
1444 | 1420 |
1445 TEST_F(LayerTreeHostImplTest, ScrollbarLinearFadeScheduling) { | 1421 TEST_F(LayerTreeHostImplTest, ScrollbarLinearFadeScheduling) { |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1570 gfx::ScaleSize(viewport_size, device_scale_factor)); | 1546 gfx::ScaleSize(viewport_size, device_scale_factor)); |
1571 gfx::Size content_size(1000, 1000); | 1547 gfx::Size content_size(1000, 1000); |
1572 | 1548 |
1573 CreateHostImpl(settings, CreateOutputSurface()); | 1549 CreateHostImpl(settings, CreateOutputSurface()); |
1574 host_impl_->SetDeviceScaleFactor(device_scale_factor); | 1550 host_impl_->SetDeviceScaleFactor(device_scale_factor); |
1575 host_impl_->SetViewportSize(device_viewport_size); | 1551 host_impl_->SetViewportSize(device_viewport_size); |
1576 | 1552 |
1577 scoped_ptr<LayerImpl> root = | 1553 scoped_ptr<LayerImpl> root = |
1578 LayerImpl::Create(host_impl_->active_tree(), 1); | 1554 LayerImpl::Create(host_impl_->active_tree(), 1); |
1579 root->SetBounds(viewport_size); | 1555 root->SetBounds(viewport_size); |
| 1556 root->SetHasRenderSurface(true); |
1580 | 1557 |
1581 scoped_ptr<LayerImpl> scroll = | 1558 scoped_ptr<LayerImpl> scroll = |
1582 LayerImpl::Create(host_impl_->active_tree(), 2); | 1559 LayerImpl::Create(host_impl_->active_tree(), 2); |
1583 scroll->SetScrollClipLayer(root->id()); | 1560 scroll->SetScrollClipLayer(root->id()); |
1584 scroll->SetScrollOffset(gfx::ScrollOffset()); | 1561 scroll->SetScrollOffset(gfx::ScrollOffset()); |
1585 scroll->SetBounds(content_size); | 1562 scroll->SetBounds(content_size); |
1586 scroll->SetContentBounds(content_size); | 1563 scroll->SetContentBounds(content_size); |
1587 scroll->SetIsContainerForFixedPositionLayers(true); | 1564 scroll->SetIsContainerForFixedPositionLayers(true); |
1588 | 1565 |
1589 scoped_ptr<LayerImpl> contents = | 1566 scoped_ptr<LayerImpl> contents = |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1775 | 1752 |
1776 TEST_F(LayerTreeHostImplTest, WillDrawReturningFalseDoesNotCall) { | 1753 TEST_F(LayerTreeHostImplTest, WillDrawReturningFalseDoesNotCall) { |
1777 // The root layer is always drawn, so run this test on a child layer that | 1754 // The root layer is always drawn, so run this test on a child layer that |
1778 // will be masked out by the root layer's bounds. | 1755 // will be masked out by the root layer's bounds. |
1779 host_impl_->active_tree()->SetRootLayer( | 1756 host_impl_->active_tree()->SetRootLayer( |
1780 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 1757 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
1781 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( | 1758 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( |
1782 host_impl_->active_tree()->root_layer()); | 1759 host_impl_->active_tree()->root_layer()); |
1783 | 1760 |
1784 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 1761 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
| 1762 root->SetHasRenderSurface(true); |
1785 DidDrawCheckLayer* layer = | 1763 DidDrawCheckLayer* layer = |
1786 static_cast<DidDrawCheckLayer*>(root->children()[0]); | 1764 static_cast<DidDrawCheckLayer*>(root->children()[0]); |
1787 | 1765 |
1788 { | 1766 { |
1789 LayerTreeHostImpl::FrameData frame; | 1767 LayerTreeHostImpl::FrameData frame; |
1790 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 1768 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
1791 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 1769 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
1792 host_impl_->DidDrawAllLayers(frame); | 1770 host_impl_->DidDrawAllLayers(frame); |
1793 | 1771 |
1794 EXPECT_TRUE(layer->will_draw_called()); | 1772 EXPECT_TRUE(layer->will_draw_called()); |
(...skipping 20 matching lines...) Expand all Loading... |
1815 } | 1793 } |
1816 | 1794 |
1817 TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) { | 1795 TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) { |
1818 // The root layer is always drawn, so run this test on a child layer that | 1796 // The root layer is always drawn, so run this test on a child layer that |
1819 // will be masked out by the root layer's bounds. | 1797 // will be masked out by the root layer's bounds. |
1820 host_impl_->active_tree()->SetRootLayer( | 1798 host_impl_->active_tree()->SetRootLayer( |
1821 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 1799 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
1822 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( | 1800 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( |
1823 host_impl_->active_tree()->root_layer()); | 1801 host_impl_->active_tree()->root_layer()); |
1824 root->SetMasksToBounds(true); | 1802 root->SetMasksToBounds(true); |
1825 | 1803 root->SetHasRenderSurface(true); |
1826 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 1804 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
1827 DidDrawCheckLayer* layer = | 1805 DidDrawCheckLayer* layer = |
1828 static_cast<DidDrawCheckLayer*>(root->children()[0]); | 1806 static_cast<DidDrawCheckLayer*>(root->children()[0]); |
1829 // Ensure visible_content_rect for layer is empty. | 1807 // Ensure visible_content_rect for layer is empty. |
1830 layer->SetPosition(gfx::PointF(100.f, 100.f)); | 1808 layer->SetPosition(gfx::PointF(100.f, 100.f)); |
1831 layer->SetBounds(gfx::Size(10, 10)); | 1809 layer->SetBounds(gfx::Size(10, 10)); |
1832 layer->SetContentBounds(gfx::Size(10, 10)); | 1810 layer->SetContentBounds(gfx::Size(10, 10)); |
1833 | 1811 |
1834 LayerTreeHostImpl::FrameData frame; | 1812 LayerTreeHostImpl::FrameData frame; |
1835 | 1813 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1868 host_impl_->active_tree()->SetRootLayer( | 1846 host_impl_->active_tree()->SetRootLayer( |
1869 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 1847 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
1870 DidDrawCheckLayer* root = | 1848 DidDrawCheckLayer* root = |
1871 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 1849 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
1872 | 1850 |
1873 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 1851 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
1874 DidDrawCheckLayer* occluded_layer = | 1852 DidDrawCheckLayer* occluded_layer = |
1875 static_cast<DidDrawCheckLayer*>(root->children()[0]); | 1853 static_cast<DidDrawCheckLayer*>(root->children()[0]); |
1876 | 1854 |
1877 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); | 1855 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); |
| 1856 root->SetHasRenderSurface(true); |
1878 DidDrawCheckLayer* top_layer = | 1857 DidDrawCheckLayer* top_layer = |
1879 static_cast<DidDrawCheckLayer*>(root->children()[1]); | 1858 static_cast<DidDrawCheckLayer*>(root->children()[1]); |
1880 // This layer covers the occluded_layer above. Make this layer large so it can | 1859 // This layer covers the occluded_layer above. Make this layer large so it can |
1881 // occlude. | 1860 // occlude. |
1882 top_layer->SetBounds(big_size); | 1861 top_layer->SetBounds(big_size); |
1883 top_layer->SetContentBounds(big_size); | 1862 top_layer->SetContentBounds(big_size); |
1884 top_layer->SetContentsOpaque(true); | 1863 top_layer->SetContentsOpaque(true); |
1885 | 1864 |
1886 LayerTreeHostImpl::FrameData frame; | 1865 LayerTreeHostImpl::FrameData frame; |
1887 | 1866 |
(...skipping 12 matching lines...) Expand all Loading... |
1900 EXPECT_TRUE(top_layer->did_draw_called()); | 1879 EXPECT_TRUE(top_layer->did_draw_called()); |
1901 } | 1880 } |
1902 | 1881 |
1903 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { | 1882 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { |
1904 host_impl_->active_tree()->SetRootLayer( | 1883 host_impl_->active_tree()->SetRootLayer( |
1905 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 1884 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
1906 DidDrawCheckLayer* root = | 1885 DidDrawCheckLayer* root = |
1907 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 1886 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
1908 | 1887 |
1909 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 1888 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
| 1889 root->SetHasRenderSurface(true); |
1910 DidDrawCheckLayer* layer1 = | 1890 DidDrawCheckLayer* layer1 = |
1911 static_cast<DidDrawCheckLayer*>(root->children()[0]); | 1891 static_cast<DidDrawCheckLayer*>(root->children()[0]); |
1912 | 1892 |
1913 layer1->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); | 1893 layer1->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); |
1914 DidDrawCheckLayer* layer2 = | 1894 DidDrawCheckLayer* layer2 = |
1915 static_cast<DidDrawCheckLayer*>(layer1->children()[0]); | 1895 static_cast<DidDrawCheckLayer*>(layer1->children()[0]); |
1916 | 1896 |
1917 layer1->SetOpacity(0.3f); | 1897 layer1->SetHasRenderSurface(true); |
1918 layer1->SetShouldFlattenTransform(true); | 1898 layer1->SetShouldFlattenTransform(true); |
1919 | 1899 |
1920 EXPECT_FALSE(root->did_draw_called()); | 1900 EXPECT_FALSE(root->did_draw_called()); |
1921 EXPECT_FALSE(layer1->did_draw_called()); | 1901 EXPECT_FALSE(layer1->did_draw_called()); |
1922 EXPECT_FALSE(layer2->did_draw_called()); | 1902 EXPECT_FALSE(layer2->did_draw_called()); |
1923 | 1903 |
1924 LayerTreeHostImpl::FrameData frame; | 1904 LayerTreeHostImpl::FrameData frame; |
1925 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( | 1905 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( |
1926 host_impl_->active_tree()->root_layer()); | 1906 host_impl_->active_tree()->root_layer()); |
1927 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 1907 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1979 | 1959 |
1980 bool tile_missing_; | 1960 bool tile_missing_; |
1981 bool had_incomplete_tile_; | 1961 bool had_incomplete_tile_; |
1982 }; | 1962 }; |
1983 | 1963 |
1984 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsOnDefault) { | 1964 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsOnDefault) { |
1985 host_impl_->active_tree()->SetRootLayer( | 1965 host_impl_->active_tree()->SetRootLayer( |
1986 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 1966 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
1987 DidDrawCheckLayer* root = | 1967 DidDrawCheckLayer* root = |
1988 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 1968 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
1989 | 1969 root->SetHasRenderSurface(true); |
1990 bool tile_missing = false; | 1970 bool tile_missing = false; |
1991 bool had_incomplete_tile = false; | 1971 bool had_incomplete_tile = false; |
1992 bool is_animating = false; | 1972 bool is_animating = false; |
1993 root->AddChild( | 1973 root->AddChild( |
1994 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 1974 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
1995 2, | 1975 2, |
1996 tile_missing, | 1976 tile_missing, |
1997 had_incomplete_tile, | 1977 had_incomplete_tile, |
1998 is_animating, | 1978 is_animating, |
1999 host_impl_->resource_provider())); | 1979 host_impl_->resource_provider())); |
2000 | 1980 |
2001 LayerTreeHostImpl::FrameData frame; | 1981 LayerTreeHostImpl::FrameData frame; |
2002 | 1982 |
2003 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 1983 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
2004 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 1984 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
2005 host_impl_->DidDrawAllLayers(frame); | 1985 host_impl_->DidDrawAllLayers(frame); |
2006 } | 1986 } |
2007 | 1987 |
2008 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithAnimatedLayer) { | 1988 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithAnimatedLayer) { |
2009 host_impl_->active_tree()->SetRootLayer( | 1989 host_impl_->active_tree()->SetRootLayer( |
2010 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 1990 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
2011 DidDrawCheckLayer* root = | 1991 DidDrawCheckLayer* root = |
2012 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 1992 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 1993 root->SetHasRenderSurface(true); |
2013 bool tile_missing = false; | 1994 bool tile_missing = false; |
2014 bool had_incomplete_tile = false; | 1995 bool had_incomplete_tile = false; |
2015 bool is_animating = true; | 1996 bool is_animating = true; |
2016 root->AddChild( | 1997 root->AddChild( |
2017 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 1998 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
2018 2, | 1999 2, |
2019 tile_missing, | 2000 tile_missing, |
2020 had_incomplete_tile, | 2001 had_incomplete_tile, |
2021 is_animating, | 2002 is_animating, |
2022 host_impl_->resource_provider())); | 2003 host_impl_->resource_provider())); |
2023 | 2004 |
2024 LayerTreeHostImpl::FrameData frame; | 2005 LayerTreeHostImpl::FrameData frame; |
2025 | 2006 |
2026 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2007 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
2027 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2008 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
2028 host_impl_->DidDrawAllLayers(frame); | 2009 host_impl_->DidDrawAllLayers(frame); |
2029 } | 2010 } |
2030 | 2011 |
2031 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithMissingTiles) { | 2012 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithMissingTiles) { |
2032 host_impl_->active_tree()->SetRootLayer( | 2013 host_impl_->active_tree()->SetRootLayer( |
2033 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); | 2014 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); |
2034 DidDrawCheckLayer* root = | 2015 DidDrawCheckLayer* root = |
2035 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2016 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 2017 root->SetHasRenderSurface(true); |
2036 | 2018 |
2037 LayerTreeHostImpl::FrameData frame; | 2019 LayerTreeHostImpl::FrameData frame; |
2038 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2020 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
2039 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2021 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
2040 host_impl_->DidDrawAllLayers(frame); | 2022 host_impl_->DidDrawAllLayers(frame); |
2041 host_impl_->SwapBuffers(frame); | 2023 host_impl_->SwapBuffers(frame); |
2042 | 2024 |
2043 bool tile_missing = true; | 2025 bool tile_missing = true; |
2044 bool had_incomplete_tile = false; | 2026 bool had_incomplete_tile = false; |
2045 bool is_animating = false; | 2027 bool is_animating = false; |
2046 root->AddChild( | 2028 root->AddChild( |
2047 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 2029 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
2048 4, | 2030 4, |
2049 tile_missing, | 2031 tile_missing, |
2050 had_incomplete_tile, | 2032 had_incomplete_tile, |
2051 is_animating, | 2033 is_animating, |
2052 host_impl_->resource_provider())); | 2034 host_impl_->resource_provider())); |
2053 LayerTreeHostImpl::FrameData frame2; | 2035 LayerTreeHostImpl::FrameData frame2; |
2054 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame2)); | 2036 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame2)); |
2055 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); | 2037 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); |
2056 host_impl_->DidDrawAllLayers(frame2); | 2038 host_impl_->DidDrawAllLayers(frame2); |
2057 } | 2039 } |
2058 | 2040 |
2059 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithIncompleteTile) { | 2041 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithIncompleteTile) { |
2060 host_impl_->active_tree()->SetRootLayer( | 2042 host_impl_->active_tree()->SetRootLayer( |
2061 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); | 2043 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); |
2062 DidDrawCheckLayer* root = | 2044 DidDrawCheckLayer* root = |
2063 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2045 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 2046 root->SetHasRenderSurface(true); |
2064 | 2047 |
2065 LayerTreeHostImpl::FrameData frame; | 2048 LayerTreeHostImpl::FrameData frame; |
2066 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2049 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
2067 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2050 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
2068 host_impl_->DidDrawAllLayers(frame); | 2051 host_impl_->DidDrawAllLayers(frame); |
2069 host_impl_->SwapBuffers(frame); | 2052 host_impl_->SwapBuffers(frame); |
2070 | 2053 |
2071 bool tile_missing = false; | 2054 bool tile_missing = false; |
2072 bool had_incomplete_tile = true; | 2055 bool had_incomplete_tile = true; |
2073 bool is_animating = false; | 2056 bool is_animating = false; |
2074 root->AddChild( | 2057 root->AddChild( |
2075 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 2058 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
2076 4, | 2059 4, |
2077 tile_missing, | 2060 tile_missing, |
2078 had_incomplete_tile, | 2061 had_incomplete_tile, |
2079 is_animating, | 2062 is_animating, |
2080 host_impl_->resource_provider())); | 2063 host_impl_->resource_provider())); |
2081 LayerTreeHostImpl::FrameData frame2; | 2064 LayerTreeHostImpl::FrameData frame2; |
2082 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame2)); | 2065 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame2)); |
2083 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); | 2066 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); |
2084 host_impl_->DidDrawAllLayers(frame2); | 2067 host_impl_->DidDrawAllLayers(frame2); |
2085 } | 2068 } |
2086 | 2069 |
2087 TEST_F(LayerTreeHostImplTest, | 2070 TEST_F(LayerTreeHostImplTest, |
2088 PrepareToDrawFailsWithAnimationAndMissingTilesUsesCheckerboard) { | 2071 PrepareToDrawFailsWithAnimationAndMissingTilesUsesCheckerboard) { |
2089 host_impl_->active_tree()->SetRootLayer( | 2072 host_impl_->active_tree()->SetRootLayer( |
2090 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); | 2073 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); |
2091 DidDrawCheckLayer* root = | 2074 DidDrawCheckLayer* root = |
2092 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2075 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 2076 root->SetHasRenderSurface(true); |
2093 | 2077 |
2094 LayerTreeHostImpl::FrameData frame; | 2078 LayerTreeHostImpl::FrameData frame; |
2095 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2079 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
2096 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2080 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
2097 host_impl_->DidDrawAllLayers(frame); | 2081 host_impl_->DidDrawAllLayers(frame); |
2098 host_impl_->SwapBuffers(frame); | 2082 host_impl_->SwapBuffers(frame); |
2099 | 2083 |
2100 bool tile_missing = true; | 2084 bool tile_missing = true; |
2101 bool had_incomplete_tile = false; | 2085 bool had_incomplete_tile = false; |
2102 bool is_animating = true; | 2086 bool is_animating = true; |
(...skipping 10 matching lines...) Expand all Loading... |
2113 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); | 2097 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); |
2114 host_impl_->DidDrawAllLayers(frame2); | 2098 host_impl_->DidDrawAllLayers(frame2); |
2115 } | 2099 } |
2116 | 2100 |
2117 TEST_F(LayerTreeHostImplTest, | 2101 TEST_F(LayerTreeHostImplTest, |
2118 PrepareToDrawSucceedsWithAnimationAndIncompleteTiles) { | 2102 PrepareToDrawSucceedsWithAnimationAndIncompleteTiles) { |
2119 host_impl_->active_tree()->SetRootLayer( | 2103 host_impl_->active_tree()->SetRootLayer( |
2120 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); | 2104 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); |
2121 DidDrawCheckLayer* root = | 2105 DidDrawCheckLayer* root = |
2122 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2106 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 2107 root->SetHasRenderSurface(true); |
2123 | 2108 |
2124 LayerTreeHostImpl::FrameData frame; | 2109 LayerTreeHostImpl::FrameData frame; |
2125 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2110 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
2126 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2111 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
2127 host_impl_->DidDrawAllLayers(frame); | 2112 host_impl_->DidDrawAllLayers(frame); |
2128 host_impl_->SwapBuffers(frame); | 2113 host_impl_->SwapBuffers(frame); |
2129 | 2114 |
2130 bool tile_missing = false; | 2115 bool tile_missing = false; |
2131 bool had_incomplete_tile = true; | 2116 bool had_incomplete_tile = true; |
2132 bool is_animating = true; | 2117 bool is_animating = true; |
2133 root->AddChild( | 2118 root->AddChild( |
2134 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 2119 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
2135 6, | 2120 6, |
2136 tile_missing, | 2121 tile_missing, |
2137 had_incomplete_tile, | 2122 had_incomplete_tile, |
2138 is_animating, | 2123 is_animating, |
2139 host_impl_->resource_provider())); | 2124 host_impl_->resource_provider())); |
2140 LayerTreeHostImpl::FrameData frame2; | 2125 LayerTreeHostImpl::FrameData frame2; |
2141 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame2)); | 2126 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame2)); |
2142 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); | 2127 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); |
2143 host_impl_->DidDrawAllLayers(frame2); | 2128 host_impl_->DidDrawAllLayers(frame2); |
2144 } | 2129 } |
2145 | 2130 |
2146 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWhenHighResRequired) { | 2131 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWhenHighResRequired) { |
2147 host_impl_->active_tree()->SetRootLayer( | 2132 host_impl_->active_tree()->SetRootLayer( |
2148 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); | 2133 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); |
2149 DidDrawCheckLayer* root = | 2134 DidDrawCheckLayer* root = |
2150 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2135 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 2136 root->SetHasRenderSurface(true); |
2151 | 2137 |
2152 LayerTreeHostImpl::FrameData frame; | 2138 LayerTreeHostImpl::FrameData frame; |
2153 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2139 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
2154 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2140 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
2155 host_impl_->DidDrawAllLayers(frame); | 2141 host_impl_->DidDrawAllLayers(frame); |
2156 host_impl_->SwapBuffers(frame); | 2142 host_impl_->SwapBuffers(frame); |
2157 | 2143 |
2158 bool tile_missing = false; | 2144 bool tile_missing = false; |
2159 bool had_incomplete_tile = false; | 2145 bool had_incomplete_tile = false; |
2160 bool is_animating = false; | 2146 bool is_animating = false; |
(...skipping 10 matching lines...) Expand all Loading... |
2171 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); | 2157 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); |
2172 host_impl_->DidDrawAllLayers(frame2); | 2158 host_impl_->DidDrawAllLayers(frame2); |
2173 } | 2159 } |
2174 | 2160 |
2175 TEST_F(LayerTreeHostImplTest, | 2161 TEST_F(LayerTreeHostImplTest, |
2176 PrepareToDrawFailsWhenHighResRequiredAndIncompleteTiles) { | 2162 PrepareToDrawFailsWhenHighResRequiredAndIncompleteTiles) { |
2177 host_impl_->active_tree()->SetRootLayer( | 2163 host_impl_->active_tree()->SetRootLayer( |
2178 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); | 2164 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); |
2179 DidDrawCheckLayer* root = | 2165 DidDrawCheckLayer* root = |
2180 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2166 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 2167 root->SetHasRenderSurface(true); |
2181 | 2168 |
2182 LayerTreeHostImpl::FrameData frame; | 2169 LayerTreeHostImpl::FrameData frame; |
2183 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2170 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
2184 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2171 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
2185 host_impl_->DidDrawAllLayers(frame); | 2172 host_impl_->DidDrawAllLayers(frame); |
2186 host_impl_->SwapBuffers(frame); | 2173 host_impl_->SwapBuffers(frame); |
2187 | 2174 |
2188 bool tile_missing = false; | 2175 bool tile_missing = false; |
2189 bool had_incomplete_tile = true; | 2176 bool had_incomplete_tile = true; |
2190 bool is_animating = false; | 2177 bool is_animating = false; |
(...skipping 11 matching lines...) Expand all Loading... |
2202 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); | 2189 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); |
2203 host_impl_->DidDrawAllLayers(frame2); | 2190 host_impl_->DidDrawAllLayers(frame2); |
2204 } | 2191 } |
2205 | 2192 |
2206 TEST_F(LayerTreeHostImplTest, | 2193 TEST_F(LayerTreeHostImplTest, |
2207 PrepareToDrawFailsWhenHighResRequiredAndMissingTile) { | 2194 PrepareToDrawFailsWhenHighResRequiredAndMissingTile) { |
2208 host_impl_->active_tree()->SetRootLayer( | 2195 host_impl_->active_tree()->SetRootLayer( |
2209 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); | 2196 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); |
2210 DidDrawCheckLayer* root = | 2197 DidDrawCheckLayer* root = |
2211 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2198 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 2199 root->SetHasRenderSurface(true); |
2212 | 2200 |
2213 LayerTreeHostImpl::FrameData frame; | 2201 LayerTreeHostImpl::FrameData frame; |
2214 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2202 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
2215 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2203 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
2216 host_impl_->DidDrawAllLayers(frame); | 2204 host_impl_->DidDrawAllLayers(frame); |
2217 host_impl_->SwapBuffers(frame); | 2205 host_impl_->SwapBuffers(frame); |
2218 | 2206 |
2219 bool tile_missing = true; | 2207 bool tile_missing = true; |
2220 bool had_incomplete_tile = false; | 2208 bool had_incomplete_tile = false; |
2221 bool is_animating = false; | 2209 bool is_animating = false; |
2222 root->AddChild( | 2210 root->AddChild( |
2223 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 2211 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
2224 8, | 2212 8, |
2225 tile_missing, | 2213 tile_missing, |
2226 had_incomplete_tile, | 2214 had_incomplete_tile, |
2227 is_animating, | 2215 is_animating, |
2228 host_impl_->resource_provider())); | 2216 host_impl_->resource_provider())); |
2229 host_impl_->SetRequiresHighResToDraw(); | 2217 host_impl_->SetRequiresHighResToDraw(); |
2230 LayerTreeHostImpl::FrameData frame2; | 2218 LayerTreeHostImpl::FrameData frame2; |
2231 EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT, | 2219 EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT, |
2232 host_impl_->PrepareToDraw(&frame2)); | 2220 host_impl_->PrepareToDraw(&frame2)); |
2233 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); | 2221 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); |
2234 host_impl_->DidDrawAllLayers(frame2); | 2222 host_impl_->DidDrawAllLayers(frame2); |
2235 } | 2223 } |
2236 | 2224 |
2237 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { | 2225 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { |
2238 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 2226 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
2239 root->SetScrollClipLayer(Layer::INVALID_ID); | 2227 root->SetScrollClipLayer(Layer::INVALID_ID); |
| 2228 root->SetHasRenderSurface(true); |
2240 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 2229 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
2241 DrawFrame(); | 2230 DrawFrame(); |
2242 | 2231 |
2243 // Scroll event is ignored because layer is not scrollable. | 2232 // Scroll event is ignored because layer is not scrollable. |
2244 EXPECT_EQ(InputHandler::ScrollIgnored, | 2233 EXPECT_EQ(InputHandler::ScrollIgnored, |
2245 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); | 2234 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
2246 EXPECT_FALSE(did_request_redraw_); | 2235 EXPECT_FALSE(did_request_redraw_); |
2247 EXPECT_FALSE(did_request_commit_); | 2236 EXPECT_FALSE(did_request_commit_); |
2248 } | 2237 } |
2249 | 2238 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2284 LayerImpl::Create(host_impl_->active_tree(), 2); | 2273 LayerImpl::Create(host_impl_->active_tree(), 2); |
2285 root_clip->SetBounds(clip_size_); | 2274 root_clip->SetBounds(clip_size_); |
2286 root->SetScrollClipLayer(root_clip->id()); | 2275 root->SetScrollClipLayer(root_clip->id()); |
2287 root->SetBounds(layer_size_); | 2276 root->SetBounds(layer_size_); |
2288 root->SetContentBounds(layer_size_); | 2277 root->SetContentBounds(layer_size_); |
2289 root->SetPosition(gfx::PointF()); | 2278 root->SetPosition(gfx::PointF()); |
2290 root->SetDrawsContent(false); | 2279 root->SetDrawsContent(false); |
2291 root->SetIsContainerForFixedPositionLayers(true); | 2280 root->SetIsContainerForFixedPositionLayers(true); |
2292 int inner_viewport_scroll_layer_id = root->id(); | 2281 int inner_viewport_scroll_layer_id = root->id(); |
2293 int page_scale_layer_id = root_clip->id(); | 2282 int page_scale_layer_id = root_clip->id(); |
| 2283 root_clip->SetHasRenderSurface(true); |
2294 root_clip->AddChild(root.Pass()); | 2284 root_clip->AddChild(root.Pass()); |
| 2285 root_clip->SetHasRenderSurface(true); |
2295 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 2286 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); |
2296 host_impl_->active_tree()->SetViewportLayersFromIds( | 2287 host_impl_->active_tree()->SetViewportLayersFromIds( |
2297 Layer::INVALID_ID, page_scale_layer_id, inner_viewport_scroll_layer_id, | 2288 Layer::INVALID_ID, page_scale_layer_id, inner_viewport_scroll_layer_id, |
2298 Layer::INVALID_ID); | 2289 Layer::INVALID_ID); |
2299 // Set a viewport size that is large enough to contain both the top controls | 2290 // Set a viewport size that is large enough to contain both the top controls |
2300 // and some content. | 2291 // and some content. |
2301 host_impl_->SetViewportSize(viewport_size_); | 2292 host_impl_->SetViewportSize(viewport_size_); |
2302 host_impl_->sync_tree()->set_top_controls_shrink_blink_size(true); | 2293 host_impl_->sync_tree()->set_top_controls_shrink_blink_size(true); |
2303 | 2294 |
2304 host_impl_->DidChangeTopControlsPosition(); | 2295 host_impl_->DidChangeTopControlsPosition(); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2349 scoped_ptr<LayerImpl> outer_clip = | 2340 scoped_ptr<LayerImpl> outer_clip = |
2350 LayerImpl::Create(host_impl_->active_tree(), 5); | 2341 LayerImpl::Create(host_impl_->active_tree(), 5); |
2351 | 2342 |
2352 root_clip->SetBounds(inner_viewport_size); | 2343 root_clip->SetBounds(inner_viewport_size); |
2353 root->SetScrollClipLayer(root_clip->id()); | 2344 root->SetScrollClipLayer(root_clip->id()); |
2354 root->SetBounds(outer_viewport_size); | 2345 root->SetBounds(outer_viewport_size); |
2355 root->SetContentBounds(outer_viewport_size); | 2346 root->SetContentBounds(outer_viewport_size); |
2356 root->SetPosition(gfx::PointF()); | 2347 root->SetPosition(gfx::PointF()); |
2357 root->SetDrawsContent(false); | 2348 root->SetDrawsContent(false); |
2358 root->SetIsContainerForFixedPositionLayers(true); | 2349 root->SetIsContainerForFixedPositionLayers(true); |
2359 | 2350 root_clip->SetHasRenderSurface(true); |
2360 outer_clip->SetBounds(outer_viewport_size); | 2351 outer_clip->SetBounds(outer_viewport_size); |
2361 outer_scroll->SetScrollClipLayer(outer_clip->id()); | 2352 outer_scroll->SetScrollClipLayer(outer_clip->id()); |
2362 outer_scroll->SetBounds(scroll_layer_size); | 2353 outer_scroll->SetBounds(scroll_layer_size); |
2363 outer_scroll->SetContentBounds(scroll_layer_size); | 2354 outer_scroll->SetContentBounds(scroll_layer_size); |
2364 outer_scroll->SetPosition(gfx::PointF()); | 2355 outer_scroll->SetPosition(gfx::PointF()); |
2365 outer_scroll->SetDrawsContent(false); | 2356 outer_scroll->SetDrawsContent(false); |
2366 outer_scroll->SetIsContainerForFixedPositionLayers(true); | 2357 outer_scroll->SetIsContainerForFixedPositionLayers(true); |
2367 | 2358 |
2368 int inner_viewport_scroll_layer_id = root->id(); | 2359 int inner_viewport_scroll_layer_id = root->id(); |
2369 int outer_viewport_scroll_layer_id = outer_scroll->id(); | 2360 int outer_viewport_scroll_layer_id = outer_scroll->id(); |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2922 | 2913 |
2923 scoped_ptr<LayerImpl> scroll_layer = | 2914 scoped_ptr<LayerImpl> scroll_layer = |
2924 LayerImpl::Create(host_impl_->active_tree(), 2); | 2915 LayerImpl::Create(host_impl_->active_tree(), 2); |
2925 scroll_layer->SetScrollClipLayer(3); | 2916 scroll_layer->SetScrollClipLayer(3); |
2926 scroll_layer->SetBounds(contents_size); | 2917 scroll_layer->SetBounds(contents_size); |
2927 scroll_layer->SetContentBounds(contents_size); | 2918 scroll_layer->SetContentBounds(contents_size); |
2928 scroll_layer->SetPosition(gfx::PointF()); | 2919 scroll_layer->SetPosition(gfx::PointF()); |
2929 scroll_layer->AddChild(content_layer.Pass()); | 2920 scroll_layer->AddChild(content_layer.Pass()); |
2930 scroll_clip_layer->AddChild(scroll_layer.Pass()); | 2921 scroll_clip_layer->AddChild(scroll_layer.Pass()); |
2931 | 2922 |
| 2923 scroll_clip_layer->SetHasRenderSurface(true); |
2932 host_impl_->active_tree()->SetRootLayer(scroll_clip_layer.Pass()); | 2924 host_impl_->active_tree()->SetRootLayer(scroll_clip_layer.Pass()); |
2933 host_impl_->SetViewportSize(surface_size); | 2925 host_impl_->SetViewportSize(surface_size); |
2934 DrawFrame(); | 2926 DrawFrame(); |
2935 | 2927 |
2936 EXPECT_EQ(InputHandler::ScrollStarted, | 2928 EXPECT_EQ(InputHandler::ScrollStarted, |
2937 host_impl_->ScrollBegin(gfx::Point(5, 5), | 2929 host_impl_->ScrollBegin(gfx::Point(5, 5), |
2938 InputHandler::Wheel)); | 2930 InputHandler::Wheel)); |
2939 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 2931 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
2940 host_impl_->ScrollEnd(); | 2932 host_impl_->ScrollEnd(); |
2941 EXPECT_TRUE(did_request_redraw_); | 2933 EXPECT_TRUE(did_request_redraw_); |
2942 EXPECT_TRUE(did_request_commit_); | 2934 EXPECT_TRUE(did_request_commit_); |
2943 } | 2935 } |
2944 | 2936 |
2945 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) { | 2937 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) { |
2946 gfx::Size surface_size(10, 10); | 2938 gfx::Size surface_size(10, 10); |
2947 gfx::Size contents_size(20, 20); | 2939 gfx::Size contents_size(20, 20); |
2948 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 2940 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
2949 root->SetBounds(surface_size); | 2941 root->SetBounds(surface_size); |
2950 root->SetContentBounds(contents_size); | 2942 root->SetContentBounds(contents_size); |
2951 root->AddChild(CreateScrollableLayer(2, contents_size, root.get())); | 2943 root->AddChild(CreateScrollableLayer(2, contents_size, root.get())); |
| 2944 root->SetHasRenderSurface(true); |
2952 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 2945 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
2953 host_impl_->SetViewportSize(surface_size); | 2946 host_impl_->SetViewportSize(surface_size); |
2954 DrawFrame(); | 2947 DrawFrame(); |
2955 | 2948 |
2956 EXPECT_EQ(InputHandler::ScrollStarted, | 2949 EXPECT_EQ(InputHandler::ScrollStarted, |
2957 host_impl_->ScrollBegin(gfx::Point(5, 5), | 2950 host_impl_->ScrollBegin(gfx::Point(5, 5), |
2958 InputHandler::Wheel)); | 2951 InputHandler::Wheel)); |
2959 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 2952 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
2960 host_impl_->ScrollEnd(); | 2953 host_impl_->ScrollEnd(); |
2961 EXPECT_TRUE(did_request_redraw_); | 2954 EXPECT_TRUE(did_request_redraw_); |
2962 EXPECT_TRUE(did_request_commit_); | 2955 EXPECT_TRUE(did_request_commit_); |
2963 } | 2956 } |
2964 | 2957 |
2965 TEST_F(LayerTreeHostImplTest, ScrollMissesChild) { | 2958 TEST_F(LayerTreeHostImplTest, ScrollMissesChild) { |
2966 gfx::Size surface_size(10, 10); | 2959 gfx::Size surface_size(10, 10); |
2967 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 2960 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
2968 root->AddChild(CreateScrollableLayer(2, surface_size, root.get())); | 2961 root->AddChild(CreateScrollableLayer(2, surface_size, root.get())); |
| 2962 root->SetHasRenderSurface(true); |
2969 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 2963 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
2970 host_impl_->SetViewportSize(surface_size); | 2964 host_impl_->SetViewportSize(surface_size); |
2971 DrawFrame(); | 2965 DrawFrame(); |
2972 | 2966 |
2973 // Scroll event is ignored because the input coordinate is outside the layer | 2967 // Scroll event is ignored because the input coordinate is outside the layer |
2974 // boundaries. | 2968 // boundaries. |
2975 EXPECT_EQ(InputHandler::ScrollIgnored, | 2969 EXPECT_EQ(InputHandler::ScrollIgnored, |
2976 host_impl_->ScrollBegin(gfx::Point(15, 5), | 2970 host_impl_->ScrollBegin(gfx::Point(15, 5), |
2977 InputHandler::Wheel)); | 2971 InputHandler::Wheel)); |
2978 EXPECT_FALSE(did_request_redraw_); | 2972 EXPECT_FALSE(did_request_redraw_); |
2979 EXPECT_FALSE(did_request_commit_); | 2973 EXPECT_FALSE(did_request_commit_); |
2980 } | 2974 } |
2981 | 2975 |
2982 TEST_F(LayerTreeHostImplTest, ScrollMissesBackfacingChild) { | 2976 TEST_F(LayerTreeHostImplTest, ScrollMissesBackfacingChild) { |
2983 gfx::Size surface_size(10, 10); | 2977 gfx::Size surface_size(10, 10); |
2984 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 2978 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 2979 root->SetHasRenderSurface(true); |
2985 scoped_ptr<LayerImpl> child = | 2980 scoped_ptr<LayerImpl> child = |
2986 CreateScrollableLayer(2, surface_size, root.get()); | 2981 CreateScrollableLayer(2, surface_size, root.get()); |
2987 host_impl_->SetViewportSize(surface_size); | 2982 host_impl_->SetViewportSize(surface_size); |
2988 | 2983 |
2989 gfx::Transform matrix; | 2984 gfx::Transform matrix; |
2990 matrix.RotateAboutXAxis(180.0); | 2985 matrix.RotateAboutXAxis(180.0); |
2991 child->SetTransform(matrix); | 2986 child->SetTransform(matrix); |
2992 child->SetDoubleSided(false); | 2987 child->SetDoubleSided(false); |
2993 | 2988 |
2994 root->AddChild(child.Pass()); | 2989 root->AddChild(child.Pass()); |
(...skipping 17 matching lines...) Expand all Loading... |
3012 CreateScrollableLayer(1, surface_size, clip_layer.get()); | 3007 CreateScrollableLayer(1, surface_size, clip_layer.get()); |
3013 content_layer->SetShouldScrollOnMainThread(true); | 3008 content_layer->SetShouldScrollOnMainThread(true); |
3014 content_layer->SetScrollClipLayer(Layer::INVALID_ID); | 3009 content_layer->SetScrollClipLayer(Layer::INVALID_ID); |
3015 | 3010 |
3016 // Note: we can use the same clip layer for both since both calls to | 3011 // Note: we can use the same clip layer for both since both calls to |
3017 // CreateScrollableLayer() use the same surface size. | 3012 // CreateScrollableLayer() use the same surface size. |
3018 scoped_ptr<LayerImpl> scroll_layer = | 3013 scoped_ptr<LayerImpl> scroll_layer = |
3019 CreateScrollableLayer(2, surface_size, clip_layer.get()); | 3014 CreateScrollableLayer(2, surface_size, clip_layer.get()); |
3020 scroll_layer->AddChild(content_layer.Pass()); | 3015 scroll_layer->AddChild(content_layer.Pass()); |
3021 clip_layer->AddChild(scroll_layer.Pass()); | 3016 clip_layer->AddChild(scroll_layer.Pass()); |
| 3017 clip_layer->SetHasRenderSurface(true); |
3022 | 3018 |
3023 host_impl_->active_tree()->SetRootLayer(clip_layer.Pass()); | 3019 host_impl_->active_tree()->SetRootLayer(clip_layer.Pass()); |
3024 host_impl_->SetViewportSize(surface_size); | 3020 host_impl_->SetViewportSize(surface_size); |
3025 DrawFrame(); | 3021 DrawFrame(); |
3026 | 3022 |
3027 // Scrolling fails because the content layer is asking to be scrolled on the | 3023 // Scrolling fails because the content layer is asking to be scrolled on the |
3028 // main thread. | 3024 // main thread. |
3029 EXPECT_EQ(InputHandler::ScrollOnMainThread, | 3025 EXPECT_EQ(InputHandler::ScrollOnMainThread, |
3030 host_impl_->ScrollBegin(gfx::Point(5, 5), | 3026 host_impl_->ScrollBegin(gfx::Point(5, 5), |
3031 InputHandler::Wheel)); | 3027 InputHandler::Wheel)); |
3032 } | 3028 } |
3033 | 3029 |
3034 TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnMainThread) { | 3030 TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnMainThread) { |
3035 gfx::Size surface_size(20, 20); | 3031 gfx::Size surface_size(20, 20); |
3036 gfx::Size viewport_size(10, 10); | 3032 gfx::Size viewport_size(10, 10); |
3037 float page_scale = 2.f; | 3033 float page_scale = 2.f; |
3038 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 3034 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
3039 scoped_ptr<LayerImpl> root_clip = | 3035 scoped_ptr<LayerImpl> root_clip = |
3040 LayerImpl::Create(host_impl_->active_tree(), 2); | 3036 LayerImpl::Create(host_impl_->active_tree(), 2); |
3041 scoped_ptr<LayerImpl> root_scrolling = | 3037 scoped_ptr<LayerImpl> root_scrolling = |
3042 CreateScrollableLayer(3, surface_size, root_clip.get()); | 3038 CreateScrollableLayer(3, surface_size, root_clip.get()); |
3043 EXPECT_EQ(viewport_size, root_clip->bounds()); | 3039 EXPECT_EQ(viewport_size, root_clip->bounds()); |
3044 root_scrolling->SetIsContainerForFixedPositionLayers(true); | 3040 root_scrolling->SetIsContainerForFixedPositionLayers(true); |
3045 root_clip->AddChild(root_scrolling.Pass()); | 3041 root_clip->AddChild(root_scrolling.Pass()); |
3046 root->AddChild(root_clip.Pass()); | 3042 root->AddChild(root_clip.Pass()); |
| 3043 root->SetHasRenderSurface(true); |
3047 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 3044 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
3048 // The behaviour in this test assumes the page scale is applied at a layer | 3045 // The behaviour in this test assumes the page scale is applied at a layer |
3049 // above the clip layer. | 3046 // above the clip layer. |
3050 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3, | 3047 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3, |
3051 Layer::INVALID_ID); | 3048 Layer::INVALID_ID); |
3052 host_impl_->active_tree()->DidBecomeActive(); | 3049 host_impl_->active_tree()->DidBecomeActive(); |
3053 host_impl_->SetViewportSize(viewport_size); | 3050 host_impl_->SetViewportSize(viewport_size); |
3054 DrawFrame(); | 3051 DrawFrame(); |
3055 | 3052 |
3056 LayerImpl* root_scroll = | 3053 LayerImpl* root_scroll = |
(...skipping 30 matching lines...) Expand all Loading... |
3087 float page_scale = 2.f; | 3084 float page_scale = 2.f; |
3088 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 3085 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
3089 scoped_ptr<LayerImpl> root_clip = | 3086 scoped_ptr<LayerImpl> root_clip = |
3090 LayerImpl::Create(host_impl_->active_tree(), 2); | 3087 LayerImpl::Create(host_impl_->active_tree(), 2); |
3091 scoped_ptr<LayerImpl> root_scrolling = | 3088 scoped_ptr<LayerImpl> root_scrolling = |
3092 CreateScrollableLayer(3, surface_size, root_clip.get()); | 3089 CreateScrollableLayer(3, surface_size, root_clip.get()); |
3093 EXPECT_EQ(viewport_size, root_clip->bounds()); | 3090 EXPECT_EQ(viewport_size, root_clip->bounds()); |
3094 root_scrolling->SetIsContainerForFixedPositionLayers(true); | 3091 root_scrolling->SetIsContainerForFixedPositionLayers(true); |
3095 root_clip->AddChild(root_scrolling.Pass()); | 3092 root_clip->AddChild(root_scrolling.Pass()); |
3096 root->AddChild(root_clip.Pass()); | 3093 root->AddChild(root_clip.Pass()); |
| 3094 root->SetHasRenderSurface(true); |
3097 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 3095 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
3098 // The behaviour in this test assumes the page scale is applied at a layer | 3096 // The behaviour in this test assumes the page scale is applied at a layer |
3099 // above the clip layer. | 3097 // above the clip layer. |
3100 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3, | 3098 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3, |
3101 Layer::INVALID_ID); | 3099 Layer::INVALID_ID); |
3102 host_impl_->active_tree()->DidBecomeActive(); | 3100 host_impl_->active_tree()->DidBecomeActive(); |
3103 host_impl_->SetViewportSize(viewport_size); | 3101 host_impl_->SetViewportSize(viewport_size); |
3104 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, page_scale); | 3102 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, page_scale); |
3105 DrawFrame(); | 3103 DrawFrame(); |
3106 | 3104 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3192 EXPECT_EQ(new_page_scale, | 3190 EXPECT_EQ(new_page_scale, |
3193 grand_child->draw_transform().matrix().getDouble(0, 0)); | 3191 grand_child->draw_transform().matrix().getDouble(0, 0)); |
3194 EXPECT_EQ(new_page_scale, | 3192 EXPECT_EQ(new_page_scale, |
3195 grand_child->draw_transform().matrix().getDouble(1, 1)); | 3193 grand_child->draw_transform().matrix().getDouble(1, 1)); |
3196 } | 3194 } |
3197 | 3195 |
3198 TEST_F(LayerTreeHostImplTest, ScrollChildAndChangePageScaleOnMainThread) { | 3196 TEST_F(LayerTreeHostImplTest, ScrollChildAndChangePageScaleOnMainThread) { |
3199 gfx::Size surface_size(30, 30); | 3197 gfx::Size surface_size(30, 30); |
3200 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 3198 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
3201 root->SetBounds(gfx::Size(5, 5)); | 3199 root->SetBounds(gfx::Size(5, 5)); |
| 3200 root->SetHasRenderSurface(true); |
3202 scoped_ptr<LayerImpl> root_scrolling = | 3201 scoped_ptr<LayerImpl> root_scrolling = |
3203 LayerImpl::Create(host_impl_->active_tree(), 2); | 3202 LayerImpl::Create(host_impl_->active_tree(), 2); |
3204 root_scrolling->SetBounds(surface_size); | 3203 root_scrolling->SetBounds(surface_size); |
3205 root_scrolling->SetContentBounds(surface_size); | 3204 root_scrolling->SetContentBounds(surface_size); |
3206 root_scrolling->SetScrollClipLayer(root->id()); | 3205 root_scrolling->SetScrollClipLayer(root->id()); |
3207 root_scrolling->SetIsContainerForFixedPositionLayers(true); | 3206 root_scrolling->SetIsContainerForFixedPositionLayers(true); |
3208 LayerImpl* root_scrolling_ptr = root_scrolling.get(); | 3207 LayerImpl* root_scrolling_ptr = root_scrolling.get(); |
3209 root->AddChild(root_scrolling.Pass()); | 3208 root->AddChild(root_scrolling.Pass()); |
3210 int child_scroll_layer_id = 3; | 3209 int child_scroll_layer_id = 3; |
3211 scoped_ptr<LayerImpl> child_scrolling = CreateScrollableLayer( | 3210 scoped_ptr<LayerImpl> child_scrolling = CreateScrollableLayer( |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3247 } | 3246 } |
3248 | 3247 |
3249 TEST_F(LayerTreeHostImplTest, ScrollChildBeyondLimit) { | 3248 TEST_F(LayerTreeHostImplTest, ScrollChildBeyondLimit) { |
3250 // Scroll a child layer beyond its maximum scroll range and make sure the | 3249 // Scroll a child layer beyond its maximum scroll range and make sure the |
3251 // parent layer is scrolled on the axis on which the child was unable to | 3250 // parent layer is scrolled on the axis on which the child was unable to |
3252 // scroll. | 3251 // scroll. |
3253 gfx::Size surface_size(10, 10); | 3252 gfx::Size surface_size(10, 10); |
3254 gfx::Size content_size(20, 20); | 3253 gfx::Size content_size(20, 20); |
3255 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 3254 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
3256 root->SetBounds(surface_size); | 3255 root->SetBounds(surface_size); |
3257 | 3256 root->SetHasRenderSurface(true); |
3258 scoped_ptr<LayerImpl> grand_child = | 3257 scoped_ptr<LayerImpl> grand_child = |
3259 CreateScrollableLayer(3, content_size, root.get()); | 3258 CreateScrollableLayer(3, content_size, root.get()); |
3260 | 3259 |
3261 scoped_ptr<LayerImpl> child = | 3260 scoped_ptr<LayerImpl> child = |
3262 CreateScrollableLayer(2, content_size, root.get()); | 3261 CreateScrollableLayer(2, content_size, root.get()); |
3263 LayerImpl* grand_child_layer = grand_child.get(); | 3262 LayerImpl* grand_child_layer = grand_child.get(); |
3264 child->AddChild(grand_child.Pass()); | 3263 child->AddChild(grand_child.Pass()); |
3265 | 3264 |
3266 LayerImpl* child_layer = child.get(); | 3265 LayerImpl* child_layer = child.get(); |
3267 root->AddChild(child.Pass()); | 3266 root->AddChild(child.Pass()); |
(...skipping 24 matching lines...) Expand all Loading... |
3292 ExpectContains(*scroll_info.get(), child->id(), gfx::Vector2d(-3, 0)); | 3291 ExpectContains(*scroll_info.get(), child->id(), gfx::Vector2d(-3, 0)); |
3293 } | 3292 } |
3294 } | 3293 } |
3295 | 3294 |
3296 TEST_F(LayerTreeHostImplTest, ScrollWithoutBubbling) { | 3295 TEST_F(LayerTreeHostImplTest, ScrollWithoutBubbling) { |
3297 // Scroll a child layer beyond its maximum scroll range and make sure the | 3296 // Scroll a child layer beyond its maximum scroll range and make sure the |
3298 // the scroll doesn't bubble up to the parent layer. | 3297 // the scroll doesn't bubble up to the parent layer. |
3299 gfx::Size surface_size(20, 20); | 3298 gfx::Size surface_size(20, 20); |
3300 gfx::Size viewport_size(10, 10); | 3299 gfx::Size viewport_size(10, 10); |
3301 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 3300 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 3301 root->SetHasRenderSurface(true); |
3302 scoped_ptr<LayerImpl> root_scrolling = | 3302 scoped_ptr<LayerImpl> root_scrolling = |
3303 CreateScrollableLayer(2, surface_size, root.get()); | 3303 CreateScrollableLayer(2, surface_size, root.get()); |
3304 root_scrolling->SetIsContainerForFixedPositionLayers(true); | 3304 root_scrolling->SetIsContainerForFixedPositionLayers(true); |
3305 | 3305 |
3306 scoped_ptr<LayerImpl> grand_child = | 3306 scoped_ptr<LayerImpl> grand_child = |
3307 CreateScrollableLayer(4, surface_size, root.get()); | 3307 CreateScrollableLayer(4, surface_size, root.get()); |
3308 | 3308 |
3309 scoped_ptr<LayerImpl> child = | 3309 scoped_ptr<LayerImpl> child = |
3310 CreateScrollableLayer(3, surface_size, root.get()); | 3310 CreateScrollableLayer(3, surface_size, root.get()); |
3311 LayerImpl* grand_child_layer = grand_child.get(); | 3311 LayerImpl* grand_child_layer = grand_child.get(); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3401 ExpectContains(*scroll_info.get(), grand_child->id(), gfx::Vector2d(0, 4)); | 3401 ExpectContains(*scroll_info.get(), grand_child->id(), gfx::Vector2d(0, 4)); |
3402 } | 3402 } |
3403 } | 3403 } |
3404 TEST_F(LayerTreeHostImplTest, ScrollEventBubbling) { | 3404 TEST_F(LayerTreeHostImplTest, ScrollEventBubbling) { |
3405 // When we try to scroll a non-scrollable child layer, the scroll delta | 3405 // When we try to scroll a non-scrollable child layer, the scroll delta |
3406 // should be applied to one of its ancestors if possible. | 3406 // should be applied to one of its ancestors if possible. |
3407 gfx::Size surface_size(10, 10); | 3407 gfx::Size surface_size(10, 10); |
3408 gfx::Size content_size(20, 20); | 3408 gfx::Size content_size(20, 20); |
3409 scoped_ptr<LayerImpl> root_clip = | 3409 scoped_ptr<LayerImpl> root_clip = |
3410 LayerImpl::Create(host_impl_->active_tree(), 3); | 3410 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 3411 root_clip->SetHasRenderSurface(true); |
3411 scoped_ptr<LayerImpl> root = | 3412 scoped_ptr<LayerImpl> root = |
3412 CreateScrollableLayer(1, content_size, root_clip.get()); | 3413 CreateScrollableLayer(1, content_size, root_clip.get()); |
3413 // Make 'root' the clip layer for child: since they have the same sizes the | 3414 // Make 'root' the clip layer for child: since they have the same sizes the |
3414 // child will have zero max_scroll_offset and scrolls will bubble. | 3415 // child will have zero max_scroll_offset and scrolls will bubble. |
3415 scoped_ptr<LayerImpl> child = | 3416 scoped_ptr<LayerImpl> child = |
3416 CreateScrollableLayer(2, content_size, root.get()); | 3417 CreateScrollableLayer(2, content_size, root.get()); |
3417 child->SetIsContainerForFixedPositionLayers(true); | 3418 child->SetIsContainerForFixedPositionLayers(true); |
3418 root->SetBounds(content_size); | 3419 root->SetBounds(content_size); |
3419 | 3420 |
3420 int root_scroll_id = root->id(); | 3421 int root_scroll_id = root->id(); |
(...skipping 23 matching lines...) Expand all Loading... |
3444 } | 3445 } |
3445 } | 3446 } |
3446 | 3447 |
3447 TEST_F(LayerTreeHostImplTest, ScrollBeforeRedraw) { | 3448 TEST_F(LayerTreeHostImplTest, ScrollBeforeRedraw) { |
3448 gfx::Size surface_size(10, 10); | 3449 gfx::Size surface_size(10, 10); |
3449 scoped_ptr<LayerImpl> root_clip = | 3450 scoped_ptr<LayerImpl> root_clip = |
3450 LayerImpl::Create(host_impl_->active_tree(), 1); | 3451 LayerImpl::Create(host_impl_->active_tree(), 1); |
3451 scoped_ptr<LayerImpl> root_scroll = | 3452 scoped_ptr<LayerImpl> root_scroll = |
3452 CreateScrollableLayer(2, surface_size, root_clip.get()); | 3453 CreateScrollableLayer(2, surface_size, root_clip.get()); |
3453 root_scroll->SetIsContainerForFixedPositionLayers(true); | 3454 root_scroll->SetIsContainerForFixedPositionLayers(true); |
| 3455 root_clip->SetHasRenderSurface(true); |
3454 root_clip->AddChild(root_scroll.Pass()); | 3456 root_clip->AddChild(root_scroll.Pass()); |
3455 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 3457 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); |
3456 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 2, | 3458 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 2, |
3457 Layer::INVALID_ID); | 3459 Layer::INVALID_ID); |
3458 host_impl_->active_tree()->DidBecomeActive(); | 3460 host_impl_->active_tree()->DidBecomeActive(); |
3459 host_impl_->SetViewportSize(surface_size); | 3461 host_impl_->SetViewportSize(surface_size); |
3460 | 3462 |
3461 // Draw one frame and then immediately rebuild the layer tree to mimic a tree | 3463 // Draw one frame and then immediately rebuild the layer tree to mimic a tree |
3462 // synchronization. | 3464 // synchronization. |
3463 DrawFrame(); | 3465 DrawFrame(); |
3464 host_impl_->active_tree()->DetachLayerTree(); | 3466 host_impl_->active_tree()->DetachLayerTree(); |
3465 scoped_ptr<LayerImpl> root_clip2 = | 3467 scoped_ptr<LayerImpl> root_clip2 = |
3466 LayerImpl::Create(host_impl_->active_tree(), 3); | 3468 LayerImpl::Create(host_impl_->active_tree(), 3); |
3467 scoped_ptr<LayerImpl> root_scroll2 = | 3469 scoped_ptr<LayerImpl> root_scroll2 = |
3468 CreateScrollableLayer(4, surface_size, root_clip2.get()); | 3470 CreateScrollableLayer(4, surface_size, root_clip2.get()); |
3469 root_scroll2->SetIsContainerForFixedPositionLayers(true); | 3471 root_scroll2->SetIsContainerForFixedPositionLayers(true); |
3470 root_clip2->AddChild(root_scroll2.Pass()); | 3472 root_clip2->AddChild(root_scroll2.Pass()); |
| 3473 root_clip2->SetHasRenderSurface(true); |
3471 host_impl_->active_tree()->SetRootLayer(root_clip2.Pass()); | 3474 host_impl_->active_tree()->SetRootLayer(root_clip2.Pass()); |
3472 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 3, 4, | 3475 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 3, 4, |
3473 Layer::INVALID_ID); | 3476 Layer::INVALID_ID); |
3474 host_impl_->active_tree()->DidBecomeActive(); | 3477 host_impl_->active_tree()->DidBecomeActive(); |
3475 | 3478 |
3476 // Scrolling should still work even though we did not draw yet. | 3479 // Scrolling should still work even though we did not draw yet. |
3477 EXPECT_EQ(InputHandler::ScrollStarted, | 3480 EXPECT_EQ(InputHandler::ScrollStarted, |
3478 host_impl_->ScrollBegin(gfx::Point(5, 5), | 3481 host_impl_->ScrollBegin(gfx::Point(5, 5), |
3479 InputHandler::Wheel)); | 3482 InputHandler::Wheel)); |
3480 } | 3483 } |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3975 host_impl_->ScrollEnd(); | 3978 host_impl_->ScrollEnd(); |
3976 } | 3979 } |
3977 | 3980 |
3978 | 3981 |
3979 TEST_F(LayerTreeHostImplTest, OverscrollChildWithoutBubbling) { | 3982 TEST_F(LayerTreeHostImplTest, OverscrollChildWithoutBubbling) { |
3980 // Scroll child layers beyond their maximum scroll range and make sure root | 3983 // Scroll child layers beyond their maximum scroll range and make sure root |
3981 // overscroll does not accumulate. | 3984 // overscroll does not accumulate. |
3982 gfx::Size surface_size(10, 10); | 3985 gfx::Size surface_size(10, 10); |
3983 scoped_ptr<LayerImpl> root_clip = | 3986 scoped_ptr<LayerImpl> root_clip = |
3984 LayerImpl::Create(host_impl_->active_tree(), 4); | 3987 LayerImpl::Create(host_impl_->active_tree(), 4); |
| 3988 root_clip->SetHasRenderSurface(true); |
| 3989 |
3985 scoped_ptr<LayerImpl> root = | 3990 scoped_ptr<LayerImpl> root = |
3986 CreateScrollableLayer(1, surface_size, root_clip.get()); | 3991 CreateScrollableLayer(1, surface_size, root_clip.get()); |
3987 | 3992 |
3988 scoped_ptr<LayerImpl> grand_child = | 3993 scoped_ptr<LayerImpl> grand_child = |
3989 CreateScrollableLayer(3, surface_size, root_clip.get()); | 3994 CreateScrollableLayer(3, surface_size, root_clip.get()); |
3990 | 3995 |
3991 scoped_ptr<LayerImpl> child = | 3996 scoped_ptr<LayerImpl> child = |
3992 CreateScrollableLayer(2, surface_size, root_clip.get()); | 3997 CreateScrollableLayer(2, surface_size, root_clip.get()); |
3993 LayerImpl* grand_child_layer = grand_child.get(); | 3998 LayerImpl* grand_child_layer = grand_child.get(); |
3994 child->AddChild(grand_child.Pass()); | 3999 child->AddChild(grand_child.Pass()); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4039 } | 4044 } |
4040 | 4045 |
4041 TEST_F(LayerTreeHostImplTest, OverscrollChildEventBubbling) { | 4046 TEST_F(LayerTreeHostImplTest, OverscrollChildEventBubbling) { |
4042 // When we try to scroll a non-scrollable child layer, the scroll delta | 4047 // When we try to scroll a non-scrollable child layer, the scroll delta |
4043 // should be applied to one of its ancestors if possible. Overscroll should | 4048 // should be applied to one of its ancestors if possible. Overscroll should |
4044 // be reflected only when it has bubbled up to the root scrolling layer. | 4049 // be reflected only when it has bubbled up to the root scrolling layer. |
4045 gfx::Size surface_size(10, 10); | 4050 gfx::Size surface_size(10, 10); |
4046 gfx::Size content_size(20, 20); | 4051 gfx::Size content_size(20, 20); |
4047 scoped_ptr<LayerImpl> root_clip = | 4052 scoped_ptr<LayerImpl> root_clip = |
4048 LayerImpl::Create(host_impl_->active_tree(), 3); | 4053 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 4054 root_clip->SetHasRenderSurface(true); |
| 4055 |
4049 scoped_ptr<LayerImpl> root = | 4056 scoped_ptr<LayerImpl> root = |
4050 CreateScrollableLayer(1, content_size, root_clip.get()); | 4057 CreateScrollableLayer(1, content_size, root_clip.get()); |
4051 root->SetIsContainerForFixedPositionLayers(true); | 4058 root->SetIsContainerForFixedPositionLayers(true); |
4052 scoped_ptr<LayerImpl> child = | 4059 scoped_ptr<LayerImpl> child = |
4053 CreateScrollableLayer(2, content_size, root_clip.get()); | 4060 CreateScrollableLayer(2, content_size, root_clip.get()); |
4054 | 4061 |
4055 child->SetScrollClipLayer(Layer::INVALID_ID); | 4062 child->SetScrollClipLayer(Layer::INVALID_ID); |
4056 root->AddChild(child.Pass()); | 4063 root->AddChild(child.Pass()); |
4057 root_clip->AddChild(root.Pass()); | 4064 root_clip->AddChild(root.Pass()); |
4058 | 4065 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4095 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 4102 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
4096 EXPECT_EQ(gfx::Vector2dF(0, 10), host_impl_->accumulated_root_overscroll()); | 4103 EXPECT_EQ(gfx::Vector2dF(0, 10), host_impl_->accumulated_root_overscroll()); |
4097 } | 4104 } |
4098 | 4105 |
4099 TEST_F(LayerTreeHostImplTest, NoOverscrollOnFractionalDeviceScale) { | 4106 TEST_F(LayerTreeHostImplTest, NoOverscrollOnFractionalDeviceScale) { |
4100 gfx::Size surface_size(980, 1439); | 4107 gfx::Size surface_size(980, 1439); |
4101 gfx::Size content_size(980, 1438); | 4108 gfx::Size content_size(980, 1438); |
4102 float device_scale_factor = 1.5f; | 4109 float device_scale_factor = 1.5f; |
4103 scoped_ptr<LayerImpl> root_clip = | 4110 scoped_ptr<LayerImpl> root_clip = |
4104 LayerImpl::Create(host_impl_->active_tree(), 3); | 4111 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 4112 root_clip->SetHasRenderSurface(true); |
| 4113 |
4105 scoped_ptr<LayerImpl> root = | 4114 scoped_ptr<LayerImpl> root = |
4106 CreateScrollableLayer(1, content_size, root_clip.get()); | 4115 CreateScrollableLayer(1, content_size, root_clip.get()); |
4107 root->SetIsContainerForFixedPositionLayers(true); | 4116 root->SetIsContainerForFixedPositionLayers(true); |
4108 scoped_ptr<LayerImpl> child = | 4117 scoped_ptr<LayerImpl> child = |
4109 CreateScrollableLayer(2, content_size, root_clip.get()); | 4118 CreateScrollableLayer(2, content_size, root_clip.get()); |
4110 root->scroll_clip_layer()->SetBounds(gfx::Size(320, 469)); | 4119 root->scroll_clip_layer()->SetBounds(gfx::Size(320, 469)); |
4111 host_impl_->active_tree()->PushPageScaleFromMainThread(0.326531f, 0.326531f, | 4120 host_impl_->active_tree()->PushPageScaleFromMainThread(0.326531f, 0.326531f, |
4112 5.f); | 4121 5.f); |
4113 host_impl_->SetPageScaleOnActiveTree(0.326531f); | 4122 host_impl_->SetPageScaleOnActiveTree(0.326531f); |
4114 child->SetScrollClipLayer(Layer::INVALID_ID); | 4123 child->SetScrollClipLayer(Layer::INVALID_ID); |
(...skipping 19 matching lines...) Expand all Loading... |
4134 | 4143 |
4135 host_impl_->ScrollEnd(); | 4144 host_impl_->ScrollEnd(); |
4136 } | 4145 } |
4137 } | 4146 } |
4138 | 4147 |
4139 TEST_F(LayerTreeHostImplTest, NoOverscrollWhenNotAtEdge) { | 4148 TEST_F(LayerTreeHostImplTest, NoOverscrollWhenNotAtEdge) { |
4140 gfx::Size surface_size(100, 100); | 4149 gfx::Size surface_size(100, 100); |
4141 gfx::Size content_size(200, 200); | 4150 gfx::Size content_size(200, 200); |
4142 scoped_ptr<LayerImpl> root_clip = | 4151 scoped_ptr<LayerImpl> root_clip = |
4143 LayerImpl::Create(host_impl_->active_tree(), 3); | 4152 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 4153 root_clip->SetHasRenderSurface(true); |
| 4154 |
4144 scoped_ptr<LayerImpl> root = | 4155 scoped_ptr<LayerImpl> root = |
4145 CreateScrollableLayer(1, content_size, root_clip.get()); | 4156 CreateScrollableLayer(1, content_size, root_clip.get()); |
4146 root->SetIsContainerForFixedPositionLayers(true); | 4157 root->SetIsContainerForFixedPositionLayers(true); |
4147 scoped_ptr<LayerImpl> child = | 4158 scoped_ptr<LayerImpl> child = |
4148 CreateScrollableLayer(2, content_size, root_clip.get()); | 4159 CreateScrollableLayer(2, content_size, root_clip.get()); |
4149 | 4160 |
4150 child->SetScrollClipLayer(Layer::INVALID_ID); | 4161 child->SetScrollClipLayer(Layer::INVALID_ID); |
4151 root->AddChild(child.Pass()); | 4162 root->AddChild(child.Pass()); |
4152 root_clip->AddChild(root.Pass()); | 4163 root_clip->AddChild(root.Pass()); |
4153 | 4164 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4280 ResourceProvider::ResourceId resource_id_; | 4291 ResourceProvider::ResourceId resource_id_; |
4281 }; | 4292 }; |
4282 | 4293 |
4283 TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { | 4294 TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { |
4284 { | 4295 { |
4285 scoped_ptr<LayerImpl> root = | 4296 scoped_ptr<LayerImpl> root = |
4286 LayerImpl::Create(host_impl_->active_tree(), 1); | 4297 LayerImpl::Create(host_impl_->active_tree(), 1); |
4287 root->SetBounds(gfx::Size(10, 10)); | 4298 root->SetBounds(gfx::Size(10, 10)); |
4288 root->SetContentBounds(root->bounds()); | 4299 root->SetContentBounds(root->bounds()); |
4289 root->SetDrawsContent(false); | 4300 root->SetDrawsContent(false); |
| 4301 root->SetHasRenderSurface(true); |
4290 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 4302 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
4291 } | 4303 } |
4292 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 4304 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
4293 | 4305 |
4294 root->AddChild( | 4306 root->AddChild( |
4295 BlendStateCheckLayer::Create(host_impl_->active_tree(), | 4307 BlendStateCheckLayer::Create(host_impl_->active_tree(), |
4296 2, | 4308 2, |
4297 host_impl_->resource_provider())); | 4309 host_impl_->resource_provider())); |
4298 BlendStateCheckLayer* layer1 = | 4310 BlendStateCheckLayer* layer1 = |
4299 static_cast<BlendStateCheckLayer*>(root->children()[0]); | 4311 static_cast<BlendStateCheckLayer*>(root->children()[0]); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4389 EXPECT_TRUE(layer2->quads_appended()); | 4401 EXPECT_TRUE(layer2->quads_appended()); |
4390 host_impl_->DidDrawAllLayers(frame); | 4402 host_impl_->DidDrawAllLayers(frame); |
4391 | 4403 |
4392 // Parent layer with translucent opacity and opaque content. Since it has a | 4404 // Parent layer with translucent opacity and opaque content. Since it has a |
4393 // drawing child, it's drawn to a render surface which carries the opacity, | 4405 // drawing child, it's drawn to a render surface which carries the opacity, |
4394 // so it's itself drawn without blending. | 4406 // so it's itself drawn without blending. |
4395 // Child layer with opaque content, drawn without blending (parent surface | 4407 // Child layer with opaque content, drawn without blending (parent surface |
4396 // carries the inherited opacity). | 4408 // carries the inherited opacity). |
4397 layer1->SetContentsOpaque(true); | 4409 layer1->SetContentsOpaque(true); |
4398 layer1->SetOpacity(0.5f); | 4410 layer1->SetOpacity(0.5f); |
| 4411 layer1->SetHasRenderSurface(true); |
4399 layer1->SetExpectation(false, true); | 4412 layer1->SetExpectation(false, true); |
4400 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); | 4413 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); |
4401 layer2->SetExpectation(false, false); | 4414 layer2->SetExpectation(false, false); |
4402 layer2->SetUpdateRect(gfx::Rect(layer1->content_bounds())); | 4415 layer2->SetUpdateRect(gfx::Rect(layer1->content_bounds())); |
4403 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( | 4416 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( |
4404 host_impl_->active_tree()->root_layer()); | 4417 host_impl_->active_tree()->root_layer()); |
4405 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4418 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
4406 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 4419 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
4407 EXPECT_TRUE(layer1->quads_appended()); | 4420 EXPECT_TRUE(layer1->quads_appended()); |
4408 EXPECT_TRUE(layer2->quads_appended()); | 4421 EXPECT_TRUE(layer2->quads_appended()); |
4409 host_impl_->DidDrawAllLayers(frame); | 4422 host_impl_->DidDrawAllLayers(frame); |
| 4423 layer1->SetHasRenderSurface(false); |
4410 | 4424 |
4411 // Draw again, but with child non-opaque, to make sure | 4425 // Draw again, but with child non-opaque, to make sure |
4412 // layer1 not culled. | 4426 // layer1 not culled. |
4413 layer1->SetContentsOpaque(true); | 4427 layer1->SetContentsOpaque(true); |
4414 layer1->SetOpacity(1.f); | 4428 layer1->SetOpacity(1.f); |
4415 layer1->SetExpectation(false, false); | 4429 layer1->SetExpectation(false, false); |
4416 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); | 4430 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); |
4417 layer2->SetContentsOpaque(true); | 4431 layer2->SetContentsOpaque(true); |
4418 layer2->SetOpacity(0.5f); | 4432 layer2->SetOpacity(0.5f); |
4419 layer2->SetExpectation(true, false); | 4433 layer2->SetExpectation(true, false); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4516 if (always_draw) { | 4530 if (always_draw) { |
4517 return FakeOutputSurface::CreateAlwaysDrawAndSwap3d(); | 4531 return FakeOutputSurface::CreateAlwaysDrawAndSwap3d(); |
4518 } | 4532 } |
4519 return FakeOutputSurface::Create3d(); | 4533 return FakeOutputSurface::Create3d(); |
4520 } | 4534 } |
4521 | 4535 |
4522 void SetupActiveTreeLayers() { | 4536 void SetupActiveTreeLayers() { |
4523 host_impl_->active_tree()->set_background_color(SK_ColorGRAY); | 4537 host_impl_->active_tree()->set_background_color(SK_ColorGRAY); |
4524 host_impl_->active_tree()->SetRootLayer( | 4538 host_impl_->active_tree()->SetRootLayer( |
4525 LayerImpl::Create(host_impl_->active_tree(), 1)); | 4539 LayerImpl::Create(host_impl_->active_tree(), 1)); |
| 4540 host_impl_->active_tree()->root_layer()->SetHasRenderSurface(true); |
4526 host_impl_->active_tree()->root_layer()->AddChild( | 4541 host_impl_->active_tree()->root_layer()->AddChild( |
4527 BlendStateCheckLayer::Create(host_impl_->active_tree(), | 4542 BlendStateCheckLayer::Create(host_impl_->active_tree(), |
4528 2, | 4543 2, |
4529 host_impl_->resource_provider())); | 4544 host_impl_->resource_provider())); |
4530 child_ = static_cast<BlendStateCheckLayer*>( | 4545 child_ = static_cast<BlendStateCheckLayer*>( |
4531 host_impl_->active_tree()->root_layer()->children()[0]); | 4546 host_impl_->active_tree()->root_layer()->children()[0]); |
4532 child_->SetExpectation(false, false); | 4547 child_->SetExpectation(false, false); |
4533 child_->SetContentsOpaque(true); | 4548 child_->SetContentsOpaque(true); |
4534 } | 4549 } |
4535 | 4550 |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4806 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); | 4821 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); |
4807 scoped_ptr<OutputSurface> output_surface( | 4822 scoped_ptr<OutputSurface> output_surface( |
4808 FakeOutputSurface::Create3d(provider)); | 4823 FakeOutputSurface::Create3d(provider)); |
4809 CreateHostImpl(DefaultSettings(), output_surface.Pass()); | 4824 CreateHostImpl(DefaultSettings(), output_surface.Pass()); |
4810 | 4825 |
4811 scoped_ptr<LayerImpl> root = | 4826 scoped_ptr<LayerImpl> root = |
4812 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); | 4827 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); |
4813 root->SetBounds(gfx::Size(10, 10)); | 4828 root->SetBounds(gfx::Size(10, 10)); |
4814 root->SetContentBounds(gfx::Size(10, 10)); | 4829 root->SetContentBounds(gfx::Size(10, 10)); |
4815 root->SetDrawsContent(true); | 4830 root->SetDrawsContent(true); |
| 4831 root->SetHasRenderSurface(true); |
4816 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 4832 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
4817 EXPECT_FALSE(provider->TestContext3d()->reshape_called()); | 4833 EXPECT_FALSE(provider->TestContext3d()->reshape_called()); |
4818 provider->TestContext3d()->clear_reshape_called(); | 4834 provider->TestContext3d()->clear_reshape_called(); |
4819 | 4835 |
4820 LayerTreeHostImpl::FrameData frame; | 4836 LayerTreeHostImpl::FrameData frame; |
4821 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 4837 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
4822 host_impl_->SetDeviceScaleFactor(1.f); | 4838 host_impl_->SetDeviceScaleFactor(1.f); |
4823 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4839 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
4824 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 4840 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
4825 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); | 4841 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4874 &proxy_, | 4890 &proxy_, |
4875 &stats_instrumentation_, | 4891 &stats_instrumentation_, |
4876 shared_bitmap_manager.get(), | 4892 shared_bitmap_manager.get(), |
4877 NULL, | 4893 NULL, |
4878 0); | 4894 0); |
4879 layer_tree_host_impl->InitializeRenderer(output_surface.Pass()); | 4895 layer_tree_host_impl->InitializeRenderer(output_surface.Pass()); |
4880 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); | 4896 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); |
4881 | 4897 |
4882 scoped_ptr<LayerImpl> root = | 4898 scoped_ptr<LayerImpl> root = |
4883 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); | 4899 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); |
| 4900 root->SetHasRenderSurface(true); |
4884 scoped_ptr<LayerImpl> child = | 4901 scoped_ptr<LayerImpl> child = |
4885 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); | 4902 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); |
4886 child->SetPosition(gfx::PointF(12.f, 13.f)); | 4903 child->SetPosition(gfx::PointF(12.f, 13.f)); |
4887 child->SetBounds(gfx::Size(14, 15)); | 4904 child->SetBounds(gfx::Size(14, 15)); |
4888 child->SetContentBounds(gfx::Size(14, 15)); | 4905 child->SetContentBounds(gfx::Size(14, 15)); |
4889 child->SetDrawsContent(true); | 4906 child->SetDrawsContent(true); |
4890 root->SetBounds(gfx::Size(500, 500)); | 4907 root->SetBounds(gfx::Size(500, 500)); |
4891 root->SetContentBounds(gfx::Size(500, 500)); | 4908 root->SetContentBounds(gfx::Size(500, 500)); |
4892 root->SetDrawsContent(true); | 4909 root->SetDrawsContent(true); |
4893 root->AddChild(child.Pass()); | 4910 root->AddChild(child.Pass()); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4940 scoped_ptr<LayerImpl> root = | 4957 scoped_ptr<LayerImpl> root = |
4941 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); | 4958 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); |
4942 scoped_ptr<LayerImpl> child = | 4959 scoped_ptr<LayerImpl> child = |
4943 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2); | 4960 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2); |
4944 child->SetBounds(gfx::Size(10, 10)); | 4961 child->SetBounds(gfx::Size(10, 10)); |
4945 child->SetContentBounds(gfx::Size(10, 10)); | 4962 child->SetContentBounds(gfx::Size(10, 10)); |
4946 child->SetDrawsContent(true); | 4963 child->SetDrawsContent(true); |
4947 root->SetBounds(gfx::Size(10, 10)); | 4964 root->SetBounds(gfx::Size(10, 10)); |
4948 root->SetContentBounds(gfx::Size(10, 10)); | 4965 root->SetContentBounds(gfx::Size(10, 10)); |
4949 root->SetDrawsContent(true); | 4966 root->SetDrawsContent(true); |
4950 root->SetForceRenderSurface(true); | 4967 root->SetHasRenderSurface(true); |
4951 root->AddChild(child.Pass()); | 4968 root->AddChild(child.Pass()); |
4952 | 4969 |
4953 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 4970 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
4954 | 4971 |
4955 LayerTreeHostImpl::FrameData frame; | 4972 LayerTreeHostImpl::FrameData frame; |
4956 | 4973 |
4957 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4974 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
4958 EXPECT_EQ(1u, frame.render_surface_layer_list->size()); | 4975 EXPECT_EQ(1u, frame.render_surface_layer_list->size()); |
4959 EXPECT_EQ(1u, frame.render_passes.size()); | 4976 EXPECT_EQ(1u, frame.render_passes.size()); |
4960 host_impl_->DidDrawAllLayers(frame); | 4977 host_impl_->DidDrawAllLayers(frame); |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5189 LayerImpl::Create(my_host_impl->active_tree(), 1); | 5206 LayerImpl::Create(my_host_impl->active_tree(), 1); |
5190 scoped_ptr<LayerImpl> child = | 5207 scoped_ptr<LayerImpl> child = |
5191 LayerImpl::Create(my_host_impl->active_tree(), 2); | 5208 LayerImpl::Create(my_host_impl->active_tree(), 2); |
5192 scoped_ptr<LayerImpl> grand_child = | 5209 scoped_ptr<LayerImpl> grand_child = |
5193 FakeLayerWithQuads::Create(my_host_impl->active_tree(), 3); | 5210 FakeLayerWithQuads::Create(my_host_impl->active_tree(), 3); |
5194 | 5211 |
5195 gfx::Rect root_rect(0, 0, 100, 100); | 5212 gfx::Rect root_rect(0, 0, 100, 100); |
5196 gfx::Rect child_rect(10, 10, 50, 50); | 5213 gfx::Rect child_rect(10, 10, 50, 50); |
5197 gfx::Rect grand_child_rect(5, 5, 150, 150); | 5214 gfx::Rect grand_child_rect(5, 5, 150, 150); |
5198 | 5215 |
5199 root->CreateRenderSurface(); | 5216 root->SetHasRenderSurface(true); |
5200 root->SetPosition(root_rect.origin()); | 5217 root->SetPosition(root_rect.origin()); |
5201 root->SetBounds(root_rect.size()); | 5218 root->SetBounds(root_rect.size()); |
5202 root->SetContentBounds(root->bounds()); | 5219 root->SetContentBounds(root->bounds()); |
5203 root->draw_properties().visible_content_rect = root_rect; | 5220 root->draw_properties().visible_content_rect = root_rect; |
5204 root->SetDrawsContent(false); | 5221 root->SetDrawsContent(false); |
5205 root->render_surface()->SetContentRect(gfx::Rect(root_rect.size())); | 5222 root->render_surface()->SetContentRect(gfx::Rect(root_rect.size())); |
5206 | 5223 |
5207 child->SetPosition(gfx::PointF(child_rect.x(), child_rect.y())); | 5224 child->SetPosition(gfx::PointF(child_rect.x(), child_rect.y())); |
5208 child->SetOpacity(0.5f); | 5225 child->SetOpacity(0.5f); |
5209 child->SetBounds(gfx::Size(child_rect.width(), child_rect.height())); | 5226 child->SetBounds(gfx::Size(child_rect.width(), child_rect.height())); |
5210 child->SetContentBounds(child->bounds()); | 5227 child->SetContentBounds(child->bounds()); |
5211 child->draw_properties().visible_content_rect = child_rect; | 5228 child->draw_properties().visible_content_rect = child_rect; |
5212 child->SetDrawsContent(false); | 5229 child->SetDrawsContent(false); |
5213 child->SetForceRenderSurface(true); | 5230 child->SetHasRenderSurface(true); |
5214 | 5231 |
5215 grand_child->SetPosition(grand_child_rect.origin()); | 5232 grand_child->SetPosition(grand_child_rect.origin()); |
5216 grand_child->SetBounds(grand_child_rect.size()); | 5233 grand_child->SetBounds(grand_child_rect.size()); |
5217 grand_child->SetContentBounds(grand_child->bounds()); | 5234 grand_child->SetContentBounds(grand_child->bounds()); |
5218 grand_child->draw_properties().visible_content_rect = grand_child_rect; | 5235 grand_child->draw_properties().visible_content_rect = grand_child_rect; |
5219 grand_child->SetDrawsContent(true); | 5236 grand_child->SetDrawsContent(true); |
5220 | 5237 |
5221 child->AddChild(grand_child.Pass()); | 5238 child->AddChild(grand_child.Pass()); |
5222 root->AddChild(child.Pass()); | 5239 root->AddChild(child.Pass()); |
5223 | 5240 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5283 scoped_ptr<TestWebGraphicsContext3D> context = | 5300 scoped_ptr<TestWebGraphicsContext3D> context = |
5284 TestWebGraphicsContext3D::Create(); | 5301 TestWebGraphicsContext3D::Create(); |
5285 TestWebGraphicsContext3D* context3d = context.get(); | 5302 TestWebGraphicsContext3D* context3d = context.get(); |
5286 scoped_ptr<OutputSurface> output_surface( | 5303 scoped_ptr<OutputSurface> output_surface( |
5287 FakeOutputSurface::Create3d(context.Pass())); | 5304 FakeOutputSurface::Create3d(context.Pass())); |
5288 CreateHostImpl(DefaultSettings(), output_surface.Pass()); | 5305 CreateHostImpl(DefaultSettings(), output_surface.Pass()); |
5289 | 5306 |
5290 scoped_ptr<LayerImpl> root_layer = | 5307 scoped_ptr<LayerImpl> root_layer = |
5291 LayerImpl::Create(host_impl_->active_tree(), 1); | 5308 LayerImpl::Create(host_impl_->active_tree(), 1); |
5292 root_layer->SetBounds(gfx::Size(10, 10)); | 5309 root_layer->SetBounds(gfx::Size(10, 10)); |
| 5310 root_layer->SetHasRenderSurface(true); |
5293 | 5311 |
5294 scoped_ptr<IOSurfaceLayerImpl> io_surface_layer = | 5312 scoped_ptr<IOSurfaceLayerImpl> io_surface_layer = |
5295 IOSurfaceLayerImpl::Create(host_impl_->active_tree(), 5); | 5313 IOSurfaceLayerImpl::Create(host_impl_->active_tree(), 5); |
5296 io_surface_layer->SetBounds(gfx::Size(10, 10)); | 5314 io_surface_layer->SetBounds(gfx::Size(10, 10)); |
5297 io_surface_layer->SetContentBounds(gfx::Size(10, 10)); | 5315 io_surface_layer->SetContentBounds(gfx::Size(10, 10)); |
5298 io_surface_layer->SetDrawsContent(true); | 5316 io_surface_layer->SetDrawsContent(true); |
5299 io_surface_layer->SetIOSurfaceProperties(1, gfx::Size(10, 10)); | 5317 io_surface_layer->SetIOSurfaceProperties(1, gfx::Size(10, 10)); |
5300 root_layer->AddChild(io_surface_layer.Pass()); | 5318 root_layer->AddChild(io_surface_layer.Pass()); |
5301 | 5319 |
5302 host_impl_->active_tree()->SetRootLayer(root_layer.Pass()); | 5320 host_impl_->active_tree()->SetRootLayer(root_layer.Pass()); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5445 } | 5463 } |
5446 }; | 5464 }; |
5447 | 5465 |
5448 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) { | 5466 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) { |
5449 scoped_ptr<SolidColorLayerImpl> root = | 5467 scoped_ptr<SolidColorLayerImpl> root = |
5450 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 5468 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
5451 root->SetPosition(gfx::PointF()); | 5469 root->SetPosition(gfx::PointF()); |
5452 root->SetBounds(gfx::Size(10, 10)); | 5470 root->SetBounds(gfx::Size(10, 10)); |
5453 root->SetContentBounds(gfx::Size(10, 10)); | 5471 root->SetContentBounds(gfx::Size(10, 10)); |
5454 root->SetDrawsContent(true); | 5472 root->SetDrawsContent(true); |
| 5473 root->SetHasRenderSurface(true); |
5455 | 5474 |
5456 // Child layer is in the bottom right corner. | 5475 // Child layer is in the bottom right corner. |
5457 scoped_ptr<SolidColorLayerImpl> child = | 5476 scoped_ptr<SolidColorLayerImpl> child = |
5458 SolidColorLayerImpl::Create(host_impl_->active_tree(), 2); | 5477 SolidColorLayerImpl::Create(host_impl_->active_tree(), 2); |
5459 child->SetPosition(gfx::PointF(9.f, 9.f)); | 5478 child->SetPosition(gfx::PointF(9.f, 9.f)); |
5460 child->SetBounds(gfx::Size(1, 1)); | 5479 child->SetBounds(gfx::Size(1, 1)); |
5461 child->SetContentBounds(gfx::Size(1, 1)); | 5480 child->SetContentBounds(gfx::Size(1, 1)); |
5462 child->SetDrawsContent(true); | 5481 child->SetDrawsContent(true); |
5463 root->AddChild(child.Pass()); | 5482 root->AddChild(child.Pass()); |
5464 | 5483 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5511 | 5530 |
5512 // Root | 5531 // Root |
5513 // | | 5532 // | |
5514 // +-- Scaling Layer (adds a 2x scale) | 5533 // +-- Scaling Layer (adds a 2x scale) |
5515 // | | 5534 // | |
5516 // +-- Content Layer | 5535 // +-- Content Layer |
5517 // +--Mask | 5536 // +--Mask |
5518 scoped_ptr<LayerImpl> scoped_root = | 5537 scoped_ptr<LayerImpl> scoped_root = |
5519 LayerImpl::Create(host_impl_->active_tree(), 1); | 5538 LayerImpl::Create(host_impl_->active_tree(), 1); |
5520 LayerImpl* root = scoped_root.get(); | 5539 LayerImpl* root = scoped_root.get(); |
| 5540 root->SetHasRenderSurface(true); |
5521 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); | 5541 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); |
5522 | 5542 |
5523 scoped_ptr<LayerImpl> scoped_scaling_layer = | 5543 scoped_ptr<LayerImpl> scoped_scaling_layer = |
5524 LayerImpl::Create(host_impl_->active_tree(), 2); | 5544 LayerImpl::Create(host_impl_->active_tree(), 2); |
5525 LayerImpl* scaling_layer = scoped_scaling_layer.get(); | 5545 LayerImpl* scaling_layer = scoped_scaling_layer.get(); |
5526 root->AddChild(scoped_scaling_layer.Pass()); | 5546 root->AddChild(scoped_scaling_layer.Pass()); |
5527 | 5547 |
5528 scoped_ptr<LayerImpl> scoped_content_layer = | 5548 scoped_ptr<LayerImpl> scoped_content_layer = |
5529 LayerImpl::Create(host_impl_->active_tree(), 3); | 5549 LayerImpl::Create(host_impl_->active_tree(), 3); |
5530 LayerImpl* content_layer = scoped_content_layer.get(); | 5550 LayerImpl* content_layer = scoped_content_layer.get(); |
5531 scaling_layer->AddChild(scoped_content_layer.Pass()); | 5551 scaling_layer->AddChild(scoped_content_layer.Pass()); |
5532 | 5552 |
5533 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = | 5553 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = |
5534 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); | 5554 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); |
5535 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); | 5555 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); |
| 5556 content_layer->SetHasRenderSurface(true); |
5536 content_layer->SetMaskLayer(scoped_mask_layer.Pass()); | 5557 content_layer->SetMaskLayer(scoped_mask_layer.Pass()); |
5537 | 5558 |
5538 gfx::Size root_size(100, 100); | 5559 gfx::Size root_size(100, 100); |
5539 root->SetBounds(root_size); | 5560 root->SetBounds(root_size); |
5540 root->SetContentBounds(root_size); | 5561 root->SetContentBounds(root_size); |
5541 root->SetPosition(gfx::PointF()); | 5562 root->SetPosition(gfx::PointF()); |
5542 | 5563 |
5543 gfx::Size scaling_layer_size(50, 50); | 5564 gfx::Size scaling_layer_size(50, 50); |
5544 scaling_layer->SetBounds(scaling_layer_size); | 5565 scaling_layer->SetBounds(scaling_layer_size); |
5545 scaling_layer->SetContentBounds(scaling_layer_size); | 5566 scaling_layer->SetContentBounds(scaling_layer_size); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5651 } | 5672 } |
5652 } | 5673 } |
5653 | 5674 |
5654 TEST_F(LayerTreeHostImplTest, MaskLayerWithDifferentBounds) { | 5675 TEST_F(LayerTreeHostImplTest, MaskLayerWithDifferentBounds) { |
5655 // The mask layer has bounds 100x100 but is attached to a layer with bounds | 5676 // The mask layer has bounds 100x100 but is attached to a layer with bounds |
5656 // 50x50. | 5677 // 50x50. |
5657 | 5678 |
5658 scoped_ptr<LayerImpl> scoped_root = | 5679 scoped_ptr<LayerImpl> scoped_root = |
5659 LayerImpl::Create(host_impl_->active_tree(), 1); | 5680 LayerImpl::Create(host_impl_->active_tree(), 1); |
5660 LayerImpl* root = scoped_root.get(); | 5681 LayerImpl* root = scoped_root.get(); |
| 5682 root->SetHasRenderSurface(true); |
| 5683 |
5661 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); | 5684 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); |
5662 | 5685 |
5663 scoped_ptr<LayerImpl> scoped_content_layer = | 5686 scoped_ptr<LayerImpl> scoped_content_layer = |
5664 LayerImpl::Create(host_impl_->active_tree(), 3); | 5687 LayerImpl::Create(host_impl_->active_tree(), 3); |
5665 LayerImpl* content_layer = scoped_content_layer.get(); | 5688 LayerImpl* content_layer = scoped_content_layer.get(); |
5666 root->AddChild(scoped_content_layer.Pass()); | 5689 root->AddChild(scoped_content_layer.Pass()); |
5667 | 5690 |
5668 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = | 5691 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = |
5669 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); | 5692 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); |
5670 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); | 5693 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); |
5671 content_layer->SetMaskLayer(scoped_mask_layer.Pass()); | 5694 content_layer->SetMaskLayer(scoped_mask_layer.Pass()); |
| 5695 content_layer->SetHasRenderSurface(true); |
5672 | 5696 |
5673 gfx::Size root_size(100, 100); | 5697 gfx::Size root_size(100, 100); |
5674 root->SetBounds(root_size); | 5698 root->SetBounds(root_size); |
5675 root->SetContentBounds(root_size); | 5699 root->SetContentBounds(root_size); |
5676 root->SetPosition(gfx::PointF()); | 5700 root->SetPosition(gfx::PointF()); |
5677 | 5701 |
5678 gfx::Size layer_size(50, 50); | 5702 gfx::Size layer_size(50, 50); |
5679 content_layer->SetBounds(layer_size); | 5703 content_layer->SetBounds(layer_size); |
5680 content_layer->SetContentBounds(layer_size); | 5704 content_layer->SetContentBounds(layer_size); |
5681 content_layer->SetPosition(gfx::PointF()); | 5705 content_layer->SetPosition(gfx::PointF()); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5805 } | 5829 } |
5806 } | 5830 } |
5807 | 5831 |
5808 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerWithDifferentBounds) { | 5832 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerWithDifferentBounds) { |
5809 // The replica's mask layer has bounds 100x100 but the replica is of a | 5833 // The replica's mask layer has bounds 100x100 but the replica is of a |
5810 // layer with bounds 50x50. | 5834 // layer with bounds 50x50. |
5811 | 5835 |
5812 scoped_ptr<LayerImpl> scoped_root = | 5836 scoped_ptr<LayerImpl> scoped_root = |
5813 LayerImpl::Create(host_impl_->active_tree(), 1); | 5837 LayerImpl::Create(host_impl_->active_tree(), 1); |
5814 LayerImpl* root = scoped_root.get(); | 5838 LayerImpl* root = scoped_root.get(); |
| 5839 root->SetHasRenderSurface(true); |
| 5840 |
5815 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); | 5841 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); |
5816 | 5842 |
5817 scoped_ptr<LayerImpl> scoped_content_layer = | 5843 scoped_ptr<LayerImpl> scoped_content_layer = |
5818 LayerImpl::Create(host_impl_->active_tree(), 3); | 5844 LayerImpl::Create(host_impl_->active_tree(), 3); |
5819 LayerImpl* content_layer = scoped_content_layer.get(); | 5845 LayerImpl* content_layer = scoped_content_layer.get(); |
5820 root->AddChild(scoped_content_layer.Pass()); | 5846 root->AddChild(scoped_content_layer.Pass()); |
5821 | 5847 |
5822 scoped_ptr<LayerImpl> scoped_replica_layer = | 5848 scoped_ptr<LayerImpl> scoped_replica_layer = |
5823 LayerImpl::Create(host_impl_->active_tree(), 2); | 5849 LayerImpl::Create(host_impl_->active_tree(), 2); |
5824 LayerImpl* replica_layer = scoped_replica_layer.get(); | 5850 LayerImpl* replica_layer = scoped_replica_layer.get(); |
5825 content_layer->SetReplicaLayer(scoped_replica_layer.Pass()); | 5851 content_layer->SetReplicaLayer(scoped_replica_layer.Pass()); |
| 5852 content_layer->SetHasRenderSurface(true); |
5826 | 5853 |
5827 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = | 5854 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = |
5828 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); | 5855 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); |
5829 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); | 5856 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); |
5830 replica_layer->SetMaskLayer(scoped_mask_layer.Pass()); | 5857 replica_layer->SetMaskLayer(scoped_mask_layer.Pass()); |
| 5858 replica_layer->SetHasRenderSurface(true); |
5831 | 5859 |
5832 gfx::Size root_size(100, 100); | 5860 gfx::Size root_size(100, 100); |
5833 root->SetBounds(root_size); | 5861 root->SetBounds(root_size); |
5834 root->SetContentBounds(root_size); | 5862 root->SetContentBounds(root_size); |
5835 root->SetPosition(gfx::PointF()); | 5863 root->SetPosition(gfx::PointF()); |
5836 | 5864 |
5837 gfx::Size layer_size(50, 50); | 5865 gfx::Size layer_size(50, 50); |
5838 content_layer->SetBounds(layer_size); | 5866 content_layer->SetBounds(layer_size); |
5839 content_layer->SetContentBounds(layer_size); | 5867 content_layer->SetContentBounds(layer_size); |
5840 content_layer->SetPosition(gfx::PointF()); | 5868 content_layer->SetPosition(gfx::PointF()); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5960 } | 5988 } |
5961 } | 5989 } |
5962 | 5990 |
5963 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerForSurfaceWithUnclippedChild) { | 5991 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerForSurfaceWithUnclippedChild) { |
5964 // The replica is of a layer with bounds 50x50, but it has a child that causes | 5992 // The replica is of a layer with bounds 50x50, but it has a child that causes |
5965 // the surface bounds to be larger. | 5993 // the surface bounds to be larger. |
5966 | 5994 |
5967 scoped_ptr<LayerImpl> scoped_root = | 5995 scoped_ptr<LayerImpl> scoped_root = |
5968 LayerImpl::Create(host_impl_->active_tree(), 1); | 5996 LayerImpl::Create(host_impl_->active_tree(), 1); |
5969 LayerImpl* root = scoped_root.get(); | 5997 LayerImpl* root = scoped_root.get(); |
| 5998 root->SetHasRenderSurface(true); |
5970 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); | 5999 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); |
5971 | 6000 |
5972 scoped_ptr<LayerImpl> scoped_content_layer = | 6001 scoped_ptr<LayerImpl> scoped_content_layer = |
5973 LayerImpl::Create(host_impl_->active_tree(), 2); | 6002 LayerImpl::Create(host_impl_->active_tree(), 2); |
5974 LayerImpl* content_layer = scoped_content_layer.get(); | 6003 LayerImpl* content_layer = scoped_content_layer.get(); |
5975 root->AddChild(scoped_content_layer.Pass()); | 6004 root->AddChild(scoped_content_layer.Pass()); |
5976 | 6005 |
5977 scoped_ptr<LayerImpl> scoped_content_child_layer = | 6006 scoped_ptr<LayerImpl> scoped_content_child_layer = |
5978 LayerImpl::Create(host_impl_->active_tree(), 3); | 6007 LayerImpl::Create(host_impl_->active_tree(), 3); |
5979 LayerImpl* content_child_layer = scoped_content_child_layer.get(); | 6008 LayerImpl* content_child_layer = scoped_content_child_layer.get(); |
5980 content_layer->AddChild(scoped_content_child_layer.Pass()); | 6009 content_layer->AddChild(scoped_content_child_layer.Pass()); |
5981 | 6010 |
5982 scoped_ptr<LayerImpl> scoped_replica_layer = | 6011 scoped_ptr<LayerImpl> scoped_replica_layer = |
5983 LayerImpl::Create(host_impl_->active_tree(), 4); | 6012 LayerImpl::Create(host_impl_->active_tree(), 4); |
5984 LayerImpl* replica_layer = scoped_replica_layer.get(); | 6013 LayerImpl* replica_layer = scoped_replica_layer.get(); |
5985 content_layer->SetReplicaLayer(scoped_replica_layer.Pass()); | 6014 content_layer->SetReplicaLayer(scoped_replica_layer.Pass()); |
| 6015 content_layer->SetHasRenderSurface(true); |
5986 | 6016 |
5987 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = | 6017 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = |
5988 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 5); | 6018 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 5); |
5989 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); | 6019 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); |
5990 replica_layer->SetMaskLayer(scoped_mask_layer.Pass()); | 6020 replica_layer->SetMaskLayer(scoped_mask_layer.Pass()); |
| 6021 replica_layer->SetHasRenderSurface(true); |
5991 | 6022 |
5992 gfx::Size root_size(100, 100); | 6023 gfx::Size root_size(100, 100); |
5993 root->SetBounds(root_size); | 6024 root->SetBounds(root_size); |
5994 root->SetContentBounds(root_size); | 6025 root->SetContentBounds(root_size); |
5995 root->SetPosition(gfx::PointF()); | 6026 root->SetPosition(gfx::PointF()); |
5996 | 6027 |
5997 gfx::Size layer_size(50, 50); | 6028 gfx::Size layer_size(50, 50); |
5998 content_layer->SetBounds(layer_size); | 6029 content_layer->SetBounds(layer_size); |
5999 content_layer->SetContentBounds(layer_size); | 6030 content_layer->SetContentBounds(layer_size); |
6000 content_layer->SetPosition(gfx::PointF()); | 6031 content_layer->SetPosition(gfx::PointF()); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6084 } | 6115 } |
6085 | 6116 |
6086 TEST_F(LayerTreeHostImplTest, MaskLayerForSurfaceWithClippedLayer) { | 6117 TEST_F(LayerTreeHostImplTest, MaskLayerForSurfaceWithClippedLayer) { |
6087 // The masked layer has bounds 50x50, but it has a child that causes | 6118 // The masked layer has bounds 50x50, but it has a child that causes |
6088 // the surface bounds to be larger. It also has a parent that clips the | 6119 // the surface bounds to be larger. It also has a parent that clips the |
6089 // masked layer and its surface. | 6120 // masked layer and its surface. |
6090 | 6121 |
6091 scoped_ptr<LayerImpl> scoped_root = | 6122 scoped_ptr<LayerImpl> scoped_root = |
6092 LayerImpl::Create(host_impl_->active_tree(), 1); | 6123 LayerImpl::Create(host_impl_->active_tree(), 1); |
6093 LayerImpl* root = scoped_root.get(); | 6124 LayerImpl* root = scoped_root.get(); |
| 6125 root->SetHasRenderSurface(true); |
| 6126 |
6094 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); | 6127 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); |
6095 | 6128 |
6096 scoped_ptr<LayerImpl> scoped_clipping_layer = | 6129 scoped_ptr<LayerImpl> scoped_clipping_layer = |
6097 LayerImpl::Create(host_impl_->active_tree(), 2); | 6130 LayerImpl::Create(host_impl_->active_tree(), 2); |
6098 LayerImpl* clipping_layer = scoped_clipping_layer.get(); | 6131 LayerImpl* clipping_layer = scoped_clipping_layer.get(); |
6099 root->AddChild(scoped_clipping_layer.Pass()); | 6132 root->AddChild(scoped_clipping_layer.Pass()); |
6100 | 6133 |
6101 scoped_ptr<LayerImpl> scoped_content_layer = | 6134 scoped_ptr<LayerImpl> scoped_content_layer = |
6102 LayerImpl::Create(host_impl_->active_tree(), 3); | 6135 LayerImpl::Create(host_impl_->active_tree(), 3); |
6103 LayerImpl* content_layer = scoped_content_layer.get(); | 6136 LayerImpl* content_layer = scoped_content_layer.get(); |
6104 clipping_layer->AddChild(scoped_content_layer.Pass()); | 6137 clipping_layer->AddChild(scoped_content_layer.Pass()); |
6105 | 6138 |
6106 scoped_ptr<LayerImpl> scoped_content_child_layer = | 6139 scoped_ptr<LayerImpl> scoped_content_child_layer = |
6107 LayerImpl::Create(host_impl_->active_tree(), 4); | 6140 LayerImpl::Create(host_impl_->active_tree(), 4); |
6108 LayerImpl* content_child_layer = scoped_content_child_layer.get(); | 6141 LayerImpl* content_child_layer = scoped_content_child_layer.get(); |
6109 content_layer->AddChild(scoped_content_child_layer.Pass()); | 6142 content_layer->AddChild(scoped_content_child_layer.Pass()); |
6110 | 6143 |
6111 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = | 6144 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = |
6112 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 6); | 6145 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 6); |
6113 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); | 6146 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); |
6114 content_layer->SetMaskLayer(scoped_mask_layer.Pass()); | 6147 content_layer->SetMaskLayer(scoped_mask_layer.Pass()); |
| 6148 content_layer->SetHasRenderSurface(true); |
6115 | 6149 |
6116 gfx::Size root_size(100, 100); | 6150 gfx::Size root_size(100, 100); |
6117 root->SetBounds(root_size); | 6151 root->SetBounds(root_size); |
6118 root->SetContentBounds(root_size); | 6152 root->SetContentBounds(root_size); |
6119 root->SetPosition(gfx::PointF()); | 6153 root->SetPosition(gfx::PointF()); |
6120 | 6154 |
6121 gfx::Rect clipping_rect(20, 10, 10, 20); | 6155 gfx::Rect clipping_rect(20, 10, 10, 20); |
6122 clipping_layer->SetBounds(clipping_rect.size()); | 6156 clipping_layer->SetBounds(clipping_rect.size()); |
6123 clipping_layer->SetContentBounds(clipping_rect.size()); | 6157 clipping_layer->SetContentBounds(clipping_rect.size()); |
6124 clipping_layer->SetPosition(clipping_rect.origin()); | 6158 clipping_layer->SetPosition(clipping_rect.origin()); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6190 gfx::ToCeiledSize(gfx::ScaleSize(root_size, device_scale_factor)); | 6224 gfx::ToCeiledSize(gfx::ScaleSize(root_size, device_scale_factor)); |
6191 host_impl_->SetViewportSize(device_viewport_size); | 6225 host_impl_->SetViewportSize(device_viewport_size); |
6192 | 6226 |
6193 host_impl_->CreatePendingTree(); | 6227 host_impl_->CreatePendingTree(); |
6194 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f / 16.f, | 6228 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f / 16.f, |
6195 16.f); | 6229 16.f); |
6196 | 6230 |
6197 scoped_ptr<LayerImpl> scoped_root = | 6231 scoped_ptr<LayerImpl> scoped_root = |
6198 LayerImpl::Create(host_impl_->pending_tree(), 1); | 6232 LayerImpl::Create(host_impl_->pending_tree(), 1); |
6199 LayerImpl* root = scoped_root.get(); | 6233 LayerImpl* root = scoped_root.get(); |
| 6234 root->SetHasRenderSurface(true); |
6200 | 6235 |
6201 host_impl_->pending_tree()->SetRootLayer(scoped_root.Pass()); | 6236 host_impl_->pending_tree()->SetRootLayer(scoped_root.Pass()); |
6202 | 6237 |
6203 scoped_ptr<LayerImpl> scoped_scrolling_layer = | 6238 scoped_ptr<LayerImpl> scoped_scrolling_layer = |
6204 LayerImpl::Create(host_impl_->pending_tree(), 2); | 6239 LayerImpl::Create(host_impl_->pending_tree(), 2); |
6205 LayerImpl* scrolling_layer = scoped_scrolling_layer.get(); | 6240 LayerImpl* scrolling_layer = scoped_scrolling_layer.get(); |
6206 root->AddChild(scoped_scrolling_layer.Pass()); | 6241 root->AddChild(scoped_scrolling_layer.Pass()); |
6207 | 6242 |
6208 gfx::Size content_layer_bounds(100000, 100); | 6243 gfx::Size content_layer_bounds(100000, 100); |
6209 gfx::Size pile_tile_size(3000, 3000); | 6244 gfx::Size pile_tile_size(3000, 3000); |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6681 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures()); | 6716 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures()); |
6682 } | 6717 } |
6683 | 6718 |
6684 TEST_F(LayerTreeHostImplTest, TouchFlingShouldNotBubble) { | 6719 TEST_F(LayerTreeHostImplTest, TouchFlingShouldNotBubble) { |
6685 // When flinging via touch, only the child should scroll (we should not | 6720 // When flinging via touch, only the child should scroll (we should not |
6686 // bubble). | 6721 // bubble). |
6687 gfx::Size surface_size(10, 10); | 6722 gfx::Size surface_size(10, 10); |
6688 gfx::Size content_size(20, 20); | 6723 gfx::Size content_size(20, 20); |
6689 scoped_ptr<LayerImpl> root_clip = | 6724 scoped_ptr<LayerImpl> root_clip = |
6690 LayerImpl::Create(host_impl_->active_tree(), 3); | 6725 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 6726 root_clip->SetHasRenderSurface(true); |
| 6727 |
6691 scoped_ptr<LayerImpl> root = | 6728 scoped_ptr<LayerImpl> root = |
6692 CreateScrollableLayer(1, content_size, root_clip.get()); | 6729 CreateScrollableLayer(1, content_size, root_clip.get()); |
6693 root->SetIsContainerForFixedPositionLayers(true); | 6730 root->SetIsContainerForFixedPositionLayers(true); |
6694 scoped_ptr<LayerImpl> child = | 6731 scoped_ptr<LayerImpl> child = |
6695 CreateScrollableLayer(2, content_size, root_clip.get()); | 6732 CreateScrollableLayer(2, content_size, root_clip.get()); |
6696 | 6733 |
6697 root->AddChild(child.Pass()); | 6734 root->AddChild(child.Pass()); |
6698 int root_id = root->id(); | 6735 int root_id = root->id(); |
6699 root_clip->AddChild(root.Pass()); | 6736 root_clip->AddChild(root.Pass()); |
6700 | 6737 |
(...skipping 24 matching lines...) Expand all Loading... |
6725 ASSERT_EQ(1u, scroll_info->scrolls.size()); | 6762 ASSERT_EQ(1u, scroll_info->scrolls.size()); |
6726 ExpectNone(*scroll_info.get(), root_id); | 6763 ExpectNone(*scroll_info.get(), root_id); |
6727 } | 6764 } |
6728 } | 6765 } |
6729 | 6766 |
6730 TEST_F(LayerTreeHostImplTest, TouchFlingShouldLockToFirstScrolledLayer) { | 6767 TEST_F(LayerTreeHostImplTest, TouchFlingShouldLockToFirstScrolledLayer) { |
6731 // Scroll a child layer beyond its maximum scroll range and make sure the | 6768 // Scroll a child layer beyond its maximum scroll range and make sure the |
6732 // the scroll doesn't bubble up to the parent layer. | 6769 // the scroll doesn't bubble up to the parent layer. |
6733 gfx::Size surface_size(10, 10); | 6770 gfx::Size surface_size(10, 10); |
6734 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 6771 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 6772 root->SetHasRenderSurface(true); |
6735 scoped_ptr<LayerImpl> root_scrolling = | 6773 scoped_ptr<LayerImpl> root_scrolling = |
6736 CreateScrollableLayer(2, surface_size, root.get()); | 6774 CreateScrollableLayer(2, surface_size, root.get()); |
6737 | 6775 |
6738 scoped_ptr<LayerImpl> grand_child = | 6776 scoped_ptr<LayerImpl> grand_child = |
6739 CreateScrollableLayer(4, surface_size, root.get()); | 6777 CreateScrollableLayer(4, surface_size, root.get()); |
6740 grand_child->SetScrollOffset(gfx::ScrollOffset(0, 2)); | 6778 grand_child->SetScrollOffset(gfx::ScrollOffset(0, 2)); |
6741 | 6779 |
6742 scoped_ptr<LayerImpl> child = | 6780 scoped_ptr<LayerImpl> child = |
6743 CreateScrollableLayer(3, surface_size, root.get()); | 6781 CreateScrollableLayer(3, surface_size, root.get()); |
6744 child->SetScrollOffset(gfx::ScrollOffset(0, 4)); | 6782 child->SetScrollOffset(gfx::ScrollOffset(0, 4)); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6795 } | 6833 } |
6796 } | 6834 } |
6797 | 6835 |
6798 TEST_F(LayerTreeHostImplTest, WheelFlingShouldBubble) { | 6836 TEST_F(LayerTreeHostImplTest, WheelFlingShouldBubble) { |
6799 // When flinging via wheel, the root should eventually scroll (we should | 6837 // When flinging via wheel, the root should eventually scroll (we should |
6800 // bubble). | 6838 // bubble). |
6801 gfx::Size surface_size(10, 10); | 6839 gfx::Size surface_size(10, 10); |
6802 gfx::Size content_size(20, 20); | 6840 gfx::Size content_size(20, 20); |
6803 scoped_ptr<LayerImpl> root_clip = | 6841 scoped_ptr<LayerImpl> root_clip = |
6804 LayerImpl::Create(host_impl_->active_tree(), 3); | 6842 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 6843 root_clip->SetHasRenderSurface(true); |
6805 scoped_ptr<LayerImpl> root_scroll = | 6844 scoped_ptr<LayerImpl> root_scroll = |
6806 CreateScrollableLayer(1, content_size, root_clip.get()); | 6845 CreateScrollableLayer(1, content_size, root_clip.get()); |
6807 int root_scroll_id = root_scroll->id(); | 6846 int root_scroll_id = root_scroll->id(); |
6808 scoped_ptr<LayerImpl> child = | 6847 scoped_ptr<LayerImpl> child = |
6809 CreateScrollableLayer(2, content_size, root_clip.get()); | 6848 CreateScrollableLayer(2, content_size, root_clip.get()); |
6810 | 6849 |
6811 root_scroll->AddChild(child.Pass()); | 6850 root_scroll->AddChild(child.Pass()); |
6812 root_clip->AddChild(root_scroll.Pass()); | 6851 root_clip->AddChild(root_scroll.Pass()); |
6813 | 6852 |
6814 host_impl_->SetViewportSize(surface_size); | 6853 host_impl_->SetViewportSize(surface_size); |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6998 | 7037 |
6999 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed | 7038 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed |
7000 // to CompositorFrameMetadata after SwapBuffers(); | 7039 // to CompositorFrameMetadata after SwapBuffers(); |
7001 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { | 7040 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { |
7002 scoped_ptr<SolidColorLayerImpl> root = | 7041 scoped_ptr<SolidColorLayerImpl> root = |
7003 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 7042 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
7004 root->SetPosition(gfx::PointF()); | 7043 root->SetPosition(gfx::PointF()); |
7005 root->SetBounds(gfx::Size(10, 10)); | 7044 root->SetBounds(gfx::Size(10, 10)); |
7006 root->SetContentBounds(gfx::Size(10, 10)); | 7045 root->SetContentBounds(gfx::Size(10, 10)); |
7007 root->SetDrawsContent(true); | 7046 root->SetDrawsContent(true); |
| 7047 root->SetHasRenderSurface(true); |
7008 | 7048 |
7009 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 7049 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
7010 | 7050 |
7011 FakeOutputSurface* fake_output_surface = | 7051 FakeOutputSurface* fake_output_surface = |
7012 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); | 7052 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); |
7013 | 7053 |
7014 const std::vector<ui::LatencyInfo>& metadata_latency_before = | 7054 const std::vector<ui::LatencyInfo>& metadata_latency_before = |
7015 fake_output_surface->last_sent_frame().metadata.latency_info; | 7055 fake_output_surface->last_sent_frame().metadata.latency_info; |
7016 EXPECT_TRUE(metadata_latency_before.empty()); | 7056 EXPECT_TRUE(metadata_latency_before.empty()); |
7017 | 7057 |
(...skipping 20 matching lines...) Expand all Loading... |
7038 } | 7078 } |
7039 | 7079 |
7040 TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) { | 7080 TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) { |
7041 int root_layer_id = 1; | 7081 int root_layer_id = 1; |
7042 scoped_ptr<SolidColorLayerImpl> root = | 7082 scoped_ptr<SolidColorLayerImpl> root = |
7043 SolidColorLayerImpl::Create(host_impl_->active_tree(), root_layer_id); | 7083 SolidColorLayerImpl::Create(host_impl_->active_tree(), root_layer_id); |
7044 root->SetPosition(gfx::PointF()); | 7084 root->SetPosition(gfx::PointF()); |
7045 root->SetBounds(gfx::Size(10, 10)); | 7085 root->SetBounds(gfx::Size(10, 10)); |
7046 root->SetContentBounds(gfx::Size(10, 10)); | 7086 root->SetContentBounds(gfx::Size(10, 10)); |
7047 root->SetDrawsContent(true); | 7087 root->SetDrawsContent(true); |
| 7088 root->SetHasRenderSurface(true); |
7048 | 7089 |
7049 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 7090 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
7050 | 7091 |
7051 // Ensure the default frame selection bounds are empty. | 7092 // Ensure the default frame selection bounds are empty. |
7052 FakeOutputSurface* fake_output_surface = | 7093 FakeOutputSurface* fake_output_surface = |
7053 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); | 7094 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); |
7054 const ViewportSelectionBound& selection_start_before = | 7095 const ViewportSelectionBound& selection_start_before = |
7055 fake_output_surface->last_sent_frame().metadata.selection_start; | 7096 fake_output_surface->last_sent_frame().metadata.selection_start; |
7056 const ViewportSelectionBound& selection_end_before = | 7097 const ViewportSelectionBound& selection_end_before = |
7057 fake_output_surface->last_sent_frame().metadata.selection_end; | 7098 fake_output_surface->last_sent_frame().metadata.selection_end; |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7563 contents->SetBounds(content_size); | 7604 contents->SetBounds(content_size); |
7564 contents->SetContentBounds(content_size); | 7605 contents->SetContentBounds(content_size); |
7565 contents->SetPosition(gfx::PointF()); | 7606 contents->SetPosition(gfx::PointF()); |
7566 | 7607 |
7567 outer_scroll->AddChild(contents.Pass()); | 7608 outer_scroll->AddChild(contents.Pass()); |
7568 outer_clip->AddChild(outer_scroll.Pass()); | 7609 outer_clip->AddChild(outer_scroll.Pass()); |
7569 inner_scroll->AddChild(outer_clip.Pass()); | 7610 inner_scroll->AddChild(outer_clip.Pass()); |
7570 page_scale->AddChild(inner_scroll.Pass()); | 7611 page_scale->AddChild(inner_scroll.Pass()); |
7571 inner_clip->AddChild(page_scale.Pass()); | 7612 inner_clip->AddChild(page_scale.Pass()); |
7572 | 7613 |
| 7614 inner_clip->SetHasRenderSurface(true); |
7573 layer_tree_impl->SetRootLayer(inner_clip.Pass()); | 7615 layer_tree_impl->SetRootLayer(inner_clip.Pass()); |
7574 layer_tree_impl->SetViewportLayersFromIds( | 7616 layer_tree_impl->SetViewportLayersFromIds( |
7575 Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportScrollLayerId, | 7617 Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportScrollLayerId, |
7576 kOuterViewportScrollLayerId); | 7618 kOuterViewportScrollLayerId); |
7577 | 7619 |
7578 host_impl_->active_tree()->DidBecomeActive(); | 7620 host_impl_->active_tree()->DidBecomeActive(); |
7579 } | 7621 } |
7580 }; | 7622 }; |
7581 | 7623 |
7582 TEST_F(LayerTreeHostImplVirtualViewportTest, FlingScrollBubblesToInner) { | 7624 TEST_F(LayerTreeHostImplVirtualViewportTest, FlingScrollBubblesToInner) { |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7984 // surface. | 8026 // surface. |
7985 EXPECT_EQ(0, num_lost_surfaces_); | 8027 EXPECT_EQ(0, num_lost_surfaces_); |
7986 host_impl_->DidLoseOutputSurface(); | 8028 host_impl_->DidLoseOutputSurface(); |
7987 EXPECT_EQ(1, num_lost_surfaces_); | 8029 EXPECT_EQ(1, num_lost_surfaces_); |
7988 host_impl_->DidLoseOutputSurface(); | 8030 host_impl_->DidLoseOutputSurface(); |
7989 EXPECT_LE(1, num_lost_surfaces_); | 8031 EXPECT_LE(1, num_lost_surfaces_); |
7990 } | 8032 } |
7991 | 8033 |
7992 } // namespace | 8034 } // namespace |
7993 } // namespace cc | 8035 } // namespace cc |
OLD | NEW |