OLD | NEW |
---|---|
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
42 #include "cc/test/fake_layer_tree_host_impl.h" | 42 #include "cc/test/fake_layer_tree_host_impl.h" |
43 #include "cc/test/fake_output_surface.h" | 43 #include "cc/test/fake_output_surface.h" |
44 #include "cc/test/fake_output_surface_client.h" | 44 #include "cc/test/fake_output_surface_client.h" |
45 #include "cc/test/fake_picture_layer_impl.h" | 45 #include "cc/test/fake_picture_layer_impl.h" |
46 #include "cc/test/fake_picture_pile_impl.h" | 46 #include "cc/test/fake_picture_pile_impl.h" |
47 #include "cc/test/fake_proxy.h" | 47 #include "cc/test/fake_proxy.h" |
48 #include "cc/test/fake_rendering_stats_instrumentation.h" | 48 #include "cc/test/fake_rendering_stats_instrumentation.h" |
49 #include "cc/test/fake_video_frame_provider.h" | 49 #include "cc/test/fake_video_frame_provider.h" |
50 #include "cc/test/geometry_test_utils.h" | 50 #include "cc/test/geometry_test_utils.h" |
51 #include "cc/test/layer_test_common.h" | 51 #include "cc/test/layer_test_common.h" |
52 #include "cc/test/layer_tree_test.h" | |
52 #include "cc/test/render_pass_test_common.h" | 53 #include "cc/test/render_pass_test_common.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 "media/base/media.h" | 58 #include "media/base/media.h" |
58 #include "testing/gmock/include/gmock/gmock.h" | 59 #include "testing/gmock/include/gmock/gmock.h" |
59 #include "testing/gtest/include/gtest/gtest.h" | 60 #include "testing/gtest/include/gtest/gtest.h" |
60 #include "third_party/skia/include/core/SkMallocPixelRef.h" | 61 #include "third_party/skia/include/core/SkMallocPixelRef.h" |
61 #include "ui/gfx/frame_time.h" | 62 #include "ui/gfx/frame_time.h" |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
180 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 181 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
181 return init; | 182 return init; |
182 } | 183 } |
183 | 184 |
184 void SetupRootLayerImpl(scoped_ptr<LayerImpl> root) { | 185 void SetupRootLayerImpl(scoped_ptr<LayerImpl> root) { |
185 root->SetPosition(gfx::PointF()); | 186 root->SetPosition(gfx::PointF()); |
186 root->SetBounds(gfx::Size(10, 10)); | 187 root->SetBounds(gfx::Size(10, 10)); |
187 root->SetContentBounds(gfx::Size(10, 10)); | 188 root->SetContentBounds(gfx::Size(10, 10)); |
188 root->SetDrawsContent(true); | 189 root->SetDrawsContent(true); |
189 root->draw_properties().visible_content_rect = gfx::Rect(0, 0, 10, 10); | 190 root->draw_properties().visible_content_rect = gfx::Rect(0, 0, 10, 10); |
191 root->SetHasRenderSurface(true); | |
190 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 192 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
191 } | 193 } |
192 | 194 |
193 static void ExpectClearedScrollDeltasRecursive(LayerImpl* layer) { | 195 static void ExpectClearedScrollDeltasRecursive(LayerImpl* layer) { |
194 ASSERT_EQ(layer->ScrollDelta(), gfx::Vector2d()); | 196 ASSERT_EQ(layer->ScrollDelta(), gfx::Vector2d()); |
195 for (size_t i = 0; i < layer->children().size(); ++i) | 197 for (size_t i = 0; i < layer->children().size(); ++i) |
196 ExpectClearedScrollDeltasRecursive(layer->children()[i]); | 198 ExpectClearedScrollDeltasRecursive(layer->children()[i]); |
197 } | 199 } |
198 | 200 |
199 static void ExpectContains(const ScrollAndScaleSet& scroll_info, | 201 static void ExpectContains(const ScrollAndScaleSet& scroll_info, |
(...skipping 26 matching lines...) Expand all Loading... | |
226 LayerImpl* CreateScrollAndContentsLayers(LayerTreeImpl* layer_tree_impl, | 228 LayerImpl* CreateScrollAndContentsLayers(LayerTreeImpl* layer_tree_impl, |
227 const gfx::Size& content_size) { | 229 const gfx::Size& content_size) { |
228 const int kInnerViewportScrollLayerId = 2; | 230 const int kInnerViewportScrollLayerId = 2; |
229 const int kInnerViewportClipLayerId = 4; | 231 const int kInnerViewportClipLayerId = 4; |
230 const int kPageScaleLayerId = 5; | 232 const int kPageScaleLayerId = 5; |
231 scoped_ptr<LayerImpl> root = | 233 scoped_ptr<LayerImpl> root = |
232 LayerImpl::Create(layer_tree_impl, 1); | 234 LayerImpl::Create(layer_tree_impl, 1); |
233 root->SetBounds(content_size); | 235 root->SetBounds(content_size); |
234 root->SetContentBounds(content_size); | 236 root->SetContentBounds(content_size); |
235 root->SetPosition(gfx::PointF()); | 237 root->SetPosition(gfx::PointF()); |
238 root->SetHasRenderSurface(true); | |
236 | 239 |
237 scoped_ptr<LayerImpl> scroll = | 240 scoped_ptr<LayerImpl> scroll = |
238 LayerImpl::Create(layer_tree_impl, kInnerViewportScrollLayerId); | 241 LayerImpl::Create(layer_tree_impl, kInnerViewportScrollLayerId); |
239 LayerImpl* scroll_layer = scroll.get(); | 242 LayerImpl* scroll_layer = scroll.get(); |
240 scroll->SetIsContainerForFixedPositionLayers(true); | 243 scroll->SetIsContainerForFixedPositionLayers(true); |
241 scroll->SetScrollOffset(gfx::Vector2d()); | 244 scroll->SetScrollOffset(gfx::Vector2d()); |
242 | 245 |
243 scoped_ptr<LayerImpl> clip = | 246 scoped_ptr<LayerImpl> clip = |
244 LayerImpl::Create(layer_tree_impl, kInnerViewportClipLayerId); | 247 LayerImpl::Create(layer_tree_impl, kInnerViewportClipLayerId); |
245 clip->SetBounds( | 248 clip->SetBounds( |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
556 | 559 |
557 // We should still be scrolling, because the scrolled layer also exists in the | 560 // We should still be scrolling, because the scrolled layer also exists in the |
558 // new tree. | 561 // new tree. |
559 gfx::Vector2d scroll_delta(0, 10); | 562 gfx::Vector2d scroll_delta(0, 10); |
560 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 563 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
561 host_impl_->ScrollEnd(); | 564 host_impl_->ScrollEnd(); |
562 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); | 565 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); |
563 ExpectContains(*scroll_info, scroll_layer->id(), scroll_delta); | 566 ExpectContains(*scroll_info, scroll_layer->id(), scroll_delta); |
564 } | 567 } |
565 | 568 |
566 TEST_F(LayerTreeHostImplTest, ClearRootRenderSurfaceAndScroll) { | |
567 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | |
568 host_impl_->SetViewportSize(gfx::Size(50, 50)); | |
569 DrawFrame(); | |
570 | |
571 // We should be able to scroll even if the root layer loses its render surface | |
572 // after the most recent render. | |
573 host_impl_->active_tree()->root_layer()->ClearRenderSurface(); | |
574 host_impl_->active_tree()->set_needs_update_draw_properties(); | |
575 | |
576 EXPECT_EQ(InputHandler::ScrollStarted, | |
577 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); | |
578 } | |
579 | |
580 TEST_F(LayerTreeHostImplTest, WheelEventHandlers) { | 569 TEST_F(LayerTreeHostImplTest, WheelEventHandlers) { |
581 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 570 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
582 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 571 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
583 DrawFrame(); | 572 DrawFrame(); |
584 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 573 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
585 | 574 |
586 root->SetHaveWheelEventHandlers(true); | 575 root->SetHaveWheelEventHandlers(true); |
587 | 576 |
588 // With registered event handlers, wheel scrolls have to go to the main | 577 // With registered event handlers, wheel scrolls have to go to the main |
589 // thread. | 578 // thread. |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
874 host_impl_->ScrollBegin(scroll_position, InputHandler::Wheel)); | 863 host_impl_->ScrollBegin(scroll_position, InputHandler::Wheel)); |
875 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 0), scroll_layer->TotalScrollOffset()); | 864 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 0), scroll_layer->TotalScrollOffset()); |
876 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->TotalScrollOffset()); | 865 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->TotalScrollOffset()); |
877 | 866 |
878 host_impl_->ScrollBy(scroll_position, scroll_delta); | 867 host_impl_->ScrollBy(scroll_position, scroll_delta); |
879 host_impl_->ScrollEnd(); | 868 host_impl_->ScrollEnd(); |
880 EXPECT_VECTOR_EQ(gfx::Vector2dF(20, 10), scroll_layer->TotalScrollOffset()); | 869 EXPECT_VECTOR_EQ(gfx::Vector2dF(20, 10), scroll_layer->TotalScrollOffset()); |
881 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->TotalScrollOffset()); | 870 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->TotalScrollOffset()); |
882 } | 871 } |
883 | 872 |
884 TEST_F(LayerTreeHostImplTest, | |
885 ClearRootRenderSurfaceAndHitTestTouchHandlerRegion) { | |
886 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | |
887 host_impl_->SetViewportSize(gfx::Size(50, 50)); | |
888 DrawFrame(); | |
889 | |
890 // We should be able to hit test for touch event handlers even if the root | |
891 // layer loses its render surface after the most recent render. | |
892 host_impl_->active_tree()->root_layer()->ClearRenderSurface(); | |
893 host_impl_->active_tree()->set_needs_update_draw_properties(); | |
894 | |
895 EXPECT_EQ(host_impl_->HaveTouchEventHandlersAt(gfx::Point()), false); | |
896 } | |
897 | |
898 TEST_F(LayerTreeHostImplTest, ImplPinchZoom) { | 873 TEST_F(LayerTreeHostImplTest, ImplPinchZoom) { |
899 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 874 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
900 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 875 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
901 DrawFrame(); | 876 DrawFrame(); |
902 | 877 |
903 EXPECT_EQ(scroll_layer, host_impl_->InnerViewportScrollLayer()); | 878 EXPECT_EQ(scroll_layer, host_impl_->InnerViewportScrollLayer()); |
904 LayerImpl* container_layer = scroll_layer->scroll_clip_layer(); | 879 LayerImpl* container_layer = scroll_layer->scroll_clip_layer(); |
905 EXPECT_EQ(gfx::Size(50, 50), container_layer->bounds()); | 880 EXPECT_EQ(gfx::Size(50, 50), container_layer->bounds()); |
906 | 881 |
907 float min_page_scale = 1.f, max_page_scale = 4.f; | 882 float min_page_scale = 1.f, max_page_scale = 4.f; |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1321 contents->SetBounds(content_size); \ | 1296 contents->SetBounds(content_size); \ |
1322 contents->SetContentBounds(content_size); \ | 1297 contents->SetContentBounds(content_size); \ |
1323 \ | 1298 \ |
1324 scoped_ptr<SolidColorScrollbarLayerImpl> scrollbar = \ | 1299 scoped_ptr<SolidColorScrollbarLayerImpl> scrollbar = \ |
1325 SolidColorScrollbarLayerImpl::Create( \ | 1300 SolidColorScrollbarLayerImpl::Create( \ |
1326 host_impl_->active_tree(), 4, VERTICAL, 10, 0, false, true); \ | 1301 host_impl_->active_tree(), 4, VERTICAL, 10, 0, false, true); \ |
1327 EXPECT_FLOAT_EQ(0.f, scrollbar->opacity()); \ | 1302 EXPECT_FLOAT_EQ(0.f, scrollbar->opacity()); \ |
1328 \ | 1303 \ |
1329 scroll->AddChild(contents.Pass()); \ | 1304 scroll->AddChild(contents.Pass()); \ |
1330 root->AddChild(scroll.Pass()); \ | 1305 root->AddChild(scroll.Pass()); \ |
1306 root->SetHasRenderSurface(true); \ | |
1331 scrollbar->SetScrollLayerAndClipLayerByIds(2, 1); \ | 1307 scrollbar->SetScrollLayerAndClipLayerByIds(2, 1); \ |
1332 root->AddChild(scrollbar.PassAs<LayerImpl>()); \ | 1308 root->AddChild(scrollbar.PassAs<LayerImpl>()); \ |
1333 \ | 1309 \ |
1334 host_impl_->active_tree()->SetRootLayer(root.Pass()); \ | 1310 host_impl_->active_tree()->SetRootLayer(root.Pass()); \ |
1335 host_impl_->active_tree()->SetViewportLayersFromIds( \ | 1311 host_impl_->active_tree()->SetViewportLayersFromIds( \ |
1336 1, 2, Layer::INVALID_ID); \ | 1312 1, 2, Layer::INVALID_ID); \ |
1337 host_impl_->active_tree()->DidBecomeActive(); \ | 1313 host_impl_->active_tree()->DidBecomeActive(); \ |
1338 DrawFrame(); | 1314 DrawFrame(); |
1339 | 1315 |
1340 TEST_F(LayerTreeHostImplTest, ScrollbarLinearFadeScheduling) { | 1316 TEST_F(LayerTreeHostImplTest, ScrollbarLinearFadeScheduling) { |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1458 gfx::ScaleSize(viewport_size, device_scale_factor)); | 1434 gfx::ScaleSize(viewport_size, device_scale_factor)); |
1459 gfx::Size content_size(1000, 1000); | 1435 gfx::Size content_size(1000, 1000); |
1460 | 1436 |
1461 CreateHostImpl(settings, CreateOutputSurface()); | 1437 CreateHostImpl(settings, CreateOutputSurface()); |
1462 host_impl_->SetDeviceScaleFactor(device_scale_factor); | 1438 host_impl_->SetDeviceScaleFactor(device_scale_factor); |
1463 host_impl_->SetViewportSize(device_viewport_size); | 1439 host_impl_->SetViewportSize(device_viewport_size); |
1464 | 1440 |
1465 scoped_ptr<LayerImpl> root = | 1441 scoped_ptr<LayerImpl> root = |
1466 LayerImpl::Create(host_impl_->active_tree(), 1); | 1442 LayerImpl::Create(host_impl_->active_tree(), 1); |
1467 root->SetBounds(viewport_size); | 1443 root->SetBounds(viewport_size); |
1444 root->SetHasRenderSurface(true); | |
1468 | 1445 |
1469 scoped_ptr<LayerImpl> scroll = | 1446 scoped_ptr<LayerImpl> scroll = |
1470 LayerImpl::Create(host_impl_->active_tree(), 2); | 1447 LayerImpl::Create(host_impl_->active_tree(), 2); |
1471 scroll->SetScrollClipLayer(root->id()); | 1448 scroll->SetScrollClipLayer(root->id()); |
1472 scroll->SetScrollOffset(gfx::Vector2d()); | 1449 scroll->SetScrollOffset(gfx::Vector2d()); |
1473 scroll->SetBounds(content_size); | 1450 scroll->SetBounds(content_size); |
1474 scroll->SetContentBounds(content_size); | 1451 scroll->SetContentBounds(content_size); |
1475 scroll->SetIsContainerForFixedPositionLayers(true); | 1452 scroll->SetIsContainerForFixedPositionLayers(true); |
1476 | 1453 |
1477 scoped_ptr<LayerImpl> contents = | 1454 scoped_ptr<LayerImpl> contents = |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1662 | 1639 |
1663 TEST_F(LayerTreeHostImplTest, WillDrawReturningFalseDoesNotCall) { | 1640 TEST_F(LayerTreeHostImplTest, WillDrawReturningFalseDoesNotCall) { |
1664 // The root layer is always drawn, so run this test on a child layer that | 1641 // The root layer is always drawn, so run this test on a child layer that |
1665 // will be masked out by the root layer's bounds. | 1642 // will be masked out by the root layer's bounds. |
1666 host_impl_->active_tree()->SetRootLayer( | 1643 host_impl_->active_tree()->SetRootLayer( |
1667 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 1644 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
1668 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( | 1645 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( |
1669 host_impl_->active_tree()->root_layer()); | 1646 host_impl_->active_tree()->root_layer()); |
1670 | 1647 |
1671 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 1648 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
1649 root->SetHasRenderSurface(true); | |
1672 DidDrawCheckLayer* layer = | 1650 DidDrawCheckLayer* layer = |
1673 static_cast<DidDrawCheckLayer*>(root->children()[0]); | 1651 static_cast<DidDrawCheckLayer*>(root->children()[0]); |
1674 | 1652 |
1675 { | 1653 { |
1676 LayerTreeHostImpl::FrameData frame; | 1654 LayerTreeHostImpl::FrameData frame; |
1677 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 1655 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
1678 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 1656 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
1679 host_impl_->DidDrawAllLayers(frame); | 1657 host_impl_->DidDrawAllLayers(frame); |
1680 | 1658 |
1681 EXPECT_TRUE(layer->will_draw_called()); | 1659 EXPECT_TRUE(layer->will_draw_called()); |
(...skipping 20 matching lines...) Expand all Loading... | |
1702 } | 1680 } |
1703 | 1681 |
1704 TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) { | 1682 TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) { |
1705 // The root layer is always drawn, so run this test on a child layer that | 1683 // The root layer is always drawn, so run this test on a child layer that |
1706 // will be masked out by the root layer's bounds. | 1684 // will be masked out by the root layer's bounds. |
1707 host_impl_->active_tree()->SetRootLayer( | 1685 host_impl_->active_tree()->SetRootLayer( |
1708 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 1686 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
1709 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( | 1687 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( |
1710 host_impl_->active_tree()->root_layer()); | 1688 host_impl_->active_tree()->root_layer()); |
1711 root->SetMasksToBounds(true); | 1689 root->SetMasksToBounds(true); |
1712 | 1690 root->SetHasRenderSurface(true); |
1713 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 1691 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
1714 DidDrawCheckLayer* layer = | 1692 DidDrawCheckLayer* layer = |
1715 static_cast<DidDrawCheckLayer*>(root->children()[0]); | 1693 static_cast<DidDrawCheckLayer*>(root->children()[0]); |
1716 // Ensure visible_content_rect for layer is empty. | 1694 // Ensure visible_content_rect for layer is empty. |
1717 layer->SetPosition(gfx::PointF(100.f, 100.f)); | 1695 layer->SetPosition(gfx::PointF(100.f, 100.f)); |
1718 layer->SetBounds(gfx::Size(10, 10)); | 1696 layer->SetBounds(gfx::Size(10, 10)); |
1719 layer->SetContentBounds(gfx::Size(10, 10)); | 1697 layer->SetContentBounds(gfx::Size(10, 10)); |
1720 | 1698 |
1721 LayerTreeHostImpl::FrameData frame; | 1699 LayerTreeHostImpl::FrameData frame; |
1722 | 1700 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1755 host_impl_->active_tree()->SetRootLayer( | 1733 host_impl_->active_tree()->SetRootLayer( |
1756 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 1734 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
1757 DidDrawCheckLayer* root = | 1735 DidDrawCheckLayer* root = |
1758 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 1736 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
1759 | 1737 |
1760 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 1738 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
1761 DidDrawCheckLayer* occluded_layer = | 1739 DidDrawCheckLayer* occluded_layer = |
1762 static_cast<DidDrawCheckLayer*>(root->children()[0]); | 1740 static_cast<DidDrawCheckLayer*>(root->children()[0]); |
1763 | 1741 |
1764 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); | 1742 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); |
1743 root->SetHasRenderSurface(true); | |
1765 DidDrawCheckLayer* top_layer = | 1744 DidDrawCheckLayer* top_layer = |
1766 static_cast<DidDrawCheckLayer*>(root->children()[1]); | 1745 static_cast<DidDrawCheckLayer*>(root->children()[1]); |
1767 // This layer covers the occluded_layer above. Make this layer large so it can | 1746 // This layer covers the occluded_layer above. Make this layer large so it can |
1768 // occlude. | 1747 // occlude. |
1769 top_layer->SetBounds(big_size); | 1748 top_layer->SetBounds(big_size); |
1770 top_layer->SetContentBounds(big_size); | 1749 top_layer->SetContentBounds(big_size); |
1771 top_layer->SetContentsOpaque(true); | 1750 top_layer->SetContentsOpaque(true); |
1772 | 1751 |
1773 LayerTreeHostImpl::FrameData frame; | 1752 LayerTreeHostImpl::FrameData frame; |
1774 | 1753 |
(...skipping 12 matching lines...) Expand all Loading... | |
1787 EXPECT_TRUE(top_layer->did_draw_called()); | 1766 EXPECT_TRUE(top_layer->did_draw_called()); |
1788 } | 1767 } |
1789 | 1768 |
1790 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { | 1769 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { |
1791 host_impl_->active_tree()->SetRootLayer( | 1770 host_impl_->active_tree()->SetRootLayer( |
1792 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 1771 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
1793 DidDrawCheckLayer* root = | 1772 DidDrawCheckLayer* root = |
1794 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 1773 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
1795 | 1774 |
1796 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 1775 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
1776 root->SetHasRenderSurface(true); | |
1797 DidDrawCheckLayer* layer1 = | 1777 DidDrawCheckLayer* layer1 = |
1798 static_cast<DidDrawCheckLayer*>(root->children()[0]); | 1778 static_cast<DidDrawCheckLayer*>(root->children()[0]); |
1799 | 1779 |
1800 layer1->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); | 1780 layer1->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); |
1801 DidDrawCheckLayer* layer2 = | 1781 DidDrawCheckLayer* layer2 = |
1802 static_cast<DidDrawCheckLayer*>(layer1->children()[0]); | 1782 static_cast<DidDrawCheckLayer*>(layer1->children()[0]); |
1803 | 1783 |
1804 layer1->SetOpacity(0.3f); | 1784 layer1->SetOpacity(0.3f); |
danakj
2014/09/03 19:30:35
needed still?
awoloszyn
2014/09/09 15:31:37
No longer needed.
| |
1785 layer1->SetHasRenderSurface(true); | |
1805 layer1->SetShouldFlattenTransform(true); | 1786 layer1->SetShouldFlattenTransform(true); |
1806 | 1787 |
1807 EXPECT_FALSE(root->did_draw_called()); | 1788 EXPECT_FALSE(root->did_draw_called()); |
1808 EXPECT_FALSE(layer1->did_draw_called()); | 1789 EXPECT_FALSE(layer1->did_draw_called()); |
1809 EXPECT_FALSE(layer2->did_draw_called()); | 1790 EXPECT_FALSE(layer2->did_draw_called()); |
1810 | 1791 |
1811 LayerTreeHostImpl::FrameData frame; | 1792 LayerTreeHostImpl::FrameData frame; |
1812 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( | 1793 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( |
1813 host_impl_->active_tree()->root_layer()); | 1794 host_impl_->active_tree()->root_layer()); |
1814 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 1795 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1866 | 1847 |
1867 bool tile_missing_; | 1848 bool tile_missing_; |
1868 bool had_incomplete_tile_; | 1849 bool had_incomplete_tile_; |
1869 }; | 1850 }; |
1870 | 1851 |
1871 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsOnDefault) { | 1852 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsOnDefault) { |
1872 host_impl_->active_tree()->SetRootLayer( | 1853 host_impl_->active_tree()->SetRootLayer( |
1873 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 1854 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
1874 DidDrawCheckLayer* root = | 1855 DidDrawCheckLayer* root = |
1875 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 1856 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
1876 | 1857 root->SetHasRenderSurface(true); |
1877 bool tile_missing = false; | 1858 bool tile_missing = false; |
1878 bool had_incomplete_tile = false; | 1859 bool had_incomplete_tile = false; |
1879 bool is_animating = false; | 1860 bool is_animating = false; |
1880 root->AddChild( | 1861 root->AddChild( |
1881 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 1862 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
1882 2, | 1863 2, |
1883 tile_missing, | 1864 tile_missing, |
1884 had_incomplete_tile, | 1865 had_incomplete_tile, |
1885 is_animating, | 1866 is_animating, |
1886 host_impl_->resource_provider())); | 1867 host_impl_->resource_provider())); |
1887 | 1868 |
1888 LayerTreeHostImpl::FrameData frame; | 1869 LayerTreeHostImpl::FrameData frame; |
1889 | 1870 |
1890 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 1871 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
1891 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 1872 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
1892 host_impl_->DidDrawAllLayers(frame); | 1873 host_impl_->DidDrawAllLayers(frame); |
1893 } | 1874 } |
1894 | 1875 |
1895 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithAnimatedLayer) { | 1876 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithAnimatedLayer) { |
1896 host_impl_->active_tree()->SetRootLayer( | 1877 host_impl_->active_tree()->SetRootLayer( |
1897 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 1878 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
1898 DidDrawCheckLayer* root = | 1879 DidDrawCheckLayer* root = |
1899 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 1880 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
1881 root->SetHasRenderSurface(true); | |
1900 bool tile_missing = false; | 1882 bool tile_missing = false; |
1901 bool had_incomplete_tile = false; | 1883 bool had_incomplete_tile = false; |
1902 bool is_animating = true; | 1884 bool is_animating = true; |
1903 root->AddChild( | 1885 root->AddChild( |
1904 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 1886 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
1905 2, | 1887 2, |
1906 tile_missing, | 1888 tile_missing, |
1907 had_incomplete_tile, | 1889 had_incomplete_tile, |
1908 is_animating, | 1890 is_animating, |
1909 host_impl_->resource_provider())); | 1891 host_impl_->resource_provider())); |
1910 | 1892 |
1911 LayerTreeHostImpl::FrameData frame; | 1893 LayerTreeHostImpl::FrameData frame; |
1912 | 1894 |
1913 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 1895 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
1914 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 1896 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
1915 host_impl_->DidDrawAllLayers(frame); | 1897 host_impl_->DidDrawAllLayers(frame); |
1916 } | 1898 } |
1917 | 1899 |
1918 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithMissingTiles) { | 1900 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithMissingTiles) { |
1919 host_impl_->active_tree()->SetRootLayer( | 1901 host_impl_->active_tree()->SetRootLayer( |
1920 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); | 1902 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); |
1921 DidDrawCheckLayer* root = | 1903 DidDrawCheckLayer* root = |
1922 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 1904 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
1905 root->SetHasRenderSurface(true); | |
1923 | 1906 |
1924 bool tile_missing = true; | 1907 bool tile_missing = true; |
1925 bool had_incomplete_tile = false; | 1908 bool had_incomplete_tile = false; |
1926 bool is_animating = false; | 1909 bool is_animating = false; |
1927 root->AddChild( | 1910 root->AddChild( |
1928 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 1911 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
1929 4, | 1912 4, |
1930 tile_missing, | 1913 tile_missing, |
1931 had_incomplete_tile, | 1914 had_incomplete_tile, |
1932 is_animating, | 1915 is_animating, |
1933 host_impl_->resource_provider())); | 1916 host_impl_->resource_provider())); |
1934 LayerTreeHostImpl::FrameData frame; | 1917 LayerTreeHostImpl::FrameData frame; |
1935 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 1918 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
1936 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 1919 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
1937 host_impl_->DidDrawAllLayers(frame); | 1920 host_impl_->DidDrawAllLayers(frame); |
1938 } | 1921 } |
1939 | 1922 |
1940 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithIncompleteTile) { | 1923 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithIncompleteTile) { |
1941 host_impl_->active_tree()->SetRootLayer( | 1924 host_impl_->active_tree()->SetRootLayer( |
1942 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); | 1925 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); |
1943 DidDrawCheckLayer* root = | 1926 DidDrawCheckLayer* root = |
1944 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 1927 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
1928 root->SetHasRenderSurface(true); | |
1945 | 1929 |
1946 bool tile_missing = false; | 1930 bool tile_missing = false; |
1947 bool had_incomplete_tile = true; | 1931 bool had_incomplete_tile = true; |
1948 bool is_animating = false; | 1932 bool is_animating = false; |
1949 root->AddChild( | 1933 root->AddChild( |
1950 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 1934 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
1951 4, | 1935 4, |
1952 tile_missing, | 1936 tile_missing, |
1953 had_incomplete_tile, | 1937 had_incomplete_tile, |
1954 is_animating, | 1938 is_animating, |
1955 host_impl_->resource_provider())); | 1939 host_impl_->resource_provider())); |
1956 LayerTreeHostImpl::FrameData frame; | 1940 LayerTreeHostImpl::FrameData frame; |
1957 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 1941 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
1958 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 1942 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
1959 host_impl_->DidDrawAllLayers(frame); | 1943 host_impl_->DidDrawAllLayers(frame); |
1960 } | 1944 } |
1961 | 1945 |
1962 TEST_F(LayerTreeHostImplTest, | 1946 TEST_F(LayerTreeHostImplTest, |
1963 PrepareToDrawFailsWithAnimationAndMissingTilesUsesCheckerboard) { | 1947 PrepareToDrawFailsWithAnimationAndMissingTilesUsesCheckerboard) { |
1964 host_impl_->active_tree()->SetRootLayer( | 1948 host_impl_->active_tree()->SetRootLayer( |
1965 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); | 1949 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); |
1966 DidDrawCheckLayer* root = | 1950 DidDrawCheckLayer* root = |
1967 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 1951 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
1952 root->SetHasRenderSurface(true); | |
1968 bool tile_missing = true; | 1953 bool tile_missing = true; |
1969 bool had_incomplete_tile = false; | 1954 bool had_incomplete_tile = false; |
1970 bool is_animating = true; | 1955 bool is_animating = true; |
1971 root->AddChild( | 1956 root->AddChild( |
1972 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 1957 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
1973 6, | 1958 6, |
1974 tile_missing, | 1959 tile_missing, |
1975 had_incomplete_tile, | 1960 had_incomplete_tile, |
1976 is_animating, | 1961 is_animating, |
1977 host_impl_->resource_provider())); | 1962 host_impl_->resource_provider())); |
1978 LayerTreeHostImpl::FrameData frame; | 1963 LayerTreeHostImpl::FrameData frame; |
1979 EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS, | 1964 EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS, |
1980 host_impl_->PrepareToDraw(&frame)); | 1965 host_impl_->PrepareToDraw(&frame)); |
1981 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 1966 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
1982 host_impl_->DidDrawAllLayers(frame); | 1967 host_impl_->DidDrawAllLayers(frame); |
1983 } | 1968 } |
1984 | 1969 |
1985 TEST_F(LayerTreeHostImplTest, | 1970 TEST_F(LayerTreeHostImplTest, |
1986 PrepareToDrawSucceedsWithAnimationAndIncompleteTiles) { | 1971 PrepareToDrawSucceedsWithAnimationAndIncompleteTiles) { |
1987 host_impl_->active_tree()->SetRootLayer( | 1972 host_impl_->active_tree()->SetRootLayer( |
1988 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); | 1973 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); |
1989 DidDrawCheckLayer* root = | 1974 DidDrawCheckLayer* root = |
1990 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 1975 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
1976 root->SetHasRenderSurface(true); | |
1991 bool tile_missing = false; | 1977 bool tile_missing = false; |
1992 bool had_incomplete_tile = true; | 1978 bool had_incomplete_tile = true; |
1993 bool is_animating = true; | 1979 bool is_animating = true; |
1994 root->AddChild( | 1980 root->AddChild( |
1995 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 1981 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
1996 6, | 1982 6, |
1997 tile_missing, | 1983 tile_missing, |
1998 had_incomplete_tile, | 1984 had_incomplete_tile, |
1999 is_animating, | 1985 is_animating, |
2000 host_impl_->resource_provider())); | 1986 host_impl_->resource_provider())); |
2001 LayerTreeHostImpl::FrameData frame; | 1987 LayerTreeHostImpl::FrameData frame; |
2002 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 1988 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
2003 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 1989 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
2004 host_impl_->DidDrawAllLayers(frame); | 1990 host_impl_->DidDrawAllLayers(frame); |
2005 } | 1991 } |
2006 | 1992 |
2007 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWhenHighResRequired) { | 1993 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWhenHighResRequired) { |
2008 host_impl_->active_tree()->SetRootLayer( | 1994 host_impl_->active_tree()->SetRootLayer( |
2009 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); | 1995 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); |
2010 DidDrawCheckLayer* root = | 1996 DidDrawCheckLayer* root = |
2011 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 1997 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
1998 root->SetHasRenderSurface(true); | |
2012 bool tile_missing = false; | 1999 bool tile_missing = false; |
2013 bool had_incomplete_tile = false; | 2000 bool had_incomplete_tile = false; |
2014 bool is_animating = false; | 2001 bool is_animating = false; |
2015 root->AddChild( | 2002 root->AddChild( |
2016 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 2003 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
2017 8, | 2004 8, |
2018 tile_missing, | 2005 tile_missing, |
2019 had_incomplete_tile, | 2006 had_incomplete_tile, |
2020 is_animating, | 2007 is_animating, |
2021 host_impl_->resource_provider())); | 2008 host_impl_->resource_provider())); |
2022 host_impl_->active_tree()->SetRequiresHighResToDraw(); | 2009 host_impl_->active_tree()->SetRequiresHighResToDraw(); |
2023 LayerTreeHostImpl::FrameData frame; | 2010 LayerTreeHostImpl::FrameData frame; |
2024 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2011 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
2025 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2012 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
2026 host_impl_->DidDrawAllLayers(frame); | 2013 host_impl_->DidDrawAllLayers(frame); |
2027 } | 2014 } |
2028 | 2015 |
2029 TEST_F(LayerTreeHostImplTest, | 2016 TEST_F(LayerTreeHostImplTest, |
2030 PrepareToDrawFailsWhenHighResRequiredAndIncompleteTiles) { | 2017 PrepareToDrawFailsWhenHighResRequiredAndIncompleteTiles) { |
2031 host_impl_->active_tree()->SetRootLayer( | 2018 host_impl_->active_tree()->SetRootLayer( |
2032 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); | 2019 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); |
2033 DidDrawCheckLayer* root = | 2020 DidDrawCheckLayer* root = |
2034 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2021 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
2022 root->SetHasRenderSurface(true); | |
2035 bool tile_missing = false; | 2023 bool tile_missing = false; |
2036 bool had_incomplete_tile = true; | 2024 bool had_incomplete_tile = true; |
2037 bool is_animating = false; | 2025 bool is_animating = false; |
2038 root->AddChild( | 2026 root->AddChild( |
2039 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 2027 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
2040 8, | 2028 8, |
2041 tile_missing, | 2029 tile_missing, |
2042 had_incomplete_tile, | 2030 had_incomplete_tile, |
2043 is_animating, | 2031 is_animating, |
2044 host_impl_->resource_provider())); | 2032 host_impl_->resource_provider())); |
2045 host_impl_->active_tree()->SetRequiresHighResToDraw(); | 2033 host_impl_->active_tree()->SetRequiresHighResToDraw(); |
2046 LayerTreeHostImpl::FrameData frame; | 2034 LayerTreeHostImpl::FrameData frame; |
2047 EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT, | 2035 EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT, |
2048 host_impl_->PrepareToDraw(&frame)); | 2036 host_impl_->PrepareToDraw(&frame)); |
2049 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2037 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
2050 host_impl_->DidDrawAllLayers(frame); | 2038 host_impl_->DidDrawAllLayers(frame); |
2051 } | 2039 } |
2052 | 2040 |
2053 TEST_F(LayerTreeHostImplTest, | 2041 TEST_F(LayerTreeHostImplTest, |
2054 PrepareToDrawFailsWhenHighResRequiredAndMissingTile) { | 2042 PrepareToDrawFailsWhenHighResRequiredAndMissingTile) { |
2055 host_impl_->active_tree()->SetRootLayer( | 2043 host_impl_->active_tree()->SetRootLayer( |
2056 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); | 2044 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); |
2057 DidDrawCheckLayer* root = | 2045 DidDrawCheckLayer* root = |
2058 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2046 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
2047 root->SetHasRenderSurface(true); | |
2059 bool tile_missing = true; | 2048 bool tile_missing = true; |
2060 bool had_incomplete_tile = false; | 2049 bool had_incomplete_tile = false; |
2061 bool is_animating = false; | 2050 bool is_animating = false; |
2062 root->AddChild( | 2051 root->AddChild( |
2063 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 2052 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
2064 8, | 2053 8, |
2065 tile_missing, | 2054 tile_missing, |
2066 had_incomplete_tile, | 2055 had_incomplete_tile, |
2067 is_animating, | 2056 is_animating, |
2068 host_impl_->resource_provider())); | 2057 host_impl_->resource_provider())); |
2069 host_impl_->active_tree()->SetRequiresHighResToDraw(); | 2058 host_impl_->active_tree()->SetRequiresHighResToDraw(); |
2070 LayerTreeHostImpl::FrameData frame; | 2059 LayerTreeHostImpl::FrameData frame; |
2071 EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT, | 2060 EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT, |
2072 host_impl_->PrepareToDraw(&frame)); | 2061 host_impl_->PrepareToDraw(&frame)); |
2073 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2062 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
2074 host_impl_->DidDrawAllLayers(frame); | 2063 host_impl_->DidDrawAllLayers(frame); |
2075 } | 2064 } |
2076 | 2065 |
2077 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { | 2066 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { |
2078 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 2067 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
2079 root->SetScrollClipLayer(Layer::INVALID_ID); | 2068 root->SetScrollClipLayer(Layer::INVALID_ID); |
2069 root->SetHasRenderSurface(true); | |
2080 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 2070 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
2081 DrawFrame(); | 2071 DrawFrame(); |
2082 | 2072 |
2083 // Scroll event is ignored because layer is not scrollable. | 2073 // Scroll event is ignored because layer is not scrollable. |
2084 EXPECT_EQ(InputHandler::ScrollIgnored, | 2074 EXPECT_EQ(InputHandler::ScrollIgnored, |
2085 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); | 2075 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
2086 EXPECT_FALSE(did_request_redraw_); | 2076 EXPECT_FALSE(did_request_redraw_); |
2087 EXPECT_FALSE(did_request_commit_); | 2077 EXPECT_FALSE(did_request_commit_); |
2088 } | 2078 } |
2089 | 2079 |
(...skipping 22 matching lines...) Expand all Loading... | |
2112 root_clip->SetBounds(clip_size_); | 2102 root_clip->SetBounds(clip_size_); |
2113 root->SetScrollClipLayer(root_clip->id()); | 2103 root->SetScrollClipLayer(root_clip->id()); |
2114 root->SetBounds(layer_size_); | 2104 root->SetBounds(layer_size_); |
2115 root->SetContentBounds(layer_size_); | 2105 root->SetContentBounds(layer_size_); |
2116 root->SetPosition(gfx::PointF()); | 2106 root->SetPosition(gfx::PointF()); |
2117 root->SetDrawsContent(false); | 2107 root->SetDrawsContent(false); |
2118 root->SetIsContainerForFixedPositionLayers(true); | 2108 root->SetIsContainerForFixedPositionLayers(true); |
2119 int inner_viewport_scroll_layer_id = root->id(); | 2109 int inner_viewport_scroll_layer_id = root->id(); |
2120 int page_scale_layer_id = root_clip->id(); | 2110 int page_scale_layer_id = root_clip->id(); |
2121 root_clip->AddChild(root.Pass()); | 2111 root_clip->AddChild(root.Pass()); |
2112 root_clip->SetHasRenderSurface(true); | |
2122 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 2113 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); |
2123 host_impl_->active_tree()->SetViewportLayersFromIds( | 2114 host_impl_->active_tree()->SetViewportLayersFromIds( |
2124 page_scale_layer_id, inner_viewport_scroll_layer_id, Layer::INVALID_ID); | 2115 page_scale_layer_id, inner_viewport_scroll_layer_id, Layer::INVALID_ID); |
2125 // Set a viewport size that is large enough to contain both the top controls | 2116 // Set a viewport size that is large enough to contain both the top controls |
2126 // and some content. | 2117 // and some content. |
2127 host_impl_->SetViewportSize(viewport_size_); | 2118 host_impl_->SetViewportSize(viewport_size_); |
2128 host_impl_->SetTopControlsLayoutHeight(settings_.top_controls_height); | 2119 host_impl_->SetTopControlsLayoutHeight(settings_.top_controls_height); |
2129 LayerImpl* root_clip_ptr = host_impl_->active_tree()->root_layer(); | 2120 LayerImpl* root_clip_ptr = host_impl_->active_tree()->root_layer(); |
2130 EXPECT_EQ(clip_size_, root_clip_ptr->bounds()); | 2121 EXPECT_EQ(clip_size_, root_clip_ptr->bounds()); |
2131 } | 2122 } |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2263 | 2254 |
2264 scoped_ptr<LayerImpl> scroll_layer = | 2255 scoped_ptr<LayerImpl> scroll_layer = |
2265 LayerImpl::Create(host_impl_->active_tree(), 2); | 2256 LayerImpl::Create(host_impl_->active_tree(), 2); |
2266 scroll_layer->SetScrollClipLayer(3); | 2257 scroll_layer->SetScrollClipLayer(3); |
2267 scroll_layer->SetBounds(contents_size); | 2258 scroll_layer->SetBounds(contents_size); |
2268 scroll_layer->SetContentBounds(contents_size); | 2259 scroll_layer->SetContentBounds(contents_size); |
2269 scroll_layer->SetPosition(gfx::PointF()); | 2260 scroll_layer->SetPosition(gfx::PointF()); |
2270 scroll_layer->AddChild(content_layer.Pass()); | 2261 scroll_layer->AddChild(content_layer.Pass()); |
2271 scroll_clip_layer->AddChild(scroll_layer.Pass()); | 2262 scroll_clip_layer->AddChild(scroll_layer.Pass()); |
2272 | 2263 |
2264 scroll_clip_layer->SetHasRenderSurface(true); | |
2273 host_impl_->active_tree()->SetRootLayer(scroll_clip_layer.Pass()); | 2265 host_impl_->active_tree()->SetRootLayer(scroll_clip_layer.Pass()); |
2274 host_impl_->SetViewportSize(surface_size); | 2266 host_impl_->SetViewportSize(surface_size); |
2275 DrawFrame(); | 2267 DrawFrame(); |
2276 | 2268 |
2277 EXPECT_EQ(InputHandler::ScrollStarted, | 2269 EXPECT_EQ(InputHandler::ScrollStarted, |
2278 host_impl_->ScrollBegin(gfx::Point(5, 5), | 2270 host_impl_->ScrollBegin(gfx::Point(5, 5), |
2279 InputHandler::Wheel)); | 2271 InputHandler::Wheel)); |
2280 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 2272 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
2281 host_impl_->ScrollEnd(); | 2273 host_impl_->ScrollEnd(); |
2282 EXPECT_TRUE(did_request_redraw_); | 2274 EXPECT_TRUE(did_request_redraw_); |
2283 EXPECT_TRUE(did_request_commit_); | 2275 EXPECT_TRUE(did_request_commit_); |
2284 } | 2276 } |
2285 | 2277 |
2286 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) { | 2278 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) { |
2287 gfx::Size surface_size(10, 10); | 2279 gfx::Size surface_size(10, 10); |
2288 gfx::Size contents_size(20, 20); | 2280 gfx::Size contents_size(20, 20); |
2289 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 2281 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
2290 root->SetBounds(surface_size); | 2282 root->SetBounds(surface_size); |
2291 root->SetContentBounds(contents_size); | 2283 root->SetContentBounds(contents_size); |
2292 root->AddChild(CreateScrollableLayer(2, contents_size, root.get())); | 2284 root->AddChild(CreateScrollableLayer(2, contents_size, root.get())); |
2285 root->SetHasRenderSurface(true); | |
2293 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 2286 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
2294 host_impl_->SetViewportSize(surface_size); | 2287 host_impl_->SetViewportSize(surface_size); |
2295 DrawFrame(); | 2288 DrawFrame(); |
2296 | 2289 |
2297 EXPECT_EQ(InputHandler::ScrollStarted, | 2290 EXPECT_EQ(InputHandler::ScrollStarted, |
2298 host_impl_->ScrollBegin(gfx::Point(5, 5), | 2291 host_impl_->ScrollBegin(gfx::Point(5, 5), |
2299 InputHandler::Wheel)); | 2292 InputHandler::Wheel)); |
2300 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 2293 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
2301 host_impl_->ScrollEnd(); | 2294 host_impl_->ScrollEnd(); |
2302 EXPECT_TRUE(did_request_redraw_); | 2295 EXPECT_TRUE(did_request_redraw_); |
2303 EXPECT_TRUE(did_request_commit_); | 2296 EXPECT_TRUE(did_request_commit_); |
2304 } | 2297 } |
2305 | 2298 |
2306 TEST_F(LayerTreeHostImplTest, ScrollMissesChild) { | 2299 TEST_F(LayerTreeHostImplTest, ScrollMissesChild) { |
2307 gfx::Size surface_size(10, 10); | 2300 gfx::Size surface_size(10, 10); |
2308 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 2301 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
2309 root->AddChild(CreateScrollableLayer(2, surface_size, root.get())); | 2302 root->AddChild(CreateScrollableLayer(2, surface_size, root.get())); |
2303 root->SetHasRenderSurface(true); | |
2310 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 2304 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
2311 host_impl_->SetViewportSize(surface_size); | 2305 host_impl_->SetViewportSize(surface_size); |
2312 DrawFrame(); | 2306 DrawFrame(); |
2313 | 2307 |
2314 // Scroll event is ignored because the input coordinate is outside the layer | 2308 // Scroll event is ignored because the input coordinate is outside the layer |
2315 // boundaries. | 2309 // boundaries. |
2316 EXPECT_EQ(InputHandler::ScrollIgnored, | 2310 EXPECT_EQ(InputHandler::ScrollIgnored, |
2317 host_impl_->ScrollBegin(gfx::Point(15, 5), | 2311 host_impl_->ScrollBegin(gfx::Point(15, 5), |
2318 InputHandler::Wheel)); | 2312 InputHandler::Wheel)); |
2319 EXPECT_FALSE(did_request_redraw_); | 2313 EXPECT_FALSE(did_request_redraw_); |
2320 EXPECT_FALSE(did_request_commit_); | 2314 EXPECT_FALSE(did_request_commit_); |
2321 } | 2315 } |
2322 | 2316 |
2323 TEST_F(LayerTreeHostImplTest, ScrollMissesBackfacingChild) { | 2317 TEST_F(LayerTreeHostImplTest, ScrollMissesBackfacingChild) { |
2324 gfx::Size surface_size(10, 10); | 2318 gfx::Size surface_size(10, 10); |
2325 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 2319 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
2320 root->SetHasRenderSurface(true); | |
2326 scoped_ptr<LayerImpl> child = | 2321 scoped_ptr<LayerImpl> child = |
2327 CreateScrollableLayer(2, surface_size, root.get()); | 2322 CreateScrollableLayer(2, surface_size, root.get()); |
2328 host_impl_->SetViewportSize(surface_size); | 2323 host_impl_->SetViewportSize(surface_size); |
2329 | 2324 |
2330 gfx::Transform matrix; | 2325 gfx::Transform matrix; |
2331 matrix.RotateAboutXAxis(180.0); | 2326 matrix.RotateAboutXAxis(180.0); |
2332 child->SetTransform(matrix); | 2327 child->SetTransform(matrix); |
2333 child->SetDoubleSided(false); | 2328 child->SetDoubleSided(false); |
2334 | 2329 |
2335 root->AddChild(child.Pass()); | 2330 root->AddChild(child.Pass()); |
(...skipping 17 matching lines...) Expand all Loading... | |
2353 CreateScrollableLayer(1, surface_size, clip_layer.get()); | 2348 CreateScrollableLayer(1, surface_size, clip_layer.get()); |
2354 content_layer->SetShouldScrollOnMainThread(true); | 2349 content_layer->SetShouldScrollOnMainThread(true); |
2355 content_layer->SetScrollClipLayer(Layer::INVALID_ID); | 2350 content_layer->SetScrollClipLayer(Layer::INVALID_ID); |
2356 | 2351 |
2357 // Note: we can use the same clip layer for both since both calls to | 2352 // Note: we can use the same clip layer for both since both calls to |
2358 // CreateScrollableLayer() use the same surface size. | 2353 // CreateScrollableLayer() use the same surface size. |
2359 scoped_ptr<LayerImpl> scroll_layer = | 2354 scoped_ptr<LayerImpl> scroll_layer = |
2360 CreateScrollableLayer(2, surface_size, clip_layer.get()); | 2355 CreateScrollableLayer(2, surface_size, clip_layer.get()); |
2361 scroll_layer->AddChild(content_layer.Pass()); | 2356 scroll_layer->AddChild(content_layer.Pass()); |
2362 clip_layer->AddChild(scroll_layer.Pass()); | 2357 clip_layer->AddChild(scroll_layer.Pass()); |
2358 clip_layer->SetHasRenderSurface(true); | |
2363 | 2359 |
2364 host_impl_->active_tree()->SetRootLayer(clip_layer.Pass()); | 2360 host_impl_->active_tree()->SetRootLayer(clip_layer.Pass()); |
2365 host_impl_->SetViewportSize(surface_size); | 2361 host_impl_->SetViewportSize(surface_size); |
2366 DrawFrame(); | 2362 DrawFrame(); |
2367 | 2363 |
2368 // Scrolling fails because the content layer is asking to be scrolled on the | 2364 // Scrolling fails because the content layer is asking to be scrolled on the |
2369 // main thread. | 2365 // main thread. |
2370 EXPECT_EQ(InputHandler::ScrollOnMainThread, | 2366 EXPECT_EQ(InputHandler::ScrollOnMainThread, |
2371 host_impl_->ScrollBegin(gfx::Point(5, 5), | 2367 host_impl_->ScrollBegin(gfx::Point(5, 5), |
2372 InputHandler::Wheel)); | 2368 InputHandler::Wheel)); |
2373 } | 2369 } |
2374 | 2370 |
2375 TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnMainThread) { | 2371 TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnMainThread) { |
2376 gfx::Size surface_size(20, 20); | 2372 gfx::Size surface_size(20, 20); |
2377 gfx::Size viewport_size(10, 10); | 2373 gfx::Size viewport_size(10, 10); |
2378 float page_scale = 2.f; | 2374 float page_scale = 2.f; |
2379 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 2375 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
2380 scoped_ptr<LayerImpl> root_clip = | 2376 scoped_ptr<LayerImpl> root_clip = |
2381 LayerImpl::Create(host_impl_->active_tree(), 2); | 2377 LayerImpl::Create(host_impl_->active_tree(), 2); |
2382 scoped_ptr<LayerImpl> root_scrolling = | 2378 scoped_ptr<LayerImpl> root_scrolling = |
2383 CreateScrollableLayer(3, surface_size, root_clip.get()); | 2379 CreateScrollableLayer(3, surface_size, root_clip.get()); |
2384 EXPECT_EQ(viewport_size, root_clip->bounds()); | 2380 EXPECT_EQ(viewport_size, root_clip->bounds()); |
2385 root_scrolling->SetIsContainerForFixedPositionLayers(true); | 2381 root_scrolling->SetIsContainerForFixedPositionLayers(true); |
2386 root_clip->AddChild(root_scrolling.Pass()); | 2382 root_clip->AddChild(root_scrolling.Pass()); |
2387 root->AddChild(root_clip.Pass()); | 2383 root->AddChild(root_clip.Pass()); |
2384 root->SetHasRenderSurface(true); | |
2388 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 2385 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
2389 // The behaviour in this test assumes the page scale is applied at a layer | 2386 // The behaviour in this test assumes the page scale is applied at a layer |
2390 // above the clip layer. | 2387 // above the clip layer. |
2391 host_impl_->active_tree()->SetViewportLayersFromIds(1, 3, Layer::INVALID_ID); | 2388 host_impl_->active_tree()->SetViewportLayersFromIds(1, 3, Layer::INVALID_ID); |
2392 host_impl_->active_tree()->DidBecomeActive(); | 2389 host_impl_->active_tree()->DidBecomeActive(); |
2393 host_impl_->SetViewportSize(viewport_size); | 2390 host_impl_->SetViewportSize(viewport_size); |
2394 DrawFrame(); | 2391 DrawFrame(); |
2395 | 2392 |
2396 LayerImpl* root_scroll = | 2393 LayerImpl* root_scroll = |
2397 host_impl_->active_tree()->InnerViewportScrollLayer(); | 2394 host_impl_->active_tree()->InnerViewportScrollLayer(); |
(...skipping 30 matching lines...) Expand all Loading... | |
2428 float page_scale = 2.f; | 2425 float page_scale = 2.f; |
2429 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 2426 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
2430 scoped_ptr<LayerImpl> root_clip = | 2427 scoped_ptr<LayerImpl> root_clip = |
2431 LayerImpl::Create(host_impl_->active_tree(), 2); | 2428 LayerImpl::Create(host_impl_->active_tree(), 2); |
2432 scoped_ptr<LayerImpl> root_scrolling = | 2429 scoped_ptr<LayerImpl> root_scrolling = |
2433 CreateScrollableLayer(3, surface_size, root_clip.get()); | 2430 CreateScrollableLayer(3, surface_size, root_clip.get()); |
2434 EXPECT_EQ(viewport_size, root_clip->bounds()); | 2431 EXPECT_EQ(viewport_size, root_clip->bounds()); |
2435 root_scrolling->SetIsContainerForFixedPositionLayers(true); | 2432 root_scrolling->SetIsContainerForFixedPositionLayers(true); |
2436 root_clip->AddChild(root_scrolling.Pass()); | 2433 root_clip->AddChild(root_scrolling.Pass()); |
2437 root->AddChild(root_clip.Pass()); | 2434 root->AddChild(root_clip.Pass()); |
2435 root->SetHasRenderSurface(true); | |
2438 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 2436 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
2439 // The behaviour in this test assumes the page scale is applied at a layer | 2437 // The behaviour in this test assumes the page scale is applied at a layer |
2440 // above the clip layer. | 2438 // above the clip layer. |
2441 host_impl_->active_tree()->SetViewportLayersFromIds(1, 3, Layer::INVALID_ID); | 2439 host_impl_->active_tree()->SetViewportLayersFromIds(1, 3, Layer::INVALID_ID); |
2442 host_impl_->active_tree()->DidBecomeActive(); | 2440 host_impl_->active_tree()->DidBecomeActive(); |
2443 host_impl_->SetViewportSize(viewport_size); | 2441 host_impl_->SetViewportSize(viewport_size); |
2444 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 1.f, page_scale); | 2442 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 1.f, page_scale); |
2445 DrawFrame(); | 2443 DrawFrame(); |
2446 | 2444 |
2447 LayerImpl* root_scroll = | 2445 LayerImpl* root_scroll = |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2532 EXPECT_EQ(new_page_scale, | 2530 EXPECT_EQ(new_page_scale, |
2533 grand_child->draw_transform().matrix().getDouble(0, 0)); | 2531 grand_child->draw_transform().matrix().getDouble(0, 0)); |
2534 EXPECT_EQ(new_page_scale, | 2532 EXPECT_EQ(new_page_scale, |
2535 grand_child->draw_transform().matrix().getDouble(1, 1)); | 2533 grand_child->draw_transform().matrix().getDouble(1, 1)); |
2536 } | 2534 } |
2537 | 2535 |
2538 TEST_F(LayerTreeHostImplTest, ScrollChildAndChangePageScaleOnMainThread) { | 2536 TEST_F(LayerTreeHostImplTest, ScrollChildAndChangePageScaleOnMainThread) { |
2539 gfx::Size surface_size(30, 30); | 2537 gfx::Size surface_size(30, 30); |
2540 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 2538 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
2541 root->SetBounds(gfx::Size(5, 5)); | 2539 root->SetBounds(gfx::Size(5, 5)); |
2540 root->SetHasRenderSurface(true); | |
2542 scoped_ptr<LayerImpl> root_scrolling = | 2541 scoped_ptr<LayerImpl> root_scrolling = |
2543 LayerImpl::Create(host_impl_->active_tree(), 2); | 2542 LayerImpl::Create(host_impl_->active_tree(), 2); |
2544 root_scrolling->SetBounds(surface_size); | 2543 root_scrolling->SetBounds(surface_size); |
2545 root_scrolling->SetContentBounds(surface_size); | 2544 root_scrolling->SetContentBounds(surface_size); |
2546 root_scrolling->SetScrollClipLayer(root->id()); | 2545 root_scrolling->SetScrollClipLayer(root->id()); |
2547 root_scrolling->SetIsContainerForFixedPositionLayers(true); | 2546 root_scrolling->SetIsContainerForFixedPositionLayers(true); |
2548 LayerImpl* root_scrolling_ptr = root_scrolling.get(); | 2547 LayerImpl* root_scrolling_ptr = root_scrolling.get(); |
2549 root->AddChild(root_scrolling.Pass()); | 2548 root->AddChild(root_scrolling.Pass()); |
2550 int child_scroll_layer_id = 3; | 2549 int child_scroll_layer_id = 3; |
2551 scoped_ptr<LayerImpl> child_scrolling = CreateScrollableLayer( | 2550 scoped_ptr<LayerImpl> child_scrolling = CreateScrollableLayer( |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2587 } | 2586 } |
2588 | 2587 |
2589 TEST_F(LayerTreeHostImplTest, ScrollChildBeyondLimit) { | 2588 TEST_F(LayerTreeHostImplTest, ScrollChildBeyondLimit) { |
2590 // Scroll a child layer beyond its maximum scroll range and make sure the | 2589 // Scroll a child layer beyond its maximum scroll range and make sure the |
2591 // parent layer is scrolled on the axis on which the child was unable to | 2590 // parent layer is scrolled on the axis on which the child was unable to |
2592 // scroll. | 2591 // scroll. |
2593 gfx::Size surface_size(10, 10); | 2592 gfx::Size surface_size(10, 10); |
2594 gfx::Size content_size(20, 20); | 2593 gfx::Size content_size(20, 20); |
2595 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 2594 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
2596 root->SetBounds(surface_size); | 2595 root->SetBounds(surface_size); |
2597 | 2596 root->SetHasRenderSurface(true); |
2598 scoped_ptr<LayerImpl> grand_child = | 2597 scoped_ptr<LayerImpl> grand_child = |
2599 CreateScrollableLayer(3, content_size, root.get()); | 2598 CreateScrollableLayer(3, content_size, root.get()); |
2600 | 2599 |
2601 scoped_ptr<LayerImpl> child = | 2600 scoped_ptr<LayerImpl> child = |
2602 CreateScrollableLayer(2, content_size, root.get()); | 2601 CreateScrollableLayer(2, content_size, root.get()); |
2603 LayerImpl* grand_child_layer = grand_child.get(); | 2602 LayerImpl* grand_child_layer = grand_child.get(); |
2604 child->AddChild(grand_child.Pass()); | 2603 child->AddChild(grand_child.Pass()); |
2605 | 2604 |
2606 LayerImpl* child_layer = child.get(); | 2605 LayerImpl* child_layer = child.get(); |
2607 root->AddChild(child.Pass()); | 2606 root->AddChild(child.Pass()); |
(...skipping 24 matching lines...) Expand all Loading... | |
2632 ExpectContains(*scroll_info.get(), child->id(), gfx::Vector2d(-3, 0)); | 2631 ExpectContains(*scroll_info.get(), child->id(), gfx::Vector2d(-3, 0)); |
2633 } | 2632 } |
2634 } | 2633 } |
2635 | 2634 |
2636 TEST_F(LayerTreeHostImplTest, ScrollWithoutBubbling) { | 2635 TEST_F(LayerTreeHostImplTest, ScrollWithoutBubbling) { |
2637 // Scroll a child layer beyond its maximum scroll range and make sure the | 2636 // Scroll a child layer beyond its maximum scroll range and make sure the |
2638 // the scroll doesn't bubble up to the parent layer. | 2637 // the scroll doesn't bubble up to the parent layer. |
2639 gfx::Size surface_size(20, 20); | 2638 gfx::Size surface_size(20, 20); |
2640 gfx::Size viewport_size(10, 10); | 2639 gfx::Size viewport_size(10, 10); |
2641 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 2640 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
2641 root->SetHasRenderSurface(true); | |
2642 scoped_ptr<LayerImpl> root_scrolling = | 2642 scoped_ptr<LayerImpl> root_scrolling = |
2643 CreateScrollableLayer(2, surface_size, root.get()); | 2643 CreateScrollableLayer(2, surface_size, root.get()); |
2644 root_scrolling->SetIsContainerForFixedPositionLayers(true); | 2644 root_scrolling->SetIsContainerForFixedPositionLayers(true); |
2645 | 2645 |
2646 scoped_ptr<LayerImpl> grand_child = | 2646 scoped_ptr<LayerImpl> grand_child = |
2647 CreateScrollableLayer(4, surface_size, root.get()); | 2647 CreateScrollableLayer(4, surface_size, root.get()); |
2648 | 2648 |
2649 scoped_ptr<LayerImpl> child = | 2649 scoped_ptr<LayerImpl> child = |
2650 CreateScrollableLayer(3, surface_size, root.get()); | 2650 CreateScrollableLayer(3, surface_size, root.get()); |
2651 LayerImpl* grand_child_layer = grand_child.get(); | 2651 LayerImpl* grand_child_layer = grand_child.get(); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2740 ExpectContains(*scroll_info.get(), grand_child->id(), gfx::Vector2d(0, 4)); | 2740 ExpectContains(*scroll_info.get(), grand_child->id(), gfx::Vector2d(0, 4)); |
2741 } | 2741 } |
2742 } | 2742 } |
2743 TEST_F(LayerTreeHostImplTest, ScrollEventBubbling) { | 2743 TEST_F(LayerTreeHostImplTest, ScrollEventBubbling) { |
2744 // When we try to scroll a non-scrollable child layer, the scroll delta | 2744 // When we try to scroll a non-scrollable child layer, the scroll delta |
2745 // should be applied to one of its ancestors if possible. | 2745 // should be applied to one of its ancestors if possible. |
2746 gfx::Size surface_size(10, 10); | 2746 gfx::Size surface_size(10, 10); |
2747 gfx::Size content_size(20, 20); | 2747 gfx::Size content_size(20, 20); |
2748 scoped_ptr<LayerImpl> root_clip = | 2748 scoped_ptr<LayerImpl> root_clip = |
2749 LayerImpl::Create(host_impl_->active_tree(), 3); | 2749 LayerImpl::Create(host_impl_->active_tree(), 3); |
2750 root_clip->SetHasRenderSurface(true); | |
2750 scoped_ptr<LayerImpl> root = | 2751 scoped_ptr<LayerImpl> root = |
2751 CreateScrollableLayer(1, content_size, root_clip.get()); | 2752 CreateScrollableLayer(1, content_size, root_clip.get()); |
2752 // Make 'root' the clip layer for child: since they have the same sizes the | 2753 // Make 'root' the clip layer for child: since they have the same sizes the |
2753 // child will have zero max_scroll_offset and scrolls will bubble. | 2754 // child will have zero max_scroll_offset and scrolls will bubble. |
2754 scoped_ptr<LayerImpl> child = | 2755 scoped_ptr<LayerImpl> child = |
2755 CreateScrollableLayer(2, content_size, root.get()); | 2756 CreateScrollableLayer(2, content_size, root.get()); |
2756 child->SetIsContainerForFixedPositionLayers(true); | 2757 child->SetIsContainerForFixedPositionLayers(true); |
2757 root->SetBounds(content_size); | 2758 root->SetBounds(content_size); |
2758 | 2759 |
2759 int root_scroll_id = root->id(); | 2760 int root_scroll_id = root->id(); |
(...skipping 22 matching lines...) Expand all Loading... | |
2782 } | 2783 } |
2783 } | 2784 } |
2784 | 2785 |
2785 TEST_F(LayerTreeHostImplTest, ScrollBeforeRedraw) { | 2786 TEST_F(LayerTreeHostImplTest, ScrollBeforeRedraw) { |
2786 gfx::Size surface_size(10, 10); | 2787 gfx::Size surface_size(10, 10); |
2787 scoped_ptr<LayerImpl> root_clip = | 2788 scoped_ptr<LayerImpl> root_clip = |
2788 LayerImpl::Create(host_impl_->active_tree(), 1); | 2789 LayerImpl::Create(host_impl_->active_tree(), 1); |
2789 scoped_ptr<LayerImpl> root_scroll = | 2790 scoped_ptr<LayerImpl> root_scroll = |
2790 CreateScrollableLayer(2, surface_size, root_clip.get()); | 2791 CreateScrollableLayer(2, surface_size, root_clip.get()); |
2791 root_scroll->SetIsContainerForFixedPositionLayers(true); | 2792 root_scroll->SetIsContainerForFixedPositionLayers(true); |
2793 root_clip->SetHasRenderSurface(true); | |
2792 root_clip->AddChild(root_scroll.Pass()); | 2794 root_clip->AddChild(root_scroll.Pass()); |
2793 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 2795 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); |
2794 host_impl_->active_tree()->SetViewportLayersFromIds(1, 2, Layer::INVALID_ID); | 2796 host_impl_->active_tree()->SetViewportLayersFromIds(1, 2, Layer::INVALID_ID); |
2795 host_impl_->active_tree()->DidBecomeActive(); | 2797 host_impl_->active_tree()->DidBecomeActive(); |
2796 host_impl_->SetViewportSize(surface_size); | 2798 host_impl_->SetViewportSize(surface_size); |
2797 | 2799 |
2798 // Draw one frame and then immediately rebuild the layer tree to mimic a tree | 2800 // Draw one frame and then immediately rebuild the layer tree to mimic a tree |
2799 // synchronization. | 2801 // synchronization. |
2800 DrawFrame(); | 2802 DrawFrame(); |
2801 host_impl_->active_tree()->DetachLayerTree(); | 2803 host_impl_->active_tree()->DetachLayerTree(); |
2802 scoped_ptr<LayerImpl> root_clip2 = | 2804 scoped_ptr<LayerImpl> root_clip2 = |
2803 LayerImpl::Create(host_impl_->active_tree(), 3); | 2805 LayerImpl::Create(host_impl_->active_tree(), 3); |
2804 scoped_ptr<LayerImpl> root_scroll2 = | 2806 scoped_ptr<LayerImpl> root_scroll2 = |
2805 CreateScrollableLayer(4, surface_size, root_clip2.get()); | 2807 CreateScrollableLayer(4, surface_size, root_clip2.get()); |
2806 root_scroll2->SetIsContainerForFixedPositionLayers(true); | 2808 root_scroll2->SetIsContainerForFixedPositionLayers(true); |
2807 root_clip2->AddChild(root_scroll2.Pass()); | 2809 root_clip2->AddChild(root_scroll2.Pass()); |
2810 root_clip2->SetHasRenderSurface(true); | |
2808 host_impl_->active_tree()->SetRootLayer(root_clip2.Pass()); | 2811 host_impl_->active_tree()->SetRootLayer(root_clip2.Pass()); |
2809 host_impl_->active_tree()->SetViewportLayersFromIds(3, 4, Layer::INVALID_ID); | 2812 host_impl_->active_tree()->SetViewportLayersFromIds(3, 4, Layer::INVALID_ID); |
2810 host_impl_->active_tree()->DidBecomeActive(); | 2813 host_impl_->active_tree()->DidBecomeActive(); |
2811 | 2814 |
2812 // Scrolling should still work even though we did not draw yet. | 2815 // Scrolling should still work even though we did not draw yet. |
2813 EXPECT_EQ(InputHandler::ScrollStarted, | 2816 EXPECT_EQ(InputHandler::ScrollStarted, |
2814 host_impl_->ScrollBegin(gfx::Point(5, 5), | 2817 host_impl_->ScrollBegin(gfx::Point(5, 5), |
2815 InputHandler::Wheel)); | 2818 InputHandler::Wheel)); |
2816 } | 2819 } |
2817 | 2820 |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3239 host_impl_->ScrollEnd(); | 3242 host_impl_->ScrollEnd(); |
3240 } | 3243 } |
3241 | 3244 |
3242 | 3245 |
3243 TEST_F(LayerTreeHostImplTest, OverscrollChildWithoutBubbling) { | 3246 TEST_F(LayerTreeHostImplTest, OverscrollChildWithoutBubbling) { |
3244 // Scroll child layers beyond their maximum scroll range and make sure root | 3247 // Scroll child layers beyond their maximum scroll range and make sure root |
3245 // overscroll does not accumulate. | 3248 // overscroll does not accumulate. |
3246 gfx::Size surface_size(10, 10); | 3249 gfx::Size surface_size(10, 10); |
3247 scoped_ptr<LayerImpl> root_clip = | 3250 scoped_ptr<LayerImpl> root_clip = |
3248 LayerImpl::Create(host_impl_->active_tree(), 4); | 3251 LayerImpl::Create(host_impl_->active_tree(), 4); |
3252 root_clip->SetHasRenderSurface(true); | |
3253 | |
3249 scoped_ptr<LayerImpl> root = | 3254 scoped_ptr<LayerImpl> root = |
3250 CreateScrollableLayer(1, surface_size, root_clip.get()); | 3255 CreateScrollableLayer(1, surface_size, root_clip.get()); |
3251 | 3256 |
3252 scoped_ptr<LayerImpl> grand_child = | 3257 scoped_ptr<LayerImpl> grand_child = |
3253 CreateScrollableLayer(3, surface_size, root_clip.get()); | 3258 CreateScrollableLayer(3, surface_size, root_clip.get()); |
3254 | 3259 |
3255 scoped_ptr<LayerImpl> child = | 3260 scoped_ptr<LayerImpl> child = |
3256 CreateScrollableLayer(2, surface_size, root_clip.get()); | 3261 CreateScrollableLayer(2, surface_size, root_clip.get()); |
3257 LayerImpl* grand_child_layer = grand_child.get(); | 3262 LayerImpl* grand_child_layer = grand_child.get(); |
3258 child->AddChild(grand_child.Pass()); | 3263 child->AddChild(grand_child.Pass()); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3303 } | 3308 } |
3304 | 3309 |
3305 TEST_F(LayerTreeHostImplTest, OverscrollChildEventBubbling) { | 3310 TEST_F(LayerTreeHostImplTest, OverscrollChildEventBubbling) { |
3306 // When we try to scroll a non-scrollable child layer, the scroll delta | 3311 // When we try to scroll a non-scrollable child layer, the scroll delta |
3307 // should be applied to one of its ancestors if possible. Overscroll should | 3312 // should be applied to one of its ancestors if possible. Overscroll should |
3308 // be reflected only when it has bubbled up to the root scrolling layer. | 3313 // be reflected only when it has bubbled up to the root scrolling layer. |
3309 gfx::Size surface_size(10, 10); | 3314 gfx::Size surface_size(10, 10); |
3310 gfx::Size content_size(20, 20); | 3315 gfx::Size content_size(20, 20); |
3311 scoped_ptr<LayerImpl> root_clip = | 3316 scoped_ptr<LayerImpl> root_clip = |
3312 LayerImpl::Create(host_impl_->active_tree(), 3); | 3317 LayerImpl::Create(host_impl_->active_tree(), 3); |
3318 root_clip->SetHasRenderSurface(true); | |
3319 | |
3313 scoped_ptr<LayerImpl> root = | 3320 scoped_ptr<LayerImpl> root = |
3314 CreateScrollableLayer(1, content_size, root_clip.get()); | 3321 CreateScrollableLayer(1, content_size, root_clip.get()); |
3315 root->SetIsContainerForFixedPositionLayers(true); | 3322 root->SetIsContainerForFixedPositionLayers(true); |
3316 scoped_ptr<LayerImpl> child = | 3323 scoped_ptr<LayerImpl> child = |
3317 CreateScrollableLayer(2, content_size, root_clip.get()); | 3324 CreateScrollableLayer(2, content_size, root_clip.get()); |
3318 | 3325 |
3319 child->SetScrollClipLayer(Layer::INVALID_ID); | 3326 child->SetScrollClipLayer(Layer::INVALID_ID); |
3320 root->AddChild(child.Pass()); | 3327 root->AddChild(child.Pass()); |
3321 root_clip->AddChild(root.Pass()); | 3328 root_clip->AddChild(root.Pass()); |
3322 | 3329 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3358 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 3365 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
3359 EXPECT_EQ(gfx::Vector2dF(0, 10), host_impl_->accumulated_root_overscroll()); | 3366 EXPECT_EQ(gfx::Vector2dF(0, 10), host_impl_->accumulated_root_overscroll()); |
3360 } | 3367 } |
3361 | 3368 |
3362 TEST_F(LayerTreeHostImplTest, NoOverscrollOnFractionalDeviceScale) { | 3369 TEST_F(LayerTreeHostImplTest, NoOverscrollOnFractionalDeviceScale) { |
3363 gfx::Size surface_size(980, 1439); | 3370 gfx::Size surface_size(980, 1439); |
3364 gfx::Size content_size(980, 1438); | 3371 gfx::Size content_size(980, 1438); |
3365 float device_scale_factor = 1.5f; | 3372 float device_scale_factor = 1.5f; |
3366 scoped_ptr<LayerImpl> root_clip = | 3373 scoped_ptr<LayerImpl> root_clip = |
3367 LayerImpl::Create(host_impl_->active_tree(), 3); | 3374 LayerImpl::Create(host_impl_->active_tree(), 3); |
3375 root_clip->SetHasRenderSurface(true); | |
3376 | |
3368 scoped_ptr<LayerImpl> root = | 3377 scoped_ptr<LayerImpl> root = |
3369 CreateScrollableLayer(1, content_size, root_clip.get()); | 3378 CreateScrollableLayer(1, content_size, root_clip.get()); |
3370 root->SetIsContainerForFixedPositionLayers(true); | 3379 root->SetIsContainerForFixedPositionLayers(true); |
3371 scoped_ptr<LayerImpl> child = | 3380 scoped_ptr<LayerImpl> child = |
3372 CreateScrollableLayer(2, content_size, root_clip.get()); | 3381 CreateScrollableLayer(2, content_size, root_clip.get()); |
3373 root->scroll_clip_layer()->SetBounds(gfx::Size(320, 469)); | 3382 root->scroll_clip_layer()->SetBounds(gfx::Size(320, 469)); |
3374 host_impl_->active_tree()->SetPageScaleFactorAndLimits( | 3383 host_impl_->active_tree()->SetPageScaleFactorAndLimits( |
3375 0.326531f, 0.326531f, 5.f); | 3384 0.326531f, 0.326531f, 5.f); |
3376 host_impl_->active_tree()->SetPageScaleDelta(1.f); | 3385 host_impl_->active_tree()->SetPageScaleDelta(1.f); |
3377 child->SetScrollClipLayer(Layer::INVALID_ID); | 3386 child->SetScrollClipLayer(Layer::INVALID_ID); |
(...skipping 18 matching lines...) Expand all Loading... | |
3396 | 3405 |
3397 host_impl_->ScrollEnd(); | 3406 host_impl_->ScrollEnd(); |
3398 } | 3407 } |
3399 } | 3408 } |
3400 | 3409 |
3401 TEST_F(LayerTreeHostImplTest, NoOverscrollWhenNotAtEdge) { | 3410 TEST_F(LayerTreeHostImplTest, NoOverscrollWhenNotAtEdge) { |
3402 gfx::Size surface_size(100, 100); | 3411 gfx::Size surface_size(100, 100); |
3403 gfx::Size content_size(200, 200); | 3412 gfx::Size content_size(200, 200); |
3404 scoped_ptr<LayerImpl> root_clip = | 3413 scoped_ptr<LayerImpl> root_clip = |
3405 LayerImpl::Create(host_impl_->active_tree(), 3); | 3414 LayerImpl::Create(host_impl_->active_tree(), 3); |
3415 root_clip->SetHasRenderSurface(true); | |
3416 | |
3406 scoped_ptr<LayerImpl> root = | 3417 scoped_ptr<LayerImpl> root = |
3407 CreateScrollableLayer(1, content_size, root_clip.get()); | 3418 CreateScrollableLayer(1, content_size, root_clip.get()); |
3408 root->SetIsContainerForFixedPositionLayers(true); | 3419 root->SetIsContainerForFixedPositionLayers(true); |
3409 scoped_ptr<LayerImpl> child = | 3420 scoped_ptr<LayerImpl> child = |
3410 CreateScrollableLayer(2, content_size, root_clip.get()); | 3421 CreateScrollableLayer(2, content_size, root_clip.get()); |
3411 | 3422 |
3412 child->SetScrollClipLayer(Layer::INVALID_ID); | 3423 child->SetScrollClipLayer(Layer::INVALID_ID); |
3413 root->AddChild(child.Pass()); | 3424 root->AddChild(child.Pass()); |
3414 root_clip->AddChild(root.Pass()); | 3425 root_clip->AddChild(root.Pass()); |
3415 | 3426 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3541 ResourceProvider::ResourceId resource_id_; | 3552 ResourceProvider::ResourceId resource_id_; |
3542 }; | 3553 }; |
3543 | 3554 |
3544 TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { | 3555 TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { |
3545 { | 3556 { |
3546 scoped_ptr<LayerImpl> root = | 3557 scoped_ptr<LayerImpl> root = |
3547 LayerImpl::Create(host_impl_->active_tree(), 1); | 3558 LayerImpl::Create(host_impl_->active_tree(), 1); |
3548 root->SetBounds(gfx::Size(10, 10)); | 3559 root->SetBounds(gfx::Size(10, 10)); |
3549 root->SetContentBounds(root->bounds()); | 3560 root->SetContentBounds(root->bounds()); |
3550 root->SetDrawsContent(false); | 3561 root->SetDrawsContent(false); |
3562 root->SetHasRenderSurface(true); | |
3551 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 3563 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
3552 } | 3564 } |
3553 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 3565 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
3554 | 3566 |
3555 root->AddChild( | 3567 root->AddChild( |
3556 BlendStateCheckLayer::Create(host_impl_->active_tree(), | 3568 BlendStateCheckLayer::Create(host_impl_->active_tree(), |
3557 2, | 3569 2, |
3558 host_impl_->resource_provider())); | 3570 host_impl_->resource_provider())); |
3559 BlendStateCheckLayer* layer1 = | 3571 BlendStateCheckLayer* layer1 = |
3560 static_cast<BlendStateCheckLayer*>(root->children()[0]); | 3572 static_cast<BlendStateCheckLayer*>(root->children()[0]); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3650 EXPECT_TRUE(layer2->quads_appended()); | 3662 EXPECT_TRUE(layer2->quads_appended()); |
3651 host_impl_->DidDrawAllLayers(frame); | 3663 host_impl_->DidDrawAllLayers(frame); |
3652 | 3664 |
3653 // Parent layer with translucent opacity and opaque content. Since it has a | 3665 // Parent layer with translucent opacity and opaque content. Since it has a |
3654 // drawing child, it's drawn to a render surface which carries the opacity, | 3666 // drawing child, it's drawn to a render surface which carries the opacity, |
3655 // so it's itself drawn without blending. | 3667 // so it's itself drawn without blending. |
3656 // Child layer with opaque content, drawn without blending (parent surface | 3668 // Child layer with opaque content, drawn without blending (parent surface |
3657 // carries the inherited opacity). | 3669 // carries the inherited opacity). |
3658 layer1->SetContentsOpaque(true); | 3670 layer1->SetContentsOpaque(true); |
3659 layer1->SetOpacity(0.5f); | 3671 layer1->SetOpacity(0.5f); |
3672 layer1->SetHasRenderSurface(true); | |
3660 layer1->SetExpectation(false, true); | 3673 layer1->SetExpectation(false, true); |
3661 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 3674 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
3662 layer2->SetExpectation(false, false); | 3675 layer2->SetExpectation(false, false); |
3663 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 3676 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
3664 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( | 3677 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( |
3665 host_impl_->active_tree()->root_layer()); | 3678 host_impl_->active_tree()->root_layer()); |
3666 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 3679 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
3667 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 3680 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
3668 EXPECT_TRUE(layer1->quads_appended()); | 3681 EXPECT_TRUE(layer1->quads_appended()); |
3669 EXPECT_TRUE(layer2->quads_appended()); | 3682 EXPECT_TRUE(layer2->quads_appended()); |
3670 host_impl_->DidDrawAllLayers(frame); | 3683 host_impl_->DidDrawAllLayers(frame); |
3684 layer1->SetHasRenderSurface(false); | |
3671 | 3685 |
3672 // Draw again, but with child non-opaque, to make sure | 3686 // Draw again, but with child non-opaque, to make sure |
3673 // layer1 not culled. | 3687 // layer1 not culled. |
3674 layer1->SetContentsOpaque(true); | 3688 layer1->SetContentsOpaque(true); |
3675 layer1->SetOpacity(1.f); | 3689 layer1->SetOpacity(1.f); |
3676 layer1->SetExpectation(false, false); | 3690 layer1->SetExpectation(false, false); |
3677 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 3691 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
3678 layer2->SetContentsOpaque(true); | 3692 layer2->SetContentsOpaque(true); |
3679 layer2->SetOpacity(0.5f); | 3693 layer2->SetOpacity(0.5f); |
3680 layer2->SetExpectation(true, false); | 3694 layer2->SetExpectation(true, false); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3778 return FakeOutputSurface::CreateAlwaysDrawAndSwap3d() | 3792 return FakeOutputSurface::CreateAlwaysDrawAndSwap3d() |
3779 .PassAs<OutputSurface>(); | 3793 .PassAs<OutputSurface>(); |
3780 } | 3794 } |
3781 return FakeOutputSurface::Create3d().PassAs<OutputSurface>(); | 3795 return FakeOutputSurface::Create3d().PassAs<OutputSurface>(); |
3782 } | 3796 } |
3783 | 3797 |
3784 void SetupActiveTreeLayers() { | 3798 void SetupActiveTreeLayers() { |
3785 host_impl_->active_tree()->set_background_color(SK_ColorGRAY); | 3799 host_impl_->active_tree()->set_background_color(SK_ColorGRAY); |
3786 host_impl_->active_tree()->SetRootLayer( | 3800 host_impl_->active_tree()->SetRootLayer( |
3787 LayerImpl::Create(host_impl_->active_tree(), 1)); | 3801 LayerImpl::Create(host_impl_->active_tree(), 1)); |
3802 host_impl_->active_tree()->root_layer()->SetHasRenderSurface(true); | |
3788 host_impl_->active_tree()->root_layer()->AddChild( | 3803 host_impl_->active_tree()->root_layer()->AddChild( |
3789 BlendStateCheckLayer::Create(host_impl_->active_tree(), | 3804 BlendStateCheckLayer::Create(host_impl_->active_tree(), |
3790 2, | 3805 2, |
3791 host_impl_->resource_provider())); | 3806 host_impl_->resource_provider())); |
3792 child_ = static_cast<BlendStateCheckLayer*>( | 3807 child_ = static_cast<BlendStateCheckLayer*>( |
3793 host_impl_->active_tree()->root_layer()->children()[0]); | 3808 host_impl_->active_tree()->root_layer()->children()[0]); |
3794 child_->SetExpectation(false, false); | 3809 child_->SetExpectation(false, false); |
3795 child_->SetContentsOpaque(true); | 3810 child_->SetContentsOpaque(true); |
3796 } | 3811 } |
3797 | 3812 |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4069 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); | 4084 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); |
4070 scoped_ptr<OutputSurface> output_surface( | 4085 scoped_ptr<OutputSurface> output_surface( |
4071 FakeOutputSurface::Create3d(provider)); | 4086 FakeOutputSurface::Create3d(provider)); |
4072 CreateHostImpl(DefaultSettings(), output_surface.Pass()); | 4087 CreateHostImpl(DefaultSettings(), output_surface.Pass()); |
4073 | 4088 |
4074 scoped_ptr<LayerImpl> root = | 4089 scoped_ptr<LayerImpl> root = |
4075 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); | 4090 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); |
4076 root->SetBounds(gfx::Size(10, 10)); | 4091 root->SetBounds(gfx::Size(10, 10)); |
4077 root->SetContentBounds(gfx::Size(10, 10)); | 4092 root->SetContentBounds(gfx::Size(10, 10)); |
4078 root->SetDrawsContent(true); | 4093 root->SetDrawsContent(true); |
4094 root->SetHasRenderSurface(true); | |
4079 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 4095 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
4080 EXPECT_FALSE(provider->TestContext3d()->reshape_called()); | 4096 EXPECT_FALSE(provider->TestContext3d()->reshape_called()); |
4081 provider->TestContext3d()->clear_reshape_called(); | 4097 provider->TestContext3d()->clear_reshape_called(); |
4082 | 4098 |
4083 LayerTreeHostImpl::FrameData frame; | 4099 LayerTreeHostImpl::FrameData frame; |
4084 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 4100 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
4085 host_impl_->SetDeviceScaleFactor(1.f); | 4101 host_impl_->SetDeviceScaleFactor(1.f); |
4086 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4102 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
4087 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 4103 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
4088 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); | 4104 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4135 this, | 4151 this, |
4136 &proxy_, | 4152 &proxy_, |
4137 &stats_instrumentation_, | 4153 &stats_instrumentation_, |
4138 shared_bitmap_manager.get(), | 4154 shared_bitmap_manager.get(), |
4139 0); | 4155 0); |
4140 layer_tree_host_impl->InitializeRenderer(output_surface.Pass()); | 4156 layer_tree_host_impl->InitializeRenderer(output_surface.Pass()); |
4141 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); | 4157 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); |
4142 | 4158 |
4143 scoped_ptr<LayerImpl> root = | 4159 scoped_ptr<LayerImpl> root = |
4144 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); | 4160 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); |
4161 root->SetHasRenderSurface(true); | |
4145 scoped_ptr<LayerImpl> child = | 4162 scoped_ptr<LayerImpl> child = |
4146 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); | 4163 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); |
4147 child->SetPosition(gfx::PointF(12.f, 13.f)); | 4164 child->SetPosition(gfx::PointF(12.f, 13.f)); |
4148 child->SetBounds(gfx::Size(14, 15)); | 4165 child->SetBounds(gfx::Size(14, 15)); |
4149 child->SetContentBounds(gfx::Size(14, 15)); | 4166 child->SetContentBounds(gfx::Size(14, 15)); |
4150 child->SetDrawsContent(true); | 4167 child->SetDrawsContent(true); |
4151 root->SetBounds(gfx::Size(500, 500)); | 4168 root->SetBounds(gfx::Size(500, 500)); |
4152 root->SetContentBounds(gfx::Size(500, 500)); | 4169 root->SetContentBounds(gfx::Size(500, 500)); |
4153 root->SetDrawsContent(true); | 4170 root->SetDrawsContent(true); |
4154 root->AddChild(child.Pass()); | 4171 root->AddChild(child.Pass()); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4202 scoped_ptr<LayerImpl> root = | 4219 scoped_ptr<LayerImpl> root = |
4203 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); | 4220 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); |
4204 scoped_ptr<LayerImpl> child = | 4221 scoped_ptr<LayerImpl> child = |
4205 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2); | 4222 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2); |
4206 child->SetBounds(gfx::Size(10, 10)); | 4223 child->SetBounds(gfx::Size(10, 10)); |
4207 child->SetContentBounds(gfx::Size(10, 10)); | 4224 child->SetContentBounds(gfx::Size(10, 10)); |
4208 child->SetDrawsContent(true); | 4225 child->SetDrawsContent(true); |
4209 root->SetBounds(gfx::Size(10, 10)); | 4226 root->SetBounds(gfx::Size(10, 10)); |
4210 root->SetContentBounds(gfx::Size(10, 10)); | 4227 root->SetContentBounds(gfx::Size(10, 10)); |
4211 root->SetDrawsContent(true); | 4228 root->SetDrawsContent(true); |
4212 root->SetForceRenderSurface(true); | 4229 root->SetHasRenderSurface(true); |
4213 root->AddChild(child.Pass()); | 4230 root->AddChild(child.Pass()); |
4214 | 4231 |
4215 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 4232 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
4216 | 4233 |
4217 LayerTreeHostImpl::FrameData frame; | 4234 LayerTreeHostImpl::FrameData frame; |
4218 | 4235 |
4219 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4236 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
4220 EXPECT_EQ(1u, frame.render_surface_layer_list->size()); | 4237 EXPECT_EQ(1u, frame.render_surface_layer_list->size()); |
4221 EXPECT_EQ(1u, frame.render_passes.size()); | 4238 EXPECT_EQ(1u, frame.render_passes.size()); |
4222 host_impl_->DidDrawAllLayers(frame); | 4239 host_impl_->DidDrawAllLayers(frame); |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4455 LayerImpl::Create(my_host_impl->active_tree(), 1); | 4472 LayerImpl::Create(my_host_impl->active_tree(), 1); |
4456 scoped_ptr<LayerImpl> child = | 4473 scoped_ptr<LayerImpl> child = |
4457 LayerImpl::Create(my_host_impl->active_tree(), 2); | 4474 LayerImpl::Create(my_host_impl->active_tree(), 2); |
4458 scoped_ptr<LayerImpl> grand_child = | 4475 scoped_ptr<LayerImpl> grand_child = |
4459 FakeLayerWithQuads::Create(my_host_impl->active_tree(), 3); | 4476 FakeLayerWithQuads::Create(my_host_impl->active_tree(), 3); |
4460 | 4477 |
4461 gfx::Rect root_rect(0, 0, 100, 100); | 4478 gfx::Rect root_rect(0, 0, 100, 100); |
4462 gfx::Rect child_rect(10, 10, 50, 50); | 4479 gfx::Rect child_rect(10, 10, 50, 50); |
4463 gfx::Rect grand_child_rect(5, 5, 150, 150); | 4480 gfx::Rect grand_child_rect(5, 5, 150, 150); |
4464 | 4481 |
4465 root->CreateRenderSurface(); | 4482 root->SetHasRenderSurface(true); |
4466 root->SetPosition(root_rect.origin()); | 4483 root->SetPosition(root_rect.origin()); |
4467 root->SetBounds(root_rect.size()); | 4484 root->SetBounds(root_rect.size()); |
4468 root->SetContentBounds(root->bounds()); | 4485 root->SetContentBounds(root->bounds()); |
4469 root->draw_properties().visible_content_rect = root_rect; | 4486 root->draw_properties().visible_content_rect = root_rect; |
4470 root->SetDrawsContent(false); | 4487 root->SetDrawsContent(false); |
4471 root->render_surface()->SetContentRect(gfx::Rect(root_rect.size())); | 4488 root->render_surface()->SetContentRect(gfx::Rect(root_rect.size())); |
4472 | 4489 |
4473 child->SetPosition(gfx::PointF(child_rect.x(), child_rect.y())); | 4490 child->SetPosition(gfx::PointF(child_rect.x(), child_rect.y())); |
4474 child->SetOpacity(0.5f); | 4491 child->SetOpacity(0.5f); |
4475 child->SetBounds(gfx::Size(child_rect.width(), child_rect.height())); | 4492 child->SetBounds(gfx::Size(child_rect.width(), child_rect.height())); |
4476 child->SetContentBounds(child->bounds()); | 4493 child->SetContentBounds(child->bounds()); |
4477 child->draw_properties().visible_content_rect = child_rect; | 4494 child->draw_properties().visible_content_rect = child_rect; |
4478 child->SetDrawsContent(false); | 4495 child->SetDrawsContent(false); |
4479 child->SetForceRenderSurface(true); | 4496 child->SetHasRenderSurface(true); |
4480 | 4497 |
4481 grand_child->SetPosition(grand_child_rect.origin()); | 4498 grand_child->SetPosition(grand_child_rect.origin()); |
4482 grand_child->SetBounds(grand_child_rect.size()); | 4499 grand_child->SetBounds(grand_child_rect.size()); |
4483 grand_child->SetContentBounds(grand_child->bounds()); | 4500 grand_child->SetContentBounds(grand_child->bounds()); |
4484 grand_child->draw_properties().visible_content_rect = grand_child_rect; | 4501 grand_child->draw_properties().visible_content_rect = grand_child_rect; |
4485 grand_child->SetDrawsContent(true); | 4502 grand_child->SetDrawsContent(true); |
4486 | 4503 |
4487 child->AddChild(grand_child.Pass()); | 4504 child->AddChild(grand_child.Pass()); |
4488 root->AddChild(child.Pass()); | 4505 root->AddChild(child.Pass()); |
4489 | 4506 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4549 scoped_ptr<TestWebGraphicsContext3D> context = | 4566 scoped_ptr<TestWebGraphicsContext3D> context = |
4550 TestWebGraphicsContext3D::Create(); | 4567 TestWebGraphicsContext3D::Create(); |
4551 TestWebGraphicsContext3D* context3d = context.get(); | 4568 TestWebGraphicsContext3D* context3d = context.get(); |
4552 scoped_ptr<OutputSurface> output_surface( | 4569 scoped_ptr<OutputSurface> output_surface( |
4553 FakeOutputSurface::Create3d(context.Pass())); | 4570 FakeOutputSurface::Create3d(context.Pass())); |
4554 CreateHostImpl(DefaultSettings(), output_surface.Pass()); | 4571 CreateHostImpl(DefaultSettings(), output_surface.Pass()); |
4555 | 4572 |
4556 scoped_ptr<LayerImpl> root_layer = | 4573 scoped_ptr<LayerImpl> root_layer = |
4557 LayerImpl::Create(host_impl_->active_tree(), 1); | 4574 LayerImpl::Create(host_impl_->active_tree(), 1); |
4558 root_layer->SetBounds(gfx::Size(10, 10)); | 4575 root_layer->SetBounds(gfx::Size(10, 10)); |
4576 root_layer->SetHasRenderSurface(true); | |
4559 | 4577 |
4560 scoped_refptr<VideoFrame> softwareFrame = | 4578 scoped_refptr<VideoFrame> softwareFrame = |
4561 media::VideoFrame::CreateColorFrame( | 4579 media::VideoFrame::CreateColorFrame( |
4562 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); | 4580 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); |
4563 FakeVideoFrameProvider provider; | 4581 FakeVideoFrameProvider provider; |
4564 provider.set_frame(softwareFrame); | 4582 provider.set_frame(softwareFrame); |
4565 scoped_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( | 4583 scoped_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( |
4566 host_impl_->active_tree(), 4, &provider, media::VIDEO_ROTATION_0); | 4584 host_impl_->active_tree(), 4, &provider, media::VIDEO_ROTATION_0); |
4567 video_layer->SetBounds(gfx::Size(10, 10)); | 4585 video_layer->SetBounds(gfx::Size(10, 10)); |
4568 video_layer->SetContentBounds(gfx::Size(10, 10)); | 4586 video_layer->SetContentBounds(gfx::Size(10, 10)); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4725 } | 4743 } |
4726 }; | 4744 }; |
4727 | 4745 |
4728 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) { | 4746 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) { |
4729 scoped_ptr<SolidColorLayerImpl> root = | 4747 scoped_ptr<SolidColorLayerImpl> root = |
4730 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 4748 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
4731 root->SetPosition(gfx::PointF()); | 4749 root->SetPosition(gfx::PointF()); |
4732 root->SetBounds(gfx::Size(10, 10)); | 4750 root->SetBounds(gfx::Size(10, 10)); |
4733 root->SetContentBounds(gfx::Size(10, 10)); | 4751 root->SetContentBounds(gfx::Size(10, 10)); |
4734 root->SetDrawsContent(true); | 4752 root->SetDrawsContent(true); |
4753 root->SetHasRenderSurface(true); | |
4735 | 4754 |
4736 // Child layer is in the bottom right corner. | 4755 // Child layer is in the bottom right corner. |
4737 scoped_ptr<SolidColorLayerImpl> child = | 4756 scoped_ptr<SolidColorLayerImpl> child = |
4738 SolidColorLayerImpl::Create(host_impl_->active_tree(), 2); | 4757 SolidColorLayerImpl::Create(host_impl_->active_tree(), 2); |
4739 child->SetPosition(gfx::PointF(9.f, 9.f)); | 4758 child->SetPosition(gfx::PointF(9.f, 9.f)); |
4740 child->SetBounds(gfx::Size(1, 1)); | 4759 child->SetBounds(gfx::Size(1, 1)); |
4741 child->SetContentBounds(gfx::Size(1, 1)); | 4760 child->SetContentBounds(gfx::Size(1, 1)); |
4742 child->SetDrawsContent(true); | 4761 child->SetDrawsContent(true); |
4743 root->AddChild(child.PassAs<LayerImpl>()); | 4762 root->AddChild(child.PassAs<LayerImpl>()); |
4744 | 4763 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4790 | 4809 |
4791 // Root | 4810 // Root |
4792 // | | 4811 // | |
4793 // +-- Scaling Layer (adds a 2x scale) | 4812 // +-- Scaling Layer (adds a 2x scale) |
4794 // | | 4813 // | |
4795 // +-- Content Layer | 4814 // +-- Content Layer |
4796 // +--Mask | 4815 // +--Mask |
4797 scoped_ptr<LayerImpl> scoped_root = | 4816 scoped_ptr<LayerImpl> scoped_root = |
4798 LayerImpl::Create(host_impl_->active_tree(), 1); | 4817 LayerImpl::Create(host_impl_->active_tree(), 1); |
4799 LayerImpl* root = scoped_root.get(); | 4818 LayerImpl* root = scoped_root.get(); |
4819 root->SetHasRenderSurface(true); | |
4800 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); | 4820 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); |
4801 | 4821 |
4802 scoped_ptr<LayerImpl> scoped_scaling_layer = | 4822 scoped_ptr<LayerImpl> scoped_scaling_layer = |
4803 LayerImpl::Create(host_impl_->active_tree(), 2); | 4823 LayerImpl::Create(host_impl_->active_tree(), 2); |
4804 LayerImpl* scaling_layer = scoped_scaling_layer.get(); | 4824 LayerImpl* scaling_layer = scoped_scaling_layer.get(); |
4805 root->AddChild(scoped_scaling_layer.Pass()); | 4825 root->AddChild(scoped_scaling_layer.Pass()); |
4806 | 4826 |
4807 scoped_ptr<LayerImpl> scoped_content_layer = | 4827 scoped_ptr<LayerImpl> scoped_content_layer = |
4808 LayerImpl::Create(host_impl_->active_tree(), 3); | 4828 LayerImpl::Create(host_impl_->active_tree(), 3); |
4809 LayerImpl* content_layer = scoped_content_layer.get(); | 4829 LayerImpl* content_layer = scoped_content_layer.get(); |
4810 scaling_layer->AddChild(scoped_content_layer.Pass()); | 4830 scaling_layer->AddChild(scoped_content_layer.Pass()); |
4811 | 4831 |
4812 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = | 4832 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = |
4813 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); | 4833 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); |
4814 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); | 4834 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); |
4815 content_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>()); | 4835 content_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>()); |
4836 content_layer->SetHasRenderSurface(true); | |
4816 | 4837 |
4817 gfx::Size root_size(100, 100); | 4838 gfx::Size root_size(100, 100); |
4818 root->SetBounds(root_size); | 4839 root->SetBounds(root_size); |
4819 root->SetContentBounds(root_size); | 4840 root->SetContentBounds(root_size); |
4820 root->SetPosition(gfx::PointF()); | 4841 root->SetPosition(gfx::PointF()); |
4821 | 4842 |
4822 gfx::Size scaling_layer_size(50, 50); | 4843 gfx::Size scaling_layer_size(50, 50); |
4823 scaling_layer->SetBounds(scaling_layer_size); | 4844 scaling_layer->SetBounds(scaling_layer_size); |
4824 scaling_layer->SetContentBounds(scaling_layer_size); | 4845 scaling_layer->SetContentBounds(scaling_layer_size); |
4825 scaling_layer->SetPosition(gfx::PointF()); | 4846 scaling_layer->SetPosition(gfx::PointF()); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4921 } | 4942 } |
4922 } | 4943 } |
4923 | 4944 |
4924 TEST_F(LayerTreeHostImplTest, MaskLayerWithDifferentBounds) { | 4945 TEST_F(LayerTreeHostImplTest, MaskLayerWithDifferentBounds) { |
4925 // The mask layer has bounds 100x100 but is attached to a layer with bounds | 4946 // The mask layer has bounds 100x100 but is attached to a layer with bounds |
4926 // 50x50. | 4947 // 50x50. |
4927 | 4948 |
4928 scoped_ptr<LayerImpl> scoped_root = | 4949 scoped_ptr<LayerImpl> scoped_root = |
4929 LayerImpl::Create(host_impl_->active_tree(), 1); | 4950 LayerImpl::Create(host_impl_->active_tree(), 1); |
4930 LayerImpl* root = scoped_root.get(); | 4951 LayerImpl* root = scoped_root.get(); |
4952 root->SetHasRenderSurface(true); | |
4953 | |
4931 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); | 4954 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); |
4932 | 4955 |
4933 scoped_ptr<LayerImpl> scoped_content_layer = | 4956 scoped_ptr<LayerImpl> scoped_content_layer = |
4934 LayerImpl::Create(host_impl_->active_tree(), 3); | 4957 LayerImpl::Create(host_impl_->active_tree(), 3); |
4935 LayerImpl* content_layer = scoped_content_layer.get(); | 4958 LayerImpl* content_layer = scoped_content_layer.get(); |
4936 root->AddChild(scoped_content_layer.Pass()); | 4959 root->AddChild(scoped_content_layer.Pass()); |
4937 | 4960 |
4938 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = | 4961 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = |
4939 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); | 4962 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); |
4940 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); | 4963 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); |
4941 content_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>()); | 4964 content_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>()); |
4965 content_layer->SetHasRenderSurface(true); | |
4942 | 4966 |
4943 gfx::Size root_size(100, 100); | 4967 gfx::Size root_size(100, 100); |
4944 root->SetBounds(root_size); | 4968 root->SetBounds(root_size); |
4945 root->SetContentBounds(root_size); | 4969 root->SetContentBounds(root_size); |
4946 root->SetPosition(gfx::PointF()); | 4970 root->SetPosition(gfx::PointF()); |
4947 | 4971 |
4948 gfx::Size layer_size(50, 50); | 4972 gfx::Size layer_size(50, 50); |
4949 content_layer->SetBounds(layer_size); | 4973 content_layer->SetBounds(layer_size); |
4950 content_layer->SetContentBounds(layer_size); | 4974 content_layer->SetContentBounds(layer_size); |
4951 content_layer->SetPosition(gfx::PointF()); | 4975 content_layer->SetPosition(gfx::PointF()); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5063 } | 5087 } |
5064 } | 5088 } |
5065 | 5089 |
5066 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerWithDifferentBounds) { | 5090 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerWithDifferentBounds) { |
5067 // The replica's mask layer has bounds 100x100 but the replica is of a | 5091 // The replica's mask layer has bounds 100x100 but the replica is of a |
5068 // layer with bounds 50x50. | 5092 // layer with bounds 50x50. |
5069 | 5093 |
5070 scoped_ptr<LayerImpl> scoped_root = | 5094 scoped_ptr<LayerImpl> scoped_root = |
5071 LayerImpl::Create(host_impl_->active_tree(), 1); | 5095 LayerImpl::Create(host_impl_->active_tree(), 1); |
5072 LayerImpl* root = scoped_root.get(); | 5096 LayerImpl* root = scoped_root.get(); |
5097 root->SetHasRenderSurface(true); | |
5098 | |
5073 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); | 5099 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); |
5074 | 5100 |
5075 scoped_ptr<LayerImpl> scoped_content_layer = | 5101 scoped_ptr<LayerImpl> scoped_content_layer = |
5076 LayerImpl::Create(host_impl_->active_tree(), 3); | 5102 LayerImpl::Create(host_impl_->active_tree(), 3); |
5077 LayerImpl* content_layer = scoped_content_layer.get(); | 5103 LayerImpl* content_layer = scoped_content_layer.get(); |
5078 root->AddChild(scoped_content_layer.Pass()); | 5104 root->AddChild(scoped_content_layer.Pass()); |
5079 | 5105 |
5080 scoped_ptr<LayerImpl> scoped_replica_layer = | 5106 scoped_ptr<LayerImpl> scoped_replica_layer = |
5081 LayerImpl::Create(host_impl_->active_tree(), 2); | 5107 LayerImpl::Create(host_impl_->active_tree(), 2); |
5082 LayerImpl* replica_layer = scoped_replica_layer.get(); | 5108 LayerImpl* replica_layer = scoped_replica_layer.get(); |
5083 content_layer->SetReplicaLayer(scoped_replica_layer.Pass()); | 5109 content_layer->SetReplicaLayer(scoped_replica_layer.Pass()); |
5110 content_layer->SetHasRenderSurface(true); | |
5084 | 5111 |
5085 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = | 5112 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = |
5086 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); | 5113 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); |
5087 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); | 5114 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); |
5088 replica_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>()); | 5115 replica_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>()); |
5116 replica_layer->SetHasRenderSurface(true); | |
5089 | 5117 |
5090 gfx::Size root_size(100, 100); | 5118 gfx::Size root_size(100, 100); |
5091 root->SetBounds(root_size); | 5119 root->SetBounds(root_size); |
5092 root->SetContentBounds(root_size); | 5120 root->SetContentBounds(root_size); |
5093 root->SetPosition(gfx::PointF()); | 5121 root->SetPosition(gfx::PointF()); |
5094 | 5122 |
5095 gfx::Size layer_size(50, 50); | 5123 gfx::Size layer_size(50, 50); |
5096 content_layer->SetBounds(layer_size); | 5124 content_layer->SetBounds(layer_size); |
5097 content_layer->SetContentBounds(layer_size); | 5125 content_layer->SetContentBounds(layer_size); |
5098 content_layer->SetPosition(gfx::PointF()); | 5126 content_layer->SetPosition(gfx::PointF()); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5210 } | 5238 } |
5211 } | 5239 } |
5212 | 5240 |
5213 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerForSurfaceWithUnclippedChild) { | 5241 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerForSurfaceWithUnclippedChild) { |
5214 // The replica is of a layer with bounds 50x50, but it has a child that causes | 5242 // The replica is of a layer with bounds 50x50, but it has a child that causes |
5215 // the surface bounds to be larger. | 5243 // the surface bounds to be larger. |
5216 | 5244 |
5217 scoped_ptr<LayerImpl> scoped_root = | 5245 scoped_ptr<LayerImpl> scoped_root = |
5218 LayerImpl::Create(host_impl_->active_tree(), 1); | 5246 LayerImpl::Create(host_impl_->active_tree(), 1); |
5219 LayerImpl* root = scoped_root.get(); | 5247 LayerImpl* root = scoped_root.get(); |
5248 root->SetHasRenderSurface(true); | |
5220 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); | 5249 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); |
5221 | 5250 |
5222 scoped_ptr<LayerImpl> scoped_content_layer = | 5251 scoped_ptr<LayerImpl> scoped_content_layer = |
5223 LayerImpl::Create(host_impl_->active_tree(), 2); | 5252 LayerImpl::Create(host_impl_->active_tree(), 2); |
5224 LayerImpl* content_layer = scoped_content_layer.get(); | 5253 LayerImpl* content_layer = scoped_content_layer.get(); |
5225 root->AddChild(scoped_content_layer.Pass()); | 5254 root->AddChild(scoped_content_layer.Pass()); |
5226 | 5255 |
5227 scoped_ptr<LayerImpl> scoped_content_child_layer = | 5256 scoped_ptr<LayerImpl> scoped_content_child_layer = |
5228 LayerImpl::Create(host_impl_->active_tree(), 3); | 5257 LayerImpl::Create(host_impl_->active_tree(), 3); |
5229 LayerImpl* content_child_layer = scoped_content_child_layer.get(); | 5258 LayerImpl* content_child_layer = scoped_content_child_layer.get(); |
5230 content_layer->AddChild(scoped_content_child_layer.Pass()); | 5259 content_layer->AddChild(scoped_content_child_layer.Pass()); |
5231 | 5260 |
5232 scoped_ptr<LayerImpl> scoped_replica_layer = | 5261 scoped_ptr<LayerImpl> scoped_replica_layer = |
5233 LayerImpl::Create(host_impl_->active_tree(), 4); | 5262 LayerImpl::Create(host_impl_->active_tree(), 4); |
5234 LayerImpl* replica_layer = scoped_replica_layer.get(); | 5263 LayerImpl* replica_layer = scoped_replica_layer.get(); |
5235 content_layer->SetReplicaLayer(scoped_replica_layer.Pass()); | 5264 content_layer->SetReplicaLayer(scoped_replica_layer.Pass()); |
5265 content_layer->SetHasRenderSurface(true); | |
danakj
2014/09/03 19:30:35
For new tests that want to use a mask/replica/filt
| |
5236 | 5266 |
5237 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = | 5267 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = |
5238 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 5); | 5268 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 5); |
5239 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); | 5269 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); |
5240 replica_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>()); | 5270 replica_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>()); |
5271 replica_layer->SetHasRenderSurface(true); | |
5241 | 5272 |
5242 gfx::Size root_size(100, 100); | 5273 gfx::Size root_size(100, 100); |
5243 root->SetBounds(root_size); | 5274 root->SetBounds(root_size); |
5244 root->SetContentBounds(root_size); | 5275 root->SetContentBounds(root_size); |
5245 root->SetPosition(gfx::PointF()); | 5276 root->SetPosition(gfx::PointF()); |
5246 | 5277 |
5247 gfx::Size layer_size(50, 50); | 5278 gfx::Size layer_size(50, 50); |
5248 content_layer->SetBounds(layer_size); | 5279 content_layer->SetBounds(layer_size); |
5249 content_layer->SetContentBounds(layer_size); | 5280 content_layer->SetContentBounds(layer_size); |
5250 content_layer->SetPosition(gfx::PointF()); | 5281 content_layer->SetPosition(gfx::PointF()); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5328 } | 5359 } |
5329 | 5360 |
5330 TEST_F(LayerTreeHostImplTest, MaskLayerForSurfaceWithClippedLayer) { | 5361 TEST_F(LayerTreeHostImplTest, MaskLayerForSurfaceWithClippedLayer) { |
5331 // The masked layer has bounds 50x50, but it has a child that causes | 5362 // The masked layer has bounds 50x50, but it has a child that causes |
5332 // the surface bounds to be larger. It also has a parent that clips the | 5363 // the surface bounds to be larger. It also has a parent that clips the |
5333 // masked layer and its surface. | 5364 // masked layer and its surface. |
5334 | 5365 |
5335 scoped_ptr<LayerImpl> scoped_root = | 5366 scoped_ptr<LayerImpl> scoped_root = |
5336 LayerImpl::Create(host_impl_->active_tree(), 1); | 5367 LayerImpl::Create(host_impl_->active_tree(), 1); |
5337 LayerImpl* root = scoped_root.get(); | 5368 LayerImpl* root = scoped_root.get(); |
5369 root->SetHasRenderSurface(true); | |
5370 | |
5338 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); | 5371 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); |
5339 | 5372 |
5340 scoped_ptr<LayerImpl> scoped_clipping_layer = | 5373 scoped_ptr<LayerImpl> scoped_clipping_layer = |
5341 LayerImpl::Create(host_impl_->active_tree(), 2); | 5374 LayerImpl::Create(host_impl_->active_tree(), 2); |
5342 LayerImpl* clipping_layer = scoped_clipping_layer.get(); | 5375 LayerImpl* clipping_layer = scoped_clipping_layer.get(); |
5343 root->AddChild(scoped_clipping_layer.Pass()); | 5376 root->AddChild(scoped_clipping_layer.Pass()); |
5344 | 5377 |
5345 scoped_ptr<LayerImpl> scoped_content_layer = | 5378 scoped_ptr<LayerImpl> scoped_content_layer = |
5346 LayerImpl::Create(host_impl_->active_tree(), 3); | 5379 LayerImpl::Create(host_impl_->active_tree(), 3); |
5347 LayerImpl* content_layer = scoped_content_layer.get(); | 5380 LayerImpl* content_layer = scoped_content_layer.get(); |
5348 clipping_layer->AddChild(scoped_content_layer.Pass()); | 5381 clipping_layer->AddChild(scoped_content_layer.Pass()); |
5349 | 5382 |
5350 scoped_ptr<LayerImpl> scoped_content_child_layer = | 5383 scoped_ptr<LayerImpl> scoped_content_child_layer = |
5351 LayerImpl::Create(host_impl_->active_tree(), 4); | 5384 LayerImpl::Create(host_impl_->active_tree(), 4); |
5352 LayerImpl* content_child_layer = scoped_content_child_layer.get(); | 5385 LayerImpl* content_child_layer = scoped_content_child_layer.get(); |
5353 content_layer->AddChild(scoped_content_child_layer.Pass()); | 5386 content_layer->AddChild(scoped_content_child_layer.Pass()); |
5354 | 5387 |
5355 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = | 5388 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = |
5356 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 6); | 5389 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 6); |
5357 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); | 5390 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); |
5358 content_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>()); | 5391 content_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>()); |
5359 | 5392 content_layer->SetHasRenderSurface(true); |
5360 gfx::Size root_size(100, 100); | 5393 gfx::Size root_size(100, 100); |
5361 root->SetBounds(root_size); | 5394 root->SetBounds(root_size); |
5362 root->SetContentBounds(root_size); | 5395 root->SetContentBounds(root_size); |
5363 root->SetPosition(gfx::PointF()); | 5396 root->SetPosition(gfx::PointF()); |
5364 | 5397 |
5365 gfx::Rect clipping_rect(20, 10, 10, 20); | 5398 gfx::Rect clipping_rect(20, 10, 10, 20); |
5366 clipping_layer->SetBounds(clipping_rect.size()); | 5399 clipping_layer->SetBounds(clipping_rect.size()); |
5367 clipping_layer->SetContentBounds(clipping_rect.size()); | 5400 clipping_layer->SetContentBounds(clipping_rect.size()); |
5368 clipping_layer->SetPosition(clipping_rect.origin()); | 5401 clipping_layer->SetPosition(clipping_rect.origin()); |
5369 clipping_layer->SetMasksToBounds(true); | 5402 clipping_layer->SetMasksToBounds(true); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5432 gfx::ToCeiledSize(gfx::ScaleSize(root_size, device_scale_factor)); | 5465 gfx::ToCeiledSize(gfx::ScaleSize(root_size, device_scale_factor)); |
5433 host_impl_->SetViewportSize(device_viewport_size); | 5466 host_impl_->SetViewportSize(device_viewport_size); |
5434 | 5467 |
5435 host_impl_->CreatePendingTree(); | 5468 host_impl_->CreatePendingTree(); |
5436 host_impl_->pending_tree() | 5469 host_impl_->pending_tree() |
5437 ->SetPageScaleFactorAndLimits(1.f, 1.f / 16.f, 16.f); | 5470 ->SetPageScaleFactorAndLimits(1.f, 1.f / 16.f, 16.f); |
5438 | 5471 |
5439 scoped_ptr<LayerImpl> scoped_root = | 5472 scoped_ptr<LayerImpl> scoped_root = |
5440 LayerImpl::Create(host_impl_->pending_tree(), 1); | 5473 LayerImpl::Create(host_impl_->pending_tree(), 1); |
5441 LayerImpl* root = scoped_root.get(); | 5474 LayerImpl* root = scoped_root.get(); |
5475 root->SetHasRenderSurface(true); | |
5442 | 5476 |
5443 host_impl_->pending_tree()->SetRootLayer(scoped_root.Pass()); | 5477 host_impl_->pending_tree()->SetRootLayer(scoped_root.Pass()); |
5444 | 5478 |
5445 scoped_ptr<LayerImpl> scoped_scrolling_layer = | 5479 scoped_ptr<LayerImpl> scoped_scrolling_layer = |
5446 LayerImpl::Create(host_impl_->pending_tree(), 2); | 5480 LayerImpl::Create(host_impl_->pending_tree(), 2); |
5447 LayerImpl* scrolling_layer = scoped_scrolling_layer.get(); | 5481 LayerImpl* scrolling_layer = scoped_scrolling_layer.get(); |
5448 root->AddChild(scoped_scrolling_layer.Pass()); | 5482 root->AddChild(scoped_scrolling_layer.Pass()); |
5449 | 5483 |
5450 gfx::Size content_layer_bounds(100000, 100); | 5484 gfx::Size content_layer_bounds(100000, 100); |
5451 gfx::Size pile_tile_size(3000, 3000); | 5485 gfx::Size pile_tile_size(3000, 3000); |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5930 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures()); | 5964 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures()); |
5931 } | 5965 } |
5932 | 5966 |
5933 TEST_F(LayerTreeHostImplTest, TouchFlingShouldNotBubble) { | 5967 TEST_F(LayerTreeHostImplTest, TouchFlingShouldNotBubble) { |
5934 // When flinging via touch, only the child should scroll (we should not | 5968 // When flinging via touch, only the child should scroll (we should not |
5935 // bubble). | 5969 // bubble). |
5936 gfx::Size surface_size(10, 10); | 5970 gfx::Size surface_size(10, 10); |
5937 gfx::Size content_size(20, 20); | 5971 gfx::Size content_size(20, 20); |
5938 scoped_ptr<LayerImpl> root_clip = | 5972 scoped_ptr<LayerImpl> root_clip = |
5939 LayerImpl::Create(host_impl_->active_tree(), 3); | 5973 LayerImpl::Create(host_impl_->active_tree(), 3); |
5974 root_clip->SetHasRenderSurface(true); | |
5975 | |
5940 scoped_ptr<LayerImpl> root = | 5976 scoped_ptr<LayerImpl> root = |
5941 CreateScrollableLayer(1, content_size, root_clip.get()); | 5977 CreateScrollableLayer(1, content_size, root_clip.get()); |
5942 root->SetIsContainerForFixedPositionLayers(true); | 5978 root->SetIsContainerForFixedPositionLayers(true); |
5943 scoped_ptr<LayerImpl> child = | 5979 scoped_ptr<LayerImpl> child = |
5944 CreateScrollableLayer(2, content_size, root_clip.get()); | 5980 CreateScrollableLayer(2, content_size, root_clip.get()); |
5945 | 5981 |
5946 root->AddChild(child.Pass()); | 5982 root->AddChild(child.Pass()); |
5947 int root_id = root->id(); | 5983 int root_id = root->id(); |
5948 root_clip->AddChild(root.Pass()); | 5984 root_clip->AddChild(root.Pass()); |
5949 | 5985 |
(...skipping 23 matching lines...) Expand all Loading... | |
5973 ASSERT_EQ(1u, scroll_info->scrolls.size()); | 6009 ASSERT_EQ(1u, scroll_info->scrolls.size()); |
5974 ExpectNone(*scroll_info.get(), root_id); | 6010 ExpectNone(*scroll_info.get(), root_id); |
5975 } | 6011 } |
5976 } | 6012 } |
5977 | 6013 |
5978 TEST_F(LayerTreeHostImplTest, TouchFlingShouldLockToFirstScrolledLayer) { | 6014 TEST_F(LayerTreeHostImplTest, TouchFlingShouldLockToFirstScrolledLayer) { |
5979 // Scroll a child layer beyond its maximum scroll range and make sure the | 6015 // Scroll a child layer beyond its maximum scroll range and make sure the |
5980 // the scroll doesn't bubble up to the parent layer. | 6016 // the scroll doesn't bubble up to the parent layer. |
5981 gfx::Size surface_size(10, 10); | 6017 gfx::Size surface_size(10, 10); |
5982 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 6018 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
6019 root->SetHasRenderSurface(true); | |
5983 scoped_ptr<LayerImpl> root_scrolling = | 6020 scoped_ptr<LayerImpl> root_scrolling = |
5984 CreateScrollableLayer(2, surface_size, root.get()); | 6021 CreateScrollableLayer(2, surface_size, root.get()); |
5985 | 6022 |
5986 scoped_ptr<LayerImpl> grand_child = | 6023 scoped_ptr<LayerImpl> grand_child = |
5987 CreateScrollableLayer(4, surface_size, root.get()); | 6024 CreateScrollableLayer(4, surface_size, root.get()); |
5988 grand_child->SetScrollOffset(gfx::Vector2d(0, 2)); | 6025 grand_child->SetScrollOffset(gfx::Vector2d(0, 2)); |
5989 | 6026 |
5990 scoped_ptr<LayerImpl> child = | 6027 scoped_ptr<LayerImpl> child = |
5991 CreateScrollableLayer(3, surface_size, root.get()); | 6028 CreateScrollableLayer(3, surface_size, root.get()); |
5992 child->SetScrollOffset(gfx::Vector2d(0, 4)); | 6029 child->SetScrollOffset(gfx::Vector2d(0, 4)); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6043 } | 6080 } |
6044 } | 6081 } |
6045 | 6082 |
6046 TEST_F(LayerTreeHostImplTest, WheelFlingShouldBubble) { | 6083 TEST_F(LayerTreeHostImplTest, WheelFlingShouldBubble) { |
6047 // When flinging via wheel, the root should eventually scroll (we should | 6084 // When flinging via wheel, the root should eventually scroll (we should |
6048 // bubble). | 6085 // bubble). |
6049 gfx::Size surface_size(10, 10); | 6086 gfx::Size surface_size(10, 10); |
6050 gfx::Size content_size(20, 20); | 6087 gfx::Size content_size(20, 20); |
6051 scoped_ptr<LayerImpl> root_clip = | 6088 scoped_ptr<LayerImpl> root_clip = |
6052 LayerImpl::Create(host_impl_->active_tree(), 3); | 6089 LayerImpl::Create(host_impl_->active_tree(), 3); |
6090 root_clip->SetHasRenderSurface(true); | |
6053 scoped_ptr<LayerImpl> root_scroll = | 6091 scoped_ptr<LayerImpl> root_scroll = |
6054 CreateScrollableLayer(1, content_size, root_clip.get()); | 6092 CreateScrollableLayer(1, content_size, root_clip.get()); |
6055 int root_scroll_id = root_scroll->id(); | 6093 int root_scroll_id = root_scroll->id(); |
6056 scoped_ptr<LayerImpl> child = | 6094 scoped_ptr<LayerImpl> child = |
6057 CreateScrollableLayer(2, content_size, root_clip.get()); | 6095 CreateScrollableLayer(2, content_size, root_clip.get()); |
6058 | 6096 |
6059 root_scroll->AddChild(child.Pass()); | 6097 root_scroll->AddChild(child.Pass()); |
6060 root_clip->AddChild(root_scroll.Pass()); | 6098 root_clip->AddChild(root_scroll.Pass()); |
6061 | 6099 |
6062 host_impl_->SetViewportSize(surface_size); | 6100 host_impl_->SetViewportSize(surface_size); |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6246 | 6284 |
6247 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed | 6285 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed |
6248 // to CompositorFrameMetadata after SwapBuffers(); | 6286 // to CompositorFrameMetadata after SwapBuffers(); |
6249 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { | 6287 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { |
6250 scoped_ptr<SolidColorLayerImpl> root = | 6288 scoped_ptr<SolidColorLayerImpl> root = |
6251 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 6289 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
6252 root->SetPosition(gfx::PointF()); | 6290 root->SetPosition(gfx::PointF()); |
6253 root->SetBounds(gfx::Size(10, 10)); | 6291 root->SetBounds(gfx::Size(10, 10)); |
6254 root->SetContentBounds(gfx::Size(10, 10)); | 6292 root->SetContentBounds(gfx::Size(10, 10)); |
6255 root->SetDrawsContent(true); | 6293 root->SetDrawsContent(true); |
6294 root->SetHasRenderSurface(true); | |
6256 | 6295 |
6257 host_impl_->active_tree()->SetRootLayer(root.PassAs<LayerImpl>()); | 6296 host_impl_->active_tree()->SetRootLayer(root.PassAs<LayerImpl>()); |
6258 | 6297 |
6259 FakeOutputSurface* fake_output_surface = | 6298 FakeOutputSurface* fake_output_surface = |
6260 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); | 6299 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); |
6261 | 6300 |
6262 const std::vector<ui::LatencyInfo>& metadata_latency_before = | 6301 const std::vector<ui::LatencyInfo>& metadata_latency_before = |
6263 fake_output_surface->last_sent_frame().metadata.latency_info; | 6302 fake_output_surface->last_sent_frame().metadata.latency_info; |
6264 EXPECT_TRUE(metadata_latency_before.empty()); | 6303 EXPECT_TRUE(metadata_latency_before.empty()); |
6265 | 6304 |
(...skipping 20 matching lines...) Expand all Loading... | |
6286 } | 6325 } |
6287 | 6326 |
6288 TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) { | 6327 TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) { |
6289 int root_layer_id = 1; | 6328 int root_layer_id = 1; |
6290 scoped_ptr<SolidColorLayerImpl> root = | 6329 scoped_ptr<SolidColorLayerImpl> root = |
6291 SolidColorLayerImpl::Create(host_impl_->active_tree(), root_layer_id); | 6330 SolidColorLayerImpl::Create(host_impl_->active_tree(), root_layer_id); |
6292 root->SetPosition(gfx::PointF()); | 6331 root->SetPosition(gfx::PointF()); |
6293 root->SetBounds(gfx::Size(10, 10)); | 6332 root->SetBounds(gfx::Size(10, 10)); |
6294 root->SetContentBounds(gfx::Size(10, 10)); | 6333 root->SetContentBounds(gfx::Size(10, 10)); |
6295 root->SetDrawsContent(true); | 6334 root->SetDrawsContent(true); |
6335 root->SetHasRenderSurface(true); | |
6296 | 6336 |
6297 host_impl_->active_tree()->SetRootLayer(root.PassAs<LayerImpl>()); | 6337 host_impl_->active_tree()->SetRootLayer(root.PassAs<LayerImpl>()); |
6298 | 6338 |
6299 // Ensure the default frame selection bounds are empty. | 6339 // Ensure the default frame selection bounds are empty. |
6300 FakeOutputSurface* fake_output_surface = | 6340 FakeOutputSurface* fake_output_surface = |
6301 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); | 6341 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); |
6302 const ViewportSelectionBound& selection_start_before = | 6342 const ViewportSelectionBound& selection_start_before = |
6303 fake_output_surface->last_sent_frame().metadata.selection_start; | 6343 fake_output_surface->last_sent_frame().metadata.selection_start; |
6304 const ViewportSelectionBound& selection_end_before = | 6344 const ViewportSelectionBound& selection_end_before = |
6305 fake_output_surface->last_sent_frame().metadata.selection_end; | 6345 fake_output_surface->last_sent_frame().metadata.selection_end; |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6710 contents->SetBounds(content_size); | 6750 contents->SetBounds(content_size); |
6711 contents->SetContentBounds(content_size); | 6751 contents->SetContentBounds(content_size); |
6712 contents->SetPosition(gfx::PointF()); | 6752 contents->SetPosition(gfx::PointF()); |
6713 | 6753 |
6714 outer_scroll->AddChild(contents.Pass()); | 6754 outer_scroll->AddChild(contents.Pass()); |
6715 outer_clip->AddChild(outer_scroll.Pass()); | 6755 outer_clip->AddChild(outer_scroll.Pass()); |
6716 inner_scroll->AddChild(outer_clip.Pass()); | 6756 inner_scroll->AddChild(outer_clip.Pass()); |
6717 page_scale->AddChild(inner_scroll.Pass()); | 6757 page_scale->AddChild(inner_scroll.Pass()); |
6718 inner_clip->AddChild(page_scale.Pass()); | 6758 inner_clip->AddChild(page_scale.Pass()); |
6719 | 6759 |
6760 inner_clip->SetHasRenderSurface(true); | |
6720 layer_tree_impl->SetRootLayer(inner_clip.Pass()); | 6761 layer_tree_impl->SetRootLayer(inner_clip.Pass()); |
6721 layer_tree_impl->SetViewportLayersFromIds(kPageScaleLayerId, | 6762 layer_tree_impl->SetViewportLayersFromIds(kPageScaleLayerId, |
6722 kInnerViewportScrollLayerId, kOuterViewportScrollLayerId); | 6763 kInnerViewportScrollLayerId, kOuterViewportScrollLayerId); |
6723 | 6764 |
6724 host_impl_->active_tree()->DidBecomeActive(); | 6765 host_impl_->active_tree()->DidBecomeActive(); |
6725 } | 6766 } |
6726 }; | 6767 }; |
6727 | 6768 |
6728 TEST_F(LayerTreeHostImplVirtualViewportTest, FlingScrollBubblesToInner) { | 6769 TEST_F(LayerTreeHostImplVirtualViewportTest, FlingScrollBubblesToInner) { |
6729 gfx::Size content_size = gfx::Size(100, 160); | 6770 gfx::Size content_size = gfx::Size(100, 160); |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6979 // surface. | 7020 // surface. |
6980 EXPECT_EQ(0, num_lost_surfaces_); | 7021 EXPECT_EQ(0, num_lost_surfaces_); |
6981 host_impl_->DidLoseOutputSurface(); | 7022 host_impl_->DidLoseOutputSurface(); |
6982 EXPECT_EQ(1, num_lost_surfaces_); | 7023 EXPECT_EQ(1, num_lost_surfaces_); |
6983 host_impl_->DidLoseOutputSurface(); | 7024 host_impl_->DidLoseOutputSurface(); |
6984 EXPECT_LE(1, num_lost_surfaces_); | 7025 EXPECT_LE(1, num_lost_surfaces_); |
6985 } | 7026 } |
6986 | 7027 |
6987 } // namespace | 7028 } // namespace |
6988 } // namespace cc | 7029 } // namespace cc |
OLD | NEW |