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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 void set_reduce_memory_result(bool reduce_memory_result) { | 159 void set_reduce_memory_result(bool reduce_memory_result) { |
160 reduce_memory_result_ = reduce_memory_result; | 160 reduce_memory_result_ = reduce_memory_result; |
161 } | 161 } |
162 | 162 |
163 virtual bool CreateHostImpl(const LayerTreeSettings& settings, | 163 virtual bool CreateHostImpl(const LayerTreeSettings& settings, |
164 scoped_ptr<OutputSurface> output_surface) { | 164 scoped_ptr<OutputSurface> output_surface) { |
165 host_impl_ = LayerTreeHostImpl::Create( | 165 host_impl_ = LayerTreeHostImpl::Create( |
166 settings, this, &task_runner_provider_, &stats_instrumentation_, | 166 settings, this, &task_runner_provider_, &stats_instrumentation_, |
167 &shared_bitmap_manager_, &gpu_memory_buffer_manager_, | 167 &shared_bitmap_manager_, &gpu_memory_buffer_manager_, |
168 &task_graph_runner_, 0); | 168 &task_graph_runner_, 0); |
169 output_surface_ = output_surface.Pass(); | 169 output_surface_ = std::move(output_surface); |
170 host_impl_->SetVisible(true); | 170 host_impl_->SetVisible(true); |
171 bool init = host_impl_->InitializeRenderer(output_surface_.get()); | 171 bool init = host_impl_->InitializeRenderer(output_surface_.get()); |
172 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 172 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
173 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); | 173 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); |
174 // Set the BeginFrameArgs so that methods which use it are able to. | 174 // Set the BeginFrameArgs so that methods which use it are able to. |
175 host_impl_->WillBeginImplFrame(CreateBeginFrameArgsForTesting( | 175 host_impl_->WillBeginImplFrame(CreateBeginFrameArgsForTesting( |
176 BEGINFRAME_FROM_HERE, | 176 BEGINFRAME_FROM_HERE, |
177 base::TimeTicks() + base::TimeDelta::FromMilliseconds(1))); | 177 base::TimeTicks() + base::TimeDelta::FromMilliseconds(1))); |
178 host_impl_->DidFinishImplFrame(); | 178 host_impl_->DidFinishImplFrame(); |
179 return init; | 179 return init; |
180 } | 180 } |
181 | 181 |
182 void SetupRootLayerImpl(scoped_ptr<LayerImpl> root) { | 182 void SetupRootLayerImpl(scoped_ptr<LayerImpl> root) { |
183 root->SetPosition(gfx::PointF()); | 183 root->SetPosition(gfx::PointF()); |
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(std::move(root)); |
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].get()); | 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, |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 outer_scroll->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); | 275 outer_scroll->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); |
276 outer_scroll->SetBounds(content_size); | 276 outer_scroll->SetBounds(content_size); |
277 outer_scroll->SetPosition(gfx::PointF()); | 277 outer_scroll->SetPosition(gfx::PointF()); |
278 | 278 |
279 scoped_ptr<LayerImpl> contents = | 279 scoped_ptr<LayerImpl> contents = |
280 LayerImpl::Create(layer_tree_impl, kContentLayerId); | 280 LayerImpl::Create(layer_tree_impl, kContentLayerId); |
281 contents->SetDrawsContent(true); | 281 contents->SetDrawsContent(true); |
282 contents->SetBounds(content_size); | 282 contents->SetBounds(content_size); |
283 contents->SetPosition(gfx::PointF()); | 283 contents->SetPosition(gfx::PointF()); |
284 | 284 |
285 outer_scroll->AddChild(contents.Pass()); | 285 outer_scroll->AddChild(std::move(contents)); |
286 outer_clip->AddChild(outer_scroll.Pass()); | 286 outer_clip->AddChild(std::move(outer_scroll)); |
287 inner_scroll->AddChild(outer_clip.Pass()); | 287 inner_scroll->AddChild(std::move(outer_clip)); |
288 page_scale->AddChild(inner_scroll.Pass()); | 288 page_scale->AddChild(std::move(inner_scroll)); |
289 inner_clip->AddChild(page_scale.Pass()); | 289 inner_clip->AddChild(std::move(page_scale)); |
290 root->AddChild(inner_clip.Pass()); | 290 root->AddChild(std::move(inner_clip)); |
291 | 291 |
292 layer_tree_impl->SetRootLayer(root.Pass()); | 292 layer_tree_impl->SetRootLayer(std::move(root)); |
293 layer_tree_impl->SetViewportLayersFromIds( | 293 layer_tree_impl->SetViewportLayersFromIds( |
294 Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportScrollLayerId, | 294 Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportScrollLayerId, |
295 kOuterViewportScrollLayerId); | 295 kOuterViewportScrollLayerId); |
296 | 296 |
297 layer_tree_impl->DidBecomeActive(); | 297 layer_tree_impl->DidBecomeActive(); |
298 return layer_tree_impl->InnerViewportScrollLayer(); | 298 return layer_tree_impl->InnerViewportScrollLayer(); |
299 } | 299 } |
300 | 300 |
301 LayerImpl* SetupScrollAndContentsLayers(const gfx::Size& content_size) { | 301 LayerImpl* SetupScrollAndContentsLayers(const gfx::Size& content_size) { |
302 LayerImpl* scroll_layer = CreateScrollAndContentsLayers( | 302 LayerImpl* scroll_layer = CreateScrollAndContentsLayers( |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 const gfx::Size& size, | 338 const gfx::Size& size, |
339 LayerImpl* clip_layer) { | 339 LayerImpl* clip_layer) { |
340 DCHECK(clip_layer); | 340 DCHECK(clip_layer); |
341 DCHECK(id != clip_layer->id()); | 341 DCHECK(id != clip_layer->id()); |
342 scoped_ptr<LayerImpl> layer = | 342 scoped_ptr<LayerImpl> layer = |
343 LayerImpl::Create(host_impl_->active_tree(), id); | 343 LayerImpl::Create(host_impl_->active_tree(), id); |
344 layer->SetScrollClipLayer(clip_layer->id()); | 344 layer->SetScrollClipLayer(clip_layer->id()); |
345 layer->SetDrawsContent(true); | 345 layer->SetDrawsContent(true); |
346 layer->SetBounds(size); | 346 layer->SetBounds(size); |
347 clip_layer->SetBounds(gfx::Size(size.width() / 2, size.height() / 2)); | 347 clip_layer->SetBounds(gfx::Size(size.width() / 2, size.height() / 2)); |
348 return layer.Pass(); | 348 return layer; |
349 } | 349 } |
350 | 350 |
351 void DrawFrame() { | 351 void DrawFrame() { |
352 LayerTreeHostImpl::FrameData frame; | 352 LayerTreeHostImpl::FrameData frame; |
353 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 353 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
354 host_impl_->DrawLayers(&frame); | 354 host_impl_->DrawLayers(&frame); |
355 host_impl_->DidDrawAllLayers(frame); | 355 host_impl_->DidDrawAllLayers(frame); |
356 } | 356 } |
357 | 357 |
358 void RebuildPropertyTrees() { | 358 void RebuildPropertyTrees() { |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 scoped_ptr<LayerImpl> root = | 490 scoped_ptr<LayerImpl> root = |
491 LayerImpl::Create(host_impl_->active_tree(), 1); | 491 LayerImpl::Create(host_impl_->active_tree(), 1); |
492 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2)); | 492 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2)); |
493 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 3)); | 493 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 3)); |
494 root->children()[1]->AddChild( | 494 root->children()[1]->AddChild( |
495 LayerImpl::Create(host_impl_->active_tree(), 4)); | 495 LayerImpl::Create(host_impl_->active_tree(), 4)); |
496 root->children()[1]->AddChild( | 496 root->children()[1]->AddChild( |
497 LayerImpl::Create(host_impl_->active_tree(), 5)); | 497 LayerImpl::Create(host_impl_->active_tree(), 5)); |
498 root->children()[1]->children()[0]->AddChild( | 498 root->children()[1]->children()[0]->AddChild( |
499 LayerImpl::Create(host_impl_->active_tree(), 6)); | 499 LayerImpl::Create(host_impl_->active_tree(), 6)); |
500 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 500 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
501 } | 501 } |
502 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 502 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
503 | 503 |
504 ExpectClearedScrollDeltasRecursive(root); | 504 ExpectClearedScrollDeltasRecursive(root); |
505 | 505 |
506 scoped_ptr<ScrollAndScaleSet> scroll_info; | 506 scoped_ptr<ScrollAndScaleSet> scroll_info; |
507 | 507 |
508 scroll_info = host_impl_->ProcessScrollDeltas(); | 508 scroll_info = host_impl_->ProcessScrollDeltas(); |
509 ASSERT_EQ(scroll_info->scrolls.size(), 0u); | 509 ASSERT_EQ(scroll_info->scrolls.size(), 0u); |
510 ExpectClearedScrollDeltasRecursive(root); | 510 ExpectClearedScrollDeltasRecursive(root); |
511 | 511 |
512 scroll_info = host_impl_->ProcessScrollDeltas(); | 512 scroll_info = host_impl_->ProcessScrollDeltas(); |
513 ASSERT_EQ(scroll_info->scrolls.size(), 0u); | 513 ASSERT_EQ(scroll_info->scrolls.size(), 0u); |
514 ExpectClearedScrollDeltasRecursive(root); | 514 ExpectClearedScrollDeltasRecursive(root); |
515 } | 515 } |
516 | 516 |
517 TEST_F(LayerTreeHostImplTest, ScrollDeltaRepeatedScrolls) { | 517 TEST_F(LayerTreeHostImplTest, ScrollDeltaRepeatedScrolls) { |
518 gfx::ScrollOffset scroll_offset(20, 30); | 518 gfx::ScrollOffset scroll_offset(20, 30); |
519 gfx::Vector2d scroll_delta(11, -15); | 519 gfx::Vector2d scroll_delta(11, -15); |
520 { | 520 { |
521 scoped_ptr<LayerImpl> root_clip = | 521 scoped_ptr<LayerImpl> root_clip = |
522 LayerImpl::Create(host_impl_->active_tree(), 2); | 522 LayerImpl::Create(host_impl_->active_tree(), 2); |
523 scoped_ptr<LayerImpl> root = | 523 scoped_ptr<LayerImpl> root = |
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(std::move(root)); |
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(std::move(root_clip)); |
533 } | 533 } |
534 LayerImpl* root = | 534 LayerImpl* root = |
535 host_impl_->active_tree()->root_layer()->children()[0].get(); | 535 host_impl_->active_tree()->root_layer()->children()[0].get(); |
536 | 536 |
537 scoped_ptr<ScrollAndScaleSet> scroll_info; | 537 scoped_ptr<ScrollAndScaleSet> scroll_info; |
538 | 538 |
539 scroll_info = host_impl_->ProcessScrollDeltas(); | 539 scroll_info = host_impl_->ProcessScrollDeltas(); |
540 ASSERT_EQ(scroll_info->scrolls.size(), 1u); | 540 ASSERT_EQ(scroll_info->scrolls.size(), 1u); |
541 EXPECT_TRUE(ScrollInfoContains(*scroll_info, root->id(), scroll_delta)); | 541 EXPECT_TRUE(ScrollInfoContains(*scroll_info, root->id(), scroll_delta)); |
542 | 542 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 EXPECT_EQ(InputHandler::SCROLL_IGNORED, | 591 EXPECT_EQ(InputHandler::SCROLL_IGNORED, |
592 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 592 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); |
593 } | 593 } |
594 | 594 |
595 TEST_F(LayerTreeHostImplTest, ScrollWithoutRenderer) { | 595 TEST_F(LayerTreeHostImplTest, ScrollWithoutRenderer) { |
596 scoped_ptr<TestWebGraphicsContext3D> context_owned = | 596 scoped_ptr<TestWebGraphicsContext3D> context_owned = |
597 TestWebGraphicsContext3D::Create(); | 597 TestWebGraphicsContext3D::Create(); |
598 context_owned->set_context_lost(true); | 598 context_owned->set_context_lost(true); |
599 | 599 |
600 // Initialization will fail. | 600 // Initialization will fail. |
601 EXPECT_FALSE(CreateHostImpl( | 601 EXPECT_FALSE( |
602 DefaultSettings(), FakeOutputSurface::Create3d(context_owned.Pass()))); | 602 CreateHostImpl(DefaultSettings(), |
| 603 FakeOutputSurface::Create3d(std::move(context_owned)))); |
603 | 604 |
604 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 605 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
605 | 606 |
606 // We should not crash when trying to scroll after the renderer initialization | 607 // We should not crash when trying to scroll after the renderer initialization |
607 // fails. | 608 // fails. |
608 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 609 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
609 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 610 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); |
610 } | 611 } |
611 | 612 |
612 TEST_F(LayerTreeHostImplTest, ReplaceTreeWhileScrolling) { | 613 TEST_F(LayerTreeHostImplTest, ReplaceTreeWhileScrolling) { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 671 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
671 | 672 |
672 LayerImpl* child = 0; | 673 LayerImpl* child = 0; |
673 { | 674 { |
674 scoped_ptr<LayerImpl> child_layer = | 675 scoped_ptr<LayerImpl> child_layer = |
675 LayerImpl::Create(host_impl_->active_tree(), 6); | 676 LayerImpl::Create(host_impl_->active_tree(), 6); |
676 child = child_layer.get(); | 677 child = child_layer.get(); |
677 child_layer->SetDrawsContent(true); | 678 child_layer->SetDrawsContent(true); |
678 child_layer->SetPosition(gfx::PointF(0, 20)); | 679 child_layer->SetPosition(gfx::PointF(0, 20)); |
679 child_layer->SetBounds(gfx::Size(50, 50)); | 680 child_layer->SetBounds(gfx::Size(50, 50)); |
680 scroll->AddChild(child_layer.Pass()); | 681 scroll->AddChild(std::move(child_layer)); |
681 RebuildPropertyTrees(); | 682 RebuildPropertyTrees(); |
682 } | 683 } |
683 | 684 |
684 // Touch handler regions determine whether touch events block scroll. | 685 // Touch handler regions determine whether touch events block scroll. |
685 root->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 100, 100)); | 686 root->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 100, 100)); |
686 EXPECT_FALSE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 10))); | 687 EXPECT_FALSE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 10))); |
687 root->SetScrollBlocksOn(SCROLL_BLOCKS_ON_START_TOUCH | | 688 root->SetScrollBlocksOn(SCROLL_BLOCKS_ON_START_TOUCH | |
688 SCROLL_BLOCKS_ON_WHEEL_EVENT); | 689 SCROLL_BLOCKS_ON_WHEEL_EVENT); |
689 EXPECT_TRUE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 10))); | 690 EXPECT_TRUE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 10))); |
690 | 691 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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()); |
758 child1 = scrollable_child_1.get(); | 759 child1 = scrollable_child_1.get(); |
759 scrollable_child_1->SetPosition(gfx::PointF(5.f, 5.f)); | 760 scrollable_child_1->SetPosition(gfx::PointF(5.f, 5.f)); |
760 scrollable_child_1->SetHaveWheelEventHandlers(true); | 761 scrollable_child_1->SetHaveWheelEventHandlers(true); |
761 scrollable_child_1->SetHaveScrollEventHandlers(true); | 762 scrollable_child_1->SetHaveScrollEventHandlers(true); |
762 scrollable_child_clip_1->AddChild(scrollable_child_1.Pass()); | 763 scrollable_child_clip_1->AddChild(std::move(scrollable_child_1)); |
763 root_child->AddChild(scrollable_child_clip_1.Pass()); | 764 root_child->AddChild(std::move(scrollable_child_clip_1)); |
764 RebuildPropertyTrees(); | 765 RebuildPropertyTrees(); |
765 } | 766 } |
766 | 767 |
767 LayerImpl* child2 = 0; | 768 LayerImpl* child2 = 0; |
768 { | 769 { |
769 scoped_ptr<LayerImpl> scrollable_child_clip_2 = | 770 scoped_ptr<LayerImpl> scrollable_child_clip_2 = |
770 LayerImpl::Create(host_impl_->active_tree(), 8); | 771 LayerImpl::Create(host_impl_->active_tree(), 8); |
771 scoped_ptr<LayerImpl> scrollable_child_2 = CreateScrollableLayer( | 772 scoped_ptr<LayerImpl> scrollable_child_2 = CreateScrollableLayer( |
772 9, gfx::Size(10, 10), scrollable_child_clip_2.get()); | 773 9, gfx::Size(10, 10), scrollable_child_clip_2.get()); |
773 child2 = scrollable_child_2.get(); | 774 child2 = scrollable_child_2.get(); |
774 scrollable_child_2->SetPosition(gfx::PointF(5.f, 20.f)); | 775 scrollable_child_2->SetPosition(gfx::PointF(5.f, 20.f)); |
775 scrollable_child_2->SetHaveWheelEventHandlers(true); | 776 scrollable_child_2->SetHaveWheelEventHandlers(true); |
776 scrollable_child_2->SetHaveScrollEventHandlers(true); | 777 scrollable_child_2->SetHaveScrollEventHandlers(true); |
777 scrollable_child_clip_2->AddChild(scrollable_child_2.Pass()); | 778 scrollable_child_clip_2->AddChild(std::move(scrollable_child_2)); |
778 root_child->AddChild(scrollable_child_clip_2.Pass()); | 779 root_child->AddChild(std::move(scrollable_child_clip_2)); |
779 RebuildPropertyTrees(); | 780 RebuildPropertyTrees(); |
780 } | 781 } |
781 | 782 |
782 // Scroll-blocks-on on a layer affects scrolls that hit that layer. | 783 // Scroll-blocks-on on a layer affects scrolls that hit that layer. |
783 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 784 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
784 host_impl_->ScrollBegin(gfx::Point(10, 10), InputHandler::GESTURE)); | 785 host_impl_->ScrollBegin(gfx::Point(10, 10), InputHandler::GESTURE)); |
785 host_impl_->ScrollEnd(); | 786 host_impl_->ScrollEnd(); |
786 child1->SetScrollBlocksOn(SCROLL_BLOCKS_ON_SCROLL_EVENT); | 787 child1->SetScrollBlocksOn(SCROLL_BLOCKS_ON_SCROLL_EVENT); |
787 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, | 788 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, |
788 host_impl_->ScrollBegin(gfx::Point(10, 10), InputHandler::GESTURE)); | 789 host_impl_->ScrollBegin(gfx::Point(10, 10), InputHandler::GESTURE)); |
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1564 ui::LatencyInfo latency_info; | 1565 ui::LatencyInfo latency_info; |
1565 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, | 1566 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, |
1566 1234); | 1567 1234); |
1567 scoped_ptr<SwapPromise> swap_promise( | 1568 scoped_ptr<SwapPromise> swap_promise( |
1568 new LatencyInfoSwapPromise(latency_info)); | 1569 new LatencyInfoSwapPromise(latency_info)); |
1569 | 1570 |
1570 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 1571 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
1571 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 1572 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
1572 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 1573 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
1573 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 1574 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
1574 host_impl_->QueueSwapPromiseForMainThreadScrollUpdate(swap_promise.Pass()); | 1575 host_impl_->QueueSwapPromiseForMainThreadScrollUpdate( |
| 1576 std::move(swap_promise)); |
1575 host_impl_->ScrollEnd(); | 1577 host_impl_->ScrollEnd(); |
1576 | 1578 |
1577 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); | 1579 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); |
1578 EXPECT_EQ(1u, scroll_info->swap_promises.size()); | 1580 EXPECT_EQ(1u, scroll_info->swap_promises.size()); |
1579 EXPECT_EQ(latency_info.trace_id(), scroll_info->swap_promises[0]->TraceId()); | 1581 EXPECT_EQ(latency_info.trace_id(), scroll_info->swap_promises[0]->TraceId()); |
1580 } | 1582 } |
1581 | 1583 |
1582 // Test that scrolls targeting a layer with a non-null scroll_parent() don't | 1584 // Test that scrolls targeting a layer with a non-null scroll_parent() don't |
1583 // bubble up. | 1585 // bubble up. |
1584 TEST_F(LayerTreeHostImplTest, ScrollDoesntBubble) { | 1586 TEST_F(LayerTreeHostImplTest, ScrollDoesntBubble) { |
1585 LayerImpl* viewport_scroll = | 1587 LayerImpl* viewport_scroll = |
1586 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 1588 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
1587 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 1589 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
1588 | 1590 |
1589 // Set up two scrolling children of the root, one of which is a scroll parent | 1591 // Set up two scrolling children of the root, one of which is a scroll parent |
1590 // to the other. Scrolls shouldn't bubbling from the child. | 1592 // to the other. Scrolls shouldn't bubbling from the child. |
1591 LayerImpl *parent; | 1593 LayerImpl *parent; |
1592 LayerImpl *child; | 1594 LayerImpl *child; |
1593 LayerImpl *child_clip; | 1595 LayerImpl *child_clip; |
1594 | 1596 |
1595 scoped_ptr<LayerImpl> scroll_parent_clip = | 1597 scoped_ptr<LayerImpl> scroll_parent_clip = |
1596 LayerImpl::Create(host_impl_->active_tree(), 6); | 1598 LayerImpl::Create(host_impl_->active_tree(), 6); |
1597 scoped_ptr<LayerImpl> scroll_parent = CreateScrollableLayer( | 1599 scoped_ptr<LayerImpl> scroll_parent = CreateScrollableLayer( |
1598 7, gfx::Size(10, 10), scroll_parent_clip.get()); | 1600 7, gfx::Size(10, 10), scroll_parent_clip.get()); |
1599 parent = scroll_parent.get(); | 1601 parent = scroll_parent.get(); |
1600 scroll_parent_clip->AddChild(scroll_parent.Pass()); | 1602 scroll_parent_clip->AddChild(std::move(scroll_parent)); |
1601 | 1603 |
1602 viewport_scroll->AddChild(scroll_parent_clip.Pass()); | 1604 viewport_scroll->AddChild(std::move(scroll_parent_clip)); |
1603 | 1605 |
1604 scoped_ptr<LayerImpl> scroll_child_clip = | 1606 scoped_ptr<LayerImpl> scroll_child_clip = |
1605 LayerImpl::Create(host_impl_->active_tree(), 8); | 1607 LayerImpl::Create(host_impl_->active_tree(), 8); |
1606 scoped_ptr<LayerImpl> scroll_child = CreateScrollableLayer( | 1608 scoped_ptr<LayerImpl> scroll_child = CreateScrollableLayer( |
1607 9, gfx::Size(10, 10), scroll_child_clip.get()); | 1609 9, gfx::Size(10, 10), scroll_child_clip.get()); |
1608 child = scroll_child.get(); | 1610 child = scroll_child.get(); |
1609 scroll_child->SetPosition(gfx::PointF(20.f, 20.f)); | 1611 scroll_child->SetPosition(gfx::PointF(20.f, 20.f)); |
1610 scroll_child_clip->AddChild(scroll_child.Pass()); | 1612 scroll_child_clip->AddChild(std::move(scroll_child)); |
1611 | 1613 |
1612 child_clip = scroll_child_clip.get(); | 1614 child_clip = scroll_child_clip.get(); |
1613 viewport_scroll->AddChild(scroll_child_clip.Pass()); | 1615 viewport_scroll->AddChild(std::move(scroll_child_clip)); |
1614 | 1616 |
1615 child_clip->SetScrollParent(parent); | 1617 child_clip->SetScrollParent(parent); |
1616 scoped_ptr<std::set<LayerImpl*>> scroll_children(new std::set<LayerImpl*>); | 1618 scoped_ptr<std::set<LayerImpl*>> scroll_children(new std::set<LayerImpl*>); |
1617 scroll_children->insert(child_clip); | 1619 scroll_children->insert(child_clip); |
1618 parent->SetScrollChildren(scroll_children.release()); | 1620 parent->SetScrollChildren(scroll_children.release()); |
1619 | 1621 |
1620 DrawFrame(); | 1622 DrawFrame(); |
1621 | 1623 |
1622 { | 1624 { |
1623 host_impl_->ScrollBegin(gfx::Point(21, 21), InputHandler::GESTURE); | 1625 host_impl_->ScrollBegin(gfx::Point(21, 21), InputHandler::GESTURE); |
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2205 gfx::Size(content_size.width() / 2, content_size.height() / 2)); | 2207 gfx::Size(content_size.width() / 2, content_size.height() / 2)); |
2206 | 2208 |
2207 scoped_ptr<SolidColorScrollbarLayerImpl> scrollbar = | 2209 scoped_ptr<SolidColorScrollbarLayerImpl> scrollbar = |
2208 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 400, | 2210 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 400, |
2209 VERTICAL, 10, 0, false, true); | 2211 VERTICAL, 10, 0, false, true); |
2210 EXPECT_FLOAT_EQ(0.f, scrollbar->opacity()); | 2212 EXPECT_FLOAT_EQ(0.f, scrollbar->opacity()); |
2211 | 2213 |
2212 LayerImpl* scroll = host_impl_->active_tree()->OuterViewportScrollLayer(); | 2214 LayerImpl* scroll = host_impl_->active_tree()->OuterViewportScrollLayer(); |
2213 LayerImpl* root = host_impl_->active_tree()->InnerViewportContainerLayer(); | 2215 LayerImpl* root = host_impl_->active_tree()->InnerViewportContainerLayer(); |
2214 scrollbar->SetScrollLayerId(scroll->id()); | 2216 scrollbar->SetScrollLayerId(scroll->id()); |
2215 root->AddChild(scrollbar.Pass()); | 2217 root->AddChild(std::move(scrollbar)); |
2216 | 2218 |
2217 host_impl_->active_tree()->DidBecomeActive(); | 2219 host_impl_->active_tree()->DidBecomeActive(); |
2218 DrawFrame(); | 2220 DrawFrame(); |
2219 } | 2221 } |
2220 | 2222 |
2221 void RunTest(LayerTreeSettings::ScrollbarAnimator animator) { | 2223 void RunTest(LayerTreeSettings::ScrollbarAnimator animator) { |
2222 LayerTreeSettings settings; | 2224 LayerTreeSettings settings; |
2223 settings.scrollbar_animator = animator; | 2225 settings.scrollbar_animator = animator; |
2224 settings.scrollbar_fade_delay_ms = 20; | 2226 settings.scrollbar_fade_delay_ms = 20; |
2225 settings.scrollbar_fade_duration_ms = 20; | 2227 settings.scrollbar_fade_duration_ms = 20; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2341 | 2343 |
2342 CreateHostImpl(settings, CreateOutputSurface()); | 2344 CreateHostImpl(settings, CreateOutputSurface()); |
2343 host_impl_->CreatePendingTree(); | 2345 host_impl_->CreatePendingTree(); |
2344 CreateScrollAndContentsLayers(host_impl_->pending_tree(), content_size); | 2346 CreateScrollAndContentsLayers(host_impl_->pending_tree(), content_size); |
2345 scoped_ptr<SolidColorScrollbarLayerImpl> scrollbar = | 2347 scoped_ptr<SolidColorScrollbarLayerImpl> scrollbar = |
2346 SolidColorScrollbarLayerImpl::Create(host_impl_->pending_tree(), 400, | 2348 SolidColorScrollbarLayerImpl::Create(host_impl_->pending_tree(), 400, |
2347 VERTICAL, 10, 0, false, true); | 2349 VERTICAL, 10, 0, false, true); |
2348 LayerImpl* scroll = host_impl_->pending_tree()->OuterViewportScrollLayer(); | 2350 LayerImpl* scroll = host_impl_->pending_tree()->OuterViewportScrollLayer(); |
2349 LayerImpl* root = host_impl_->pending_tree()->InnerViewportContainerLayer(); | 2351 LayerImpl* root = host_impl_->pending_tree()->InnerViewportContainerLayer(); |
2350 scrollbar->SetScrollLayerId(scroll->id()); | 2352 scrollbar->SetScrollLayerId(scroll->id()); |
2351 root->AddChild(scrollbar.Pass()); | 2353 root->AddChild(std::move(scrollbar)); |
2352 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); | 2354 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); |
2353 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); | 2355 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); |
2354 host_impl_->ActivateSyncTree(); | 2356 host_impl_->ActivateSyncTree(); |
2355 | 2357 |
2356 LayerImpl* scrollbar_layer = host_impl_->active_tree()->LayerById(400); | 2358 LayerImpl* scrollbar_layer = host_impl_->active_tree()->LayerById(400); |
2357 | 2359 |
2358 EffectNode* active_tree_node = | 2360 EffectNode* active_tree_node = |
2359 host_impl_->active_tree()->property_trees()->effect_tree.Node( | 2361 host_impl_->active_tree()->property_trees()->effect_tree.Node( |
2360 scrollbar_layer->effect_tree_index()); | 2362 scrollbar_layer->effect_tree_index()); |
2361 EXPECT_FLOAT_EQ(scrollbar_layer->opacity(), active_tree_node->data.opacity); | 2363 EXPECT_FLOAT_EQ(scrollbar_layer->opacity(), active_tree_node->data.opacity); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2488 gfx::ScrollOffset(10, 10)); | 2490 gfx::ScrollOffset(10, 10)); |
2489 EXPECT_FALSE(animation_task_.Equals(base::Closure())); | 2491 EXPECT_FALSE(animation_task_.Equals(base::Closure())); |
2490 animation_task_ = base::Closure(); | 2492 animation_task_ = base::Closure(); |
2491 host_impl_->active_tree()->InnerViewportScrollLayer()->SetCurrentScrollOffset( | 2493 host_impl_->active_tree()->InnerViewportScrollLayer()->SetCurrentScrollOffset( |
2492 gfx::ScrollOffset(10, 10)); | 2494 gfx::ScrollOffset(10, 10)); |
2493 EXPECT_FALSE(animation_task_.Equals(base::Closure())); | 2495 EXPECT_FALSE(animation_task_.Equals(base::Closure())); |
2494 animation_task_ = base::Closure(); | 2496 animation_task_ = base::Closure(); |
2495 | 2497 |
2496 // Check scrollbar registration on a sublayer. | 2498 // Check scrollbar registration on a sublayer. |
2497 child->SetScrollClipLayer(child_clip->id()); | 2499 child->SetScrollClipLayer(child_clip->id()); |
2498 child_clip->AddChild(child.Pass()); | 2500 child_clip->AddChild(std::move(child)); |
2499 root_scroll->AddChild(child_clip.Pass()); | 2501 root_scroll->AddChild(std::move(child_clip)); |
2500 EXPECT_EQ(0ul, host_impl_->ScrollbarsFor(child_scroll_id).size()); | 2502 EXPECT_EQ(0ul, host_impl_->ScrollbarsFor(child_scroll_id).size()); |
2501 EXPECT_EQ(nullptr, | 2503 EXPECT_EQ(nullptr, |
2502 host_impl_->ScrollbarAnimationControllerForId(child_scroll_id)); | 2504 host_impl_->ScrollbarAnimationControllerForId(child_scroll_id)); |
2503 vert_2_scrollbar->SetScrollLayerId(child_scroll_id); | 2505 vert_2_scrollbar->SetScrollLayerId(child_scroll_id); |
2504 EXPECT_EQ(1ul, host_impl_->ScrollbarsFor(child_scroll_id).size()); | 2506 EXPECT_EQ(1ul, host_impl_->ScrollbarsFor(child_scroll_id).size()); |
2505 EXPECT_TRUE(host_impl_->ScrollbarAnimationControllerForId(child_scroll_id)); | 2507 EXPECT_TRUE(host_impl_->ScrollbarAnimationControllerForId(child_scroll_id)); |
2506 horiz_2_scrollbar->SetScrollLayerId(child_scroll_id); | 2508 horiz_2_scrollbar->SetScrollLayerId(child_scroll_id); |
2507 EXPECT_EQ(2ul, host_impl_->ScrollbarsFor(child_scroll_id).size()); | 2509 EXPECT_EQ(2ul, host_impl_->ScrollbarsFor(child_scroll_id).size()); |
2508 EXPECT_TRUE(host_impl_->ScrollbarAnimationControllerForId(child_scroll_id)); | 2510 EXPECT_TRUE(host_impl_->ScrollbarAnimationControllerForId(child_scroll_id)); |
2509 | 2511 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2567 host_impl_->active_tree()->OuterViewportScrollLayer(); | 2569 host_impl_->active_tree()->OuterViewportScrollLayer(); |
2568 // The scrollbar is on the left side. | 2570 // The scrollbar is on the left side. |
2569 scoped_ptr<SolidColorScrollbarLayerImpl> scrollbar = | 2571 scoped_ptr<SolidColorScrollbarLayerImpl> scrollbar = |
2570 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 6, | 2572 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 6, |
2571 VERTICAL, 5, 5, true, true); | 2573 VERTICAL, 5, 5, true, true); |
2572 scrollbar->SetScrollLayerId(root_scroll->id()); | 2574 scrollbar->SetScrollLayerId(root_scroll->id()); |
2573 scrollbar->SetDrawsContent(true); | 2575 scrollbar->SetDrawsContent(true); |
2574 scrollbar->SetBounds(scrollbar_size); | 2576 scrollbar->SetBounds(scrollbar_size); |
2575 scrollbar->SetTouchEventHandlerRegion(gfx::Rect(scrollbar_size)); | 2577 scrollbar->SetTouchEventHandlerRegion(gfx::Rect(scrollbar_size)); |
2576 host_impl_->active_tree()->InnerViewportContainerLayer()->AddChild( | 2578 host_impl_->active_tree()->InnerViewportContainerLayer()->AddChild( |
2577 scrollbar.Pass()); | 2579 std::move(scrollbar)); |
2578 host_impl_->active_tree()->DidBecomeActive(); | 2580 host_impl_->active_tree()->DidBecomeActive(); |
2579 | 2581 |
2580 DrawFrame(); | 2582 DrawFrame(); |
2581 host_impl_->active_tree()->UpdateDrawProperties(false); | 2583 host_impl_->active_tree()->UpdateDrawProperties(false); |
2582 | 2584 |
2583 ScrollbarAnimationControllerThinning* scrollbar_animation_controller = | 2585 ScrollbarAnimationControllerThinning* scrollbar_animation_controller = |
2584 static_cast<ScrollbarAnimationControllerThinning*>( | 2586 static_cast<ScrollbarAnimationControllerThinning*>( |
2585 host_impl_->ScrollbarAnimationControllerForId(root_scroll->id())); | 2587 host_impl_->ScrollbarAnimationControllerForId(root_scroll->id())); |
2586 scrollbar_animation_controller->set_mouse_move_distance_for_test(100.f); | 2588 scrollbar_animation_controller->set_mouse_move_distance_for_test(100.f); |
2587 | 2589 |
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3250 host_impl_->DrawLayers(&frame); | 3252 host_impl_->DrawLayers(&frame); |
3251 host_impl_->DidDrawAllLayers(frame); | 3253 host_impl_->DidDrawAllLayers(frame); |
3252 host_impl_->SwapBuffers(frame); | 3254 host_impl_->SwapBuffers(frame); |
3253 } | 3255 } |
3254 } | 3256 } |
3255 | 3257 |
3256 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { | 3258 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { |
3257 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 3259 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
3258 root->SetScrollClipLayer(Layer::INVALID_ID); | 3260 root->SetScrollClipLayer(Layer::INVALID_ID); |
3259 root->SetHasRenderSurface(true); | 3261 root->SetHasRenderSurface(true); |
3260 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 3262 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
3261 DrawFrame(); | 3263 DrawFrame(); |
3262 | 3264 |
3263 // Scroll event is ignored because layer is not scrollable. | 3265 // Scroll event is ignored because layer is not scrollable. |
3264 EXPECT_EQ(InputHandler::SCROLL_IGNORED, | 3266 EXPECT_EQ(InputHandler::SCROLL_IGNORED, |
3265 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 3267 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); |
3266 EXPECT_FALSE(did_request_redraw_); | 3268 EXPECT_FALSE(did_request_redraw_); |
3267 EXPECT_FALSE(did_request_commit_); | 3269 EXPECT_FALSE(did_request_commit_); |
3268 } | 3270 } |
3269 | 3271 |
3270 TEST_F(LayerTreeHostImplTest, ClampingAfterActivation) { | 3272 TEST_F(LayerTreeHostImplTest, ClampingAfterActivation) { |
(...skipping 23 matching lines...) Expand all Loading... |
3294 // non-scrollable. | 3296 // non-scrollable. |
3295 : layer_size_(10, 10), | 3297 : layer_size_(10, 10), |
3296 clip_size_(layer_size_), | 3298 clip_size_(layer_size_), |
3297 top_controls_height_(50) { | 3299 top_controls_height_(50) { |
3298 viewport_size_ = gfx::Size(clip_size_.width(), | 3300 viewport_size_ = gfx::Size(clip_size_.width(), |
3299 clip_size_.height() + top_controls_height_); | 3301 clip_size_.height() + top_controls_height_); |
3300 } | 3302 } |
3301 | 3303 |
3302 bool CreateHostImpl(const LayerTreeSettings& settings, | 3304 bool CreateHostImpl(const LayerTreeSettings& settings, |
3303 scoped_ptr<OutputSurface> output_surface) override { | 3305 scoped_ptr<OutputSurface> output_surface) override { |
3304 bool init = | 3306 bool init = LayerTreeHostImplTest::CreateHostImpl( |
3305 LayerTreeHostImplTest::CreateHostImpl(settings, output_surface.Pass()); | 3307 settings, std::move(output_surface)); |
3306 if (init) { | 3308 if (init) { |
3307 host_impl_->active_tree()->set_top_controls_height(top_controls_height_); | 3309 host_impl_->active_tree()->set_top_controls_height(top_controls_height_); |
3308 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(1.f); | 3310 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(1.f); |
3309 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); | 3311 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); |
3310 } | 3312 } |
3311 return init; | 3313 return init; |
3312 } | 3314 } |
3313 | 3315 |
3314 void SetupTopControlsAndScrollLayerWithVirtualViewport( | 3316 void SetupTopControlsAndScrollLayerWithVirtualViewport( |
3315 const gfx::Size& inner_viewport_size, | 3317 const gfx::Size& inner_viewport_size, |
(...skipping 27 matching lines...) Expand all Loading... |
3343 outer_scroll->SetScrollClipLayer(outer_clip->id()); | 3345 outer_scroll->SetScrollClipLayer(outer_clip->id()); |
3344 outer_scroll->SetBounds(scroll_layer_size); | 3346 outer_scroll->SetBounds(scroll_layer_size); |
3345 outer_scroll->SetPosition(gfx::PointF()); | 3347 outer_scroll->SetPosition(gfx::PointF()); |
3346 outer_scroll->SetDrawsContent(false); | 3348 outer_scroll->SetDrawsContent(false); |
3347 outer_scroll->SetIsContainerForFixedPositionLayers(true); | 3349 outer_scroll->SetIsContainerForFixedPositionLayers(true); |
3348 | 3350 |
3349 int inner_viewport_scroll_layer_id = root->id(); | 3351 int inner_viewport_scroll_layer_id = root->id(); |
3350 int outer_viewport_scroll_layer_id = outer_scroll->id(); | 3352 int outer_viewport_scroll_layer_id = outer_scroll->id(); |
3351 int page_scale_layer_id = page_scale->id(); | 3353 int page_scale_layer_id = page_scale->id(); |
3352 | 3354 |
3353 outer_clip->AddChild(outer_scroll.Pass()); | 3355 outer_clip->AddChild(std::move(outer_scroll)); |
3354 root->AddChild(outer_clip.Pass()); | 3356 root->AddChild(std::move(outer_clip)); |
3355 page_scale->AddChild(root.Pass()); | 3357 page_scale->AddChild(std::move(root)); |
3356 root_clip->AddChild(page_scale.Pass()); | 3358 root_clip->AddChild(std::move(page_scale)); |
3357 | 3359 |
3358 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 3360 host_impl_->active_tree()->SetRootLayer(std::move(root_clip)); |
3359 host_impl_->active_tree()->SetViewportLayersFromIds( | 3361 host_impl_->active_tree()->SetViewportLayersFromIds( |
3360 Layer::INVALID_ID, page_scale_layer_id, inner_viewport_scroll_layer_id, | 3362 Layer::INVALID_ID, page_scale_layer_id, inner_viewport_scroll_layer_id, |
3361 outer_viewport_scroll_layer_id); | 3363 outer_viewport_scroll_layer_id); |
3362 | 3364 |
3363 host_impl_->SetViewportSize(inner_viewport_size); | 3365 host_impl_->SetViewportSize(inner_viewport_size); |
3364 LayerImpl* root_clip_ptr = host_impl_->active_tree()->root_layer(); | 3366 LayerImpl* root_clip_ptr = host_impl_->active_tree()->root_layer(); |
3365 EXPECT_EQ(inner_viewport_size, root_clip_ptr->bounds()); | 3367 EXPECT_EQ(inner_viewport_size, root_clip_ptr->bounds()); |
3366 } | 3368 } |
3367 | 3369 |
3368 protected: | 3370 protected: |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3634 | 3636 |
3635 child_clip->SetBounds(sub_content_layer_size); | 3637 child_clip->SetBounds(sub_content_layer_size); |
3636 child->SetScrollClipLayer(child_clip->id()); | 3638 child->SetScrollClipLayer(child_clip->id()); |
3637 child->SetBounds(sub_content_size); | 3639 child->SetBounds(sub_content_size); |
3638 child->SetPosition(gfx::PointF()); | 3640 child->SetPosition(gfx::PointF()); |
3639 child->SetDrawsContent(true); | 3641 child->SetDrawsContent(true); |
3640 child->SetIsContainerForFixedPositionLayers(true); | 3642 child->SetIsContainerForFixedPositionLayers(true); |
3641 | 3643 |
3642 // scroll child to limit | 3644 // scroll child to limit |
3643 child->SetScrollDelta(gfx::Vector2dF(0, 100.f)); | 3645 child->SetScrollDelta(gfx::Vector2dF(0, 100.f)); |
3644 child_clip->AddChild(child.Pass()); | 3646 child_clip->AddChild(std::move(child)); |
3645 outer_viewport_scroll_layer->AddChild(child_clip.Pass()); | 3647 outer_viewport_scroll_layer->AddChild(std::move(child_clip)); |
3646 | 3648 |
3647 // Scroll 25px to hide top controls | 3649 // Scroll 25px to hide top controls |
3648 gfx::Vector2dF scroll_delta(0.f, 25.f); | 3650 gfx::Vector2dF scroll_delta(0.f, 25.f); |
3649 host_impl_->active_tree()->property_trees()->needs_rebuild = true; | 3651 host_impl_->active_tree()->property_trees()->needs_rebuild = true; |
3650 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 3652 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
3651 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3653 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
3652 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 3654 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
3653 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 3655 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
3654 host_impl_->ScrollEnd(); | 3656 host_impl_->ScrollEnd(); |
3655 | 3657 |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4008 | 4010 |
4009 scoped_ptr<LayerImpl> scroll_clip_layer = | 4011 scoped_ptr<LayerImpl> scroll_clip_layer = |
4010 LayerImpl::Create(host_impl_->active_tree(), 3); | 4012 LayerImpl::Create(host_impl_->active_tree(), 3); |
4011 scroll_clip_layer->SetBounds(surface_size); | 4013 scroll_clip_layer->SetBounds(surface_size); |
4012 | 4014 |
4013 scoped_ptr<LayerImpl> scroll_layer = | 4015 scoped_ptr<LayerImpl> scroll_layer = |
4014 LayerImpl::Create(host_impl_->active_tree(), 2); | 4016 LayerImpl::Create(host_impl_->active_tree(), 2); |
4015 scroll_layer->SetScrollClipLayer(3); | 4017 scroll_layer->SetScrollClipLayer(3); |
4016 scroll_layer->SetBounds(contents_size); | 4018 scroll_layer->SetBounds(contents_size); |
4017 scroll_layer->SetPosition(gfx::PointF()); | 4019 scroll_layer->SetPosition(gfx::PointF()); |
4018 scroll_layer->AddChild(content_layer.Pass()); | 4020 scroll_layer->AddChild(std::move(content_layer)); |
4019 scroll_clip_layer->AddChild(scroll_layer.Pass()); | 4021 scroll_clip_layer->AddChild(std::move(scroll_layer)); |
4020 | 4022 |
4021 scroll_clip_layer->SetHasRenderSurface(true); | 4023 scroll_clip_layer->SetHasRenderSurface(true); |
4022 host_impl_->active_tree()->SetRootLayer(scroll_clip_layer.Pass()); | 4024 host_impl_->active_tree()->SetRootLayer(std::move(scroll_clip_layer)); |
4023 host_impl_->SetViewportSize(surface_size); | 4025 host_impl_->SetViewportSize(surface_size); |
4024 DrawFrame(); | 4026 DrawFrame(); |
4025 | 4027 |
4026 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 4028 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
4027 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); | 4029 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); |
4028 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 4030 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
4029 host_impl_->ScrollEnd(); | 4031 host_impl_->ScrollEnd(); |
4030 EXPECT_TRUE(did_request_redraw_); | 4032 EXPECT_TRUE(did_request_redraw_); |
4031 EXPECT_TRUE(did_request_commit_); | 4033 EXPECT_TRUE(did_request_commit_); |
4032 } | 4034 } |
4033 | 4035 |
4034 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) { | 4036 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) { |
4035 gfx::Size surface_size(10, 10); | 4037 gfx::Size surface_size(10, 10); |
4036 gfx::Size contents_size(20, 20); | 4038 gfx::Size contents_size(20, 20); |
4037 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 4039 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
4038 root->SetBounds(surface_size); | 4040 root->SetBounds(surface_size); |
4039 root->AddChild(CreateScrollableLayer(2, contents_size, root.get())); | 4041 root->AddChild(CreateScrollableLayer(2, contents_size, root.get())); |
4040 root->SetHasRenderSurface(true); | 4042 root->SetHasRenderSurface(true); |
4041 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 4043 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
4042 host_impl_->SetViewportSize(surface_size); | 4044 host_impl_->SetViewportSize(surface_size); |
4043 DrawFrame(); | 4045 DrawFrame(); |
4044 | 4046 |
4045 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 4047 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
4046 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); | 4048 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); |
4047 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 4049 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
4048 host_impl_->ScrollEnd(); | 4050 host_impl_->ScrollEnd(); |
4049 EXPECT_TRUE(did_request_redraw_); | 4051 EXPECT_TRUE(did_request_redraw_); |
4050 EXPECT_TRUE(did_request_commit_); | 4052 EXPECT_TRUE(did_request_commit_); |
4051 } | 4053 } |
4052 | 4054 |
4053 TEST_F(LayerTreeHostImplTest, ScrollMissesChild) { | 4055 TEST_F(LayerTreeHostImplTest, ScrollMissesChild) { |
4054 gfx::Size surface_size(10, 10); | 4056 gfx::Size surface_size(10, 10); |
4055 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 4057 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
4056 root->AddChild(CreateScrollableLayer(2, surface_size, root.get())); | 4058 root->AddChild(CreateScrollableLayer(2, surface_size, root.get())); |
4057 root->SetHasRenderSurface(true); | 4059 root->SetHasRenderSurface(true); |
4058 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 4060 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
4059 host_impl_->SetViewportSize(surface_size); | 4061 host_impl_->SetViewportSize(surface_size); |
4060 DrawFrame(); | 4062 DrawFrame(); |
4061 | 4063 |
4062 // Scroll event is ignored because the input coordinate is outside the layer | 4064 // Scroll event is ignored because the input coordinate is outside the layer |
4063 // boundaries. | 4065 // boundaries. |
4064 EXPECT_EQ(InputHandler::SCROLL_IGNORED, | 4066 EXPECT_EQ(InputHandler::SCROLL_IGNORED, |
4065 host_impl_->ScrollBegin(gfx::Point(15, 5), InputHandler::WHEEL)); | 4067 host_impl_->ScrollBegin(gfx::Point(15, 5), InputHandler::WHEEL)); |
4066 EXPECT_FALSE(did_request_redraw_); | 4068 EXPECT_FALSE(did_request_redraw_); |
4067 EXPECT_FALSE(did_request_commit_); | 4069 EXPECT_FALSE(did_request_commit_); |
4068 } | 4070 } |
4069 | 4071 |
4070 TEST_F(LayerTreeHostImplTest, ScrollMissesBackfacingChild) { | 4072 TEST_F(LayerTreeHostImplTest, ScrollMissesBackfacingChild) { |
4071 gfx::Size surface_size(10, 10); | 4073 gfx::Size surface_size(10, 10); |
4072 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 4074 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
4073 root->SetHasRenderSurface(true); | 4075 root->SetHasRenderSurface(true); |
4074 scoped_ptr<LayerImpl> child = | 4076 scoped_ptr<LayerImpl> child = |
4075 CreateScrollableLayer(2, surface_size, root.get()); | 4077 CreateScrollableLayer(2, surface_size, root.get()); |
4076 host_impl_->SetViewportSize(surface_size); | 4078 host_impl_->SetViewportSize(surface_size); |
4077 | 4079 |
4078 gfx::Transform matrix; | 4080 gfx::Transform matrix; |
4079 matrix.RotateAboutXAxis(180.0); | 4081 matrix.RotateAboutXAxis(180.0); |
4080 child->SetTransform(matrix); | 4082 child->SetTransform(matrix); |
4081 child->SetDoubleSided(false); | 4083 child->SetDoubleSided(false); |
4082 | 4084 |
4083 root->AddChild(child.Pass()); | 4085 root->AddChild(std::move(child)); |
4084 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 4086 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
4085 DrawFrame(); | 4087 DrawFrame(); |
4086 | 4088 |
4087 // Scroll event is ignored because the scrollable layer is not facing the | 4089 // Scroll event is ignored because the scrollable layer is not facing the |
4088 // viewer and there is nothing scrollable behind it. | 4090 // viewer and there is nothing scrollable behind it. |
4089 EXPECT_EQ(InputHandler::SCROLL_IGNORED, | 4091 EXPECT_EQ(InputHandler::SCROLL_IGNORED, |
4090 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); | 4092 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); |
4091 EXPECT_FALSE(did_request_redraw_); | 4093 EXPECT_FALSE(did_request_redraw_); |
4092 EXPECT_FALSE(did_request_commit_); | 4094 EXPECT_FALSE(did_request_commit_); |
4093 } | 4095 } |
4094 | 4096 |
4095 TEST_F(LayerTreeHostImplTest, ScrollBlockedByContentLayer) { | 4097 TEST_F(LayerTreeHostImplTest, ScrollBlockedByContentLayer) { |
4096 gfx::Size surface_size(10, 10); | 4098 gfx::Size surface_size(10, 10); |
4097 scoped_ptr<LayerImpl> clip_layer = | 4099 scoped_ptr<LayerImpl> clip_layer = |
4098 LayerImpl::Create(host_impl_->active_tree(), 3); | 4100 LayerImpl::Create(host_impl_->active_tree(), 3); |
4099 scoped_ptr<LayerImpl> content_layer = | 4101 scoped_ptr<LayerImpl> content_layer = |
4100 CreateScrollableLayer(1, surface_size, clip_layer.get()); | 4102 CreateScrollableLayer(1, surface_size, clip_layer.get()); |
4101 content_layer->SetShouldScrollOnMainThread(true); | 4103 content_layer->SetShouldScrollOnMainThread(true); |
4102 content_layer->SetScrollClipLayer(Layer::INVALID_ID); | 4104 content_layer->SetScrollClipLayer(Layer::INVALID_ID); |
4103 | 4105 |
4104 // Note: we can use the same clip layer for both since both calls to | 4106 // Note: we can use the same clip layer for both since both calls to |
4105 // CreateScrollableLayer() use the same surface size. | 4107 // CreateScrollableLayer() use the same surface size. |
4106 scoped_ptr<LayerImpl> scroll_layer = | 4108 scoped_ptr<LayerImpl> scroll_layer = |
4107 CreateScrollableLayer(2, surface_size, clip_layer.get()); | 4109 CreateScrollableLayer(2, surface_size, clip_layer.get()); |
4108 scroll_layer->AddChild(content_layer.Pass()); | 4110 scroll_layer->AddChild(std::move(content_layer)); |
4109 clip_layer->AddChild(scroll_layer.Pass()); | 4111 clip_layer->AddChild(std::move(scroll_layer)); |
4110 clip_layer->SetHasRenderSurface(true); | 4112 clip_layer->SetHasRenderSurface(true); |
4111 | 4113 |
4112 host_impl_->active_tree()->SetRootLayer(clip_layer.Pass()); | 4114 host_impl_->active_tree()->SetRootLayer(std::move(clip_layer)); |
4113 host_impl_->SetViewportSize(surface_size); | 4115 host_impl_->SetViewportSize(surface_size); |
4114 DrawFrame(); | 4116 DrawFrame(); |
4115 | 4117 |
4116 // Scrolling fails because the content layer is asking to be scrolled on the | 4118 // Scrolling fails because the content layer is asking to be scrolled on the |
4117 // main thread. | 4119 // main thread. |
4118 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, | 4120 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, |
4119 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); | 4121 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); |
4120 } | 4122 } |
4121 | 4123 |
4122 TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnMainThread) { | 4124 TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnMainThread) { |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4225 LayerImpl* scroll = SetupScrollAndContentsLayers(surface_size); | 4227 LayerImpl* scroll = SetupScrollAndContentsLayers(surface_size); |
4226 scroll->SetDrawsContent(true); | 4228 scroll->SetDrawsContent(true); |
4227 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 4229 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
4228 LayerImpl* child = scroll->children()[0].get(); | 4230 LayerImpl* child = scroll->children()[0].get(); |
4229 child->SetDrawsContent(true); | 4231 child->SetDrawsContent(true); |
4230 | 4232 |
4231 scoped_ptr<LayerImpl> scrollable_child_clip = | 4233 scoped_ptr<LayerImpl> scrollable_child_clip = |
4232 LayerImpl::Create(host_impl_->active_tree(), 6); | 4234 LayerImpl::Create(host_impl_->active_tree(), 6); |
4233 scoped_ptr<LayerImpl> scrollable_child = | 4235 scoped_ptr<LayerImpl> scrollable_child = |
4234 CreateScrollableLayer(7, surface_size, scrollable_child_clip.get()); | 4236 CreateScrollableLayer(7, surface_size, scrollable_child_clip.get()); |
4235 scrollable_child_clip->AddChild(scrollable_child.Pass()); | 4237 scrollable_child_clip->AddChild(std::move(scrollable_child)); |
4236 child->AddChild(scrollable_child_clip.Pass()); | 4238 child->AddChild(std::move(scrollable_child_clip)); |
4237 LayerImpl* grand_child = child->children()[0].get(); | 4239 LayerImpl* grand_child = child->children()[0].get(); |
4238 grand_child->SetDrawsContent(true); | 4240 grand_child->SetDrawsContent(true); |
4239 | 4241 |
4240 // Set new page scale on impl thread by pinching. | 4242 // Set new page scale on impl thread by pinching. |
4241 RebuildPropertyTrees(); | 4243 RebuildPropertyTrees(); |
4242 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE); | 4244 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE); |
4243 host_impl_->PinchGestureBegin(); | 4245 host_impl_->PinchGestureBegin(); |
4244 host_impl_->PinchGestureUpdate(new_page_scale, gfx::Point()); | 4246 host_impl_->PinchGestureUpdate(new_page_scale, gfx::Point()); |
4245 host_impl_->PinchGestureEnd(); | 4247 host_impl_->PinchGestureEnd(); |
4246 host_impl_->ScrollEnd(); | 4248 host_impl_->ScrollEnd(); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4309 gfx::Size content_size(20, 20); | 4311 gfx::Size content_size(20, 20); |
4310 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 4312 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
4311 root->SetBounds(surface_size); | 4313 root->SetBounds(surface_size); |
4312 root->SetHasRenderSurface(true); | 4314 root->SetHasRenderSurface(true); |
4313 scoped_ptr<LayerImpl> grand_child = | 4315 scoped_ptr<LayerImpl> grand_child = |
4314 CreateScrollableLayer(3, content_size, root.get()); | 4316 CreateScrollableLayer(3, content_size, root.get()); |
4315 | 4317 |
4316 scoped_ptr<LayerImpl> child = | 4318 scoped_ptr<LayerImpl> child = |
4317 CreateScrollableLayer(2, content_size, root.get()); | 4319 CreateScrollableLayer(2, content_size, root.get()); |
4318 LayerImpl* grand_child_layer = grand_child.get(); | 4320 LayerImpl* grand_child_layer = grand_child.get(); |
4319 child->AddChild(grand_child.Pass()); | 4321 child->AddChild(std::move(grand_child)); |
4320 | 4322 |
4321 LayerImpl* child_layer = child.get(); | 4323 LayerImpl* child_layer = child.get(); |
4322 root->AddChild(child.Pass()); | 4324 root->AddChild(std::move(child)); |
4323 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 4325 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
4324 host_impl_->active_tree()->DidBecomeActive(); | 4326 host_impl_->active_tree()->DidBecomeActive(); |
4325 host_impl_->SetViewportSize(surface_size); | 4327 host_impl_->SetViewportSize(surface_size); |
4326 grand_child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 5)); | 4328 grand_child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 5)); |
4327 child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(3, 0)); | 4329 child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(3, 0)); |
4328 | 4330 |
4329 DrawFrame(); | 4331 DrawFrame(); |
4330 { | 4332 { |
4331 gfx::Vector2d scroll_delta(-8, -7); | 4333 gfx::Vector2d scroll_delta(-8, -7); |
4332 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 4334 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
4333 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 4335 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); |
(...skipping 25 matching lines...) Expand all Loading... |
4359 scoped_ptr<LayerImpl> root_scrolling = | 4361 scoped_ptr<LayerImpl> root_scrolling = |
4360 CreateScrollableLayer(2, surface_size, root.get()); | 4362 CreateScrollableLayer(2, surface_size, root.get()); |
4361 root_scrolling->SetIsContainerForFixedPositionLayers(true); | 4363 root_scrolling->SetIsContainerForFixedPositionLayers(true); |
4362 | 4364 |
4363 scoped_ptr<LayerImpl> grand_child = | 4365 scoped_ptr<LayerImpl> grand_child = |
4364 CreateScrollableLayer(4, surface_size, root.get()); | 4366 CreateScrollableLayer(4, surface_size, root.get()); |
4365 | 4367 |
4366 scoped_ptr<LayerImpl> child = | 4368 scoped_ptr<LayerImpl> child = |
4367 CreateScrollableLayer(3, surface_size, root.get()); | 4369 CreateScrollableLayer(3, surface_size, root.get()); |
4368 LayerImpl* grand_child_layer = grand_child.get(); | 4370 LayerImpl* grand_child_layer = grand_child.get(); |
4369 child->AddChild(grand_child.Pass()); | 4371 child->AddChild(std::move(grand_child)); |
4370 | 4372 |
4371 LayerImpl* child_layer = child.get(); | 4373 LayerImpl* child_layer = child.get(); |
4372 root_scrolling->AddChild(child.Pass()); | 4374 root_scrolling->AddChild(std::move(child)); |
4373 root->AddChild(root_scrolling.Pass()); | 4375 root->AddChild(std::move(root_scrolling)); |
4374 EXPECT_EQ(viewport_size, root->bounds()); | 4376 EXPECT_EQ(viewport_size, root->bounds()); |
4375 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 4377 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
4376 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 2, | 4378 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 2, |
4377 Layer::INVALID_ID); | 4379 Layer::INVALID_ID); |
4378 host_impl_->active_tree()->DidBecomeActive(); | 4380 host_impl_->active_tree()->DidBecomeActive(); |
4379 host_impl_->SetViewportSize(viewport_size); | 4381 host_impl_->SetViewportSize(viewport_size); |
4380 | 4382 |
4381 grand_child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 2)); | 4383 grand_child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 2)); |
4382 child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 3)); | 4384 child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 3)); |
4383 | 4385 |
4384 DrawFrame(); | 4386 DrawFrame(); |
4385 { | 4387 { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4475 scoped_ptr<LayerImpl> root = | 4477 scoped_ptr<LayerImpl> root = |
4476 CreateScrollableLayer(1, content_size, root_clip.get()); | 4478 CreateScrollableLayer(1, content_size, root_clip.get()); |
4477 // Make 'root' the clip layer for child: since they have the same sizes the | 4479 // Make 'root' the clip layer for child: since they have the same sizes the |
4478 // child will have zero max_scroll_offset and scrolls will bubble. | 4480 // child will have zero max_scroll_offset and scrolls will bubble. |
4479 scoped_ptr<LayerImpl> child = | 4481 scoped_ptr<LayerImpl> child = |
4480 CreateScrollableLayer(2, content_size, root.get()); | 4482 CreateScrollableLayer(2, content_size, root.get()); |
4481 child->SetIsContainerForFixedPositionLayers(true); | 4483 child->SetIsContainerForFixedPositionLayers(true); |
4482 root->SetBounds(content_size); | 4484 root->SetBounds(content_size); |
4483 | 4485 |
4484 int root_scroll_id = root->id(); | 4486 int root_scroll_id = root->id(); |
4485 root->AddChild(child.Pass()); | 4487 root->AddChild(std::move(child)); |
4486 root_clip->AddChild(root.Pass()); | 4488 root_clip->AddChild(std::move(root)); |
4487 | 4489 |
4488 host_impl_->SetViewportSize(surface_size); | 4490 host_impl_->SetViewportSize(surface_size); |
4489 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 4491 host_impl_->active_tree()->SetRootLayer(std::move(root_clip)); |
4490 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 3, 2, | 4492 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 3, 2, |
4491 Layer::INVALID_ID); | 4493 Layer::INVALID_ID); |
4492 host_impl_->active_tree()->DidBecomeActive(); | 4494 host_impl_->active_tree()->DidBecomeActive(); |
4493 DrawFrame(); | 4495 DrawFrame(); |
4494 { | 4496 { |
4495 gfx::Vector2d scroll_delta(0, 4); | 4497 gfx::Vector2d scroll_delta(0, 4); |
4496 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 4498 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
4497 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); | 4499 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); |
4498 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 4500 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
4499 host_impl_->ScrollEnd(); | 4501 host_impl_->ScrollEnd(); |
4500 | 4502 |
4501 scoped_ptr<ScrollAndScaleSet> scroll_info = | 4503 scoped_ptr<ScrollAndScaleSet> scroll_info = |
4502 host_impl_->ProcessScrollDeltas(); | 4504 host_impl_->ProcessScrollDeltas(); |
4503 | 4505 |
4504 // Only the root scroll should have scrolled. | 4506 // Only the root scroll should have scrolled. |
4505 ASSERT_EQ(scroll_info->scrolls.size(), 1u); | 4507 ASSERT_EQ(scroll_info->scrolls.size(), 1u); |
4506 EXPECT_TRUE( | 4508 EXPECT_TRUE( |
4507 ScrollInfoContains(*scroll_info.get(), root_scroll_id, scroll_delta)); | 4509 ScrollInfoContains(*scroll_info.get(), root_scroll_id, scroll_delta)); |
4508 } | 4510 } |
4509 } | 4511 } |
4510 | 4512 |
4511 TEST_F(LayerTreeHostImplTest, ScrollBeforeRedraw) { | 4513 TEST_F(LayerTreeHostImplTest, ScrollBeforeRedraw) { |
4512 gfx::Size surface_size(10, 10); | 4514 gfx::Size surface_size(10, 10); |
4513 scoped_ptr<LayerImpl> root_clip = | 4515 scoped_ptr<LayerImpl> root_clip = |
4514 LayerImpl::Create(host_impl_->active_tree(), 1); | 4516 LayerImpl::Create(host_impl_->active_tree(), 1); |
4515 scoped_ptr<LayerImpl> root_scroll = | 4517 scoped_ptr<LayerImpl> root_scroll = |
4516 CreateScrollableLayer(2, surface_size, root_clip.get()); | 4518 CreateScrollableLayer(2, surface_size, root_clip.get()); |
4517 root_scroll->SetIsContainerForFixedPositionLayers(true); | 4519 root_scroll->SetIsContainerForFixedPositionLayers(true); |
4518 root_clip->SetHasRenderSurface(true); | 4520 root_clip->SetHasRenderSurface(true); |
4519 root_clip->AddChild(root_scroll.Pass()); | 4521 root_clip->AddChild(std::move(root_scroll)); |
4520 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 4522 host_impl_->active_tree()->SetRootLayer(std::move(root_clip)); |
4521 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 2, | 4523 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 2, |
4522 Layer::INVALID_ID); | 4524 Layer::INVALID_ID); |
4523 host_impl_->active_tree()->DidBecomeActive(); | 4525 host_impl_->active_tree()->DidBecomeActive(); |
4524 host_impl_->SetViewportSize(surface_size); | 4526 host_impl_->SetViewportSize(surface_size); |
4525 | 4527 |
4526 // Draw one frame and then immediately rebuild the layer tree to mimic a tree | 4528 // Draw one frame and then immediately rebuild the layer tree to mimic a tree |
4527 // synchronization. | 4529 // synchronization. |
4528 DrawFrame(); | 4530 DrawFrame(); |
4529 host_impl_->active_tree()->DetachLayerTree(); | 4531 host_impl_->active_tree()->DetachLayerTree(); |
4530 scoped_ptr<LayerImpl> root_clip2 = | 4532 scoped_ptr<LayerImpl> root_clip2 = |
4531 LayerImpl::Create(host_impl_->active_tree(), 3); | 4533 LayerImpl::Create(host_impl_->active_tree(), 3); |
4532 scoped_ptr<LayerImpl> root_scroll2 = | 4534 scoped_ptr<LayerImpl> root_scroll2 = |
4533 CreateScrollableLayer(4, surface_size, root_clip2.get()); | 4535 CreateScrollableLayer(4, surface_size, root_clip2.get()); |
4534 root_scroll2->SetIsContainerForFixedPositionLayers(true); | 4536 root_scroll2->SetIsContainerForFixedPositionLayers(true); |
4535 root_clip2->AddChild(root_scroll2.Pass()); | 4537 root_clip2->AddChild(std::move(root_scroll2)); |
4536 root_clip2->SetHasRenderSurface(true); | 4538 root_clip2->SetHasRenderSurface(true); |
4537 host_impl_->active_tree()->SetRootLayer(root_clip2.Pass()); | 4539 host_impl_->active_tree()->SetRootLayer(std::move(root_clip2)); |
4538 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 3, 4, | 4540 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 3, 4, |
4539 Layer::INVALID_ID); | 4541 Layer::INVALID_ID); |
4540 host_impl_->active_tree()->DidBecomeActive(); | 4542 host_impl_->active_tree()->DidBecomeActive(); |
4541 | 4543 |
4542 // Scrolling should still work even though we did not draw yet. | 4544 // Scrolling should still work even though we did not draw yet. |
4543 RebuildPropertyTrees(); | 4545 RebuildPropertyTrees(); |
4544 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 4546 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
4545 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); | 4547 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); |
4546 } | 4548 } |
4547 | 4549 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4603 | 4605 |
4604 // Only allow vertical scrolling. | 4606 // Only allow vertical scrolling. |
4605 clip_layer->SetBounds( | 4607 clip_layer->SetBounds( |
4606 gfx::Size(child->bounds().width(), child->bounds().height() / 2)); | 4608 gfx::Size(child->bounds().width(), child->bounds().height() / 2)); |
4607 // The rotation depends on the layer's transform origin, and the child layer | 4609 // The rotation depends on the layer's transform origin, and the child layer |
4608 // is a different size than the clip, so make sure the clip layer's origin | 4610 // is a different size than the clip, so make sure the clip layer's origin |
4609 // lines up over the child. | 4611 // lines up over the child. |
4610 clip_layer->SetTransformOrigin(gfx::Point3F( | 4612 clip_layer->SetTransformOrigin(gfx::Point3F( |
4611 clip_layer->bounds().width() * 0.5f, clip_layer->bounds().height(), 0.f)); | 4613 clip_layer->bounds().width() * 0.5f, clip_layer->bounds().height(), 0.f)); |
4612 LayerImpl* child_ptr = child.get(); | 4614 LayerImpl* child_ptr = child.get(); |
4613 clip_layer->AddChild(child.Pass()); | 4615 clip_layer->AddChild(std::move(child)); |
4614 scroll_layer->AddChild(clip_layer.Pass()); | 4616 scroll_layer->AddChild(std::move(clip_layer)); |
4615 | 4617 |
4616 gfx::Size surface_size(50, 50); | 4618 gfx::Size surface_size(50, 50); |
4617 host_impl_->SetViewportSize(surface_size); | 4619 host_impl_->SetViewportSize(surface_size); |
4618 DrawFrame(); | 4620 DrawFrame(); |
4619 { | 4621 { |
4620 // Scroll down in screen coordinates with a gesture. | 4622 // Scroll down in screen coordinates with a gesture. |
4621 gfx::Vector2d gesture_scroll_delta(0, 10); | 4623 gfx::Vector2d gesture_scroll_delta(0, 10); |
4622 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 4624 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
4623 host_impl_->ScrollBegin(gfx::Point(1, 1), InputHandler::GESTURE)); | 4625 host_impl_->ScrollBegin(gfx::Point(1, 1), InputHandler::GESTURE)); |
4624 host_impl_->ScrollBy(gfx::Point(), gesture_scroll_delta); | 4626 host_impl_->ScrollBy(gfx::Point(), gesture_scroll_delta); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4681 perspective_transform.Translate(50.0, 50.0); | 4683 perspective_transform.Translate(50.0, 50.0); |
4682 clip_layer->SetTransform(perspective_transform); | 4684 clip_layer->SetTransform(perspective_transform); |
4683 | 4685 |
4684 clip_layer->SetBounds(gfx::Size(child_ptr->bounds().width() / 2, | 4686 clip_layer->SetBounds(gfx::Size(child_ptr->bounds().width() / 2, |
4685 child_ptr->bounds().height() / 2)); | 4687 child_ptr->bounds().height() / 2)); |
4686 // The transform depends on the layer's transform origin, and the child layer | 4688 // The transform depends on the layer's transform origin, and the child layer |
4687 // is a different size than the clip, so make sure the clip layer's origin | 4689 // is a different size than the clip, so make sure the clip layer's origin |
4688 // lines up over the child. | 4690 // lines up over the child. |
4689 clip_layer->SetTransformOrigin(gfx::Point3F( | 4691 clip_layer->SetTransformOrigin(gfx::Point3F( |
4690 clip_layer->bounds().width(), clip_layer->bounds().height(), 0.f)); | 4692 clip_layer->bounds().width(), clip_layer->bounds().height(), 0.f)); |
4691 clip_layer->AddChild(child.Pass()); | 4693 clip_layer->AddChild(std::move(child)); |
4692 scroll_layer->AddChild(clip_layer.Pass()); | 4694 scroll_layer->AddChild(std::move(clip_layer)); |
4693 | 4695 |
4694 gfx::Size surface_size(50, 50); | 4696 gfx::Size surface_size(50, 50); |
4695 host_impl_->SetViewportSize(surface_size); | 4697 host_impl_->SetViewportSize(surface_size); |
4696 | 4698 |
4697 scoped_ptr<ScrollAndScaleSet> scroll_info; | 4699 scoped_ptr<ScrollAndScaleSet> scroll_info; |
4698 | 4700 |
4699 gfx::Vector2d gesture_scroll_deltas[4]; | 4701 gfx::Vector2d gesture_scroll_deltas[4]; |
4700 gesture_scroll_deltas[0] = gfx::Vector2d(4, 10); | 4702 gesture_scroll_deltas[0] = gfx::Vector2d(4, 10); |
4701 gesture_scroll_deltas[1] = gfx::Vector2d(4, 10); | 4703 gesture_scroll_deltas[1] = gfx::Vector2d(4, 10); |
4702 gesture_scroll_deltas[2] = gfx::Vector2d(10, 0); | 4704 gesture_scroll_deltas[2] = gfx::Vector2d(10, 0); |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5109 | 5111 |
5110 scoped_ptr<LayerImpl> root = | 5112 scoped_ptr<LayerImpl> root = |
5111 CreateScrollableLayer(1, surface_size, root_clip.get()); | 5113 CreateScrollableLayer(1, surface_size, root_clip.get()); |
5112 | 5114 |
5113 scoped_ptr<LayerImpl> grand_child = | 5115 scoped_ptr<LayerImpl> grand_child = |
5114 CreateScrollableLayer(3, surface_size, root_clip.get()); | 5116 CreateScrollableLayer(3, surface_size, root_clip.get()); |
5115 | 5117 |
5116 scoped_ptr<LayerImpl> child = | 5118 scoped_ptr<LayerImpl> child = |
5117 CreateScrollableLayer(2, surface_size, root_clip.get()); | 5119 CreateScrollableLayer(2, surface_size, root_clip.get()); |
5118 LayerImpl* grand_child_layer = grand_child.get(); | 5120 LayerImpl* grand_child_layer = grand_child.get(); |
5119 child->AddChild(grand_child.Pass()); | 5121 child->AddChild(std::move(grand_child)); |
5120 | 5122 |
5121 LayerImpl* child_layer = child.get(); | 5123 LayerImpl* child_layer = child.get(); |
5122 root->AddChild(child.Pass()); | 5124 root->AddChild(std::move(child)); |
5123 root_clip->AddChild(root.Pass()); | 5125 root_clip->AddChild(std::move(root)); |
5124 child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 3)); | 5126 child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 3)); |
5125 grand_child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 2)); | 5127 grand_child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 2)); |
5126 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 5128 host_impl_->active_tree()->SetRootLayer(std::move(root_clip)); |
5127 host_impl_->active_tree()->DidBecomeActive(); | 5129 host_impl_->active_tree()->DidBecomeActive(); |
5128 host_impl_->SetViewportSize(surface_size); | 5130 host_impl_->SetViewportSize(surface_size); |
5129 DrawFrame(); | 5131 DrawFrame(); |
5130 { | 5132 { |
5131 gfx::Vector2d scroll_delta(0, -10); | 5133 gfx::Vector2d scroll_delta(0, -10); |
5132 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 5134 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
5133 host_impl_->ScrollBegin(gfx::Point(), | 5135 host_impl_->ScrollBegin(gfx::Point(), |
5134 InputHandler::NON_BUBBLING_GESTURE)); | 5136 InputHandler::NON_BUBBLING_GESTURE)); |
5135 scroll_result = host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 5137 scroll_result = host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
5136 EXPECT_TRUE(scroll_result.did_scroll); | 5138 EXPECT_TRUE(scroll_result.did_scroll); |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5356 ResourceId resource_id_; | 5358 ResourceId resource_id_; |
5357 }; | 5359 }; |
5358 | 5360 |
5359 TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { | 5361 TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { |
5360 { | 5362 { |
5361 scoped_ptr<LayerImpl> root = | 5363 scoped_ptr<LayerImpl> root = |
5362 LayerImpl::Create(host_impl_->active_tree(), 1); | 5364 LayerImpl::Create(host_impl_->active_tree(), 1); |
5363 root->SetBounds(gfx::Size(10, 10)); | 5365 root->SetBounds(gfx::Size(10, 10)); |
5364 root->SetDrawsContent(false); | 5366 root->SetDrawsContent(false); |
5365 root->SetHasRenderSurface(true); | 5367 root->SetHasRenderSurface(true); |
5366 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 5368 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
5367 } | 5369 } |
5368 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 5370 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
5369 | 5371 |
5370 root->AddChild( | 5372 root->AddChild( |
5371 BlendStateCheckLayer::Create(host_impl_->active_tree(), | 5373 BlendStateCheckLayer::Create(host_impl_->active_tree(), |
5372 2, | 5374 2, |
5373 host_impl_->resource_provider())); | 5375 host_impl_->resource_provider())); |
5374 BlendStateCheckLayer* layer1 = | 5376 BlendStateCheckLayer* layer1 = |
5375 static_cast<BlendStateCheckLayer*>(root->children()[0].get()); | 5377 static_cast<BlendStateCheckLayer*>(root->children()[0].get()); |
5376 layer1->SetPosition(gfx::PointF(2.f, 2.f)); | 5378 layer1->SetPosition(gfx::PointF(2.f, 2.f)); |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5845 : LayerImpl(tree_impl, id) {} | 5847 : LayerImpl(tree_impl, id) {} |
5846 }; | 5848 }; |
5847 | 5849 |
5848 // Only reshape when we know we are going to draw. Otherwise, the reshape | 5850 // Only reshape when we know we are going to draw. Otherwise, the reshape |
5849 // can leave the window at the wrong size if we never draw and the proper | 5851 // can leave the window at the wrong size if we never draw and the proper |
5850 // viewport size is never set. | 5852 // viewport size is never set. |
5851 TEST_F(LayerTreeHostImplTest, ReshapeNotCalledUntilDraw) { | 5853 TEST_F(LayerTreeHostImplTest, ReshapeNotCalledUntilDraw) { |
5852 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); | 5854 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); |
5853 scoped_ptr<OutputSurface> output_surface( | 5855 scoped_ptr<OutputSurface> output_surface( |
5854 FakeOutputSurface::Create3d(provider)); | 5856 FakeOutputSurface::Create3d(provider)); |
5855 CreateHostImpl(DefaultSettings(), output_surface.Pass()); | 5857 CreateHostImpl(DefaultSettings(), std::move(output_surface)); |
5856 | 5858 |
5857 scoped_ptr<LayerImpl> root = | 5859 scoped_ptr<LayerImpl> root = |
5858 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); | 5860 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); |
5859 root->SetBounds(gfx::Size(10, 10)); | 5861 root->SetBounds(gfx::Size(10, 10)); |
5860 root->SetDrawsContent(true); | 5862 root->SetDrawsContent(true); |
5861 root->SetHasRenderSurface(true); | 5863 root->SetHasRenderSurface(true); |
5862 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 5864 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
5863 EXPECT_FALSE(provider->TestContext3d()->reshape_called()); | 5865 EXPECT_FALSE(provider->TestContext3d()->reshape_called()); |
5864 provider->TestContext3d()->clear_reshape_called(); | 5866 provider->TestContext3d()->clear_reshape_called(); |
5865 | 5867 |
5866 LayerTreeHostImpl::FrameData frame; | 5868 LayerTreeHostImpl::FrameData frame; |
5867 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 5869 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
5868 host_impl_->active_tree()->SetDeviceScaleFactor(1.f); | 5870 host_impl_->active_tree()->SetDeviceScaleFactor(1.f); |
5869 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 5871 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
5870 host_impl_->DrawLayers(&frame); | 5872 host_impl_->DrawLayers(&frame); |
5871 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); | 5873 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); |
5872 EXPECT_EQ(provider->TestContext3d()->width(), 10); | 5874 EXPECT_EQ(provider->TestContext3d()->width(), 10); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5925 scoped_ptr<LayerImpl> root = | 5927 scoped_ptr<LayerImpl> root = |
5926 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); | 5928 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); |
5927 root->SetHasRenderSurface(true); | 5929 root->SetHasRenderSurface(true); |
5928 scoped_ptr<LayerImpl> child = | 5930 scoped_ptr<LayerImpl> child = |
5929 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); | 5931 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); |
5930 child->SetPosition(gfx::PointF(12.f, 13.f)); | 5932 child->SetPosition(gfx::PointF(12.f, 13.f)); |
5931 child->SetBounds(gfx::Size(14, 15)); | 5933 child->SetBounds(gfx::Size(14, 15)); |
5932 child->SetDrawsContent(true); | 5934 child->SetDrawsContent(true); |
5933 root->SetBounds(gfx::Size(500, 500)); | 5935 root->SetBounds(gfx::Size(500, 500)); |
5934 root->SetDrawsContent(true); | 5936 root->SetDrawsContent(true); |
5935 root->AddChild(child.Pass()); | 5937 root->AddChild(std::move(child)); |
5936 layer_tree_host_impl->active_tree()->SetRootLayer(root.Pass()); | 5938 layer_tree_host_impl->active_tree()->SetRootLayer(std::move(root)); |
5937 | 5939 |
5938 LayerTreeHostImpl::FrameData frame; | 5940 LayerTreeHostImpl::FrameData frame; |
5939 | 5941 |
5940 // First frame, the entire screen should get swapped. | 5942 // First frame, the entire screen should get swapped. |
5941 layer_tree_host_impl->active_tree()->BuildPropertyTreesForTesting(); | 5943 layer_tree_host_impl->active_tree()->BuildPropertyTreesForTesting(); |
5942 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); | 5944 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); |
5943 layer_tree_host_impl->DrawLayers(&frame); | 5945 layer_tree_host_impl->DrawLayers(&frame); |
5944 layer_tree_host_impl->DidDrawAllLayers(frame); | 5946 layer_tree_host_impl->DidDrawAllLayers(frame); |
5945 layer_tree_host_impl->SwapBuffers(frame); | 5947 layer_tree_host_impl->SwapBuffers(frame); |
5946 gfx::Rect expected_swap_rect(0, 0, 500, 500); | 5948 gfx::Rect expected_swap_rect(0, 0, 500, 500); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5984 TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) { | 5986 TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) { |
5985 scoped_ptr<LayerImpl> root = | 5987 scoped_ptr<LayerImpl> root = |
5986 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); | 5988 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); |
5987 scoped_ptr<LayerImpl> child = | 5989 scoped_ptr<LayerImpl> child = |
5988 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2); | 5990 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2); |
5989 child->SetBounds(gfx::Size(10, 10)); | 5991 child->SetBounds(gfx::Size(10, 10)); |
5990 child->SetDrawsContent(true); | 5992 child->SetDrawsContent(true); |
5991 root->SetBounds(gfx::Size(10, 10)); | 5993 root->SetBounds(gfx::Size(10, 10)); |
5992 root->SetDrawsContent(true); | 5994 root->SetDrawsContent(true); |
5993 root->SetHasRenderSurface(true); | 5995 root->SetHasRenderSurface(true); |
5994 root->AddChild(child.Pass()); | 5996 root->AddChild(std::move(child)); |
5995 | 5997 |
5996 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 5998 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
5997 | 5999 |
5998 LayerTreeHostImpl::FrameData frame; | 6000 LayerTreeHostImpl::FrameData frame; |
5999 | 6001 |
6000 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6002 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
6001 EXPECT_EQ(1u, frame.render_surface_layer_list->size()); | 6003 EXPECT_EQ(1u, frame.render_surface_layer_list->size()); |
6002 EXPECT_EQ(1u, frame.render_passes.size()); | 6004 EXPECT_EQ(1u, frame.render_passes.size()); |
6003 host_impl_->DidDrawAllLayers(frame); | 6005 host_impl_->DidDrawAllLayers(frame); |
6004 } | 6006 } |
6005 | 6007 |
6006 class FakeLayerWithQuads : public LayerImpl { | 6008 class FakeLayerWithQuads : public LayerImpl { |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6118 | 6120 |
6119 TEST_F(LayerTreeHostImplTest, NoPartialSwap) { | 6121 TEST_F(LayerTreeHostImplTest, NoPartialSwap) { |
6120 scoped_ptr<MockContext> mock_context_owned(new MockContext); | 6122 scoped_ptr<MockContext> mock_context_owned(new MockContext); |
6121 MockContext* mock_context = mock_context_owned.get(); | 6123 MockContext* mock_context = mock_context_owned.get(); |
6122 MockContextHarness harness(mock_context); | 6124 MockContextHarness harness(mock_context); |
6123 | 6125 |
6124 // Run test case | 6126 // Run test case |
6125 LayerTreeSettings settings = DefaultSettings(); | 6127 LayerTreeSettings settings = DefaultSettings(); |
6126 settings.renderer_settings.partial_swap_enabled = false; | 6128 settings.renderer_settings.partial_swap_enabled = false; |
6127 CreateHostImpl(settings, | 6129 CreateHostImpl(settings, |
6128 FakeOutputSurface::Create3d(mock_context_owned.Pass())); | 6130 FakeOutputSurface::Create3d(std::move(mock_context_owned))); |
6129 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); | 6131 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); |
6130 | 6132 |
6131 // Without partial swap, and no clipping, no scissor is set. | 6133 // Without partial swap, and no clipping, no scissor is set. |
6132 harness.MustDrawSolidQuad(); | 6134 harness.MustDrawSolidQuad(); |
6133 harness.MustSetNoScissor(); | 6135 harness.MustSetNoScissor(); |
6134 { | 6136 { |
6135 LayerTreeHostImpl::FrameData frame; | 6137 LayerTreeHostImpl::FrameData frame; |
6136 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6138 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
6137 host_impl_->DrawLayers(&frame); | 6139 host_impl_->DrawLayers(&frame); |
6138 host_impl_->DidDrawAllLayers(frame); | 6140 host_impl_->DidDrawAllLayers(frame); |
(...skipping 14 matching lines...) Expand all Loading... |
6153 Mock::VerifyAndClearExpectations(&mock_context); | 6155 Mock::VerifyAndClearExpectations(&mock_context); |
6154 } | 6156 } |
6155 | 6157 |
6156 TEST_F(LayerTreeHostImplTest, PartialSwap) { | 6158 TEST_F(LayerTreeHostImplTest, PartialSwap) { |
6157 scoped_ptr<MockContext> context_owned(new MockContext); | 6159 scoped_ptr<MockContext> context_owned(new MockContext); |
6158 MockContext* mock_context = context_owned.get(); | 6160 MockContext* mock_context = context_owned.get(); |
6159 MockContextHarness harness(mock_context); | 6161 MockContextHarness harness(mock_context); |
6160 | 6162 |
6161 LayerTreeSettings settings = DefaultSettings(); | 6163 LayerTreeSettings settings = DefaultSettings(); |
6162 settings.renderer_settings.partial_swap_enabled = true; | 6164 settings.renderer_settings.partial_swap_enabled = true; |
6163 CreateHostImpl(settings, FakeOutputSurface::Create3d(context_owned.Pass())); | 6165 CreateHostImpl(settings, |
| 6166 FakeOutputSurface::Create3d(std::move(context_owned))); |
6164 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); | 6167 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); |
6165 | 6168 |
6166 // The first frame is not a partially-swapped one. No scissor should be set. | 6169 // The first frame is not a partially-swapped one. No scissor should be set. |
6167 harness.MustSetNoScissor(); | 6170 harness.MustSetNoScissor(); |
6168 harness.MustDrawSolidQuad(); | 6171 harness.MustDrawSolidQuad(); |
6169 { | 6172 { |
6170 LayerTreeHostImpl::FrameData frame; | 6173 LayerTreeHostImpl::FrameData frame; |
6171 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6174 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
6172 host_impl_->DrawLayers(&frame); | 6175 host_impl_->DrawLayers(&frame); |
6173 host_impl_->DidDrawAllLayers(frame); | 6176 host_impl_->DidDrawAllLayers(frame); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6250 child->SetBounds(gfx::Size(child_rect.width(), child_rect.height())); | 6253 child->SetBounds(gfx::Size(child_rect.width(), child_rect.height())); |
6251 child->draw_properties().visible_layer_rect = child_rect; | 6254 child->draw_properties().visible_layer_rect = child_rect; |
6252 child->SetDrawsContent(false); | 6255 child->SetDrawsContent(false); |
6253 child->SetHasRenderSurface(true); | 6256 child->SetHasRenderSurface(true); |
6254 | 6257 |
6255 grand_child->SetPosition(gfx::PointF(grand_child_rect.origin())); | 6258 grand_child->SetPosition(gfx::PointF(grand_child_rect.origin())); |
6256 grand_child->SetBounds(grand_child_rect.size()); | 6259 grand_child->SetBounds(grand_child_rect.size()); |
6257 grand_child->draw_properties().visible_layer_rect = grand_child_rect; | 6260 grand_child->draw_properties().visible_layer_rect = grand_child_rect; |
6258 grand_child->SetDrawsContent(true); | 6261 grand_child->SetDrawsContent(true); |
6259 | 6262 |
6260 child->AddChild(grand_child.Pass()); | 6263 child->AddChild(std::move(grand_child)); |
6261 root->AddChild(child.Pass()); | 6264 root->AddChild(std::move(child)); |
6262 | 6265 |
6263 my_host_impl->active_tree()->SetRootLayer(root.Pass()); | 6266 my_host_impl->active_tree()->SetRootLayer(std::move(root)); |
6264 my_host_impl->active_tree()->BuildPropertyTreesForTesting(); | 6267 my_host_impl->active_tree()->BuildPropertyTreesForTesting(); |
6265 return my_host_impl.Pass(); | 6268 return my_host_impl; |
6266 } | 6269 } |
6267 | 6270 |
6268 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorPartialSwap) { | 6271 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorPartialSwap) { |
6269 TestSharedBitmapManager shared_bitmap_manager; | 6272 TestSharedBitmapManager shared_bitmap_manager; |
6270 TestTaskGraphRunner task_graph_runner; | 6273 TestTaskGraphRunner task_graph_runner; |
6271 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); | 6274 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); |
6272 provider->BindToCurrentThread(); | 6275 provider->BindToCurrentThread(); |
6273 provider->TestContext3d()->set_have_post_sub_buffer(true); | 6276 provider->TestContext3d()->set_have_post_sub_buffer(true); |
6274 scoped_ptr<OutputSurface> output_surface( | 6277 scoped_ptr<OutputSurface> output_surface( |
6275 FakeOutputSurface::Create3d(provider)); | 6278 FakeOutputSurface::Create3d(provider)); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6321 my_host_impl->DrawLayers(&frame); | 6324 my_host_impl->DrawLayers(&frame); |
6322 my_host_impl->DidDrawAllLayers(frame); | 6325 my_host_impl->DidDrawAllLayers(frame); |
6323 } | 6326 } |
6324 } | 6327 } |
6325 | 6328 |
6326 TEST_F(LayerTreeHostImplTest, LayersFreeTextures) { | 6329 TEST_F(LayerTreeHostImplTest, LayersFreeTextures) { |
6327 scoped_ptr<TestWebGraphicsContext3D> context = | 6330 scoped_ptr<TestWebGraphicsContext3D> context = |
6328 TestWebGraphicsContext3D::Create(); | 6331 TestWebGraphicsContext3D::Create(); |
6329 TestWebGraphicsContext3D* context3d = context.get(); | 6332 TestWebGraphicsContext3D* context3d = context.get(); |
6330 scoped_ptr<OutputSurface> output_surface( | 6333 scoped_ptr<OutputSurface> output_surface( |
6331 FakeOutputSurface::Create3d(context.Pass())); | 6334 FakeOutputSurface::Create3d(std::move(context))); |
6332 CreateHostImpl(DefaultSettings(), output_surface.Pass()); | 6335 CreateHostImpl(DefaultSettings(), std::move(output_surface)); |
6333 | 6336 |
6334 scoped_ptr<LayerImpl> root_layer = | 6337 scoped_ptr<LayerImpl> root_layer = |
6335 LayerImpl::Create(host_impl_->active_tree(), 1); | 6338 LayerImpl::Create(host_impl_->active_tree(), 1); |
6336 root_layer->SetBounds(gfx::Size(10, 10)); | 6339 root_layer->SetBounds(gfx::Size(10, 10)); |
6337 root_layer->SetHasRenderSurface(true); | 6340 root_layer->SetHasRenderSurface(true); |
6338 | 6341 |
6339 scoped_refptr<VideoFrame> softwareFrame = | 6342 scoped_refptr<VideoFrame> softwareFrame = |
6340 media::VideoFrame::CreateColorFrame( | 6343 media::VideoFrame::CreateColorFrame( |
6341 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); | 6344 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); |
6342 FakeVideoFrameProvider provider; | 6345 FakeVideoFrameProvider provider; |
6343 provider.set_frame(softwareFrame); | 6346 provider.set_frame(softwareFrame); |
6344 scoped_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( | 6347 scoped_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( |
6345 host_impl_->active_tree(), 4, &provider, media::VIDEO_ROTATION_0); | 6348 host_impl_->active_tree(), 4, &provider, media::VIDEO_ROTATION_0); |
6346 video_layer->SetBounds(gfx::Size(10, 10)); | 6349 video_layer->SetBounds(gfx::Size(10, 10)); |
6347 video_layer->SetDrawsContent(true); | 6350 video_layer->SetDrawsContent(true); |
6348 root_layer->AddChild(video_layer.Pass()); | 6351 root_layer->AddChild(std::move(video_layer)); |
6349 | 6352 |
6350 scoped_ptr<IOSurfaceLayerImpl> io_surface_layer = | 6353 scoped_ptr<IOSurfaceLayerImpl> io_surface_layer = |
6351 IOSurfaceLayerImpl::Create(host_impl_->active_tree(), 5); | 6354 IOSurfaceLayerImpl::Create(host_impl_->active_tree(), 5); |
6352 io_surface_layer->SetBounds(gfx::Size(10, 10)); | 6355 io_surface_layer->SetBounds(gfx::Size(10, 10)); |
6353 io_surface_layer->SetDrawsContent(true); | 6356 io_surface_layer->SetDrawsContent(true); |
6354 io_surface_layer->SetIOSurfaceProperties(1, gfx::Size(10, 10)); | 6357 io_surface_layer->SetIOSurfaceProperties(1, gfx::Size(10, 10)); |
6355 root_layer->AddChild(io_surface_layer.Pass()); | 6358 root_layer->AddChild(std::move(io_surface_layer)); |
6356 | 6359 |
6357 host_impl_->active_tree()->SetRootLayer(root_layer.Pass()); | 6360 host_impl_->active_tree()->SetRootLayer(std::move(root_layer)); |
6358 | 6361 |
6359 EXPECT_EQ(0u, context3d->NumTextures()); | 6362 EXPECT_EQ(0u, context3d->NumTextures()); |
6360 | 6363 |
6361 LayerTreeHostImpl::FrameData frame; | 6364 LayerTreeHostImpl::FrameData frame; |
6362 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6365 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
6363 host_impl_->DrawLayers(&frame); | 6366 host_impl_->DrawLayers(&frame); |
6364 host_impl_->DidDrawAllLayers(frame); | 6367 host_impl_->DidDrawAllLayers(frame); |
6365 host_impl_->SwapBuffers(frame); | 6368 host_impl_->SwapBuffers(frame); |
6366 | 6369 |
6367 EXPECT_GT(context3d->NumTextures(), 0u); | 6370 EXPECT_GT(context3d->NumTextures(), 0u); |
(...skipping 16 matching lines...) Expand all Loading... |
6384 | 6387 |
6385 TEST_F(LayerTreeHostImplTest, HasTransparentBackground) { | 6388 TEST_F(LayerTreeHostImplTest, HasTransparentBackground) { |
6386 scoped_ptr<MockDrawQuadsToFillScreenContext> mock_context_owned( | 6389 scoped_ptr<MockDrawQuadsToFillScreenContext> mock_context_owned( |
6387 new MockDrawQuadsToFillScreenContext); | 6390 new MockDrawQuadsToFillScreenContext); |
6388 MockDrawQuadsToFillScreenContext* mock_context = mock_context_owned.get(); | 6391 MockDrawQuadsToFillScreenContext* mock_context = mock_context_owned.get(); |
6389 | 6392 |
6390 // Run test case | 6393 // Run test case |
6391 LayerTreeSettings settings = DefaultSettings(); | 6394 LayerTreeSettings settings = DefaultSettings(); |
6392 settings.renderer_settings.partial_swap_enabled = false; | 6395 settings.renderer_settings.partial_swap_enabled = false; |
6393 CreateHostImpl(settings, | 6396 CreateHostImpl(settings, |
6394 FakeOutputSurface::Create3d(mock_context_owned.Pass())); | 6397 FakeOutputSurface::Create3d(std::move(mock_context_owned))); |
6395 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); | 6398 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); |
6396 host_impl_->active_tree()->set_background_color(SK_ColorWHITE); | 6399 host_impl_->active_tree()->set_background_color(SK_ColorWHITE); |
6397 | 6400 |
6398 // Verify one quad is drawn when transparent background set is not set. | 6401 // Verify one quad is drawn when transparent background set is not set. |
6399 host_impl_->active_tree()->set_has_transparent_background(false); | 6402 host_impl_->active_tree()->set_has_transparent_background(false); |
6400 EXPECT_CALL(*mock_context, useProgram(_)) | 6403 EXPECT_CALL(*mock_context, useProgram(_)) |
6401 .Times(1); | 6404 .Times(1); |
6402 EXPECT_CALL(*mock_context, drawElements(_, _, _, _)) | 6405 EXPECT_CALL(*mock_context, drawElements(_, _, _, _)) |
6403 .Times(1); | 6406 .Times(1); |
6404 LayerTreeHostImpl::FrameData frame; | 6407 LayerTreeHostImpl::FrameData frame; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6468 root->SetBounds(gfx::Size(10, 10)); | 6471 root->SetBounds(gfx::Size(10, 10)); |
6469 root->SetDrawsContent(true); | 6472 root->SetDrawsContent(true); |
6470 root->SetHasRenderSurface(true); | 6473 root->SetHasRenderSurface(true); |
6471 | 6474 |
6472 // Child layer is in the bottom right corner. | 6475 // Child layer is in the bottom right corner. |
6473 scoped_ptr<SolidColorLayerImpl> child = | 6476 scoped_ptr<SolidColorLayerImpl> child = |
6474 SolidColorLayerImpl::Create(host_impl_->active_tree(), 2); | 6477 SolidColorLayerImpl::Create(host_impl_->active_tree(), 2); |
6475 child->SetPosition(gfx::PointF(9.f, 9.f)); | 6478 child->SetPosition(gfx::PointF(9.f, 9.f)); |
6476 child->SetBounds(gfx::Size(1, 1)); | 6479 child->SetBounds(gfx::Size(1, 1)); |
6477 child->SetDrawsContent(true); | 6480 child->SetDrawsContent(true); |
6478 root->AddChild(child.Pass()); | 6481 root->AddChild(std::move(child)); |
6479 | 6482 |
6480 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 6483 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
6481 | 6484 |
6482 // Draw a frame. In the first frame, the entire viewport should be damaged. | 6485 // Draw a frame. In the first frame, the entire viewport should be damaged. |
6483 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); | 6486 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); |
6484 DrawFrameAndTestDamage(full_frame_damage); | 6487 DrawFrameAndTestDamage(full_frame_damage); |
6485 | 6488 |
6486 // The second frame has damage that doesn't touch the child layer. Its quads | 6489 // The second frame has damage that doesn't touch the child layer. Its quads |
6487 // should still be generated. | 6490 // should still be generated. |
6488 gfx::Rect small_damage = gfx::Rect(0, 0, 1, 1); | 6491 gfx::Rect small_damage = gfx::Rect(0, 0, 1, 1); |
6489 host_impl_->active_tree()->root_layer()->SetUpdateRect(small_damage); | 6492 host_impl_->active_tree()->root_layer()->SetUpdateRect(small_damage); |
6490 DrawFrameAndTestDamage(small_damage); | 6493 DrawFrameAndTestDamage(small_damage); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6536 host_impl_->CreatePendingTree(); | 6539 host_impl_->CreatePendingTree(); |
6537 host_impl_->pending_tree()->SetDeviceScaleFactor(device_scale_factor); | 6540 host_impl_->pending_tree()->SetDeviceScaleFactor(device_scale_factor); |
6538 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f / 16.f, | 6541 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f / 16.f, |
6539 16.f); | 6542 16.f); |
6540 | 6543 |
6541 scoped_ptr<LayerImpl> scoped_root = | 6544 scoped_ptr<LayerImpl> scoped_root = |
6542 LayerImpl::Create(host_impl_->pending_tree(), 1); | 6545 LayerImpl::Create(host_impl_->pending_tree(), 1); |
6543 LayerImpl* root = scoped_root.get(); | 6546 LayerImpl* root = scoped_root.get(); |
6544 root->SetHasRenderSurface(true); | 6547 root->SetHasRenderSurface(true); |
6545 | 6548 |
6546 host_impl_->pending_tree()->SetRootLayer(scoped_root.Pass()); | 6549 host_impl_->pending_tree()->SetRootLayer(std::move(scoped_root)); |
6547 | 6550 |
6548 scoped_ptr<LayerImpl> scoped_scrolling_layer = | 6551 scoped_ptr<LayerImpl> scoped_scrolling_layer = |
6549 LayerImpl::Create(host_impl_->pending_tree(), 2); | 6552 LayerImpl::Create(host_impl_->pending_tree(), 2); |
6550 LayerImpl* scrolling_layer = scoped_scrolling_layer.get(); | 6553 LayerImpl* scrolling_layer = scoped_scrolling_layer.get(); |
6551 root->AddChild(scoped_scrolling_layer.Pass()); | 6554 root->AddChild(std::move(scoped_scrolling_layer)); |
6552 | 6555 |
6553 gfx::Size content_layer_bounds(100000, 100); | 6556 gfx::Size content_layer_bounds(100000, 100); |
6554 scoped_refptr<FakeDisplayListRasterSource> raster_source( | 6557 scoped_refptr<FakeDisplayListRasterSource> raster_source( |
6555 FakeDisplayListRasterSource::CreateFilled(content_layer_bounds)); | 6558 FakeDisplayListRasterSource::CreateFilled(content_layer_bounds)); |
6556 | 6559 |
6557 scoped_ptr<FakePictureLayerImpl> scoped_content_layer = | 6560 scoped_ptr<FakePictureLayerImpl> scoped_content_layer = |
6558 FakePictureLayerImpl::CreateWithRasterSource(host_impl_->pending_tree(), | 6561 FakePictureLayerImpl::CreateWithRasterSource(host_impl_->pending_tree(), |
6559 3, raster_source); | 6562 3, raster_source); |
6560 LayerImpl* content_layer = scoped_content_layer.get(); | 6563 LayerImpl* content_layer = scoped_content_layer.get(); |
6561 scrolling_layer->AddChild(scoped_content_layer.Pass()); | 6564 scrolling_layer->AddChild(std::move(scoped_content_layer)); |
6562 content_layer->SetBounds(content_layer_bounds); | 6565 content_layer->SetBounds(content_layer_bounds); |
6563 content_layer->SetDrawsContent(true); | 6566 content_layer->SetDrawsContent(true); |
6564 | 6567 |
6565 root->SetBounds(root_size); | 6568 root->SetBounds(root_size); |
6566 | 6569 |
6567 gfx::ScrollOffset scroll_offset(100000, 0); | 6570 gfx::ScrollOffset scroll_offset(100000, 0); |
6568 scrolling_layer->SetScrollClipLayer(root->id()); | 6571 scrolling_layer->SetScrollClipLayer(root->id()); |
6569 scrolling_layer->PushScrollOffsetFromMainThread(scroll_offset); | 6572 scrolling_layer->PushScrollOffsetFromMainThread(scroll_offset); |
6570 | 6573 |
6571 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); | 6574 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6697 // SolidColorLayerImpl will be drawn. | 6700 // SolidColorLayerImpl will be drawn. |
6698 scoped_ptr<SolidColorLayerImpl> root_layer = | 6701 scoped_ptr<SolidColorLayerImpl> root_layer = |
6699 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 6702 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
6700 | 6703 |
6701 // VideoLayerImpl will not be drawn. | 6704 // VideoLayerImpl will not be drawn. |
6702 FakeVideoFrameProvider provider; | 6705 FakeVideoFrameProvider provider; |
6703 scoped_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( | 6706 scoped_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( |
6704 host_impl_->active_tree(), 2, &provider, media::VIDEO_ROTATION_0); | 6707 host_impl_->active_tree(), 2, &provider, media::VIDEO_ROTATION_0); |
6705 video_layer->SetBounds(gfx::Size(10, 10)); | 6708 video_layer->SetBounds(gfx::Size(10, 10)); |
6706 video_layer->SetDrawsContent(true); | 6709 video_layer->SetDrawsContent(true); |
6707 root_layer->AddChild(video_layer.Pass()); | 6710 root_layer->AddChild(std::move(video_layer)); |
6708 SetupRootLayerImpl(root_layer.Pass()); | 6711 SetupRootLayerImpl(std::move(root_layer)); |
6709 | 6712 |
6710 LayerTreeHostImpl::FrameData frame; | 6713 LayerTreeHostImpl::FrameData frame; |
6711 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6714 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
6712 host_impl_->DrawLayers(&frame); | 6715 host_impl_->DrawLayers(&frame); |
6713 host_impl_->DidDrawAllLayers(frame); | 6716 host_impl_->DidDrawAllLayers(frame); |
6714 | 6717 |
6715 EXPECT_EQ(1u, frame.will_draw_layers.size()); | 6718 EXPECT_EQ(1u, frame.will_draw_layers.size()); |
6716 EXPECT_EQ(host_impl_->active_tree()->root_layer(), frame.will_draw_layers[0]); | 6719 EXPECT_EQ(host_impl_->active_tree()->root_layer(), frame.will_draw_layers[0]); |
6717 } | 6720 } |
6718 | 6721 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6804 EXPECT_FALSE(fake_host_impl_->prepare_tiles_needed()); | 6807 EXPECT_FALSE(fake_host_impl_->prepare_tiles_needed()); |
6805 host_impl_->SetVisible(true); | 6808 host_impl_->SetVisible(true); |
6806 EXPECT_TRUE(fake_host_impl_->prepare_tiles_needed()); | 6809 EXPECT_TRUE(fake_host_impl_->prepare_tiles_needed()); |
6807 } | 6810 } |
6808 | 6811 |
6809 TEST_F(LayerTreeHostImplTest, UIResourceManagement) { | 6812 TEST_F(LayerTreeHostImplTest, UIResourceManagement) { |
6810 scoped_ptr<TestWebGraphicsContext3D> context = | 6813 scoped_ptr<TestWebGraphicsContext3D> context = |
6811 TestWebGraphicsContext3D::Create(); | 6814 TestWebGraphicsContext3D::Create(); |
6812 TestWebGraphicsContext3D* context3d = context.get(); | 6815 TestWebGraphicsContext3D* context3d = context.get(); |
6813 scoped_ptr<FakeOutputSurface> output_surface = FakeOutputSurface::Create3d(); | 6816 scoped_ptr<FakeOutputSurface> output_surface = FakeOutputSurface::Create3d(); |
6814 CreateHostImpl(DefaultSettings(), output_surface.Pass()); | 6817 CreateHostImpl(DefaultSettings(), std::move(output_surface)); |
6815 | 6818 |
6816 EXPECT_EQ(0u, context3d->NumTextures()); | 6819 EXPECT_EQ(0u, context3d->NumTextures()); |
6817 | 6820 |
6818 UIResourceId ui_resource_id = 1; | 6821 UIResourceId ui_resource_id = 1; |
6819 bool is_opaque = false; | 6822 bool is_opaque = false; |
6820 UIResourceBitmap bitmap(gfx::Size(1, 1), is_opaque); | 6823 UIResourceBitmap bitmap(gfx::Size(1, 1), is_opaque); |
6821 host_impl_->CreateUIResource(ui_resource_id, bitmap); | 6824 host_impl_->CreateUIResource(ui_resource_id, bitmap); |
6822 EXPECT_EQ(1u, context3d->NumTextures()); | 6825 EXPECT_EQ(1u, context3d->NumTextures()); |
6823 ResourceId id1 = host_impl_->ResourceIdForUIResource(ui_resource_id); | 6826 ResourceId id1 = host_impl_->ResourceIdForUIResource(ui_resource_id); |
6824 EXPECT_NE(0u, id1); | 6827 EXPECT_NE(0u, id1); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6920 scoped_ptr<LayerImpl> root_clip = | 6923 scoped_ptr<LayerImpl> root_clip = |
6921 LayerImpl::Create(host_impl_->active_tree(), 3); | 6924 LayerImpl::Create(host_impl_->active_tree(), 3); |
6922 root_clip->SetHasRenderSurface(true); | 6925 root_clip->SetHasRenderSurface(true); |
6923 | 6926 |
6924 scoped_ptr<LayerImpl> root = | 6927 scoped_ptr<LayerImpl> root = |
6925 CreateScrollableLayer(1, content_size, root_clip.get()); | 6928 CreateScrollableLayer(1, content_size, root_clip.get()); |
6926 root->SetIsContainerForFixedPositionLayers(true); | 6929 root->SetIsContainerForFixedPositionLayers(true); |
6927 scoped_ptr<LayerImpl> child = | 6930 scoped_ptr<LayerImpl> child = |
6928 CreateScrollableLayer(2, content_size, root_clip.get()); | 6931 CreateScrollableLayer(2, content_size, root_clip.get()); |
6929 | 6932 |
6930 root->AddChild(child.Pass()); | 6933 root->AddChild(std::move(child)); |
6931 int root_id = root->id(); | 6934 int root_id = root->id(); |
6932 root_clip->AddChild(root.Pass()); | 6935 root_clip->AddChild(std::move(root)); |
6933 | 6936 |
6934 host_impl_->SetViewportSize(surface_size); | 6937 host_impl_->SetViewportSize(surface_size); |
6935 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 6938 host_impl_->active_tree()->SetRootLayer(std::move(root_clip)); |
6936 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 3, 1, | 6939 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 3, 1, |
6937 Layer::INVALID_ID); | 6940 Layer::INVALID_ID); |
6938 host_impl_->active_tree()->DidBecomeActive(); | 6941 host_impl_->active_tree()->DidBecomeActive(); |
6939 DrawFrame(); | 6942 DrawFrame(); |
6940 { | 6943 { |
6941 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 6944 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
6942 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 6945 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
6943 | 6946 |
6944 EXPECT_EQ(InputHandler::SCROLL_STARTED, host_impl_->FlingScrollBegin()); | 6947 EXPECT_EQ(InputHandler::SCROLL_STARTED, host_impl_->FlingScrollBegin()); |
6945 | 6948 |
(...skipping 21 matching lines...) Expand all Loading... |
6967 scoped_ptr<LayerImpl> root_scrolling = | 6970 scoped_ptr<LayerImpl> root_scrolling = |
6968 CreateScrollableLayer(2, surface_size, root.get()); | 6971 CreateScrollableLayer(2, surface_size, root.get()); |
6969 | 6972 |
6970 scoped_ptr<LayerImpl> grand_child = | 6973 scoped_ptr<LayerImpl> grand_child = |
6971 CreateScrollableLayer(4, surface_size, root.get()); | 6974 CreateScrollableLayer(4, surface_size, root.get()); |
6972 grand_child->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 2)); | 6975 grand_child->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 2)); |
6973 | 6976 |
6974 scoped_ptr<LayerImpl> child = | 6977 scoped_ptr<LayerImpl> child = |
6975 CreateScrollableLayer(3, surface_size, root.get()); | 6978 CreateScrollableLayer(3, surface_size, root.get()); |
6976 child->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 4)); | 6979 child->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 4)); |
6977 child->AddChild(grand_child.Pass()); | 6980 child->AddChild(std::move(grand_child)); |
6978 | 6981 |
6979 root_scrolling->AddChild(child.Pass()); | 6982 root_scrolling->AddChild(std::move(child)); |
6980 root->AddChild(root_scrolling.Pass()); | 6983 root->AddChild(std::move(root_scrolling)); |
6981 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 6984 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
6982 host_impl_->active_tree()->DidBecomeActive(); | 6985 host_impl_->active_tree()->DidBecomeActive(); |
6983 host_impl_->SetViewportSize(surface_size); | 6986 host_impl_->SetViewportSize(surface_size); |
6984 DrawFrame(); | 6987 DrawFrame(); |
6985 { | 6988 { |
6986 scoped_ptr<ScrollAndScaleSet> scroll_info; | 6989 scoped_ptr<ScrollAndScaleSet> scroll_info; |
6987 LayerImpl* child = | 6990 LayerImpl* child = |
6988 host_impl_->active_tree()->root_layer()->children()[0]->children() | 6991 host_impl_->active_tree()->root_layer()->children()[0]->children() |
6989 [0].get(); | 6992 [0].get(); |
6990 LayerImpl* grand_child = child->children()[0].get(); | 6993 LayerImpl* grand_child = child->children()[0].get(); |
6991 | 6994 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7034 gfx::Size content_size(20, 20); | 7037 gfx::Size content_size(20, 20); |
7035 scoped_ptr<LayerImpl> root_clip = | 7038 scoped_ptr<LayerImpl> root_clip = |
7036 LayerImpl::Create(host_impl_->active_tree(), 3); | 7039 LayerImpl::Create(host_impl_->active_tree(), 3); |
7037 root_clip->SetHasRenderSurface(true); | 7040 root_clip->SetHasRenderSurface(true); |
7038 scoped_ptr<LayerImpl> root_scroll = | 7041 scoped_ptr<LayerImpl> root_scroll = |
7039 CreateScrollableLayer(1, content_size, root_clip.get()); | 7042 CreateScrollableLayer(1, content_size, root_clip.get()); |
7040 int root_scroll_id = root_scroll->id(); | 7043 int root_scroll_id = root_scroll->id(); |
7041 scoped_ptr<LayerImpl> child = | 7044 scoped_ptr<LayerImpl> child = |
7042 CreateScrollableLayer(2, content_size, root_clip.get()); | 7045 CreateScrollableLayer(2, content_size, root_clip.get()); |
7043 | 7046 |
7044 root_scroll->AddChild(child.Pass()); | 7047 root_scroll->AddChild(std::move(child)); |
7045 root_clip->AddChild(root_scroll.Pass()); | 7048 root_clip->AddChild(std::move(root_scroll)); |
7046 | 7049 |
7047 host_impl_->SetViewportSize(surface_size); | 7050 host_impl_->SetViewportSize(surface_size); |
7048 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 7051 host_impl_->active_tree()->SetRootLayer(std::move(root_clip)); |
7049 host_impl_->active_tree()->DidBecomeActive(); | 7052 host_impl_->active_tree()->DidBecomeActive(); |
7050 DrawFrame(); | 7053 DrawFrame(); |
7051 { | 7054 { |
7052 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 7055 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
7053 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 7056 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); |
7054 | 7057 |
7055 EXPECT_EQ(InputHandler::SCROLL_STARTED, host_impl_->FlingScrollBegin()); | 7058 EXPECT_EQ(InputHandler::SCROLL_STARTED, host_impl_->FlingScrollBegin()); |
7056 | 7059 |
7057 gfx::Vector2d scroll_delta(0, 100); | 7060 gfx::Vector2d scroll_delta(0, 100); |
7058 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 7061 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
(...skipping 26 matching lines...) Expand all Loading... |
7085 host_impl_->active_tree()->LayerById(page_scale_layer_id); | 7088 host_impl_->active_tree()->LayerById(page_scale_layer_id); |
7086 | 7089 |
7087 int occluder_layer_id = 6; | 7090 int occluder_layer_id = 6; |
7088 scoped_ptr<LayerImpl> occluder_layer = | 7091 scoped_ptr<LayerImpl> occluder_layer = |
7089 LayerImpl::Create(host_impl_->active_tree(), occluder_layer_id); | 7092 LayerImpl::Create(host_impl_->active_tree(), occluder_layer_id); |
7090 occluder_layer->SetDrawsContent(true); | 7093 occluder_layer->SetDrawsContent(true); |
7091 occluder_layer->SetBounds(content_size); | 7094 occluder_layer->SetBounds(content_size); |
7092 occluder_layer->SetPosition(gfx::PointF()); | 7095 occluder_layer->SetPosition(gfx::PointF()); |
7093 | 7096 |
7094 // The parent of the occluder is *above* the scroller. | 7097 // The parent of the occluder is *above* the scroller. |
7095 page_scale_layer->AddChild(occluder_layer.Pass()); | 7098 page_scale_layer->AddChild(std::move(occluder_layer)); |
7096 | 7099 |
7097 DrawFrame(); | 7100 DrawFrame(); |
7098 | 7101 |
7099 EXPECT_EQ(InputHandler::SCROLL_UNKNOWN, | 7102 EXPECT_EQ(InputHandler::SCROLL_UNKNOWN, |
7100 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 7103 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); |
7101 } | 7104 } |
7102 | 7105 |
7103 TEST_F(LayerTreeHostImplTest, ScrollUnknownScrollAncestorMismatch) { | 7106 TEST_F(LayerTreeHostImplTest, ScrollUnknownScrollAncestorMismatch) { |
7104 // If we ray cast a scroller this is on the first layer's ancestor chain, but | 7107 // If we ray cast a scroller this is on the first layer's ancestor chain, but |
7105 // is not the first scroller we encounter when walking up from the layer, we | 7108 // is not the first scroller we encounter when walking up from the layer, we |
(...skipping 16 matching lines...) Expand all Loading... |
7122 int child_scroll_clip_layer_id = 7; | 7125 int child_scroll_clip_layer_id = 7; |
7123 scoped_ptr<LayerImpl> child_scroll_clip = | 7126 scoped_ptr<LayerImpl> child_scroll_clip = |
7124 LayerImpl::Create(host_impl_->active_tree(), child_scroll_clip_layer_id); | 7127 LayerImpl::Create(host_impl_->active_tree(), child_scroll_clip_layer_id); |
7125 | 7128 |
7126 int child_scroll_layer_id = 8; | 7129 int child_scroll_layer_id = 8; |
7127 scoped_ptr<LayerImpl> child_scroll = CreateScrollableLayer( | 7130 scoped_ptr<LayerImpl> child_scroll = CreateScrollableLayer( |
7128 child_scroll_layer_id, content_size, child_scroll_clip.get()); | 7131 child_scroll_layer_id, content_size, child_scroll_clip.get()); |
7129 | 7132 |
7130 child_scroll->SetPosition(gfx::PointF(10.f, 10.f)); | 7133 child_scroll->SetPosition(gfx::PointF(10.f, 10.f)); |
7131 | 7134 |
7132 child_scroll->AddChild(occluder_layer.Pass()); | 7135 child_scroll->AddChild(std::move(occluder_layer)); |
7133 scroll_layer->AddChild(child_scroll.Pass()); | 7136 scroll_layer->AddChild(std::move(child_scroll)); |
7134 | 7137 |
7135 DrawFrame(); | 7138 DrawFrame(); |
7136 | 7139 |
7137 EXPECT_EQ(InputHandler::SCROLL_UNKNOWN, | 7140 EXPECT_EQ(InputHandler::SCROLL_UNKNOWN, |
7138 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 7141 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); |
7139 } | 7142 } |
7140 | 7143 |
7141 TEST_F(LayerTreeHostImplTest, NotScrollInvisibleScroller) { | 7144 TEST_F(LayerTreeHostImplTest, NotScrollInvisibleScroller) { |
7142 gfx::Size content_size(100, 100); | 7145 gfx::Size content_size(100, 100); |
7143 SetupScrollAndContentsLayers(content_size); | 7146 SetupScrollAndContentsLayers(content_size); |
7144 | 7147 |
7145 LayerImpl* root = host_impl_->active_tree()->LayerById(1); | 7148 LayerImpl* root = host_impl_->active_tree()->LayerById(1); |
7146 | 7149 |
7147 int scroll_layer_id = 2; | 7150 int scroll_layer_id = 2; |
7148 LayerImpl* scroll_layer = | 7151 LayerImpl* scroll_layer = |
7149 host_impl_->active_tree()->LayerById(scroll_layer_id); | 7152 host_impl_->active_tree()->LayerById(scroll_layer_id); |
7150 | 7153 |
7151 int child_scroll_layer_id = 7; | 7154 int child_scroll_layer_id = 7; |
7152 scoped_ptr<LayerImpl> child_scroll = | 7155 scoped_ptr<LayerImpl> child_scroll = |
7153 CreateScrollableLayer(child_scroll_layer_id, content_size, root); | 7156 CreateScrollableLayer(child_scroll_layer_id, content_size, root); |
7154 child_scroll->SetDrawsContent(false); | 7157 child_scroll->SetDrawsContent(false); |
7155 | 7158 |
7156 scroll_layer->AddChild(child_scroll.Pass()); | 7159 scroll_layer->AddChild(std::move(child_scroll)); |
7157 | 7160 |
7158 DrawFrame(); | 7161 DrawFrame(); |
7159 | 7162 |
7160 // We should not have scrolled |child_scroll| even though we technically "hit" | 7163 // We should not have scrolled |child_scroll| even though we technically "hit" |
7161 // it. The reason for this is that if the scrolling the scroll would not move | 7164 // it. The reason for this is that if the scrolling the scroll would not move |
7162 // any layer that is a drawn RSLL member, then we can ignore the hit. | 7165 // any layer that is a drawn RSLL member, then we can ignore the hit. |
7163 // | 7166 // |
7164 // Why SCROLL_STARTED? In this case, it's because we've bubbled out and | 7167 // Why SCROLL_STARTED? In this case, it's because we've bubbled out and |
7165 // started scrolling the inner viewport. | 7168 // started scrolling the inner viewport. |
7166 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 7169 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
(...skipping 17 matching lines...) Expand all Loading... |
7184 LayerImpl::Create(host_impl_->active_tree(), 8); | 7187 LayerImpl::Create(host_impl_->active_tree(), 8); |
7185 child_layer->SetDrawsContent(false); | 7188 child_layer->SetDrawsContent(false); |
7186 | 7189 |
7187 scoped_ptr<LayerImpl> grand_child_layer = | 7190 scoped_ptr<LayerImpl> grand_child_layer = |
7188 LayerImpl::Create(host_impl_->active_tree(), 9); | 7191 LayerImpl::Create(host_impl_->active_tree(), 9); |
7189 grand_child_layer->SetDrawsContent(true); | 7192 grand_child_layer->SetDrawsContent(true); |
7190 grand_child_layer->SetBounds(content_size); | 7193 grand_child_layer->SetBounds(content_size); |
7191 // Move the grand child so it's not hit by our test point. | 7194 // Move the grand child so it's not hit by our test point. |
7192 grand_child_layer->SetPosition(gfx::PointF(10.f, 10.f)); | 7195 grand_child_layer->SetPosition(gfx::PointF(10.f, 10.f)); |
7193 | 7196 |
7194 child_layer->AddChild(grand_child_layer.Pass()); | 7197 child_layer->AddChild(std::move(grand_child_layer)); |
7195 invisible_scroll_layer->AddChild(child_layer.Pass()); | 7198 invisible_scroll_layer->AddChild(std::move(child_layer)); |
7196 root_scroll_layer->AddChild(invisible_scroll_layer.Pass()); | 7199 root_scroll_layer->AddChild(std::move(invisible_scroll_layer)); |
7197 | 7200 |
7198 DrawFrame(); | 7201 DrawFrame(); |
7199 | 7202 |
7200 // We should have scrolled |invisible_scroll_layer| as it was hit and it has | 7203 // We should have scrolled |invisible_scroll_layer| as it was hit and it has |
7201 // a descendant which is a drawn RSLL member. | 7204 // a descendant which is a drawn RSLL member. |
7202 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 7205 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
7203 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 7206 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); |
7204 | 7207 |
7205 EXPECT_EQ(7, host_impl_->CurrentlyScrollingLayer()->id()); | 7208 EXPECT_EQ(7, host_impl_->CurrentlyScrollingLayer()->id()); |
7206 } | 7209 } |
(...skipping 28 matching lines...) Expand all Loading... |
7235 int container_id = 8; | 7238 int container_id = 8; |
7236 scoped_ptr<LayerImpl> container = | 7239 scoped_ptr<LayerImpl> container = |
7237 LayerImpl::Create(host_impl_->active_tree(), container_id); | 7240 LayerImpl::Create(host_impl_->active_tree(), container_id); |
7238 | 7241 |
7239 scoped_ptr<std::set<LayerImpl*>> scroll_children(new std::set<LayerImpl*>); | 7242 scoped_ptr<std::set<LayerImpl*>> scroll_children(new std::set<LayerImpl*>); |
7240 scroll_children->insert(scroll_child.get()); | 7243 scroll_children->insert(scroll_child.get()); |
7241 invisible_scroll->SetScrollChildren(scroll_children.release()); | 7244 invisible_scroll->SetScrollChildren(scroll_children.release()); |
7242 | 7245 |
7243 scroll_child->SetScrollParent(invisible_scroll.get()); | 7246 scroll_child->SetScrollParent(invisible_scroll.get()); |
7244 | 7247 |
7245 container->AddChild(invisible_scroll.Pass()); | 7248 container->AddChild(std::move(invisible_scroll)); |
7246 container->AddChild(scroll_child.Pass()); | 7249 container->AddChild(std::move(scroll_child)); |
7247 | 7250 |
7248 scroll_layer->AddChild(container.Pass()); | 7251 scroll_layer->AddChild(std::move(container)); |
7249 | 7252 |
7250 DrawFrame(); | 7253 DrawFrame(); |
7251 | 7254 |
7252 // We should have scrolled |child_scroll| even though it is invisible. | 7255 // We should have scrolled |child_scroll| even though it is invisible. |
7253 // The reason for this is that if the scrolling the scroll would move a layer | 7256 // The reason for this is that if the scrolling the scroll would move a layer |
7254 // that is a drawn RSLL member, then we should accept this hit. | 7257 // that is a drawn RSLL member, then we should accept this hit. |
7255 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 7258 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
7256 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 7259 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); |
7257 | 7260 |
7258 EXPECT_EQ(7, host_impl_->CurrentlyScrollingLayer()->id()); | 7261 EXPECT_EQ(7, host_impl_->CurrentlyScrollingLayer()->id()); |
7259 } | 7262 } |
7260 | 7263 |
7261 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed | 7264 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed |
7262 // to CompositorFrameMetadata after SwapBuffers(); | 7265 // to CompositorFrameMetadata after SwapBuffers(); |
7263 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { | 7266 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { |
7264 scoped_ptr<SolidColorLayerImpl> root = | 7267 scoped_ptr<SolidColorLayerImpl> root = |
7265 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 7268 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
7266 root->SetPosition(gfx::PointF()); | 7269 root->SetPosition(gfx::PointF()); |
7267 root->SetBounds(gfx::Size(10, 10)); | 7270 root->SetBounds(gfx::Size(10, 10)); |
7268 root->SetDrawsContent(true); | 7271 root->SetDrawsContent(true); |
7269 root->SetHasRenderSurface(true); | 7272 root->SetHasRenderSurface(true); |
7270 | 7273 |
7271 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 7274 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
7272 | 7275 |
7273 FakeOutputSurface* fake_output_surface = | 7276 FakeOutputSurface* fake_output_surface = |
7274 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); | 7277 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); |
7275 | 7278 |
7276 const std::vector<ui::LatencyInfo>& metadata_latency_before = | 7279 const std::vector<ui::LatencyInfo>& metadata_latency_before = |
7277 fake_output_surface->last_sent_frame().metadata.latency_info; | 7280 fake_output_surface->last_sent_frame().metadata.latency_info; |
7278 EXPECT_TRUE(metadata_latency_before.empty()); | 7281 EXPECT_TRUE(metadata_latency_before.empty()); |
7279 | 7282 |
7280 ui::LatencyInfo latency_info; | 7283 ui::LatencyInfo latency_info; |
7281 latency_info.AddLatencyNumber( | 7284 latency_info.AddLatencyNumber( |
7282 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, 0); | 7285 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, 0); |
7283 scoped_ptr<SwapPromise> swap_promise( | 7286 scoped_ptr<SwapPromise> swap_promise( |
7284 new LatencyInfoSwapPromise(latency_info)); | 7287 new LatencyInfoSwapPromise(latency_info)); |
7285 host_impl_->active_tree()->QueuePinnedSwapPromise(swap_promise.Pass()); | 7288 host_impl_->active_tree()->QueuePinnedSwapPromise(std::move(swap_promise)); |
7286 host_impl_->SetNeedsRedraw(); | 7289 host_impl_->SetNeedsRedraw(); |
7287 | 7290 |
7288 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); | 7291 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); |
7289 LayerTreeHostImpl::FrameData frame; | 7292 LayerTreeHostImpl::FrameData frame; |
7290 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 7293 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
7291 host_impl_->DrawLayers(&frame); | 7294 host_impl_->DrawLayers(&frame); |
7292 host_impl_->DidDrawAllLayers(frame); | 7295 host_impl_->DidDrawAllLayers(frame); |
7293 EXPECT_TRUE(host_impl_->SwapBuffers(frame)); | 7296 EXPECT_TRUE(host_impl_->SwapBuffers(frame)); |
7294 | 7297 |
7295 const std::vector<ui::LatencyInfo>& metadata_latency_after = | 7298 const std::vector<ui::LatencyInfo>& metadata_latency_after = |
7296 fake_output_surface->last_sent_frame().metadata.latency_info; | 7299 fake_output_surface->last_sent_frame().metadata.latency_info; |
7297 EXPECT_EQ(1u, metadata_latency_after.size()); | 7300 EXPECT_EQ(1u, metadata_latency_after.size()); |
7298 EXPECT_TRUE(metadata_latency_after[0].FindLatency( | 7301 EXPECT_TRUE(metadata_latency_after[0].FindLatency( |
7299 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, NULL)); | 7302 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, NULL)); |
7300 } | 7303 } |
7301 | 7304 |
7302 TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) { | 7305 TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) { |
7303 int root_layer_id = 1; | 7306 int root_layer_id = 1; |
7304 scoped_ptr<SolidColorLayerImpl> root = | 7307 scoped_ptr<SolidColorLayerImpl> root = |
7305 SolidColorLayerImpl::Create(host_impl_->active_tree(), root_layer_id); | 7308 SolidColorLayerImpl::Create(host_impl_->active_tree(), root_layer_id); |
7306 root->SetPosition(gfx::PointF()); | 7309 root->SetPosition(gfx::PointF()); |
7307 root->SetBounds(gfx::Size(10, 10)); | 7310 root->SetBounds(gfx::Size(10, 10)); |
7308 root->SetDrawsContent(true); | 7311 root->SetDrawsContent(true); |
7309 root->SetHasRenderSurface(true); | 7312 root->SetHasRenderSurface(true); |
7310 | 7313 |
7311 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 7314 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
7312 | 7315 |
7313 // Ensure the default frame selection bounds are empty. | 7316 // Ensure the default frame selection bounds are empty. |
7314 FakeOutputSurface* fake_output_surface = | 7317 FakeOutputSurface* fake_output_surface = |
7315 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); | 7318 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); |
7316 const ViewportSelection& selection_before = | 7319 const ViewportSelection& selection_before = |
7317 fake_output_surface->last_sent_frame().metadata.selection; | 7320 fake_output_surface->last_sent_frame().metadata.selection; |
7318 EXPECT_EQ(ViewportSelectionBound(), selection_before.start); | 7321 EXPECT_EQ(ViewportSelectionBound(), selection_before.start); |
7319 EXPECT_EQ(ViewportSelectionBound(), selection_before.end); | 7322 EXPECT_EQ(ViewportSelectionBound(), selection_before.end); |
7320 | 7323 |
7321 // Plumb the layer-local selection bounds. | 7324 // Plumb the layer-local selection bounds. |
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7928 outer_scroll->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); | 7931 outer_scroll->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); |
7929 outer_scroll->SetBounds(content_size); | 7932 outer_scroll->SetBounds(content_size); |
7930 outer_scroll->SetPosition(gfx::PointF()); | 7933 outer_scroll->SetPosition(gfx::PointF()); |
7931 | 7934 |
7932 scoped_ptr<LayerImpl> contents = | 7935 scoped_ptr<LayerImpl> contents = |
7933 LayerImpl::Create(layer_tree_impl, 8); | 7936 LayerImpl::Create(layer_tree_impl, 8); |
7934 contents->SetDrawsContent(true); | 7937 contents->SetDrawsContent(true); |
7935 contents->SetBounds(content_size); | 7938 contents->SetBounds(content_size); |
7936 contents->SetPosition(gfx::PointF()); | 7939 contents->SetPosition(gfx::PointF()); |
7937 | 7940 |
7938 outer_scroll->AddChild(contents.Pass()); | 7941 outer_scroll->AddChild(std::move(contents)); |
7939 outer_clip->AddChild(outer_scroll.Pass()); | 7942 outer_clip->AddChild(std::move(outer_scroll)); |
7940 inner_scroll->AddChild(outer_clip.Pass()); | 7943 inner_scroll->AddChild(std::move(outer_clip)); |
7941 page_scale->AddChild(inner_scroll.Pass()); | 7944 page_scale->AddChild(std::move(inner_scroll)); |
7942 inner_clip->AddChild(page_scale.Pass()); | 7945 inner_clip->AddChild(std::move(page_scale)); |
7943 | 7946 |
7944 inner_clip->SetHasRenderSurface(true); | 7947 inner_clip->SetHasRenderSurface(true); |
7945 layer_tree_impl->SetRootLayer(inner_clip.Pass()); | 7948 layer_tree_impl->SetRootLayer(std::move(inner_clip)); |
7946 layer_tree_impl->SetViewportLayersFromIds( | 7949 layer_tree_impl->SetViewportLayersFromIds( |
7947 Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportScrollLayerId, | 7950 Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportScrollLayerId, |
7948 kOuterViewportScrollLayerId); | 7951 kOuterViewportScrollLayerId); |
7949 | 7952 |
7950 host_impl_->active_tree()->DidBecomeActive(); | 7953 host_impl_->active_tree()->DidBecomeActive(); |
7951 } | 7954 } |
7952 }; | 7955 }; |
7953 | 7956 |
7954 TEST_F(LayerTreeHostImplVirtualViewportTest, ScrollBothInnerAndOuterLayer) { | 7957 TEST_F(LayerTreeHostImplVirtualViewportTest, ScrollBothInnerAndOuterLayer) { |
7955 gfx::Size content_size = gfx::Size(100, 160); | 7958 gfx::Size content_size = gfx::Size(100, 160); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8100 gfx::Size inner_viewport = gfx::Size(25, 40); | 8103 gfx::Size inner_viewport = gfx::Size(25, 40); |
8101 | 8104 |
8102 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); | 8105 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); |
8103 | 8106 |
8104 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); | 8107 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); |
8105 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); | 8108 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); |
8106 | 8109 |
8107 scoped_ptr<LayerImpl> child = | 8110 scoped_ptr<LayerImpl> child = |
8108 CreateScrollableLayer(10, outer_viewport, outer_scroll); | 8111 CreateScrollableLayer(10, outer_viewport, outer_scroll); |
8109 LayerImpl* child_scroll = child.get(); | 8112 LayerImpl* child_scroll = child.get(); |
8110 outer_scroll->children()[0]->AddChild(child.Pass()); | 8113 outer_scroll->children()[0]->AddChild(std::move(child)); |
8111 | 8114 |
8112 DrawFrame(); | 8115 DrawFrame(); |
8113 { | 8116 { |
8114 scoped_ptr<ScrollAndScaleSet> scroll_info; | 8117 scoped_ptr<ScrollAndScaleSet> scroll_info; |
8115 | 8118 |
8116 gfx::Vector2d scroll_delta(0, inner_viewport.height()); | 8119 gfx::Vector2d scroll_delta(0, inner_viewport.height()); |
8117 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 8120 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
8118 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 8121 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
8119 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll); | 8122 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll); |
8120 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), | 8123 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8157 gfx::Size inner_viewport = gfx::Size(25, 40); | 8160 gfx::Size inner_viewport = gfx::Size(25, 40); |
8158 | 8161 |
8159 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); | 8162 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); |
8160 | 8163 |
8161 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); | 8164 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); |
8162 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); | 8165 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); |
8163 | 8166 |
8164 scoped_ptr<LayerImpl> child = | 8167 scoped_ptr<LayerImpl> child = |
8165 CreateScrollableLayer(10, outer_viewport, outer_scroll); | 8168 CreateScrollableLayer(10, outer_viewport, outer_scroll); |
8166 LayerImpl* child_scroll = child.get(); | 8169 LayerImpl* child_scroll = child.get(); |
8167 outer_scroll->children()[0]->AddChild(child.Pass()); | 8170 outer_scroll->children()[0]->AddChild(std::move(child)); |
8168 | 8171 |
8169 DrawFrame(); | 8172 DrawFrame(); |
8170 | 8173 |
8171 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 8174 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
8172 host_impl_->RootScrollBegin(InputHandler::GESTURE)); | 8175 host_impl_->RootScrollBegin(InputHandler::GESTURE)); |
8173 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), inner_scroll); | 8176 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), inner_scroll); |
8174 host_impl_->ScrollEnd(); | 8177 host_impl_->ScrollEnd(); |
8175 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 8178 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
8176 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 8179 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
8177 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_scroll); | 8180 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_scroll); |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8593 layer->set_gpu_raster_max_texture_size(host_impl_->device_viewport_size()); | 8596 layer->set_gpu_raster_max_texture_size(host_impl_->device_viewport_size()); |
8594 layer->SetDrawsContent(true); | 8597 layer->SetDrawsContent(true); |
8595 layer->tilings()->AddTiling(1.0f, raster_source_with_tiles); | 8598 layer->tilings()->AddTiling(1.0f, raster_source_with_tiles); |
8596 layer->UpdateRasterSource(raster_source_with_tiles, &empty_invalidation, | 8599 layer->UpdateRasterSource(raster_source_with_tiles, &empty_invalidation, |
8597 nullptr); | 8600 nullptr); |
8598 layer->tilings()->tiling_at(0)->set_resolution( | 8601 layer->tilings()->tiling_at(0)->set_resolution( |
8599 TileResolution::HIGH_RESOLUTION); | 8602 TileResolution::HIGH_RESOLUTION); |
8600 layer->tilings()->tiling_at(0)->CreateAllTilesForTesting(); | 8603 layer->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
8601 layer->tilings()->tiling_at(0)->ComputeTilePriorityRects( | 8604 layer->tilings()->tiling_at(0)->ComputeTilePriorityRects( |
8602 gfx::Rect(gfx::Size(10, 10)), 1.f, 1.0, Occlusion()); | 8605 gfx::Rect(gfx::Size(10, 10)), 1.f, 1.0, Occlusion()); |
8603 host_impl_->pending_tree()->SetRootLayer(layer.Pass()); | 8606 host_impl_->pending_tree()->SetRootLayer(std::move(layer)); |
8604 | 8607 |
8605 FakePictureLayerImpl* root_layer = static_cast<FakePictureLayerImpl*>( | 8608 FakePictureLayerImpl* root_layer = static_cast<FakePictureLayerImpl*>( |
8606 host_impl_->pending_tree()->root_layer()); | 8609 host_impl_->pending_tree()->root_layer()); |
8607 | 8610 |
8608 root_layer->set_has_valid_tile_priorities(true); | 8611 root_layer->set_has_valid_tile_priorities(true); |
8609 scoped_ptr<RasterTilePriorityQueue> non_empty_raster_priority_queue_all = | 8612 scoped_ptr<RasterTilePriorityQueue> non_empty_raster_priority_queue_all = |
8610 host_impl_->BuildRasterQueue(TreePriority::SAME_PRIORITY_FOR_BOTH_TREES, | 8613 host_impl_->BuildRasterQueue(TreePriority::SAME_PRIORITY_FOR_BOTH_TREES, |
8611 RasterTilePriorityQueue::Type::ALL); | 8614 RasterTilePriorityQueue::Type::ALL); |
8612 EXPECT_FALSE(non_empty_raster_priority_queue_all->IsEmpty()); | 8615 EXPECT_FALSE(non_empty_raster_priority_queue_all->IsEmpty()); |
8613 | 8616 |
8614 root_layer->set_has_valid_tile_priorities(false); | 8617 root_layer->set_has_valid_tile_priorities(false); |
8615 scoped_ptr<RasterTilePriorityQueue> empty_raster_priority_queue_all = | 8618 scoped_ptr<RasterTilePriorityQueue> empty_raster_priority_queue_all = |
8616 host_impl_->BuildRasterQueue(TreePriority::SAME_PRIORITY_FOR_BOTH_TREES, | 8619 host_impl_->BuildRasterQueue(TreePriority::SAME_PRIORITY_FOR_BOTH_TREES, |
8617 RasterTilePriorityQueue::Type::ALL); | 8620 RasterTilePriorityQueue::Type::ALL); |
8618 EXPECT_TRUE(empty_raster_priority_queue_all->IsEmpty()); | 8621 EXPECT_TRUE(empty_raster_priority_queue_all->IsEmpty()); |
8619 } | 8622 } |
8620 | 8623 |
8621 TEST_F(LayerTreeHostImplTest, DidBecomeActive) { | 8624 TEST_F(LayerTreeHostImplTest, DidBecomeActive) { |
8622 host_impl_->CreatePendingTree(); | 8625 host_impl_->CreatePendingTree(); |
8623 host_impl_->ActivateSyncTree(); | 8626 host_impl_->ActivateSyncTree(); |
8624 host_impl_->CreatePendingTree(); | 8627 host_impl_->CreatePendingTree(); |
8625 | 8628 |
8626 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); | 8629 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); |
8627 | 8630 |
8628 scoped_ptr<FakePictureLayerImpl> pending_layer = | 8631 scoped_ptr<FakePictureLayerImpl> pending_layer = |
8629 FakePictureLayerImpl::Create(pending_tree, 10); | 8632 FakePictureLayerImpl::Create(pending_tree, 10); |
8630 FakePictureLayerImpl* raw_pending_layer = pending_layer.get(); | 8633 FakePictureLayerImpl* raw_pending_layer = pending_layer.get(); |
8631 pending_tree->SetRootLayer(pending_layer.Pass()); | 8634 pending_tree->SetRootLayer(std::move(pending_layer)); |
8632 ASSERT_EQ(raw_pending_layer, pending_tree->root_layer()); | 8635 ASSERT_EQ(raw_pending_layer, pending_tree->root_layer()); |
8633 | 8636 |
8634 EXPECT_EQ(0u, raw_pending_layer->did_become_active_call_count()); | 8637 EXPECT_EQ(0u, raw_pending_layer->did_become_active_call_count()); |
8635 pending_tree->DidBecomeActive(); | 8638 pending_tree->DidBecomeActive(); |
8636 EXPECT_EQ(1u, raw_pending_layer->did_become_active_call_count()); | 8639 EXPECT_EQ(1u, raw_pending_layer->did_become_active_call_count()); |
8637 | 8640 |
8638 scoped_ptr<FakePictureLayerImpl> mask_layer = | 8641 scoped_ptr<FakePictureLayerImpl> mask_layer = |
8639 FakePictureLayerImpl::Create(pending_tree, 11); | 8642 FakePictureLayerImpl::Create(pending_tree, 11); |
8640 FakePictureLayerImpl* raw_mask_layer = mask_layer.get(); | 8643 FakePictureLayerImpl* raw_mask_layer = mask_layer.get(); |
8641 raw_pending_layer->SetMaskLayer(mask_layer.Pass()); | 8644 raw_pending_layer->SetMaskLayer(std::move(mask_layer)); |
8642 ASSERT_EQ(raw_mask_layer, raw_pending_layer->mask_layer()); | 8645 ASSERT_EQ(raw_mask_layer, raw_pending_layer->mask_layer()); |
8643 | 8646 |
8644 EXPECT_EQ(1u, raw_pending_layer->did_become_active_call_count()); | 8647 EXPECT_EQ(1u, raw_pending_layer->did_become_active_call_count()); |
8645 EXPECT_EQ(0u, raw_mask_layer->did_become_active_call_count()); | 8648 EXPECT_EQ(0u, raw_mask_layer->did_become_active_call_count()); |
8646 pending_tree->DidBecomeActive(); | 8649 pending_tree->DidBecomeActive(); |
8647 EXPECT_EQ(2u, raw_pending_layer->did_become_active_call_count()); | 8650 EXPECT_EQ(2u, raw_pending_layer->did_become_active_call_count()); |
8648 EXPECT_EQ(1u, raw_mask_layer->did_become_active_call_count()); | 8651 EXPECT_EQ(1u, raw_mask_layer->did_become_active_call_count()); |
8649 | 8652 |
8650 scoped_ptr<FakePictureLayerImpl> replica_layer = | 8653 scoped_ptr<FakePictureLayerImpl> replica_layer = |
8651 FakePictureLayerImpl::Create(pending_tree, 12); | 8654 FakePictureLayerImpl::Create(pending_tree, 12); |
8652 scoped_ptr<FakePictureLayerImpl> replica_mask_layer = | 8655 scoped_ptr<FakePictureLayerImpl> replica_mask_layer = |
8653 FakePictureLayerImpl::Create(pending_tree, 13); | 8656 FakePictureLayerImpl::Create(pending_tree, 13); |
8654 FakePictureLayerImpl* raw_replica_mask_layer = replica_mask_layer.get(); | 8657 FakePictureLayerImpl* raw_replica_mask_layer = replica_mask_layer.get(); |
8655 replica_layer->SetMaskLayer(replica_mask_layer.Pass()); | 8658 replica_layer->SetMaskLayer(std::move(replica_mask_layer)); |
8656 raw_pending_layer->SetReplicaLayer(replica_layer.Pass()); | 8659 raw_pending_layer->SetReplicaLayer(std::move(replica_layer)); |
8657 ASSERT_EQ(raw_replica_mask_layer, | 8660 ASSERT_EQ(raw_replica_mask_layer, |
8658 raw_pending_layer->replica_layer()->mask_layer()); | 8661 raw_pending_layer->replica_layer()->mask_layer()); |
8659 | 8662 |
8660 EXPECT_EQ(2u, raw_pending_layer->did_become_active_call_count()); | 8663 EXPECT_EQ(2u, raw_pending_layer->did_become_active_call_count()); |
8661 EXPECT_EQ(1u, raw_mask_layer->did_become_active_call_count()); | 8664 EXPECT_EQ(1u, raw_mask_layer->did_become_active_call_count()); |
8662 EXPECT_EQ(0u, raw_replica_mask_layer->did_become_active_call_count()); | 8665 EXPECT_EQ(0u, raw_replica_mask_layer->did_become_active_call_count()); |
8663 pending_tree->DidBecomeActive(); | 8666 pending_tree->DidBecomeActive(); |
8664 EXPECT_EQ(3u, raw_pending_layer->did_become_active_call_count()); | 8667 EXPECT_EQ(3u, raw_pending_layer->did_become_active_call_count()); |
8665 EXPECT_EQ(2u, raw_mask_layer->did_become_active_call_count()); | 8668 EXPECT_EQ(2u, raw_mask_layer->did_become_active_call_count()); |
8666 EXPECT_EQ(1u, raw_replica_mask_layer->did_become_active_call_count()); | 8669 EXPECT_EQ(1u, raw_replica_mask_layer->did_become_active_call_count()); |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8944 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 8947 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
8945 EXPECT_FALSE(host_impl_->use_msaa()); | 8948 EXPECT_FALSE(host_impl_->use_msaa()); |
8946 | 8949 |
8947 scoped_ptr<TestWebGraphicsContext3D> context_with_msaa = | 8950 scoped_ptr<TestWebGraphicsContext3D> context_with_msaa = |
8948 TestWebGraphicsContext3D::Create(); | 8951 TestWebGraphicsContext3D::Create(); |
8949 context_with_msaa->SetMaxSamples(8); | 8952 context_with_msaa->SetMaxSamples(8); |
8950 | 8953 |
8951 LayerTreeSettings msaaSettings = GpuRasterizationEnabledSettings(); | 8954 LayerTreeSettings msaaSettings = GpuRasterizationEnabledSettings(); |
8952 msaaSettings.gpu_rasterization_msaa_sample_count = 4; | 8955 msaaSettings.gpu_rasterization_msaa_sample_count = 4; |
8953 EXPECT_TRUE(CreateHostImpl( | 8956 EXPECT_TRUE(CreateHostImpl( |
8954 msaaSettings, FakeOutputSurface::Create3d(context_with_msaa.Pass()))); | 8957 msaaSettings, FakeOutputSurface::Create3d(std::move(context_with_msaa)))); |
8955 host_impl_->SetHasGpuRasterizationTrigger(true); | 8958 host_impl_->SetHasGpuRasterizationTrigger(true); |
8956 host_impl_->SetContentIsSuitableForGpuRasterization(false); | 8959 host_impl_->SetContentIsSuitableForGpuRasterization(false); |
8957 EXPECT_EQ(GpuRasterizationStatus::MSAA_CONTENT, | 8960 EXPECT_EQ(GpuRasterizationStatus::MSAA_CONTENT, |
8958 host_impl_->gpu_rasterization_status()); | 8961 host_impl_->gpu_rasterization_status()); |
8959 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); | 8962 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); |
8960 EXPECT_TRUE(host_impl_->use_msaa()); | 8963 EXPECT_TRUE(host_impl_->use_msaa()); |
8961 | 8964 |
8962 LayerTreeSettings settings = DefaultSettings(); | 8965 LayerTreeSettings settings = DefaultSettings(); |
8963 settings.gpu_rasterization_enabled = false; | 8966 settings.gpu_rasterization_enabled = false; |
8964 EXPECT_TRUE(CreateHostImpl(settings, FakeOutputSurface::Create3d())); | 8967 EXPECT_TRUE(CreateHostImpl(settings, FakeOutputSurface::Create3d())); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9002 // Display::Draw (and the planned Display Scheduler) currently rely on resources | 9005 // Display::Draw (and the planned Display Scheduler) currently rely on resources |
9003 // being reclaimed to block drawing between BeginCommit / Swap. This test | 9006 // being reclaimed to block drawing between BeginCommit / Swap. This test |
9004 // ensures that BeginCommit triggers ForceReclaimResources. See | 9007 // ensures that BeginCommit triggers ForceReclaimResources. See |
9005 // crbug.com/489515. | 9008 // crbug.com/489515. |
9006 TEST_F(LayerTreeHostImplTest, BeginCommitReclaimsResources) { | 9009 TEST_F(LayerTreeHostImplTest, BeginCommitReclaimsResources) { |
9007 scoped_ptr<MockReclaimResourcesOutputSurface> output_surface( | 9010 scoped_ptr<MockReclaimResourcesOutputSurface> output_surface( |
9008 MockReclaimResourcesOutputSurface::Create3d()); | 9011 MockReclaimResourcesOutputSurface::Create3d()); |
9009 // Hold an unowned pointer to the output surface to use for mock expectations. | 9012 // Hold an unowned pointer to the output surface to use for mock expectations. |
9010 MockReclaimResourcesOutputSurface* mock_output_surface = output_surface.get(); | 9013 MockReclaimResourcesOutputSurface* mock_output_surface = output_surface.get(); |
9011 | 9014 |
9012 CreateHostImpl(DefaultSettings(), output_surface.Pass()); | 9015 CreateHostImpl(DefaultSettings(), std::move(output_surface)); |
9013 EXPECT_CALL(*mock_output_surface, ForceReclaimResources()).Times(1); | 9016 EXPECT_CALL(*mock_output_surface, ForceReclaimResources()).Times(1); |
9014 host_impl_->BeginCommit(); | 9017 host_impl_->BeginCommit(); |
9015 } | 9018 } |
9016 | 9019 |
9017 TEST_F(LayerTreeHostImplTest, UpdatePageScaleFactorOnActiveTree) { | 9020 TEST_F(LayerTreeHostImplTest, UpdatePageScaleFactorOnActiveTree) { |
9018 // Check page scale factor update in property trees when an update is made | 9021 // Check page scale factor update in property trees when an update is made |
9019 // on the active tree. | 9022 // on the active tree. |
9020 host_impl_->CreatePendingTree(); | 9023 host_impl_->CreatePendingTree(); |
9021 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 3.f); | 9024 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 3.f); |
9022 CreateScrollAndContentsLayers(host_impl_->pending_tree(), | 9025 CreateScrollAndContentsLayers(host_impl_->pending_tree(), |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9076 host_impl_->active_tree()->SetPageScaleOnActiveTree(2.f); | 9079 host_impl_->active_tree()->SetPageScaleOnActiveTree(2.f); |
9077 DrawFrame(); | 9080 DrawFrame(); |
9078 in_subtree_of_page_scale_layer = host_impl_->active_tree()->LayerById(100); | 9081 in_subtree_of_page_scale_layer = host_impl_->active_tree()->LayerById(100); |
9079 node = host_impl_->active_tree()->property_trees()->transform_tree.Node( | 9082 node = host_impl_->active_tree()->property_trees()->transform_tree.Node( |
9080 in_subtree_of_page_scale_layer->transform_tree_index()); | 9083 in_subtree_of_page_scale_layer->transform_tree_index()); |
9081 EXPECT_EQ(node->data.sublayer_scale, gfx::Vector2dF(2.f, 2.f)); | 9084 EXPECT_EQ(node->data.sublayer_scale, gfx::Vector2dF(2.f, 2.f)); |
9082 } | 9085 } |
9083 | 9086 |
9084 } // namespace | 9087 } // namespace |
9085 } // namespace cc | 9088 } // namespace cc |
OLD | NEW |