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

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 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 <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #include "cc/test/begin_frame_args_test.h" 43 #include "cc/test/begin_frame_args_test.h"
44 #include "cc/test/fake_layer_tree_host_impl.h" 44 #include "cc/test/fake_layer_tree_host_impl.h"
45 #include "cc/test/fake_output_surface.h" 45 #include "cc/test/fake_output_surface.h"
46 #include "cc/test/fake_output_surface_client.h" 46 #include "cc/test/fake_output_surface_client.h"
47 #include "cc/test/fake_picture_layer_impl.h" 47 #include "cc/test/fake_picture_layer_impl.h"
48 #include "cc/test/fake_picture_pile_impl.h" 48 #include "cc/test/fake_picture_pile_impl.h"
49 #include "cc/test/fake_proxy.h" 49 #include "cc/test/fake_proxy.h"
50 #include "cc/test/fake_video_frame_provider.h" 50 #include "cc/test/fake_video_frame_provider.h"
51 #include "cc/test/geometry_test_utils.h" 51 #include "cc/test/geometry_test_utils.h"
52 #include "cc/test/layer_test_common.h" 52 #include "cc/test/layer_test_common.h"
53 #include "cc/test/layer_tree_test.h"
53 #include "cc/test/render_pass_test_common.h" 54 #include "cc/test/render_pass_test_common.h"
54 #include "cc/test/test_gpu_memory_buffer_manager.h" 55 #include "cc/test/test_gpu_memory_buffer_manager.h"
55 #include "cc/test/test_shared_bitmap_manager.h" 56 #include "cc/test/test_shared_bitmap_manager.h"
56 #include "cc/test/test_web_graphics_context_3d.h" 57 #include "cc/test/test_web_graphics_context_3d.h"
57 #include "cc/trees/layer_tree_impl.h" 58 #include "cc/trees/layer_tree_impl.h"
58 #include "cc/trees/single_thread_proxy.h" 59 #include "cc/trees/single_thread_proxy.h"
59 #include "media/base/media.h" 60 #include "media/base/media.h"
60 #include "testing/gmock/include/gmock/gmock.h" 61 #include "testing/gmock/include/gmock/gmock.h"
61 #include "testing/gtest/include/gtest/gtest.h" 62 #include "testing/gtest/include/gtest/gtest.h"
62 #include "third_party/skia/include/core/SkMallocPixelRef.h" 63 #include "third_party/skia/include/core/SkMallocPixelRef.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 host_impl_->SetViewportSize(gfx::Size(10, 10)); 178 host_impl_->SetViewportSize(gfx::Size(10, 10));
178 return init; 179 return init;
179 } 180 }
180 181
181 void SetupRootLayerImpl(scoped_ptr<LayerImpl> root) { 182 void SetupRootLayerImpl(scoped_ptr<LayerImpl> root) {
182 root->SetPosition(gfx::PointF()); 183 root->SetPosition(gfx::PointF());
183 root->SetBounds(gfx::Size(10, 10)); 184 root->SetBounds(gfx::Size(10, 10));
184 root->SetContentBounds(gfx::Size(10, 10)); 185 root->SetContentBounds(gfx::Size(10, 10));
185 root->SetDrawsContent(true); 186 root->SetDrawsContent(true);
186 root->draw_properties().visible_content_rect = gfx::Rect(0, 0, 10, 10); 187 root->draw_properties().visible_content_rect = gfx::Rect(0, 0, 10, 10);
188 root->SetHasRenderSurface(true);
187 host_impl_->active_tree()->SetRootLayer(root.Pass()); 189 host_impl_->active_tree()->SetRootLayer(root.Pass());
188 } 190 }
189 191
190 static void ExpectClearedScrollDeltasRecursive(LayerImpl* layer) { 192 static void ExpectClearedScrollDeltasRecursive(LayerImpl* layer) {
191 ASSERT_EQ(layer->ScrollDelta(), gfx::Vector2d()); 193 ASSERT_EQ(layer->ScrollDelta(), gfx::Vector2d());
192 for (size_t i = 0; i < layer->children().size(); ++i) 194 for (size_t i = 0; i < layer->children().size(); ++i)
193 ExpectClearedScrollDeltasRecursive(layer->children()[i]); 195 ExpectClearedScrollDeltasRecursive(layer->children()[i]);
194 } 196 }
195 197
196 static void ExpectContains(const ScrollAndScaleSet& scroll_info, 198 static void ExpectContains(const ScrollAndScaleSet& scroll_info,
(...skipping 26 matching lines...) Expand all
223 LayerImpl* CreateScrollAndContentsLayers(LayerTreeImpl* layer_tree_impl, 225 LayerImpl* CreateScrollAndContentsLayers(LayerTreeImpl* layer_tree_impl,
224 const gfx::Size& content_size) { 226 const gfx::Size& content_size) {
225 const int kInnerViewportScrollLayerId = 2; 227 const int kInnerViewportScrollLayerId = 2;
226 const int kInnerViewportClipLayerId = 4; 228 const int kInnerViewportClipLayerId = 4;
227 const int kPageScaleLayerId = 5; 229 const int kPageScaleLayerId = 5;
228 scoped_ptr<LayerImpl> root = 230 scoped_ptr<LayerImpl> root =
229 LayerImpl::Create(layer_tree_impl, 1); 231 LayerImpl::Create(layer_tree_impl, 1);
230 root->SetBounds(content_size); 232 root->SetBounds(content_size);
231 root->SetContentBounds(content_size); 233 root->SetContentBounds(content_size);
232 root->SetPosition(gfx::PointF()); 234 root->SetPosition(gfx::PointF());
235 root->SetHasRenderSurface(true);
233 236
234 scoped_ptr<LayerImpl> scroll = 237 scoped_ptr<LayerImpl> scroll =
235 LayerImpl::Create(layer_tree_impl, kInnerViewportScrollLayerId); 238 LayerImpl::Create(layer_tree_impl, kInnerViewportScrollLayerId);
236 LayerImpl* scroll_layer = scroll.get(); 239 LayerImpl* scroll_layer = scroll.get();
237 scroll->SetIsContainerForFixedPositionLayers(true); 240 scroll->SetIsContainerForFixedPositionLayers(true);
238 scroll->SetScrollOffset(gfx::ScrollOffset()); 241 scroll->SetScrollOffset(gfx::ScrollOffset());
239 242
240 scoped_ptr<LayerImpl> clip = 243 scoped_ptr<LayerImpl> clip =
241 LayerImpl::Create(layer_tree_impl, kInnerViewportClipLayerId); 244 LayerImpl::Create(layer_tree_impl, kInnerViewportClipLayerId);
242 clip->SetBounds( 245 clip->SetBounds(
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 567
565 // We should still be scrolling, because the scrolled layer also exists in the 568 // We should still be scrolling, because the scrolled layer also exists in the
566 // new tree. 569 // new tree.
567 gfx::Vector2d scroll_delta(0, 10); 570 gfx::Vector2d scroll_delta(0, 10);
568 host_impl_->ScrollBy(gfx::Point(), scroll_delta); 571 host_impl_->ScrollBy(gfx::Point(), scroll_delta);
569 host_impl_->ScrollEnd(); 572 host_impl_->ScrollEnd();
570 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); 573 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas();
571 ExpectContains(*scroll_info, scroll_layer->id(), scroll_delta); 574 ExpectContains(*scroll_info, scroll_layer->id(), scroll_delta);
572 } 575 }
573 576
574 TEST_F(LayerTreeHostImplTest, ClearRootRenderSurfaceAndScroll) {
575 SetupScrollAndContentsLayers(gfx::Size(100, 100));
576 host_impl_->SetViewportSize(gfx::Size(50, 50));
577 DrawFrame();
578
579 // We should be able to scroll even if the root layer loses its render surface
580 // after the most recent render.
581 host_impl_->active_tree()->root_layer()->ClearRenderSurface();
582 host_impl_->active_tree()->set_needs_update_draw_properties();
583
584 EXPECT_EQ(InputHandler::ScrollStarted,
585 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel));
586 }
587
588 TEST_F(LayerTreeHostImplTest, WheelEventHandlers) { 577 TEST_F(LayerTreeHostImplTest, WheelEventHandlers) {
589 SetupScrollAndContentsLayers(gfx::Size(100, 100)); 578 SetupScrollAndContentsLayers(gfx::Size(100, 100));
590 host_impl_->SetViewportSize(gfx::Size(50, 50)); 579 host_impl_->SetViewportSize(gfx::Size(50, 50));
591 DrawFrame(); 580 DrawFrame();
592 LayerImpl* root = host_impl_->active_tree()->root_layer(); 581 LayerImpl* root = host_impl_->active_tree()->root_layer();
593 582
594 root->SetHaveWheelEventHandlers(true); 583 root->SetHaveWheelEventHandlers(true);
595 584
596 // With registered event handlers, wheel scrolls have to go to the main 585 // With registered event handlers, wheel scrolls have to go to the main
597 // thread. 586 // thread.
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 host_impl_->ScrollBegin(scroll_position, InputHandler::Wheel)); 882 host_impl_->ScrollBegin(scroll_position, InputHandler::Wheel));
894 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 0), scroll_layer->TotalScrollOffset()); 883 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 0), scroll_layer->TotalScrollOffset());
895 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->TotalScrollOffset()); 884 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->TotalScrollOffset());
896 885
897 host_impl_->ScrollBy(scroll_position, scroll_delta); 886 host_impl_->ScrollBy(scroll_position, scroll_delta);
898 host_impl_->ScrollEnd(); 887 host_impl_->ScrollEnd();
899 EXPECT_VECTOR_EQ(gfx::Vector2dF(20, 10), scroll_layer->TotalScrollOffset()); 888 EXPECT_VECTOR_EQ(gfx::Vector2dF(20, 10), scroll_layer->TotalScrollOffset());
900 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->TotalScrollOffset()); 889 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->TotalScrollOffset());
901 } 890 }
902 891
903 TEST_F(LayerTreeHostImplTest,
904 ClearRootRenderSurfaceAndHitTestTouchHandlerRegion) {
905 SetupScrollAndContentsLayers(gfx::Size(100, 100));
906 host_impl_->SetViewportSize(gfx::Size(50, 50));
907 DrawFrame();
908
909 // We should be able to hit test for touch event handlers even if the root
910 // layer loses its render surface after the most recent render.
911 host_impl_->active_tree()->root_layer()->ClearRenderSurface();
912 host_impl_->active_tree()->set_needs_update_draw_properties();
913
914 EXPECT_EQ(host_impl_->HaveTouchEventHandlersAt(gfx::Point()), false);
915 }
916
917 TEST_F(LayerTreeHostImplTest, ImplPinchZoom) { 892 TEST_F(LayerTreeHostImplTest, ImplPinchZoom) {
918 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); 893 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100));
919 host_impl_->SetViewportSize(gfx::Size(50, 50)); 894 host_impl_->SetViewportSize(gfx::Size(50, 50));
920 DrawFrame(); 895 DrawFrame();
921 896
922 EXPECT_EQ(scroll_layer, host_impl_->InnerViewportScrollLayer()); 897 EXPECT_EQ(scroll_layer, host_impl_->InnerViewportScrollLayer());
923 LayerImpl* container_layer = scroll_layer->scroll_clip_layer(); 898 LayerImpl* container_layer = scroll_layer->scroll_clip_layer();
924 EXPECT_EQ(gfx::Size(50, 50), container_layer->bounds()); 899 EXPECT_EQ(gfx::Size(50, 50), container_layer->bounds());
925 900
926 float min_page_scale = 1.f, max_page_scale = 4.f; 901 float min_page_scale = 1.f, max_page_scale = 4.f;
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
1438 contents->SetBounds(content_size); \ 1413 contents->SetBounds(content_size); \
1439 contents->SetContentBounds(content_size); \ 1414 contents->SetContentBounds(content_size); \
1440 \ 1415 \
1441 scoped_ptr<SolidColorScrollbarLayerImpl> scrollbar = \ 1416 scoped_ptr<SolidColorScrollbarLayerImpl> scrollbar = \
1442 SolidColorScrollbarLayerImpl::Create( \ 1417 SolidColorScrollbarLayerImpl::Create( \
1443 host_impl_->active_tree(), 4, VERTICAL, 10, 0, false, true); \ 1418 host_impl_->active_tree(), 4, VERTICAL, 10, 0, false, true); \
1444 EXPECT_FLOAT_EQ(0.f, scrollbar->opacity()); \ 1419 EXPECT_FLOAT_EQ(0.f, scrollbar->opacity()); \
1445 \ 1420 \
1446 scroll->AddChild(contents.Pass()); \ 1421 scroll->AddChild(contents.Pass()); \
1447 root->AddChild(scroll.Pass()); \ 1422 root->AddChild(scroll.Pass()); \
1423 root->SetHasRenderSurface(true); \
1448 scrollbar->SetScrollLayerAndClipLayerByIds(2, 1); \ 1424 scrollbar->SetScrollLayerAndClipLayerByIds(2, 1); \
1449 root->AddChild(scrollbar.Pass()); \ 1425 root->AddChild(scrollbar.Pass()); \
1450 \ 1426 \
1451 host_impl_->active_tree()->SetRootLayer(root.Pass()); \ 1427 host_impl_->active_tree()->SetRootLayer(root.Pass()); \
1452 host_impl_->active_tree()->SetViewportLayersFromIds( \ 1428 host_impl_->active_tree()->SetViewportLayersFromIds( \
1453 1, 2, Layer::INVALID_ID); \ 1429 1, 2, Layer::INVALID_ID); \
1454 host_impl_->active_tree()->DidBecomeActive(); \ 1430 host_impl_->active_tree()->DidBecomeActive(); \
1455 DrawFrame(); 1431 DrawFrame();
1456 1432
1457 TEST_F(LayerTreeHostImplTest, ScrollbarLinearFadeScheduling) { 1433 TEST_F(LayerTreeHostImplTest, ScrollbarLinearFadeScheduling) {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1582 gfx::ScaleSize(viewport_size, device_scale_factor)); 1558 gfx::ScaleSize(viewport_size, device_scale_factor));
1583 gfx::Size content_size(1000, 1000); 1559 gfx::Size content_size(1000, 1000);
1584 1560
1585 CreateHostImpl(settings, CreateOutputSurface()); 1561 CreateHostImpl(settings, CreateOutputSurface());
1586 host_impl_->SetDeviceScaleFactor(device_scale_factor); 1562 host_impl_->SetDeviceScaleFactor(device_scale_factor);
1587 host_impl_->SetViewportSize(device_viewport_size); 1563 host_impl_->SetViewportSize(device_viewport_size);
1588 1564
1589 scoped_ptr<LayerImpl> root = 1565 scoped_ptr<LayerImpl> root =
1590 LayerImpl::Create(host_impl_->active_tree(), 1); 1566 LayerImpl::Create(host_impl_->active_tree(), 1);
1591 root->SetBounds(viewport_size); 1567 root->SetBounds(viewport_size);
1568 root->SetHasRenderSurface(true);
1592 1569
1593 scoped_ptr<LayerImpl> scroll = 1570 scoped_ptr<LayerImpl> scroll =
1594 LayerImpl::Create(host_impl_->active_tree(), 2); 1571 LayerImpl::Create(host_impl_->active_tree(), 2);
1595 scroll->SetScrollClipLayer(root->id()); 1572 scroll->SetScrollClipLayer(root->id());
1596 scroll->SetScrollOffset(gfx::ScrollOffset()); 1573 scroll->SetScrollOffset(gfx::ScrollOffset());
1597 scroll->SetBounds(content_size); 1574 scroll->SetBounds(content_size);
1598 scroll->SetContentBounds(content_size); 1575 scroll->SetContentBounds(content_size);
1599 scroll->SetIsContainerForFixedPositionLayers(true); 1576 scroll->SetIsContainerForFixedPositionLayers(true);
1600 1577
1601 scoped_ptr<LayerImpl> contents = 1578 scoped_ptr<LayerImpl> contents =
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1786 1763
1787 TEST_F(LayerTreeHostImplTest, WillDrawReturningFalseDoesNotCall) { 1764 TEST_F(LayerTreeHostImplTest, WillDrawReturningFalseDoesNotCall) {
1788 // The root layer is always drawn, so run this test on a child layer that 1765 // The root layer is always drawn, so run this test on a child layer that
1789 // will be masked out by the root layer's bounds. 1766 // will be masked out by the root layer's bounds.
1790 host_impl_->active_tree()->SetRootLayer( 1767 host_impl_->active_tree()->SetRootLayer(
1791 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); 1768 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1));
1792 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( 1769 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(
1793 host_impl_->active_tree()->root_layer()); 1770 host_impl_->active_tree()->root_layer());
1794 1771
1795 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); 1772 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2));
1773 root->SetHasRenderSurface(true);
1796 DidDrawCheckLayer* layer = 1774 DidDrawCheckLayer* layer =
1797 static_cast<DidDrawCheckLayer*>(root->children()[0]); 1775 static_cast<DidDrawCheckLayer*>(root->children()[0]);
1798 1776
1799 { 1777 {
1800 LayerTreeHostImpl::FrameData frame; 1778 LayerTreeHostImpl::FrameData frame;
1801 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 1779 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
1802 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1780 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1803 host_impl_->DidDrawAllLayers(frame); 1781 host_impl_->DidDrawAllLayers(frame);
1804 1782
1805 EXPECT_TRUE(layer->will_draw_called()); 1783 EXPECT_TRUE(layer->will_draw_called());
(...skipping 20 matching lines...) Expand all
1826 } 1804 }
1827 1805
1828 TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) { 1806 TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) {
1829 // The root layer is always drawn, so run this test on a child layer that 1807 // The root layer is always drawn, so run this test on a child layer that
1830 // will be masked out by the root layer's bounds. 1808 // will be masked out by the root layer's bounds.
1831 host_impl_->active_tree()->SetRootLayer( 1809 host_impl_->active_tree()->SetRootLayer(
1832 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); 1810 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1));
1833 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( 1811 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(
1834 host_impl_->active_tree()->root_layer()); 1812 host_impl_->active_tree()->root_layer());
1835 root->SetMasksToBounds(true); 1813 root->SetMasksToBounds(true);
1836 1814 root->SetHasRenderSurface(true);
1837 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); 1815 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2));
1838 DidDrawCheckLayer* layer = 1816 DidDrawCheckLayer* layer =
1839 static_cast<DidDrawCheckLayer*>(root->children()[0]); 1817 static_cast<DidDrawCheckLayer*>(root->children()[0]);
1840 // Ensure visible_content_rect for layer is empty. 1818 // Ensure visible_content_rect for layer is empty.
1841 layer->SetPosition(gfx::PointF(100.f, 100.f)); 1819 layer->SetPosition(gfx::PointF(100.f, 100.f));
1842 layer->SetBounds(gfx::Size(10, 10)); 1820 layer->SetBounds(gfx::Size(10, 10));
1843 layer->SetContentBounds(gfx::Size(10, 10)); 1821 layer->SetContentBounds(gfx::Size(10, 10));
1844 1822
1845 LayerTreeHostImpl::FrameData frame; 1823 LayerTreeHostImpl::FrameData frame;
1846 1824
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1879 host_impl_->active_tree()->SetRootLayer( 1857 host_impl_->active_tree()->SetRootLayer(
1880 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); 1858 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1));
1881 DidDrawCheckLayer* root = 1859 DidDrawCheckLayer* root =
1882 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 1860 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
1883 1861
1884 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); 1862 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2));
1885 DidDrawCheckLayer* occluded_layer = 1863 DidDrawCheckLayer* occluded_layer =
1886 static_cast<DidDrawCheckLayer*>(root->children()[0]); 1864 static_cast<DidDrawCheckLayer*>(root->children()[0]);
1887 1865
1888 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); 1866 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3));
1867 root->SetHasRenderSurface(true);
1889 DidDrawCheckLayer* top_layer = 1868 DidDrawCheckLayer* top_layer =
1890 static_cast<DidDrawCheckLayer*>(root->children()[1]); 1869 static_cast<DidDrawCheckLayer*>(root->children()[1]);
1891 // This layer covers the occluded_layer above. Make this layer large so it can 1870 // This layer covers the occluded_layer above. Make this layer large so it can
1892 // occlude. 1871 // occlude.
1893 top_layer->SetBounds(big_size); 1872 top_layer->SetBounds(big_size);
1894 top_layer->SetContentBounds(big_size); 1873 top_layer->SetContentBounds(big_size);
1895 top_layer->SetContentsOpaque(true); 1874 top_layer->SetContentsOpaque(true);
1896 1875
1897 LayerTreeHostImpl::FrameData frame; 1876 LayerTreeHostImpl::FrameData frame;
1898 1877
(...skipping 12 matching lines...) Expand all
1911 EXPECT_TRUE(top_layer->did_draw_called()); 1890 EXPECT_TRUE(top_layer->did_draw_called());
1912 } 1891 }
1913 1892
1914 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { 1893 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) {
1915 host_impl_->active_tree()->SetRootLayer( 1894 host_impl_->active_tree()->SetRootLayer(
1916 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); 1895 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1));
1917 DidDrawCheckLayer* root = 1896 DidDrawCheckLayer* root =
1918 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 1897 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
1919 1898
1920 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); 1899 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2));
1900 root->SetHasRenderSurface(true);
1921 DidDrawCheckLayer* layer1 = 1901 DidDrawCheckLayer* layer1 =
1922 static_cast<DidDrawCheckLayer*>(root->children()[0]); 1902 static_cast<DidDrawCheckLayer*>(root->children()[0]);
1923 1903
1924 layer1->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); 1904 layer1->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3));
1925 DidDrawCheckLayer* layer2 = 1905 DidDrawCheckLayer* layer2 =
1926 static_cast<DidDrawCheckLayer*>(layer1->children()[0]); 1906 static_cast<DidDrawCheckLayer*>(layer1->children()[0]);
1927 1907
1928 layer1->SetOpacity(0.3f); 1908 layer1->SetHasRenderSurface(true);
1929 layer1->SetShouldFlattenTransform(true); 1909 layer1->SetShouldFlattenTransform(true);
1930 1910
1931 EXPECT_FALSE(root->did_draw_called()); 1911 EXPECT_FALSE(root->did_draw_called());
1932 EXPECT_FALSE(layer1->did_draw_called()); 1912 EXPECT_FALSE(layer1->did_draw_called());
1933 EXPECT_FALSE(layer2->did_draw_called()); 1913 EXPECT_FALSE(layer2->did_draw_called());
1934 1914
1935 LayerTreeHostImpl::FrameData frame; 1915 LayerTreeHostImpl::FrameData frame;
1936 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( 1916 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(
1937 host_impl_->active_tree()->root_layer()); 1917 host_impl_->active_tree()->root_layer());
1938 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 1918 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1990 1970
1991 bool tile_missing_; 1971 bool tile_missing_;
1992 bool had_incomplete_tile_; 1972 bool had_incomplete_tile_;
1993 }; 1973 };
1994 1974
1995 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsOnDefault) { 1975 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsOnDefault) {
1996 host_impl_->active_tree()->SetRootLayer( 1976 host_impl_->active_tree()->SetRootLayer(
1997 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); 1977 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1));
1998 DidDrawCheckLayer* root = 1978 DidDrawCheckLayer* root =
1999 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 1979 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
2000 1980 root->SetHasRenderSurface(true);
2001 bool tile_missing = false; 1981 bool tile_missing = false;
2002 bool had_incomplete_tile = false; 1982 bool had_incomplete_tile = false;
2003 bool is_animating = false; 1983 bool is_animating = false;
2004 root->AddChild( 1984 root->AddChild(
2005 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 1985 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
2006 2, 1986 2,
2007 tile_missing, 1987 tile_missing,
2008 had_incomplete_tile, 1988 had_incomplete_tile,
2009 is_animating, 1989 is_animating,
2010 host_impl_->resource_provider())); 1990 host_impl_->resource_provider()));
2011 1991
2012 LayerTreeHostImpl::FrameData frame; 1992 LayerTreeHostImpl::FrameData frame;
2013 1993
2014 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 1994 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
2015 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1995 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2016 host_impl_->DidDrawAllLayers(frame); 1996 host_impl_->DidDrawAllLayers(frame);
2017 } 1997 }
2018 1998
2019 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithAnimatedLayer) { 1999 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithAnimatedLayer) {
2020 host_impl_->active_tree()->SetRootLayer( 2000 host_impl_->active_tree()->SetRootLayer(
2021 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); 2001 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1));
2022 DidDrawCheckLayer* root = 2002 DidDrawCheckLayer* root =
2023 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 2003 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
2004 root->SetHasRenderSurface(true);
2024 bool tile_missing = false; 2005 bool tile_missing = false;
2025 bool had_incomplete_tile = false; 2006 bool had_incomplete_tile = false;
2026 bool is_animating = true; 2007 bool is_animating = true;
2027 root->AddChild( 2008 root->AddChild(
2028 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 2009 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
2029 2, 2010 2,
2030 tile_missing, 2011 tile_missing,
2031 had_incomplete_tile, 2012 had_incomplete_tile,
2032 is_animating, 2013 is_animating,
2033 host_impl_->resource_provider())); 2014 host_impl_->resource_provider()));
2034 2015
2035 LayerTreeHostImpl::FrameData frame; 2016 LayerTreeHostImpl::FrameData frame;
2036 2017
2037 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 2018 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
2038 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 2019 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2039 host_impl_->DidDrawAllLayers(frame); 2020 host_impl_->DidDrawAllLayers(frame);
2040 } 2021 }
2041 2022
2042 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithMissingTiles) { 2023 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithMissingTiles) {
2043 host_impl_->active_tree()->SetRootLayer( 2024 host_impl_->active_tree()->SetRootLayer(
2044 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); 2025 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3));
2045 DidDrawCheckLayer* root = 2026 DidDrawCheckLayer* root =
2046 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 2027 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
2028 root->SetHasRenderSurface(true);
2047 2029
2048 LayerTreeHostImpl::FrameData frame; 2030 LayerTreeHostImpl::FrameData frame;
2049 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 2031 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
2050 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 2032 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2051 host_impl_->DidDrawAllLayers(frame); 2033 host_impl_->DidDrawAllLayers(frame);
2052 host_impl_->SwapBuffers(frame); 2034 host_impl_->SwapBuffers(frame);
2053 2035
2054 bool tile_missing = true; 2036 bool tile_missing = true;
2055 bool had_incomplete_tile = false; 2037 bool had_incomplete_tile = false;
2056 bool is_animating = false; 2038 bool is_animating = false;
2057 root->AddChild( 2039 root->AddChild(
2058 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 2040 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
2059 4, 2041 4,
2060 tile_missing, 2042 tile_missing,
2061 had_incomplete_tile, 2043 had_incomplete_tile,
2062 is_animating, 2044 is_animating,
2063 host_impl_->resource_provider())); 2045 host_impl_->resource_provider()));
2064 LayerTreeHostImpl::FrameData frame2; 2046 LayerTreeHostImpl::FrameData frame2;
2065 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame2)); 2047 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame2));
2066 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); 2048 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now());
2067 host_impl_->DidDrawAllLayers(frame2); 2049 host_impl_->DidDrawAllLayers(frame2);
2068 } 2050 }
2069 2051
2070 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithIncompleteTile) { 2052 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithIncompleteTile) {
2071 host_impl_->active_tree()->SetRootLayer( 2053 host_impl_->active_tree()->SetRootLayer(
2072 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); 2054 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3));
2073 DidDrawCheckLayer* root = 2055 DidDrawCheckLayer* root =
2074 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 2056 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
2057 root->SetHasRenderSurface(true);
2075 2058
2076 LayerTreeHostImpl::FrameData frame; 2059 LayerTreeHostImpl::FrameData frame;
2077 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 2060 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
2078 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 2061 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2079 host_impl_->DidDrawAllLayers(frame); 2062 host_impl_->DidDrawAllLayers(frame);
2080 host_impl_->SwapBuffers(frame); 2063 host_impl_->SwapBuffers(frame);
2081 2064
2082 bool tile_missing = false; 2065 bool tile_missing = false;
2083 bool had_incomplete_tile = true; 2066 bool had_incomplete_tile = true;
2084 bool is_animating = false; 2067 bool is_animating = false;
2085 root->AddChild( 2068 root->AddChild(
2086 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 2069 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
2087 4, 2070 4,
2088 tile_missing, 2071 tile_missing,
2089 had_incomplete_tile, 2072 had_incomplete_tile,
2090 is_animating, 2073 is_animating,
2091 host_impl_->resource_provider())); 2074 host_impl_->resource_provider()));
2092 LayerTreeHostImpl::FrameData frame2; 2075 LayerTreeHostImpl::FrameData frame2;
2093 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame2)); 2076 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame2));
2094 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); 2077 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now());
2095 host_impl_->DidDrawAllLayers(frame2); 2078 host_impl_->DidDrawAllLayers(frame2);
2096 } 2079 }
2097 2080
2098 TEST_F(LayerTreeHostImplTest, 2081 TEST_F(LayerTreeHostImplTest,
2099 PrepareToDrawFailsWithAnimationAndMissingTilesUsesCheckerboard) { 2082 PrepareToDrawFailsWithAnimationAndMissingTilesUsesCheckerboard) {
2100 host_impl_->active_tree()->SetRootLayer( 2083 host_impl_->active_tree()->SetRootLayer(
2101 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); 2084 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5));
2102 DidDrawCheckLayer* root = 2085 DidDrawCheckLayer* root =
2103 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 2086 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
2087 root->SetHasRenderSurface(true);
2104 2088
2105 LayerTreeHostImpl::FrameData frame; 2089 LayerTreeHostImpl::FrameData frame;
2106 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 2090 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
2107 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 2091 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2108 host_impl_->DidDrawAllLayers(frame); 2092 host_impl_->DidDrawAllLayers(frame);
2109 host_impl_->SwapBuffers(frame); 2093 host_impl_->SwapBuffers(frame);
2110 2094
2111 bool tile_missing = true; 2095 bool tile_missing = true;
2112 bool had_incomplete_tile = false; 2096 bool had_incomplete_tile = false;
2113 bool is_animating = true; 2097 bool is_animating = true;
(...skipping 10 matching lines...) Expand all
2124 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); 2108 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now());
2125 host_impl_->DidDrawAllLayers(frame2); 2109 host_impl_->DidDrawAllLayers(frame2);
2126 } 2110 }
2127 2111
2128 TEST_F(LayerTreeHostImplTest, 2112 TEST_F(LayerTreeHostImplTest,
2129 PrepareToDrawSucceedsWithAnimationAndIncompleteTiles) { 2113 PrepareToDrawSucceedsWithAnimationAndIncompleteTiles) {
2130 host_impl_->active_tree()->SetRootLayer( 2114 host_impl_->active_tree()->SetRootLayer(
2131 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); 2115 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5));
2132 DidDrawCheckLayer* root = 2116 DidDrawCheckLayer* root =
2133 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 2117 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
2118 root->SetHasRenderSurface(true);
2134 2119
2135 LayerTreeHostImpl::FrameData frame; 2120 LayerTreeHostImpl::FrameData frame;
2136 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 2121 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
2137 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 2122 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2138 host_impl_->DidDrawAllLayers(frame); 2123 host_impl_->DidDrawAllLayers(frame);
2139 host_impl_->SwapBuffers(frame); 2124 host_impl_->SwapBuffers(frame);
2140 2125
2141 bool tile_missing = false; 2126 bool tile_missing = false;
2142 bool had_incomplete_tile = true; 2127 bool had_incomplete_tile = true;
2143 bool is_animating = true; 2128 bool is_animating = true;
2144 root->AddChild( 2129 root->AddChild(
2145 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 2130 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
2146 6, 2131 6,
2147 tile_missing, 2132 tile_missing,
2148 had_incomplete_tile, 2133 had_incomplete_tile,
2149 is_animating, 2134 is_animating,
2150 host_impl_->resource_provider())); 2135 host_impl_->resource_provider()));
2151 LayerTreeHostImpl::FrameData frame2; 2136 LayerTreeHostImpl::FrameData frame2;
2152 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame2)); 2137 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame2));
2153 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); 2138 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now());
2154 host_impl_->DidDrawAllLayers(frame2); 2139 host_impl_->DidDrawAllLayers(frame2);
2155 } 2140 }
2156 2141
2157 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWhenHighResRequired) { 2142 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWhenHighResRequired) {
2158 host_impl_->active_tree()->SetRootLayer( 2143 host_impl_->active_tree()->SetRootLayer(
2159 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); 2144 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7));
2160 DidDrawCheckLayer* root = 2145 DidDrawCheckLayer* root =
2161 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 2146 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
2147 root->SetHasRenderSurface(true);
2162 2148
2163 LayerTreeHostImpl::FrameData frame; 2149 LayerTreeHostImpl::FrameData frame;
2164 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 2150 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
2165 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 2151 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2166 host_impl_->DidDrawAllLayers(frame); 2152 host_impl_->DidDrawAllLayers(frame);
2167 host_impl_->SwapBuffers(frame); 2153 host_impl_->SwapBuffers(frame);
2168 2154
2169 bool tile_missing = false; 2155 bool tile_missing = false;
2170 bool had_incomplete_tile = false; 2156 bool had_incomplete_tile = false;
2171 bool is_animating = false; 2157 bool is_animating = false;
(...skipping 10 matching lines...) Expand all
2182 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); 2168 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now());
2183 host_impl_->DidDrawAllLayers(frame2); 2169 host_impl_->DidDrawAllLayers(frame2);
2184 } 2170 }
2185 2171
2186 TEST_F(LayerTreeHostImplTest, 2172 TEST_F(LayerTreeHostImplTest,
2187 PrepareToDrawFailsWhenHighResRequiredAndIncompleteTiles) { 2173 PrepareToDrawFailsWhenHighResRequiredAndIncompleteTiles) {
2188 host_impl_->active_tree()->SetRootLayer( 2174 host_impl_->active_tree()->SetRootLayer(
2189 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); 2175 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7));
2190 DidDrawCheckLayer* root = 2176 DidDrawCheckLayer* root =
2191 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 2177 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
2178 root->SetHasRenderSurface(true);
2192 2179
2193 LayerTreeHostImpl::FrameData frame; 2180 LayerTreeHostImpl::FrameData frame;
2194 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 2181 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
2195 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 2182 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2196 host_impl_->DidDrawAllLayers(frame); 2183 host_impl_->DidDrawAllLayers(frame);
2197 host_impl_->SwapBuffers(frame); 2184 host_impl_->SwapBuffers(frame);
2198 2185
2199 bool tile_missing = false; 2186 bool tile_missing = false;
2200 bool had_incomplete_tile = true; 2187 bool had_incomplete_tile = true;
2201 bool is_animating = false; 2188 bool is_animating = false;
(...skipping 11 matching lines...) Expand all
2213 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); 2200 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now());
2214 host_impl_->DidDrawAllLayers(frame2); 2201 host_impl_->DidDrawAllLayers(frame2);
2215 } 2202 }
2216 2203
2217 TEST_F(LayerTreeHostImplTest, 2204 TEST_F(LayerTreeHostImplTest,
2218 PrepareToDrawFailsWhenHighResRequiredAndMissingTile) { 2205 PrepareToDrawFailsWhenHighResRequiredAndMissingTile) {
2219 host_impl_->active_tree()->SetRootLayer( 2206 host_impl_->active_tree()->SetRootLayer(
2220 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); 2207 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7));
2221 DidDrawCheckLayer* root = 2208 DidDrawCheckLayer* root =
2222 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 2209 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
2210 root->SetHasRenderSurface(true);
2223 2211
2224 LayerTreeHostImpl::FrameData frame; 2212 LayerTreeHostImpl::FrameData frame;
2225 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 2213 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
2226 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 2214 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2227 host_impl_->DidDrawAllLayers(frame); 2215 host_impl_->DidDrawAllLayers(frame);
2228 host_impl_->SwapBuffers(frame); 2216 host_impl_->SwapBuffers(frame);
2229 2217
2230 bool tile_missing = true; 2218 bool tile_missing = true;
2231 bool had_incomplete_tile = false; 2219 bool had_incomplete_tile = false;
2232 bool is_animating = false; 2220 bool is_animating = false;
2233 root->AddChild( 2221 root->AddChild(
2234 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 2222 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
2235 8, 2223 8,
2236 tile_missing, 2224 tile_missing,
2237 had_incomplete_tile, 2225 had_incomplete_tile,
2238 is_animating, 2226 is_animating,
2239 host_impl_->resource_provider())); 2227 host_impl_->resource_provider()));
2240 host_impl_->SetRequiresHighResToDraw(); 2228 host_impl_->SetRequiresHighResToDraw();
2241 LayerTreeHostImpl::FrameData frame2; 2229 LayerTreeHostImpl::FrameData frame2;
2242 EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT, 2230 EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT,
2243 host_impl_->PrepareToDraw(&frame2)); 2231 host_impl_->PrepareToDraw(&frame2));
2244 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); 2232 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now());
2245 host_impl_->DidDrawAllLayers(frame2); 2233 host_impl_->DidDrawAllLayers(frame2);
2246 } 2234 }
2247 2235
2248 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { 2236 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) {
2249 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); 2237 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
2250 root->SetScrollClipLayer(Layer::INVALID_ID); 2238 root->SetScrollClipLayer(Layer::INVALID_ID);
2239 root->SetHasRenderSurface(true);
2251 host_impl_->active_tree()->SetRootLayer(root.Pass()); 2240 host_impl_->active_tree()->SetRootLayer(root.Pass());
2252 DrawFrame(); 2241 DrawFrame();
2253 2242
2254 // Scroll event is ignored because layer is not scrollable. 2243 // Scroll event is ignored because layer is not scrollable.
2255 EXPECT_EQ(InputHandler::ScrollIgnored, 2244 EXPECT_EQ(InputHandler::ScrollIgnored,
2256 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); 2245 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel));
2257 EXPECT_FALSE(did_request_redraw_); 2246 EXPECT_FALSE(did_request_redraw_);
2258 EXPECT_FALSE(did_request_commit_); 2247 EXPECT_FALSE(did_request_commit_);
2259 } 2248 }
2260 2249
(...skipping 21 matching lines...) Expand all
2282 LayerImpl::Create(host_impl_->active_tree(), 2); 2271 LayerImpl::Create(host_impl_->active_tree(), 2);
2283 root_clip->SetBounds(clip_size_); 2272 root_clip->SetBounds(clip_size_);
2284 root->SetScrollClipLayer(root_clip->id()); 2273 root->SetScrollClipLayer(root_clip->id());
2285 root->SetBounds(layer_size_); 2274 root->SetBounds(layer_size_);
2286 root->SetContentBounds(layer_size_); 2275 root->SetContentBounds(layer_size_);
2287 root->SetPosition(gfx::PointF()); 2276 root->SetPosition(gfx::PointF());
2288 root->SetDrawsContent(false); 2277 root->SetDrawsContent(false);
2289 root->SetIsContainerForFixedPositionLayers(true); 2278 root->SetIsContainerForFixedPositionLayers(true);
2290 int inner_viewport_scroll_layer_id = root->id(); 2279 int inner_viewport_scroll_layer_id = root->id();
2291 int page_scale_layer_id = root_clip->id(); 2280 int page_scale_layer_id = root_clip->id();
2281 root_clip->SetHasRenderSurface(true);
2292 root_clip->AddChild(root.Pass()); 2282 root_clip->AddChild(root.Pass());
2283 root_clip->SetHasRenderSurface(true);
2293 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); 2284 host_impl_->active_tree()->SetRootLayer(root_clip.Pass());
2294 host_impl_->active_tree()->SetViewportLayersFromIds( 2285 host_impl_->active_tree()->SetViewportLayersFromIds(
2295 page_scale_layer_id, inner_viewport_scroll_layer_id, Layer::INVALID_ID); 2286 page_scale_layer_id, inner_viewport_scroll_layer_id, Layer::INVALID_ID);
2296 // Set a viewport size that is large enough to contain both the top controls 2287 // Set a viewport size that is large enough to contain both the top controls
2297 // and some content. 2288 // and some content.
2298 host_impl_->SetViewportSize(viewport_size_); 2289 host_impl_->SetViewportSize(viewport_size_);
2299 host_impl_->SetTopControlsLayoutHeight( 2290 host_impl_->SetTopControlsLayoutHeight(
2300 settings_.top_controls_height); 2291 settings_.top_controls_height);
2301 2292
2302 host_impl_->CreatePendingTree(); 2293 host_impl_->CreatePendingTree();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2342 scoped_ptr<LayerImpl> outer_clip = 2333 scoped_ptr<LayerImpl> outer_clip =
2343 LayerImpl::Create(host_impl_->active_tree(), 5); 2334 LayerImpl::Create(host_impl_->active_tree(), 5);
2344 2335
2345 root_clip->SetBounds(inner_viewport_size); 2336 root_clip->SetBounds(inner_viewport_size);
2346 root->SetScrollClipLayer(root_clip->id()); 2337 root->SetScrollClipLayer(root_clip->id());
2347 root->SetBounds(outer_viewport_size); 2338 root->SetBounds(outer_viewport_size);
2348 root->SetContentBounds(outer_viewport_size); 2339 root->SetContentBounds(outer_viewport_size);
2349 root->SetPosition(gfx::PointF()); 2340 root->SetPosition(gfx::PointF());
2350 root->SetDrawsContent(false); 2341 root->SetDrawsContent(false);
2351 root->SetIsContainerForFixedPositionLayers(true); 2342 root->SetIsContainerForFixedPositionLayers(true);
2352 2343 root_clip->SetHasRenderSurface(true);
2353 outer_clip->SetBounds(outer_viewport_size); 2344 outer_clip->SetBounds(outer_viewport_size);
2354 outer_scroll->SetScrollClipLayer(outer_clip->id()); 2345 outer_scroll->SetScrollClipLayer(outer_clip->id());
2355 outer_scroll->SetBounds(scroll_layer_size); 2346 outer_scroll->SetBounds(scroll_layer_size);
2356 outer_scroll->SetContentBounds(scroll_layer_size); 2347 outer_scroll->SetContentBounds(scroll_layer_size);
2357 outer_scroll->SetPosition(gfx::PointF()); 2348 outer_scroll->SetPosition(gfx::PointF());
2358 outer_scroll->SetDrawsContent(false); 2349 outer_scroll->SetDrawsContent(false);
2359 outer_scroll->SetIsContainerForFixedPositionLayers(true); 2350 outer_scroll->SetIsContainerForFixedPositionLayers(true);
2360 2351
2361 int inner_viewport_scroll_layer_id = root->id(); 2352 int inner_viewport_scroll_layer_id = root->id();
2362 int outer_viewport_scroll_layer_id = outer_scroll->id(); 2353 int outer_viewport_scroll_layer_id = outer_scroll->id();
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
2796 2787
2797 scoped_ptr<LayerImpl> scroll_layer = 2788 scoped_ptr<LayerImpl> scroll_layer =
2798 LayerImpl::Create(host_impl_->active_tree(), 2); 2789 LayerImpl::Create(host_impl_->active_tree(), 2);
2799 scroll_layer->SetScrollClipLayer(3); 2790 scroll_layer->SetScrollClipLayer(3);
2800 scroll_layer->SetBounds(contents_size); 2791 scroll_layer->SetBounds(contents_size);
2801 scroll_layer->SetContentBounds(contents_size); 2792 scroll_layer->SetContentBounds(contents_size);
2802 scroll_layer->SetPosition(gfx::PointF()); 2793 scroll_layer->SetPosition(gfx::PointF());
2803 scroll_layer->AddChild(content_layer.Pass()); 2794 scroll_layer->AddChild(content_layer.Pass());
2804 scroll_clip_layer->AddChild(scroll_layer.Pass()); 2795 scroll_clip_layer->AddChild(scroll_layer.Pass());
2805 2796
2797 scroll_clip_layer->SetHasRenderSurface(true);
2806 host_impl_->active_tree()->SetRootLayer(scroll_clip_layer.Pass()); 2798 host_impl_->active_tree()->SetRootLayer(scroll_clip_layer.Pass());
2807 host_impl_->SetViewportSize(surface_size); 2799 host_impl_->SetViewportSize(surface_size);
2808 DrawFrame(); 2800 DrawFrame();
2809 2801
2810 EXPECT_EQ(InputHandler::ScrollStarted, 2802 EXPECT_EQ(InputHandler::ScrollStarted,
2811 host_impl_->ScrollBegin(gfx::Point(5, 5), 2803 host_impl_->ScrollBegin(gfx::Point(5, 5),
2812 InputHandler::Wheel)); 2804 InputHandler::Wheel));
2813 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); 2805 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10));
2814 host_impl_->ScrollEnd(); 2806 host_impl_->ScrollEnd();
2815 EXPECT_TRUE(did_request_redraw_); 2807 EXPECT_TRUE(did_request_redraw_);
2816 EXPECT_TRUE(did_request_commit_); 2808 EXPECT_TRUE(did_request_commit_);
2817 } 2809 }
2818 2810
2819 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) { 2811 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) {
2820 gfx::Size surface_size(10, 10); 2812 gfx::Size surface_size(10, 10);
2821 gfx::Size contents_size(20, 20); 2813 gfx::Size contents_size(20, 20);
2822 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); 2814 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
2823 root->SetBounds(surface_size); 2815 root->SetBounds(surface_size);
2824 root->SetContentBounds(contents_size); 2816 root->SetContentBounds(contents_size);
2825 root->AddChild(CreateScrollableLayer(2, contents_size, root.get())); 2817 root->AddChild(CreateScrollableLayer(2, contents_size, root.get()));
2818 root->SetHasRenderSurface(true);
2826 host_impl_->active_tree()->SetRootLayer(root.Pass()); 2819 host_impl_->active_tree()->SetRootLayer(root.Pass());
2827 host_impl_->SetViewportSize(surface_size); 2820 host_impl_->SetViewportSize(surface_size);
2828 DrawFrame(); 2821 DrawFrame();
2829 2822
2830 EXPECT_EQ(InputHandler::ScrollStarted, 2823 EXPECT_EQ(InputHandler::ScrollStarted,
2831 host_impl_->ScrollBegin(gfx::Point(5, 5), 2824 host_impl_->ScrollBegin(gfx::Point(5, 5),
2832 InputHandler::Wheel)); 2825 InputHandler::Wheel));
2833 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); 2826 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10));
2834 host_impl_->ScrollEnd(); 2827 host_impl_->ScrollEnd();
2835 EXPECT_TRUE(did_request_redraw_); 2828 EXPECT_TRUE(did_request_redraw_);
2836 EXPECT_TRUE(did_request_commit_); 2829 EXPECT_TRUE(did_request_commit_);
2837 } 2830 }
2838 2831
2839 TEST_F(LayerTreeHostImplTest, ScrollMissesChild) { 2832 TEST_F(LayerTreeHostImplTest, ScrollMissesChild) {
2840 gfx::Size surface_size(10, 10); 2833 gfx::Size surface_size(10, 10);
2841 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); 2834 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
2842 root->AddChild(CreateScrollableLayer(2, surface_size, root.get())); 2835 root->AddChild(CreateScrollableLayer(2, surface_size, root.get()));
2836 root->SetHasRenderSurface(true);
2843 host_impl_->active_tree()->SetRootLayer(root.Pass()); 2837 host_impl_->active_tree()->SetRootLayer(root.Pass());
2844 host_impl_->SetViewportSize(surface_size); 2838 host_impl_->SetViewportSize(surface_size);
2845 DrawFrame(); 2839 DrawFrame();
2846 2840
2847 // Scroll event is ignored because the input coordinate is outside the layer 2841 // Scroll event is ignored because the input coordinate is outside the layer
2848 // boundaries. 2842 // boundaries.
2849 EXPECT_EQ(InputHandler::ScrollIgnored, 2843 EXPECT_EQ(InputHandler::ScrollIgnored,
2850 host_impl_->ScrollBegin(gfx::Point(15, 5), 2844 host_impl_->ScrollBegin(gfx::Point(15, 5),
2851 InputHandler::Wheel)); 2845 InputHandler::Wheel));
2852 EXPECT_FALSE(did_request_redraw_); 2846 EXPECT_FALSE(did_request_redraw_);
2853 EXPECT_FALSE(did_request_commit_); 2847 EXPECT_FALSE(did_request_commit_);
2854 } 2848 }
2855 2849
2856 TEST_F(LayerTreeHostImplTest, ScrollMissesBackfacingChild) { 2850 TEST_F(LayerTreeHostImplTest, ScrollMissesBackfacingChild) {
2857 gfx::Size surface_size(10, 10); 2851 gfx::Size surface_size(10, 10);
2858 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); 2852 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
2853 root->SetHasRenderSurface(true);
2859 scoped_ptr<LayerImpl> child = 2854 scoped_ptr<LayerImpl> child =
2860 CreateScrollableLayer(2, surface_size, root.get()); 2855 CreateScrollableLayer(2, surface_size, root.get());
2861 host_impl_->SetViewportSize(surface_size); 2856 host_impl_->SetViewportSize(surface_size);
2862 2857
2863 gfx::Transform matrix; 2858 gfx::Transform matrix;
2864 matrix.RotateAboutXAxis(180.0); 2859 matrix.RotateAboutXAxis(180.0);
2865 child->SetTransform(matrix); 2860 child->SetTransform(matrix);
2866 child->SetDoubleSided(false); 2861 child->SetDoubleSided(false);
2867 2862
2868 root->AddChild(child.Pass()); 2863 root->AddChild(child.Pass());
(...skipping 17 matching lines...) Expand all
2886 CreateScrollableLayer(1, surface_size, clip_layer.get()); 2881 CreateScrollableLayer(1, surface_size, clip_layer.get());
2887 content_layer->SetShouldScrollOnMainThread(true); 2882 content_layer->SetShouldScrollOnMainThread(true);
2888 content_layer->SetScrollClipLayer(Layer::INVALID_ID); 2883 content_layer->SetScrollClipLayer(Layer::INVALID_ID);
2889 2884
2890 // Note: we can use the same clip layer for both since both calls to 2885 // Note: we can use the same clip layer for both since both calls to
2891 // CreateScrollableLayer() use the same surface size. 2886 // CreateScrollableLayer() use the same surface size.
2892 scoped_ptr<LayerImpl> scroll_layer = 2887 scoped_ptr<LayerImpl> scroll_layer =
2893 CreateScrollableLayer(2, surface_size, clip_layer.get()); 2888 CreateScrollableLayer(2, surface_size, clip_layer.get());
2894 scroll_layer->AddChild(content_layer.Pass()); 2889 scroll_layer->AddChild(content_layer.Pass());
2895 clip_layer->AddChild(scroll_layer.Pass()); 2890 clip_layer->AddChild(scroll_layer.Pass());
2891 clip_layer->SetHasRenderSurface(true);
2896 2892
2897 host_impl_->active_tree()->SetRootLayer(clip_layer.Pass()); 2893 host_impl_->active_tree()->SetRootLayer(clip_layer.Pass());
2898 host_impl_->SetViewportSize(surface_size); 2894 host_impl_->SetViewportSize(surface_size);
2899 DrawFrame(); 2895 DrawFrame();
2900 2896
2901 // Scrolling fails because the content layer is asking to be scrolled on the 2897 // Scrolling fails because the content layer is asking to be scrolled on the
2902 // main thread. 2898 // main thread.
2903 EXPECT_EQ(InputHandler::ScrollOnMainThread, 2899 EXPECT_EQ(InputHandler::ScrollOnMainThread,
2904 host_impl_->ScrollBegin(gfx::Point(5, 5), 2900 host_impl_->ScrollBegin(gfx::Point(5, 5),
2905 InputHandler::Wheel)); 2901 InputHandler::Wheel));
2906 } 2902 }
2907 2903
2908 TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnMainThread) { 2904 TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnMainThread) {
2909 gfx::Size surface_size(20, 20); 2905 gfx::Size surface_size(20, 20);
2910 gfx::Size viewport_size(10, 10); 2906 gfx::Size viewport_size(10, 10);
2911 float page_scale = 2.f; 2907 float page_scale = 2.f;
2912 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); 2908 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
2913 scoped_ptr<LayerImpl> root_clip = 2909 scoped_ptr<LayerImpl> root_clip =
2914 LayerImpl::Create(host_impl_->active_tree(), 2); 2910 LayerImpl::Create(host_impl_->active_tree(), 2);
2915 scoped_ptr<LayerImpl> root_scrolling = 2911 scoped_ptr<LayerImpl> root_scrolling =
2916 CreateScrollableLayer(3, surface_size, root_clip.get()); 2912 CreateScrollableLayer(3, surface_size, root_clip.get());
2917 EXPECT_EQ(viewport_size, root_clip->bounds()); 2913 EXPECT_EQ(viewport_size, root_clip->bounds());
2918 root_scrolling->SetIsContainerForFixedPositionLayers(true); 2914 root_scrolling->SetIsContainerForFixedPositionLayers(true);
2919 root_clip->AddChild(root_scrolling.Pass()); 2915 root_clip->AddChild(root_scrolling.Pass());
2920 root->AddChild(root_clip.Pass()); 2916 root->AddChild(root_clip.Pass());
2917 root->SetHasRenderSurface(true);
2921 host_impl_->active_tree()->SetRootLayer(root.Pass()); 2918 host_impl_->active_tree()->SetRootLayer(root.Pass());
2922 // The behaviour in this test assumes the page scale is applied at a layer 2919 // The behaviour in this test assumes the page scale is applied at a layer
2923 // above the clip layer. 2920 // above the clip layer.
2924 host_impl_->active_tree()->SetViewportLayersFromIds(1, 3, Layer::INVALID_ID); 2921 host_impl_->active_tree()->SetViewportLayersFromIds(1, 3, Layer::INVALID_ID);
2925 host_impl_->active_tree()->DidBecomeActive(); 2922 host_impl_->active_tree()->DidBecomeActive();
2926 host_impl_->SetViewportSize(viewport_size); 2923 host_impl_->SetViewportSize(viewport_size);
2927 DrawFrame(); 2924 DrawFrame();
2928 2925
2929 LayerImpl* root_scroll = 2926 LayerImpl* root_scroll =
2930 host_impl_->active_tree()->InnerViewportScrollLayer(); 2927 host_impl_->active_tree()->InnerViewportScrollLayer();
(...skipping 30 matching lines...) Expand all
2961 float page_scale = 2.f; 2958 float page_scale = 2.f;
2962 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); 2959 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
2963 scoped_ptr<LayerImpl> root_clip = 2960 scoped_ptr<LayerImpl> root_clip =
2964 LayerImpl::Create(host_impl_->active_tree(), 2); 2961 LayerImpl::Create(host_impl_->active_tree(), 2);
2965 scoped_ptr<LayerImpl> root_scrolling = 2962 scoped_ptr<LayerImpl> root_scrolling =
2966 CreateScrollableLayer(3, surface_size, root_clip.get()); 2963 CreateScrollableLayer(3, surface_size, root_clip.get());
2967 EXPECT_EQ(viewport_size, root_clip->bounds()); 2964 EXPECT_EQ(viewport_size, root_clip->bounds());
2968 root_scrolling->SetIsContainerForFixedPositionLayers(true); 2965 root_scrolling->SetIsContainerForFixedPositionLayers(true);
2969 root_clip->AddChild(root_scrolling.Pass()); 2966 root_clip->AddChild(root_scrolling.Pass());
2970 root->AddChild(root_clip.Pass()); 2967 root->AddChild(root_clip.Pass());
2968 root->SetHasRenderSurface(true);
2971 host_impl_->active_tree()->SetRootLayer(root.Pass()); 2969 host_impl_->active_tree()->SetRootLayer(root.Pass());
2972 // The behaviour in this test assumes the page scale is applied at a layer 2970 // The behaviour in this test assumes the page scale is applied at a layer
2973 // above the clip layer. 2971 // above the clip layer.
2974 host_impl_->active_tree()->SetViewportLayersFromIds(1, 3, Layer::INVALID_ID); 2972 host_impl_->active_tree()->SetViewportLayersFromIds(1, 3, Layer::INVALID_ID);
2975 host_impl_->active_tree()->DidBecomeActive(); 2973 host_impl_->active_tree()->DidBecomeActive();
2976 host_impl_->SetViewportSize(viewport_size); 2974 host_impl_->SetViewportSize(viewport_size);
2977 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 1.f, page_scale); 2975 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 1.f, page_scale);
2978 DrawFrame(); 2976 DrawFrame();
2979 2977
2980 LayerImpl* root_scroll = 2978 LayerImpl* root_scroll =
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
3065 EXPECT_EQ(new_page_scale, 3063 EXPECT_EQ(new_page_scale,
3066 grand_child->draw_transform().matrix().getDouble(0, 0)); 3064 grand_child->draw_transform().matrix().getDouble(0, 0));
3067 EXPECT_EQ(new_page_scale, 3065 EXPECT_EQ(new_page_scale,
3068 grand_child->draw_transform().matrix().getDouble(1, 1)); 3066 grand_child->draw_transform().matrix().getDouble(1, 1));
3069 } 3067 }
3070 3068
3071 TEST_F(LayerTreeHostImplTest, ScrollChildAndChangePageScaleOnMainThread) { 3069 TEST_F(LayerTreeHostImplTest, ScrollChildAndChangePageScaleOnMainThread) {
3072 gfx::Size surface_size(30, 30); 3070 gfx::Size surface_size(30, 30);
3073 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); 3071 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
3074 root->SetBounds(gfx::Size(5, 5)); 3072 root->SetBounds(gfx::Size(5, 5));
3073 root->SetHasRenderSurface(true);
3075 scoped_ptr<LayerImpl> root_scrolling = 3074 scoped_ptr<LayerImpl> root_scrolling =
3076 LayerImpl::Create(host_impl_->active_tree(), 2); 3075 LayerImpl::Create(host_impl_->active_tree(), 2);
3077 root_scrolling->SetBounds(surface_size); 3076 root_scrolling->SetBounds(surface_size);
3078 root_scrolling->SetContentBounds(surface_size); 3077 root_scrolling->SetContentBounds(surface_size);
3079 root_scrolling->SetScrollClipLayer(root->id()); 3078 root_scrolling->SetScrollClipLayer(root->id());
3080 root_scrolling->SetIsContainerForFixedPositionLayers(true); 3079 root_scrolling->SetIsContainerForFixedPositionLayers(true);
3081 LayerImpl* root_scrolling_ptr = root_scrolling.get(); 3080 LayerImpl* root_scrolling_ptr = root_scrolling.get();
3082 root->AddChild(root_scrolling.Pass()); 3081 root->AddChild(root_scrolling.Pass());
3083 int child_scroll_layer_id = 3; 3082 int child_scroll_layer_id = 3;
3084 scoped_ptr<LayerImpl> child_scrolling = CreateScrollableLayer( 3083 scoped_ptr<LayerImpl> child_scrolling = CreateScrollableLayer(
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
3120 } 3119 }
3121 3120
3122 TEST_F(LayerTreeHostImplTest, ScrollChildBeyondLimit) { 3121 TEST_F(LayerTreeHostImplTest, ScrollChildBeyondLimit) {
3123 // Scroll a child layer beyond its maximum scroll range and make sure the 3122 // Scroll a child layer beyond its maximum scroll range and make sure the
3124 // parent layer is scrolled on the axis on which the child was unable to 3123 // parent layer is scrolled on the axis on which the child was unable to
3125 // scroll. 3124 // scroll.
3126 gfx::Size surface_size(10, 10); 3125 gfx::Size surface_size(10, 10);
3127 gfx::Size content_size(20, 20); 3126 gfx::Size content_size(20, 20);
3128 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); 3127 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
3129 root->SetBounds(surface_size); 3128 root->SetBounds(surface_size);
3130 3129 root->SetHasRenderSurface(true);
3131 scoped_ptr<LayerImpl> grand_child = 3130 scoped_ptr<LayerImpl> grand_child =
3132 CreateScrollableLayer(3, content_size, root.get()); 3131 CreateScrollableLayer(3, content_size, root.get());
3133 3132
3134 scoped_ptr<LayerImpl> child = 3133 scoped_ptr<LayerImpl> child =
3135 CreateScrollableLayer(2, content_size, root.get()); 3134 CreateScrollableLayer(2, content_size, root.get());
3136 LayerImpl* grand_child_layer = grand_child.get(); 3135 LayerImpl* grand_child_layer = grand_child.get();
3137 child->AddChild(grand_child.Pass()); 3136 child->AddChild(grand_child.Pass());
3138 3137
3139 LayerImpl* child_layer = child.get(); 3138 LayerImpl* child_layer = child.get();
3140 root->AddChild(child.Pass()); 3139 root->AddChild(child.Pass());
(...skipping 24 matching lines...) Expand all
3165 ExpectContains(*scroll_info.get(), child->id(), gfx::Vector2d(-3, 0)); 3164 ExpectContains(*scroll_info.get(), child->id(), gfx::Vector2d(-3, 0));
3166 } 3165 }
3167 } 3166 }
3168 3167
3169 TEST_F(LayerTreeHostImplTest, ScrollWithoutBubbling) { 3168 TEST_F(LayerTreeHostImplTest, ScrollWithoutBubbling) {
3170 // Scroll a child layer beyond its maximum scroll range and make sure the 3169 // Scroll a child layer beyond its maximum scroll range and make sure the
3171 // the scroll doesn't bubble up to the parent layer. 3170 // the scroll doesn't bubble up to the parent layer.
3172 gfx::Size surface_size(20, 20); 3171 gfx::Size surface_size(20, 20);
3173 gfx::Size viewport_size(10, 10); 3172 gfx::Size viewport_size(10, 10);
3174 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); 3173 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
3174 root->SetHasRenderSurface(true);
3175 scoped_ptr<LayerImpl> root_scrolling = 3175 scoped_ptr<LayerImpl> root_scrolling =
3176 CreateScrollableLayer(2, surface_size, root.get()); 3176 CreateScrollableLayer(2, surface_size, root.get());
3177 root_scrolling->SetIsContainerForFixedPositionLayers(true); 3177 root_scrolling->SetIsContainerForFixedPositionLayers(true);
3178 3178
3179 scoped_ptr<LayerImpl> grand_child = 3179 scoped_ptr<LayerImpl> grand_child =
3180 CreateScrollableLayer(4, surface_size, root.get()); 3180 CreateScrollableLayer(4, surface_size, root.get());
3181 3181
3182 scoped_ptr<LayerImpl> child = 3182 scoped_ptr<LayerImpl> child =
3183 CreateScrollableLayer(3, surface_size, root.get()); 3183 CreateScrollableLayer(3, surface_size, root.get());
3184 LayerImpl* grand_child_layer = grand_child.get(); 3184 LayerImpl* grand_child_layer = grand_child.get();
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
3273 ExpectContains(*scroll_info.get(), grand_child->id(), gfx::Vector2d(0, 4)); 3273 ExpectContains(*scroll_info.get(), grand_child->id(), gfx::Vector2d(0, 4));
3274 } 3274 }
3275 } 3275 }
3276 TEST_F(LayerTreeHostImplTest, ScrollEventBubbling) { 3276 TEST_F(LayerTreeHostImplTest, ScrollEventBubbling) {
3277 // When we try to scroll a non-scrollable child layer, the scroll delta 3277 // When we try to scroll a non-scrollable child layer, the scroll delta
3278 // should be applied to one of its ancestors if possible. 3278 // should be applied to one of its ancestors if possible.
3279 gfx::Size surface_size(10, 10); 3279 gfx::Size surface_size(10, 10);
3280 gfx::Size content_size(20, 20); 3280 gfx::Size content_size(20, 20);
3281 scoped_ptr<LayerImpl> root_clip = 3281 scoped_ptr<LayerImpl> root_clip =
3282 LayerImpl::Create(host_impl_->active_tree(), 3); 3282 LayerImpl::Create(host_impl_->active_tree(), 3);
3283 root_clip->SetHasRenderSurface(true);
3283 scoped_ptr<LayerImpl> root = 3284 scoped_ptr<LayerImpl> root =
3284 CreateScrollableLayer(1, content_size, root_clip.get()); 3285 CreateScrollableLayer(1, content_size, root_clip.get());
3285 // Make 'root' the clip layer for child: since they have the same sizes the 3286 // Make 'root' the clip layer for child: since they have the same sizes the
3286 // child will have zero max_scroll_offset and scrolls will bubble. 3287 // child will have zero max_scroll_offset and scrolls will bubble.
3287 scoped_ptr<LayerImpl> child = 3288 scoped_ptr<LayerImpl> child =
3288 CreateScrollableLayer(2, content_size, root.get()); 3289 CreateScrollableLayer(2, content_size, root.get());
3289 child->SetIsContainerForFixedPositionLayers(true); 3290 child->SetIsContainerForFixedPositionLayers(true);
3290 root->SetBounds(content_size); 3291 root->SetBounds(content_size);
3291 3292
3292 int root_scroll_id = root->id(); 3293 int root_scroll_id = root->id();
(...skipping 22 matching lines...) Expand all
3315 } 3316 }
3316 } 3317 }
3317 3318
3318 TEST_F(LayerTreeHostImplTest, ScrollBeforeRedraw) { 3319 TEST_F(LayerTreeHostImplTest, ScrollBeforeRedraw) {
3319 gfx::Size surface_size(10, 10); 3320 gfx::Size surface_size(10, 10);
3320 scoped_ptr<LayerImpl> root_clip = 3321 scoped_ptr<LayerImpl> root_clip =
3321 LayerImpl::Create(host_impl_->active_tree(), 1); 3322 LayerImpl::Create(host_impl_->active_tree(), 1);
3322 scoped_ptr<LayerImpl> root_scroll = 3323 scoped_ptr<LayerImpl> root_scroll =
3323 CreateScrollableLayer(2, surface_size, root_clip.get()); 3324 CreateScrollableLayer(2, surface_size, root_clip.get());
3324 root_scroll->SetIsContainerForFixedPositionLayers(true); 3325 root_scroll->SetIsContainerForFixedPositionLayers(true);
3326 root_clip->SetHasRenderSurface(true);
3325 root_clip->AddChild(root_scroll.Pass()); 3327 root_clip->AddChild(root_scroll.Pass());
3326 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); 3328 host_impl_->active_tree()->SetRootLayer(root_clip.Pass());
3327 host_impl_->active_tree()->SetViewportLayersFromIds(1, 2, Layer::INVALID_ID); 3329 host_impl_->active_tree()->SetViewportLayersFromIds(1, 2, Layer::INVALID_ID);
3328 host_impl_->active_tree()->DidBecomeActive(); 3330 host_impl_->active_tree()->DidBecomeActive();
3329 host_impl_->SetViewportSize(surface_size); 3331 host_impl_->SetViewportSize(surface_size);
3330 3332
3331 // Draw one frame and then immediately rebuild the layer tree to mimic a tree 3333 // Draw one frame and then immediately rebuild the layer tree to mimic a tree
3332 // synchronization. 3334 // synchronization.
3333 DrawFrame(); 3335 DrawFrame();
3334 host_impl_->active_tree()->DetachLayerTree(); 3336 host_impl_->active_tree()->DetachLayerTree();
3335 scoped_ptr<LayerImpl> root_clip2 = 3337 scoped_ptr<LayerImpl> root_clip2 =
3336 LayerImpl::Create(host_impl_->active_tree(), 3); 3338 LayerImpl::Create(host_impl_->active_tree(), 3);
3337 scoped_ptr<LayerImpl> root_scroll2 = 3339 scoped_ptr<LayerImpl> root_scroll2 =
3338 CreateScrollableLayer(4, surface_size, root_clip2.get()); 3340 CreateScrollableLayer(4, surface_size, root_clip2.get());
3339 root_scroll2->SetIsContainerForFixedPositionLayers(true); 3341 root_scroll2->SetIsContainerForFixedPositionLayers(true);
3340 root_clip2->AddChild(root_scroll2.Pass()); 3342 root_clip2->AddChild(root_scroll2.Pass());
3343 root_clip2->SetHasRenderSurface(true);
3341 host_impl_->active_tree()->SetRootLayer(root_clip2.Pass()); 3344 host_impl_->active_tree()->SetRootLayer(root_clip2.Pass());
3342 host_impl_->active_tree()->SetViewportLayersFromIds(3, 4, Layer::INVALID_ID); 3345 host_impl_->active_tree()->SetViewportLayersFromIds(3, 4, Layer::INVALID_ID);
3343 host_impl_->active_tree()->DidBecomeActive(); 3346 host_impl_->active_tree()->DidBecomeActive();
3344 3347
3345 // Scrolling should still work even though we did not draw yet. 3348 // Scrolling should still work even though we did not draw yet.
3346 EXPECT_EQ(InputHandler::ScrollStarted, 3349 EXPECT_EQ(InputHandler::ScrollStarted,
3347 host_impl_->ScrollBegin(gfx::Point(5, 5), 3350 host_impl_->ScrollBegin(gfx::Point(5, 5),
3348 InputHandler::Wheel)); 3351 InputHandler::Wheel));
3349 } 3352 }
3350 3353
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
3844 host_impl_->ScrollEnd(); 3847 host_impl_->ScrollEnd();
3845 } 3848 }
3846 3849
3847 3850
3848 TEST_F(LayerTreeHostImplTest, OverscrollChildWithoutBubbling) { 3851 TEST_F(LayerTreeHostImplTest, OverscrollChildWithoutBubbling) {
3849 // Scroll child layers beyond their maximum scroll range and make sure root 3852 // Scroll child layers beyond their maximum scroll range and make sure root
3850 // overscroll does not accumulate. 3853 // overscroll does not accumulate.
3851 gfx::Size surface_size(10, 10); 3854 gfx::Size surface_size(10, 10);
3852 scoped_ptr<LayerImpl> root_clip = 3855 scoped_ptr<LayerImpl> root_clip =
3853 LayerImpl::Create(host_impl_->active_tree(), 4); 3856 LayerImpl::Create(host_impl_->active_tree(), 4);
3857 root_clip->SetHasRenderSurface(true);
3858
3854 scoped_ptr<LayerImpl> root = 3859 scoped_ptr<LayerImpl> root =
3855 CreateScrollableLayer(1, surface_size, root_clip.get()); 3860 CreateScrollableLayer(1, surface_size, root_clip.get());
3856 3861
3857 scoped_ptr<LayerImpl> grand_child = 3862 scoped_ptr<LayerImpl> grand_child =
3858 CreateScrollableLayer(3, surface_size, root_clip.get()); 3863 CreateScrollableLayer(3, surface_size, root_clip.get());
3859 3864
3860 scoped_ptr<LayerImpl> child = 3865 scoped_ptr<LayerImpl> child =
3861 CreateScrollableLayer(2, surface_size, root_clip.get()); 3866 CreateScrollableLayer(2, surface_size, root_clip.get());
3862 LayerImpl* grand_child_layer = grand_child.get(); 3867 LayerImpl* grand_child_layer = grand_child.get();
3863 child->AddChild(grand_child.Pass()); 3868 child->AddChild(grand_child.Pass());
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
3908 } 3913 }
3909 3914
3910 TEST_F(LayerTreeHostImplTest, OverscrollChildEventBubbling) { 3915 TEST_F(LayerTreeHostImplTest, OverscrollChildEventBubbling) {
3911 // When we try to scroll a non-scrollable child layer, the scroll delta 3916 // When we try to scroll a non-scrollable child layer, the scroll delta
3912 // should be applied to one of its ancestors if possible. Overscroll should 3917 // should be applied to one of its ancestors if possible. Overscroll should
3913 // be reflected only when it has bubbled up to the root scrolling layer. 3918 // be reflected only when it has bubbled up to the root scrolling layer.
3914 gfx::Size surface_size(10, 10); 3919 gfx::Size surface_size(10, 10);
3915 gfx::Size content_size(20, 20); 3920 gfx::Size content_size(20, 20);
3916 scoped_ptr<LayerImpl> root_clip = 3921 scoped_ptr<LayerImpl> root_clip =
3917 LayerImpl::Create(host_impl_->active_tree(), 3); 3922 LayerImpl::Create(host_impl_->active_tree(), 3);
3923 root_clip->SetHasRenderSurface(true);
3924
3918 scoped_ptr<LayerImpl> root = 3925 scoped_ptr<LayerImpl> root =
3919 CreateScrollableLayer(1, content_size, root_clip.get()); 3926 CreateScrollableLayer(1, content_size, root_clip.get());
3920 root->SetIsContainerForFixedPositionLayers(true); 3927 root->SetIsContainerForFixedPositionLayers(true);
3921 scoped_ptr<LayerImpl> child = 3928 scoped_ptr<LayerImpl> child =
3922 CreateScrollableLayer(2, content_size, root_clip.get()); 3929 CreateScrollableLayer(2, content_size, root_clip.get());
3923 3930
3924 child->SetScrollClipLayer(Layer::INVALID_ID); 3931 child->SetScrollClipLayer(Layer::INVALID_ID);
3925 root->AddChild(child.Pass()); 3932 root->AddChild(child.Pass());
3926 root_clip->AddChild(root.Pass()); 3933 root_clip->AddChild(root.Pass());
3927 3934
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
3963 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); 3970 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10));
3964 EXPECT_EQ(gfx::Vector2dF(0, 10), host_impl_->accumulated_root_overscroll()); 3971 EXPECT_EQ(gfx::Vector2dF(0, 10), host_impl_->accumulated_root_overscroll());
3965 } 3972 }
3966 3973
3967 TEST_F(LayerTreeHostImplTest, NoOverscrollOnFractionalDeviceScale) { 3974 TEST_F(LayerTreeHostImplTest, NoOverscrollOnFractionalDeviceScale) {
3968 gfx::Size surface_size(980, 1439); 3975 gfx::Size surface_size(980, 1439);
3969 gfx::Size content_size(980, 1438); 3976 gfx::Size content_size(980, 1438);
3970 float device_scale_factor = 1.5f; 3977 float device_scale_factor = 1.5f;
3971 scoped_ptr<LayerImpl> root_clip = 3978 scoped_ptr<LayerImpl> root_clip =
3972 LayerImpl::Create(host_impl_->active_tree(), 3); 3979 LayerImpl::Create(host_impl_->active_tree(), 3);
3980 root_clip->SetHasRenderSurface(true);
3981
3973 scoped_ptr<LayerImpl> root = 3982 scoped_ptr<LayerImpl> root =
3974 CreateScrollableLayer(1, content_size, root_clip.get()); 3983 CreateScrollableLayer(1, content_size, root_clip.get());
3975 root->SetIsContainerForFixedPositionLayers(true); 3984 root->SetIsContainerForFixedPositionLayers(true);
3976 scoped_ptr<LayerImpl> child = 3985 scoped_ptr<LayerImpl> child =
3977 CreateScrollableLayer(2, content_size, root_clip.get()); 3986 CreateScrollableLayer(2, content_size, root_clip.get());
3978 root->scroll_clip_layer()->SetBounds(gfx::Size(320, 469)); 3987 root->scroll_clip_layer()->SetBounds(gfx::Size(320, 469));
3979 host_impl_->active_tree()->SetPageScaleFactorAndLimits( 3988 host_impl_->active_tree()->SetPageScaleFactorAndLimits(
3980 0.326531f, 0.326531f, 5.f); 3989 0.326531f, 0.326531f, 5.f);
3981 host_impl_->active_tree()->SetPageScaleDelta(1.f); 3990 host_impl_->active_tree()->SetPageScaleDelta(1.f);
3982 child->SetScrollClipLayer(Layer::INVALID_ID); 3991 child->SetScrollClipLayer(Layer::INVALID_ID);
(...skipping 18 matching lines...) Expand all
4001 4010
4002 host_impl_->ScrollEnd(); 4011 host_impl_->ScrollEnd();
4003 } 4012 }
4004 } 4013 }
4005 4014
4006 TEST_F(LayerTreeHostImplTest, NoOverscrollWhenNotAtEdge) { 4015 TEST_F(LayerTreeHostImplTest, NoOverscrollWhenNotAtEdge) {
4007 gfx::Size surface_size(100, 100); 4016 gfx::Size surface_size(100, 100);
4008 gfx::Size content_size(200, 200); 4017 gfx::Size content_size(200, 200);
4009 scoped_ptr<LayerImpl> root_clip = 4018 scoped_ptr<LayerImpl> root_clip =
4010 LayerImpl::Create(host_impl_->active_tree(), 3); 4019 LayerImpl::Create(host_impl_->active_tree(), 3);
4020 root_clip->SetHasRenderSurface(true);
4021
4011 scoped_ptr<LayerImpl> root = 4022 scoped_ptr<LayerImpl> root =
4012 CreateScrollableLayer(1, content_size, root_clip.get()); 4023 CreateScrollableLayer(1, content_size, root_clip.get());
4013 root->SetIsContainerForFixedPositionLayers(true); 4024 root->SetIsContainerForFixedPositionLayers(true);
4014 scoped_ptr<LayerImpl> child = 4025 scoped_ptr<LayerImpl> child =
4015 CreateScrollableLayer(2, content_size, root_clip.get()); 4026 CreateScrollableLayer(2, content_size, root_clip.get());
4016 4027
4017 child->SetScrollClipLayer(Layer::INVALID_ID); 4028 child->SetScrollClipLayer(Layer::INVALID_ID);
4018 root->AddChild(child.Pass()); 4029 root->AddChild(child.Pass());
4019 root_clip->AddChild(root.Pass()); 4030 root_clip->AddChild(root.Pass());
4020 4031
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
4145 ResourceProvider::ResourceId resource_id_; 4156 ResourceProvider::ResourceId resource_id_;
4146 }; 4157 };
4147 4158
4148 TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { 4159 TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) {
4149 { 4160 {
4150 scoped_ptr<LayerImpl> root = 4161 scoped_ptr<LayerImpl> root =
4151 LayerImpl::Create(host_impl_->active_tree(), 1); 4162 LayerImpl::Create(host_impl_->active_tree(), 1);
4152 root->SetBounds(gfx::Size(10, 10)); 4163 root->SetBounds(gfx::Size(10, 10));
4153 root->SetContentBounds(root->bounds()); 4164 root->SetContentBounds(root->bounds());
4154 root->SetDrawsContent(false); 4165 root->SetDrawsContent(false);
4166 root->SetHasRenderSurface(true);
4155 host_impl_->active_tree()->SetRootLayer(root.Pass()); 4167 host_impl_->active_tree()->SetRootLayer(root.Pass());
4156 } 4168 }
4157 LayerImpl* root = host_impl_->active_tree()->root_layer(); 4169 LayerImpl* root = host_impl_->active_tree()->root_layer();
4158 4170
4159 root->AddChild( 4171 root->AddChild(
4160 BlendStateCheckLayer::Create(host_impl_->active_tree(), 4172 BlendStateCheckLayer::Create(host_impl_->active_tree(),
4161 2, 4173 2,
4162 host_impl_->resource_provider())); 4174 host_impl_->resource_provider()));
4163 BlendStateCheckLayer* layer1 = 4175 BlendStateCheckLayer* layer1 =
4164 static_cast<BlendStateCheckLayer*>(root->children()[0]); 4176 static_cast<BlendStateCheckLayer*>(root->children()[0]);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
4254 EXPECT_TRUE(layer2->quads_appended()); 4266 EXPECT_TRUE(layer2->quads_appended());
4255 host_impl_->DidDrawAllLayers(frame); 4267 host_impl_->DidDrawAllLayers(frame);
4256 4268
4257 // Parent layer with translucent opacity and opaque content. Since it has a 4269 // Parent layer with translucent opacity and opaque content. Since it has a
4258 // drawing child, it's drawn to a render surface which carries the opacity, 4270 // drawing child, it's drawn to a render surface which carries the opacity,
4259 // so it's itself drawn without blending. 4271 // so it's itself drawn without blending.
4260 // Child layer with opaque content, drawn without blending (parent surface 4272 // Child layer with opaque content, drawn without blending (parent surface
4261 // carries the inherited opacity). 4273 // carries the inherited opacity).
4262 layer1->SetContentsOpaque(true); 4274 layer1->SetContentsOpaque(true);
4263 layer1->SetOpacity(0.5f); 4275 layer1->SetOpacity(0.5f);
4276 layer1->SetHasRenderSurface(true);
4264 layer1->SetExpectation(false, true); 4277 layer1->SetExpectation(false, true);
4265 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); 4278 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds()));
4266 layer2->SetExpectation(false, false); 4279 layer2->SetExpectation(false, false);
4267 layer2->SetUpdateRect(gfx::Rect(layer1->content_bounds())); 4280 layer2->SetUpdateRect(gfx::Rect(layer1->content_bounds()));
4268 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( 4281 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(
4269 host_impl_->active_tree()->root_layer()); 4282 host_impl_->active_tree()->root_layer());
4270 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 4283 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
4271 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4284 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4272 EXPECT_TRUE(layer1->quads_appended()); 4285 EXPECT_TRUE(layer1->quads_appended());
4273 EXPECT_TRUE(layer2->quads_appended()); 4286 EXPECT_TRUE(layer2->quads_appended());
4274 host_impl_->DidDrawAllLayers(frame); 4287 host_impl_->DidDrawAllLayers(frame);
4288 layer1->SetHasRenderSurface(false);
4275 4289
4276 // Draw again, but with child non-opaque, to make sure 4290 // Draw again, but with child non-opaque, to make sure
4277 // layer1 not culled. 4291 // layer1 not culled.
4278 layer1->SetContentsOpaque(true); 4292 layer1->SetContentsOpaque(true);
4279 layer1->SetOpacity(1.f); 4293 layer1->SetOpacity(1.f);
4280 layer1->SetExpectation(false, false); 4294 layer1->SetExpectation(false, false);
4281 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); 4295 layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds()));
4282 layer2->SetContentsOpaque(true); 4296 layer2->SetContentsOpaque(true);
4283 layer2->SetOpacity(0.5f); 4297 layer2->SetOpacity(0.5f);
4284 layer2->SetExpectation(true, false); 4298 layer2->SetExpectation(true, false);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
4381 if (always_draw) { 4395 if (always_draw) {
4382 return FakeOutputSurface::CreateAlwaysDrawAndSwap3d(); 4396 return FakeOutputSurface::CreateAlwaysDrawAndSwap3d();
4383 } 4397 }
4384 return FakeOutputSurface::Create3d(); 4398 return FakeOutputSurface::Create3d();
4385 } 4399 }
4386 4400
4387 void SetupActiveTreeLayers() { 4401 void SetupActiveTreeLayers() {
4388 host_impl_->active_tree()->set_background_color(SK_ColorGRAY); 4402 host_impl_->active_tree()->set_background_color(SK_ColorGRAY);
4389 host_impl_->active_tree()->SetRootLayer( 4403 host_impl_->active_tree()->SetRootLayer(
4390 LayerImpl::Create(host_impl_->active_tree(), 1)); 4404 LayerImpl::Create(host_impl_->active_tree(), 1));
4405 host_impl_->active_tree()->root_layer()->SetHasRenderSurface(true);
4391 host_impl_->active_tree()->root_layer()->AddChild( 4406 host_impl_->active_tree()->root_layer()->AddChild(
4392 BlendStateCheckLayer::Create(host_impl_->active_tree(), 4407 BlendStateCheckLayer::Create(host_impl_->active_tree(),
4393 2, 4408 2,
4394 host_impl_->resource_provider())); 4409 host_impl_->resource_provider()));
4395 child_ = static_cast<BlendStateCheckLayer*>( 4410 child_ = static_cast<BlendStateCheckLayer*>(
4396 host_impl_->active_tree()->root_layer()->children()[0]); 4411 host_impl_->active_tree()->root_layer()->children()[0]);
4397 child_->SetExpectation(false, false); 4412 child_->SetExpectation(false, false);
4398 child_->SetContentsOpaque(true); 4413 child_->SetContentsOpaque(true);
4399 } 4414 }
4400 4415
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
4671 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); 4686 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create());
4672 scoped_ptr<OutputSurface> output_surface( 4687 scoped_ptr<OutputSurface> output_surface(
4673 FakeOutputSurface::Create3d(provider)); 4688 FakeOutputSurface::Create3d(provider));
4674 CreateHostImpl(DefaultSettings(), output_surface.Pass()); 4689 CreateHostImpl(DefaultSettings(), output_surface.Pass());
4675 4690
4676 scoped_ptr<LayerImpl> root = 4691 scoped_ptr<LayerImpl> root =
4677 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); 4692 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1);
4678 root->SetBounds(gfx::Size(10, 10)); 4693 root->SetBounds(gfx::Size(10, 10));
4679 root->SetContentBounds(gfx::Size(10, 10)); 4694 root->SetContentBounds(gfx::Size(10, 10));
4680 root->SetDrawsContent(true); 4695 root->SetDrawsContent(true);
4696 root->SetHasRenderSurface(true);
4681 host_impl_->active_tree()->SetRootLayer(root.Pass()); 4697 host_impl_->active_tree()->SetRootLayer(root.Pass());
4682 EXPECT_FALSE(provider->TestContext3d()->reshape_called()); 4698 EXPECT_FALSE(provider->TestContext3d()->reshape_called());
4683 provider->TestContext3d()->clear_reshape_called(); 4699 provider->TestContext3d()->clear_reshape_called();
4684 4700
4685 LayerTreeHostImpl::FrameData frame; 4701 LayerTreeHostImpl::FrameData frame;
4686 host_impl_->SetViewportSize(gfx::Size(10, 10)); 4702 host_impl_->SetViewportSize(gfx::Size(10, 10));
4687 host_impl_->SetDeviceScaleFactor(1.f); 4703 host_impl_->SetDeviceScaleFactor(1.f);
4688 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 4704 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
4689 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4705 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4690 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); 4706 EXPECT_TRUE(provider->TestContext3d()->reshape_called());
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
4739 &proxy_, 4755 &proxy_,
4740 &stats_instrumentation_, 4756 &stats_instrumentation_,
4741 shared_bitmap_manager.get(), 4757 shared_bitmap_manager.get(),
4742 NULL, 4758 NULL,
4743 0); 4759 0);
4744 layer_tree_host_impl->InitializeRenderer(output_surface.Pass()); 4760 layer_tree_host_impl->InitializeRenderer(output_surface.Pass());
4745 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); 4761 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500));
4746 4762
4747 scoped_ptr<LayerImpl> root = 4763 scoped_ptr<LayerImpl> root =
4748 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); 4764 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1);
4765 root->SetHasRenderSurface(true);
4749 scoped_ptr<LayerImpl> child = 4766 scoped_ptr<LayerImpl> child =
4750 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); 4767 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2);
4751 child->SetPosition(gfx::PointF(12.f, 13.f)); 4768 child->SetPosition(gfx::PointF(12.f, 13.f));
4752 child->SetBounds(gfx::Size(14, 15)); 4769 child->SetBounds(gfx::Size(14, 15));
4753 child->SetContentBounds(gfx::Size(14, 15)); 4770 child->SetContentBounds(gfx::Size(14, 15));
4754 child->SetDrawsContent(true); 4771 child->SetDrawsContent(true);
4755 root->SetBounds(gfx::Size(500, 500)); 4772 root->SetBounds(gfx::Size(500, 500));
4756 root->SetContentBounds(gfx::Size(500, 500)); 4773 root->SetContentBounds(gfx::Size(500, 500));
4757 root->SetDrawsContent(true); 4774 root->SetDrawsContent(true);
4758 root->AddChild(child.Pass()); 4775 root->AddChild(child.Pass());
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
4805 scoped_ptr<LayerImpl> root = 4822 scoped_ptr<LayerImpl> root =
4806 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); 4823 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1);
4807 scoped_ptr<LayerImpl> child = 4824 scoped_ptr<LayerImpl> child =
4808 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2); 4825 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2);
4809 child->SetBounds(gfx::Size(10, 10)); 4826 child->SetBounds(gfx::Size(10, 10));
4810 child->SetContentBounds(gfx::Size(10, 10)); 4827 child->SetContentBounds(gfx::Size(10, 10));
4811 child->SetDrawsContent(true); 4828 child->SetDrawsContent(true);
4812 root->SetBounds(gfx::Size(10, 10)); 4829 root->SetBounds(gfx::Size(10, 10));
4813 root->SetContentBounds(gfx::Size(10, 10)); 4830 root->SetContentBounds(gfx::Size(10, 10));
4814 root->SetDrawsContent(true); 4831 root->SetDrawsContent(true);
4815 root->SetForceRenderSurface(true); 4832 root->SetHasRenderSurface(true);
4816 root->AddChild(child.Pass()); 4833 root->AddChild(child.Pass());
4817 4834
4818 host_impl_->active_tree()->SetRootLayer(root.Pass()); 4835 host_impl_->active_tree()->SetRootLayer(root.Pass());
4819 4836
4820 LayerTreeHostImpl::FrameData frame; 4837 LayerTreeHostImpl::FrameData frame;
4821 4838
4822 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 4839 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
4823 EXPECT_EQ(1u, frame.render_surface_layer_list->size()); 4840 EXPECT_EQ(1u, frame.render_surface_layer_list->size());
4824 EXPECT_EQ(1u, frame.render_passes.size()); 4841 EXPECT_EQ(1u, frame.render_passes.size());
4825 host_impl_->DidDrawAllLayers(frame); 4842 host_impl_->DidDrawAllLayers(frame);
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
5054 LayerImpl::Create(my_host_impl->active_tree(), 1); 5071 LayerImpl::Create(my_host_impl->active_tree(), 1);
5055 scoped_ptr<LayerImpl> child = 5072 scoped_ptr<LayerImpl> child =
5056 LayerImpl::Create(my_host_impl->active_tree(), 2); 5073 LayerImpl::Create(my_host_impl->active_tree(), 2);
5057 scoped_ptr<LayerImpl> grand_child = 5074 scoped_ptr<LayerImpl> grand_child =
5058 FakeLayerWithQuads::Create(my_host_impl->active_tree(), 3); 5075 FakeLayerWithQuads::Create(my_host_impl->active_tree(), 3);
5059 5076
5060 gfx::Rect root_rect(0, 0, 100, 100); 5077 gfx::Rect root_rect(0, 0, 100, 100);
5061 gfx::Rect child_rect(10, 10, 50, 50); 5078 gfx::Rect child_rect(10, 10, 50, 50);
5062 gfx::Rect grand_child_rect(5, 5, 150, 150); 5079 gfx::Rect grand_child_rect(5, 5, 150, 150);
5063 5080
5064 root->CreateRenderSurface(); 5081 root->SetHasRenderSurface(true);
5065 root->SetPosition(root_rect.origin()); 5082 root->SetPosition(root_rect.origin());
5066 root->SetBounds(root_rect.size()); 5083 root->SetBounds(root_rect.size());
5067 root->SetContentBounds(root->bounds()); 5084 root->SetContentBounds(root->bounds());
5068 root->draw_properties().visible_content_rect = root_rect; 5085 root->draw_properties().visible_content_rect = root_rect;
5069 root->SetDrawsContent(false); 5086 root->SetDrawsContent(false);
5070 root->render_surface()->SetContentRect(gfx::Rect(root_rect.size())); 5087 root->render_surface()->SetContentRect(gfx::Rect(root_rect.size()));
5071 5088
5072 child->SetPosition(gfx::PointF(child_rect.x(), child_rect.y())); 5089 child->SetPosition(gfx::PointF(child_rect.x(), child_rect.y()));
5073 child->SetOpacity(0.5f); 5090 child->SetOpacity(0.5f);
5074 child->SetBounds(gfx::Size(child_rect.width(), child_rect.height())); 5091 child->SetBounds(gfx::Size(child_rect.width(), child_rect.height()));
5075 child->SetContentBounds(child->bounds()); 5092 child->SetContentBounds(child->bounds());
5076 child->draw_properties().visible_content_rect = child_rect; 5093 child->draw_properties().visible_content_rect = child_rect;
5077 child->SetDrawsContent(false); 5094 child->SetDrawsContent(false);
5078 child->SetForceRenderSurface(true); 5095 child->SetHasRenderSurface(true);
5079 5096
5080 grand_child->SetPosition(grand_child_rect.origin()); 5097 grand_child->SetPosition(grand_child_rect.origin());
5081 grand_child->SetBounds(grand_child_rect.size()); 5098 grand_child->SetBounds(grand_child_rect.size());
5082 grand_child->SetContentBounds(grand_child->bounds()); 5099 grand_child->SetContentBounds(grand_child->bounds());
5083 grand_child->draw_properties().visible_content_rect = grand_child_rect; 5100 grand_child->draw_properties().visible_content_rect = grand_child_rect;
5084 grand_child->SetDrawsContent(true); 5101 grand_child->SetDrawsContent(true);
5085 5102
5086 child->AddChild(grand_child.Pass()); 5103 child->AddChild(grand_child.Pass());
5087 root->AddChild(child.Pass()); 5104 root->AddChild(child.Pass());
5088 5105
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
5148 scoped_ptr<TestWebGraphicsContext3D> context = 5165 scoped_ptr<TestWebGraphicsContext3D> context =
5149 TestWebGraphicsContext3D::Create(); 5166 TestWebGraphicsContext3D::Create();
5150 TestWebGraphicsContext3D* context3d = context.get(); 5167 TestWebGraphicsContext3D* context3d = context.get();
5151 scoped_ptr<OutputSurface> output_surface( 5168 scoped_ptr<OutputSurface> output_surface(
5152 FakeOutputSurface::Create3d(context.Pass())); 5169 FakeOutputSurface::Create3d(context.Pass()));
5153 CreateHostImpl(DefaultSettings(), output_surface.Pass()); 5170 CreateHostImpl(DefaultSettings(), output_surface.Pass());
5154 5171
5155 scoped_ptr<LayerImpl> root_layer = 5172 scoped_ptr<LayerImpl> root_layer =
5156 LayerImpl::Create(host_impl_->active_tree(), 1); 5173 LayerImpl::Create(host_impl_->active_tree(), 1);
5157 root_layer->SetBounds(gfx::Size(10, 10)); 5174 root_layer->SetBounds(gfx::Size(10, 10));
5175 root_layer->SetHasRenderSurface(true);
5158 5176
5159 scoped_refptr<VideoFrame> softwareFrame = 5177 scoped_refptr<VideoFrame> softwareFrame =
5160 media::VideoFrame::CreateColorFrame( 5178 media::VideoFrame::CreateColorFrame(
5161 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); 5179 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta());
5162 FakeVideoFrameProvider provider; 5180 FakeVideoFrameProvider provider;
5163 provider.set_frame(softwareFrame); 5181 provider.set_frame(softwareFrame);
5164 scoped_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( 5182 scoped_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create(
5165 host_impl_->active_tree(), 4, &provider, media::VIDEO_ROTATION_0); 5183 host_impl_->active_tree(), 4, &provider, media::VIDEO_ROTATION_0);
5166 video_layer->SetBounds(gfx::Size(10, 10)); 5184 video_layer->SetBounds(gfx::Size(10, 10));
5167 video_layer->SetContentBounds(gfx::Size(10, 10)); 5185 video_layer->SetContentBounds(gfx::Size(10, 10));
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
5322 } 5340 }
5323 }; 5341 };
5324 5342
5325 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) { 5343 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) {
5326 scoped_ptr<SolidColorLayerImpl> root = 5344 scoped_ptr<SolidColorLayerImpl> root =
5327 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); 5345 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1);
5328 root->SetPosition(gfx::PointF()); 5346 root->SetPosition(gfx::PointF());
5329 root->SetBounds(gfx::Size(10, 10)); 5347 root->SetBounds(gfx::Size(10, 10));
5330 root->SetContentBounds(gfx::Size(10, 10)); 5348 root->SetContentBounds(gfx::Size(10, 10));
5331 root->SetDrawsContent(true); 5349 root->SetDrawsContent(true);
5350 root->SetHasRenderSurface(true);
5332 5351
5333 // Child layer is in the bottom right corner. 5352 // Child layer is in the bottom right corner.
5334 scoped_ptr<SolidColorLayerImpl> child = 5353 scoped_ptr<SolidColorLayerImpl> child =
5335 SolidColorLayerImpl::Create(host_impl_->active_tree(), 2); 5354 SolidColorLayerImpl::Create(host_impl_->active_tree(), 2);
5336 child->SetPosition(gfx::PointF(9.f, 9.f)); 5355 child->SetPosition(gfx::PointF(9.f, 9.f));
5337 child->SetBounds(gfx::Size(1, 1)); 5356 child->SetBounds(gfx::Size(1, 1));
5338 child->SetContentBounds(gfx::Size(1, 1)); 5357 child->SetContentBounds(gfx::Size(1, 1));
5339 child->SetDrawsContent(true); 5358 child->SetDrawsContent(true);
5340 root->AddChild(child.Pass()); 5359 root->AddChild(child.Pass());
5341 5360
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
5388 5407
5389 // Root 5408 // Root
5390 // | 5409 // |
5391 // +-- Scaling Layer (adds a 2x scale) 5410 // +-- Scaling Layer (adds a 2x scale)
5392 // | 5411 // |
5393 // +-- Content Layer 5412 // +-- Content Layer
5394 // +--Mask 5413 // +--Mask
5395 scoped_ptr<LayerImpl> scoped_root = 5414 scoped_ptr<LayerImpl> scoped_root =
5396 LayerImpl::Create(host_impl_->active_tree(), 1); 5415 LayerImpl::Create(host_impl_->active_tree(), 1);
5397 LayerImpl* root = scoped_root.get(); 5416 LayerImpl* root = scoped_root.get();
5417 root->SetHasRenderSurface(true);
5398 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); 5418 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass());
5399 5419
5400 scoped_ptr<LayerImpl> scoped_scaling_layer = 5420 scoped_ptr<LayerImpl> scoped_scaling_layer =
5401 LayerImpl::Create(host_impl_->active_tree(), 2); 5421 LayerImpl::Create(host_impl_->active_tree(), 2);
5402 LayerImpl* scaling_layer = scoped_scaling_layer.get(); 5422 LayerImpl* scaling_layer = scoped_scaling_layer.get();
5403 root->AddChild(scoped_scaling_layer.Pass()); 5423 root->AddChild(scoped_scaling_layer.Pass());
5404 5424
5405 scoped_ptr<LayerImpl> scoped_content_layer = 5425 scoped_ptr<LayerImpl> scoped_content_layer =
5406 LayerImpl::Create(host_impl_->active_tree(), 3); 5426 LayerImpl::Create(host_impl_->active_tree(), 3);
5407 LayerImpl* content_layer = scoped_content_layer.get(); 5427 LayerImpl* content_layer = scoped_content_layer.get();
5408 scaling_layer->AddChild(scoped_content_layer.Pass()); 5428 scaling_layer->AddChild(scoped_content_layer.Pass());
5409 5429
5410 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = 5430 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer =
5411 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); 5431 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4);
5412 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); 5432 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get();
5433 content_layer->SetHasRenderSurface(true);
5413 content_layer->SetMaskLayer(scoped_mask_layer.Pass()); 5434 content_layer->SetMaskLayer(scoped_mask_layer.Pass());
5414 5435
5415 gfx::Size root_size(100, 100); 5436 gfx::Size root_size(100, 100);
5416 root->SetBounds(root_size); 5437 root->SetBounds(root_size);
5417 root->SetContentBounds(root_size); 5438 root->SetContentBounds(root_size);
5418 root->SetPosition(gfx::PointF()); 5439 root->SetPosition(gfx::PointF());
5419 5440
5420 gfx::Size scaling_layer_size(50, 50); 5441 gfx::Size scaling_layer_size(50, 50);
5421 scaling_layer->SetBounds(scaling_layer_size); 5442 scaling_layer->SetBounds(scaling_layer_size);
5422 scaling_layer->SetContentBounds(scaling_layer_size); 5443 scaling_layer->SetContentBounds(scaling_layer_size);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
5528 } 5549 }
5529 } 5550 }
5530 5551
5531 TEST_F(LayerTreeHostImplTest, MaskLayerWithDifferentBounds) { 5552 TEST_F(LayerTreeHostImplTest, MaskLayerWithDifferentBounds) {
5532 // The mask layer has bounds 100x100 but is attached to a layer with bounds 5553 // The mask layer has bounds 100x100 but is attached to a layer with bounds
5533 // 50x50. 5554 // 50x50.
5534 5555
5535 scoped_ptr<LayerImpl> scoped_root = 5556 scoped_ptr<LayerImpl> scoped_root =
5536 LayerImpl::Create(host_impl_->active_tree(), 1); 5557 LayerImpl::Create(host_impl_->active_tree(), 1);
5537 LayerImpl* root = scoped_root.get(); 5558 LayerImpl* root = scoped_root.get();
5559 root->SetHasRenderSurface(true);
5560
5538 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); 5561 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass());
5539 5562
5540 scoped_ptr<LayerImpl> scoped_content_layer = 5563 scoped_ptr<LayerImpl> scoped_content_layer =
5541 LayerImpl::Create(host_impl_->active_tree(), 3); 5564 LayerImpl::Create(host_impl_->active_tree(), 3);
5542 LayerImpl* content_layer = scoped_content_layer.get(); 5565 LayerImpl* content_layer = scoped_content_layer.get();
5543 root->AddChild(scoped_content_layer.Pass()); 5566 root->AddChild(scoped_content_layer.Pass());
5544 5567
5545 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = 5568 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer =
5546 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); 5569 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4);
5547 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); 5570 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get();
5548 content_layer->SetMaskLayer(scoped_mask_layer.Pass()); 5571 content_layer->SetMaskLayer(scoped_mask_layer.Pass());
5572 content_layer->SetHasRenderSurface(true);
5549 5573
5550 gfx::Size root_size(100, 100); 5574 gfx::Size root_size(100, 100);
5551 root->SetBounds(root_size); 5575 root->SetBounds(root_size);
5552 root->SetContentBounds(root_size); 5576 root->SetContentBounds(root_size);
5553 root->SetPosition(gfx::PointF()); 5577 root->SetPosition(gfx::PointF());
5554 5578
5555 gfx::Size layer_size(50, 50); 5579 gfx::Size layer_size(50, 50);
5556 content_layer->SetBounds(layer_size); 5580 content_layer->SetBounds(layer_size);
5557 content_layer->SetContentBounds(layer_size); 5581 content_layer->SetContentBounds(layer_size);
5558 content_layer->SetPosition(gfx::PointF()); 5582 content_layer->SetPosition(gfx::PointF());
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
5682 } 5706 }
5683 } 5707 }
5684 5708
5685 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerWithDifferentBounds) { 5709 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerWithDifferentBounds) {
5686 // The replica's mask layer has bounds 100x100 but the replica is of a 5710 // The replica's mask layer has bounds 100x100 but the replica is of a
5687 // layer with bounds 50x50. 5711 // layer with bounds 50x50.
5688 5712
5689 scoped_ptr<LayerImpl> scoped_root = 5713 scoped_ptr<LayerImpl> scoped_root =
5690 LayerImpl::Create(host_impl_->active_tree(), 1); 5714 LayerImpl::Create(host_impl_->active_tree(), 1);
5691 LayerImpl* root = scoped_root.get(); 5715 LayerImpl* root = scoped_root.get();
5716 root->SetHasRenderSurface(true);
5717
5692 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); 5718 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass());
5693 5719
5694 scoped_ptr<LayerImpl> scoped_content_layer = 5720 scoped_ptr<LayerImpl> scoped_content_layer =
5695 LayerImpl::Create(host_impl_->active_tree(), 3); 5721 LayerImpl::Create(host_impl_->active_tree(), 3);
5696 LayerImpl* content_layer = scoped_content_layer.get(); 5722 LayerImpl* content_layer = scoped_content_layer.get();
5697 root->AddChild(scoped_content_layer.Pass()); 5723 root->AddChild(scoped_content_layer.Pass());
5698 5724
5699 scoped_ptr<LayerImpl> scoped_replica_layer = 5725 scoped_ptr<LayerImpl> scoped_replica_layer =
5700 LayerImpl::Create(host_impl_->active_tree(), 2); 5726 LayerImpl::Create(host_impl_->active_tree(), 2);
5701 LayerImpl* replica_layer = scoped_replica_layer.get(); 5727 LayerImpl* replica_layer = scoped_replica_layer.get();
5702 content_layer->SetReplicaLayer(scoped_replica_layer.Pass()); 5728 content_layer->SetReplicaLayer(scoped_replica_layer.Pass());
5729 content_layer->SetHasRenderSurface(true);
5703 5730
5704 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = 5731 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer =
5705 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); 5732 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4);
5706 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); 5733 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get();
5707 replica_layer->SetMaskLayer(scoped_mask_layer.Pass()); 5734 replica_layer->SetMaskLayer(scoped_mask_layer.Pass());
5735 replica_layer->SetHasRenderSurface(true);
5708 5736
5709 gfx::Size root_size(100, 100); 5737 gfx::Size root_size(100, 100);
5710 root->SetBounds(root_size); 5738 root->SetBounds(root_size);
5711 root->SetContentBounds(root_size); 5739 root->SetContentBounds(root_size);
5712 root->SetPosition(gfx::PointF()); 5740 root->SetPosition(gfx::PointF());
5713 5741
5714 gfx::Size layer_size(50, 50); 5742 gfx::Size layer_size(50, 50);
5715 content_layer->SetBounds(layer_size); 5743 content_layer->SetBounds(layer_size);
5716 content_layer->SetContentBounds(layer_size); 5744 content_layer->SetContentBounds(layer_size);
5717 content_layer->SetPosition(gfx::PointF()); 5745 content_layer->SetPosition(gfx::PointF());
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
5837 } 5865 }
5838 } 5866 }
5839 5867
5840 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerForSurfaceWithUnclippedChild) { 5868 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerForSurfaceWithUnclippedChild) {
5841 // The replica is of a layer with bounds 50x50, but it has a child that causes 5869 // The replica is of a layer with bounds 50x50, but it has a child that causes
5842 // the surface bounds to be larger. 5870 // the surface bounds to be larger.
5843 5871
5844 scoped_ptr<LayerImpl> scoped_root = 5872 scoped_ptr<LayerImpl> scoped_root =
5845 LayerImpl::Create(host_impl_->active_tree(), 1); 5873 LayerImpl::Create(host_impl_->active_tree(), 1);
5846 LayerImpl* root = scoped_root.get(); 5874 LayerImpl* root = scoped_root.get();
5875 root->SetHasRenderSurface(true);
5847 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); 5876 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass());
5848 5877
5849 scoped_ptr<LayerImpl> scoped_content_layer = 5878 scoped_ptr<LayerImpl> scoped_content_layer =
5850 LayerImpl::Create(host_impl_->active_tree(), 2); 5879 LayerImpl::Create(host_impl_->active_tree(), 2);
5851 LayerImpl* content_layer = scoped_content_layer.get(); 5880 LayerImpl* content_layer = scoped_content_layer.get();
5852 root->AddChild(scoped_content_layer.Pass()); 5881 root->AddChild(scoped_content_layer.Pass());
5853 5882
5854 scoped_ptr<LayerImpl> scoped_content_child_layer = 5883 scoped_ptr<LayerImpl> scoped_content_child_layer =
5855 LayerImpl::Create(host_impl_->active_tree(), 3); 5884 LayerImpl::Create(host_impl_->active_tree(), 3);
5856 LayerImpl* content_child_layer = scoped_content_child_layer.get(); 5885 LayerImpl* content_child_layer = scoped_content_child_layer.get();
5857 content_layer->AddChild(scoped_content_child_layer.Pass()); 5886 content_layer->AddChild(scoped_content_child_layer.Pass());
5858 5887
5859 scoped_ptr<LayerImpl> scoped_replica_layer = 5888 scoped_ptr<LayerImpl> scoped_replica_layer =
5860 LayerImpl::Create(host_impl_->active_tree(), 4); 5889 LayerImpl::Create(host_impl_->active_tree(), 4);
5861 LayerImpl* replica_layer = scoped_replica_layer.get(); 5890 LayerImpl* replica_layer = scoped_replica_layer.get();
5862 content_layer->SetReplicaLayer(scoped_replica_layer.Pass()); 5891 content_layer->SetReplicaLayer(scoped_replica_layer.Pass());
5892 content_layer->SetHasRenderSurface(true);
5863 5893
5864 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = 5894 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer =
5865 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 5); 5895 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 5);
5866 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); 5896 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get();
5867 replica_layer->SetMaskLayer(scoped_mask_layer.Pass()); 5897 replica_layer->SetMaskLayer(scoped_mask_layer.Pass());
5898 replica_layer->SetHasRenderSurface(true);
5868 5899
5869 gfx::Size root_size(100, 100); 5900 gfx::Size root_size(100, 100);
5870 root->SetBounds(root_size); 5901 root->SetBounds(root_size);
5871 root->SetContentBounds(root_size); 5902 root->SetContentBounds(root_size);
5872 root->SetPosition(gfx::PointF()); 5903 root->SetPosition(gfx::PointF());
5873 5904
5874 gfx::Size layer_size(50, 50); 5905 gfx::Size layer_size(50, 50);
5875 content_layer->SetBounds(layer_size); 5906 content_layer->SetBounds(layer_size);
5876 content_layer->SetContentBounds(layer_size); 5907 content_layer->SetContentBounds(layer_size);
5877 content_layer->SetPosition(gfx::PointF()); 5908 content_layer->SetPosition(gfx::PointF());
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
5961 } 5992 }
5962 5993
5963 TEST_F(LayerTreeHostImplTest, MaskLayerForSurfaceWithClippedLayer) { 5994 TEST_F(LayerTreeHostImplTest, MaskLayerForSurfaceWithClippedLayer) {
5964 // The masked layer has bounds 50x50, but it has a child that causes 5995 // The masked layer has bounds 50x50, but it has a child that causes
5965 // the surface bounds to be larger. It also has a parent that clips the 5996 // the surface bounds to be larger. It also has a parent that clips the
5966 // masked layer and its surface. 5997 // masked layer and its surface.
5967 5998
5968 scoped_ptr<LayerImpl> scoped_root = 5999 scoped_ptr<LayerImpl> scoped_root =
5969 LayerImpl::Create(host_impl_->active_tree(), 1); 6000 LayerImpl::Create(host_impl_->active_tree(), 1);
5970 LayerImpl* root = scoped_root.get(); 6001 LayerImpl* root = scoped_root.get();
6002 root->SetHasRenderSurface(true);
6003
5971 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); 6004 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass());
5972 6005
5973 scoped_ptr<LayerImpl> scoped_clipping_layer = 6006 scoped_ptr<LayerImpl> scoped_clipping_layer =
5974 LayerImpl::Create(host_impl_->active_tree(), 2); 6007 LayerImpl::Create(host_impl_->active_tree(), 2);
5975 LayerImpl* clipping_layer = scoped_clipping_layer.get(); 6008 LayerImpl* clipping_layer = scoped_clipping_layer.get();
5976 root->AddChild(scoped_clipping_layer.Pass()); 6009 root->AddChild(scoped_clipping_layer.Pass());
5977 6010
5978 scoped_ptr<LayerImpl> scoped_content_layer = 6011 scoped_ptr<LayerImpl> scoped_content_layer =
5979 LayerImpl::Create(host_impl_->active_tree(), 3); 6012 LayerImpl::Create(host_impl_->active_tree(), 3);
5980 LayerImpl* content_layer = scoped_content_layer.get(); 6013 LayerImpl* content_layer = scoped_content_layer.get();
5981 clipping_layer->AddChild(scoped_content_layer.Pass()); 6014 clipping_layer->AddChild(scoped_content_layer.Pass());
5982 6015
5983 scoped_ptr<LayerImpl> scoped_content_child_layer = 6016 scoped_ptr<LayerImpl> scoped_content_child_layer =
5984 LayerImpl::Create(host_impl_->active_tree(), 4); 6017 LayerImpl::Create(host_impl_->active_tree(), 4);
5985 LayerImpl* content_child_layer = scoped_content_child_layer.get(); 6018 LayerImpl* content_child_layer = scoped_content_child_layer.get();
5986 content_layer->AddChild(scoped_content_child_layer.Pass()); 6019 content_layer->AddChild(scoped_content_child_layer.Pass());
5987 6020
5988 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = 6021 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer =
5989 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 6); 6022 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 6);
5990 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); 6023 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get();
5991 content_layer->SetMaskLayer(scoped_mask_layer.Pass()); 6024 content_layer->SetMaskLayer(scoped_mask_layer.Pass());
6025 content_layer->SetHasRenderSurface(true);
5992 6026
5993 gfx::Size root_size(100, 100); 6027 gfx::Size root_size(100, 100);
5994 root->SetBounds(root_size); 6028 root->SetBounds(root_size);
5995 root->SetContentBounds(root_size); 6029 root->SetContentBounds(root_size);
5996 root->SetPosition(gfx::PointF()); 6030 root->SetPosition(gfx::PointF());
5997 6031
5998 gfx::Rect clipping_rect(20, 10, 10, 20); 6032 gfx::Rect clipping_rect(20, 10, 10, 20);
5999 clipping_layer->SetBounds(clipping_rect.size()); 6033 clipping_layer->SetBounds(clipping_rect.size());
6000 clipping_layer->SetContentBounds(clipping_rect.size()); 6034 clipping_layer->SetContentBounds(clipping_rect.size());
6001 clipping_layer->SetPosition(clipping_rect.origin()); 6035 clipping_layer->SetPosition(clipping_rect.origin());
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
6067 gfx::ToCeiledSize(gfx::ScaleSize(root_size, device_scale_factor)); 6101 gfx::ToCeiledSize(gfx::ScaleSize(root_size, device_scale_factor));
6068 host_impl_->SetViewportSize(device_viewport_size); 6102 host_impl_->SetViewportSize(device_viewport_size);
6069 6103
6070 host_impl_->CreatePendingTree(); 6104 host_impl_->CreatePendingTree();
6071 host_impl_->pending_tree() 6105 host_impl_->pending_tree()
6072 ->SetPageScaleFactorAndLimits(1.f, 1.f / 16.f, 16.f); 6106 ->SetPageScaleFactorAndLimits(1.f, 1.f / 16.f, 16.f);
6073 6107
6074 scoped_ptr<LayerImpl> scoped_root = 6108 scoped_ptr<LayerImpl> scoped_root =
6075 LayerImpl::Create(host_impl_->pending_tree(), 1); 6109 LayerImpl::Create(host_impl_->pending_tree(), 1);
6076 LayerImpl* root = scoped_root.get(); 6110 LayerImpl* root = scoped_root.get();
6111 root->SetHasRenderSurface(true);
6077 6112
6078 host_impl_->pending_tree()->SetRootLayer(scoped_root.Pass()); 6113 host_impl_->pending_tree()->SetRootLayer(scoped_root.Pass());
6079 6114
6080 scoped_ptr<LayerImpl> scoped_scrolling_layer = 6115 scoped_ptr<LayerImpl> scoped_scrolling_layer =
6081 LayerImpl::Create(host_impl_->pending_tree(), 2); 6116 LayerImpl::Create(host_impl_->pending_tree(), 2);
6082 LayerImpl* scrolling_layer = scoped_scrolling_layer.get(); 6117 LayerImpl* scrolling_layer = scoped_scrolling_layer.get();
6083 root->AddChild(scoped_scrolling_layer.Pass()); 6118 root->AddChild(scoped_scrolling_layer.Pass());
6084 6119
6085 gfx::Size content_layer_bounds(100000, 100); 6120 gfx::Size content_layer_bounds(100000, 100);
6086 gfx::Size pile_tile_size(3000, 3000); 6121 gfx::Size pile_tile_size(3000, 3000);
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
6568 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures()); 6603 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures());
6569 } 6604 }
6570 6605
6571 TEST_F(LayerTreeHostImplTest, TouchFlingShouldNotBubble) { 6606 TEST_F(LayerTreeHostImplTest, TouchFlingShouldNotBubble) {
6572 // When flinging via touch, only the child should scroll (we should not 6607 // When flinging via touch, only the child should scroll (we should not
6573 // bubble). 6608 // bubble).
6574 gfx::Size surface_size(10, 10); 6609 gfx::Size surface_size(10, 10);
6575 gfx::Size content_size(20, 20); 6610 gfx::Size content_size(20, 20);
6576 scoped_ptr<LayerImpl> root_clip = 6611 scoped_ptr<LayerImpl> root_clip =
6577 LayerImpl::Create(host_impl_->active_tree(), 3); 6612 LayerImpl::Create(host_impl_->active_tree(), 3);
6613 root_clip->SetHasRenderSurface(true);
6614
6578 scoped_ptr<LayerImpl> root = 6615 scoped_ptr<LayerImpl> root =
6579 CreateScrollableLayer(1, content_size, root_clip.get()); 6616 CreateScrollableLayer(1, content_size, root_clip.get());
6580 root->SetIsContainerForFixedPositionLayers(true); 6617 root->SetIsContainerForFixedPositionLayers(true);
6581 scoped_ptr<LayerImpl> child = 6618 scoped_ptr<LayerImpl> child =
6582 CreateScrollableLayer(2, content_size, root_clip.get()); 6619 CreateScrollableLayer(2, content_size, root_clip.get());
6583 6620
6584 root->AddChild(child.Pass()); 6621 root->AddChild(child.Pass());
6585 int root_id = root->id(); 6622 int root_id = root->id();
6586 root_clip->AddChild(root.Pass()); 6623 root_clip->AddChild(root.Pass());
6587 6624
(...skipping 23 matching lines...) Expand all
6611 ASSERT_EQ(1u, scroll_info->scrolls.size()); 6648 ASSERT_EQ(1u, scroll_info->scrolls.size());
6612 ExpectNone(*scroll_info.get(), root_id); 6649 ExpectNone(*scroll_info.get(), root_id);
6613 } 6650 }
6614 } 6651 }
6615 6652
6616 TEST_F(LayerTreeHostImplTest, TouchFlingShouldLockToFirstScrolledLayer) { 6653 TEST_F(LayerTreeHostImplTest, TouchFlingShouldLockToFirstScrolledLayer) {
6617 // Scroll a child layer beyond its maximum scroll range and make sure the 6654 // Scroll a child layer beyond its maximum scroll range and make sure the
6618 // the scroll doesn't bubble up to the parent layer. 6655 // the scroll doesn't bubble up to the parent layer.
6619 gfx::Size surface_size(10, 10); 6656 gfx::Size surface_size(10, 10);
6620 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); 6657 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
6658 root->SetHasRenderSurface(true);
6621 scoped_ptr<LayerImpl> root_scrolling = 6659 scoped_ptr<LayerImpl> root_scrolling =
6622 CreateScrollableLayer(2, surface_size, root.get()); 6660 CreateScrollableLayer(2, surface_size, root.get());
6623 6661
6624 scoped_ptr<LayerImpl> grand_child = 6662 scoped_ptr<LayerImpl> grand_child =
6625 CreateScrollableLayer(4, surface_size, root.get()); 6663 CreateScrollableLayer(4, surface_size, root.get());
6626 grand_child->SetScrollOffset(gfx::ScrollOffset(0, 2)); 6664 grand_child->SetScrollOffset(gfx::ScrollOffset(0, 2));
6627 6665
6628 scoped_ptr<LayerImpl> child = 6666 scoped_ptr<LayerImpl> child =
6629 CreateScrollableLayer(3, surface_size, root.get()); 6667 CreateScrollableLayer(3, surface_size, root.get());
6630 child->SetScrollOffset(gfx::ScrollOffset(0, 4)); 6668 child->SetScrollOffset(gfx::ScrollOffset(0, 4));
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
6681 } 6719 }
6682 } 6720 }
6683 6721
6684 TEST_F(LayerTreeHostImplTest, WheelFlingShouldBubble) { 6722 TEST_F(LayerTreeHostImplTest, WheelFlingShouldBubble) {
6685 // When flinging via wheel, the root should eventually scroll (we should 6723 // When flinging via wheel, the root should eventually scroll (we should
6686 // bubble). 6724 // bubble).
6687 gfx::Size surface_size(10, 10); 6725 gfx::Size surface_size(10, 10);
6688 gfx::Size content_size(20, 20); 6726 gfx::Size content_size(20, 20);
6689 scoped_ptr<LayerImpl> root_clip = 6727 scoped_ptr<LayerImpl> root_clip =
6690 LayerImpl::Create(host_impl_->active_tree(), 3); 6728 LayerImpl::Create(host_impl_->active_tree(), 3);
6729 root_clip->SetHasRenderSurface(true);
6691 scoped_ptr<LayerImpl> root_scroll = 6730 scoped_ptr<LayerImpl> root_scroll =
6692 CreateScrollableLayer(1, content_size, root_clip.get()); 6731 CreateScrollableLayer(1, content_size, root_clip.get());
6693 int root_scroll_id = root_scroll->id(); 6732 int root_scroll_id = root_scroll->id();
6694 scoped_ptr<LayerImpl> child = 6733 scoped_ptr<LayerImpl> child =
6695 CreateScrollableLayer(2, content_size, root_clip.get()); 6734 CreateScrollableLayer(2, content_size, root_clip.get());
6696 6735
6697 root_scroll->AddChild(child.Pass()); 6736 root_scroll->AddChild(child.Pass());
6698 root_clip->AddChild(root_scroll.Pass()); 6737 root_clip->AddChild(root_scroll.Pass());
6699 6738
6700 host_impl_->SetViewportSize(surface_size); 6739 host_impl_->SetViewportSize(surface_size);
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
6884 6923
6885 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed 6924 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed
6886 // to CompositorFrameMetadata after SwapBuffers(); 6925 // to CompositorFrameMetadata after SwapBuffers();
6887 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { 6926 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) {
6888 scoped_ptr<SolidColorLayerImpl> root = 6927 scoped_ptr<SolidColorLayerImpl> root =
6889 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); 6928 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1);
6890 root->SetPosition(gfx::PointF()); 6929 root->SetPosition(gfx::PointF());
6891 root->SetBounds(gfx::Size(10, 10)); 6930 root->SetBounds(gfx::Size(10, 10));
6892 root->SetContentBounds(gfx::Size(10, 10)); 6931 root->SetContentBounds(gfx::Size(10, 10));
6893 root->SetDrawsContent(true); 6932 root->SetDrawsContent(true);
6933 root->SetHasRenderSurface(true);
6894 6934
6895 host_impl_->active_tree()->SetRootLayer(root.Pass()); 6935 host_impl_->active_tree()->SetRootLayer(root.Pass());
6896 6936
6897 FakeOutputSurface* fake_output_surface = 6937 FakeOutputSurface* fake_output_surface =
6898 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); 6938 static_cast<FakeOutputSurface*>(host_impl_->output_surface());
6899 6939
6900 const std::vector<ui::LatencyInfo>& metadata_latency_before = 6940 const std::vector<ui::LatencyInfo>& metadata_latency_before =
6901 fake_output_surface->last_sent_frame().metadata.latency_info; 6941 fake_output_surface->last_sent_frame().metadata.latency_info;
6902 EXPECT_TRUE(metadata_latency_before.empty()); 6942 EXPECT_TRUE(metadata_latency_before.empty());
6903 6943
(...skipping 20 matching lines...) Expand all
6924 } 6964 }
6925 6965
6926 TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) { 6966 TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) {
6927 int root_layer_id = 1; 6967 int root_layer_id = 1;
6928 scoped_ptr<SolidColorLayerImpl> root = 6968 scoped_ptr<SolidColorLayerImpl> root =
6929 SolidColorLayerImpl::Create(host_impl_->active_tree(), root_layer_id); 6969 SolidColorLayerImpl::Create(host_impl_->active_tree(), root_layer_id);
6930 root->SetPosition(gfx::PointF()); 6970 root->SetPosition(gfx::PointF());
6931 root->SetBounds(gfx::Size(10, 10)); 6971 root->SetBounds(gfx::Size(10, 10));
6932 root->SetContentBounds(gfx::Size(10, 10)); 6972 root->SetContentBounds(gfx::Size(10, 10));
6933 root->SetDrawsContent(true); 6973 root->SetDrawsContent(true);
6974 root->SetHasRenderSurface(true);
6934 6975
6935 host_impl_->active_tree()->SetRootLayer(root.Pass()); 6976 host_impl_->active_tree()->SetRootLayer(root.Pass());
6936 6977
6937 // Ensure the default frame selection bounds are empty. 6978 // Ensure the default frame selection bounds are empty.
6938 FakeOutputSurface* fake_output_surface = 6979 FakeOutputSurface* fake_output_surface =
6939 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); 6980 static_cast<FakeOutputSurface*>(host_impl_->output_surface());
6940 const ViewportSelectionBound& selection_start_before = 6981 const ViewportSelectionBound& selection_start_before =
6941 fake_output_surface->last_sent_frame().metadata.selection_start; 6982 fake_output_surface->last_sent_frame().metadata.selection_start;
6942 const ViewportSelectionBound& selection_end_before = 6983 const ViewportSelectionBound& selection_end_before =
6943 fake_output_surface->last_sent_frame().metadata.selection_end; 6984 fake_output_surface->last_sent_frame().metadata.selection_end;
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
7421 contents->SetBounds(content_size); 7462 contents->SetBounds(content_size);
7422 contents->SetContentBounds(content_size); 7463 contents->SetContentBounds(content_size);
7423 contents->SetPosition(gfx::PointF()); 7464 contents->SetPosition(gfx::PointF());
7424 7465
7425 outer_scroll->AddChild(contents.Pass()); 7466 outer_scroll->AddChild(contents.Pass());
7426 outer_clip->AddChild(outer_scroll.Pass()); 7467 outer_clip->AddChild(outer_scroll.Pass());
7427 inner_scroll->AddChild(outer_clip.Pass()); 7468 inner_scroll->AddChild(outer_clip.Pass());
7428 page_scale->AddChild(inner_scroll.Pass()); 7469 page_scale->AddChild(inner_scroll.Pass());
7429 inner_clip->AddChild(page_scale.Pass()); 7470 inner_clip->AddChild(page_scale.Pass());
7430 7471
7472 inner_clip->SetHasRenderSurface(true);
7431 layer_tree_impl->SetRootLayer(inner_clip.Pass()); 7473 layer_tree_impl->SetRootLayer(inner_clip.Pass());
7432 layer_tree_impl->SetViewportLayersFromIds(kPageScaleLayerId, 7474 layer_tree_impl->SetViewportLayersFromIds(kPageScaleLayerId,
7433 kInnerViewportScrollLayerId, kOuterViewportScrollLayerId); 7475 kInnerViewportScrollLayerId, kOuterViewportScrollLayerId);
7434 7476
7435 host_impl_->active_tree()->DidBecomeActive(); 7477 host_impl_->active_tree()->DidBecomeActive();
7436 } 7478 }
7437 }; 7479 };
7438 7480
7439 TEST_F(LayerTreeHostImplVirtualViewportTest, FlingScrollBubblesToInner) { 7481 TEST_F(LayerTreeHostImplVirtualViewportTest, FlingScrollBubblesToInner) {
7440 gfx::Size content_size = gfx::Size(100, 160); 7482 gfx::Size content_size = gfx::Size(100, 160);
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
7706 // surface. 7748 // surface.
7707 EXPECT_EQ(0, num_lost_surfaces_); 7749 EXPECT_EQ(0, num_lost_surfaces_);
7708 host_impl_->DidLoseOutputSurface(); 7750 host_impl_->DidLoseOutputSurface();
7709 EXPECT_EQ(1, num_lost_surfaces_); 7751 EXPECT_EQ(1, num_lost_surfaces_);
7710 host_impl_->DidLoseOutputSurface(); 7752 host_impl_->DidLoseOutputSurface();
7711 EXPECT_LE(1, num_lost_surfaces_); 7753 EXPECT_LE(1, num_lost_surfaces_);
7712 } 7754 }
7713 7755
7714 } // namespace 7756 } // namespace
7715 } // namespace cc 7757 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698