| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 #include "cc/test/fake_layer_tree_host_impl.h" | 42 #include "cc/test/fake_layer_tree_host_impl.h" |
| 43 #include "cc/test/fake_output_surface.h" | 43 #include "cc/test/fake_output_surface.h" |
| 44 #include "cc/test/fake_output_surface_client.h" | 44 #include "cc/test/fake_output_surface_client.h" |
| 45 #include "cc/test/fake_picture_layer_impl.h" | 45 #include "cc/test/fake_picture_layer_impl.h" |
| 46 #include "cc/test/fake_picture_pile_impl.h" | 46 #include "cc/test/fake_picture_pile_impl.h" |
| 47 #include "cc/test/fake_proxy.h" | 47 #include "cc/test/fake_proxy.h" |
| 48 #include "cc/test/fake_rendering_stats_instrumentation.h" | 48 #include "cc/test/fake_rendering_stats_instrumentation.h" |
| 49 #include "cc/test/fake_video_frame_provider.h" | 49 #include "cc/test/fake_video_frame_provider.h" |
| 50 #include "cc/test/geometry_test_utils.h" | 50 #include "cc/test/geometry_test_utils.h" |
| 51 #include "cc/test/layer_test_common.h" | 51 #include "cc/test/layer_test_common.h" |
| 52 #include "cc/test/layer_tree_test.h" |
| 52 #include "cc/test/render_pass_test_common.h" | 53 #include "cc/test/render_pass_test_common.h" |
| 53 #include "cc/test/test_shared_bitmap_manager.h" | 54 #include "cc/test/test_shared_bitmap_manager.h" |
| 54 #include "cc/test/test_web_graphics_context_3d.h" | 55 #include "cc/test/test_web_graphics_context_3d.h" |
| 55 #include "cc/trees/layer_tree_impl.h" | 56 #include "cc/trees/layer_tree_impl.h" |
| 56 #include "cc/trees/single_thread_proxy.h" | 57 #include "cc/trees/single_thread_proxy.h" |
| 57 #include "media/base/media.h" | 58 #include "media/base/media.h" |
| 58 #include "testing/gmock/include/gmock/gmock.h" | 59 #include "testing/gmock/include/gmock/gmock.h" |
| 59 #include "testing/gtest/include/gtest/gtest.h" | 60 #include "testing/gtest/include/gtest/gtest.h" |
| 60 #include "third_party/skia/include/core/SkMallocPixelRef.h" | 61 #include "third_party/skia/include/core/SkMallocPixelRef.h" |
| 61 #include "ui/gfx/frame_time.h" | 62 #include "ui/gfx/frame_time.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 181 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
| 181 return init; | 182 return init; |
| 182 } | 183 } |
| 183 | 184 |
| 184 void SetupRootLayerImpl(scoped_ptr<LayerImpl> root) { | 185 void SetupRootLayerImpl(scoped_ptr<LayerImpl> root) { |
| 185 root->SetPosition(gfx::PointF()); | 186 root->SetPosition(gfx::PointF()); |
| 186 root->SetBounds(gfx::Size(10, 10)); | 187 root->SetBounds(gfx::Size(10, 10)); |
| 187 root->SetContentBounds(gfx::Size(10, 10)); | 188 root->SetContentBounds(gfx::Size(10, 10)); |
| 188 root->SetDrawsContent(true); | 189 root->SetDrawsContent(true); |
| 189 root->draw_properties().visible_content_rect = gfx::Rect(0, 0, 10, 10); | 190 root->draw_properties().visible_content_rect = gfx::Rect(0, 0, 10, 10); |
| 191 root->CreateRenderSurface(); |
| 190 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 192 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 191 } | 193 } |
| 192 | 194 |
| 193 static void ExpectClearedScrollDeltasRecursive(LayerImpl* layer) { | 195 static void ExpectClearedScrollDeltasRecursive(LayerImpl* layer) { |
| 194 ASSERT_EQ(layer->ScrollDelta(), gfx::Vector2d()); | 196 ASSERT_EQ(layer->ScrollDelta(), gfx::Vector2d()); |
| 195 for (size_t i = 0; i < layer->children().size(); ++i) | 197 for (size_t i = 0; i < layer->children().size(); ++i) |
| 196 ExpectClearedScrollDeltasRecursive(layer->children()[i]); | 198 ExpectClearedScrollDeltasRecursive(layer->children()[i]); |
| 197 } | 199 } |
| 198 | 200 |
| 199 static void ExpectContains(const ScrollAndScaleSet& scroll_info, | 201 static void ExpectContains(const ScrollAndScaleSet& scroll_info, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 226 LayerImpl* CreateScrollAndContentsLayers(LayerTreeImpl* layer_tree_impl, | 228 LayerImpl* CreateScrollAndContentsLayers(LayerTreeImpl* layer_tree_impl, |
| 227 const gfx::Size& content_size) { | 229 const gfx::Size& content_size) { |
| 228 const int kInnerViewportScrollLayerId = 2; | 230 const int kInnerViewportScrollLayerId = 2; |
| 229 const int kInnerViewportClipLayerId = 4; | 231 const int kInnerViewportClipLayerId = 4; |
| 230 const int kPageScaleLayerId = 5; | 232 const int kPageScaleLayerId = 5; |
| 231 scoped_ptr<LayerImpl> root = | 233 scoped_ptr<LayerImpl> root = |
| 232 LayerImpl::Create(layer_tree_impl, 1); | 234 LayerImpl::Create(layer_tree_impl, 1); |
| 233 root->SetBounds(content_size); | 235 root->SetBounds(content_size); |
| 234 root->SetContentBounds(content_size); | 236 root->SetContentBounds(content_size); |
| 235 root->SetPosition(gfx::PointF()); | 237 root->SetPosition(gfx::PointF()); |
| 238 root->CreateRenderSurface(); |
| 236 | 239 |
| 237 scoped_ptr<LayerImpl> scroll = | 240 scoped_ptr<LayerImpl> scroll = |
| 238 LayerImpl::Create(layer_tree_impl, kInnerViewportScrollLayerId); | 241 LayerImpl::Create(layer_tree_impl, kInnerViewportScrollLayerId); |
| 239 LayerImpl* scroll_layer = scroll.get(); | 242 LayerImpl* scroll_layer = scroll.get(); |
| 240 scroll->SetIsContainerForFixedPositionLayers(true); | 243 scroll->SetIsContainerForFixedPositionLayers(true); |
| 241 scroll->SetScrollOffset(gfx::Vector2d()); | 244 scroll->SetScrollOffset(gfx::Vector2d()); |
| 242 | 245 |
| 243 scoped_ptr<LayerImpl> clip = | 246 scoped_ptr<LayerImpl> clip = |
| 244 LayerImpl::Create(layer_tree_impl, kInnerViewportClipLayerId); | 247 LayerImpl::Create(layer_tree_impl, kInnerViewportClipLayerId); |
| 245 clip->SetBounds( | 248 clip->SetBounds( |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 ExpectContains(*scroll_info, scroll_layer->id(), scroll_delta); | 566 ExpectContains(*scroll_info, scroll_layer->id(), scroll_delta); |
| 564 } | 567 } |
| 565 | 568 |
| 566 TEST_F(LayerTreeHostImplTest, ClearRootRenderSurfaceAndScroll) { | 569 TEST_F(LayerTreeHostImplTest, ClearRootRenderSurfaceAndScroll) { |
| 567 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 570 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 568 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 571 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 569 DrawFrame(); | 572 DrawFrame(); |
| 570 | 573 |
| 571 // We should be able to scroll even if the root layer loses its render surface | 574 // We should be able to scroll even if the root layer loses its render surface |
| 572 // after the most recent render. | 575 // after the most recent render. |
| 573 host_impl_->active_tree()->root_layer()->ClearRenderSurface(); | 576 host_impl_->active_tree()->root_layer()->SetRenderSurfaceActive(false); |
| 574 host_impl_->active_tree()->set_needs_update_draw_properties(); | 577 host_impl_->active_tree()->set_needs_update_draw_properties(); |
| 575 | 578 |
| 576 EXPECT_EQ(InputHandler::ScrollStarted, | 579 EXPECT_EQ(InputHandler::ScrollStarted, |
| 577 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); | 580 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
| 578 } | 581 } |
| 579 | 582 |
| 580 TEST_F(LayerTreeHostImplTest, WheelEventHandlers) { | 583 TEST_F(LayerTreeHostImplTest, WheelEventHandlers) { |
| 581 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 584 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 582 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 585 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 583 DrawFrame(); | 586 DrawFrame(); |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 882 } | 885 } |
| 883 | 886 |
| 884 TEST_F(LayerTreeHostImplTest, | 887 TEST_F(LayerTreeHostImplTest, |
| 885 ClearRootRenderSurfaceAndHitTestTouchHandlerRegion) { | 888 ClearRootRenderSurfaceAndHitTestTouchHandlerRegion) { |
| 886 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 889 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 887 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 890 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 888 DrawFrame(); | 891 DrawFrame(); |
| 889 | 892 |
| 890 // We should be able to hit test for touch event handlers even if the root | 893 // We should be able to hit test for touch event handlers even if the root |
| 891 // layer loses its render surface after the most recent render. | 894 // layer loses its render surface after the most recent render. |
| 892 host_impl_->active_tree()->root_layer()->ClearRenderSurface(); | 895 host_impl_->active_tree()->root_layer()->SetRenderSurfaceActive(false); |
| 893 host_impl_->active_tree()->set_needs_update_draw_properties(); | 896 host_impl_->active_tree()->set_needs_update_draw_properties(); |
| 894 | 897 |
| 895 EXPECT_EQ(host_impl_->HaveTouchEventHandlersAt(gfx::Point()), false); | 898 EXPECT_EQ(host_impl_->HaveTouchEventHandlersAt(gfx::Point()), false); |
| 896 } | 899 } |
| 897 | 900 |
| 898 TEST_F(LayerTreeHostImplTest, ImplPinchZoom) { | 901 TEST_F(LayerTreeHostImplTest, ImplPinchZoom) { |
| 899 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 902 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 900 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 903 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 901 DrawFrame(); | 904 DrawFrame(); |
| 902 | 905 |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1321 contents->SetBounds(content_size); \ | 1324 contents->SetBounds(content_size); \ |
| 1322 contents->SetContentBounds(content_size); \ | 1325 contents->SetContentBounds(content_size); \ |
| 1323 \ | 1326 \ |
| 1324 scoped_ptr<SolidColorScrollbarLayerImpl> scrollbar = \ | 1327 scoped_ptr<SolidColorScrollbarLayerImpl> scrollbar = \ |
| 1325 SolidColorScrollbarLayerImpl::Create( \ | 1328 SolidColorScrollbarLayerImpl::Create( \ |
| 1326 host_impl_->active_tree(), 4, VERTICAL, 10, 0, false, true); \ | 1329 host_impl_->active_tree(), 4, VERTICAL, 10, 0, false, true); \ |
| 1327 EXPECT_FLOAT_EQ(0.f, scrollbar->opacity()); \ | 1330 EXPECT_FLOAT_EQ(0.f, scrollbar->opacity()); \ |
| 1328 \ | 1331 \ |
| 1329 scroll->AddChild(contents.Pass()); \ | 1332 scroll->AddChild(contents.Pass()); \ |
| 1330 root->AddChild(scroll.Pass()); \ | 1333 root->AddChild(scroll.Pass()); \ |
| 1334 root->CreateRenderSurface(); \ |
| 1331 scrollbar->SetScrollLayerAndClipLayerByIds(2, 1); \ | 1335 scrollbar->SetScrollLayerAndClipLayerByIds(2, 1); \ |
| 1332 root->AddChild(scrollbar.PassAs<LayerImpl>()); \ | 1336 root->AddChild(scrollbar.PassAs<LayerImpl>()); \ |
| 1333 \ | 1337 \ |
| 1334 host_impl_->active_tree()->SetRootLayer(root.Pass()); \ | 1338 host_impl_->active_tree()->SetRootLayer(root.Pass()); \ |
| 1335 host_impl_->active_tree()->SetViewportLayersFromIds( \ | 1339 host_impl_->active_tree()->SetViewportLayersFromIds( \ |
| 1336 1, 2, Layer::INVALID_ID); \ | 1340 1, 2, Layer::INVALID_ID); \ |
| 1337 host_impl_->active_tree()->DidBecomeActive(); \ | 1341 host_impl_->active_tree()->DidBecomeActive(); \ |
| 1338 DrawFrame(); | 1342 DrawFrame(); |
| 1339 | 1343 |
| 1340 TEST_F(LayerTreeHostImplTest, ScrollbarLinearFadeScheduling) { | 1344 TEST_F(LayerTreeHostImplTest, ScrollbarLinearFadeScheduling) { |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1458 gfx::ScaleSize(viewport_size, device_scale_factor)); | 1462 gfx::ScaleSize(viewport_size, device_scale_factor)); |
| 1459 gfx::Size content_size(1000, 1000); | 1463 gfx::Size content_size(1000, 1000); |
| 1460 | 1464 |
| 1461 CreateHostImpl(settings, CreateOutputSurface()); | 1465 CreateHostImpl(settings, CreateOutputSurface()); |
| 1462 host_impl_->SetDeviceScaleFactor(device_scale_factor); | 1466 host_impl_->SetDeviceScaleFactor(device_scale_factor); |
| 1463 host_impl_->SetViewportSize(device_viewport_size); | 1467 host_impl_->SetViewportSize(device_viewport_size); |
| 1464 | 1468 |
| 1465 scoped_ptr<LayerImpl> root = | 1469 scoped_ptr<LayerImpl> root = |
| 1466 LayerImpl::Create(host_impl_->active_tree(), 1); | 1470 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 1467 root->SetBounds(viewport_size); | 1471 root->SetBounds(viewport_size); |
| 1472 root->CreateRenderSurface(); |
| 1468 | 1473 |
| 1469 scoped_ptr<LayerImpl> scroll = | 1474 scoped_ptr<LayerImpl> scroll = |
| 1470 LayerImpl::Create(host_impl_->active_tree(), 2); | 1475 LayerImpl::Create(host_impl_->active_tree(), 2); |
| 1471 scroll->SetScrollClipLayer(root->id()); | 1476 scroll->SetScrollClipLayer(root->id()); |
| 1472 scroll->SetScrollOffset(gfx::Vector2d()); | 1477 scroll->SetScrollOffset(gfx::Vector2d()); |
| 1473 scroll->SetBounds(content_size); | 1478 scroll->SetBounds(content_size); |
| 1474 scroll->SetContentBounds(content_size); | 1479 scroll->SetContentBounds(content_size); |
| 1475 scroll->SetIsContainerForFixedPositionLayers(true); | 1480 scroll->SetIsContainerForFixedPositionLayers(true); |
| 1476 | 1481 |
| 1477 scoped_ptr<LayerImpl> contents = | 1482 scoped_ptr<LayerImpl> contents = |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1662 | 1667 |
| 1663 TEST_F(LayerTreeHostImplTest, WillDrawReturningFalseDoesNotCall) { | 1668 TEST_F(LayerTreeHostImplTest, WillDrawReturningFalseDoesNotCall) { |
| 1664 // The root layer is always drawn, so run this test on a child layer that | 1669 // The root layer is always drawn, so run this test on a child layer that |
| 1665 // will be masked out by the root layer's bounds. | 1670 // will be masked out by the root layer's bounds. |
| 1666 host_impl_->active_tree()->SetRootLayer( | 1671 host_impl_->active_tree()->SetRootLayer( |
| 1667 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 1672 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
| 1668 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( | 1673 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( |
| 1669 host_impl_->active_tree()->root_layer()); | 1674 host_impl_->active_tree()->root_layer()); |
| 1670 | 1675 |
| 1671 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 1676 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
| 1677 root->CreateRenderSurface(); |
| 1672 DidDrawCheckLayer* layer = | 1678 DidDrawCheckLayer* layer = |
| 1673 static_cast<DidDrawCheckLayer*>(root->children()[0]); | 1679 static_cast<DidDrawCheckLayer*>(root->children()[0]); |
| 1674 | 1680 |
| 1675 { | 1681 { |
| 1676 LayerTreeHostImpl::FrameData frame; | 1682 LayerTreeHostImpl::FrameData frame; |
| 1677 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 1683 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 1678 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 1684 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 1679 host_impl_->DidDrawAllLayers(frame); | 1685 host_impl_->DidDrawAllLayers(frame); |
| 1680 | 1686 |
| 1681 EXPECT_TRUE(layer->will_draw_called()); | 1687 EXPECT_TRUE(layer->will_draw_called()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1702 } | 1708 } |
| 1703 | 1709 |
| 1704 TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) { | 1710 TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) { |
| 1705 // The root layer is always drawn, so run this test on a child layer that | 1711 // The root layer is always drawn, so run this test on a child layer that |
| 1706 // will be masked out by the root layer's bounds. | 1712 // will be masked out by the root layer's bounds. |
| 1707 host_impl_->active_tree()->SetRootLayer( | 1713 host_impl_->active_tree()->SetRootLayer( |
| 1708 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 1714 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
| 1709 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( | 1715 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( |
| 1710 host_impl_->active_tree()->root_layer()); | 1716 host_impl_->active_tree()->root_layer()); |
| 1711 root->SetMasksToBounds(true); | 1717 root->SetMasksToBounds(true); |
| 1712 | 1718 root->CreateRenderSurface(); |
| 1713 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 1719 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
| 1714 DidDrawCheckLayer* layer = | 1720 DidDrawCheckLayer* layer = |
| 1715 static_cast<DidDrawCheckLayer*>(root->children()[0]); | 1721 static_cast<DidDrawCheckLayer*>(root->children()[0]); |
| 1716 // Ensure visible_content_rect for layer is empty. | 1722 // Ensure visible_content_rect for layer is empty. |
| 1717 layer->SetPosition(gfx::PointF(100.f, 100.f)); | 1723 layer->SetPosition(gfx::PointF(100.f, 100.f)); |
| 1718 layer->SetBounds(gfx::Size(10, 10)); | 1724 layer->SetBounds(gfx::Size(10, 10)); |
| 1719 layer->SetContentBounds(gfx::Size(10, 10)); | 1725 layer->SetContentBounds(gfx::Size(10, 10)); |
| 1720 | 1726 |
| 1721 LayerTreeHostImpl::FrameData frame; | 1727 LayerTreeHostImpl::FrameData frame; |
| 1722 | 1728 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1755 host_impl_->active_tree()->SetRootLayer( | 1761 host_impl_->active_tree()->SetRootLayer( |
| 1756 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 1762 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
| 1757 DidDrawCheckLayer* root = | 1763 DidDrawCheckLayer* root = |
| 1758 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 1764 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 1759 | 1765 |
| 1760 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 1766 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
| 1761 DidDrawCheckLayer* occluded_layer = | 1767 DidDrawCheckLayer* occluded_layer = |
| 1762 static_cast<DidDrawCheckLayer*>(root->children()[0]); | 1768 static_cast<DidDrawCheckLayer*>(root->children()[0]); |
| 1763 | 1769 |
| 1764 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); | 1770 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); |
| 1771 root->CreateRenderSurface(); |
| 1765 DidDrawCheckLayer* top_layer = | 1772 DidDrawCheckLayer* top_layer = |
| 1766 static_cast<DidDrawCheckLayer*>(root->children()[1]); | 1773 static_cast<DidDrawCheckLayer*>(root->children()[1]); |
| 1767 // This layer covers the occluded_layer above. Make this layer large so it can | 1774 // This layer covers the occluded_layer above. Make this layer large so it can |
| 1768 // occlude. | 1775 // occlude. |
| 1769 top_layer->SetBounds(big_size); | 1776 top_layer->SetBounds(big_size); |
| 1770 top_layer->SetContentBounds(big_size); | 1777 top_layer->SetContentBounds(big_size); |
| 1771 top_layer->SetContentsOpaque(true); | 1778 top_layer->SetContentsOpaque(true); |
| 1772 | 1779 |
| 1773 LayerTreeHostImpl::FrameData frame; | 1780 LayerTreeHostImpl::FrameData frame; |
| 1774 | 1781 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1787 EXPECT_TRUE(top_layer->did_draw_called()); | 1794 EXPECT_TRUE(top_layer->did_draw_called()); |
| 1788 } | 1795 } |
| 1789 | 1796 |
| 1790 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { | 1797 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { |
| 1791 host_impl_->active_tree()->SetRootLayer( | 1798 host_impl_->active_tree()->SetRootLayer( |
| 1792 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 1799 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
| 1793 DidDrawCheckLayer* root = | 1800 DidDrawCheckLayer* root = |
| 1794 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 1801 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 1795 | 1802 |
| 1796 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 1803 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
| 1804 root->CreateRenderSurface(); |
| 1797 DidDrawCheckLayer* layer1 = | 1805 DidDrawCheckLayer* layer1 = |
| 1798 static_cast<DidDrawCheckLayer*>(root->children()[0]); | 1806 static_cast<DidDrawCheckLayer*>(root->children()[0]); |
| 1799 | 1807 |
| 1800 layer1->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); | 1808 layer1->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); |
| 1801 DidDrawCheckLayer* layer2 = | 1809 DidDrawCheckLayer* layer2 = |
| 1802 static_cast<DidDrawCheckLayer*>(layer1->children()[0]); | 1810 static_cast<DidDrawCheckLayer*>(layer1->children()[0]); |
| 1803 | 1811 |
| 1804 layer1->SetOpacity(0.3f); | 1812 layer1->SetOpacity(0.3f); |
| 1813 layer1->CreateRenderSurface(); |
| 1805 layer1->SetShouldFlattenTransform(true); | 1814 layer1->SetShouldFlattenTransform(true); |
| 1806 | 1815 |
| 1807 EXPECT_FALSE(root->did_draw_called()); | 1816 EXPECT_FALSE(root->did_draw_called()); |
| 1808 EXPECT_FALSE(layer1->did_draw_called()); | 1817 EXPECT_FALSE(layer1->did_draw_called()); |
| 1809 EXPECT_FALSE(layer2->did_draw_called()); | 1818 EXPECT_FALSE(layer2->did_draw_called()); |
| 1810 | 1819 |
| 1811 LayerTreeHostImpl::FrameData frame; | 1820 LayerTreeHostImpl::FrameData frame; |
| 1812 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( | 1821 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( |
| 1813 host_impl_->active_tree()->root_layer()); | 1822 host_impl_->active_tree()->root_layer()); |
| 1814 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 1823 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1866 | 1875 |
| 1867 bool tile_missing_; | 1876 bool tile_missing_; |
| 1868 bool had_incomplete_tile_; | 1877 bool had_incomplete_tile_; |
| 1869 }; | 1878 }; |
| 1870 | 1879 |
| 1871 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsOnDefault) { | 1880 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsOnDefault) { |
| 1872 host_impl_->active_tree()->SetRootLayer( | 1881 host_impl_->active_tree()->SetRootLayer( |
| 1873 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 1882 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
| 1874 DidDrawCheckLayer* root = | 1883 DidDrawCheckLayer* root = |
| 1875 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 1884 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 1876 | 1885 root->CreateRenderSurface(); |
| 1877 bool tile_missing = false; | 1886 bool tile_missing = false; |
| 1878 bool had_incomplete_tile = false; | 1887 bool had_incomplete_tile = false; |
| 1879 bool is_animating = false; | 1888 bool is_animating = false; |
| 1880 root->AddChild( | 1889 root->AddChild( |
| 1881 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 1890 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
| 1882 2, | 1891 2, |
| 1883 tile_missing, | 1892 tile_missing, |
| 1884 had_incomplete_tile, | 1893 had_incomplete_tile, |
| 1885 is_animating, | 1894 is_animating, |
| 1886 host_impl_->resource_provider())); | 1895 host_impl_->resource_provider())); |
| 1887 | 1896 |
| 1888 LayerTreeHostImpl::FrameData frame; | 1897 LayerTreeHostImpl::FrameData frame; |
| 1889 | 1898 |
| 1890 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 1899 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 1891 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 1900 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 1892 host_impl_->DidDrawAllLayers(frame); | 1901 host_impl_->DidDrawAllLayers(frame); |
| 1893 } | 1902 } |
| 1894 | 1903 |
| 1895 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithAnimatedLayer) { | 1904 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithAnimatedLayer) { |
| 1896 host_impl_->active_tree()->SetRootLayer( | 1905 host_impl_->active_tree()->SetRootLayer( |
| 1897 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 1906 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
| 1898 DidDrawCheckLayer* root = | 1907 DidDrawCheckLayer* root = |
| 1899 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 1908 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 1909 root->CreateRenderSurface(); |
| 1900 bool tile_missing = false; | 1910 bool tile_missing = false; |
| 1901 bool had_incomplete_tile = false; | 1911 bool had_incomplete_tile = false; |
| 1902 bool is_animating = true; | 1912 bool is_animating = true; |
| 1903 root->AddChild( | 1913 root->AddChild( |
| 1904 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 1914 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
| 1905 2, | 1915 2, |
| 1906 tile_missing, | 1916 tile_missing, |
| 1907 had_incomplete_tile, | 1917 had_incomplete_tile, |
| 1908 is_animating, | 1918 is_animating, |
| 1909 host_impl_->resource_provider())); | 1919 host_impl_->resource_provider())); |
| 1910 | 1920 |
| 1911 LayerTreeHostImpl::FrameData frame; | 1921 LayerTreeHostImpl::FrameData frame; |
| 1912 | 1922 |
| 1913 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 1923 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 1914 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 1924 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 1915 host_impl_->DidDrawAllLayers(frame); | 1925 host_impl_->DidDrawAllLayers(frame); |
| 1916 } | 1926 } |
| 1917 | 1927 |
| 1918 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithMissingTiles) { | 1928 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithMissingTiles) { |
| 1919 host_impl_->active_tree()->SetRootLayer( | 1929 host_impl_->active_tree()->SetRootLayer( |
| 1920 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); | 1930 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); |
| 1921 DidDrawCheckLayer* root = | 1931 DidDrawCheckLayer* root = |
| 1922 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 1932 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 1933 root->CreateRenderSurface(); |
| 1923 | 1934 |
| 1924 bool tile_missing = true; | 1935 bool tile_missing = true; |
| 1925 bool had_incomplete_tile = false; | 1936 bool had_incomplete_tile = false; |
| 1926 bool is_animating = false; | 1937 bool is_animating = false; |
| 1927 root->AddChild( | 1938 root->AddChild( |
| 1928 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 1939 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
| 1929 4, | 1940 4, |
| 1930 tile_missing, | 1941 tile_missing, |
| 1931 had_incomplete_tile, | 1942 had_incomplete_tile, |
| 1932 is_animating, | 1943 is_animating, |
| 1933 host_impl_->resource_provider())); | 1944 host_impl_->resource_provider())); |
| 1934 LayerTreeHostImpl::FrameData frame; | 1945 LayerTreeHostImpl::FrameData frame; |
| 1935 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 1946 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 1936 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 1947 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 1937 host_impl_->DidDrawAllLayers(frame); | 1948 host_impl_->DidDrawAllLayers(frame); |
| 1938 } | 1949 } |
| 1939 | 1950 |
| 1940 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithIncompleteTile) { | 1951 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithIncompleteTile) { |
| 1941 host_impl_->active_tree()->SetRootLayer( | 1952 host_impl_->active_tree()->SetRootLayer( |
| 1942 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); | 1953 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); |
| 1943 DidDrawCheckLayer* root = | 1954 DidDrawCheckLayer* root = |
| 1944 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 1955 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 1956 root->CreateRenderSurface(); |
| 1945 | 1957 |
| 1946 bool tile_missing = false; | 1958 bool tile_missing = false; |
| 1947 bool had_incomplete_tile = true; | 1959 bool had_incomplete_tile = true; |
| 1948 bool is_animating = false; | 1960 bool is_animating = false; |
| 1949 root->AddChild( | 1961 root->AddChild( |
| 1950 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 1962 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
| 1951 4, | 1963 4, |
| 1952 tile_missing, | 1964 tile_missing, |
| 1953 had_incomplete_tile, | 1965 had_incomplete_tile, |
| 1954 is_animating, | 1966 is_animating, |
| 1955 host_impl_->resource_provider())); | 1967 host_impl_->resource_provider())); |
| 1956 LayerTreeHostImpl::FrameData frame; | 1968 LayerTreeHostImpl::FrameData frame; |
| 1957 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 1969 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 1958 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 1970 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 1959 host_impl_->DidDrawAllLayers(frame); | 1971 host_impl_->DidDrawAllLayers(frame); |
| 1960 } | 1972 } |
| 1961 | 1973 |
| 1962 TEST_F(LayerTreeHostImplTest, | 1974 TEST_F(LayerTreeHostImplTest, |
| 1963 PrepareToDrawFailsWithAnimationAndMissingTilesUsesCheckerboard) { | 1975 PrepareToDrawFailsWithAnimationAndMissingTilesUsesCheckerboard) { |
| 1964 host_impl_->active_tree()->SetRootLayer( | 1976 host_impl_->active_tree()->SetRootLayer( |
| 1965 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); | 1977 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); |
| 1966 DidDrawCheckLayer* root = | 1978 DidDrawCheckLayer* root = |
| 1967 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 1979 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 1980 root->CreateRenderSurface(); |
| 1968 bool tile_missing = true; | 1981 bool tile_missing = true; |
| 1969 bool had_incomplete_tile = false; | 1982 bool had_incomplete_tile = false; |
| 1970 bool is_animating = true; | 1983 bool is_animating = true; |
| 1971 root->AddChild( | 1984 root->AddChild( |
| 1972 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 1985 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
| 1973 6, | 1986 6, |
| 1974 tile_missing, | 1987 tile_missing, |
| 1975 had_incomplete_tile, | 1988 had_incomplete_tile, |
| 1976 is_animating, | 1989 is_animating, |
| 1977 host_impl_->resource_provider())); | 1990 host_impl_->resource_provider())); |
| 1978 LayerTreeHostImpl::FrameData frame; | 1991 LayerTreeHostImpl::FrameData frame; |
| 1979 EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS, | 1992 EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS, |
| 1980 host_impl_->PrepareToDraw(&frame)); | 1993 host_impl_->PrepareToDraw(&frame)); |
| 1981 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 1994 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 1982 host_impl_->DidDrawAllLayers(frame); | 1995 host_impl_->DidDrawAllLayers(frame); |
| 1983 } | 1996 } |
| 1984 | 1997 |
| 1985 TEST_F(LayerTreeHostImplTest, | 1998 TEST_F(LayerTreeHostImplTest, |
| 1986 PrepareToDrawSucceedsWithAnimationAndIncompleteTiles) { | 1999 PrepareToDrawSucceedsWithAnimationAndIncompleteTiles) { |
| 1987 host_impl_->active_tree()->SetRootLayer( | 2000 host_impl_->active_tree()->SetRootLayer( |
| 1988 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); | 2001 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); |
| 1989 DidDrawCheckLayer* root = | 2002 DidDrawCheckLayer* root = |
| 1990 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2003 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 2004 root->CreateRenderSurface(); |
| 1991 bool tile_missing = false; | 2005 bool tile_missing = false; |
| 1992 bool had_incomplete_tile = true; | 2006 bool had_incomplete_tile = true; |
| 1993 bool is_animating = true; | 2007 bool is_animating = true; |
| 1994 root->AddChild( | 2008 root->AddChild( |
| 1995 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 2009 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
| 1996 6, | 2010 6, |
| 1997 tile_missing, | 2011 tile_missing, |
| 1998 had_incomplete_tile, | 2012 had_incomplete_tile, |
| 1999 is_animating, | 2013 is_animating, |
| 2000 host_impl_->resource_provider())); | 2014 host_impl_->resource_provider())); |
| 2001 LayerTreeHostImpl::FrameData frame; | 2015 LayerTreeHostImpl::FrameData frame; |
| 2002 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2016 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 2003 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2017 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2004 host_impl_->DidDrawAllLayers(frame); | 2018 host_impl_->DidDrawAllLayers(frame); |
| 2005 } | 2019 } |
| 2006 | 2020 |
| 2007 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWhenHighResRequired) { | 2021 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWhenHighResRequired) { |
| 2008 host_impl_->active_tree()->SetRootLayer( | 2022 host_impl_->active_tree()->SetRootLayer( |
| 2009 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); | 2023 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); |
| 2010 DidDrawCheckLayer* root = | 2024 DidDrawCheckLayer* root = |
| 2011 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2025 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 2026 root->CreateRenderSurface(); |
| 2012 bool tile_missing = false; | 2027 bool tile_missing = false; |
| 2013 bool had_incomplete_tile = false; | 2028 bool had_incomplete_tile = false; |
| 2014 bool is_animating = false; | 2029 bool is_animating = false; |
| 2015 root->AddChild( | 2030 root->AddChild( |
| 2016 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 2031 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
| 2017 8, | 2032 8, |
| 2018 tile_missing, | 2033 tile_missing, |
| 2019 had_incomplete_tile, | 2034 had_incomplete_tile, |
| 2020 is_animating, | 2035 is_animating, |
| 2021 host_impl_->resource_provider())); | 2036 host_impl_->resource_provider())); |
| 2022 host_impl_->active_tree()->SetRequiresHighResToDraw(); | 2037 host_impl_->active_tree()->SetRequiresHighResToDraw(); |
| 2023 LayerTreeHostImpl::FrameData frame; | 2038 LayerTreeHostImpl::FrameData frame; |
| 2024 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2039 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 2025 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2040 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2026 host_impl_->DidDrawAllLayers(frame); | 2041 host_impl_->DidDrawAllLayers(frame); |
| 2027 } | 2042 } |
| 2028 | 2043 |
| 2029 TEST_F(LayerTreeHostImplTest, | 2044 TEST_F(LayerTreeHostImplTest, |
| 2030 PrepareToDrawFailsWhenHighResRequiredAndIncompleteTiles) { | 2045 PrepareToDrawFailsWhenHighResRequiredAndIncompleteTiles) { |
| 2031 host_impl_->active_tree()->SetRootLayer( | 2046 host_impl_->active_tree()->SetRootLayer( |
| 2032 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); | 2047 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); |
| 2033 DidDrawCheckLayer* root = | 2048 DidDrawCheckLayer* root = |
| 2034 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2049 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 2050 root->CreateRenderSurface(); |
| 2035 bool tile_missing = false; | 2051 bool tile_missing = false; |
| 2036 bool had_incomplete_tile = true; | 2052 bool had_incomplete_tile = true; |
| 2037 bool is_animating = false; | 2053 bool is_animating = false; |
| 2038 root->AddChild( | 2054 root->AddChild( |
| 2039 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 2055 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
| 2040 8, | 2056 8, |
| 2041 tile_missing, | 2057 tile_missing, |
| 2042 had_incomplete_tile, | 2058 had_incomplete_tile, |
| 2043 is_animating, | 2059 is_animating, |
| 2044 host_impl_->resource_provider())); | 2060 host_impl_->resource_provider())); |
| 2045 host_impl_->active_tree()->SetRequiresHighResToDraw(); | 2061 host_impl_->active_tree()->SetRequiresHighResToDraw(); |
| 2046 LayerTreeHostImpl::FrameData frame; | 2062 LayerTreeHostImpl::FrameData frame; |
| 2047 EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT, | 2063 EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT, |
| 2048 host_impl_->PrepareToDraw(&frame)); | 2064 host_impl_->PrepareToDraw(&frame)); |
| 2049 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2065 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2050 host_impl_->DidDrawAllLayers(frame); | 2066 host_impl_->DidDrawAllLayers(frame); |
| 2051 } | 2067 } |
| 2052 | 2068 |
| 2053 TEST_F(LayerTreeHostImplTest, | 2069 TEST_F(LayerTreeHostImplTest, |
| 2054 PrepareToDrawFailsWhenHighResRequiredAndMissingTile) { | 2070 PrepareToDrawFailsWhenHighResRequiredAndMissingTile) { |
| 2055 host_impl_->active_tree()->SetRootLayer( | 2071 host_impl_->active_tree()->SetRootLayer( |
| 2056 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); | 2072 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); |
| 2057 DidDrawCheckLayer* root = | 2073 DidDrawCheckLayer* root = |
| 2058 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2074 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 2075 root->CreateRenderSurface(); |
| 2059 bool tile_missing = true; | 2076 bool tile_missing = true; |
| 2060 bool had_incomplete_tile = false; | 2077 bool had_incomplete_tile = false; |
| 2061 bool is_animating = false; | 2078 bool is_animating = false; |
| 2062 root->AddChild( | 2079 root->AddChild( |
| 2063 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 2080 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
| 2064 8, | 2081 8, |
| 2065 tile_missing, | 2082 tile_missing, |
| 2066 had_incomplete_tile, | 2083 had_incomplete_tile, |
| 2067 is_animating, | 2084 is_animating, |
| 2068 host_impl_->resource_provider())); | 2085 host_impl_->resource_provider())); |
| 2069 host_impl_->active_tree()->SetRequiresHighResToDraw(); | 2086 host_impl_->active_tree()->SetRequiresHighResToDraw(); |
| 2070 LayerTreeHostImpl::FrameData frame; | 2087 LayerTreeHostImpl::FrameData frame; |
| 2071 EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT, | 2088 EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT, |
| 2072 host_impl_->PrepareToDraw(&frame)); | 2089 host_impl_->PrepareToDraw(&frame)); |
| 2073 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2090 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2074 host_impl_->DidDrawAllLayers(frame); | 2091 host_impl_->DidDrawAllLayers(frame); |
| 2075 } | 2092 } |
| 2076 | 2093 |
| 2077 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { | 2094 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { |
| 2078 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 2095 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 2079 root->SetScrollClipLayer(Layer::INVALID_ID); | 2096 root->SetScrollClipLayer(Layer::INVALID_ID); |
| 2097 root->CreateRenderSurface(); |
| 2080 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 2098 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 2081 DrawFrame(); | 2099 DrawFrame(); |
| 2082 | 2100 |
| 2083 // Scroll event is ignored because layer is not scrollable. | 2101 // Scroll event is ignored because layer is not scrollable. |
| 2084 EXPECT_EQ(InputHandler::ScrollIgnored, | 2102 EXPECT_EQ(InputHandler::ScrollIgnored, |
| 2085 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); | 2103 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
| 2086 EXPECT_FALSE(did_request_redraw_); | 2104 EXPECT_FALSE(did_request_redraw_); |
| 2087 EXPECT_FALSE(did_request_commit_); | 2105 EXPECT_FALSE(did_request_commit_); |
| 2088 } | 2106 } |
| 2089 | 2107 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2112 root_clip->SetBounds(clip_size_); | 2130 root_clip->SetBounds(clip_size_); |
| 2113 root->SetScrollClipLayer(root_clip->id()); | 2131 root->SetScrollClipLayer(root_clip->id()); |
| 2114 root->SetBounds(layer_size_); | 2132 root->SetBounds(layer_size_); |
| 2115 root->SetContentBounds(layer_size_); | 2133 root->SetContentBounds(layer_size_); |
| 2116 root->SetPosition(gfx::PointF()); | 2134 root->SetPosition(gfx::PointF()); |
| 2117 root->SetDrawsContent(false); | 2135 root->SetDrawsContent(false); |
| 2118 root->SetIsContainerForFixedPositionLayers(true); | 2136 root->SetIsContainerForFixedPositionLayers(true); |
| 2119 int inner_viewport_scroll_layer_id = root->id(); | 2137 int inner_viewport_scroll_layer_id = root->id(); |
| 2120 int page_scale_layer_id = root_clip->id(); | 2138 int page_scale_layer_id = root_clip->id(); |
| 2121 root_clip->AddChild(root.Pass()); | 2139 root_clip->AddChild(root.Pass()); |
| 2140 root_clip->CreateRenderSurface(); |
| 2122 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 2141 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); |
| 2123 host_impl_->active_tree()->SetViewportLayersFromIds( | 2142 host_impl_->active_tree()->SetViewportLayersFromIds( |
| 2124 page_scale_layer_id, inner_viewport_scroll_layer_id, Layer::INVALID_ID); | 2143 page_scale_layer_id, inner_viewport_scroll_layer_id, Layer::INVALID_ID); |
| 2125 // Set a viewport size that is large enough to contain both the top controls | 2144 // Set a viewport size that is large enough to contain both the top controls |
| 2126 // and some content. | 2145 // and some content. |
| 2127 host_impl_->SetViewportSize(viewport_size_); | 2146 host_impl_->SetViewportSize(viewport_size_); |
| 2128 host_impl_->SetTopControlsLayoutHeight(settings_.top_controls_height); | 2147 host_impl_->SetTopControlsLayoutHeight(settings_.top_controls_height); |
| 2129 LayerImpl* root_clip_ptr = host_impl_->active_tree()->root_layer(); | 2148 LayerImpl* root_clip_ptr = host_impl_->active_tree()->root_layer(); |
| 2130 EXPECT_EQ(clip_size_, root_clip_ptr->bounds()); | 2149 EXPECT_EQ(clip_size_, root_clip_ptr->bounds()); |
| 2131 } | 2150 } |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2263 | 2282 |
| 2264 scoped_ptr<LayerImpl> scroll_layer = | 2283 scoped_ptr<LayerImpl> scroll_layer = |
| 2265 LayerImpl::Create(host_impl_->active_tree(), 2); | 2284 LayerImpl::Create(host_impl_->active_tree(), 2); |
| 2266 scroll_layer->SetScrollClipLayer(3); | 2285 scroll_layer->SetScrollClipLayer(3); |
| 2267 scroll_layer->SetBounds(contents_size); | 2286 scroll_layer->SetBounds(contents_size); |
| 2268 scroll_layer->SetContentBounds(contents_size); | 2287 scroll_layer->SetContentBounds(contents_size); |
| 2269 scroll_layer->SetPosition(gfx::PointF()); | 2288 scroll_layer->SetPosition(gfx::PointF()); |
| 2270 scroll_layer->AddChild(content_layer.Pass()); | 2289 scroll_layer->AddChild(content_layer.Pass()); |
| 2271 scroll_clip_layer->AddChild(scroll_layer.Pass()); | 2290 scroll_clip_layer->AddChild(scroll_layer.Pass()); |
| 2272 | 2291 |
| 2292 scroll_clip_layer->CreateRenderSurface(); |
| 2273 host_impl_->active_tree()->SetRootLayer(scroll_clip_layer.Pass()); | 2293 host_impl_->active_tree()->SetRootLayer(scroll_clip_layer.Pass()); |
| 2274 host_impl_->SetViewportSize(surface_size); | 2294 host_impl_->SetViewportSize(surface_size); |
| 2275 DrawFrame(); | 2295 DrawFrame(); |
| 2276 | 2296 |
| 2277 EXPECT_EQ(InputHandler::ScrollStarted, | 2297 EXPECT_EQ(InputHandler::ScrollStarted, |
| 2278 host_impl_->ScrollBegin(gfx::Point(5, 5), | 2298 host_impl_->ScrollBegin(gfx::Point(5, 5), |
| 2279 InputHandler::Wheel)); | 2299 InputHandler::Wheel)); |
| 2280 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 2300 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
| 2281 host_impl_->ScrollEnd(); | 2301 host_impl_->ScrollEnd(); |
| 2282 EXPECT_TRUE(did_request_redraw_); | 2302 EXPECT_TRUE(did_request_redraw_); |
| 2283 EXPECT_TRUE(did_request_commit_); | 2303 EXPECT_TRUE(did_request_commit_); |
| 2284 } | 2304 } |
| 2285 | 2305 |
| 2286 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) { | 2306 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) { |
| 2287 gfx::Size surface_size(10, 10); | 2307 gfx::Size surface_size(10, 10); |
| 2288 gfx::Size contents_size(20, 20); | 2308 gfx::Size contents_size(20, 20); |
| 2289 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 2309 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 2290 root->SetBounds(surface_size); | 2310 root->SetBounds(surface_size); |
| 2291 root->SetContentBounds(contents_size); | 2311 root->SetContentBounds(contents_size); |
| 2292 root->AddChild(CreateScrollableLayer(2, contents_size, root.get())); | 2312 root->AddChild(CreateScrollableLayer(2, contents_size, root.get())); |
| 2313 root->CreateRenderSurface(); |
| 2293 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 2314 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 2294 host_impl_->SetViewportSize(surface_size); | 2315 host_impl_->SetViewportSize(surface_size); |
| 2295 DrawFrame(); | 2316 DrawFrame(); |
| 2296 | 2317 |
| 2297 EXPECT_EQ(InputHandler::ScrollStarted, | 2318 EXPECT_EQ(InputHandler::ScrollStarted, |
| 2298 host_impl_->ScrollBegin(gfx::Point(5, 5), | 2319 host_impl_->ScrollBegin(gfx::Point(5, 5), |
| 2299 InputHandler::Wheel)); | 2320 InputHandler::Wheel)); |
| 2300 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 2321 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
| 2301 host_impl_->ScrollEnd(); | 2322 host_impl_->ScrollEnd(); |
| 2302 EXPECT_TRUE(did_request_redraw_); | 2323 EXPECT_TRUE(did_request_redraw_); |
| 2303 EXPECT_TRUE(did_request_commit_); | 2324 EXPECT_TRUE(did_request_commit_); |
| 2304 } | 2325 } |
| 2305 | 2326 |
| 2306 TEST_F(LayerTreeHostImplTest, ScrollMissesChild) { | 2327 TEST_F(LayerTreeHostImplTest, ScrollMissesChild) { |
| 2307 gfx::Size surface_size(10, 10); | 2328 gfx::Size surface_size(10, 10); |
| 2308 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 2329 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 2309 root->AddChild(CreateScrollableLayer(2, surface_size, root.get())); | 2330 root->AddChild(CreateScrollableLayer(2, surface_size, root.get())); |
| 2331 root->CreateRenderSurface(); |
| 2310 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 2332 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 2311 host_impl_->SetViewportSize(surface_size); | 2333 host_impl_->SetViewportSize(surface_size); |
| 2312 DrawFrame(); | 2334 DrawFrame(); |
| 2313 | 2335 |
| 2314 // Scroll event is ignored because the input coordinate is outside the layer | 2336 // Scroll event is ignored because the input coordinate is outside the layer |
| 2315 // boundaries. | 2337 // boundaries. |
| 2316 EXPECT_EQ(InputHandler::ScrollIgnored, | 2338 EXPECT_EQ(InputHandler::ScrollIgnored, |
| 2317 host_impl_->ScrollBegin(gfx::Point(15, 5), | 2339 host_impl_->ScrollBegin(gfx::Point(15, 5), |
| 2318 InputHandler::Wheel)); | 2340 InputHandler::Wheel)); |
| 2319 EXPECT_FALSE(did_request_redraw_); | 2341 EXPECT_FALSE(did_request_redraw_); |
| 2320 EXPECT_FALSE(did_request_commit_); | 2342 EXPECT_FALSE(did_request_commit_); |
| 2321 } | 2343 } |
| 2322 | 2344 |
| 2323 TEST_F(LayerTreeHostImplTest, ScrollMissesBackfacingChild) { | 2345 TEST_F(LayerTreeHostImplTest, ScrollMissesBackfacingChild) { |
| 2324 gfx::Size surface_size(10, 10); | 2346 gfx::Size surface_size(10, 10); |
| 2325 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 2347 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 2348 root->CreateRenderSurface(); |
| 2326 scoped_ptr<LayerImpl> child = | 2349 scoped_ptr<LayerImpl> child = |
| 2327 CreateScrollableLayer(2, surface_size, root.get()); | 2350 CreateScrollableLayer(2, surface_size, root.get()); |
| 2328 host_impl_->SetViewportSize(surface_size); | 2351 host_impl_->SetViewportSize(surface_size); |
| 2329 | 2352 |
| 2330 gfx::Transform matrix; | 2353 gfx::Transform matrix; |
| 2331 matrix.RotateAboutXAxis(180.0); | 2354 matrix.RotateAboutXAxis(180.0); |
| 2332 child->SetTransform(matrix); | 2355 child->SetTransform(matrix); |
| 2333 child->SetDoubleSided(false); | 2356 child->SetDoubleSided(false); |
| 2334 | 2357 |
| 2335 root->AddChild(child.Pass()); | 2358 root->AddChild(child.Pass()); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2353 CreateScrollableLayer(1, surface_size, clip_layer.get()); | 2376 CreateScrollableLayer(1, surface_size, clip_layer.get()); |
| 2354 content_layer->SetShouldScrollOnMainThread(true); | 2377 content_layer->SetShouldScrollOnMainThread(true); |
| 2355 content_layer->SetScrollClipLayer(Layer::INVALID_ID); | 2378 content_layer->SetScrollClipLayer(Layer::INVALID_ID); |
| 2356 | 2379 |
| 2357 // Note: we can use the same clip layer for both since both calls to | 2380 // Note: we can use the same clip layer for both since both calls to |
| 2358 // CreateScrollableLayer() use the same surface size. | 2381 // CreateScrollableLayer() use the same surface size. |
| 2359 scoped_ptr<LayerImpl> scroll_layer = | 2382 scoped_ptr<LayerImpl> scroll_layer = |
| 2360 CreateScrollableLayer(2, surface_size, clip_layer.get()); | 2383 CreateScrollableLayer(2, surface_size, clip_layer.get()); |
| 2361 scroll_layer->AddChild(content_layer.Pass()); | 2384 scroll_layer->AddChild(content_layer.Pass()); |
| 2362 clip_layer->AddChild(scroll_layer.Pass()); | 2385 clip_layer->AddChild(scroll_layer.Pass()); |
| 2386 clip_layer->CreateRenderSurface(); |
| 2363 | 2387 |
| 2364 host_impl_->active_tree()->SetRootLayer(clip_layer.Pass()); | 2388 host_impl_->active_tree()->SetRootLayer(clip_layer.Pass()); |
| 2365 host_impl_->SetViewportSize(surface_size); | 2389 host_impl_->SetViewportSize(surface_size); |
| 2366 DrawFrame(); | 2390 DrawFrame(); |
| 2367 | 2391 |
| 2368 // Scrolling fails because the content layer is asking to be scrolled on the | 2392 // Scrolling fails because the content layer is asking to be scrolled on the |
| 2369 // main thread. | 2393 // main thread. |
| 2370 EXPECT_EQ(InputHandler::ScrollOnMainThread, | 2394 EXPECT_EQ(InputHandler::ScrollOnMainThread, |
| 2371 host_impl_->ScrollBegin(gfx::Point(5, 5), | 2395 host_impl_->ScrollBegin(gfx::Point(5, 5), |
| 2372 InputHandler::Wheel)); | 2396 InputHandler::Wheel)); |
| 2373 } | 2397 } |
| 2374 | 2398 |
| 2375 TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnMainThread) { | 2399 TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnMainThread) { |
| 2376 gfx::Size surface_size(20, 20); | 2400 gfx::Size surface_size(20, 20); |
| 2377 gfx::Size viewport_size(10, 10); | 2401 gfx::Size viewport_size(10, 10); |
| 2378 float page_scale = 2.f; | 2402 float page_scale = 2.f; |
| 2379 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 2403 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 2380 scoped_ptr<LayerImpl> root_clip = | 2404 scoped_ptr<LayerImpl> root_clip = |
| 2381 LayerImpl::Create(host_impl_->active_tree(), 2); | 2405 LayerImpl::Create(host_impl_->active_tree(), 2); |
| 2382 scoped_ptr<LayerImpl> root_scrolling = | 2406 scoped_ptr<LayerImpl> root_scrolling = |
| 2383 CreateScrollableLayer(3, surface_size, root_clip.get()); | 2407 CreateScrollableLayer(3, surface_size, root_clip.get()); |
| 2384 EXPECT_EQ(viewport_size, root_clip->bounds()); | 2408 EXPECT_EQ(viewport_size, root_clip->bounds()); |
| 2385 root_scrolling->SetIsContainerForFixedPositionLayers(true); | 2409 root_scrolling->SetIsContainerForFixedPositionLayers(true); |
| 2386 root_clip->AddChild(root_scrolling.Pass()); | 2410 root_clip->AddChild(root_scrolling.Pass()); |
| 2387 root->AddChild(root_clip.Pass()); | 2411 root->AddChild(root_clip.Pass()); |
| 2412 root->CreateRenderSurface(); |
| 2388 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 2413 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 2389 // The behaviour in this test assumes the page scale is applied at a layer | 2414 // The behaviour in this test assumes the page scale is applied at a layer |
| 2390 // above the clip layer. | 2415 // above the clip layer. |
| 2391 host_impl_->active_tree()->SetViewportLayersFromIds(1, 3, Layer::INVALID_ID); | 2416 host_impl_->active_tree()->SetViewportLayersFromIds(1, 3, Layer::INVALID_ID); |
| 2392 host_impl_->active_tree()->DidBecomeActive(); | 2417 host_impl_->active_tree()->DidBecomeActive(); |
| 2393 host_impl_->SetViewportSize(viewport_size); | 2418 host_impl_->SetViewportSize(viewport_size); |
| 2394 DrawFrame(); | 2419 DrawFrame(); |
| 2395 | 2420 |
| 2396 LayerImpl* root_scroll = | 2421 LayerImpl* root_scroll = |
| 2397 host_impl_->active_tree()->InnerViewportScrollLayer(); | 2422 host_impl_->active_tree()->InnerViewportScrollLayer(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 2428 float page_scale = 2.f; | 2453 float page_scale = 2.f; |
| 2429 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 2454 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 2430 scoped_ptr<LayerImpl> root_clip = | 2455 scoped_ptr<LayerImpl> root_clip = |
| 2431 LayerImpl::Create(host_impl_->active_tree(), 2); | 2456 LayerImpl::Create(host_impl_->active_tree(), 2); |
| 2432 scoped_ptr<LayerImpl> root_scrolling = | 2457 scoped_ptr<LayerImpl> root_scrolling = |
| 2433 CreateScrollableLayer(3, surface_size, root_clip.get()); | 2458 CreateScrollableLayer(3, surface_size, root_clip.get()); |
| 2434 EXPECT_EQ(viewport_size, root_clip->bounds()); | 2459 EXPECT_EQ(viewport_size, root_clip->bounds()); |
| 2435 root_scrolling->SetIsContainerForFixedPositionLayers(true); | 2460 root_scrolling->SetIsContainerForFixedPositionLayers(true); |
| 2436 root_clip->AddChild(root_scrolling.Pass()); | 2461 root_clip->AddChild(root_scrolling.Pass()); |
| 2437 root->AddChild(root_clip.Pass()); | 2462 root->AddChild(root_clip.Pass()); |
| 2463 root->CreateRenderSurface(); |
| 2438 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 2464 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 2439 // The behaviour in this test assumes the page scale is applied at a layer | 2465 // The behaviour in this test assumes the page scale is applied at a layer |
| 2440 // above the clip layer. | 2466 // above the clip layer. |
| 2441 host_impl_->active_tree()->SetViewportLayersFromIds(1, 3, Layer::INVALID_ID); | 2467 host_impl_->active_tree()->SetViewportLayersFromIds(1, 3, Layer::INVALID_ID); |
| 2442 host_impl_->active_tree()->DidBecomeActive(); | 2468 host_impl_->active_tree()->DidBecomeActive(); |
| 2443 host_impl_->SetViewportSize(viewport_size); | 2469 host_impl_->SetViewportSize(viewport_size); |
| 2444 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 1.f, page_scale); | 2470 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 1.f, page_scale); |
| 2445 DrawFrame(); | 2471 DrawFrame(); |
| 2446 | 2472 |
| 2447 LayerImpl* root_scroll = | 2473 LayerImpl* root_scroll = |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2532 EXPECT_EQ(new_page_scale, | 2558 EXPECT_EQ(new_page_scale, |
| 2533 grand_child->draw_transform().matrix().getDouble(0, 0)); | 2559 grand_child->draw_transform().matrix().getDouble(0, 0)); |
| 2534 EXPECT_EQ(new_page_scale, | 2560 EXPECT_EQ(new_page_scale, |
| 2535 grand_child->draw_transform().matrix().getDouble(1, 1)); | 2561 grand_child->draw_transform().matrix().getDouble(1, 1)); |
| 2536 } | 2562 } |
| 2537 | 2563 |
| 2538 TEST_F(LayerTreeHostImplTest, ScrollChildAndChangePageScaleOnMainThread) { | 2564 TEST_F(LayerTreeHostImplTest, ScrollChildAndChangePageScaleOnMainThread) { |
| 2539 gfx::Size surface_size(30, 30); | 2565 gfx::Size surface_size(30, 30); |
| 2540 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 2566 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 2541 root->SetBounds(gfx::Size(5, 5)); | 2567 root->SetBounds(gfx::Size(5, 5)); |
| 2568 root->CreateRenderSurface(); |
| 2542 scoped_ptr<LayerImpl> root_scrolling = | 2569 scoped_ptr<LayerImpl> root_scrolling = |
| 2543 LayerImpl::Create(host_impl_->active_tree(), 2); | 2570 LayerImpl::Create(host_impl_->active_tree(), 2); |
| 2544 root_scrolling->SetBounds(surface_size); | 2571 root_scrolling->SetBounds(surface_size); |
| 2545 root_scrolling->SetContentBounds(surface_size); | 2572 root_scrolling->SetContentBounds(surface_size); |
| 2546 root_scrolling->SetScrollClipLayer(root->id()); | 2573 root_scrolling->SetScrollClipLayer(root->id()); |
| 2547 root_scrolling->SetIsContainerForFixedPositionLayers(true); | 2574 root_scrolling->SetIsContainerForFixedPositionLayers(true); |
| 2548 LayerImpl* root_scrolling_ptr = root_scrolling.get(); | 2575 LayerImpl* root_scrolling_ptr = root_scrolling.get(); |
| 2549 root->AddChild(root_scrolling.Pass()); | 2576 root->AddChild(root_scrolling.Pass()); |
| 2550 int child_scroll_layer_id = 3; | 2577 int child_scroll_layer_id = 3; |
| 2551 scoped_ptr<LayerImpl> child_scrolling = CreateScrollableLayer( | 2578 scoped_ptr<LayerImpl> child_scrolling = CreateScrollableLayer( |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2587 } | 2614 } |
| 2588 | 2615 |
| 2589 TEST_F(LayerTreeHostImplTest, ScrollChildBeyondLimit) { | 2616 TEST_F(LayerTreeHostImplTest, ScrollChildBeyondLimit) { |
| 2590 // Scroll a child layer beyond its maximum scroll range and make sure the | 2617 // Scroll a child layer beyond its maximum scroll range and make sure the |
| 2591 // parent layer is scrolled on the axis on which the child was unable to | 2618 // parent layer is scrolled on the axis on which the child was unable to |
| 2592 // scroll. | 2619 // scroll. |
| 2593 gfx::Size surface_size(10, 10); | 2620 gfx::Size surface_size(10, 10); |
| 2594 gfx::Size content_size(20, 20); | 2621 gfx::Size content_size(20, 20); |
| 2595 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 2622 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 2596 root->SetBounds(surface_size); | 2623 root->SetBounds(surface_size); |
| 2597 | 2624 root->CreateRenderSurface(); |
| 2598 scoped_ptr<LayerImpl> grand_child = | 2625 scoped_ptr<LayerImpl> grand_child = |
| 2599 CreateScrollableLayer(3, content_size, root.get()); | 2626 CreateScrollableLayer(3, content_size, root.get()); |
| 2600 | 2627 |
| 2601 scoped_ptr<LayerImpl> child = | 2628 scoped_ptr<LayerImpl> child = |
| 2602 CreateScrollableLayer(2, content_size, root.get()); | 2629 CreateScrollableLayer(2, content_size, root.get()); |
| 2603 LayerImpl* grand_child_layer = grand_child.get(); | 2630 LayerImpl* grand_child_layer = grand_child.get(); |
| 2604 child->AddChild(grand_child.Pass()); | 2631 child->AddChild(grand_child.Pass()); |
| 2605 | 2632 |
| 2606 LayerImpl* child_layer = child.get(); | 2633 LayerImpl* child_layer = child.get(); |
| 2607 root->AddChild(child.Pass()); | 2634 root->AddChild(child.Pass()); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2632 ExpectContains(*scroll_info.get(), child->id(), gfx::Vector2d(-3, 0)); | 2659 ExpectContains(*scroll_info.get(), child->id(), gfx::Vector2d(-3, 0)); |
| 2633 } | 2660 } |
| 2634 } | 2661 } |
| 2635 | 2662 |
| 2636 TEST_F(LayerTreeHostImplTest, ScrollWithoutBubbling) { | 2663 TEST_F(LayerTreeHostImplTest, ScrollWithoutBubbling) { |
| 2637 // Scroll a child layer beyond its maximum scroll range and make sure the | 2664 // Scroll a child layer beyond its maximum scroll range and make sure the |
| 2638 // the scroll doesn't bubble up to the parent layer. | 2665 // the scroll doesn't bubble up to the parent layer. |
| 2639 gfx::Size surface_size(20, 20); | 2666 gfx::Size surface_size(20, 20); |
| 2640 gfx::Size viewport_size(10, 10); | 2667 gfx::Size viewport_size(10, 10); |
| 2641 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 2668 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 2669 root->CreateRenderSurface(); |
| 2642 scoped_ptr<LayerImpl> root_scrolling = | 2670 scoped_ptr<LayerImpl> root_scrolling = |
| 2643 CreateScrollableLayer(2, surface_size, root.get()); | 2671 CreateScrollableLayer(2, surface_size, root.get()); |
| 2644 root_scrolling->SetIsContainerForFixedPositionLayers(true); | 2672 root_scrolling->SetIsContainerForFixedPositionLayers(true); |
| 2645 | 2673 |
| 2646 scoped_ptr<LayerImpl> grand_child = | 2674 scoped_ptr<LayerImpl> grand_child = |
| 2647 CreateScrollableLayer(4, surface_size, root.get()); | 2675 CreateScrollableLayer(4, surface_size, root.get()); |
| 2648 | 2676 |
| 2649 scoped_ptr<LayerImpl> child = | 2677 scoped_ptr<LayerImpl> child = |
| 2650 CreateScrollableLayer(3, surface_size, root.get()); | 2678 CreateScrollableLayer(3, surface_size, root.get()); |
| 2651 LayerImpl* grand_child_layer = grand_child.get(); | 2679 LayerImpl* grand_child_layer = grand_child.get(); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2740 ExpectContains(*scroll_info.get(), grand_child->id(), gfx::Vector2d(0, 4)); | 2768 ExpectContains(*scroll_info.get(), grand_child->id(), gfx::Vector2d(0, 4)); |
| 2741 } | 2769 } |
| 2742 } | 2770 } |
| 2743 TEST_F(LayerTreeHostImplTest, ScrollEventBubbling) { | 2771 TEST_F(LayerTreeHostImplTest, ScrollEventBubbling) { |
| 2744 // When we try to scroll a non-scrollable child layer, the scroll delta | 2772 // When we try to scroll a non-scrollable child layer, the scroll delta |
| 2745 // should be applied to one of its ancestors if possible. | 2773 // should be applied to one of its ancestors if possible. |
| 2746 gfx::Size surface_size(10, 10); | 2774 gfx::Size surface_size(10, 10); |
| 2747 gfx::Size content_size(20, 20); | 2775 gfx::Size content_size(20, 20); |
| 2748 scoped_ptr<LayerImpl> root_clip = | 2776 scoped_ptr<LayerImpl> root_clip = |
| 2749 LayerImpl::Create(host_impl_->active_tree(), 3); | 2777 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 2778 root_clip->CreateRenderSurface(); |
| 2750 scoped_ptr<LayerImpl> root = | 2779 scoped_ptr<LayerImpl> root = |
| 2751 CreateScrollableLayer(1, content_size, root_clip.get()); | 2780 CreateScrollableLayer(1, content_size, root_clip.get()); |
| 2752 // Make 'root' the clip layer for child: since they have the same sizes the | 2781 // Make 'root' the clip layer for child: since they have the same sizes the |
| 2753 // child will have zero max_scroll_offset and scrolls will bubble. | 2782 // child will have zero max_scroll_offset and scrolls will bubble. |
| 2754 scoped_ptr<LayerImpl> child = | 2783 scoped_ptr<LayerImpl> child = |
| 2755 CreateScrollableLayer(2, content_size, root.get()); | 2784 CreateScrollableLayer(2, content_size, root.get()); |
| 2756 child->SetIsContainerForFixedPositionLayers(true); | 2785 child->SetIsContainerForFixedPositionLayers(true); |
| 2757 root->SetBounds(content_size); | 2786 root->SetBounds(content_size); |
| 2758 | 2787 |
| 2759 int root_scroll_id = root->id(); | 2788 int root_scroll_id = root->id(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2782 } | 2811 } |
| 2783 } | 2812 } |
| 2784 | 2813 |
| 2785 TEST_F(LayerTreeHostImplTest, ScrollBeforeRedraw) { | 2814 TEST_F(LayerTreeHostImplTest, ScrollBeforeRedraw) { |
| 2786 gfx::Size surface_size(10, 10); | 2815 gfx::Size surface_size(10, 10); |
| 2787 scoped_ptr<LayerImpl> root_clip = | 2816 scoped_ptr<LayerImpl> root_clip = |
| 2788 LayerImpl::Create(host_impl_->active_tree(), 1); | 2817 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 2789 scoped_ptr<LayerImpl> root_scroll = | 2818 scoped_ptr<LayerImpl> root_scroll = |
| 2790 CreateScrollableLayer(2, surface_size, root_clip.get()); | 2819 CreateScrollableLayer(2, surface_size, root_clip.get()); |
| 2791 root_scroll->SetIsContainerForFixedPositionLayers(true); | 2820 root_scroll->SetIsContainerForFixedPositionLayers(true); |
| 2821 root_clip->CreateRenderSurface(); |
| 2792 root_clip->AddChild(root_scroll.Pass()); | 2822 root_clip->AddChild(root_scroll.Pass()); |
| 2793 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 2823 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); |
| 2794 host_impl_->active_tree()->SetViewportLayersFromIds(1, 2, Layer::INVALID_ID); | 2824 host_impl_->active_tree()->SetViewportLayersFromIds(1, 2, Layer::INVALID_ID); |
| 2795 host_impl_->active_tree()->DidBecomeActive(); | 2825 host_impl_->active_tree()->DidBecomeActive(); |
| 2796 host_impl_->SetViewportSize(surface_size); | 2826 host_impl_->SetViewportSize(surface_size); |
| 2797 | 2827 |
| 2798 // Draw one frame and then immediately rebuild the layer tree to mimic a tree | 2828 // Draw one frame and then immediately rebuild the layer tree to mimic a tree |
| 2799 // synchronization. | 2829 // synchronization. |
| 2800 DrawFrame(); | 2830 DrawFrame(); |
| 2801 host_impl_->active_tree()->DetachLayerTree(); | 2831 host_impl_->active_tree()->DetachLayerTree(); |
| 2802 scoped_ptr<LayerImpl> root_clip2 = | 2832 scoped_ptr<LayerImpl> root_clip2 = |
| 2803 LayerImpl::Create(host_impl_->active_tree(), 3); | 2833 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 2804 scoped_ptr<LayerImpl> root_scroll2 = | 2834 scoped_ptr<LayerImpl> root_scroll2 = |
| 2805 CreateScrollableLayer(4, surface_size, root_clip2.get()); | 2835 CreateScrollableLayer(4, surface_size, root_clip2.get()); |
| 2806 root_scroll2->SetIsContainerForFixedPositionLayers(true); | 2836 root_scroll2->SetIsContainerForFixedPositionLayers(true); |
| 2807 root_clip2->AddChild(root_scroll2.Pass()); | 2837 root_clip2->AddChild(root_scroll2.Pass()); |
| 2838 root_clip2->CreateRenderSurface(); |
| 2808 host_impl_->active_tree()->SetRootLayer(root_clip2.Pass()); | 2839 host_impl_->active_tree()->SetRootLayer(root_clip2.Pass()); |
| 2809 host_impl_->active_tree()->SetViewportLayersFromIds(3, 4, Layer::INVALID_ID); | 2840 host_impl_->active_tree()->SetViewportLayersFromIds(3, 4, Layer::INVALID_ID); |
| 2810 host_impl_->active_tree()->DidBecomeActive(); | 2841 host_impl_->active_tree()->DidBecomeActive(); |
| 2811 | 2842 |
| 2812 // Scrolling should still work even though we did not draw yet. | 2843 // Scrolling should still work even though we did not draw yet. |
| 2813 EXPECT_EQ(InputHandler::ScrollStarted, | 2844 EXPECT_EQ(InputHandler::ScrollStarted, |
| 2814 host_impl_->ScrollBegin(gfx::Point(5, 5), | 2845 host_impl_->ScrollBegin(gfx::Point(5, 5), |
| 2815 InputHandler::Wheel)); | 2846 InputHandler::Wheel)); |
| 2816 } | 2847 } |
| 2817 | 2848 |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3239 host_impl_->ScrollEnd(); | 3270 host_impl_->ScrollEnd(); |
| 3240 } | 3271 } |
| 3241 | 3272 |
| 3242 | 3273 |
| 3243 TEST_F(LayerTreeHostImplTest, OverscrollChildWithoutBubbling) { | 3274 TEST_F(LayerTreeHostImplTest, OverscrollChildWithoutBubbling) { |
| 3244 // Scroll child layers beyond their maximum scroll range and make sure root | 3275 // Scroll child layers beyond their maximum scroll range and make sure root |
| 3245 // overscroll does not accumulate. | 3276 // overscroll does not accumulate. |
| 3246 gfx::Size surface_size(10, 10); | 3277 gfx::Size surface_size(10, 10); |
| 3247 scoped_ptr<LayerImpl> root_clip = | 3278 scoped_ptr<LayerImpl> root_clip = |
| 3248 LayerImpl::Create(host_impl_->active_tree(), 4); | 3279 LayerImpl::Create(host_impl_->active_tree(), 4); |
| 3280 root_clip->CreateRenderSurface(); |
| 3281 |
| 3249 scoped_ptr<LayerImpl> root = | 3282 scoped_ptr<LayerImpl> root = |
| 3250 CreateScrollableLayer(1, surface_size, root_clip.get()); | 3283 CreateScrollableLayer(1, surface_size, root_clip.get()); |
| 3251 | 3284 |
| 3252 scoped_ptr<LayerImpl> grand_child = | 3285 scoped_ptr<LayerImpl> grand_child = |
| 3253 CreateScrollableLayer(3, surface_size, root_clip.get()); | 3286 CreateScrollableLayer(3, surface_size, root_clip.get()); |
| 3254 | 3287 |
| 3255 scoped_ptr<LayerImpl> child = | 3288 scoped_ptr<LayerImpl> child = |
| 3256 CreateScrollableLayer(2, surface_size, root_clip.get()); | 3289 CreateScrollableLayer(2, surface_size, root_clip.get()); |
| 3257 LayerImpl* grand_child_layer = grand_child.get(); | 3290 LayerImpl* grand_child_layer = grand_child.get(); |
| 3258 child->AddChild(grand_child.Pass()); | 3291 child->AddChild(grand_child.Pass()); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3303 } | 3336 } |
| 3304 | 3337 |
| 3305 TEST_F(LayerTreeHostImplTest, OverscrollChildEventBubbling) { | 3338 TEST_F(LayerTreeHostImplTest, OverscrollChildEventBubbling) { |
| 3306 // When we try to scroll a non-scrollable child layer, the scroll delta | 3339 // When we try to scroll a non-scrollable child layer, the scroll delta |
| 3307 // should be applied to one of its ancestors if possible. Overscroll should | 3340 // should be applied to one of its ancestors if possible. Overscroll should |
| 3308 // be reflected only when it has bubbled up to the root scrolling layer. | 3341 // be reflected only when it has bubbled up to the root scrolling layer. |
| 3309 gfx::Size surface_size(10, 10); | 3342 gfx::Size surface_size(10, 10); |
| 3310 gfx::Size content_size(20, 20); | 3343 gfx::Size content_size(20, 20); |
| 3311 scoped_ptr<LayerImpl> root_clip = | 3344 scoped_ptr<LayerImpl> root_clip = |
| 3312 LayerImpl::Create(host_impl_->active_tree(), 3); | 3345 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 3346 root_clip->CreateRenderSurface(); |
| 3347 |
| 3313 scoped_ptr<LayerImpl> root = | 3348 scoped_ptr<LayerImpl> root = |
| 3314 CreateScrollableLayer(1, content_size, root_clip.get()); | 3349 CreateScrollableLayer(1, content_size, root_clip.get()); |
| 3315 root->SetIsContainerForFixedPositionLayers(true); | 3350 root->SetIsContainerForFixedPositionLayers(true); |
| 3316 scoped_ptr<LayerImpl> child = | 3351 scoped_ptr<LayerImpl> child = |
| 3317 CreateScrollableLayer(2, content_size, root_clip.get()); | 3352 CreateScrollableLayer(2, content_size, root_clip.get()); |
| 3318 | 3353 |
| 3319 child->SetScrollClipLayer(Layer::INVALID_ID); | 3354 child->SetScrollClipLayer(Layer::INVALID_ID); |
| 3320 root->AddChild(child.Pass()); | 3355 root->AddChild(child.Pass()); |
| 3321 root_clip->AddChild(root.Pass()); | 3356 root_clip->AddChild(root.Pass()); |
| 3322 | 3357 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3358 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 3393 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
| 3359 EXPECT_EQ(gfx::Vector2dF(0, 10), host_impl_->accumulated_root_overscroll()); | 3394 EXPECT_EQ(gfx::Vector2dF(0, 10), host_impl_->accumulated_root_overscroll()); |
| 3360 } | 3395 } |
| 3361 | 3396 |
| 3362 TEST_F(LayerTreeHostImplTest, NoOverscrollOnFractionalDeviceScale) { | 3397 TEST_F(LayerTreeHostImplTest, NoOverscrollOnFractionalDeviceScale) { |
| 3363 gfx::Size surface_size(980, 1439); | 3398 gfx::Size surface_size(980, 1439); |
| 3364 gfx::Size content_size(980, 1438); | 3399 gfx::Size content_size(980, 1438); |
| 3365 float device_scale_factor = 1.5f; | 3400 float device_scale_factor = 1.5f; |
| 3366 scoped_ptr<LayerImpl> root_clip = | 3401 scoped_ptr<LayerImpl> root_clip = |
| 3367 LayerImpl::Create(host_impl_->active_tree(), 3); | 3402 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 3403 root_clip->CreateRenderSurface(); |
| 3404 |
| 3368 scoped_ptr<LayerImpl> root = | 3405 scoped_ptr<LayerImpl> root = |
| 3369 CreateScrollableLayer(1, content_size, root_clip.get()); | 3406 CreateScrollableLayer(1, content_size, root_clip.get()); |
| 3370 root->SetIsContainerForFixedPositionLayers(true); | 3407 root->SetIsContainerForFixedPositionLayers(true); |
| 3371 scoped_ptr<LayerImpl> child = | 3408 scoped_ptr<LayerImpl> child = |
| 3372 CreateScrollableLayer(2, content_size, root_clip.get()); | 3409 CreateScrollableLayer(2, content_size, root_clip.get()); |
| 3373 root->scroll_clip_layer()->SetBounds(gfx::Size(320, 469)); | 3410 root->scroll_clip_layer()->SetBounds(gfx::Size(320, 469)); |
| 3374 host_impl_->active_tree()->SetPageScaleFactorAndLimits( | 3411 host_impl_->active_tree()->SetPageScaleFactorAndLimits( |
| 3375 0.326531f, 0.326531f, 5.f); | 3412 0.326531f, 0.326531f, 5.f); |
| 3376 host_impl_->active_tree()->SetPageScaleDelta(1.f); | 3413 host_impl_->active_tree()->SetPageScaleDelta(1.f); |
| 3377 child->SetScrollClipLayer(Layer::INVALID_ID); | 3414 child->SetScrollClipLayer(Layer::INVALID_ID); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 3396 | 3433 |
| 3397 host_impl_->ScrollEnd(); | 3434 host_impl_->ScrollEnd(); |
| 3398 } | 3435 } |
| 3399 } | 3436 } |
| 3400 | 3437 |
| 3401 TEST_F(LayerTreeHostImplTest, NoOverscrollWhenNotAtEdge) { | 3438 TEST_F(LayerTreeHostImplTest, NoOverscrollWhenNotAtEdge) { |
| 3402 gfx::Size surface_size(100, 100); | 3439 gfx::Size surface_size(100, 100); |
| 3403 gfx::Size content_size(200, 200); | 3440 gfx::Size content_size(200, 200); |
| 3404 scoped_ptr<LayerImpl> root_clip = | 3441 scoped_ptr<LayerImpl> root_clip = |
| 3405 LayerImpl::Create(host_impl_->active_tree(), 3); | 3442 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 3443 root_clip->CreateRenderSurface(); |
| 3444 |
| 3406 scoped_ptr<LayerImpl> root = | 3445 scoped_ptr<LayerImpl> root = |
| 3407 CreateScrollableLayer(1, content_size, root_clip.get()); | 3446 CreateScrollableLayer(1, content_size, root_clip.get()); |
| 3408 root->SetIsContainerForFixedPositionLayers(true); | 3447 root->SetIsContainerForFixedPositionLayers(true); |
| 3409 scoped_ptr<LayerImpl> child = | 3448 scoped_ptr<LayerImpl> child = |
| 3410 CreateScrollableLayer(2, content_size, root_clip.get()); | 3449 CreateScrollableLayer(2, content_size, root_clip.get()); |
| 3411 | 3450 |
| 3412 child->SetScrollClipLayer(Layer::INVALID_ID); | 3451 child->SetScrollClipLayer(Layer::INVALID_ID); |
| 3413 root->AddChild(child.Pass()); | 3452 root->AddChild(child.Pass()); |
| 3414 root_clip->AddChild(root.Pass()); | 3453 root_clip->AddChild(root.Pass()); |
| 3415 | 3454 |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3541 ResourceProvider::ResourceId resource_id_; | 3580 ResourceProvider::ResourceId resource_id_; |
| 3542 }; | 3581 }; |
| 3543 | 3582 |
| 3544 TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { | 3583 TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { |
| 3545 { | 3584 { |
| 3546 scoped_ptr<LayerImpl> root = | 3585 scoped_ptr<LayerImpl> root = |
| 3547 LayerImpl::Create(host_impl_->active_tree(), 1); | 3586 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 3548 root->SetBounds(gfx::Size(10, 10)); | 3587 root->SetBounds(gfx::Size(10, 10)); |
| 3549 root->SetContentBounds(root->bounds()); | 3588 root->SetContentBounds(root->bounds()); |
| 3550 root->SetDrawsContent(false); | 3589 root->SetDrawsContent(false); |
| 3590 root->CreateRenderSurface(); |
| 3551 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 3591 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 3552 } | 3592 } |
| 3553 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 3593 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 3554 | 3594 |
| 3555 root->AddChild( | 3595 root->AddChild( |
| 3556 BlendStateCheckLayer::Create(host_impl_->active_tree(), | 3596 BlendStateCheckLayer::Create(host_impl_->active_tree(), |
| 3557 2, | 3597 2, |
| 3558 host_impl_->resource_provider())); | 3598 host_impl_->resource_provider())); |
| 3559 BlendStateCheckLayer* layer1 = | 3599 BlendStateCheckLayer* layer1 = |
| 3560 static_cast<BlendStateCheckLayer*>(root->children()[0]); | 3600 static_cast<BlendStateCheckLayer*>(root->children()[0]); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3650 EXPECT_TRUE(layer2->quads_appended()); | 3690 EXPECT_TRUE(layer2->quads_appended()); |
| 3651 host_impl_->DidDrawAllLayers(frame); | 3691 host_impl_->DidDrawAllLayers(frame); |
| 3652 | 3692 |
| 3653 // Parent layer with translucent opacity and opaque content. Since it has a | 3693 // Parent layer with translucent opacity and opaque content. Since it has a |
| 3654 // drawing child, it's drawn to a render surface which carries the opacity, | 3694 // drawing child, it's drawn to a render surface which carries the opacity, |
| 3655 // so it's itself drawn without blending. | 3695 // so it's itself drawn without blending. |
| 3656 // Child layer with opaque content, drawn without blending (parent surface | 3696 // Child layer with opaque content, drawn without blending (parent surface |
| 3657 // carries the inherited opacity). | 3697 // carries the inherited opacity). |
| 3658 layer1->SetContentsOpaque(true); | 3698 layer1->SetContentsOpaque(true); |
| 3659 layer1->SetOpacity(0.5f); | 3699 layer1->SetOpacity(0.5f); |
| 3700 layer1->CreateRenderSurface(); |
| 3660 layer1->SetExpectation(false, true); | 3701 layer1->SetExpectation(false, true); |
| 3661 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 3702 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 3662 layer2->SetExpectation(false, false); | 3703 layer2->SetExpectation(false, false); |
| 3663 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 3704 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 3664 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( | 3705 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( |
| 3665 host_impl_->active_tree()->root_layer()); | 3706 host_impl_->active_tree()->root_layer()); |
| 3666 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 3707 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 3667 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 3708 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 3668 EXPECT_TRUE(layer1->quads_appended()); | 3709 EXPECT_TRUE(layer1->quads_appended()); |
| 3669 EXPECT_TRUE(layer2->quads_appended()); | 3710 EXPECT_TRUE(layer2->quads_appended()); |
| 3670 host_impl_->DidDrawAllLayers(frame); | 3711 host_impl_->DidDrawAllLayers(frame); |
| 3712 layer1->ClearRenderSurface(); |
| 3671 | 3713 |
| 3672 // Draw again, but with child non-opaque, to make sure | 3714 // Draw again, but with child non-opaque, to make sure |
| 3673 // layer1 not culled. | 3715 // layer1 not culled. |
| 3674 layer1->SetContentsOpaque(true); | 3716 layer1->SetContentsOpaque(true); |
| 3675 layer1->SetOpacity(1.f); | 3717 layer1->SetOpacity(1.f); |
| 3676 layer1->SetExpectation(false, false); | 3718 layer1->SetExpectation(false, false); |
| 3677 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 3719 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 3678 layer2->SetContentsOpaque(true); | 3720 layer2->SetContentsOpaque(true); |
| 3679 layer2->SetOpacity(0.5f); | 3721 layer2->SetOpacity(0.5f); |
| 3680 layer2->SetExpectation(true, false); | 3722 layer2->SetExpectation(true, false); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3778 return FakeOutputSurface::CreateAlwaysDrawAndSwap3d() | 3820 return FakeOutputSurface::CreateAlwaysDrawAndSwap3d() |
| 3779 .PassAs<OutputSurface>(); | 3821 .PassAs<OutputSurface>(); |
| 3780 } | 3822 } |
| 3781 return FakeOutputSurface::Create3d().PassAs<OutputSurface>(); | 3823 return FakeOutputSurface::Create3d().PassAs<OutputSurface>(); |
| 3782 } | 3824 } |
| 3783 | 3825 |
| 3784 void SetupActiveTreeLayers() { | 3826 void SetupActiveTreeLayers() { |
| 3785 host_impl_->active_tree()->set_background_color(SK_ColorGRAY); | 3827 host_impl_->active_tree()->set_background_color(SK_ColorGRAY); |
| 3786 host_impl_->active_tree()->SetRootLayer( | 3828 host_impl_->active_tree()->SetRootLayer( |
| 3787 LayerImpl::Create(host_impl_->active_tree(), 1)); | 3829 LayerImpl::Create(host_impl_->active_tree(), 1)); |
| 3830 host_impl_->active_tree()->root_layer()->CreateRenderSurface(); |
| 3788 host_impl_->active_tree()->root_layer()->AddChild( | 3831 host_impl_->active_tree()->root_layer()->AddChild( |
| 3789 BlendStateCheckLayer::Create(host_impl_->active_tree(), | 3832 BlendStateCheckLayer::Create(host_impl_->active_tree(), |
| 3790 2, | 3833 2, |
| 3791 host_impl_->resource_provider())); | 3834 host_impl_->resource_provider())); |
| 3792 child_ = static_cast<BlendStateCheckLayer*>( | 3835 child_ = static_cast<BlendStateCheckLayer*>( |
| 3793 host_impl_->active_tree()->root_layer()->children()[0]); | 3836 host_impl_->active_tree()->root_layer()->children()[0]); |
| 3794 child_->SetExpectation(false, false); | 3837 child_->SetExpectation(false, false); |
| 3795 child_->SetContentsOpaque(true); | 3838 child_->SetContentsOpaque(true); |
| 3796 } | 3839 } |
| 3797 | 3840 |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4069 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); | 4112 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); |
| 4070 scoped_ptr<OutputSurface> output_surface( | 4113 scoped_ptr<OutputSurface> output_surface( |
| 4071 FakeOutputSurface::Create3d(provider)); | 4114 FakeOutputSurface::Create3d(provider)); |
| 4072 CreateHostImpl(DefaultSettings(), output_surface.Pass()); | 4115 CreateHostImpl(DefaultSettings(), output_surface.Pass()); |
| 4073 | 4116 |
| 4074 scoped_ptr<LayerImpl> root = | 4117 scoped_ptr<LayerImpl> root = |
| 4075 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); | 4118 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); |
| 4076 root->SetBounds(gfx::Size(10, 10)); | 4119 root->SetBounds(gfx::Size(10, 10)); |
| 4077 root->SetContentBounds(gfx::Size(10, 10)); | 4120 root->SetContentBounds(gfx::Size(10, 10)); |
| 4078 root->SetDrawsContent(true); | 4121 root->SetDrawsContent(true); |
| 4122 root->CreateRenderSurface(); |
| 4079 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 4123 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 4080 EXPECT_FALSE(provider->TestContext3d()->reshape_called()); | 4124 EXPECT_FALSE(provider->TestContext3d()->reshape_called()); |
| 4081 provider->TestContext3d()->clear_reshape_called(); | 4125 provider->TestContext3d()->clear_reshape_called(); |
| 4082 | 4126 |
| 4083 LayerTreeHostImpl::FrameData frame; | 4127 LayerTreeHostImpl::FrameData frame; |
| 4084 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 4128 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
| 4085 host_impl_->SetDeviceScaleFactor(1.f); | 4129 host_impl_->SetDeviceScaleFactor(1.f); |
| 4086 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4130 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 4087 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 4131 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 4088 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); | 4132 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4135 this, | 4179 this, |
| 4136 &proxy_, | 4180 &proxy_, |
| 4137 &stats_instrumentation_, | 4181 &stats_instrumentation_, |
| 4138 shared_bitmap_manager.get(), | 4182 shared_bitmap_manager.get(), |
| 4139 0); | 4183 0); |
| 4140 layer_tree_host_impl->InitializeRenderer(output_surface.Pass()); | 4184 layer_tree_host_impl->InitializeRenderer(output_surface.Pass()); |
| 4141 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); | 4185 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); |
| 4142 | 4186 |
| 4143 scoped_ptr<LayerImpl> root = | 4187 scoped_ptr<LayerImpl> root = |
| 4144 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); | 4188 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); |
| 4189 root->CreateRenderSurface(); |
| 4145 scoped_ptr<LayerImpl> child = | 4190 scoped_ptr<LayerImpl> child = |
| 4146 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); | 4191 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); |
| 4147 child->SetPosition(gfx::PointF(12.f, 13.f)); | 4192 child->SetPosition(gfx::PointF(12.f, 13.f)); |
| 4148 child->SetBounds(gfx::Size(14, 15)); | 4193 child->SetBounds(gfx::Size(14, 15)); |
| 4149 child->SetContentBounds(gfx::Size(14, 15)); | 4194 child->SetContentBounds(gfx::Size(14, 15)); |
| 4150 child->SetDrawsContent(true); | 4195 child->SetDrawsContent(true); |
| 4151 root->SetBounds(gfx::Size(500, 500)); | 4196 root->SetBounds(gfx::Size(500, 500)); |
| 4152 root->SetContentBounds(gfx::Size(500, 500)); | 4197 root->SetContentBounds(gfx::Size(500, 500)); |
| 4153 root->SetDrawsContent(true); | 4198 root->SetDrawsContent(true); |
| 4154 root->AddChild(child.Pass()); | 4199 root->AddChild(child.Pass()); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4202 scoped_ptr<LayerImpl> root = | 4247 scoped_ptr<LayerImpl> root = |
| 4203 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); | 4248 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); |
| 4204 scoped_ptr<LayerImpl> child = | 4249 scoped_ptr<LayerImpl> child = |
| 4205 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2); | 4250 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2); |
| 4206 child->SetBounds(gfx::Size(10, 10)); | 4251 child->SetBounds(gfx::Size(10, 10)); |
| 4207 child->SetContentBounds(gfx::Size(10, 10)); | 4252 child->SetContentBounds(gfx::Size(10, 10)); |
| 4208 child->SetDrawsContent(true); | 4253 child->SetDrawsContent(true); |
| 4209 root->SetBounds(gfx::Size(10, 10)); | 4254 root->SetBounds(gfx::Size(10, 10)); |
| 4210 root->SetContentBounds(gfx::Size(10, 10)); | 4255 root->SetContentBounds(gfx::Size(10, 10)); |
| 4211 root->SetDrawsContent(true); | 4256 root->SetDrawsContent(true); |
| 4212 root->SetForceRenderSurface(true); | 4257 root->CreateRenderSurface(); |
| 4213 root->AddChild(child.Pass()); | 4258 root->AddChild(child.Pass()); |
| 4214 | 4259 |
| 4215 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 4260 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 4216 | 4261 |
| 4217 LayerTreeHostImpl::FrameData frame; | 4262 LayerTreeHostImpl::FrameData frame; |
| 4218 | 4263 |
| 4219 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4264 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 4220 EXPECT_EQ(1u, frame.render_surface_layer_list->size()); | 4265 EXPECT_EQ(1u, frame.render_surface_layer_list->size()); |
| 4221 EXPECT_EQ(1u, frame.render_passes.size()); | 4266 EXPECT_EQ(1u, frame.render_passes.size()); |
| 4222 host_impl_->DidDrawAllLayers(frame); | 4267 host_impl_->DidDrawAllLayers(frame); |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4469 root->draw_properties().visible_content_rect = root_rect; | 4514 root->draw_properties().visible_content_rect = root_rect; |
| 4470 root->SetDrawsContent(false); | 4515 root->SetDrawsContent(false); |
| 4471 root->render_surface()->SetContentRect(gfx::Rect(root_rect.size())); | 4516 root->render_surface()->SetContentRect(gfx::Rect(root_rect.size())); |
| 4472 | 4517 |
| 4473 child->SetPosition(gfx::PointF(child_rect.x(), child_rect.y())); | 4518 child->SetPosition(gfx::PointF(child_rect.x(), child_rect.y())); |
| 4474 child->SetOpacity(0.5f); | 4519 child->SetOpacity(0.5f); |
| 4475 child->SetBounds(gfx::Size(child_rect.width(), child_rect.height())); | 4520 child->SetBounds(gfx::Size(child_rect.width(), child_rect.height())); |
| 4476 child->SetContentBounds(child->bounds()); | 4521 child->SetContentBounds(child->bounds()); |
| 4477 child->draw_properties().visible_content_rect = child_rect; | 4522 child->draw_properties().visible_content_rect = child_rect; |
| 4478 child->SetDrawsContent(false); | 4523 child->SetDrawsContent(false); |
| 4479 child->SetForceRenderSurface(true); | 4524 child->CreateRenderSurface(); |
| 4480 | 4525 |
| 4481 grand_child->SetPosition(grand_child_rect.origin()); | 4526 grand_child->SetPosition(grand_child_rect.origin()); |
| 4482 grand_child->SetBounds(grand_child_rect.size()); | 4527 grand_child->SetBounds(grand_child_rect.size()); |
| 4483 grand_child->SetContentBounds(grand_child->bounds()); | 4528 grand_child->SetContentBounds(grand_child->bounds()); |
| 4484 grand_child->draw_properties().visible_content_rect = grand_child_rect; | 4529 grand_child->draw_properties().visible_content_rect = grand_child_rect; |
| 4485 grand_child->SetDrawsContent(true); | 4530 grand_child->SetDrawsContent(true); |
| 4486 | 4531 |
| 4487 child->AddChild(grand_child.Pass()); | 4532 child->AddChild(grand_child.Pass()); |
| 4488 root->AddChild(child.Pass()); | 4533 root->AddChild(child.Pass()); |
| 4489 | 4534 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4549 scoped_ptr<TestWebGraphicsContext3D> context = | 4594 scoped_ptr<TestWebGraphicsContext3D> context = |
| 4550 TestWebGraphicsContext3D::Create(); | 4595 TestWebGraphicsContext3D::Create(); |
| 4551 TestWebGraphicsContext3D* context3d = context.get(); | 4596 TestWebGraphicsContext3D* context3d = context.get(); |
| 4552 scoped_ptr<OutputSurface> output_surface( | 4597 scoped_ptr<OutputSurface> output_surface( |
| 4553 FakeOutputSurface::Create3d(context.Pass())); | 4598 FakeOutputSurface::Create3d(context.Pass())); |
| 4554 CreateHostImpl(DefaultSettings(), output_surface.Pass()); | 4599 CreateHostImpl(DefaultSettings(), output_surface.Pass()); |
| 4555 | 4600 |
| 4556 scoped_ptr<LayerImpl> root_layer = | 4601 scoped_ptr<LayerImpl> root_layer = |
| 4557 LayerImpl::Create(host_impl_->active_tree(), 1); | 4602 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 4558 root_layer->SetBounds(gfx::Size(10, 10)); | 4603 root_layer->SetBounds(gfx::Size(10, 10)); |
| 4604 root_layer->CreateRenderSurface(); |
| 4559 | 4605 |
| 4560 scoped_refptr<VideoFrame> softwareFrame = | 4606 scoped_refptr<VideoFrame> softwareFrame = |
| 4561 media::VideoFrame::CreateColorFrame( | 4607 media::VideoFrame::CreateColorFrame( |
| 4562 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); | 4608 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); |
| 4563 FakeVideoFrameProvider provider; | 4609 FakeVideoFrameProvider provider; |
| 4564 provider.set_frame(softwareFrame); | 4610 provider.set_frame(softwareFrame); |
| 4565 scoped_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( | 4611 scoped_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( |
| 4566 host_impl_->active_tree(), 4, &provider, media::VIDEO_ROTATION_0); | 4612 host_impl_->active_tree(), 4, &provider, media::VIDEO_ROTATION_0); |
| 4567 video_layer->SetBounds(gfx::Size(10, 10)); | 4613 video_layer->SetBounds(gfx::Size(10, 10)); |
| 4568 video_layer->SetContentBounds(gfx::Size(10, 10)); | 4614 video_layer->SetContentBounds(gfx::Size(10, 10)); |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4725 } | 4771 } |
| 4726 }; | 4772 }; |
| 4727 | 4773 |
| 4728 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) { | 4774 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) { |
| 4729 scoped_ptr<SolidColorLayerImpl> root = | 4775 scoped_ptr<SolidColorLayerImpl> root = |
| 4730 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 4776 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
| 4731 root->SetPosition(gfx::PointF()); | 4777 root->SetPosition(gfx::PointF()); |
| 4732 root->SetBounds(gfx::Size(10, 10)); | 4778 root->SetBounds(gfx::Size(10, 10)); |
| 4733 root->SetContentBounds(gfx::Size(10, 10)); | 4779 root->SetContentBounds(gfx::Size(10, 10)); |
| 4734 root->SetDrawsContent(true); | 4780 root->SetDrawsContent(true); |
| 4781 root->CreateRenderSurface(); |
| 4735 | 4782 |
| 4736 // Child layer is in the bottom right corner. | 4783 // Child layer is in the bottom right corner. |
| 4737 scoped_ptr<SolidColorLayerImpl> child = | 4784 scoped_ptr<SolidColorLayerImpl> child = |
| 4738 SolidColorLayerImpl::Create(host_impl_->active_tree(), 2); | 4785 SolidColorLayerImpl::Create(host_impl_->active_tree(), 2); |
| 4739 child->SetPosition(gfx::PointF(9.f, 9.f)); | 4786 child->SetPosition(gfx::PointF(9.f, 9.f)); |
| 4740 child->SetBounds(gfx::Size(1, 1)); | 4787 child->SetBounds(gfx::Size(1, 1)); |
| 4741 child->SetContentBounds(gfx::Size(1, 1)); | 4788 child->SetContentBounds(gfx::Size(1, 1)); |
| 4742 child->SetDrawsContent(true); | 4789 child->SetDrawsContent(true); |
| 4743 root->AddChild(child.PassAs<LayerImpl>()); | 4790 root->AddChild(child.PassAs<LayerImpl>()); |
| 4744 | 4791 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4790 | 4837 |
| 4791 // Root | 4838 // Root |
| 4792 // | | 4839 // | |
| 4793 // +-- Scaling Layer (adds a 2x scale) | 4840 // +-- Scaling Layer (adds a 2x scale) |
| 4794 // | | 4841 // | |
| 4795 // +-- Content Layer | 4842 // +-- Content Layer |
| 4796 // +--Mask | 4843 // +--Mask |
| 4797 scoped_ptr<LayerImpl> scoped_root = | 4844 scoped_ptr<LayerImpl> scoped_root = |
| 4798 LayerImpl::Create(host_impl_->active_tree(), 1); | 4845 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 4799 LayerImpl* root = scoped_root.get(); | 4846 LayerImpl* root = scoped_root.get(); |
| 4847 root->CreateRenderSurface(); |
| 4800 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); | 4848 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); |
| 4801 | 4849 |
| 4802 scoped_ptr<LayerImpl> scoped_scaling_layer = | 4850 scoped_ptr<LayerImpl> scoped_scaling_layer = |
| 4803 LayerImpl::Create(host_impl_->active_tree(), 2); | 4851 LayerImpl::Create(host_impl_->active_tree(), 2); |
| 4804 LayerImpl* scaling_layer = scoped_scaling_layer.get(); | 4852 LayerImpl* scaling_layer = scoped_scaling_layer.get(); |
| 4805 root->AddChild(scoped_scaling_layer.Pass()); | 4853 root->AddChild(scoped_scaling_layer.Pass()); |
| 4806 | 4854 |
| 4807 scoped_ptr<LayerImpl> scoped_content_layer = | 4855 scoped_ptr<LayerImpl> scoped_content_layer = |
| 4808 LayerImpl::Create(host_impl_->active_tree(), 3); | 4856 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 4809 LayerImpl* content_layer = scoped_content_layer.get(); | 4857 LayerImpl* content_layer = scoped_content_layer.get(); |
| 4810 scaling_layer->AddChild(scoped_content_layer.Pass()); | 4858 scaling_layer->AddChild(scoped_content_layer.Pass()); |
| 4811 | 4859 |
| 4812 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = | 4860 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = |
| 4813 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); | 4861 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); |
| 4814 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); | 4862 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); |
| 4815 content_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>()); | 4863 content_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>()); |
| 4864 content_layer->CreateRenderSurface(); |
| 4816 | 4865 |
| 4817 gfx::Size root_size(100, 100); | 4866 gfx::Size root_size(100, 100); |
| 4818 root->SetBounds(root_size); | 4867 root->SetBounds(root_size); |
| 4819 root->SetContentBounds(root_size); | 4868 root->SetContentBounds(root_size); |
| 4820 root->SetPosition(gfx::PointF()); | 4869 root->SetPosition(gfx::PointF()); |
| 4821 | 4870 |
| 4822 gfx::Size scaling_layer_size(50, 50); | 4871 gfx::Size scaling_layer_size(50, 50); |
| 4823 scaling_layer->SetBounds(scaling_layer_size); | 4872 scaling_layer->SetBounds(scaling_layer_size); |
| 4824 scaling_layer->SetContentBounds(scaling_layer_size); | 4873 scaling_layer->SetContentBounds(scaling_layer_size); |
| 4825 scaling_layer->SetPosition(gfx::PointF()); | 4874 scaling_layer->SetPosition(gfx::PointF()); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4921 } | 4970 } |
| 4922 } | 4971 } |
| 4923 | 4972 |
| 4924 TEST_F(LayerTreeHostImplTest, MaskLayerWithDifferentBounds) { | 4973 TEST_F(LayerTreeHostImplTest, MaskLayerWithDifferentBounds) { |
| 4925 // The mask layer has bounds 100x100 but is attached to a layer with bounds | 4974 // The mask layer has bounds 100x100 but is attached to a layer with bounds |
| 4926 // 50x50. | 4975 // 50x50. |
| 4927 | 4976 |
| 4928 scoped_ptr<LayerImpl> scoped_root = | 4977 scoped_ptr<LayerImpl> scoped_root = |
| 4929 LayerImpl::Create(host_impl_->active_tree(), 1); | 4978 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 4930 LayerImpl* root = scoped_root.get(); | 4979 LayerImpl* root = scoped_root.get(); |
| 4980 root->CreateRenderSurface(); |
| 4981 |
| 4931 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); | 4982 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); |
| 4932 | 4983 |
| 4933 scoped_ptr<LayerImpl> scoped_content_layer = | 4984 scoped_ptr<LayerImpl> scoped_content_layer = |
| 4934 LayerImpl::Create(host_impl_->active_tree(), 3); | 4985 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 4935 LayerImpl* content_layer = scoped_content_layer.get(); | 4986 LayerImpl* content_layer = scoped_content_layer.get(); |
| 4936 root->AddChild(scoped_content_layer.Pass()); | 4987 root->AddChild(scoped_content_layer.Pass()); |
| 4937 | 4988 |
| 4938 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = | 4989 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = |
| 4939 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); | 4990 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); |
| 4940 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); | 4991 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); |
| 4941 content_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>()); | 4992 content_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>()); |
| 4993 content_layer->CreateRenderSurface(); |
| 4942 | 4994 |
| 4943 gfx::Size root_size(100, 100); | 4995 gfx::Size root_size(100, 100); |
| 4944 root->SetBounds(root_size); | 4996 root->SetBounds(root_size); |
| 4945 root->SetContentBounds(root_size); | 4997 root->SetContentBounds(root_size); |
| 4946 root->SetPosition(gfx::PointF()); | 4998 root->SetPosition(gfx::PointF()); |
| 4947 | 4999 |
| 4948 gfx::Size layer_size(50, 50); | 5000 gfx::Size layer_size(50, 50); |
| 4949 content_layer->SetBounds(layer_size); | 5001 content_layer->SetBounds(layer_size); |
| 4950 content_layer->SetContentBounds(layer_size); | 5002 content_layer->SetContentBounds(layer_size); |
| 4951 content_layer->SetPosition(gfx::PointF()); | 5003 content_layer->SetPosition(gfx::PointF()); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5063 } | 5115 } |
| 5064 } | 5116 } |
| 5065 | 5117 |
| 5066 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerWithDifferentBounds) { | 5118 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerWithDifferentBounds) { |
| 5067 // The replica's mask layer has bounds 100x100 but the replica is of a | 5119 // The replica's mask layer has bounds 100x100 but the replica is of a |
| 5068 // layer with bounds 50x50. | 5120 // layer with bounds 50x50. |
| 5069 | 5121 |
| 5070 scoped_ptr<LayerImpl> scoped_root = | 5122 scoped_ptr<LayerImpl> scoped_root = |
| 5071 LayerImpl::Create(host_impl_->active_tree(), 1); | 5123 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 5072 LayerImpl* root = scoped_root.get(); | 5124 LayerImpl* root = scoped_root.get(); |
| 5125 root->CreateRenderSurface(); |
| 5126 |
| 5073 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); | 5127 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); |
| 5074 | 5128 |
| 5075 scoped_ptr<LayerImpl> scoped_content_layer = | 5129 scoped_ptr<LayerImpl> scoped_content_layer = |
| 5076 LayerImpl::Create(host_impl_->active_tree(), 3); | 5130 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 5077 LayerImpl* content_layer = scoped_content_layer.get(); | 5131 LayerImpl* content_layer = scoped_content_layer.get(); |
| 5078 root->AddChild(scoped_content_layer.Pass()); | 5132 root->AddChild(scoped_content_layer.Pass()); |
| 5079 | 5133 |
| 5080 scoped_ptr<LayerImpl> scoped_replica_layer = | 5134 scoped_ptr<LayerImpl> scoped_replica_layer = |
| 5081 LayerImpl::Create(host_impl_->active_tree(), 2); | 5135 LayerImpl::Create(host_impl_->active_tree(), 2); |
| 5082 LayerImpl* replica_layer = scoped_replica_layer.get(); | 5136 LayerImpl* replica_layer = scoped_replica_layer.get(); |
| 5083 content_layer->SetReplicaLayer(scoped_replica_layer.Pass()); | 5137 content_layer->SetReplicaLayer(scoped_replica_layer.Pass()); |
| 5138 content_layer->CreateRenderSurface(); |
| 5084 | 5139 |
| 5085 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = | 5140 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = |
| 5086 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); | 5141 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); |
| 5087 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); | 5142 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); |
| 5088 replica_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>()); | 5143 replica_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>()); |
| 5144 replica_layer->CreateRenderSurface(); |
| 5089 | 5145 |
| 5090 gfx::Size root_size(100, 100); | 5146 gfx::Size root_size(100, 100); |
| 5091 root->SetBounds(root_size); | 5147 root->SetBounds(root_size); |
| 5092 root->SetContentBounds(root_size); | 5148 root->SetContentBounds(root_size); |
| 5093 root->SetPosition(gfx::PointF()); | 5149 root->SetPosition(gfx::PointF()); |
| 5094 | 5150 |
| 5095 gfx::Size layer_size(50, 50); | 5151 gfx::Size layer_size(50, 50); |
| 5096 content_layer->SetBounds(layer_size); | 5152 content_layer->SetBounds(layer_size); |
| 5097 content_layer->SetContentBounds(layer_size); | 5153 content_layer->SetContentBounds(layer_size); |
| 5098 content_layer->SetPosition(gfx::PointF()); | 5154 content_layer->SetPosition(gfx::PointF()); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5210 } | 5266 } |
| 5211 } | 5267 } |
| 5212 | 5268 |
| 5213 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerForSurfaceWithUnclippedChild) { | 5269 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerForSurfaceWithUnclippedChild) { |
| 5214 // The replica is of a layer with bounds 50x50, but it has a child that causes | 5270 // The replica is of a layer with bounds 50x50, but it has a child that causes |
| 5215 // the surface bounds to be larger. | 5271 // the surface bounds to be larger. |
| 5216 | 5272 |
| 5217 scoped_ptr<LayerImpl> scoped_root = | 5273 scoped_ptr<LayerImpl> scoped_root = |
| 5218 LayerImpl::Create(host_impl_->active_tree(), 1); | 5274 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 5219 LayerImpl* root = scoped_root.get(); | 5275 LayerImpl* root = scoped_root.get(); |
| 5276 root->CreateRenderSurface(); |
| 5220 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); | 5277 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); |
| 5221 | 5278 |
| 5222 scoped_ptr<LayerImpl> scoped_content_layer = | 5279 scoped_ptr<LayerImpl> scoped_content_layer = |
| 5223 LayerImpl::Create(host_impl_->active_tree(), 2); | 5280 LayerImpl::Create(host_impl_->active_tree(), 2); |
| 5224 LayerImpl* content_layer = scoped_content_layer.get(); | 5281 LayerImpl* content_layer = scoped_content_layer.get(); |
| 5225 root->AddChild(scoped_content_layer.Pass()); | 5282 root->AddChild(scoped_content_layer.Pass()); |
| 5226 | 5283 |
| 5227 scoped_ptr<LayerImpl> scoped_content_child_layer = | 5284 scoped_ptr<LayerImpl> scoped_content_child_layer = |
| 5228 LayerImpl::Create(host_impl_->active_tree(), 3); | 5285 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 5229 LayerImpl* content_child_layer = scoped_content_child_layer.get(); | 5286 LayerImpl* content_child_layer = scoped_content_child_layer.get(); |
| 5230 content_layer->AddChild(scoped_content_child_layer.Pass()); | 5287 content_layer->AddChild(scoped_content_child_layer.Pass()); |
| 5231 | 5288 |
| 5232 scoped_ptr<LayerImpl> scoped_replica_layer = | 5289 scoped_ptr<LayerImpl> scoped_replica_layer = |
| 5233 LayerImpl::Create(host_impl_->active_tree(), 4); | 5290 LayerImpl::Create(host_impl_->active_tree(), 4); |
| 5234 LayerImpl* replica_layer = scoped_replica_layer.get(); | 5291 LayerImpl* replica_layer = scoped_replica_layer.get(); |
| 5235 content_layer->SetReplicaLayer(scoped_replica_layer.Pass()); | 5292 content_layer->SetReplicaLayer(scoped_replica_layer.Pass()); |
| 5293 content_layer->CreateRenderSurface(); |
| 5236 | 5294 |
| 5237 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = | 5295 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = |
| 5238 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 5); | 5296 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 5); |
| 5239 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); | 5297 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); |
| 5240 replica_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>()); | 5298 replica_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>()); |
| 5299 replica_layer->CreateRenderSurface(); |
| 5241 | 5300 |
| 5242 gfx::Size root_size(100, 100); | 5301 gfx::Size root_size(100, 100); |
| 5243 root->SetBounds(root_size); | 5302 root->SetBounds(root_size); |
| 5244 root->SetContentBounds(root_size); | 5303 root->SetContentBounds(root_size); |
| 5245 root->SetPosition(gfx::PointF()); | 5304 root->SetPosition(gfx::PointF()); |
| 5246 | 5305 |
| 5247 gfx::Size layer_size(50, 50); | 5306 gfx::Size layer_size(50, 50); |
| 5248 content_layer->SetBounds(layer_size); | 5307 content_layer->SetBounds(layer_size); |
| 5249 content_layer->SetContentBounds(layer_size); | 5308 content_layer->SetContentBounds(layer_size); |
| 5250 content_layer->SetPosition(gfx::PointF()); | 5309 content_layer->SetPosition(gfx::PointF()); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5328 } | 5387 } |
| 5329 | 5388 |
| 5330 TEST_F(LayerTreeHostImplTest, MaskLayerForSurfaceWithClippedLayer) { | 5389 TEST_F(LayerTreeHostImplTest, MaskLayerForSurfaceWithClippedLayer) { |
| 5331 // The masked layer has bounds 50x50, but it has a child that causes | 5390 // The masked layer has bounds 50x50, but it has a child that causes |
| 5332 // the surface bounds to be larger. It also has a parent that clips the | 5391 // the surface bounds to be larger. It also has a parent that clips the |
| 5333 // masked layer and its surface. | 5392 // masked layer and its surface. |
| 5334 | 5393 |
| 5335 scoped_ptr<LayerImpl> scoped_root = | 5394 scoped_ptr<LayerImpl> scoped_root = |
| 5336 LayerImpl::Create(host_impl_->active_tree(), 1); | 5395 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 5337 LayerImpl* root = scoped_root.get(); | 5396 LayerImpl* root = scoped_root.get(); |
| 5397 root->CreateRenderSurface(); |
| 5398 |
| 5338 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); | 5399 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); |
| 5339 | 5400 |
| 5340 scoped_ptr<LayerImpl> scoped_clipping_layer = | 5401 scoped_ptr<LayerImpl> scoped_clipping_layer = |
| 5341 LayerImpl::Create(host_impl_->active_tree(), 2); | 5402 LayerImpl::Create(host_impl_->active_tree(), 2); |
| 5342 LayerImpl* clipping_layer = scoped_clipping_layer.get(); | 5403 LayerImpl* clipping_layer = scoped_clipping_layer.get(); |
| 5343 root->AddChild(scoped_clipping_layer.Pass()); | 5404 root->AddChild(scoped_clipping_layer.Pass()); |
| 5344 | 5405 |
| 5345 scoped_ptr<LayerImpl> scoped_content_layer = | 5406 scoped_ptr<LayerImpl> scoped_content_layer = |
| 5346 LayerImpl::Create(host_impl_->active_tree(), 3); | 5407 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 5347 LayerImpl* content_layer = scoped_content_layer.get(); | 5408 LayerImpl* content_layer = scoped_content_layer.get(); |
| 5348 clipping_layer->AddChild(scoped_content_layer.Pass()); | 5409 clipping_layer->AddChild(scoped_content_layer.Pass()); |
| 5349 | 5410 |
| 5350 scoped_ptr<LayerImpl> scoped_content_child_layer = | 5411 scoped_ptr<LayerImpl> scoped_content_child_layer = |
| 5351 LayerImpl::Create(host_impl_->active_tree(), 4); | 5412 LayerImpl::Create(host_impl_->active_tree(), 4); |
| 5352 LayerImpl* content_child_layer = scoped_content_child_layer.get(); | 5413 LayerImpl* content_child_layer = scoped_content_child_layer.get(); |
| 5353 content_layer->AddChild(scoped_content_child_layer.Pass()); | 5414 content_layer->AddChild(scoped_content_child_layer.Pass()); |
| 5354 | 5415 |
| 5355 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = | 5416 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = |
| 5356 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 6); | 5417 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 6); |
| 5357 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); | 5418 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); |
| 5358 content_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>()); | 5419 content_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>()); |
| 5359 | 5420 content_layer->CreateRenderSurface(); |
| 5360 gfx::Size root_size(100, 100); | 5421 gfx::Size root_size(100, 100); |
| 5361 root->SetBounds(root_size); | 5422 root->SetBounds(root_size); |
| 5362 root->SetContentBounds(root_size); | 5423 root->SetContentBounds(root_size); |
| 5363 root->SetPosition(gfx::PointF()); | 5424 root->SetPosition(gfx::PointF()); |
| 5364 | 5425 |
| 5365 gfx::Rect clipping_rect(20, 10, 10, 20); | 5426 gfx::Rect clipping_rect(20, 10, 10, 20); |
| 5366 clipping_layer->SetBounds(clipping_rect.size()); | 5427 clipping_layer->SetBounds(clipping_rect.size()); |
| 5367 clipping_layer->SetContentBounds(clipping_rect.size()); | 5428 clipping_layer->SetContentBounds(clipping_rect.size()); |
| 5368 clipping_layer->SetPosition(clipping_rect.origin()); | 5429 clipping_layer->SetPosition(clipping_rect.origin()); |
| 5369 clipping_layer->SetMasksToBounds(true); | 5430 clipping_layer->SetMasksToBounds(true); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5432 gfx::ToCeiledSize(gfx::ScaleSize(root_size, device_scale_factor)); | 5493 gfx::ToCeiledSize(gfx::ScaleSize(root_size, device_scale_factor)); |
| 5433 host_impl_->SetViewportSize(device_viewport_size); | 5494 host_impl_->SetViewportSize(device_viewport_size); |
| 5434 | 5495 |
| 5435 host_impl_->CreatePendingTree(); | 5496 host_impl_->CreatePendingTree(); |
| 5436 host_impl_->pending_tree() | 5497 host_impl_->pending_tree() |
| 5437 ->SetPageScaleFactorAndLimits(1.f, 1.f / 16.f, 16.f); | 5498 ->SetPageScaleFactorAndLimits(1.f, 1.f / 16.f, 16.f); |
| 5438 | 5499 |
| 5439 scoped_ptr<LayerImpl> scoped_root = | 5500 scoped_ptr<LayerImpl> scoped_root = |
| 5440 LayerImpl::Create(host_impl_->pending_tree(), 1); | 5501 LayerImpl::Create(host_impl_->pending_tree(), 1); |
| 5441 LayerImpl* root = scoped_root.get(); | 5502 LayerImpl* root = scoped_root.get(); |
| 5503 root->CreateRenderSurface(); |
| 5442 | 5504 |
| 5443 host_impl_->pending_tree()->SetRootLayer(scoped_root.Pass()); | 5505 host_impl_->pending_tree()->SetRootLayer(scoped_root.Pass()); |
| 5444 | 5506 |
| 5445 scoped_ptr<LayerImpl> scoped_scrolling_layer = | 5507 scoped_ptr<LayerImpl> scoped_scrolling_layer = |
| 5446 LayerImpl::Create(host_impl_->pending_tree(), 2); | 5508 LayerImpl::Create(host_impl_->pending_tree(), 2); |
| 5447 LayerImpl* scrolling_layer = scoped_scrolling_layer.get(); | 5509 LayerImpl* scrolling_layer = scoped_scrolling_layer.get(); |
| 5448 root->AddChild(scoped_scrolling_layer.Pass()); | 5510 root->AddChild(scoped_scrolling_layer.Pass()); |
| 5449 | 5511 |
| 5450 gfx::Size content_layer_bounds(100000, 100); | 5512 gfx::Size content_layer_bounds(100000, 100); |
| 5451 gfx::Size pile_tile_size(3000, 3000); | 5513 gfx::Size pile_tile_size(3000, 3000); |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5930 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures()); | 5992 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures()); |
| 5931 } | 5993 } |
| 5932 | 5994 |
| 5933 TEST_F(LayerTreeHostImplTest, TouchFlingShouldNotBubble) { | 5995 TEST_F(LayerTreeHostImplTest, TouchFlingShouldNotBubble) { |
| 5934 // When flinging via touch, only the child should scroll (we should not | 5996 // When flinging via touch, only the child should scroll (we should not |
| 5935 // bubble). | 5997 // bubble). |
| 5936 gfx::Size surface_size(10, 10); | 5998 gfx::Size surface_size(10, 10); |
| 5937 gfx::Size content_size(20, 20); | 5999 gfx::Size content_size(20, 20); |
| 5938 scoped_ptr<LayerImpl> root_clip = | 6000 scoped_ptr<LayerImpl> root_clip = |
| 5939 LayerImpl::Create(host_impl_->active_tree(), 3); | 6001 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 6002 root_clip->CreateRenderSurface(); |
| 6003 |
| 5940 scoped_ptr<LayerImpl> root = | 6004 scoped_ptr<LayerImpl> root = |
| 5941 CreateScrollableLayer(1, content_size, root_clip.get()); | 6005 CreateScrollableLayer(1, content_size, root_clip.get()); |
| 5942 root->SetIsContainerForFixedPositionLayers(true); | 6006 root->SetIsContainerForFixedPositionLayers(true); |
| 5943 scoped_ptr<LayerImpl> child = | 6007 scoped_ptr<LayerImpl> child = |
| 5944 CreateScrollableLayer(2, content_size, root_clip.get()); | 6008 CreateScrollableLayer(2, content_size, root_clip.get()); |
| 5945 | 6009 |
| 5946 root->AddChild(child.Pass()); | 6010 root->AddChild(child.Pass()); |
| 5947 int root_id = root->id(); | 6011 int root_id = root->id(); |
| 5948 root_clip->AddChild(root.Pass()); | 6012 root_clip->AddChild(root.Pass()); |
| 5949 | 6013 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 5973 ASSERT_EQ(1u, scroll_info->scrolls.size()); | 6037 ASSERT_EQ(1u, scroll_info->scrolls.size()); |
| 5974 ExpectNone(*scroll_info.get(), root_id); | 6038 ExpectNone(*scroll_info.get(), root_id); |
| 5975 } | 6039 } |
| 5976 } | 6040 } |
| 5977 | 6041 |
| 5978 TEST_F(LayerTreeHostImplTest, TouchFlingShouldLockToFirstScrolledLayer) { | 6042 TEST_F(LayerTreeHostImplTest, TouchFlingShouldLockToFirstScrolledLayer) { |
| 5979 // Scroll a child layer beyond its maximum scroll range and make sure the | 6043 // Scroll a child layer beyond its maximum scroll range and make sure the |
| 5980 // the scroll doesn't bubble up to the parent layer. | 6044 // the scroll doesn't bubble up to the parent layer. |
| 5981 gfx::Size surface_size(10, 10); | 6045 gfx::Size surface_size(10, 10); |
| 5982 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 6046 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 6047 root->CreateRenderSurface(); |
| 5983 scoped_ptr<LayerImpl> root_scrolling = | 6048 scoped_ptr<LayerImpl> root_scrolling = |
| 5984 CreateScrollableLayer(2, surface_size, root.get()); | 6049 CreateScrollableLayer(2, surface_size, root.get()); |
| 5985 | 6050 |
| 5986 scoped_ptr<LayerImpl> grand_child = | 6051 scoped_ptr<LayerImpl> grand_child = |
| 5987 CreateScrollableLayer(4, surface_size, root.get()); | 6052 CreateScrollableLayer(4, surface_size, root.get()); |
| 5988 grand_child->SetScrollOffset(gfx::Vector2d(0, 2)); | 6053 grand_child->SetScrollOffset(gfx::Vector2d(0, 2)); |
| 5989 | 6054 |
| 5990 scoped_ptr<LayerImpl> child = | 6055 scoped_ptr<LayerImpl> child = |
| 5991 CreateScrollableLayer(3, surface_size, root.get()); | 6056 CreateScrollableLayer(3, surface_size, root.get()); |
| 5992 child->SetScrollOffset(gfx::Vector2d(0, 4)); | 6057 child->SetScrollOffset(gfx::Vector2d(0, 4)); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6043 } | 6108 } |
| 6044 } | 6109 } |
| 6045 | 6110 |
| 6046 TEST_F(LayerTreeHostImplTest, WheelFlingShouldBubble) { | 6111 TEST_F(LayerTreeHostImplTest, WheelFlingShouldBubble) { |
| 6047 // When flinging via wheel, the root should eventually scroll (we should | 6112 // When flinging via wheel, the root should eventually scroll (we should |
| 6048 // bubble). | 6113 // bubble). |
| 6049 gfx::Size surface_size(10, 10); | 6114 gfx::Size surface_size(10, 10); |
| 6050 gfx::Size content_size(20, 20); | 6115 gfx::Size content_size(20, 20); |
| 6051 scoped_ptr<LayerImpl> root_clip = | 6116 scoped_ptr<LayerImpl> root_clip = |
| 6052 LayerImpl::Create(host_impl_->active_tree(), 3); | 6117 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 6118 root_clip->CreateRenderSurface(); |
| 6053 scoped_ptr<LayerImpl> root_scroll = | 6119 scoped_ptr<LayerImpl> root_scroll = |
| 6054 CreateScrollableLayer(1, content_size, root_clip.get()); | 6120 CreateScrollableLayer(1, content_size, root_clip.get()); |
| 6055 int root_scroll_id = root_scroll->id(); | 6121 int root_scroll_id = root_scroll->id(); |
| 6056 scoped_ptr<LayerImpl> child = | 6122 scoped_ptr<LayerImpl> child = |
| 6057 CreateScrollableLayer(2, content_size, root_clip.get()); | 6123 CreateScrollableLayer(2, content_size, root_clip.get()); |
| 6058 | 6124 |
| 6059 root_scroll->AddChild(child.Pass()); | 6125 root_scroll->AddChild(child.Pass()); |
| 6060 root_clip->AddChild(root_scroll.Pass()); | 6126 root_clip->AddChild(root_scroll.Pass()); |
| 6061 | 6127 |
| 6062 host_impl_->SetViewportSize(surface_size); | 6128 host_impl_->SetViewportSize(surface_size); |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6246 | 6312 |
| 6247 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed | 6313 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed |
| 6248 // to CompositorFrameMetadata after SwapBuffers(); | 6314 // to CompositorFrameMetadata after SwapBuffers(); |
| 6249 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { | 6315 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { |
| 6250 scoped_ptr<SolidColorLayerImpl> root = | 6316 scoped_ptr<SolidColorLayerImpl> root = |
| 6251 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 6317 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
| 6252 root->SetPosition(gfx::PointF()); | 6318 root->SetPosition(gfx::PointF()); |
| 6253 root->SetBounds(gfx::Size(10, 10)); | 6319 root->SetBounds(gfx::Size(10, 10)); |
| 6254 root->SetContentBounds(gfx::Size(10, 10)); | 6320 root->SetContentBounds(gfx::Size(10, 10)); |
| 6255 root->SetDrawsContent(true); | 6321 root->SetDrawsContent(true); |
| 6322 root->CreateRenderSurface(); |
| 6256 | 6323 |
| 6257 host_impl_->active_tree()->SetRootLayer(root.PassAs<LayerImpl>()); | 6324 host_impl_->active_tree()->SetRootLayer(root.PassAs<LayerImpl>()); |
| 6258 | 6325 |
| 6259 FakeOutputSurface* fake_output_surface = | 6326 FakeOutputSurface* fake_output_surface = |
| 6260 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); | 6327 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); |
| 6261 | 6328 |
| 6262 const std::vector<ui::LatencyInfo>& metadata_latency_before = | 6329 const std::vector<ui::LatencyInfo>& metadata_latency_before = |
| 6263 fake_output_surface->last_sent_frame().metadata.latency_info; | 6330 fake_output_surface->last_sent_frame().metadata.latency_info; |
| 6264 EXPECT_TRUE(metadata_latency_before.empty()); | 6331 EXPECT_TRUE(metadata_latency_before.empty()); |
| 6265 | 6332 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 6286 } | 6353 } |
| 6287 | 6354 |
| 6288 TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) { | 6355 TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) { |
| 6289 int root_layer_id = 1; | 6356 int root_layer_id = 1; |
| 6290 scoped_ptr<SolidColorLayerImpl> root = | 6357 scoped_ptr<SolidColorLayerImpl> root = |
| 6291 SolidColorLayerImpl::Create(host_impl_->active_tree(), root_layer_id); | 6358 SolidColorLayerImpl::Create(host_impl_->active_tree(), root_layer_id); |
| 6292 root->SetPosition(gfx::PointF()); | 6359 root->SetPosition(gfx::PointF()); |
| 6293 root->SetBounds(gfx::Size(10, 10)); | 6360 root->SetBounds(gfx::Size(10, 10)); |
| 6294 root->SetContentBounds(gfx::Size(10, 10)); | 6361 root->SetContentBounds(gfx::Size(10, 10)); |
| 6295 root->SetDrawsContent(true); | 6362 root->SetDrawsContent(true); |
| 6363 root->CreateRenderSurface(); |
| 6296 | 6364 |
| 6297 host_impl_->active_tree()->SetRootLayer(root.PassAs<LayerImpl>()); | 6365 host_impl_->active_tree()->SetRootLayer(root.PassAs<LayerImpl>()); |
| 6298 | 6366 |
| 6299 // Ensure the default frame selection bounds are empty. | 6367 // Ensure the default frame selection bounds are empty. |
| 6300 FakeOutputSurface* fake_output_surface = | 6368 FakeOutputSurface* fake_output_surface = |
| 6301 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); | 6369 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); |
| 6302 const ViewportSelectionBound& selection_start_before = | 6370 const ViewportSelectionBound& selection_start_before = |
| 6303 fake_output_surface->last_sent_frame().metadata.selection_start; | 6371 fake_output_surface->last_sent_frame().metadata.selection_start; |
| 6304 const ViewportSelectionBound& selection_end_before = | 6372 const ViewportSelectionBound& selection_end_before = |
| 6305 fake_output_surface->last_sent_frame().metadata.selection_end; | 6373 fake_output_surface->last_sent_frame().metadata.selection_end; |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6710 contents->SetBounds(content_size); | 6778 contents->SetBounds(content_size); |
| 6711 contents->SetContentBounds(content_size); | 6779 contents->SetContentBounds(content_size); |
| 6712 contents->SetPosition(gfx::PointF()); | 6780 contents->SetPosition(gfx::PointF()); |
| 6713 | 6781 |
| 6714 outer_scroll->AddChild(contents.Pass()); | 6782 outer_scroll->AddChild(contents.Pass()); |
| 6715 outer_clip->AddChild(outer_scroll.Pass()); | 6783 outer_clip->AddChild(outer_scroll.Pass()); |
| 6716 inner_scroll->AddChild(outer_clip.Pass()); | 6784 inner_scroll->AddChild(outer_clip.Pass()); |
| 6717 page_scale->AddChild(inner_scroll.Pass()); | 6785 page_scale->AddChild(inner_scroll.Pass()); |
| 6718 inner_clip->AddChild(page_scale.Pass()); | 6786 inner_clip->AddChild(page_scale.Pass()); |
| 6719 | 6787 |
| 6788 inner_clip->CreateRenderSurface(); |
| 6720 layer_tree_impl->SetRootLayer(inner_clip.Pass()); | 6789 layer_tree_impl->SetRootLayer(inner_clip.Pass()); |
| 6721 layer_tree_impl->SetViewportLayersFromIds(kPageScaleLayerId, | 6790 layer_tree_impl->SetViewportLayersFromIds(kPageScaleLayerId, |
| 6722 kInnerViewportScrollLayerId, kOuterViewportScrollLayerId); | 6791 kInnerViewportScrollLayerId, kOuterViewportScrollLayerId); |
| 6723 | 6792 |
| 6724 host_impl_->active_tree()->DidBecomeActive(); | 6793 host_impl_->active_tree()->DidBecomeActive(); |
| 6725 } | 6794 } |
| 6726 }; | 6795 }; |
| 6727 | 6796 |
| 6728 TEST_F(LayerTreeHostImplVirtualViewportTest, FlingScrollBubblesToInner) { | 6797 TEST_F(LayerTreeHostImplVirtualViewportTest, FlingScrollBubblesToInner) { |
| 6729 gfx::Size content_size = gfx::Size(100, 160); | 6798 gfx::Size content_size = gfx::Size(100, 160); |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6988 host_impl_->DidLoseOutputSurface(); | 7057 host_impl_->DidLoseOutputSurface(); |
| 6989 EXPECT_TRUE(host_impl_->IsContextLost()); | 7058 EXPECT_TRUE(host_impl_->IsContextLost()); |
| 6990 EXPECT_EQ(1, num_lost_surfaces_); | 7059 EXPECT_EQ(1, num_lost_surfaces_); |
| 6991 host_impl_->DidLoseOutputSurface(); | 7060 host_impl_->DidLoseOutputSurface(); |
| 6992 EXPECT_TRUE(host_impl_->IsContextLost()); | 7061 EXPECT_TRUE(host_impl_->IsContextLost()); |
| 6993 EXPECT_EQ(1, num_lost_surfaces_); | 7062 EXPECT_EQ(1, num_lost_surfaces_); |
| 6994 } | 7063 } |
| 6995 | 7064 |
| 6996 } // namespace | 7065 } // namespace |
| 6997 } // namespace cc | 7066 } // namespace cc |
| OLD | NEW |