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

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

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

Powered by Google App Engine
This is Rietveld 408576698