| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 root->SetBounds(gfx::Size(10, 10)); | 184 root->SetBounds(gfx::Size(10, 10)); |
| 185 root->SetDrawsContent(true); | 185 root->SetDrawsContent(true); |
| 186 root->draw_properties().visible_layer_rect = gfx::Rect(0, 0, 10, 10); | 186 root->draw_properties().visible_layer_rect = gfx::Rect(0, 0, 10, 10); |
| 187 root->SetHasRenderSurface(true); | 187 root->SetHasRenderSurface(true); |
| 188 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 188 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 189 } | 189 } |
| 190 | 190 |
| 191 static void ExpectClearedScrollDeltasRecursive(LayerImpl* layer) { | 191 static void ExpectClearedScrollDeltasRecursive(LayerImpl* layer) { |
| 192 ASSERT_EQ(layer->ScrollDelta(), gfx::Vector2d()); | 192 ASSERT_EQ(layer->ScrollDelta(), gfx::Vector2d()); |
| 193 for (size_t i = 0; i < layer->children().size(); ++i) | 193 for (size_t i = 0; i < layer->children().size(); ++i) |
| 194 ExpectClearedScrollDeltasRecursive(layer->children()[i]); | 194 ExpectClearedScrollDeltasRecursive(layer->children()[i].get()); |
| 195 } | 195 } |
| 196 | 196 |
| 197 static ::testing::AssertionResult ScrollInfoContains( | 197 static ::testing::AssertionResult ScrollInfoContains( |
| 198 const ScrollAndScaleSet& scroll_info, | 198 const ScrollAndScaleSet& scroll_info, |
| 199 int id, | 199 int id, |
| 200 const gfx::Vector2d& scroll_delta) { | 200 const gfx::Vector2d& scroll_delta) { |
| 201 int times_encountered = 0; | 201 int times_encountered = 0; |
| 202 | 202 |
| 203 for (size_t i = 0; i < scroll_info.scrolls.size(); ++i) { | 203 for (size_t i = 0; i < scroll_info.scrolls.size(); ++i) { |
| 204 if (scroll_info.scrolls[i].layer_id != id) | 204 if (scroll_info.scrolls[i].layer_id != id) |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 // Sets up a typical virtual viewport setup with one child content layer. | 309 // Sets up a typical virtual viewport setup with one child content layer. |
| 310 // Returns a pointer to the content layer. | 310 // Returns a pointer to the content layer. |
| 311 LayerImpl* CreateBasicVirtualViewportLayers(const gfx::Size& viewport_size, | 311 LayerImpl* CreateBasicVirtualViewportLayers(const gfx::Size& viewport_size, |
| 312 const gfx::Size& content_size) { | 312 const gfx::Size& content_size) { |
| 313 // CreateScrollAndContentsLayers makes the outer viewport unscrollable and | 313 // CreateScrollAndContentsLayers makes the outer viewport unscrollable and |
| 314 // the inner a different size from the outer. We'll reuse its layer | 314 // the inner a different size from the outer. We'll reuse its layer |
| 315 // hierarchy but adjust the sizing to our needs. | 315 // hierarchy but adjust the sizing to our needs. |
| 316 CreateScrollAndContentsLayers(host_impl_->active_tree(), content_size); | 316 CreateScrollAndContentsLayers(host_impl_->active_tree(), content_size); |
| 317 | 317 |
| 318 LayerImpl* content_layer = | 318 LayerImpl* content_layer = |
| 319 host_impl_->OuterViewportScrollLayer()->children().back(); | 319 host_impl_->OuterViewportScrollLayer()->children().back().get(); |
| 320 content_layer->SetBounds(content_size); | 320 content_layer->SetBounds(content_size); |
| 321 host_impl_->OuterViewportScrollLayer()->SetBounds(content_size); | 321 host_impl_->OuterViewportScrollLayer()->SetBounds(content_size); |
| 322 | 322 |
| 323 LayerImpl* outer_clip = host_impl_->OuterViewportScrollLayer()->parent(); | 323 LayerImpl* outer_clip = host_impl_->OuterViewportScrollLayer()->parent(); |
| 324 outer_clip->SetBounds(viewport_size); | 324 outer_clip->SetBounds(viewport_size); |
| 325 | 325 |
| 326 LayerImpl* inner_clip_layer = | 326 LayerImpl* inner_clip_layer = |
| 327 host_impl_->InnerViewportScrollLayer()->parent()->parent(); | 327 host_impl_->InnerViewportScrollLayer()->parent()->parent(); |
| 328 inner_clip_layer->SetBounds(viewport_size); | 328 inner_clip_layer->SetBounds(viewport_size); |
| 329 host_impl_->InnerViewportScrollLayer()->SetBounds(viewport_size); | 329 host_impl_->InnerViewportScrollLayer()->SetBounds(viewport_size); |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 LayerImpl::Create(host_impl_->active_tree(), 1); | 524 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 525 root_clip->SetBounds(gfx::Size(10, 10)); | 525 root_clip->SetBounds(gfx::Size(10, 10)); |
| 526 LayerImpl* root_layer = root.get(); | 526 LayerImpl* root_layer = root.get(); |
| 527 root_clip->AddChild(root.Pass()); | 527 root_clip->AddChild(root.Pass()); |
| 528 root_layer->SetBounds(gfx::Size(110, 110)); | 528 root_layer->SetBounds(gfx::Size(110, 110)); |
| 529 root_layer->SetScrollClipLayer(root_clip->id()); | 529 root_layer->SetScrollClipLayer(root_clip->id()); |
| 530 root_layer->PushScrollOffsetFromMainThread(scroll_offset); | 530 root_layer->PushScrollOffsetFromMainThread(scroll_offset); |
| 531 root_layer->ScrollBy(scroll_delta); | 531 root_layer->ScrollBy(scroll_delta); |
| 532 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 532 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); |
| 533 } | 533 } |
| 534 LayerImpl* root = host_impl_->active_tree()->root_layer()->children()[0]; | 534 LayerImpl* root = |
| 535 host_impl_->active_tree()->root_layer()->children()[0].get(); |
| 535 | 536 |
| 536 scoped_ptr<ScrollAndScaleSet> scroll_info; | 537 scoped_ptr<ScrollAndScaleSet> scroll_info; |
| 537 | 538 |
| 538 scroll_info = host_impl_->ProcessScrollDeltas(); | 539 scroll_info = host_impl_->ProcessScrollDeltas(); |
| 539 ASSERT_EQ(scroll_info->scrolls.size(), 1u); | 540 ASSERT_EQ(scroll_info->scrolls.size(), 1u); |
| 540 EXPECT_TRUE(ScrollInfoContains(*scroll_info, root->id(), scroll_delta)); | 541 EXPECT_TRUE(ScrollInfoContains(*scroll_info, root->id(), scroll_delta)); |
| 541 | 542 |
| 542 gfx::Vector2d scroll_delta2(-5, 27); | 543 gfx::Vector2d scroll_delta2(-5, 27); |
| 543 root->ScrollBy(scroll_delta2); | 544 root->ScrollBy(scroll_delta2); |
| 544 scroll_info = host_impl_->ProcessScrollDeltas(); | 545 scroll_info = host_impl_->ProcessScrollDeltas(); |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 736 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 737 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
| 737 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 738 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
| 738 host_impl_->ScrollEnd(); | 739 host_impl_->ScrollEnd(); |
| 739 } | 740 } |
| 740 | 741 |
| 741 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnLayerTopology) { | 742 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnLayerTopology) { |
| 742 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 743 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 743 | 744 |
| 744 // Create a normal scrollable root layer | 745 // Create a normal scrollable root layer |
| 745 LayerImpl* root_scroll = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 746 LayerImpl* root_scroll = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 746 LayerImpl* root_child = root_scroll->children()[0]; | 747 LayerImpl* root_child = root_scroll->children()[0].get(); |
| 747 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 748 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 748 DrawFrame(); | 749 DrawFrame(); |
| 749 | 750 |
| 750 // Create two child scrollable layers | 751 // Create two child scrollable layers |
| 751 LayerImpl* child1 = 0; | 752 LayerImpl* child1 = 0; |
| 752 { | 753 { |
| 753 scoped_ptr<LayerImpl> scrollable_child_clip_1 = | 754 scoped_ptr<LayerImpl> scrollable_child_clip_1 = |
| 754 LayerImpl::Create(host_impl_->active_tree(), 6); | 755 LayerImpl::Create(host_impl_->active_tree(), 6); |
| 755 scoped_ptr<LayerImpl> scrollable_child_1 = CreateScrollableLayer( | 756 scoped_ptr<LayerImpl> scrollable_child_1 = CreateScrollableLayer( |
| 756 7, gfx::Size(10, 10), scrollable_child_clip_1.get()); | 757 7, gfx::Size(10, 10), scrollable_child_clip_1.get()); |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1034 EXPECT_TRUE(host_impl_->ScrollVerticallyByPage( | 1035 EXPECT_TRUE(host_impl_->ScrollVerticallyByPage( |
| 1035 gfx::Point(), SCROLL_BACKWARD)); | 1036 gfx::Point(), SCROLL_BACKWARD)); |
| 1036 } | 1037 } |
| 1037 | 1038 |
| 1038 TEST_F(LayerTreeHostImplTest, ScrollWithUserUnscrollableLayers) { | 1039 TEST_F(LayerTreeHostImplTest, ScrollWithUserUnscrollableLayers) { |
| 1039 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200)); | 1040 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
| 1040 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 1041 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
| 1041 | 1042 |
| 1042 gfx::Size overflow_size(400, 400); | 1043 gfx::Size overflow_size(400, 400); |
| 1043 ASSERT_EQ(1u, scroll_layer->children().size()); | 1044 ASSERT_EQ(1u, scroll_layer->children().size()); |
| 1044 LayerImpl* overflow = scroll_layer->children()[0]; | 1045 LayerImpl* overflow = scroll_layer->children()[0].get(); |
| 1045 overflow->SetBounds(overflow_size); | 1046 overflow->SetBounds(overflow_size); |
| 1046 overflow->SetScrollClipLayer(scroll_layer->parent()->id()); | 1047 overflow->SetScrollClipLayer(scroll_layer->parent()->id()); |
| 1047 overflow->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); | 1048 overflow->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); |
| 1048 overflow->SetPosition(gfx::PointF()); | 1049 overflow->SetPosition(gfx::PointF()); |
| 1049 | 1050 |
| 1050 DrawFrame(); | 1051 DrawFrame(); |
| 1051 gfx::Point scroll_position(10, 10); | 1052 gfx::Point scroll_position(10, 10); |
| 1052 | 1053 |
| 1053 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 1054 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
| 1054 host_impl_->ScrollBegin(scroll_position, InputHandler::WHEEL)); | 1055 host_impl_->ScrollBegin(scroll_position, InputHandler::WHEEL)); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1090 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 1091 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 1091 | 1092 |
| 1092 host_impl_->CreatePendingTree(); | 1093 host_impl_->CreatePendingTree(); |
| 1093 host_impl_->pending_tree()->SetRootLayer( | 1094 host_impl_->pending_tree()->SetRootLayer( |
| 1094 LayerImpl::Create(host_impl_->pending_tree(), 1)); | 1095 LayerImpl::Create(host_impl_->pending_tree(), 1)); |
| 1095 LayerImpl* root = host_impl_->pending_tree()->root_layer(); | 1096 LayerImpl* root = host_impl_->pending_tree()->root_layer(); |
| 1096 root->SetBounds(gfx::Size(50, 50)); | 1097 root->SetBounds(gfx::Size(50, 50)); |
| 1097 root->SetHasRenderSurface(true); | 1098 root->SetHasRenderSurface(true); |
| 1098 | 1099 |
| 1099 root->AddChild(LayerImpl::Create(host_impl_->pending_tree(), 2)); | 1100 root->AddChild(LayerImpl::Create(host_impl_->pending_tree(), 2)); |
| 1100 LayerImpl* child = root->children()[0]; | 1101 LayerImpl* child = root->children()[0].get(); |
| 1101 child->SetBounds(gfx::Size(10, 10)); | 1102 child->SetBounds(gfx::Size(10, 10)); |
| 1102 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); | 1103 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); |
| 1103 child->SetDrawsContent(true); | 1104 child->SetDrawsContent(true); |
| 1104 AddAnimatedTransformToLayer(child, 10.0, 3, 0); | 1105 AddAnimatedTransformToLayer(child, 10.0, 3, 0); |
| 1105 | 1106 |
| 1106 EXPECT_FALSE(did_request_animate_); | 1107 EXPECT_FALSE(did_request_animate_); |
| 1107 EXPECT_FALSE(did_request_redraw_); | 1108 EXPECT_FALSE(did_request_redraw_); |
| 1108 EXPECT_FALSE(did_request_commit_); | 1109 EXPECT_FALSE(did_request_commit_); |
| 1109 | 1110 |
| 1110 host_impl_->AnimatePendingTreeAfterCommit(); | 1111 host_impl_->AnimatePendingTreeAfterCommit(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1138 TEST_F(LayerTreeHostImplTest, AnimationSchedulingActiveTree) { | 1139 TEST_F(LayerTreeHostImplTest, AnimationSchedulingActiveTree) { |
| 1139 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 1140 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 1140 | 1141 |
| 1141 host_impl_->active_tree()->SetRootLayer( | 1142 host_impl_->active_tree()->SetRootLayer( |
| 1142 LayerImpl::Create(host_impl_->active_tree(), 1)); | 1143 LayerImpl::Create(host_impl_->active_tree(), 1)); |
| 1143 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 1144 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 1144 root->SetBounds(gfx::Size(50, 50)); | 1145 root->SetBounds(gfx::Size(50, 50)); |
| 1145 root->SetHasRenderSurface(true); | 1146 root->SetHasRenderSurface(true); |
| 1146 | 1147 |
| 1147 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2)); | 1148 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2)); |
| 1148 LayerImpl* child = root->children()[0]; | 1149 LayerImpl* child = root->children()[0].get(); |
| 1149 child->SetBounds(gfx::Size(10, 10)); | 1150 child->SetBounds(gfx::Size(10, 10)); |
| 1150 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); | 1151 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); |
| 1151 child->SetDrawsContent(true); | 1152 child->SetDrawsContent(true); |
| 1152 | 1153 |
| 1153 // Add a translate from 6,7 to 8,9. | 1154 // Add a translate from 6,7 to 8,9. |
| 1154 TransformOperations start; | 1155 TransformOperations start; |
| 1155 start.AppendTranslate(6.f, 7.f, 0.f); | 1156 start.AppendTranslate(6.f, 7.f, 0.f); |
| 1156 TransformOperations end; | 1157 TransformOperations end; |
| 1157 end.AppendTranslate(8.f, 9.f, 0.f); | 1158 end.AppendTranslate(8.f, 9.f, 0.f); |
| 1158 AddAnimatedTransformToLayer(child, 4.0, start, end); | 1159 AddAnimatedTransformToLayer(child, 4.0, start, end); |
| (...skipping 1609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2768 | 2769 |
| 2769 void ClearDidDrawCheck() { | 2770 void ClearDidDrawCheck() { |
| 2770 will_draw_called_ = false; | 2771 will_draw_called_ = false; |
| 2771 append_quads_called_ = false; | 2772 append_quads_called_ = false; |
| 2772 did_draw_called_ = false; | 2773 did_draw_called_ = false; |
| 2773 } | 2774 } |
| 2774 | 2775 |
| 2775 static void IgnoreResult(scoped_ptr<CopyOutputResult> result) {} | 2776 static void IgnoreResult(scoped_ptr<CopyOutputResult> result) {} |
| 2776 | 2777 |
| 2777 void AddCopyRequest() { | 2778 void AddCopyRequest() { |
| 2778 ScopedPtrVector<CopyOutputRequest> requests; | 2779 std::vector<scoped_ptr<CopyOutputRequest>> requests; |
| 2779 requests.push_back( | 2780 requests.push_back( |
| 2780 CopyOutputRequest::CreateRequest(base::Bind(&IgnoreResult))); | 2781 CopyOutputRequest::CreateRequest(base::Bind(&IgnoreResult))); |
| 2781 SetHasRenderSurface(true); | 2782 SetHasRenderSurface(true); |
| 2782 PassCopyRequests(&requests); | 2783 PassCopyRequests(&requests); |
| 2783 } | 2784 } |
| 2784 | 2785 |
| 2785 protected: | 2786 protected: |
| 2786 DidDrawCheckLayer(LayerTreeImpl* tree_impl, int id) | 2787 DidDrawCheckLayer(LayerTreeImpl* tree_impl, int id) |
| 2787 : LayerImpl(tree_impl, id), | 2788 : LayerImpl(tree_impl, id), |
| 2788 will_draw_returns_false_(false), | 2789 will_draw_returns_false_(false), |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2805 // The root layer is always drawn, so run this test on a child layer that | 2806 // The root layer is always drawn, so run this test on a child layer that |
| 2806 // will be masked out by the root layer's bounds. | 2807 // will be masked out by the root layer's bounds. |
| 2807 host_impl_->active_tree()->SetRootLayer( | 2808 host_impl_->active_tree()->SetRootLayer( |
| 2808 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 2809 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
| 2809 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( | 2810 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( |
| 2810 host_impl_->active_tree()->root_layer()); | 2811 host_impl_->active_tree()->root_layer()); |
| 2811 | 2812 |
| 2812 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 2813 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
| 2813 root->SetHasRenderSurface(true); | 2814 root->SetHasRenderSurface(true); |
| 2814 DidDrawCheckLayer* layer = | 2815 DidDrawCheckLayer* layer = |
| 2815 static_cast<DidDrawCheckLayer*>(root->children()[0]); | 2816 static_cast<DidDrawCheckLayer*>(root->children()[0].get()); |
| 2816 | 2817 |
| 2817 { | 2818 { |
| 2818 LayerTreeHostImpl::FrameData frame; | 2819 LayerTreeHostImpl::FrameData frame; |
| 2819 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 2820 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
| 2820 host_impl_->DrawLayers(&frame); | 2821 host_impl_->DrawLayers(&frame); |
| 2821 host_impl_->DidDrawAllLayers(frame); | 2822 host_impl_->DidDrawAllLayers(frame); |
| 2822 | 2823 |
| 2823 EXPECT_TRUE(layer->will_draw_called()); | 2824 EXPECT_TRUE(layer->will_draw_called()); |
| 2824 EXPECT_TRUE(layer->append_quads_called()); | 2825 EXPECT_TRUE(layer->append_quads_called()); |
| 2825 EXPECT_TRUE(layer->did_draw_called()); | 2826 EXPECT_TRUE(layer->did_draw_called()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2847 // The root layer is always drawn, so run this test on a child layer that | 2848 // The root layer is always drawn, so run this test on a child layer that |
| 2848 // will be masked out by the root layer's bounds. | 2849 // will be masked out by the root layer's bounds. |
| 2849 host_impl_->active_tree()->SetRootLayer( | 2850 host_impl_->active_tree()->SetRootLayer( |
| 2850 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 2851 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
| 2851 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( | 2852 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( |
| 2852 host_impl_->active_tree()->root_layer()); | 2853 host_impl_->active_tree()->root_layer()); |
| 2853 root->SetMasksToBounds(true); | 2854 root->SetMasksToBounds(true); |
| 2854 root->SetHasRenderSurface(true); | 2855 root->SetHasRenderSurface(true); |
| 2855 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 2856 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
| 2856 DidDrawCheckLayer* layer = | 2857 DidDrawCheckLayer* layer = |
| 2857 static_cast<DidDrawCheckLayer*>(root->children()[0]); | 2858 static_cast<DidDrawCheckLayer*>(root->children()[0].get()); |
| 2858 // Ensure visible_layer_rect for layer is empty. | 2859 // Ensure visible_layer_rect for layer is empty. |
| 2859 layer->SetPosition(gfx::PointF(100.f, 100.f)); | 2860 layer->SetPosition(gfx::PointF(100.f, 100.f)); |
| 2860 layer->SetBounds(gfx::Size(10, 10)); | 2861 layer->SetBounds(gfx::Size(10, 10)); |
| 2861 | 2862 |
| 2862 LayerTreeHostImpl::FrameData frame; | 2863 LayerTreeHostImpl::FrameData frame; |
| 2863 | 2864 |
| 2864 EXPECT_FALSE(layer->will_draw_called()); | 2865 EXPECT_FALSE(layer->will_draw_called()); |
| 2865 EXPECT_FALSE(layer->did_draw_called()); | 2866 EXPECT_FALSE(layer->did_draw_called()); |
| 2866 | 2867 |
| 2867 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 2868 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2894 gfx::Size big_size(1000, 1000); | 2895 gfx::Size big_size(1000, 1000); |
| 2895 host_impl_->SetViewportSize(big_size); | 2896 host_impl_->SetViewportSize(big_size); |
| 2896 | 2897 |
| 2897 host_impl_->active_tree()->SetRootLayer( | 2898 host_impl_->active_tree()->SetRootLayer( |
| 2898 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 2899 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
| 2899 DidDrawCheckLayer* root = | 2900 DidDrawCheckLayer* root = |
| 2900 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2901 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 2901 | 2902 |
| 2902 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 2903 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
| 2903 DidDrawCheckLayer* occluded_layer = | 2904 DidDrawCheckLayer* occluded_layer = |
| 2904 static_cast<DidDrawCheckLayer*>(root->children()[0]); | 2905 static_cast<DidDrawCheckLayer*>(root->children()[0].get()); |
| 2905 | 2906 |
| 2906 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); | 2907 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); |
| 2907 root->SetHasRenderSurface(true); | 2908 root->SetHasRenderSurface(true); |
| 2908 DidDrawCheckLayer* top_layer = | 2909 DidDrawCheckLayer* top_layer = |
| 2909 static_cast<DidDrawCheckLayer*>(root->children()[1]); | 2910 static_cast<DidDrawCheckLayer*>(root->children()[1].get()); |
| 2910 // This layer covers the occluded_layer above. Make this layer large so it can | 2911 // This layer covers the occluded_layer above. Make this layer large so it can |
| 2911 // occlude. | 2912 // occlude. |
| 2912 top_layer->SetBounds(big_size); | 2913 top_layer->SetBounds(big_size); |
| 2913 top_layer->SetContentsOpaque(true); | 2914 top_layer->SetContentsOpaque(true); |
| 2914 | 2915 |
| 2915 LayerTreeHostImpl::FrameData frame; | 2916 LayerTreeHostImpl::FrameData frame; |
| 2916 | 2917 |
| 2917 EXPECT_FALSE(occluded_layer->will_draw_called()); | 2918 EXPECT_FALSE(occluded_layer->will_draw_called()); |
| 2918 EXPECT_FALSE(occluded_layer->did_draw_called()); | 2919 EXPECT_FALSE(occluded_layer->did_draw_called()); |
| 2919 EXPECT_FALSE(top_layer->will_draw_called()); | 2920 EXPECT_FALSE(top_layer->will_draw_called()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2931 | 2932 |
| 2932 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { | 2933 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { |
| 2933 host_impl_->active_tree()->SetRootLayer( | 2934 host_impl_->active_tree()->SetRootLayer( |
| 2934 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 2935 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
| 2935 DidDrawCheckLayer* root = | 2936 DidDrawCheckLayer* root = |
| 2936 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2937 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 2937 | 2938 |
| 2938 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 2939 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
| 2939 root->SetHasRenderSurface(true); | 2940 root->SetHasRenderSurface(true); |
| 2940 DidDrawCheckLayer* layer1 = | 2941 DidDrawCheckLayer* layer1 = |
| 2941 static_cast<DidDrawCheckLayer*>(root->children()[0]); | 2942 static_cast<DidDrawCheckLayer*>(root->children()[0].get()); |
| 2942 | 2943 |
| 2943 layer1->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); | 2944 layer1->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); |
| 2944 DidDrawCheckLayer* layer2 = | 2945 DidDrawCheckLayer* layer2 = |
| 2945 static_cast<DidDrawCheckLayer*>(layer1->children()[0]); | 2946 static_cast<DidDrawCheckLayer*>(layer1->children()[0].get()); |
| 2946 | 2947 |
| 2947 layer1->SetHasRenderSurface(true); | 2948 layer1->SetHasRenderSurface(true); |
| 2948 layer1->SetShouldFlattenTransform(true); | 2949 layer1->SetShouldFlattenTransform(true); |
| 2949 | 2950 |
| 2950 EXPECT_FALSE(root->did_draw_called()); | 2951 EXPECT_FALSE(root->did_draw_called()); |
| 2951 EXPECT_FALSE(layer1->did_draw_called()); | 2952 EXPECT_FALSE(layer1->did_draw_called()); |
| 2952 EXPECT_FALSE(layer2->did_draw_called()); | 2953 EXPECT_FALSE(layer2->did_draw_called()); |
| 2953 | 2954 |
| 2954 LayerTreeHostImpl::FrameData frame; | 2955 LayerTreeHostImpl::FrameData frame; |
| 2955 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( | 2956 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3105 | 3106 |
| 3106 LayerTreeHostImpl::FrameData frame; | 3107 LayerTreeHostImpl::FrameData frame; |
| 3107 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 3108 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
| 3108 host_impl_->DrawLayers(&frame); | 3109 host_impl_->DrawLayers(&frame); |
| 3109 host_impl_->DidDrawAllLayers(frame); | 3110 host_impl_->DidDrawAllLayers(frame); |
| 3110 host_impl_->SwapBuffers(frame); | 3111 host_impl_->SwapBuffers(frame); |
| 3111 | 3112 |
| 3112 for (size_t i = 0; i < cases.size(); ++i) { | 3113 for (size_t i = 0; i < cases.size(); ++i) { |
| 3113 const auto& testcase = cases[i]; | 3114 const auto& testcase = cases[i]; |
| 3114 std::vector<LayerImpl*> to_remove; | 3115 std::vector<LayerImpl*> to_remove; |
| 3115 for (auto* child : root->children()) | 3116 for (const auto& child : root->children()) |
| 3116 to_remove.push_back(child); | 3117 to_remove.push_back(child.get()); |
| 3117 for (auto* child : to_remove) | 3118 for (auto* child : to_remove) |
| 3118 root->RemoveChild(child); | 3119 root->RemoveChild(child); |
| 3119 | 3120 |
| 3120 std::ostringstream scope; | 3121 std::ostringstream scope; |
| 3121 scope << "Test case: " << i; | 3122 scope << "Test case: " << i; |
| 3122 SCOPED_TRACE(scope.str()); | 3123 SCOPED_TRACE(scope.str()); |
| 3123 | 3124 |
| 3124 root->AddChild(MissingTextureAnimatingLayer::Create( | 3125 root->AddChild(MissingTextureAnimatingLayer::Create( |
| 3125 host_impl_->active_tree(), 2, testcase.layer_before.has_missing_tile, | 3126 host_impl_->active_tree(), 2, testcase.layer_before.has_missing_tile, |
| 3126 testcase.layer_before.has_incomplete_tile, | 3127 testcase.layer_before.has_incomplete_tile, |
| 3127 testcase.layer_before.is_animating, host_impl_->resource_provider())); | 3128 testcase.layer_before.is_animating, host_impl_->resource_provider())); |
| 3128 DidDrawCheckLayer* before = | 3129 DidDrawCheckLayer* before = |
| 3129 static_cast<DidDrawCheckLayer*>(root->children().back()); | 3130 static_cast<DidDrawCheckLayer*>(root->children().back().get()); |
| 3130 if (testcase.layer_before.has_copy_request) | 3131 if (testcase.layer_before.has_copy_request) |
| 3131 before->AddCopyRequest(); | 3132 before->AddCopyRequest(); |
| 3132 | 3133 |
| 3133 root->AddChild(MissingTextureAnimatingLayer::Create( | 3134 root->AddChild(MissingTextureAnimatingLayer::Create( |
| 3134 host_impl_->active_tree(), 3, testcase.layer_between.has_missing_tile, | 3135 host_impl_->active_tree(), 3, testcase.layer_between.has_missing_tile, |
| 3135 testcase.layer_between.has_incomplete_tile, | 3136 testcase.layer_between.has_incomplete_tile, |
| 3136 testcase.layer_between.is_animating, host_impl_->resource_provider())); | 3137 testcase.layer_between.is_animating, host_impl_->resource_provider())); |
| 3137 DidDrawCheckLayer* between = | 3138 DidDrawCheckLayer* between = |
| 3138 static_cast<DidDrawCheckLayer*>(root->children().back()); | 3139 static_cast<DidDrawCheckLayer*>(root->children().back().get()); |
| 3139 if (testcase.layer_between.has_copy_request) | 3140 if (testcase.layer_between.has_copy_request) |
| 3140 between->AddCopyRequest(); | 3141 between->AddCopyRequest(); |
| 3141 | 3142 |
| 3142 root->AddChild(MissingTextureAnimatingLayer::Create( | 3143 root->AddChild(MissingTextureAnimatingLayer::Create( |
| 3143 host_impl_->active_tree(), 4, testcase.layer_after.has_missing_tile, | 3144 host_impl_->active_tree(), 4, testcase.layer_after.has_missing_tile, |
| 3144 testcase.layer_after.has_incomplete_tile, | 3145 testcase.layer_after.has_incomplete_tile, |
| 3145 testcase.layer_after.is_animating, host_impl_->resource_provider())); | 3146 testcase.layer_after.is_animating, host_impl_->resource_provider())); |
| 3146 DidDrawCheckLayer* after = | 3147 DidDrawCheckLayer* after = |
| 3147 static_cast<DidDrawCheckLayer*>(root->children().back()); | 3148 static_cast<DidDrawCheckLayer*>(root->children().back().get()); |
| 3148 if (testcase.layer_after.has_copy_request) | 3149 if (testcase.layer_after.has_copy_request) |
| 3149 after->AddCopyRequest(); | 3150 after->AddCopyRequest(); |
| 3150 | 3151 |
| 3151 if (testcase.high_res_required) | 3152 if (testcase.high_res_required) |
| 3152 host_impl_->SetRequiresHighResToDraw(); | 3153 host_impl_->SetRequiresHighResToDraw(); |
| 3153 | 3154 |
| 3154 LayerTreeHostImpl::FrameData frame; | 3155 LayerTreeHostImpl::FrameData frame; |
| 3155 EXPECT_EQ(testcase.expected_result, PrepareToDrawFrame(&frame)); | 3156 EXPECT_EQ(testcase.expected_result, PrepareToDrawFrame(&frame)); |
| 3156 host_impl_->DrawLayers(&frame); | 3157 host_impl_->DrawLayers(&frame); |
| 3157 host_impl_->DidDrawAllLayers(frame); | 3158 host_impl_->DidDrawAllLayers(frame); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3198 | 3199 |
| 3199 LayerTreeHostImpl::FrameData frame; | 3200 LayerTreeHostImpl::FrameData frame; |
| 3200 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 3201 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
| 3201 host_impl_->DrawLayers(&frame); | 3202 host_impl_->DrawLayers(&frame); |
| 3202 host_impl_->DidDrawAllLayers(frame); | 3203 host_impl_->DidDrawAllLayers(frame); |
| 3203 host_impl_->SwapBuffers(frame); | 3204 host_impl_->SwapBuffers(frame); |
| 3204 | 3205 |
| 3205 for (size_t i = 0; i < cases.size(); ++i) { | 3206 for (size_t i = 0; i < cases.size(); ++i) { |
| 3206 const auto& testcase = cases[i]; | 3207 const auto& testcase = cases[i]; |
| 3207 std::vector<LayerImpl*> to_remove; | 3208 std::vector<LayerImpl*> to_remove; |
| 3208 for (auto* child : root->children()) | 3209 for (const auto& child : root->children()) |
| 3209 to_remove.push_back(child); | 3210 to_remove.push_back(child.get()); |
| 3210 for (auto* child : to_remove) | 3211 for (auto* child : to_remove) |
| 3211 root->RemoveChild(child); | 3212 root->RemoveChild(child); |
| 3212 | 3213 |
| 3213 std::ostringstream scope; | 3214 std::ostringstream scope; |
| 3214 scope << "Test case: " << i; | 3215 scope << "Test case: " << i; |
| 3215 SCOPED_TRACE(scope.str()); | 3216 SCOPED_TRACE(scope.str()); |
| 3216 | 3217 |
| 3217 root->AddChild(MissingTextureAnimatingLayer::Create( | 3218 root->AddChild(MissingTextureAnimatingLayer::Create( |
| 3218 host_impl_->active_tree(), 2, testcase.layer_before.has_missing_tile, | 3219 host_impl_->active_tree(), 2, testcase.layer_before.has_missing_tile, |
| 3219 testcase.layer_before.has_incomplete_tile, | 3220 testcase.layer_before.has_incomplete_tile, |
| 3220 testcase.layer_before.is_animating, host_impl_->resource_provider())); | 3221 testcase.layer_before.is_animating, host_impl_->resource_provider())); |
| 3221 DidDrawCheckLayer* before = | 3222 DidDrawCheckLayer* before = |
| 3222 static_cast<DidDrawCheckLayer*>(root->children().back()); | 3223 static_cast<DidDrawCheckLayer*>(root->children().back().get()); |
| 3223 if (testcase.layer_before.has_copy_request) | 3224 if (testcase.layer_before.has_copy_request) |
| 3224 before->AddCopyRequest(); | 3225 before->AddCopyRequest(); |
| 3225 | 3226 |
| 3226 root->AddChild(MissingTextureAnimatingLayer::Create( | 3227 root->AddChild(MissingTextureAnimatingLayer::Create( |
| 3227 host_impl_->active_tree(), 3, testcase.layer_between.has_missing_tile, | 3228 host_impl_->active_tree(), 3, testcase.layer_between.has_missing_tile, |
| 3228 testcase.layer_between.has_incomplete_tile, | 3229 testcase.layer_between.has_incomplete_tile, |
| 3229 testcase.layer_between.is_animating, host_impl_->resource_provider())); | 3230 testcase.layer_between.is_animating, host_impl_->resource_provider())); |
| 3230 DidDrawCheckLayer* between = | 3231 DidDrawCheckLayer* between = |
| 3231 static_cast<DidDrawCheckLayer*>(root->children().back()); | 3232 static_cast<DidDrawCheckLayer*>(root->children().back().get()); |
| 3232 if (testcase.layer_between.has_copy_request) | 3233 if (testcase.layer_between.has_copy_request) |
| 3233 between->AddCopyRequest(); | 3234 between->AddCopyRequest(); |
| 3234 | 3235 |
| 3235 root->AddChild(MissingTextureAnimatingLayer::Create( | 3236 root->AddChild(MissingTextureAnimatingLayer::Create( |
| 3236 host_impl_->active_tree(), 4, testcase.layer_after.has_missing_tile, | 3237 host_impl_->active_tree(), 4, testcase.layer_after.has_missing_tile, |
| 3237 testcase.layer_after.has_incomplete_tile, | 3238 testcase.layer_after.has_incomplete_tile, |
| 3238 testcase.layer_after.is_animating, host_impl_->resource_provider())); | 3239 testcase.layer_after.is_animating, host_impl_->resource_provider())); |
| 3239 DidDrawCheckLayer* after = | 3240 DidDrawCheckLayer* after = |
| 3240 static_cast<DidDrawCheckLayer*>(root->children().back()); | 3241 static_cast<DidDrawCheckLayer*>(root->children().back().get()); |
| 3241 if (testcase.layer_after.has_copy_request) | 3242 if (testcase.layer_after.has_copy_request) |
| 3242 after->AddCopyRequest(); | 3243 after->AddCopyRequest(); |
| 3243 | 3244 |
| 3244 if (testcase.high_res_required) | 3245 if (testcase.high_res_required) |
| 3245 host_impl_->SetRequiresHighResToDraw(); | 3246 host_impl_->SetRequiresHighResToDraw(); |
| 3246 | 3247 |
| 3247 LayerTreeHostImpl::FrameData frame; | 3248 LayerTreeHostImpl::FrameData frame; |
| 3248 EXPECT_EQ(testcase.expected_result, PrepareToDrawFrame(&frame)); | 3249 EXPECT_EQ(testcase.expected_result, PrepareToDrawFrame(&frame)); |
| 3249 host_impl_->DrawLayers(&frame); | 3250 host_impl_->DrawLayers(&frame); |
| 3250 host_impl_->DidDrawAllLayers(frame); | 3251 host_impl_->DidDrawAllLayers(frame); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3382 HidingTopControlsExpandsScrollableSize) { | 3383 HidingTopControlsExpandsScrollableSize) { |
| 3383 SetupTopControlsAndScrollLayerWithVirtualViewport( | 3384 SetupTopControlsAndScrollLayerWithVirtualViewport( |
| 3384 gfx::Size(50, 50), gfx::Size(50, 50), gfx::Size(50, 50)); | 3385 gfx::Size(50, 50), gfx::Size(50, 50), gfx::Size(50, 50)); |
| 3385 | 3386 |
| 3386 LayerTreeImpl* active_tree = host_impl_->active_tree(); | 3387 LayerTreeImpl* active_tree = host_impl_->active_tree(); |
| 3387 | 3388 |
| 3388 // Create a content layer beneath the outer viewport scroll layer. | 3389 // Create a content layer beneath the outer viewport scroll layer. |
| 3389 int id = host_impl_->OuterViewportScrollLayer()->id(); | 3390 int id = host_impl_->OuterViewportScrollLayer()->id(); |
| 3390 host_impl_->OuterViewportScrollLayer()->AddChild( | 3391 host_impl_->OuterViewportScrollLayer()->AddChild( |
| 3391 LayerImpl::Create(host_impl_->active_tree(), id + 2)); | 3392 LayerImpl::Create(host_impl_->active_tree(), id + 2)); |
| 3392 LayerImpl* content = active_tree->OuterViewportScrollLayer()->children()[0]; | 3393 LayerImpl* content = |
| 3394 active_tree->OuterViewportScrollLayer()->children()[0].get(); |
| 3393 content->SetBounds(gfx::Size(50, 50)); | 3395 content->SetBounds(gfx::Size(50, 50)); |
| 3394 | 3396 |
| 3395 DrawFrame(); | 3397 DrawFrame(); |
| 3396 | 3398 |
| 3397 LayerImpl* inner_container = active_tree->InnerViewportContainerLayer(); | 3399 LayerImpl* inner_container = active_tree->InnerViewportContainerLayer(); |
| 3398 LayerImpl* outer_container = active_tree->OuterViewportContainerLayer(); | 3400 LayerImpl* outer_container = active_tree->OuterViewportContainerLayer(); |
| 3399 | 3401 |
| 3400 // The top controls should start off showing so the viewport should be shrunk. | 3402 // The top controls should start off showing so the viewport should be shrunk. |
| 3401 ASSERT_EQ(gfx::Size(50, 50), inner_container->bounds()); | 3403 ASSERT_EQ(gfx::Size(50, 50), inner_container->bounds()); |
| 3402 ASSERT_EQ(gfx::Size(50, 50), outer_container->bounds()); | 3404 ASSERT_EQ(gfx::Size(50, 50), outer_container->bounds()); |
| (...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4216 default_page_scale_matrix.Scale(default_page_scale, default_page_scale); | 4218 default_page_scale_matrix.Scale(default_page_scale, default_page_scale); |
| 4217 | 4219 |
| 4218 float new_page_scale = 2.f; | 4220 float new_page_scale = 2.f; |
| 4219 gfx::Transform new_page_scale_matrix; | 4221 gfx::Transform new_page_scale_matrix; |
| 4220 new_page_scale_matrix.Scale(new_page_scale, new_page_scale); | 4222 new_page_scale_matrix.Scale(new_page_scale, new_page_scale); |
| 4221 | 4223 |
| 4222 // Create a normal scrollable root layer and another scrollable child layer. | 4224 // Create a normal scrollable root layer and another scrollable child layer. |
| 4223 LayerImpl* scroll = SetupScrollAndContentsLayers(surface_size); | 4225 LayerImpl* scroll = SetupScrollAndContentsLayers(surface_size); |
| 4224 scroll->SetDrawsContent(true); | 4226 scroll->SetDrawsContent(true); |
| 4225 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 4227 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 4226 LayerImpl* child = scroll->children()[0]; | 4228 LayerImpl* child = scroll->children()[0].get(); |
| 4227 child->SetDrawsContent(true); | 4229 child->SetDrawsContent(true); |
| 4228 | 4230 |
| 4229 scoped_ptr<LayerImpl> scrollable_child_clip = | 4231 scoped_ptr<LayerImpl> scrollable_child_clip = |
| 4230 LayerImpl::Create(host_impl_->active_tree(), 6); | 4232 LayerImpl::Create(host_impl_->active_tree(), 6); |
| 4231 scoped_ptr<LayerImpl> scrollable_child = | 4233 scoped_ptr<LayerImpl> scrollable_child = |
| 4232 CreateScrollableLayer(7, surface_size, scrollable_child_clip.get()); | 4234 CreateScrollableLayer(7, surface_size, scrollable_child_clip.get()); |
| 4233 scrollable_child_clip->AddChild(scrollable_child.Pass()); | 4235 scrollable_child_clip->AddChild(scrollable_child.Pass()); |
| 4234 child->AddChild(scrollable_child_clip.Pass()); | 4236 child->AddChild(scrollable_child_clip.Pass()); |
| 4235 LayerImpl* grand_child = child->children()[0]; | 4237 LayerImpl* grand_child = child->children()[0].get(); |
| 4236 grand_child->SetDrawsContent(true); | 4238 grand_child->SetDrawsContent(true); |
| 4237 | 4239 |
| 4238 // Set new page scale on impl thread by pinching. | 4240 // Set new page scale on impl thread by pinching. |
| 4239 RebuildPropertyTrees(); | 4241 RebuildPropertyTrees(); |
| 4240 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE); | 4242 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE); |
| 4241 host_impl_->PinchGestureBegin(); | 4243 host_impl_->PinchGestureBegin(); |
| 4242 host_impl_->PinchGestureUpdate(new_page_scale, gfx::Point()); | 4244 host_impl_->PinchGestureUpdate(new_page_scale, gfx::Point()); |
| 4243 host_impl_->PinchGestureEnd(); | 4245 host_impl_->PinchGestureEnd(); |
| 4244 host_impl_->ScrollEnd(); | 4246 host_impl_->ScrollEnd(); |
| 4245 DrawOneFrame(); | 4247 DrawOneFrame(); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4329 gfx::Vector2d scroll_delta(-8, -7); | 4331 gfx::Vector2d scroll_delta(-8, -7); |
| 4330 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 4332 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
| 4331 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 4333 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); |
| 4332 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 4334 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 4333 host_impl_->ScrollEnd(); | 4335 host_impl_->ScrollEnd(); |
| 4334 | 4336 |
| 4335 scoped_ptr<ScrollAndScaleSet> scroll_info = | 4337 scoped_ptr<ScrollAndScaleSet> scroll_info = |
| 4336 host_impl_->ProcessScrollDeltas(); | 4338 host_impl_->ProcessScrollDeltas(); |
| 4337 | 4339 |
| 4338 // The grand child should have scrolled up to its limit. | 4340 // The grand child should have scrolled up to its limit. |
| 4339 LayerImpl* child = host_impl_->active_tree()->root_layer()->children()[0]; | 4341 LayerImpl* child = |
| 4340 LayerImpl* grand_child = child->children()[0]; | 4342 host_impl_->active_tree()->root_layer()->children()[0].get(); |
| 4343 LayerImpl* grand_child = child->children()[0].get(); |
| 4341 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), | 4344 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), |
| 4342 gfx::Vector2d(0, -5))); | 4345 gfx::Vector2d(0, -5))); |
| 4343 | 4346 |
| 4344 // The child should not have scrolled. | 4347 // The child should not have scrolled. |
| 4345 ExpectNone(*scroll_info.get(), child->id()); | 4348 ExpectNone(*scroll_info.get(), child->id()); |
| 4346 } | 4349 } |
| 4347 } | 4350 } |
| 4348 | 4351 |
| 4349 TEST_F(LayerTreeHostImplTest, ScrollWithoutBubbling) { | 4352 TEST_F(LayerTreeHostImplTest, ScrollWithoutBubbling) { |
| 4350 // Scroll a child layer beyond its maximum scroll range and make sure the | 4353 // Scroll a child layer beyond its maximum scroll range and make sure the |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4385 host_impl_->ScrollBegin(gfx::Point(), | 4388 host_impl_->ScrollBegin(gfx::Point(), |
| 4386 InputHandler::NON_BUBBLING_GESTURE)); | 4389 InputHandler::NON_BUBBLING_GESTURE)); |
| 4387 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 4390 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 4388 host_impl_->ScrollEnd(); | 4391 host_impl_->ScrollEnd(); |
| 4389 | 4392 |
| 4390 scoped_ptr<ScrollAndScaleSet> scroll_info = | 4393 scoped_ptr<ScrollAndScaleSet> scroll_info = |
| 4391 host_impl_->ProcessScrollDeltas(); | 4394 host_impl_->ProcessScrollDeltas(); |
| 4392 | 4395 |
| 4393 // The grand child should have scrolled up to its limit. | 4396 // The grand child should have scrolled up to its limit. |
| 4394 LayerImpl* child = | 4397 LayerImpl* child = |
| 4395 host_impl_->active_tree()->root_layer()->children()[0]->children()[0]; | 4398 host_impl_->active_tree()->root_layer()->children()[0]->children() |
| 4396 LayerImpl* grand_child = child->children()[0]; | 4399 [0].get(); |
| 4400 LayerImpl* grand_child = child->children()[0].get(); |
| 4397 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), | 4401 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), |
| 4398 gfx::Vector2d(0, -2))); | 4402 gfx::Vector2d(0, -2))); |
| 4399 | 4403 |
| 4400 // The child should not have scrolled. | 4404 // The child should not have scrolled. |
| 4401 ExpectNone(*scroll_info.get(), child->id()); | 4405 ExpectNone(*scroll_info.get(), child->id()); |
| 4402 | 4406 |
| 4403 // The next time we scroll we should only scroll the parent. | 4407 // The next time we scroll we should only scroll the parent. |
| 4404 scroll_delta = gfx::Vector2d(0, -3); | 4408 scroll_delta = gfx::Vector2d(0, -3); |
| 4405 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 4409 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
| 4406 host_impl_->ScrollBegin(gfx::Point(5, 5), | 4410 host_impl_->ScrollBegin(gfx::Point(5, 5), |
| (...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5361 root->SetHasRenderSurface(true); | 5365 root->SetHasRenderSurface(true); |
| 5362 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 5366 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 5363 } | 5367 } |
| 5364 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 5368 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 5365 | 5369 |
| 5366 root->AddChild( | 5370 root->AddChild( |
| 5367 BlendStateCheckLayer::Create(host_impl_->active_tree(), | 5371 BlendStateCheckLayer::Create(host_impl_->active_tree(), |
| 5368 2, | 5372 2, |
| 5369 host_impl_->resource_provider())); | 5373 host_impl_->resource_provider())); |
| 5370 BlendStateCheckLayer* layer1 = | 5374 BlendStateCheckLayer* layer1 = |
| 5371 static_cast<BlendStateCheckLayer*>(root->children()[0]); | 5375 static_cast<BlendStateCheckLayer*>(root->children()[0].get()); |
| 5372 layer1->SetPosition(gfx::PointF(2.f, 2.f)); | 5376 layer1->SetPosition(gfx::PointF(2.f, 2.f)); |
| 5373 | 5377 |
| 5374 LayerTreeHostImpl::FrameData frame; | 5378 LayerTreeHostImpl::FrameData frame; |
| 5375 | 5379 |
| 5376 // Opaque layer, drawn without blending. | 5380 // Opaque layer, drawn without blending. |
| 5377 layer1->SetContentsOpaque(true); | 5381 layer1->SetContentsOpaque(true); |
| 5378 layer1->SetExpectation(false, false); | 5382 layer1->SetExpectation(false, false); |
| 5379 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 5383 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
| 5380 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 5384 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
| 5381 host_impl_->DrawLayers(&frame); | 5385 host_impl_->DrawLayers(&frame); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 5409 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 5413 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
| 5410 host_impl_->DrawLayers(&frame); | 5414 host_impl_->DrawLayers(&frame); |
| 5411 EXPECT_TRUE(layer1->quads_appended()); | 5415 EXPECT_TRUE(layer1->quads_appended()); |
| 5412 host_impl_->DidDrawAllLayers(frame); | 5416 host_impl_->DidDrawAllLayers(frame); |
| 5413 | 5417 |
| 5414 layer1->AddChild( | 5418 layer1->AddChild( |
| 5415 BlendStateCheckLayer::Create(host_impl_->active_tree(), | 5419 BlendStateCheckLayer::Create(host_impl_->active_tree(), |
| 5416 3, | 5420 3, |
| 5417 host_impl_->resource_provider())); | 5421 host_impl_->resource_provider())); |
| 5418 BlendStateCheckLayer* layer2 = | 5422 BlendStateCheckLayer* layer2 = |
| 5419 static_cast<BlendStateCheckLayer*>(layer1->children()[0]); | 5423 static_cast<BlendStateCheckLayer*>(layer1->children()[0].get()); |
| 5420 layer2->SetPosition(gfx::PointF(4.f, 4.f)); | 5424 layer2->SetPosition(gfx::PointF(4.f, 4.f)); |
| 5421 | 5425 |
| 5422 // 2 opaque layers, drawn without blending. | 5426 // 2 opaque layers, drawn without blending. |
| 5423 layer1->SetContentsOpaque(true); | 5427 layer1->SetContentsOpaque(true); |
| 5424 layer1->SetOpacity(1.f); | 5428 layer1->SetOpacity(1.f); |
| 5425 layer1->SetExpectation(false, false); | 5429 layer1->SetExpectation(false, false); |
| 5426 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 5430 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
| 5427 layer2->SetContentsOpaque(true); | 5431 layer2->SetContentsOpaque(true); |
| 5428 layer2->SetOpacity(1.f); | 5432 layer2->SetOpacity(1.f); |
| 5429 layer2->SetExpectation(false, false); | 5433 layer2->SetExpectation(false, false); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5597 void SetupActiveTreeLayers() { | 5601 void SetupActiveTreeLayers() { |
| 5598 host_impl_->active_tree()->set_background_color(SK_ColorGRAY); | 5602 host_impl_->active_tree()->set_background_color(SK_ColorGRAY); |
| 5599 host_impl_->active_tree()->SetRootLayer( | 5603 host_impl_->active_tree()->SetRootLayer( |
| 5600 LayerImpl::Create(host_impl_->active_tree(), 1)); | 5604 LayerImpl::Create(host_impl_->active_tree(), 1)); |
| 5601 host_impl_->active_tree()->root_layer()->SetHasRenderSurface(true); | 5605 host_impl_->active_tree()->root_layer()->SetHasRenderSurface(true); |
| 5602 host_impl_->active_tree()->root_layer()->AddChild( | 5606 host_impl_->active_tree()->root_layer()->AddChild( |
| 5603 BlendStateCheckLayer::Create(host_impl_->active_tree(), | 5607 BlendStateCheckLayer::Create(host_impl_->active_tree(), |
| 5604 2, | 5608 2, |
| 5605 host_impl_->resource_provider())); | 5609 host_impl_->resource_provider())); |
| 5606 child_ = static_cast<BlendStateCheckLayer*>( | 5610 child_ = static_cast<BlendStateCheckLayer*>( |
| 5607 host_impl_->active_tree()->root_layer()->children()[0]); | 5611 host_impl_->active_tree()->root_layer()->children()[0].get()); |
| 5608 child_->SetExpectation(false, false); | 5612 child_->SetExpectation(false, false); |
| 5609 child_->SetContentsOpaque(true); | 5613 child_->SetContentsOpaque(true); |
| 5610 } | 5614 } |
| 5611 | 5615 |
| 5612 // Expect no gutter rects. | 5616 // Expect no gutter rects. |
| 5613 void TestLayerCoversFullViewport() { | 5617 void TestLayerCoversFullViewport() { |
| 5614 gfx::Rect layer_rect(viewport_size_); | 5618 gfx::Rect layer_rect(viewport_size_); |
| 5615 child_->SetPosition(gfx::PointF(layer_rect.origin())); | 5619 child_->SetPosition(gfx::PointF(layer_rect.origin())); |
| 5616 child_->SetBounds(layer_rect.size()); | 5620 child_->SetBounds(layer_rect.size()); |
| 5617 child_->SetQuadRect(gfx::Rect(layer_rect.size())); | 5621 child_->SetQuadRect(gfx::Rect(layer_rect.size())); |
| (...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6425 LayerTreeHostImpl::FrameData frame; | 6429 LayerTreeHostImpl::FrameData frame; |
| 6426 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6430 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
| 6427 | 6431 |
| 6428 if (!expect_to_draw) { | 6432 if (!expect_to_draw) { |
| 6429 // With no damage, we don't draw, and no quads are created. | 6433 // With no damage, we don't draw, and no quads are created. |
| 6430 ASSERT_EQ(0u, frame.render_passes.size()); | 6434 ASSERT_EQ(0u, frame.render_passes.size()); |
| 6431 } else { | 6435 } else { |
| 6432 ASSERT_EQ(1u, frame.render_passes.size()); | 6436 ASSERT_EQ(1u, frame.render_passes.size()); |
| 6433 | 6437 |
| 6434 // Verify the damage rect for the root render pass. | 6438 // Verify the damage rect for the root render pass. |
| 6435 const RenderPass* root_render_pass = frame.render_passes.back(); | 6439 const RenderPass* root_render_pass = frame.render_passes.back().get(); |
| 6436 EXPECT_EQ(expected_damage, root_render_pass->damage_rect); | 6440 EXPECT_EQ(expected_damage, root_render_pass->damage_rect); |
| 6437 | 6441 |
| 6438 // Verify the root and child layers' quads are generated and not being | 6442 // Verify the root and child layers' quads are generated and not being |
| 6439 // culled. | 6443 // culled. |
| 6440 ASSERT_EQ(2u, root_render_pass->quad_list.size()); | 6444 ASSERT_EQ(2u, root_render_pass->quad_list.size()); |
| 6441 | 6445 |
| 6442 LayerImpl* child = host_impl_->active_tree()->root_layer()->children()[0]; | 6446 LayerImpl* child = |
| 6447 host_impl_->active_tree()->root_layer()->children()[0].get(); |
| 6443 gfx::Rect expected_child_visible_rect(child->bounds()); | 6448 gfx::Rect expected_child_visible_rect(child->bounds()); |
| 6444 EXPECT_EQ(expected_child_visible_rect, | 6449 EXPECT_EQ(expected_child_visible_rect, |
| 6445 root_render_pass->quad_list.front()->visible_rect); | 6450 root_render_pass->quad_list.front()->visible_rect); |
| 6446 | 6451 |
| 6447 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 6452 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 6448 gfx::Rect expected_root_visible_rect(root->bounds()); | 6453 gfx::Rect expected_root_visible_rect(root->bounds()); |
| 6449 EXPECT_EQ(expected_root_visible_rect, | 6454 EXPECT_EQ(expected_root_visible_rect, |
| 6450 root_render_pass->quad_list.ElementAt(1)->visible_rect); | 6455 root_render_pass->quad_list.ElementAt(1)->visible_rect); |
| 6451 } | 6456 } |
| 6452 | 6457 |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6874 | 6879 |
| 6875 TEST_F(LayerTreeHostImplTest, ShutdownReleasesContext) { | 6880 TEST_F(LayerTreeHostImplTest, ShutdownReleasesContext) { |
| 6876 scoped_refptr<TestContextProvider> context_provider = | 6881 scoped_refptr<TestContextProvider> context_provider = |
| 6877 TestContextProvider::Create(); | 6882 TestContextProvider::Create(); |
| 6878 | 6883 |
| 6879 CreateHostImpl(DefaultSettings(), | 6884 CreateHostImpl(DefaultSettings(), |
| 6880 FakeOutputSurface::Create3d(context_provider)); | 6885 FakeOutputSurface::Create3d(context_provider)); |
| 6881 | 6886 |
| 6882 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); | 6887 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); |
| 6883 | 6888 |
| 6884 ScopedPtrVector<CopyOutputRequest> requests; | 6889 std::vector<scoped_ptr<CopyOutputRequest>> requests; |
| 6885 requests.push_back(CopyOutputRequest::CreateRequest( | 6890 requests.push_back(CopyOutputRequest::CreateRequest( |
| 6886 base::Bind(&ShutdownReleasesContext_Callback))); | 6891 base::Bind(&ShutdownReleasesContext_Callback))); |
| 6887 | 6892 |
| 6888 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 6893 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 6889 root->PassCopyRequests(&requests); | 6894 root->PassCopyRequests(&requests); |
| 6890 root->set_num_layer_or_descendant_with_copy_request(1); | 6895 root->set_num_layer_or_descendant_with_copy_request(1); |
| 6891 | 6896 |
| 6892 LayerTreeHostImpl::FrameData frame; | 6897 LayerTreeHostImpl::FrameData frame; |
| 6893 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6898 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
| 6894 host_impl_->DrawLayers(&frame); | 6899 host_impl_->DrawLayers(&frame); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6973 | 6978 |
| 6974 root_scrolling->AddChild(child.Pass()); | 6979 root_scrolling->AddChild(child.Pass()); |
| 6975 root->AddChild(root_scrolling.Pass()); | 6980 root->AddChild(root_scrolling.Pass()); |
| 6976 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 6981 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 6977 host_impl_->active_tree()->DidBecomeActive(); | 6982 host_impl_->active_tree()->DidBecomeActive(); |
| 6978 host_impl_->SetViewportSize(surface_size); | 6983 host_impl_->SetViewportSize(surface_size); |
| 6979 DrawFrame(); | 6984 DrawFrame(); |
| 6980 { | 6985 { |
| 6981 scoped_ptr<ScrollAndScaleSet> scroll_info; | 6986 scoped_ptr<ScrollAndScaleSet> scroll_info; |
| 6982 LayerImpl* child = | 6987 LayerImpl* child = |
| 6983 host_impl_->active_tree()->root_layer()->children()[0]->children()[0]; | 6988 host_impl_->active_tree()->root_layer()->children()[0]->children() |
| 6984 LayerImpl* grand_child = child->children()[0]; | 6989 [0].get(); |
| 6990 LayerImpl* grand_child = child->children()[0].get(); |
| 6985 | 6991 |
| 6986 gfx::Vector2d scroll_delta(0, -2); | 6992 gfx::Vector2d scroll_delta(0, -2); |
| 6987 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 6993 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
| 6988 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 6994 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
| 6989 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll); | 6995 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll); |
| 6990 | 6996 |
| 6991 // The grand child should have scrolled up to its limit. | 6997 // The grand child should have scrolled up to its limit. |
| 6992 scroll_info = host_impl_->ProcessScrollDeltas(); | 6998 scroll_info = host_impl_->ProcessScrollDeltas(); |
| 6993 ASSERT_EQ(1u, scroll_info->scrolls.size()); | 6999 ASSERT_EQ(1u, scroll_info->scrolls.size()); |
| 6994 EXPECT_TRUE( | 7000 EXPECT_TRUE( |
| (...skipping 1317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8312 { | 8318 { |
| 8313 LayerTreeHostImpl::FrameData frame; | 8319 LayerTreeHostImpl::FrameData frame; |
| 8314 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 8320 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
| 8315 EXPECT_TRUE(frame.has_no_damage); | 8321 EXPECT_TRUE(frame.has_no_damage); |
| 8316 } | 8322 } |
| 8317 } | 8323 } |
| 8318 | 8324 |
| 8319 TEST_F(LayerTreeHostImplTest, ExternalViewportAffectsVisibleRects) { | 8325 TEST_F(LayerTreeHostImplTest, ExternalViewportAffectsVisibleRects) { |
| 8320 const gfx::Size layer_size(100, 100); | 8326 const gfx::Size layer_size(100, 100); |
| 8321 SetupScrollAndContentsLayers(layer_size); | 8327 SetupScrollAndContentsLayers(layer_size); |
| 8322 LayerImpl* content_layer = | 8328 LayerImpl* content_layer = host_impl_->active_tree() |
| 8323 host_impl_->active_tree()->OuterViewportScrollLayer()->children()[0]; | 8329 ->OuterViewportScrollLayer() |
| 8330 ->children()[0] |
| 8331 .get(); |
| 8324 RebuildPropertyTrees(); | 8332 RebuildPropertyTrees(); |
| 8325 | 8333 |
| 8326 bool update_lcd_text = false; | 8334 bool update_lcd_text = false; |
| 8327 | 8335 |
| 8328 host_impl_->SetViewportSize(gfx::Size(90, 90)); | 8336 host_impl_->SetViewportSize(gfx::Size(90, 90)); |
| 8329 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); | 8337 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); |
| 8330 EXPECT_EQ(gfx::Rect(90, 90), content_layer->visible_layer_rect()); | 8338 EXPECT_EQ(gfx::Rect(90, 90), content_layer->visible_layer_rect()); |
| 8331 | 8339 |
| 8332 gfx::Transform external_transform; | 8340 gfx::Transform external_transform; |
| 8333 gfx::Rect external_viewport(10, 20); | 8341 gfx::Rect external_viewport(10, 20); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 8347 external_transform, external_viewport, external_clip, external_viewport, | 8355 external_transform, external_viewport, external_clip, external_viewport, |
| 8348 external_transform, resourceless_software_draw); | 8356 external_transform, resourceless_software_draw); |
| 8349 | 8357 |
| 8350 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); | 8358 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); |
| 8351 EXPECT_EQ(gfx::Rect(90, 90), content_layer->visible_layer_rect()); | 8359 EXPECT_EQ(gfx::Rect(90, 90), content_layer->visible_layer_rect()); |
| 8352 } | 8360 } |
| 8353 | 8361 |
| 8354 TEST_F(LayerTreeHostImplTest, ExternalTransformAffectsVisibleRects) { | 8362 TEST_F(LayerTreeHostImplTest, ExternalTransformAffectsVisibleRects) { |
| 8355 const gfx::Size layer_size(100, 100); | 8363 const gfx::Size layer_size(100, 100); |
| 8356 SetupScrollAndContentsLayers(layer_size); | 8364 SetupScrollAndContentsLayers(layer_size); |
| 8357 LayerImpl* content_layer = | 8365 LayerImpl* content_layer = host_impl_->active_tree() |
| 8358 host_impl_->active_tree()->OuterViewportScrollLayer()->children()[0]; | 8366 ->OuterViewportScrollLayer() |
| 8367 ->children()[0] |
| 8368 .get(); |
| 8359 RebuildPropertyTrees(); | 8369 RebuildPropertyTrees(); |
| 8360 | 8370 |
| 8361 bool update_lcd_text = false; | 8371 bool update_lcd_text = false; |
| 8362 | 8372 |
| 8363 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 8373 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 8364 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); | 8374 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); |
| 8365 EXPECT_EQ(gfx::Rect(50, 50), content_layer->visible_layer_rect()); | 8375 EXPECT_EQ(gfx::Rect(50, 50), content_layer->visible_layer_rect()); |
| 8366 | 8376 |
| 8367 gfx::Transform external_transform; | 8377 gfx::Transform external_transform; |
| 8368 external_transform.Translate(10, 10); | 8378 external_transform.Translate(10, 10); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 8385 external_transform, external_viewport, external_clip, external_viewport, | 8395 external_transform, external_viewport, external_clip, external_viewport, |
| 8386 external_transform, resourceless_software_draw); | 8396 external_transform, resourceless_software_draw); |
| 8387 | 8397 |
| 8388 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); | 8398 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); |
| 8389 EXPECT_EQ(gfx::Rect(50, 50), content_layer->visible_layer_rect()); | 8399 EXPECT_EQ(gfx::Rect(50, 50), content_layer->visible_layer_rect()); |
| 8390 } | 8400 } |
| 8391 | 8401 |
| 8392 TEST_F(LayerTreeHostImplTest, ExternalTransformAffectsSublayerScaleFactor) { | 8402 TEST_F(LayerTreeHostImplTest, ExternalTransformAffectsSublayerScaleFactor) { |
| 8393 const gfx::Size layer_size(100, 100); | 8403 const gfx::Size layer_size(100, 100); |
| 8394 SetupScrollAndContentsLayers(layer_size); | 8404 SetupScrollAndContentsLayers(layer_size); |
| 8395 LayerImpl* content_layer = | 8405 LayerImpl* content_layer = host_impl_->active_tree() |
| 8396 host_impl_->active_tree()->OuterViewportScrollLayer()->children()[0]; | 8406 ->OuterViewportScrollLayer() |
| 8407 ->children()[0] |
| 8408 .get(); |
| 8397 content_layer->AddChild(LayerImpl::Create(host_impl_->active_tree(), 100)); | 8409 content_layer->AddChild(LayerImpl::Create(host_impl_->active_tree(), 100)); |
| 8398 LayerImpl* test_layer = host_impl_->active_tree()->LayerById(100); | 8410 LayerImpl* test_layer = host_impl_->active_tree()->LayerById(100); |
| 8399 test_layer->SetHasRenderSurface(true); | 8411 test_layer->SetHasRenderSurface(true); |
| 8400 test_layer->SetDrawsContent(true); | 8412 test_layer->SetDrawsContent(true); |
| 8401 test_layer->SetBounds(layer_size); | 8413 test_layer->SetBounds(layer_size); |
| 8402 gfx::Transform perspective_transform; | 8414 gfx::Transform perspective_transform; |
| 8403 perspective_transform.ApplyPerspectiveDepth(2); | 8415 perspective_transform.ApplyPerspectiveDepth(2); |
| 8404 test_layer->SetTransform(perspective_transform); | 8416 test_layer->SetTransform(perspective_transform); |
| 8405 | 8417 |
| 8406 RebuildPropertyTrees(); | 8418 RebuildPropertyTrees(); |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8704 // we go from having a valid output surface to not having a valid output | 8716 // we go from having a valid output surface to not having a valid output |
| 8705 // surface. | 8717 // surface. |
| 8706 EXPECT_EQ(0, num_lost_surfaces_); | 8718 EXPECT_EQ(0, num_lost_surfaces_); |
| 8707 host_impl_->DidLoseOutputSurface(); | 8719 host_impl_->DidLoseOutputSurface(); |
| 8708 EXPECT_EQ(1, num_lost_surfaces_); | 8720 EXPECT_EQ(1, num_lost_surfaces_); |
| 8709 host_impl_->DidLoseOutputSurface(); | 8721 host_impl_->DidLoseOutputSurface(); |
| 8710 EXPECT_LE(1, num_lost_surfaces_); | 8722 EXPECT_LE(1, num_lost_surfaces_); |
| 8711 } | 8723 } |
| 8712 | 8724 |
| 8713 size_t CountRenderPassesWithId(const RenderPassList& list, RenderPassId id) { | 8725 size_t CountRenderPassesWithId(const RenderPassList& list, RenderPassId id) { |
| 8714 return std::count_if(list.begin(), list.end(), | 8726 return std::count_if( |
| 8715 [id](const RenderPass* p) { return p->id == id; }); | 8727 list.begin(), list.end(), |
| 8728 [id](const scoped_ptr<RenderPass>& p) { return p->id == id; }); |
| 8716 } | 8729 } |
| 8717 | 8730 |
| 8718 TEST_F(LayerTreeHostImplTest, RemoveUnreferencedRenderPass) { | 8731 TEST_F(LayerTreeHostImplTest, RemoveUnreferencedRenderPass) { |
| 8719 LayerTreeHostImpl::FrameData frame; | 8732 LayerTreeHostImpl::FrameData frame; |
| 8720 frame.render_passes.push_back(RenderPass::Create()); | 8733 frame.render_passes.push_back(RenderPass::Create()); |
| 8721 RenderPass* pass3 = frame.render_passes.back(); | 8734 RenderPass* pass3 = frame.render_passes.back().get(); |
| 8722 frame.render_passes.push_back(RenderPass::Create()); | 8735 frame.render_passes.push_back(RenderPass::Create()); |
| 8723 RenderPass* pass2 = frame.render_passes.back(); | 8736 RenderPass* pass2 = frame.render_passes.back().get(); |
| 8724 frame.render_passes.push_back(RenderPass::Create()); | 8737 frame.render_passes.push_back(RenderPass::Create()); |
| 8725 RenderPass* pass1 = frame.render_passes.back(); | 8738 RenderPass* pass1 = frame.render_passes.back().get(); |
| 8726 | 8739 |
| 8727 pass1->SetNew(RenderPassId(1, 0), gfx::Rect(), gfx::Rect(), gfx::Transform()); | 8740 pass1->SetNew(RenderPassId(1, 0), gfx::Rect(), gfx::Rect(), gfx::Transform()); |
| 8728 pass2->SetNew(RenderPassId(2, 0), gfx::Rect(), gfx::Rect(), gfx::Transform()); | 8741 pass2->SetNew(RenderPassId(2, 0), gfx::Rect(), gfx::Rect(), gfx::Transform()); |
| 8729 pass3->SetNew(RenderPassId(3, 0), gfx::Rect(), gfx::Rect(), gfx::Transform()); | 8742 pass3->SetNew(RenderPassId(3, 0), gfx::Rect(), gfx::Rect(), gfx::Transform()); |
| 8730 | 8743 |
| 8731 // Add a quad to each pass so they aren't empty. | 8744 // Add a quad to each pass so they aren't empty. |
| 8732 SolidColorDrawQuad* color_quad; | 8745 SolidColorDrawQuad* color_quad; |
| 8733 color_quad = pass1->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 8746 color_quad = pass1->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
| 8734 color_quad->material = DrawQuad::SOLID_COLOR; | 8747 color_quad->material = DrawQuad::SOLID_COLOR; |
| 8735 color_quad = pass2->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 8748 color_quad = pass2->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 8751 EXPECT_EQ(0u, | 8764 EXPECT_EQ(0u, |
| 8752 CountRenderPassesWithId(frame.render_passes, RenderPassId(2, 0))); | 8765 CountRenderPassesWithId(frame.render_passes, RenderPassId(2, 0))); |
| 8753 EXPECT_EQ(0u, | 8766 EXPECT_EQ(0u, |
| 8754 CountRenderPassesWithId(frame.render_passes, RenderPassId(3, 0))); | 8767 CountRenderPassesWithId(frame.render_passes, RenderPassId(3, 0))); |
| 8755 EXPECT_EQ(RenderPassId(1, 0), frame.render_passes[0]->id); | 8768 EXPECT_EQ(RenderPassId(1, 0), frame.render_passes[0]->id); |
| 8756 } | 8769 } |
| 8757 | 8770 |
| 8758 TEST_F(LayerTreeHostImplTest, RemoveEmptyRenderPass) { | 8771 TEST_F(LayerTreeHostImplTest, RemoveEmptyRenderPass) { |
| 8759 LayerTreeHostImpl::FrameData frame; | 8772 LayerTreeHostImpl::FrameData frame; |
| 8760 frame.render_passes.push_back(RenderPass::Create()); | 8773 frame.render_passes.push_back(RenderPass::Create()); |
| 8761 RenderPass* pass3 = frame.render_passes.back(); | 8774 RenderPass* pass3 = frame.render_passes.back().get(); |
| 8762 frame.render_passes.push_back(RenderPass::Create()); | 8775 frame.render_passes.push_back(RenderPass::Create()); |
| 8763 RenderPass* pass2 = frame.render_passes.back(); | 8776 RenderPass* pass2 = frame.render_passes.back().get(); |
| 8764 frame.render_passes.push_back(RenderPass::Create()); | 8777 frame.render_passes.push_back(RenderPass::Create()); |
| 8765 RenderPass* pass1 = frame.render_passes.back(); | 8778 RenderPass* pass1 = frame.render_passes.back().get(); |
| 8766 | 8779 |
| 8767 pass1->SetNew(RenderPassId(1, 0), gfx::Rect(), gfx::Rect(), gfx::Transform()); | 8780 pass1->SetNew(RenderPassId(1, 0), gfx::Rect(), gfx::Rect(), gfx::Transform()); |
| 8768 pass2->SetNew(RenderPassId(2, 0), gfx::Rect(), gfx::Rect(), gfx::Transform()); | 8781 pass2->SetNew(RenderPassId(2, 0), gfx::Rect(), gfx::Rect(), gfx::Transform()); |
| 8769 pass3->SetNew(RenderPassId(3, 0), gfx::Rect(), gfx::Rect(), gfx::Transform()); | 8782 pass3->SetNew(RenderPassId(3, 0), gfx::Rect(), gfx::Rect(), gfx::Transform()); |
| 8770 | 8783 |
| 8771 // pass1 is not empty, but pass2 and pass3 are. | 8784 // pass1 is not empty, but pass2 and pass3 are. |
| 8772 SolidColorDrawQuad* color_quad; | 8785 SolidColorDrawQuad* color_quad; |
| 8773 color_quad = pass1->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 8786 color_quad = pass1->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
| 8774 color_quad->material = DrawQuad::SOLID_COLOR; | 8787 color_quad->material = DrawQuad::SOLID_COLOR; |
| 8775 | 8788 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 8796 CountRenderPassesWithId(frame.render_passes, RenderPassId(3, 0))); | 8809 CountRenderPassesWithId(frame.render_passes, RenderPassId(3, 0))); |
| 8797 EXPECT_EQ(RenderPassId(1, 0), frame.render_passes[0]->id); | 8810 EXPECT_EQ(RenderPassId(1, 0), frame.render_passes[0]->id); |
| 8798 // The RenderPassDrawQuad should be removed from pass1. | 8811 // The RenderPassDrawQuad should be removed from pass1. |
| 8799 EXPECT_EQ(1u, pass1->quad_list.size()); | 8812 EXPECT_EQ(1u, pass1->quad_list.size()); |
| 8800 EXPECT_EQ(DrawQuad::SOLID_COLOR, pass1->quad_list.ElementAt(0)->material); | 8813 EXPECT_EQ(DrawQuad::SOLID_COLOR, pass1->quad_list.ElementAt(0)->material); |
| 8801 } | 8814 } |
| 8802 | 8815 |
| 8803 TEST_F(LayerTreeHostImplTest, DoNotRemoveEmptyRootRenderPass) { | 8816 TEST_F(LayerTreeHostImplTest, DoNotRemoveEmptyRootRenderPass) { |
| 8804 LayerTreeHostImpl::FrameData frame; | 8817 LayerTreeHostImpl::FrameData frame; |
| 8805 frame.render_passes.push_back(RenderPass::Create()); | 8818 frame.render_passes.push_back(RenderPass::Create()); |
| 8806 RenderPass* pass3 = frame.render_passes.back(); | 8819 RenderPass* pass3 = frame.render_passes.back().get(); |
| 8807 frame.render_passes.push_back(RenderPass::Create()); | 8820 frame.render_passes.push_back(RenderPass::Create()); |
| 8808 RenderPass* pass2 = frame.render_passes.back(); | 8821 RenderPass* pass2 = frame.render_passes.back().get(); |
| 8809 frame.render_passes.push_back(RenderPass::Create()); | 8822 frame.render_passes.push_back(RenderPass::Create()); |
| 8810 RenderPass* pass1 = frame.render_passes.back(); | 8823 RenderPass* pass1 = frame.render_passes.back().get(); |
| 8811 | 8824 |
| 8812 pass1->SetNew(RenderPassId(1, 0), gfx::Rect(), gfx::Rect(), gfx::Transform()); | 8825 pass1->SetNew(RenderPassId(1, 0), gfx::Rect(), gfx::Rect(), gfx::Transform()); |
| 8813 pass2->SetNew(RenderPassId(2, 0), gfx::Rect(), gfx::Rect(), gfx::Transform()); | 8826 pass2->SetNew(RenderPassId(2, 0), gfx::Rect(), gfx::Rect(), gfx::Transform()); |
| 8814 pass3->SetNew(RenderPassId(3, 0), gfx::Rect(), gfx::Rect(), gfx::Transform()); | 8827 pass3->SetNew(RenderPassId(3, 0), gfx::Rect(), gfx::Rect(), gfx::Transform()); |
| 8815 | 8828 |
| 8816 // pass3 is referenced by pass2. | 8829 // pass3 is referenced by pass2. |
| 8817 RenderPassDrawQuad* rpdq = | 8830 RenderPassDrawQuad* rpdq = |
| 8818 pass2->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); | 8831 pass2->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); |
| 8819 rpdq->material = DrawQuad::RENDER_PASS; | 8832 rpdq->material = DrawQuad::RENDER_PASS; |
| 8820 rpdq->render_pass_id = pass3->id; | 8833 rpdq->render_pass_id = pass3->id; |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9063 host_impl_->active_tree()->SetPageScaleOnActiveTree(2.f); | 9076 host_impl_->active_tree()->SetPageScaleOnActiveTree(2.f); |
| 9064 DrawFrame(); | 9077 DrawFrame(); |
| 9065 in_subtree_of_page_scale_layer = host_impl_->active_tree()->LayerById(100); | 9078 in_subtree_of_page_scale_layer = host_impl_->active_tree()->LayerById(100); |
| 9066 node = host_impl_->active_tree()->property_trees()->transform_tree.Node( | 9079 node = host_impl_->active_tree()->property_trees()->transform_tree.Node( |
| 9067 in_subtree_of_page_scale_layer->transform_tree_index()); | 9080 in_subtree_of_page_scale_layer->transform_tree_index()); |
| 9068 EXPECT_EQ(node->data.sublayer_scale, gfx::Vector2dF(2.f, 2.f)); | 9081 EXPECT_EQ(node->data.sublayer_scale, gfx::Vector2dF(2.f, 2.f)); |
| 9069 } | 9082 } |
| 9070 | 9083 |
| 9071 } // namespace | 9084 } // namespace |
| 9072 } // namespace cc | 9085 } // namespace cc |
| OLD | NEW |