Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Side by Side Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 465853004: Moving RenderSurface creation outside of CalcDrawProps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
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
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
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
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
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
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
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
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
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->SetHasRenderSurface(true);
1805 layer1->SetShouldFlattenTransform(true); 1785 layer1->SetShouldFlattenTransform(true);
1806 1786
1807 EXPECT_FALSE(root->did_draw_called()); 1787 EXPECT_FALSE(root->did_draw_called());
1808 EXPECT_FALSE(layer1->did_draw_called()); 1788 EXPECT_FALSE(layer1->did_draw_called());
1809 EXPECT_FALSE(layer2->did_draw_called()); 1789 EXPECT_FALSE(layer2->did_draw_called());
1810 1790
1811 LayerTreeHostImpl::FrameData frame; 1791 LayerTreeHostImpl::FrameData frame;
1812 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( 1792 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(
1813 host_impl_->active_tree()->root_layer()); 1793 host_impl_->active_tree()->root_layer());
1814 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 1794 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1866 1846
1867 bool tile_missing_; 1847 bool tile_missing_;
1868 bool had_incomplete_tile_; 1848 bool had_incomplete_tile_;
1869 }; 1849 };
1870 1850
1871 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsOnDefault) { 1851 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsOnDefault) {
1872 host_impl_->active_tree()->SetRootLayer( 1852 host_impl_->active_tree()->SetRootLayer(
1873 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); 1853 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1));
1874 DidDrawCheckLayer* root = 1854 DidDrawCheckLayer* root =
1875 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 1855 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
1876 1856 root->SetHasRenderSurface(true);
1877 bool tile_missing = false; 1857 bool tile_missing = false;
1878 bool had_incomplete_tile = false; 1858 bool had_incomplete_tile = false;
1879 bool is_animating = false; 1859 bool is_animating = false;
1880 root->AddChild( 1860 root->AddChild(
1881 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 1861 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
1882 2, 1862 2,
1883 tile_missing, 1863 tile_missing,
1884 had_incomplete_tile, 1864 had_incomplete_tile,
1885 is_animating, 1865 is_animating,
1886 host_impl_->resource_provider())); 1866 host_impl_->resource_provider()));
1887 1867
1888 LayerTreeHostImpl::FrameData frame; 1868 LayerTreeHostImpl::FrameData frame;
1889 1869
1890 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 1870 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
1891 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1871 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1892 host_impl_->DidDrawAllLayers(frame); 1872 host_impl_->DidDrawAllLayers(frame);
1893 } 1873 }
1894 1874
1895 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithAnimatedLayer) { 1875 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithAnimatedLayer) {
1896 host_impl_->active_tree()->SetRootLayer( 1876 host_impl_->active_tree()->SetRootLayer(
1897 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); 1877 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1));
1898 DidDrawCheckLayer* root = 1878 DidDrawCheckLayer* root =
1899 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 1879 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
1880 root->SetHasRenderSurface(true);
1900 bool tile_missing = false; 1881 bool tile_missing = false;
1901 bool had_incomplete_tile = false; 1882 bool had_incomplete_tile = false;
1902 bool is_animating = true; 1883 bool is_animating = true;
1903 root->AddChild( 1884 root->AddChild(
1904 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 1885 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
1905 2, 1886 2,
1906 tile_missing, 1887 tile_missing,
1907 had_incomplete_tile, 1888 had_incomplete_tile,
1908 is_animating, 1889 is_animating,
1909 host_impl_->resource_provider())); 1890 host_impl_->resource_provider()));
1910 1891
1911 LayerTreeHostImpl::FrameData frame; 1892 LayerTreeHostImpl::FrameData frame;
1912 1893
1913 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 1894 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
1914 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1895 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1915 host_impl_->DidDrawAllLayers(frame); 1896 host_impl_->DidDrawAllLayers(frame);
1916 } 1897 }
1917 1898
1918 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithMissingTiles) { 1899 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithMissingTiles) {
1919 host_impl_->active_tree()->SetRootLayer( 1900 host_impl_->active_tree()->SetRootLayer(
1920 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); 1901 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3));
1921 DidDrawCheckLayer* root = 1902 DidDrawCheckLayer* root =
1922 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 1903 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
1904 root->SetHasRenderSurface(true);
1923 1905
1924 bool tile_missing = true; 1906 bool tile_missing = true;
1925 bool had_incomplete_tile = false; 1907 bool had_incomplete_tile = false;
1926 bool is_animating = false; 1908 bool is_animating = false;
1927 root->AddChild( 1909 root->AddChild(
1928 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 1910 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
1929 4, 1911 4,
1930 tile_missing, 1912 tile_missing,
1931 had_incomplete_tile, 1913 had_incomplete_tile,
1932 is_animating, 1914 is_animating,
1933 host_impl_->resource_provider())); 1915 host_impl_->resource_provider()));
1934 LayerTreeHostImpl::FrameData frame; 1916 LayerTreeHostImpl::FrameData frame;
1935 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 1917 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
1936 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1918 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1937 host_impl_->DidDrawAllLayers(frame); 1919 host_impl_->DidDrawAllLayers(frame);
1938 } 1920 }
1939 1921
1940 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithIncompleteTile) { 1922 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithIncompleteTile) {
1941 host_impl_->active_tree()->SetRootLayer( 1923 host_impl_->active_tree()->SetRootLayer(
1942 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); 1924 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3));
1943 DidDrawCheckLayer* root = 1925 DidDrawCheckLayer* root =
1944 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 1926 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
1927 root->SetHasRenderSurface(true);
1945 1928
1946 bool tile_missing = false; 1929 bool tile_missing = false;
1947 bool had_incomplete_tile = true; 1930 bool had_incomplete_tile = true;
1948 bool is_animating = false; 1931 bool is_animating = false;
1949 root->AddChild( 1932 root->AddChild(
1950 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 1933 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
1951 4, 1934 4,
1952 tile_missing, 1935 tile_missing,
1953 had_incomplete_tile, 1936 had_incomplete_tile,
1954 is_animating, 1937 is_animating,
1955 host_impl_->resource_provider())); 1938 host_impl_->resource_provider()));
1956 LayerTreeHostImpl::FrameData frame; 1939 LayerTreeHostImpl::FrameData frame;
1957 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 1940 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
1958 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1941 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1959 host_impl_->DidDrawAllLayers(frame); 1942 host_impl_->DidDrawAllLayers(frame);
1960 } 1943 }
1961 1944
1962 TEST_F(LayerTreeHostImplTest, 1945 TEST_F(LayerTreeHostImplTest,
1963 PrepareToDrawFailsWithAnimationAndMissingTilesUsesCheckerboard) { 1946 PrepareToDrawFailsWithAnimationAndMissingTilesUsesCheckerboard) {
1964 host_impl_->active_tree()->SetRootLayer( 1947 host_impl_->active_tree()->SetRootLayer(
1965 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); 1948 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5));
1966 DidDrawCheckLayer* root = 1949 DidDrawCheckLayer* root =
1967 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 1950 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
1951 root->SetHasRenderSurface(true);
1968 bool tile_missing = true; 1952 bool tile_missing = true;
1969 bool had_incomplete_tile = false; 1953 bool had_incomplete_tile = false;
1970 bool is_animating = true; 1954 bool is_animating = true;
1971 root->AddChild( 1955 root->AddChild(
1972 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 1956 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
1973 6, 1957 6,
1974 tile_missing, 1958 tile_missing,
1975 had_incomplete_tile, 1959 had_incomplete_tile,
1976 is_animating, 1960 is_animating,
1977 host_impl_->resource_provider())); 1961 host_impl_->resource_provider()));
1978 LayerTreeHostImpl::FrameData frame; 1962 LayerTreeHostImpl::FrameData frame;
1979 EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS, 1963 EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS,
1980 host_impl_->PrepareToDraw(&frame)); 1964 host_impl_->PrepareToDraw(&frame));
1981 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1965 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1982 host_impl_->DidDrawAllLayers(frame); 1966 host_impl_->DidDrawAllLayers(frame);
1983 } 1967 }
1984 1968
1985 TEST_F(LayerTreeHostImplTest, 1969 TEST_F(LayerTreeHostImplTest,
1986 PrepareToDrawSucceedsWithAnimationAndIncompleteTiles) { 1970 PrepareToDrawSucceedsWithAnimationAndIncompleteTiles) {
1987 host_impl_->active_tree()->SetRootLayer( 1971 host_impl_->active_tree()->SetRootLayer(
1988 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); 1972 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5));
1989 DidDrawCheckLayer* root = 1973 DidDrawCheckLayer* root =
1990 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 1974 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
1975 root->SetHasRenderSurface(true);
1991 bool tile_missing = false; 1976 bool tile_missing = false;
1992 bool had_incomplete_tile = true; 1977 bool had_incomplete_tile = true;
1993 bool is_animating = true; 1978 bool is_animating = true;
1994 root->AddChild( 1979 root->AddChild(
1995 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 1980 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
1996 6, 1981 6,
1997 tile_missing, 1982 tile_missing,
1998 had_incomplete_tile, 1983 had_incomplete_tile,
1999 is_animating, 1984 is_animating,
2000 host_impl_->resource_provider())); 1985 host_impl_->resource_provider()));
2001 LayerTreeHostImpl::FrameData frame; 1986 LayerTreeHostImpl::FrameData frame;
2002 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 1987 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
2003 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1988 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2004 host_impl_->DidDrawAllLayers(frame); 1989 host_impl_->DidDrawAllLayers(frame);
2005 } 1990 }
2006 1991
2007 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWhenHighResRequired) { 1992 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWhenHighResRequired) {
2008 host_impl_->active_tree()->SetRootLayer( 1993 host_impl_->active_tree()->SetRootLayer(
2009 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); 1994 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7));
2010 DidDrawCheckLayer* root = 1995 DidDrawCheckLayer* root =
2011 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 1996 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
1997 root->SetHasRenderSurface(true);
2012 bool tile_missing = false; 1998 bool tile_missing = false;
2013 bool had_incomplete_tile = false; 1999 bool had_incomplete_tile = false;
2014 bool is_animating = false; 2000 bool is_animating = false;
2015 root->AddChild( 2001 root->AddChild(
2016 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 2002 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
2017 8, 2003 8,
2018 tile_missing, 2004 tile_missing,
2019 had_incomplete_tile, 2005 had_incomplete_tile,
2020 is_animating, 2006 is_animating,
2021 host_impl_->resource_provider())); 2007 host_impl_->resource_provider()));
2022 host_impl_->active_tree()->SetRequiresHighResToDraw(); 2008 host_impl_->active_tree()->SetRequiresHighResToDraw();
2023 LayerTreeHostImpl::FrameData frame; 2009 LayerTreeHostImpl::FrameData frame;
2024 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 2010 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
2025 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 2011 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2026 host_impl_->DidDrawAllLayers(frame); 2012 host_impl_->DidDrawAllLayers(frame);
2027 } 2013 }
2028 2014
2029 TEST_F(LayerTreeHostImplTest, 2015 TEST_F(LayerTreeHostImplTest,
2030 PrepareToDrawFailsWhenHighResRequiredAndIncompleteTiles) { 2016 PrepareToDrawFailsWhenHighResRequiredAndIncompleteTiles) {
2031 host_impl_->active_tree()->SetRootLayer( 2017 host_impl_->active_tree()->SetRootLayer(
2032 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); 2018 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7));
2033 DidDrawCheckLayer* root = 2019 DidDrawCheckLayer* root =
2034 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 2020 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
2021 root->SetHasRenderSurface(true);
2035 bool tile_missing = false; 2022 bool tile_missing = false;
2036 bool had_incomplete_tile = true; 2023 bool had_incomplete_tile = true;
2037 bool is_animating = false; 2024 bool is_animating = false;
2038 root->AddChild( 2025 root->AddChild(
2039 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 2026 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
2040 8, 2027 8,
2041 tile_missing, 2028 tile_missing,
2042 had_incomplete_tile, 2029 had_incomplete_tile,
2043 is_animating, 2030 is_animating,
2044 host_impl_->resource_provider())); 2031 host_impl_->resource_provider()));
2045 host_impl_->active_tree()->SetRequiresHighResToDraw(); 2032 host_impl_->active_tree()->SetRequiresHighResToDraw();
2046 LayerTreeHostImpl::FrameData frame; 2033 LayerTreeHostImpl::FrameData frame;
2047 EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT, 2034 EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT,
2048 host_impl_->PrepareToDraw(&frame)); 2035 host_impl_->PrepareToDraw(&frame));
2049 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 2036 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2050 host_impl_->DidDrawAllLayers(frame); 2037 host_impl_->DidDrawAllLayers(frame);
2051 } 2038 }
2052 2039
2053 TEST_F(LayerTreeHostImplTest, 2040 TEST_F(LayerTreeHostImplTest,
2054 PrepareToDrawFailsWhenHighResRequiredAndMissingTile) { 2041 PrepareToDrawFailsWhenHighResRequiredAndMissingTile) {
2055 host_impl_->active_tree()->SetRootLayer( 2042 host_impl_->active_tree()->SetRootLayer(
2056 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); 2043 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7));
2057 DidDrawCheckLayer* root = 2044 DidDrawCheckLayer* root =
2058 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 2045 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
2046 root->SetHasRenderSurface(true);
2059 bool tile_missing = true; 2047 bool tile_missing = true;
2060 bool had_incomplete_tile = false; 2048 bool had_incomplete_tile = false;
2061 bool is_animating = false; 2049 bool is_animating = false;
2062 root->AddChild( 2050 root->AddChild(
2063 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 2051 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
2064 8, 2052 8,
2065 tile_missing, 2053 tile_missing,
2066 had_incomplete_tile, 2054 had_incomplete_tile,
2067 is_animating, 2055 is_animating,
2068 host_impl_->resource_provider())); 2056 host_impl_->resource_provider()));
2069 host_impl_->active_tree()->SetRequiresHighResToDraw(); 2057 host_impl_->active_tree()->SetRequiresHighResToDraw();
2070 LayerTreeHostImpl::FrameData frame; 2058 LayerTreeHostImpl::FrameData frame;
2071 EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT, 2059 EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT,
2072 host_impl_->PrepareToDraw(&frame)); 2060 host_impl_->PrepareToDraw(&frame));
2073 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 2061 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2074 host_impl_->DidDrawAllLayers(frame); 2062 host_impl_->DidDrawAllLayers(frame);
2075 } 2063 }
2076 2064
2077 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { 2065 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) {
2078 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); 2066 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
2079 root->SetScrollClipLayer(Layer::INVALID_ID); 2067 root->SetScrollClipLayer(Layer::INVALID_ID);
2068 root->SetHasRenderSurface(true);
2080 host_impl_->active_tree()->SetRootLayer(root.Pass()); 2069 host_impl_->active_tree()->SetRootLayer(root.Pass());
2081 DrawFrame(); 2070 DrawFrame();
2082 2071
2083 // Scroll event is ignored because layer is not scrollable. 2072 // Scroll event is ignored because layer is not scrollable.
2084 EXPECT_EQ(InputHandler::ScrollIgnored, 2073 EXPECT_EQ(InputHandler::ScrollIgnored,
2085 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); 2074 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel));
2086 EXPECT_FALSE(did_request_redraw_); 2075 EXPECT_FALSE(did_request_redraw_);
2087 EXPECT_FALSE(did_request_commit_); 2076 EXPECT_FALSE(did_request_commit_);
2088 } 2077 }
2089 2078
(...skipping 22 matching lines...) Expand all
2112 root_clip->SetBounds(clip_size_); 2101 root_clip->SetBounds(clip_size_);
2113 root->SetScrollClipLayer(root_clip->id()); 2102 root->SetScrollClipLayer(root_clip->id());
2114 root->SetBounds(layer_size_); 2103 root->SetBounds(layer_size_);
2115 root->SetContentBounds(layer_size_); 2104 root->SetContentBounds(layer_size_);
2116 root->SetPosition(gfx::PointF()); 2105 root->SetPosition(gfx::PointF());
2117 root->SetDrawsContent(false); 2106 root->SetDrawsContent(false);
2118 root->SetIsContainerForFixedPositionLayers(true); 2107 root->SetIsContainerForFixedPositionLayers(true);
2119 int inner_viewport_scroll_layer_id = root->id(); 2108 int inner_viewport_scroll_layer_id = root->id();
2120 int page_scale_layer_id = root_clip->id(); 2109 int page_scale_layer_id = root_clip->id();
2121 root_clip->AddChild(root.Pass()); 2110 root_clip->AddChild(root.Pass());
2111 root_clip->SetHasRenderSurface(true);
2122 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); 2112 host_impl_->active_tree()->SetRootLayer(root_clip.Pass());
2123 host_impl_->active_tree()->SetViewportLayersFromIds( 2113 host_impl_->active_tree()->SetViewportLayersFromIds(
2124 page_scale_layer_id, inner_viewport_scroll_layer_id, Layer::INVALID_ID); 2114 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 2115 // Set a viewport size that is large enough to contain both the top controls
2126 // and some content. 2116 // and some content.
2127 host_impl_->SetViewportSize(viewport_size_); 2117 host_impl_->SetViewportSize(viewport_size_);
2128 host_impl_->SetTopControlsLayoutHeight(settings_.top_controls_height); 2118 host_impl_->SetTopControlsLayoutHeight(settings_.top_controls_height);
2129 LayerImpl* root_clip_ptr = host_impl_->active_tree()->root_layer(); 2119 LayerImpl* root_clip_ptr = host_impl_->active_tree()->root_layer();
2130 EXPECT_EQ(clip_size_, root_clip_ptr->bounds()); 2120 EXPECT_EQ(clip_size_, root_clip_ptr->bounds());
2131 } 2121 }
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
2263 2253
2264 scoped_ptr<LayerImpl> scroll_layer = 2254 scoped_ptr<LayerImpl> scroll_layer =
2265 LayerImpl::Create(host_impl_->active_tree(), 2); 2255 LayerImpl::Create(host_impl_->active_tree(), 2);
2266 scroll_layer->SetScrollClipLayer(3); 2256 scroll_layer->SetScrollClipLayer(3);
2267 scroll_layer->SetBounds(contents_size); 2257 scroll_layer->SetBounds(contents_size);
2268 scroll_layer->SetContentBounds(contents_size); 2258 scroll_layer->SetContentBounds(contents_size);
2269 scroll_layer->SetPosition(gfx::PointF()); 2259 scroll_layer->SetPosition(gfx::PointF());
2270 scroll_layer->AddChild(content_layer.Pass()); 2260 scroll_layer->AddChild(content_layer.Pass());
2271 scroll_clip_layer->AddChild(scroll_layer.Pass()); 2261 scroll_clip_layer->AddChild(scroll_layer.Pass());
2272 2262
2263 scroll_clip_layer->SetHasRenderSurface(true);
2273 host_impl_->active_tree()->SetRootLayer(scroll_clip_layer.Pass()); 2264 host_impl_->active_tree()->SetRootLayer(scroll_clip_layer.Pass());
2274 host_impl_->SetViewportSize(surface_size); 2265 host_impl_->SetViewportSize(surface_size);
2275 DrawFrame(); 2266 DrawFrame();
2276 2267
2277 EXPECT_EQ(InputHandler::ScrollStarted, 2268 EXPECT_EQ(InputHandler::ScrollStarted,
2278 host_impl_->ScrollBegin(gfx::Point(5, 5), 2269 host_impl_->ScrollBegin(gfx::Point(5, 5),
2279 InputHandler::Wheel)); 2270 InputHandler::Wheel));
2280 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); 2271 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10));
2281 host_impl_->ScrollEnd(); 2272 host_impl_->ScrollEnd();
2282 EXPECT_TRUE(did_request_redraw_); 2273 EXPECT_TRUE(did_request_redraw_);
2283 EXPECT_TRUE(did_request_commit_); 2274 EXPECT_TRUE(did_request_commit_);
2284 } 2275 }
2285 2276
2286 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) { 2277 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) {
2287 gfx::Size surface_size(10, 10); 2278 gfx::Size surface_size(10, 10);
2288 gfx::Size contents_size(20, 20); 2279 gfx::Size contents_size(20, 20);
2289 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); 2280 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
2290 root->SetBounds(surface_size); 2281 root->SetBounds(surface_size);
2291 root->SetContentBounds(contents_size); 2282 root->SetContentBounds(contents_size);
2292 root->AddChild(CreateScrollableLayer(2, contents_size, root.get())); 2283 root->AddChild(CreateScrollableLayer(2, contents_size, root.get()));
2284 root->SetHasRenderSurface(true);
2293 host_impl_->active_tree()->SetRootLayer(root.Pass()); 2285 host_impl_->active_tree()->SetRootLayer(root.Pass());
2294 host_impl_->SetViewportSize(surface_size); 2286 host_impl_->SetViewportSize(surface_size);
2295 DrawFrame(); 2287 DrawFrame();
2296 2288
2297 EXPECT_EQ(InputHandler::ScrollStarted, 2289 EXPECT_EQ(InputHandler::ScrollStarted,
2298 host_impl_->ScrollBegin(gfx::Point(5, 5), 2290 host_impl_->ScrollBegin(gfx::Point(5, 5),
2299 InputHandler::Wheel)); 2291 InputHandler::Wheel));
2300 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); 2292 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10));
2301 host_impl_->ScrollEnd(); 2293 host_impl_->ScrollEnd();
2302 EXPECT_TRUE(did_request_redraw_); 2294 EXPECT_TRUE(did_request_redraw_);
2303 EXPECT_TRUE(did_request_commit_); 2295 EXPECT_TRUE(did_request_commit_);
2304 } 2296 }
2305 2297
2306 TEST_F(LayerTreeHostImplTest, ScrollMissesChild) { 2298 TEST_F(LayerTreeHostImplTest, ScrollMissesChild) {
2307 gfx::Size surface_size(10, 10); 2299 gfx::Size surface_size(10, 10);
2308 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); 2300 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
2309 root->AddChild(CreateScrollableLayer(2, surface_size, root.get())); 2301 root->AddChild(CreateScrollableLayer(2, surface_size, root.get()));
2302 root->SetHasRenderSurface(true);
2310 host_impl_->active_tree()->SetRootLayer(root.Pass()); 2303 host_impl_->active_tree()->SetRootLayer(root.Pass());
2311 host_impl_->SetViewportSize(surface_size); 2304 host_impl_->SetViewportSize(surface_size);
2312 DrawFrame(); 2305 DrawFrame();
2313 2306
2314 // Scroll event is ignored because the input coordinate is outside the layer 2307 // Scroll event is ignored because the input coordinate is outside the layer
2315 // boundaries. 2308 // boundaries.
2316 EXPECT_EQ(InputHandler::ScrollIgnored, 2309 EXPECT_EQ(InputHandler::ScrollIgnored,
2317 host_impl_->ScrollBegin(gfx::Point(15, 5), 2310 host_impl_->ScrollBegin(gfx::Point(15, 5),
2318 InputHandler::Wheel)); 2311 InputHandler::Wheel));
2319 EXPECT_FALSE(did_request_redraw_); 2312 EXPECT_FALSE(did_request_redraw_);
2320 EXPECT_FALSE(did_request_commit_); 2313 EXPECT_FALSE(did_request_commit_);
2321 } 2314 }
2322 2315
2323 TEST_F(LayerTreeHostImplTest, ScrollMissesBackfacingChild) { 2316 TEST_F(LayerTreeHostImplTest, ScrollMissesBackfacingChild) {
2324 gfx::Size surface_size(10, 10); 2317 gfx::Size surface_size(10, 10);
2325 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); 2318 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
2319 root->SetHasRenderSurface(true);
2326 scoped_ptr<LayerImpl> child = 2320 scoped_ptr<LayerImpl> child =
2327 CreateScrollableLayer(2, surface_size, root.get()); 2321 CreateScrollableLayer(2, surface_size, root.get());
2328 host_impl_->SetViewportSize(surface_size); 2322 host_impl_->SetViewportSize(surface_size);
2329 2323
2330 gfx::Transform matrix; 2324 gfx::Transform matrix;
2331 matrix.RotateAboutXAxis(180.0); 2325 matrix.RotateAboutXAxis(180.0);
2332 child->SetTransform(matrix); 2326 child->SetTransform(matrix);
2333 child->SetDoubleSided(false); 2327 child->SetDoubleSided(false);
2334 2328
2335 root->AddChild(child.Pass()); 2329 root->AddChild(child.Pass());
(...skipping 17 matching lines...) Expand all
2353 CreateScrollableLayer(1, surface_size, clip_layer.get()); 2347 CreateScrollableLayer(1, surface_size, clip_layer.get());
2354 content_layer->SetShouldScrollOnMainThread(true); 2348 content_layer->SetShouldScrollOnMainThread(true);
2355 content_layer->SetScrollClipLayer(Layer::INVALID_ID); 2349 content_layer->SetScrollClipLayer(Layer::INVALID_ID);
2356 2350
2357 // Note: we can use the same clip layer for both since both calls to 2351 // Note: we can use the same clip layer for both since both calls to
2358 // CreateScrollableLayer() use the same surface size. 2352 // CreateScrollableLayer() use the same surface size.
2359 scoped_ptr<LayerImpl> scroll_layer = 2353 scoped_ptr<LayerImpl> scroll_layer =
2360 CreateScrollableLayer(2, surface_size, clip_layer.get()); 2354 CreateScrollableLayer(2, surface_size, clip_layer.get());
2361 scroll_layer->AddChild(content_layer.Pass()); 2355 scroll_layer->AddChild(content_layer.Pass());
2362 clip_layer->AddChild(scroll_layer.Pass()); 2356 clip_layer->AddChild(scroll_layer.Pass());
2357 clip_layer->SetHasRenderSurface(true);
2363 2358
2364 host_impl_->active_tree()->SetRootLayer(clip_layer.Pass()); 2359 host_impl_->active_tree()->SetRootLayer(clip_layer.Pass());
2365 host_impl_->SetViewportSize(surface_size); 2360 host_impl_->SetViewportSize(surface_size);
2366 DrawFrame(); 2361 DrawFrame();
2367 2362
2368 // Scrolling fails because the content layer is asking to be scrolled on the 2363 // Scrolling fails because the content layer is asking to be scrolled on the
2369 // main thread. 2364 // main thread.
2370 EXPECT_EQ(InputHandler::ScrollOnMainThread, 2365 EXPECT_EQ(InputHandler::ScrollOnMainThread,
2371 host_impl_->ScrollBegin(gfx::Point(5, 5), 2366 host_impl_->ScrollBegin(gfx::Point(5, 5),
2372 InputHandler::Wheel)); 2367 InputHandler::Wheel));
2373 } 2368 }
2374 2369
2375 TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnMainThread) { 2370 TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnMainThread) {
2376 gfx::Size surface_size(20, 20); 2371 gfx::Size surface_size(20, 20);
2377 gfx::Size viewport_size(10, 10); 2372 gfx::Size viewport_size(10, 10);
2378 float page_scale = 2.f; 2373 float page_scale = 2.f;
2379 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); 2374 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
2380 scoped_ptr<LayerImpl> root_clip = 2375 scoped_ptr<LayerImpl> root_clip =
2381 LayerImpl::Create(host_impl_->active_tree(), 2); 2376 LayerImpl::Create(host_impl_->active_tree(), 2);
2382 scoped_ptr<LayerImpl> root_scrolling = 2377 scoped_ptr<LayerImpl> root_scrolling =
2383 CreateScrollableLayer(3, surface_size, root_clip.get()); 2378 CreateScrollableLayer(3, surface_size, root_clip.get());
2384 EXPECT_EQ(viewport_size, root_clip->bounds()); 2379 EXPECT_EQ(viewport_size, root_clip->bounds());
2385 root_scrolling->SetIsContainerForFixedPositionLayers(true); 2380 root_scrolling->SetIsContainerForFixedPositionLayers(true);
2386 root_clip->AddChild(root_scrolling.Pass()); 2381 root_clip->AddChild(root_scrolling.Pass());
2387 root->AddChild(root_clip.Pass()); 2382 root->AddChild(root_clip.Pass());
2383 root->SetHasRenderSurface(true);
2388 host_impl_->active_tree()->SetRootLayer(root.Pass()); 2384 host_impl_->active_tree()->SetRootLayer(root.Pass());
2389 // The behaviour in this test assumes the page scale is applied at a layer 2385 // The behaviour in this test assumes the page scale is applied at a layer
2390 // above the clip layer. 2386 // above the clip layer.
2391 host_impl_->active_tree()->SetViewportLayersFromIds(1, 3, Layer::INVALID_ID); 2387 host_impl_->active_tree()->SetViewportLayersFromIds(1, 3, Layer::INVALID_ID);
2392 host_impl_->active_tree()->DidBecomeActive(); 2388 host_impl_->active_tree()->DidBecomeActive();
2393 host_impl_->SetViewportSize(viewport_size); 2389 host_impl_->SetViewportSize(viewport_size);
2394 DrawFrame(); 2390 DrawFrame();
2395 2391
2396 LayerImpl* root_scroll = 2392 LayerImpl* root_scroll =
2397 host_impl_->active_tree()->InnerViewportScrollLayer(); 2393 host_impl_->active_tree()->InnerViewportScrollLayer();
(...skipping 30 matching lines...) Expand all
2428 float page_scale = 2.f; 2424 float page_scale = 2.f;
2429 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); 2425 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
2430 scoped_ptr<LayerImpl> root_clip = 2426 scoped_ptr<LayerImpl> root_clip =
2431 LayerImpl::Create(host_impl_->active_tree(), 2); 2427 LayerImpl::Create(host_impl_->active_tree(), 2);
2432 scoped_ptr<LayerImpl> root_scrolling = 2428 scoped_ptr<LayerImpl> root_scrolling =
2433 CreateScrollableLayer(3, surface_size, root_clip.get()); 2429 CreateScrollableLayer(3, surface_size, root_clip.get());
2434 EXPECT_EQ(viewport_size, root_clip->bounds()); 2430 EXPECT_EQ(viewport_size, root_clip->bounds());
2435 root_scrolling->SetIsContainerForFixedPositionLayers(true); 2431 root_scrolling->SetIsContainerForFixedPositionLayers(true);
2436 root_clip->AddChild(root_scrolling.Pass()); 2432 root_clip->AddChild(root_scrolling.Pass());
2437 root->AddChild(root_clip.Pass()); 2433 root->AddChild(root_clip.Pass());
2434 root->SetHasRenderSurface(true);
2438 host_impl_->active_tree()->SetRootLayer(root.Pass()); 2435 host_impl_->active_tree()->SetRootLayer(root.Pass());
2439 // The behaviour in this test assumes the page scale is applied at a layer 2436 // The behaviour in this test assumes the page scale is applied at a layer
2440 // above the clip layer. 2437 // above the clip layer.
2441 host_impl_->active_tree()->SetViewportLayersFromIds(1, 3, Layer::INVALID_ID); 2438 host_impl_->active_tree()->SetViewportLayersFromIds(1, 3, Layer::INVALID_ID);
2442 host_impl_->active_tree()->DidBecomeActive(); 2439 host_impl_->active_tree()->DidBecomeActive();
2443 host_impl_->SetViewportSize(viewport_size); 2440 host_impl_->SetViewportSize(viewport_size);
2444 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 1.f, page_scale); 2441 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 1.f, page_scale);
2445 DrawFrame(); 2442 DrawFrame();
2446 2443
2447 LayerImpl* root_scroll = 2444 LayerImpl* root_scroll =
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
2532 EXPECT_EQ(new_page_scale, 2529 EXPECT_EQ(new_page_scale,
2533 grand_child->draw_transform().matrix().getDouble(0, 0)); 2530 grand_child->draw_transform().matrix().getDouble(0, 0));
2534 EXPECT_EQ(new_page_scale, 2531 EXPECT_EQ(new_page_scale,
2535 grand_child->draw_transform().matrix().getDouble(1, 1)); 2532 grand_child->draw_transform().matrix().getDouble(1, 1));
2536 } 2533 }
2537 2534
2538 TEST_F(LayerTreeHostImplTest, ScrollChildAndChangePageScaleOnMainThread) { 2535 TEST_F(LayerTreeHostImplTest, ScrollChildAndChangePageScaleOnMainThread) {
2539 gfx::Size surface_size(30, 30); 2536 gfx::Size surface_size(30, 30);
2540 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); 2537 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
2541 root->SetBounds(gfx::Size(5, 5)); 2538 root->SetBounds(gfx::Size(5, 5));
2539 root->SetHasRenderSurface(true);
2542 scoped_ptr<LayerImpl> root_scrolling = 2540 scoped_ptr<LayerImpl> root_scrolling =
2543 LayerImpl::Create(host_impl_->active_tree(), 2); 2541 LayerImpl::Create(host_impl_->active_tree(), 2);
2544 root_scrolling->SetBounds(surface_size); 2542 root_scrolling->SetBounds(surface_size);
2545 root_scrolling->SetContentBounds(surface_size); 2543 root_scrolling->SetContentBounds(surface_size);
2546 root_scrolling->SetScrollClipLayer(root->id()); 2544 root_scrolling->SetScrollClipLayer(root->id());
2547 root_scrolling->SetIsContainerForFixedPositionLayers(true); 2545 root_scrolling->SetIsContainerForFixedPositionLayers(true);
2548 LayerImpl* root_scrolling_ptr = root_scrolling.get(); 2546 LayerImpl* root_scrolling_ptr = root_scrolling.get();
2549 root->AddChild(root_scrolling.Pass()); 2547 root->AddChild(root_scrolling.Pass());
2550 int child_scroll_layer_id = 3; 2548 int child_scroll_layer_id = 3;
2551 scoped_ptr<LayerImpl> child_scrolling = CreateScrollableLayer( 2549 scoped_ptr<LayerImpl> child_scrolling = CreateScrollableLayer(
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2587 } 2585 }
2588 2586
2589 TEST_F(LayerTreeHostImplTest, ScrollChildBeyondLimit) { 2587 TEST_F(LayerTreeHostImplTest, ScrollChildBeyondLimit) {
2590 // Scroll a child layer beyond its maximum scroll range and make sure the 2588 // 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 2589 // parent layer is scrolled on the axis on which the child was unable to
2592 // scroll. 2590 // scroll.
2593 gfx::Size surface_size(10, 10); 2591 gfx::Size surface_size(10, 10);
2594 gfx::Size content_size(20, 20); 2592 gfx::Size content_size(20, 20);
2595 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); 2593 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
2596 root->SetBounds(surface_size); 2594 root->SetBounds(surface_size);
2597 2595 root->SetHasRenderSurface(true);
2598 scoped_ptr<LayerImpl> grand_child = 2596 scoped_ptr<LayerImpl> grand_child =
2599 CreateScrollableLayer(3, content_size, root.get()); 2597 CreateScrollableLayer(3, content_size, root.get());
2600 2598
2601 scoped_ptr<LayerImpl> child = 2599 scoped_ptr<LayerImpl> child =
2602 CreateScrollableLayer(2, content_size, root.get()); 2600 CreateScrollableLayer(2, content_size, root.get());
2603 LayerImpl* grand_child_layer = grand_child.get(); 2601 LayerImpl* grand_child_layer = grand_child.get();
2604 child->AddChild(grand_child.Pass()); 2602 child->AddChild(grand_child.Pass());
2605 2603
2606 LayerImpl* child_layer = child.get(); 2604 LayerImpl* child_layer = child.get();
2607 root->AddChild(child.Pass()); 2605 root->AddChild(child.Pass());
(...skipping 24 matching lines...) Expand all
2632 ExpectContains(*scroll_info.get(), child->id(), gfx::Vector2d(-3, 0)); 2630 ExpectContains(*scroll_info.get(), child->id(), gfx::Vector2d(-3, 0));
2633 } 2631 }
2634 } 2632 }
2635 2633
2636 TEST_F(LayerTreeHostImplTest, ScrollWithoutBubbling) { 2634 TEST_F(LayerTreeHostImplTest, ScrollWithoutBubbling) {
2637 // Scroll a child layer beyond its maximum scroll range and make sure the 2635 // Scroll a child layer beyond its maximum scroll range and make sure the
2638 // the scroll doesn't bubble up to the parent layer. 2636 // the scroll doesn't bubble up to the parent layer.
2639 gfx::Size surface_size(20, 20); 2637 gfx::Size surface_size(20, 20);
2640 gfx::Size viewport_size(10, 10); 2638 gfx::Size viewport_size(10, 10);
2641 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); 2639 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
2640 root->SetHasRenderSurface(true);
2642 scoped_ptr<LayerImpl> root_scrolling = 2641 scoped_ptr<LayerImpl> root_scrolling =
2643 CreateScrollableLayer(2, surface_size, root.get()); 2642 CreateScrollableLayer(2, surface_size, root.get());
2644 root_scrolling->SetIsContainerForFixedPositionLayers(true); 2643 root_scrolling->SetIsContainerForFixedPositionLayers(true);
2645 2644
2646 scoped_ptr<LayerImpl> grand_child = 2645 scoped_ptr<LayerImpl> grand_child =
2647 CreateScrollableLayer(4, surface_size, root.get()); 2646 CreateScrollableLayer(4, surface_size, root.get());
2648 2647
2649 scoped_ptr<LayerImpl> child = 2648 scoped_ptr<LayerImpl> child =
2650 CreateScrollableLayer(3, surface_size, root.get()); 2649 CreateScrollableLayer(3, surface_size, root.get());
2651 LayerImpl* grand_child_layer = grand_child.get(); 2650 LayerImpl* grand_child_layer = grand_child.get();
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
2740 ExpectContains(*scroll_info.get(), grand_child->id(), gfx::Vector2d(0, 4)); 2739 ExpectContains(*scroll_info.get(), grand_child->id(), gfx::Vector2d(0, 4));
2741 } 2740 }
2742 } 2741 }
2743 TEST_F(LayerTreeHostImplTest, ScrollEventBubbling) { 2742 TEST_F(LayerTreeHostImplTest, ScrollEventBubbling) {
2744 // When we try to scroll a non-scrollable child layer, the scroll delta 2743 // When we try to scroll a non-scrollable child layer, the scroll delta
2745 // should be applied to one of its ancestors if possible. 2744 // should be applied to one of its ancestors if possible.
2746 gfx::Size surface_size(10, 10); 2745 gfx::Size surface_size(10, 10);
2747 gfx::Size content_size(20, 20); 2746 gfx::Size content_size(20, 20);
2748 scoped_ptr<LayerImpl> root_clip = 2747 scoped_ptr<LayerImpl> root_clip =
2749 LayerImpl::Create(host_impl_->active_tree(), 3); 2748 LayerImpl::Create(host_impl_->active_tree(), 3);
2749 root_clip->SetHasRenderSurface(true);
2750 scoped_ptr<LayerImpl> root = 2750 scoped_ptr<LayerImpl> root =
2751 CreateScrollableLayer(1, content_size, root_clip.get()); 2751 CreateScrollableLayer(1, content_size, root_clip.get());
2752 // Make 'root' the clip layer for child: since they have the same sizes the 2752 // 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. 2753 // child will have zero max_scroll_offset and scrolls will bubble.
2754 scoped_ptr<LayerImpl> child = 2754 scoped_ptr<LayerImpl> child =
2755 CreateScrollableLayer(2, content_size, root.get()); 2755 CreateScrollableLayer(2, content_size, root.get());
2756 child->SetIsContainerForFixedPositionLayers(true); 2756 child->SetIsContainerForFixedPositionLayers(true);
2757 root->SetBounds(content_size); 2757 root->SetBounds(content_size);
2758 2758
2759 int root_scroll_id = root->id(); 2759 int root_scroll_id = root->id();
(...skipping 22 matching lines...) Expand all
2782 } 2782 }
2783 } 2783 }
2784 2784
2785 TEST_F(LayerTreeHostImplTest, ScrollBeforeRedraw) { 2785 TEST_F(LayerTreeHostImplTest, ScrollBeforeRedraw) {
2786 gfx::Size surface_size(10, 10); 2786 gfx::Size surface_size(10, 10);
2787 scoped_ptr<LayerImpl> root_clip = 2787 scoped_ptr<LayerImpl> root_clip =
2788 LayerImpl::Create(host_impl_->active_tree(), 1); 2788 LayerImpl::Create(host_impl_->active_tree(), 1);
2789 scoped_ptr<LayerImpl> root_scroll = 2789 scoped_ptr<LayerImpl> root_scroll =
2790 CreateScrollableLayer(2, surface_size, root_clip.get()); 2790 CreateScrollableLayer(2, surface_size, root_clip.get());
2791 root_scroll->SetIsContainerForFixedPositionLayers(true); 2791 root_scroll->SetIsContainerForFixedPositionLayers(true);
2792 root_clip->SetHasRenderSurface(true);
2792 root_clip->AddChild(root_scroll.Pass()); 2793 root_clip->AddChild(root_scroll.Pass());
2793 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); 2794 host_impl_->active_tree()->SetRootLayer(root_clip.Pass());
2794 host_impl_->active_tree()->SetViewportLayersFromIds(1, 2, Layer::INVALID_ID); 2795 host_impl_->active_tree()->SetViewportLayersFromIds(1, 2, Layer::INVALID_ID);
2795 host_impl_->active_tree()->DidBecomeActive(); 2796 host_impl_->active_tree()->DidBecomeActive();
2796 host_impl_->SetViewportSize(surface_size); 2797 host_impl_->SetViewportSize(surface_size);
2797 2798
2798 // Draw one frame and then immediately rebuild the layer tree to mimic a tree 2799 // Draw one frame and then immediately rebuild the layer tree to mimic a tree
2799 // synchronization. 2800 // synchronization.
2800 DrawFrame(); 2801 DrawFrame();
2801 host_impl_->active_tree()->DetachLayerTree(); 2802 host_impl_->active_tree()->DetachLayerTree();
2802 scoped_ptr<LayerImpl> root_clip2 = 2803 scoped_ptr<LayerImpl> root_clip2 =
2803 LayerImpl::Create(host_impl_->active_tree(), 3); 2804 LayerImpl::Create(host_impl_->active_tree(), 3);
2804 scoped_ptr<LayerImpl> root_scroll2 = 2805 scoped_ptr<LayerImpl> root_scroll2 =
2805 CreateScrollableLayer(4, surface_size, root_clip2.get()); 2806 CreateScrollableLayer(4, surface_size, root_clip2.get());
2806 root_scroll2->SetIsContainerForFixedPositionLayers(true); 2807 root_scroll2->SetIsContainerForFixedPositionLayers(true);
2807 root_clip2->AddChild(root_scroll2.Pass()); 2808 root_clip2->AddChild(root_scroll2.Pass());
2809 root_clip2->SetHasRenderSurface(true);
2808 host_impl_->active_tree()->SetRootLayer(root_clip2.Pass()); 2810 host_impl_->active_tree()->SetRootLayer(root_clip2.Pass());
2809 host_impl_->active_tree()->SetViewportLayersFromIds(3, 4, Layer::INVALID_ID); 2811 host_impl_->active_tree()->SetViewportLayersFromIds(3, 4, Layer::INVALID_ID);
2810 host_impl_->active_tree()->DidBecomeActive(); 2812 host_impl_->active_tree()->DidBecomeActive();
2811 2813
2812 // Scrolling should still work even though we did not draw yet. 2814 // Scrolling should still work even though we did not draw yet.
2813 EXPECT_EQ(InputHandler::ScrollStarted, 2815 EXPECT_EQ(InputHandler::ScrollStarted,
2814 host_impl_->ScrollBegin(gfx::Point(5, 5), 2816 host_impl_->ScrollBegin(gfx::Point(5, 5),
2815 InputHandler::Wheel)); 2817 InputHandler::Wheel));
2816 } 2818 }
2817 2819
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
3239 host_impl_->ScrollEnd(); 3241 host_impl_->ScrollEnd();
3240 } 3242 }
3241 3243
3242 3244
3243 TEST_F(LayerTreeHostImplTest, OverscrollChildWithoutBubbling) { 3245 TEST_F(LayerTreeHostImplTest, OverscrollChildWithoutBubbling) {
3244 // Scroll child layers beyond their maximum scroll range and make sure root 3246 // Scroll child layers beyond their maximum scroll range and make sure root
3245 // overscroll does not accumulate. 3247 // overscroll does not accumulate.
3246 gfx::Size surface_size(10, 10); 3248 gfx::Size surface_size(10, 10);
3247 scoped_ptr<LayerImpl> root_clip = 3249 scoped_ptr<LayerImpl> root_clip =
3248 LayerImpl::Create(host_impl_->active_tree(), 4); 3250 LayerImpl::Create(host_impl_->active_tree(), 4);
3251 root_clip->SetHasRenderSurface(true);
3252
3249 scoped_ptr<LayerImpl> root = 3253 scoped_ptr<LayerImpl> root =
3250 CreateScrollableLayer(1, surface_size, root_clip.get()); 3254 CreateScrollableLayer(1, surface_size, root_clip.get());
3251 3255
3252 scoped_ptr<LayerImpl> grand_child = 3256 scoped_ptr<LayerImpl> grand_child =
3253 CreateScrollableLayer(3, surface_size, root_clip.get()); 3257 CreateScrollableLayer(3, surface_size, root_clip.get());
3254 3258
3255 scoped_ptr<LayerImpl> child = 3259 scoped_ptr<LayerImpl> child =
3256 CreateScrollableLayer(2, surface_size, root_clip.get()); 3260 CreateScrollableLayer(2, surface_size, root_clip.get());
3257 LayerImpl* grand_child_layer = grand_child.get(); 3261 LayerImpl* grand_child_layer = grand_child.get();
3258 child->AddChild(grand_child.Pass()); 3262 child->AddChild(grand_child.Pass());
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
3303 } 3307 }
3304 3308
3305 TEST_F(LayerTreeHostImplTest, OverscrollChildEventBubbling) { 3309 TEST_F(LayerTreeHostImplTest, OverscrollChildEventBubbling) {
3306 // When we try to scroll a non-scrollable child layer, the scroll delta 3310 // 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 3311 // 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. 3312 // be reflected only when it has bubbled up to the root scrolling layer.
3309 gfx::Size surface_size(10, 10); 3313 gfx::Size surface_size(10, 10);
3310 gfx::Size content_size(20, 20); 3314 gfx::Size content_size(20, 20);
3311 scoped_ptr<LayerImpl> root_clip = 3315 scoped_ptr<LayerImpl> root_clip =
3312 LayerImpl::Create(host_impl_->active_tree(), 3); 3316 LayerImpl::Create(host_impl_->active_tree(), 3);
3317 root_clip->SetHasRenderSurface(true);
3318
3313 scoped_ptr<LayerImpl> root = 3319 scoped_ptr<LayerImpl> root =
3314 CreateScrollableLayer(1, content_size, root_clip.get()); 3320 CreateScrollableLayer(1, content_size, root_clip.get());
3315 root->SetIsContainerForFixedPositionLayers(true); 3321 root->SetIsContainerForFixedPositionLayers(true);
3316 scoped_ptr<LayerImpl> child = 3322 scoped_ptr<LayerImpl> child =
3317 CreateScrollableLayer(2, content_size, root_clip.get()); 3323 CreateScrollableLayer(2, content_size, root_clip.get());
3318 3324
3319 child->SetScrollClipLayer(Layer::INVALID_ID); 3325 child->SetScrollClipLayer(Layer::INVALID_ID);
3320 root->AddChild(child.Pass()); 3326 root->AddChild(child.Pass());
3321 root_clip->AddChild(root.Pass()); 3327 root_clip->AddChild(root.Pass());
3322 3328
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
3358 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); 3364 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10));
3359 EXPECT_EQ(gfx::Vector2dF(0, 10), host_impl_->accumulated_root_overscroll()); 3365 EXPECT_EQ(gfx::Vector2dF(0, 10), host_impl_->accumulated_root_overscroll());
3360 } 3366 }
3361 3367
3362 TEST_F(LayerTreeHostImplTest, NoOverscrollOnFractionalDeviceScale) { 3368 TEST_F(LayerTreeHostImplTest, NoOverscrollOnFractionalDeviceScale) {
3363 gfx::Size surface_size(980, 1439); 3369 gfx::Size surface_size(980, 1439);
3364 gfx::Size content_size(980, 1438); 3370 gfx::Size content_size(980, 1438);
3365 float device_scale_factor = 1.5f; 3371 float device_scale_factor = 1.5f;
3366 scoped_ptr<LayerImpl> root_clip = 3372 scoped_ptr<LayerImpl> root_clip =
3367 LayerImpl::Create(host_impl_->active_tree(), 3); 3373 LayerImpl::Create(host_impl_->active_tree(), 3);
3374 root_clip->SetHasRenderSurface(true);
3375
3368 scoped_ptr<LayerImpl> root = 3376 scoped_ptr<LayerImpl> root =
3369 CreateScrollableLayer(1, content_size, root_clip.get()); 3377 CreateScrollableLayer(1, content_size, root_clip.get());
3370 root->SetIsContainerForFixedPositionLayers(true); 3378 root->SetIsContainerForFixedPositionLayers(true);
3371 scoped_ptr<LayerImpl> child = 3379 scoped_ptr<LayerImpl> child =
3372 CreateScrollableLayer(2, content_size, root_clip.get()); 3380 CreateScrollableLayer(2, content_size, root_clip.get());
3373 root->scroll_clip_layer()->SetBounds(gfx::Size(320, 469)); 3381 root->scroll_clip_layer()->SetBounds(gfx::Size(320, 469));
3374 host_impl_->active_tree()->SetPageScaleFactorAndLimits( 3382 host_impl_->active_tree()->SetPageScaleFactorAndLimits(
3375 0.326531f, 0.326531f, 5.f); 3383 0.326531f, 0.326531f, 5.f);
3376 host_impl_->active_tree()->SetPageScaleDelta(1.f); 3384 host_impl_->active_tree()->SetPageScaleDelta(1.f);
3377 child->SetScrollClipLayer(Layer::INVALID_ID); 3385 child->SetScrollClipLayer(Layer::INVALID_ID);
(...skipping 18 matching lines...) Expand all
3396 3404
3397 host_impl_->ScrollEnd(); 3405 host_impl_->ScrollEnd();
3398 } 3406 }
3399 } 3407 }
3400 3408
3401 TEST_F(LayerTreeHostImplTest, NoOverscrollWhenNotAtEdge) { 3409 TEST_F(LayerTreeHostImplTest, NoOverscrollWhenNotAtEdge) {
3402 gfx::Size surface_size(100, 100); 3410 gfx::Size surface_size(100, 100);
3403 gfx::Size content_size(200, 200); 3411 gfx::Size content_size(200, 200);
3404 scoped_ptr<LayerImpl> root_clip = 3412 scoped_ptr<LayerImpl> root_clip =
3405 LayerImpl::Create(host_impl_->active_tree(), 3); 3413 LayerImpl::Create(host_impl_->active_tree(), 3);
3414 root_clip->SetHasRenderSurface(true);
3415
3406 scoped_ptr<LayerImpl> root = 3416 scoped_ptr<LayerImpl> root =
3407 CreateScrollableLayer(1, content_size, root_clip.get()); 3417 CreateScrollableLayer(1, content_size, root_clip.get());
3408 root->SetIsContainerForFixedPositionLayers(true); 3418 root->SetIsContainerForFixedPositionLayers(true);
3409 scoped_ptr<LayerImpl> child = 3419 scoped_ptr<LayerImpl> child =
3410 CreateScrollableLayer(2, content_size, root_clip.get()); 3420 CreateScrollableLayer(2, content_size, root_clip.get());
3411 3421
3412 child->SetScrollClipLayer(Layer::INVALID_ID); 3422 child->SetScrollClipLayer(Layer::INVALID_ID);
3413 root->AddChild(child.Pass()); 3423 root->AddChild(child.Pass());
3414 root_clip->AddChild(root.Pass()); 3424 root_clip->AddChild(root.Pass());
3415 3425
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
3541 ResourceProvider::ResourceId resource_id_; 3551 ResourceProvider::ResourceId resource_id_;
3542 }; 3552 };
3543 3553
3544 TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { 3554 TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) {
3545 { 3555 {
3546 scoped_ptr<LayerImpl> root = 3556 scoped_ptr<LayerImpl> root =
3547 LayerImpl::Create(host_impl_->active_tree(), 1); 3557 LayerImpl::Create(host_impl_->active_tree(), 1);
3548 root->SetBounds(gfx::Size(10, 10)); 3558 root->SetBounds(gfx::Size(10, 10));
3549 root->SetContentBounds(root->bounds()); 3559 root->SetContentBounds(root->bounds());
3550 root->SetDrawsContent(false); 3560 root->SetDrawsContent(false);
3561 root->SetHasRenderSurface(true);
3551 host_impl_->active_tree()->SetRootLayer(root.Pass()); 3562 host_impl_->active_tree()->SetRootLayer(root.Pass());
3552 } 3563 }
3553 LayerImpl* root = host_impl_->active_tree()->root_layer(); 3564 LayerImpl* root = host_impl_->active_tree()->root_layer();
3554 3565
3555 root->AddChild( 3566 root->AddChild(
3556 BlendStateCheckLayer::Create(host_impl_->active_tree(), 3567 BlendStateCheckLayer::Create(host_impl_->active_tree(),
3557 2, 3568 2,
3558 host_impl_->resource_provider())); 3569 host_impl_->resource_provider()));
3559 BlendStateCheckLayer* layer1 = 3570 BlendStateCheckLayer* layer1 =
3560 static_cast<BlendStateCheckLayer*>(root->children()[0]); 3571 static_cast<BlendStateCheckLayer*>(root->children()[0]);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
3650 EXPECT_TRUE(layer2->quads_appended()); 3661 EXPECT_TRUE(layer2->quads_appended());
3651 host_impl_->DidDrawAllLayers(frame); 3662 host_impl_->DidDrawAllLayers(frame);
3652 3663
3653 // Parent layer with translucent opacity and opaque content. Since it has a 3664 // 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, 3665 // drawing child, it's drawn to a render surface which carries the opacity,
3655 // so it's itself drawn without blending. 3666 // so it's itself drawn without blending.
3656 // Child layer with opaque content, drawn without blending (parent surface 3667 // Child layer with opaque content, drawn without blending (parent surface
3657 // carries the inherited opacity). 3668 // carries the inherited opacity).
3658 layer1->SetContentsOpaque(true); 3669 layer1->SetContentsOpaque(true);
3659 layer1->SetOpacity(0.5f); 3670 layer1->SetOpacity(0.5f);
3671 layer1->SetHasRenderSurface(true);
3660 layer1->SetExpectation(false, true); 3672 layer1->SetExpectation(false, true);
3661 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3673 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3662 layer2->SetExpectation(false, false); 3674 layer2->SetExpectation(false, false);
3663 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3675 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3664 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( 3676 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(
3665 host_impl_->active_tree()->root_layer()); 3677 host_impl_->active_tree()->root_layer());
3666 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 3678 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3667 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3679 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3668 EXPECT_TRUE(layer1->quads_appended()); 3680 EXPECT_TRUE(layer1->quads_appended());
3669 EXPECT_TRUE(layer2->quads_appended()); 3681 EXPECT_TRUE(layer2->quads_appended());
3670 host_impl_->DidDrawAllLayers(frame); 3682 host_impl_->DidDrawAllLayers(frame);
3683 layer1->SetHasRenderSurface(false);
3671 3684
3672 // Draw again, but with child non-opaque, to make sure 3685 // Draw again, but with child non-opaque, to make sure
3673 // layer1 not culled. 3686 // layer1 not culled.
3674 layer1->SetContentsOpaque(true); 3687 layer1->SetContentsOpaque(true);
3675 layer1->SetOpacity(1.f); 3688 layer1->SetOpacity(1.f);
3676 layer1->SetExpectation(false, false); 3689 layer1->SetExpectation(false, false);
3677 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3690 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3678 layer2->SetContentsOpaque(true); 3691 layer2->SetContentsOpaque(true);
3679 layer2->SetOpacity(0.5f); 3692 layer2->SetOpacity(0.5f);
3680 layer2->SetExpectation(true, false); 3693 layer2->SetExpectation(true, false);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
3778 return FakeOutputSurface::CreateAlwaysDrawAndSwap3d() 3791 return FakeOutputSurface::CreateAlwaysDrawAndSwap3d()
3779 .PassAs<OutputSurface>(); 3792 .PassAs<OutputSurface>();
3780 } 3793 }
3781 return FakeOutputSurface::Create3d().PassAs<OutputSurface>(); 3794 return FakeOutputSurface::Create3d().PassAs<OutputSurface>();
3782 } 3795 }
3783 3796
3784 void SetupActiveTreeLayers() { 3797 void SetupActiveTreeLayers() {
3785 host_impl_->active_tree()->set_background_color(SK_ColorGRAY); 3798 host_impl_->active_tree()->set_background_color(SK_ColorGRAY);
3786 host_impl_->active_tree()->SetRootLayer( 3799 host_impl_->active_tree()->SetRootLayer(
3787 LayerImpl::Create(host_impl_->active_tree(), 1)); 3800 LayerImpl::Create(host_impl_->active_tree(), 1));
3801 host_impl_->active_tree()->root_layer()->SetHasRenderSurface(true);
3788 host_impl_->active_tree()->root_layer()->AddChild( 3802 host_impl_->active_tree()->root_layer()->AddChild(
3789 BlendStateCheckLayer::Create(host_impl_->active_tree(), 3803 BlendStateCheckLayer::Create(host_impl_->active_tree(),
3790 2, 3804 2,
3791 host_impl_->resource_provider())); 3805 host_impl_->resource_provider()));
3792 child_ = static_cast<BlendStateCheckLayer*>( 3806 child_ = static_cast<BlendStateCheckLayer*>(
3793 host_impl_->active_tree()->root_layer()->children()[0]); 3807 host_impl_->active_tree()->root_layer()->children()[0]);
3794 child_->SetExpectation(false, false); 3808 child_->SetExpectation(false, false);
3795 child_->SetContentsOpaque(true); 3809 child_->SetContentsOpaque(true);
3796 } 3810 }
3797 3811
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
4069 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); 4083 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create());
4070 scoped_ptr<OutputSurface> output_surface( 4084 scoped_ptr<OutputSurface> output_surface(
4071 FakeOutputSurface::Create3d(provider)); 4085 FakeOutputSurface::Create3d(provider));
4072 CreateHostImpl(DefaultSettings(), output_surface.Pass()); 4086 CreateHostImpl(DefaultSettings(), output_surface.Pass());
4073 4087
4074 scoped_ptr<LayerImpl> root = 4088 scoped_ptr<LayerImpl> root =
4075 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); 4089 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1);
4076 root->SetBounds(gfx::Size(10, 10)); 4090 root->SetBounds(gfx::Size(10, 10));
4077 root->SetContentBounds(gfx::Size(10, 10)); 4091 root->SetContentBounds(gfx::Size(10, 10));
4078 root->SetDrawsContent(true); 4092 root->SetDrawsContent(true);
4093 root->SetHasRenderSurface(true);
4079 host_impl_->active_tree()->SetRootLayer(root.Pass()); 4094 host_impl_->active_tree()->SetRootLayer(root.Pass());
4080 EXPECT_FALSE(provider->TestContext3d()->reshape_called()); 4095 EXPECT_FALSE(provider->TestContext3d()->reshape_called());
4081 provider->TestContext3d()->clear_reshape_called(); 4096 provider->TestContext3d()->clear_reshape_called();
4082 4097
4083 LayerTreeHostImpl::FrameData frame; 4098 LayerTreeHostImpl::FrameData frame;
4084 host_impl_->SetViewportSize(gfx::Size(10, 10)); 4099 host_impl_->SetViewportSize(gfx::Size(10, 10));
4085 host_impl_->SetDeviceScaleFactor(1.f); 4100 host_impl_->SetDeviceScaleFactor(1.f);
4086 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 4101 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
4087 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4102 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4088 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); 4103 EXPECT_TRUE(provider->TestContext3d()->reshape_called());
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
4135 this, 4150 this,
4136 &proxy_, 4151 &proxy_,
4137 &stats_instrumentation_, 4152 &stats_instrumentation_,
4138 shared_bitmap_manager.get(), 4153 shared_bitmap_manager.get(),
4139 0); 4154 0);
4140 layer_tree_host_impl->InitializeRenderer(output_surface.Pass()); 4155 layer_tree_host_impl->InitializeRenderer(output_surface.Pass());
4141 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); 4156 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500));
4142 4157
4143 scoped_ptr<LayerImpl> root = 4158 scoped_ptr<LayerImpl> root =
4144 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); 4159 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1);
4160 root->SetHasRenderSurface(true);
4145 scoped_ptr<LayerImpl> child = 4161 scoped_ptr<LayerImpl> child =
4146 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); 4162 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2);
4147 child->SetPosition(gfx::PointF(12.f, 13.f)); 4163 child->SetPosition(gfx::PointF(12.f, 13.f));
4148 child->SetBounds(gfx::Size(14, 15)); 4164 child->SetBounds(gfx::Size(14, 15));
4149 child->SetContentBounds(gfx::Size(14, 15)); 4165 child->SetContentBounds(gfx::Size(14, 15));
4150 child->SetDrawsContent(true); 4166 child->SetDrawsContent(true);
4151 root->SetBounds(gfx::Size(500, 500)); 4167 root->SetBounds(gfx::Size(500, 500));
4152 root->SetContentBounds(gfx::Size(500, 500)); 4168 root->SetContentBounds(gfx::Size(500, 500));
4153 root->SetDrawsContent(true); 4169 root->SetDrawsContent(true);
4154 root->AddChild(child.Pass()); 4170 root->AddChild(child.Pass());
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
4202 scoped_ptr<LayerImpl> root = 4218 scoped_ptr<LayerImpl> root =
4203 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); 4219 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1);
4204 scoped_ptr<LayerImpl> child = 4220 scoped_ptr<LayerImpl> child =
4205 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2); 4221 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2);
4206 child->SetBounds(gfx::Size(10, 10)); 4222 child->SetBounds(gfx::Size(10, 10));
4207 child->SetContentBounds(gfx::Size(10, 10)); 4223 child->SetContentBounds(gfx::Size(10, 10));
4208 child->SetDrawsContent(true); 4224 child->SetDrawsContent(true);
4209 root->SetBounds(gfx::Size(10, 10)); 4225 root->SetBounds(gfx::Size(10, 10));
4210 root->SetContentBounds(gfx::Size(10, 10)); 4226 root->SetContentBounds(gfx::Size(10, 10));
4211 root->SetDrawsContent(true); 4227 root->SetDrawsContent(true);
4212 root->SetForceRenderSurface(true); 4228 root->SetHasRenderSurface(true);
4213 root->AddChild(child.Pass()); 4229 root->AddChild(child.Pass());
4214 4230
4215 host_impl_->active_tree()->SetRootLayer(root.Pass()); 4231 host_impl_->active_tree()->SetRootLayer(root.Pass());
4216 4232
4217 LayerTreeHostImpl::FrameData frame; 4233 LayerTreeHostImpl::FrameData frame;
4218 4234
4219 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 4235 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
4220 EXPECT_EQ(1u, frame.render_surface_layer_list->size()); 4236 EXPECT_EQ(1u, frame.render_surface_layer_list->size());
4221 EXPECT_EQ(1u, frame.render_passes.size()); 4237 EXPECT_EQ(1u, frame.render_passes.size());
4222 host_impl_->DidDrawAllLayers(frame); 4238 host_impl_->DidDrawAllLayers(frame);
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
4455 LayerImpl::Create(my_host_impl->active_tree(), 1); 4471 LayerImpl::Create(my_host_impl->active_tree(), 1);
4456 scoped_ptr<LayerImpl> child = 4472 scoped_ptr<LayerImpl> child =
4457 LayerImpl::Create(my_host_impl->active_tree(), 2); 4473 LayerImpl::Create(my_host_impl->active_tree(), 2);
4458 scoped_ptr<LayerImpl> grand_child = 4474 scoped_ptr<LayerImpl> grand_child =
4459 FakeLayerWithQuads::Create(my_host_impl->active_tree(), 3); 4475 FakeLayerWithQuads::Create(my_host_impl->active_tree(), 3);
4460 4476
4461 gfx::Rect root_rect(0, 0, 100, 100); 4477 gfx::Rect root_rect(0, 0, 100, 100);
4462 gfx::Rect child_rect(10, 10, 50, 50); 4478 gfx::Rect child_rect(10, 10, 50, 50);
4463 gfx::Rect grand_child_rect(5, 5, 150, 150); 4479 gfx::Rect grand_child_rect(5, 5, 150, 150);
4464 4480
4465 root->CreateRenderSurface(); 4481 root->SetHasRenderSurface(true);
4466 root->SetPosition(root_rect.origin()); 4482 root->SetPosition(root_rect.origin());
4467 root->SetBounds(root_rect.size()); 4483 root->SetBounds(root_rect.size());
4468 root->SetContentBounds(root->bounds()); 4484 root->SetContentBounds(root->bounds());
4469 root->draw_properties().visible_content_rect = root_rect; 4485 root->draw_properties().visible_content_rect = root_rect;
4470 root->SetDrawsContent(false); 4486 root->SetDrawsContent(false);
4471 root->render_surface()->SetContentRect(gfx::Rect(root_rect.size())); 4487 root->render_surface()->SetContentRect(gfx::Rect(root_rect.size()));
4472 4488
4473 child->SetPosition(gfx::PointF(child_rect.x(), child_rect.y())); 4489 child->SetPosition(gfx::PointF(child_rect.x(), child_rect.y()));
4474 child->SetOpacity(0.5f); 4490 child->SetOpacity(0.5f);
4475 child->SetBounds(gfx::Size(child_rect.width(), child_rect.height())); 4491 child->SetBounds(gfx::Size(child_rect.width(), child_rect.height()));
4476 child->SetContentBounds(child->bounds()); 4492 child->SetContentBounds(child->bounds());
4477 child->draw_properties().visible_content_rect = child_rect; 4493 child->draw_properties().visible_content_rect = child_rect;
4478 child->SetDrawsContent(false); 4494 child->SetDrawsContent(false);
4479 child->SetForceRenderSurface(true); 4495 child->SetHasRenderSurface(true);
4480 4496
4481 grand_child->SetPosition(grand_child_rect.origin()); 4497 grand_child->SetPosition(grand_child_rect.origin());
4482 grand_child->SetBounds(grand_child_rect.size()); 4498 grand_child->SetBounds(grand_child_rect.size());
4483 grand_child->SetContentBounds(grand_child->bounds()); 4499 grand_child->SetContentBounds(grand_child->bounds());
4484 grand_child->draw_properties().visible_content_rect = grand_child_rect; 4500 grand_child->draw_properties().visible_content_rect = grand_child_rect;
4485 grand_child->SetDrawsContent(true); 4501 grand_child->SetDrawsContent(true);
4486 4502
4487 child->AddChild(grand_child.Pass()); 4503 child->AddChild(grand_child.Pass());
4488 root->AddChild(child.Pass()); 4504 root->AddChild(child.Pass());
4489 4505
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
4549 scoped_ptr<TestWebGraphicsContext3D> context = 4565 scoped_ptr<TestWebGraphicsContext3D> context =
4550 TestWebGraphicsContext3D::Create(); 4566 TestWebGraphicsContext3D::Create();
4551 TestWebGraphicsContext3D* context3d = context.get(); 4567 TestWebGraphicsContext3D* context3d = context.get();
4552 scoped_ptr<OutputSurface> output_surface( 4568 scoped_ptr<OutputSurface> output_surface(
4553 FakeOutputSurface::Create3d(context.Pass())); 4569 FakeOutputSurface::Create3d(context.Pass()));
4554 CreateHostImpl(DefaultSettings(), output_surface.Pass()); 4570 CreateHostImpl(DefaultSettings(), output_surface.Pass());
4555 4571
4556 scoped_ptr<LayerImpl> root_layer = 4572 scoped_ptr<LayerImpl> root_layer =
4557 LayerImpl::Create(host_impl_->active_tree(), 1); 4573 LayerImpl::Create(host_impl_->active_tree(), 1);
4558 root_layer->SetBounds(gfx::Size(10, 10)); 4574 root_layer->SetBounds(gfx::Size(10, 10));
4575 root_layer->SetHasRenderSurface(true);
4559 4576
4560 scoped_refptr<VideoFrame> softwareFrame = 4577 scoped_refptr<VideoFrame> softwareFrame =
4561 media::VideoFrame::CreateColorFrame( 4578 media::VideoFrame::CreateColorFrame(
4562 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); 4579 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta());
4563 FakeVideoFrameProvider provider; 4580 FakeVideoFrameProvider provider;
4564 provider.set_frame(softwareFrame); 4581 provider.set_frame(softwareFrame);
4565 scoped_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( 4582 scoped_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create(
4566 host_impl_->active_tree(), 4, &provider, media::VIDEO_ROTATION_0); 4583 host_impl_->active_tree(), 4, &provider, media::VIDEO_ROTATION_0);
4567 video_layer->SetBounds(gfx::Size(10, 10)); 4584 video_layer->SetBounds(gfx::Size(10, 10));
4568 video_layer->SetContentBounds(gfx::Size(10, 10)); 4585 video_layer->SetContentBounds(gfx::Size(10, 10));
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
4725 } 4742 }
4726 }; 4743 };
4727 4744
4728 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) { 4745 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) {
4729 scoped_ptr<SolidColorLayerImpl> root = 4746 scoped_ptr<SolidColorLayerImpl> root =
4730 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); 4747 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1);
4731 root->SetPosition(gfx::PointF()); 4748 root->SetPosition(gfx::PointF());
4732 root->SetBounds(gfx::Size(10, 10)); 4749 root->SetBounds(gfx::Size(10, 10));
4733 root->SetContentBounds(gfx::Size(10, 10)); 4750 root->SetContentBounds(gfx::Size(10, 10));
4734 root->SetDrawsContent(true); 4751 root->SetDrawsContent(true);
4752 root->SetHasRenderSurface(true);
4735 4753
4736 // Child layer is in the bottom right corner. 4754 // Child layer is in the bottom right corner.
4737 scoped_ptr<SolidColorLayerImpl> child = 4755 scoped_ptr<SolidColorLayerImpl> child =
4738 SolidColorLayerImpl::Create(host_impl_->active_tree(), 2); 4756 SolidColorLayerImpl::Create(host_impl_->active_tree(), 2);
4739 child->SetPosition(gfx::PointF(9.f, 9.f)); 4757 child->SetPosition(gfx::PointF(9.f, 9.f));
4740 child->SetBounds(gfx::Size(1, 1)); 4758 child->SetBounds(gfx::Size(1, 1));
4741 child->SetContentBounds(gfx::Size(1, 1)); 4759 child->SetContentBounds(gfx::Size(1, 1));
4742 child->SetDrawsContent(true); 4760 child->SetDrawsContent(true);
4743 root->AddChild(child.PassAs<LayerImpl>()); 4761 root->AddChild(child.PassAs<LayerImpl>());
4744 4762
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
4790 4808
4791 // Root 4809 // Root
4792 // | 4810 // |
4793 // +-- Scaling Layer (adds a 2x scale) 4811 // +-- Scaling Layer (adds a 2x scale)
4794 // | 4812 // |
4795 // +-- Content Layer 4813 // +-- Content Layer
4796 // +--Mask 4814 // +--Mask
4797 scoped_ptr<LayerImpl> scoped_root = 4815 scoped_ptr<LayerImpl> scoped_root =
4798 LayerImpl::Create(host_impl_->active_tree(), 1); 4816 LayerImpl::Create(host_impl_->active_tree(), 1);
4799 LayerImpl* root = scoped_root.get(); 4817 LayerImpl* root = scoped_root.get();
4818 root->SetHasRenderSurface(true);
4800 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); 4819 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass());
4801 4820
4802 scoped_ptr<LayerImpl> scoped_scaling_layer = 4821 scoped_ptr<LayerImpl> scoped_scaling_layer =
4803 LayerImpl::Create(host_impl_->active_tree(), 2); 4822 LayerImpl::Create(host_impl_->active_tree(), 2);
4804 LayerImpl* scaling_layer = scoped_scaling_layer.get(); 4823 LayerImpl* scaling_layer = scoped_scaling_layer.get();
4805 root->AddChild(scoped_scaling_layer.Pass()); 4824 root->AddChild(scoped_scaling_layer.Pass());
4806 4825
4807 scoped_ptr<LayerImpl> scoped_content_layer = 4826 scoped_ptr<LayerImpl> scoped_content_layer =
4808 LayerImpl::Create(host_impl_->active_tree(), 3); 4827 LayerImpl::Create(host_impl_->active_tree(), 3);
4809 LayerImpl* content_layer = scoped_content_layer.get(); 4828 LayerImpl* content_layer = scoped_content_layer.get();
4810 scaling_layer->AddChild(scoped_content_layer.Pass()); 4829 scaling_layer->AddChild(scoped_content_layer.Pass());
4811 4830
4812 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = 4831 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer =
4813 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); 4832 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4);
4814 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); 4833 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get();
4815 content_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>()); 4834 content_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>());
4835 content_layer->SetHasRenderSurface(true);
4816 4836
4817 gfx::Size root_size(100, 100); 4837 gfx::Size root_size(100, 100);
4818 root->SetBounds(root_size); 4838 root->SetBounds(root_size);
4819 root->SetContentBounds(root_size); 4839 root->SetContentBounds(root_size);
4820 root->SetPosition(gfx::PointF()); 4840 root->SetPosition(gfx::PointF());
4821 4841
4822 gfx::Size scaling_layer_size(50, 50); 4842 gfx::Size scaling_layer_size(50, 50);
4823 scaling_layer->SetBounds(scaling_layer_size); 4843 scaling_layer->SetBounds(scaling_layer_size);
4824 scaling_layer->SetContentBounds(scaling_layer_size); 4844 scaling_layer->SetContentBounds(scaling_layer_size);
4825 scaling_layer->SetPosition(gfx::PointF()); 4845 scaling_layer->SetPosition(gfx::PointF());
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
4921 } 4941 }
4922 } 4942 }
4923 4943
4924 TEST_F(LayerTreeHostImplTest, MaskLayerWithDifferentBounds) { 4944 TEST_F(LayerTreeHostImplTest, MaskLayerWithDifferentBounds) {
4925 // The mask layer has bounds 100x100 but is attached to a layer with bounds 4945 // The mask layer has bounds 100x100 but is attached to a layer with bounds
4926 // 50x50. 4946 // 50x50.
4927 4947
4928 scoped_ptr<LayerImpl> scoped_root = 4948 scoped_ptr<LayerImpl> scoped_root =
4929 LayerImpl::Create(host_impl_->active_tree(), 1); 4949 LayerImpl::Create(host_impl_->active_tree(), 1);
4930 LayerImpl* root = scoped_root.get(); 4950 LayerImpl* root = scoped_root.get();
4951 root->SetHasRenderSurface(true);
4952
4931 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); 4953 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass());
4932 4954
4933 scoped_ptr<LayerImpl> scoped_content_layer = 4955 scoped_ptr<LayerImpl> scoped_content_layer =
4934 LayerImpl::Create(host_impl_->active_tree(), 3); 4956 LayerImpl::Create(host_impl_->active_tree(), 3);
4935 LayerImpl* content_layer = scoped_content_layer.get(); 4957 LayerImpl* content_layer = scoped_content_layer.get();
4936 root->AddChild(scoped_content_layer.Pass()); 4958 root->AddChild(scoped_content_layer.Pass());
4937 4959
4938 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = 4960 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer =
4939 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); 4961 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4);
4940 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); 4962 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get();
4941 content_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>()); 4963 content_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>());
4964 content_layer->SetHasRenderSurface(true);
4942 4965
4943 gfx::Size root_size(100, 100); 4966 gfx::Size root_size(100, 100);
4944 root->SetBounds(root_size); 4967 root->SetBounds(root_size);
4945 root->SetContentBounds(root_size); 4968 root->SetContentBounds(root_size);
4946 root->SetPosition(gfx::PointF()); 4969 root->SetPosition(gfx::PointF());
4947 4970
4948 gfx::Size layer_size(50, 50); 4971 gfx::Size layer_size(50, 50);
4949 content_layer->SetBounds(layer_size); 4972 content_layer->SetBounds(layer_size);
4950 content_layer->SetContentBounds(layer_size); 4973 content_layer->SetContentBounds(layer_size);
4951 content_layer->SetPosition(gfx::PointF()); 4974 content_layer->SetPosition(gfx::PointF());
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
5063 } 5086 }
5064 } 5087 }
5065 5088
5066 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerWithDifferentBounds) { 5089 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerWithDifferentBounds) {
5067 // The replica's mask layer has bounds 100x100 but the replica is of a 5090 // The replica's mask layer has bounds 100x100 but the replica is of a
5068 // layer with bounds 50x50. 5091 // layer with bounds 50x50.
5069 5092
5070 scoped_ptr<LayerImpl> scoped_root = 5093 scoped_ptr<LayerImpl> scoped_root =
5071 LayerImpl::Create(host_impl_->active_tree(), 1); 5094 LayerImpl::Create(host_impl_->active_tree(), 1);
5072 LayerImpl* root = scoped_root.get(); 5095 LayerImpl* root = scoped_root.get();
5096 root->SetHasRenderSurface(true);
5097
5073 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); 5098 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass());
5074 5099
5075 scoped_ptr<LayerImpl> scoped_content_layer = 5100 scoped_ptr<LayerImpl> scoped_content_layer =
5076 LayerImpl::Create(host_impl_->active_tree(), 3); 5101 LayerImpl::Create(host_impl_->active_tree(), 3);
5077 LayerImpl* content_layer = scoped_content_layer.get(); 5102 LayerImpl* content_layer = scoped_content_layer.get();
5078 root->AddChild(scoped_content_layer.Pass()); 5103 root->AddChild(scoped_content_layer.Pass());
5079 5104
5080 scoped_ptr<LayerImpl> scoped_replica_layer = 5105 scoped_ptr<LayerImpl> scoped_replica_layer =
5081 LayerImpl::Create(host_impl_->active_tree(), 2); 5106 LayerImpl::Create(host_impl_->active_tree(), 2);
5082 LayerImpl* replica_layer = scoped_replica_layer.get(); 5107 LayerImpl* replica_layer = scoped_replica_layer.get();
5083 content_layer->SetReplicaLayer(scoped_replica_layer.Pass()); 5108 content_layer->SetReplicaLayer(scoped_replica_layer.Pass());
5109 content_layer->SetHasRenderSurface(true);
5084 5110
5085 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = 5111 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer =
5086 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); 5112 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4);
5087 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); 5113 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get();
5088 replica_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>()); 5114 replica_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>());
5115 replica_layer->SetHasRenderSurface(true);
5089 5116
5090 gfx::Size root_size(100, 100); 5117 gfx::Size root_size(100, 100);
5091 root->SetBounds(root_size); 5118 root->SetBounds(root_size);
5092 root->SetContentBounds(root_size); 5119 root->SetContentBounds(root_size);
5093 root->SetPosition(gfx::PointF()); 5120 root->SetPosition(gfx::PointF());
5094 5121
5095 gfx::Size layer_size(50, 50); 5122 gfx::Size layer_size(50, 50);
5096 content_layer->SetBounds(layer_size); 5123 content_layer->SetBounds(layer_size);
5097 content_layer->SetContentBounds(layer_size); 5124 content_layer->SetContentBounds(layer_size);
5098 content_layer->SetPosition(gfx::PointF()); 5125 content_layer->SetPosition(gfx::PointF());
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
5210 } 5237 }
5211 } 5238 }
5212 5239
5213 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerForSurfaceWithUnclippedChild) { 5240 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerForSurfaceWithUnclippedChild) {
5214 // The replica is of a layer with bounds 50x50, but it has a child that causes 5241 // The replica is of a layer with bounds 50x50, but it has a child that causes
5215 // the surface bounds to be larger. 5242 // the surface bounds to be larger.
5216 5243
5217 scoped_ptr<LayerImpl> scoped_root = 5244 scoped_ptr<LayerImpl> scoped_root =
5218 LayerImpl::Create(host_impl_->active_tree(), 1); 5245 LayerImpl::Create(host_impl_->active_tree(), 1);
5219 LayerImpl* root = scoped_root.get(); 5246 LayerImpl* root = scoped_root.get();
5247 root->SetHasRenderSurface(true);
5220 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); 5248 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass());
5221 5249
5222 scoped_ptr<LayerImpl> scoped_content_layer = 5250 scoped_ptr<LayerImpl> scoped_content_layer =
5223 LayerImpl::Create(host_impl_->active_tree(), 2); 5251 LayerImpl::Create(host_impl_->active_tree(), 2);
5224 LayerImpl* content_layer = scoped_content_layer.get(); 5252 LayerImpl* content_layer = scoped_content_layer.get();
5225 root->AddChild(scoped_content_layer.Pass()); 5253 root->AddChild(scoped_content_layer.Pass());
5226 5254
5227 scoped_ptr<LayerImpl> scoped_content_child_layer = 5255 scoped_ptr<LayerImpl> scoped_content_child_layer =
5228 LayerImpl::Create(host_impl_->active_tree(), 3); 5256 LayerImpl::Create(host_impl_->active_tree(), 3);
5229 LayerImpl* content_child_layer = scoped_content_child_layer.get(); 5257 LayerImpl* content_child_layer = scoped_content_child_layer.get();
5230 content_layer->AddChild(scoped_content_child_layer.Pass()); 5258 content_layer->AddChild(scoped_content_child_layer.Pass());
5231 5259
5232 scoped_ptr<LayerImpl> scoped_replica_layer = 5260 scoped_ptr<LayerImpl> scoped_replica_layer =
5233 LayerImpl::Create(host_impl_->active_tree(), 4); 5261 LayerImpl::Create(host_impl_->active_tree(), 4);
5234 LayerImpl* replica_layer = scoped_replica_layer.get(); 5262 LayerImpl* replica_layer = scoped_replica_layer.get();
5235 content_layer->SetReplicaLayer(scoped_replica_layer.Pass()); 5263 content_layer->SetReplicaLayer(scoped_replica_layer.Pass());
5264 content_layer->SetHasRenderSurface(true);
5236 5265
5237 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = 5266 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer =
5238 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 5); 5267 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 5);
5239 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); 5268 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get();
5240 replica_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>()); 5269 replica_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>());
5270 replica_layer->SetHasRenderSurface(true);
5241 5271
5242 gfx::Size root_size(100, 100); 5272 gfx::Size root_size(100, 100);
5243 root->SetBounds(root_size); 5273 root->SetBounds(root_size);
5244 root->SetContentBounds(root_size); 5274 root->SetContentBounds(root_size);
5245 root->SetPosition(gfx::PointF()); 5275 root->SetPosition(gfx::PointF());
5246 5276
5247 gfx::Size layer_size(50, 50); 5277 gfx::Size layer_size(50, 50);
5248 content_layer->SetBounds(layer_size); 5278 content_layer->SetBounds(layer_size);
5249 content_layer->SetContentBounds(layer_size); 5279 content_layer->SetContentBounds(layer_size);
5250 content_layer->SetPosition(gfx::PointF()); 5280 content_layer->SetPosition(gfx::PointF());
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
5328 } 5358 }
5329 5359
5330 TEST_F(LayerTreeHostImplTest, MaskLayerForSurfaceWithClippedLayer) { 5360 TEST_F(LayerTreeHostImplTest, MaskLayerForSurfaceWithClippedLayer) {
5331 // The masked layer has bounds 50x50, but it has a child that causes 5361 // 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 5362 // the surface bounds to be larger. It also has a parent that clips the
5333 // masked layer and its surface. 5363 // masked layer and its surface.
5334 5364
5335 scoped_ptr<LayerImpl> scoped_root = 5365 scoped_ptr<LayerImpl> scoped_root =
5336 LayerImpl::Create(host_impl_->active_tree(), 1); 5366 LayerImpl::Create(host_impl_->active_tree(), 1);
5337 LayerImpl* root = scoped_root.get(); 5367 LayerImpl* root = scoped_root.get();
5368 root->SetHasRenderSurface(true);
5369
5338 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); 5370 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass());
5339 5371
5340 scoped_ptr<LayerImpl> scoped_clipping_layer = 5372 scoped_ptr<LayerImpl> scoped_clipping_layer =
5341 LayerImpl::Create(host_impl_->active_tree(), 2); 5373 LayerImpl::Create(host_impl_->active_tree(), 2);
5342 LayerImpl* clipping_layer = scoped_clipping_layer.get(); 5374 LayerImpl* clipping_layer = scoped_clipping_layer.get();
5343 root->AddChild(scoped_clipping_layer.Pass()); 5375 root->AddChild(scoped_clipping_layer.Pass());
5344 5376
5345 scoped_ptr<LayerImpl> scoped_content_layer = 5377 scoped_ptr<LayerImpl> scoped_content_layer =
5346 LayerImpl::Create(host_impl_->active_tree(), 3); 5378 LayerImpl::Create(host_impl_->active_tree(), 3);
5347 LayerImpl* content_layer = scoped_content_layer.get(); 5379 LayerImpl* content_layer = scoped_content_layer.get();
5348 clipping_layer->AddChild(scoped_content_layer.Pass()); 5380 clipping_layer->AddChild(scoped_content_layer.Pass());
5349 5381
5350 scoped_ptr<LayerImpl> scoped_content_child_layer = 5382 scoped_ptr<LayerImpl> scoped_content_child_layer =
5351 LayerImpl::Create(host_impl_->active_tree(), 4); 5383 LayerImpl::Create(host_impl_->active_tree(), 4);
5352 LayerImpl* content_child_layer = scoped_content_child_layer.get(); 5384 LayerImpl* content_child_layer = scoped_content_child_layer.get();
5353 content_layer->AddChild(scoped_content_child_layer.Pass()); 5385 content_layer->AddChild(scoped_content_child_layer.Pass());
5354 5386
5355 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = 5387 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer =
5356 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 6); 5388 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 6);
5357 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); 5389 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get();
5358 content_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>()); 5390 content_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>());
5359 5391 content_layer->SetHasRenderSurface(true);
5360 gfx::Size root_size(100, 100); 5392 gfx::Size root_size(100, 100);
5361 root->SetBounds(root_size); 5393 root->SetBounds(root_size);
5362 root->SetContentBounds(root_size); 5394 root->SetContentBounds(root_size);
5363 root->SetPosition(gfx::PointF()); 5395 root->SetPosition(gfx::PointF());
5364 5396
5365 gfx::Rect clipping_rect(20, 10, 10, 20); 5397 gfx::Rect clipping_rect(20, 10, 10, 20);
5366 clipping_layer->SetBounds(clipping_rect.size()); 5398 clipping_layer->SetBounds(clipping_rect.size());
5367 clipping_layer->SetContentBounds(clipping_rect.size()); 5399 clipping_layer->SetContentBounds(clipping_rect.size());
5368 clipping_layer->SetPosition(clipping_rect.origin()); 5400 clipping_layer->SetPosition(clipping_rect.origin());
5369 clipping_layer->SetMasksToBounds(true); 5401 clipping_layer->SetMasksToBounds(true);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
5432 gfx::ToCeiledSize(gfx::ScaleSize(root_size, device_scale_factor)); 5464 gfx::ToCeiledSize(gfx::ScaleSize(root_size, device_scale_factor));
5433 host_impl_->SetViewportSize(device_viewport_size); 5465 host_impl_->SetViewportSize(device_viewport_size);
5434 5466
5435 host_impl_->CreatePendingTree(); 5467 host_impl_->CreatePendingTree();
5436 host_impl_->pending_tree() 5468 host_impl_->pending_tree()
5437 ->SetPageScaleFactorAndLimits(1.f, 1.f / 16.f, 16.f); 5469 ->SetPageScaleFactorAndLimits(1.f, 1.f / 16.f, 16.f);
5438 5470
5439 scoped_ptr<LayerImpl> scoped_root = 5471 scoped_ptr<LayerImpl> scoped_root =
5440 LayerImpl::Create(host_impl_->pending_tree(), 1); 5472 LayerImpl::Create(host_impl_->pending_tree(), 1);
5441 LayerImpl* root = scoped_root.get(); 5473 LayerImpl* root = scoped_root.get();
5474 root->SetHasRenderSurface(true);
5442 5475
5443 host_impl_->pending_tree()->SetRootLayer(scoped_root.Pass()); 5476 host_impl_->pending_tree()->SetRootLayer(scoped_root.Pass());
5444 5477
5445 scoped_ptr<LayerImpl> scoped_scrolling_layer = 5478 scoped_ptr<LayerImpl> scoped_scrolling_layer =
5446 LayerImpl::Create(host_impl_->pending_tree(), 2); 5479 LayerImpl::Create(host_impl_->pending_tree(), 2);
5447 LayerImpl* scrolling_layer = scoped_scrolling_layer.get(); 5480 LayerImpl* scrolling_layer = scoped_scrolling_layer.get();
5448 root->AddChild(scoped_scrolling_layer.Pass()); 5481 root->AddChild(scoped_scrolling_layer.Pass());
5449 5482
5450 gfx::Size content_layer_bounds(100000, 100); 5483 gfx::Size content_layer_bounds(100000, 100);
5451 gfx::Size pile_tile_size(3000, 3000); 5484 gfx::Size pile_tile_size(3000, 3000);
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
5930 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures()); 5963 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures());
5931 } 5964 }
5932 5965
5933 TEST_F(LayerTreeHostImplTest, TouchFlingShouldNotBubble) { 5966 TEST_F(LayerTreeHostImplTest, TouchFlingShouldNotBubble) {
5934 // When flinging via touch, only the child should scroll (we should not 5967 // When flinging via touch, only the child should scroll (we should not
5935 // bubble). 5968 // bubble).
5936 gfx::Size surface_size(10, 10); 5969 gfx::Size surface_size(10, 10);
5937 gfx::Size content_size(20, 20); 5970 gfx::Size content_size(20, 20);
5938 scoped_ptr<LayerImpl> root_clip = 5971 scoped_ptr<LayerImpl> root_clip =
5939 LayerImpl::Create(host_impl_->active_tree(), 3); 5972 LayerImpl::Create(host_impl_->active_tree(), 3);
5973 root_clip->SetHasRenderSurface(true);
5974
5940 scoped_ptr<LayerImpl> root = 5975 scoped_ptr<LayerImpl> root =
5941 CreateScrollableLayer(1, content_size, root_clip.get()); 5976 CreateScrollableLayer(1, content_size, root_clip.get());
5942 root->SetIsContainerForFixedPositionLayers(true); 5977 root->SetIsContainerForFixedPositionLayers(true);
5943 scoped_ptr<LayerImpl> child = 5978 scoped_ptr<LayerImpl> child =
5944 CreateScrollableLayer(2, content_size, root_clip.get()); 5979 CreateScrollableLayer(2, content_size, root_clip.get());
5945 5980
5946 root->AddChild(child.Pass()); 5981 root->AddChild(child.Pass());
5947 int root_id = root->id(); 5982 int root_id = root->id();
5948 root_clip->AddChild(root.Pass()); 5983 root_clip->AddChild(root.Pass());
5949 5984
(...skipping 23 matching lines...) Expand all
5973 ASSERT_EQ(1u, scroll_info->scrolls.size()); 6008 ASSERT_EQ(1u, scroll_info->scrolls.size());
5974 ExpectNone(*scroll_info.get(), root_id); 6009 ExpectNone(*scroll_info.get(), root_id);
5975 } 6010 }
5976 } 6011 }
5977 6012
5978 TEST_F(LayerTreeHostImplTest, TouchFlingShouldLockToFirstScrolledLayer) { 6013 TEST_F(LayerTreeHostImplTest, TouchFlingShouldLockToFirstScrolledLayer) {
5979 // Scroll a child layer beyond its maximum scroll range and make sure the 6014 // Scroll a child layer beyond its maximum scroll range and make sure the
5980 // the scroll doesn't bubble up to the parent layer. 6015 // the scroll doesn't bubble up to the parent layer.
5981 gfx::Size surface_size(10, 10); 6016 gfx::Size surface_size(10, 10);
5982 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); 6017 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
6018 root->SetHasRenderSurface(true);
5983 scoped_ptr<LayerImpl> root_scrolling = 6019 scoped_ptr<LayerImpl> root_scrolling =
5984 CreateScrollableLayer(2, surface_size, root.get()); 6020 CreateScrollableLayer(2, surface_size, root.get());
5985 6021
5986 scoped_ptr<LayerImpl> grand_child = 6022 scoped_ptr<LayerImpl> grand_child =
5987 CreateScrollableLayer(4, surface_size, root.get()); 6023 CreateScrollableLayer(4, surface_size, root.get());
5988 grand_child->SetScrollOffset(gfx::Vector2d(0, 2)); 6024 grand_child->SetScrollOffset(gfx::Vector2d(0, 2));
5989 6025
5990 scoped_ptr<LayerImpl> child = 6026 scoped_ptr<LayerImpl> child =
5991 CreateScrollableLayer(3, surface_size, root.get()); 6027 CreateScrollableLayer(3, surface_size, root.get());
5992 child->SetScrollOffset(gfx::Vector2d(0, 4)); 6028 child->SetScrollOffset(gfx::Vector2d(0, 4));
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
6043 } 6079 }
6044 } 6080 }
6045 6081
6046 TEST_F(LayerTreeHostImplTest, WheelFlingShouldBubble) { 6082 TEST_F(LayerTreeHostImplTest, WheelFlingShouldBubble) {
6047 // When flinging via wheel, the root should eventually scroll (we should 6083 // When flinging via wheel, the root should eventually scroll (we should
6048 // bubble). 6084 // bubble).
6049 gfx::Size surface_size(10, 10); 6085 gfx::Size surface_size(10, 10);
6050 gfx::Size content_size(20, 20); 6086 gfx::Size content_size(20, 20);
6051 scoped_ptr<LayerImpl> root_clip = 6087 scoped_ptr<LayerImpl> root_clip =
6052 LayerImpl::Create(host_impl_->active_tree(), 3); 6088 LayerImpl::Create(host_impl_->active_tree(), 3);
6089 root_clip->SetHasRenderSurface(true);
6053 scoped_ptr<LayerImpl> root_scroll = 6090 scoped_ptr<LayerImpl> root_scroll =
6054 CreateScrollableLayer(1, content_size, root_clip.get()); 6091 CreateScrollableLayer(1, content_size, root_clip.get());
6055 int root_scroll_id = root_scroll->id(); 6092 int root_scroll_id = root_scroll->id();
6056 scoped_ptr<LayerImpl> child = 6093 scoped_ptr<LayerImpl> child =
6057 CreateScrollableLayer(2, content_size, root_clip.get()); 6094 CreateScrollableLayer(2, content_size, root_clip.get());
6058 6095
6059 root_scroll->AddChild(child.Pass()); 6096 root_scroll->AddChild(child.Pass());
6060 root_clip->AddChild(root_scroll.Pass()); 6097 root_clip->AddChild(root_scroll.Pass());
6061 6098
6062 host_impl_->SetViewportSize(surface_size); 6099 host_impl_->SetViewportSize(surface_size);
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
6246 6283
6247 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed 6284 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed
6248 // to CompositorFrameMetadata after SwapBuffers(); 6285 // to CompositorFrameMetadata after SwapBuffers();
6249 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { 6286 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) {
6250 scoped_ptr<SolidColorLayerImpl> root = 6287 scoped_ptr<SolidColorLayerImpl> root =
6251 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); 6288 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1);
6252 root->SetPosition(gfx::PointF()); 6289 root->SetPosition(gfx::PointF());
6253 root->SetBounds(gfx::Size(10, 10)); 6290 root->SetBounds(gfx::Size(10, 10));
6254 root->SetContentBounds(gfx::Size(10, 10)); 6291 root->SetContentBounds(gfx::Size(10, 10));
6255 root->SetDrawsContent(true); 6292 root->SetDrawsContent(true);
6293 root->SetHasRenderSurface(true);
6256 6294
6257 host_impl_->active_tree()->SetRootLayer(root.PassAs<LayerImpl>()); 6295 host_impl_->active_tree()->SetRootLayer(root.PassAs<LayerImpl>());
6258 6296
6259 FakeOutputSurface* fake_output_surface = 6297 FakeOutputSurface* fake_output_surface =
6260 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); 6298 static_cast<FakeOutputSurface*>(host_impl_->output_surface());
6261 6299
6262 const std::vector<ui::LatencyInfo>& metadata_latency_before = 6300 const std::vector<ui::LatencyInfo>& metadata_latency_before =
6263 fake_output_surface->last_sent_frame().metadata.latency_info; 6301 fake_output_surface->last_sent_frame().metadata.latency_info;
6264 EXPECT_TRUE(metadata_latency_before.empty()); 6302 EXPECT_TRUE(metadata_latency_before.empty());
6265 6303
(...skipping 20 matching lines...) Expand all
6286 } 6324 }
6287 6325
6288 TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) { 6326 TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) {
6289 int root_layer_id = 1; 6327 int root_layer_id = 1;
6290 scoped_ptr<SolidColorLayerImpl> root = 6328 scoped_ptr<SolidColorLayerImpl> root =
6291 SolidColorLayerImpl::Create(host_impl_->active_tree(), root_layer_id); 6329 SolidColorLayerImpl::Create(host_impl_->active_tree(), root_layer_id);
6292 root->SetPosition(gfx::PointF()); 6330 root->SetPosition(gfx::PointF());
6293 root->SetBounds(gfx::Size(10, 10)); 6331 root->SetBounds(gfx::Size(10, 10));
6294 root->SetContentBounds(gfx::Size(10, 10)); 6332 root->SetContentBounds(gfx::Size(10, 10));
6295 root->SetDrawsContent(true); 6333 root->SetDrawsContent(true);
6334 root->SetHasRenderSurface(true);
6296 6335
6297 host_impl_->active_tree()->SetRootLayer(root.PassAs<LayerImpl>()); 6336 host_impl_->active_tree()->SetRootLayer(root.PassAs<LayerImpl>());
6298 6337
6299 // Ensure the default frame selection bounds are empty. 6338 // Ensure the default frame selection bounds are empty.
6300 FakeOutputSurface* fake_output_surface = 6339 FakeOutputSurface* fake_output_surface =
6301 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); 6340 static_cast<FakeOutputSurface*>(host_impl_->output_surface());
6302 const ViewportSelectionBound& selection_start_before = 6341 const ViewportSelectionBound& selection_start_before =
6303 fake_output_surface->last_sent_frame().metadata.selection_start; 6342 fake_output_surface->last_sent_frame().metadata.selection_start;
6304 const ViewportSelectionBound& selection_end_before = 6343 const ViewportSelectionBound& selection_end_before =
6305 fake_output_surface->last_sent_frame().metadata.selection_end; 6344 fake_output_surface->last_sent_frame().metadata.selection_end;
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
6710 contents->SetBounds(content_size); 6749 contents->SetBounds(content_size);
6711 contents->SetContentBounds(content_size); 6750 contents->SetContentBounds(content_size);
6712 contents->SetPosition(gfx::PointF()); 6751 contents->SetPosition(gfx::PointF());
6713 6752
6714 outer_scroll->AddChild(contents.Pass()); 6753 outer_scroll->AddChild(contents.Pass());
6715 outer_clip->AddChild(outer_scroll.Pass()); 6754 outer_clip->AddChild(outer_scroll.Pass());
6716 inner_scroll->AddChild(outer_clip.Pass()); 6755 inner_scroll->AddChild(outer_clip.Pass());
6717 page_scale->AddChild(inner_scroll.Pass()); 6756 page_scale->AddChild(inner_scroll.Pass());
6718 inner_clip->AddChild(page_scale.Pass()); 6757 inner_clip->AddChild(page_scale.Pass());
6719 6758
6759 inner_clip->SetHasRenderSurface(true);
6720 layer_tree_impl->SetRootLayer(inner_clip.Pass()); 6760 layer_tree_impl->SetRootLayer(inner_clip.Pass());
6721 layer_tree_impl->SetViewportLayersFromIds(kPageScaleLayerId, 6761 layer_tree_impl->SetViewportLayersFromIds(kPageScaleLayerId,
6722 kInnerViewportScrollLayerId, kOuterViewportScrollLayerId); 6762 kInnerViewportScrollLayerId, kOuterViewportScrollLayerId);
6723 6763
6724 host_impl_->active_tree()->DidBecomeActive(); 6764 host_impl_->active_tree()->DidBecomeActive();
6725 } 6765 }
6726 }; 6766 };
6727 6767
6728 TEST_F(LayerTreeHostImplVirtualViewportTest, FlingScrollBubblesToInner) { 6768 TEST_F(LayerTreeHostImplVirtualViewportTest, FlingScrollBubblesToInner) {
6729 gfx::Size content_size = gfx::Size(100, 160); 6769 gfx::Size content_size = gfx::Size(100, 160);
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
6979 // surface. 7019 // surface.
6980 EXPECT_EQ(0, num_lost_surfaces_); 7020 EXPECT_EQ(0, num_lost_surfaces_);
6981 host_impl_->DidLoseOutputSurface(); 7021 host_impl_->DidLoseOutputSurface();
6982 EXPECT_EQ(1, num_lost_surfaces_); 7022 EXPECT_EQ(1, num_lost_surfaces_);
6983 host_impl_->DidLoseOutputSurface(); 7023 host_impl_->DidLoseOutputSurface();
6984 EXPECT_LE(1, num_lost_surfaces_); 7024 EXPECT_LE(1, num_lost_surfaces_);
6985 } 7025 }
6986 7026
6987 } // namespace 7027 } // namespace
6988 } // namespace cc 7028 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698