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

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

Issue 2317953002: cc: Merge the DrawLayer()/DrawFrame() and SwapBuffers() methods. (Closed)
Patch Set: merge-draw-swap-2: rebase Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/proxy_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/layer_tree_host_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 LayerTreeHostImplTest() 97 LayerTreeHostImplTest()
98 : task_runner_provider_(base::ThreadTaskRunnerHandle::Get()), 98 : task_runner_provider_(base::ThreadTaskRunnerHandle::Get()),
99 always_main_thread_blocked_(&task_runner_provider_), 99 always_main_thread_blocked_(&task_runner_provider_),
100 on_can_draw_state_changed_called_(false), 100 on_can_draw_state_changed_called_(false),
101 did_notify_ready_to_activate_(false), 101 did_notify_ready_to_activate_(false),
102 did_request_commit_(false), 102 did_request_commit_(false),
103 did_request_redraw_(false), 103 did_request_redraw_(false),
104 did_request_next_frame_(false), 104 did_request_next_frame_(false),
105 did_request_prepare_tiles_(false), 105 did_request_prepare_tiles_(false),
106 did_complete_page_scale_animation_(false), 106 did_complete_page_scale_animation_(false),
107 reduce_memory_result_(true), 107 reduce_memory_result_(true) {
108 skip_draw_layers_in_on_draw_(false) {
109 media::InitializeMediaLibrary(); 108 media::InitializeMediaLibrary();
110 } 109 }
111 110
112 LayerTreeSettings DefaultSettings() { 111 LayerTreeSettings DefaultSettings() {
113 LayerTreeSettings settings; 112 LayerTreeSettings settings;
114 settings.minimum_occlusion_tracking_size = gfx::Size(); 113 settings.minimum_occlusion_tracking_size = gfx::Size();
115 settings.renderer_settings.texture_id_allocation_chunk_size = 1; 114 settings.renderer_settings.texture_id_allocation_chunk_size = 1;
116 settings.gpu_rasterization_enabled = true; 115 settings.gpu_rasterization_enabled = true;
117 settings.verify_clip_tree_calculations = true; 116 settings.verify_clip_tree_calculations = true;
118 settings.verify_transform_tree_calculations = true; 117 settings.verify_transform_tree_calculations = true;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 void DidPrepareTiles() override {} 167 void DidPrepareTiles() override {}
169 void DidCompletePageScaleAnimationOnImplThread() override { 168 void DidCompletePageScaleAnimationOnImplThread() override {
170 did_complete_page_scale_animation_ = true; 169 did_complete_page_scale_animation_ = true;
171 } 170 }
172 void OnDrawForOutputSurface(bool resourceless_software_draw) override { 171 void OnDrawForOutputSurface(bool resourceless_software_draw) override {
173 std::unique_ptr<LayerTreeHostImpl::FrameData> frame( 172 std::unique_ptr<LayerTreeHostImpl::FrameData> frame(
174 new LayerTreeHostImpl::FrameData); 173 new LayerTreeHostImpl::FrameData);
175 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(frame.get())); 174 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(frame.get()));
176 last_on_draw_render_passes_.clear(); 175 last_on_draw_render_passes_.clear();
177 RenderPass::CopyAll(frame->render_passes, &last_on_draw_render_passes_); 176 RenderPass::CopyAll(frame->render_passes, &last_on_draw_render_passes_);
178 if (!skip_draw_layers_in_on_draw_) 177 host_impl_->DrawLayers(frame.get());
179 host_impl_->DrawLayers(frame.get());
180 host_impl_->DidDrawAllLayers(*frame); 178 host_impl_->DidDrawAllLayers(*frame);
181 host_impl_->SwapBuffers(*frame);
182 last_on_draw_frame_ = std::move(frame); 179 last_on_draw_frame_ = std::move(frame);
183 } 180 }
184 181
185 void set_reduce_memory_result(bool reduce_memory_result) { 182 void set_reduce_memory_result(bool reduce_memory_result) {
186 reduce_memory_result_ = reduce_memory_result; 183 reduce_memory_result_ = reduce_memory_result;
187 } 184 }
188 185
189 virtual bool CreateHostImpl(const LayerTreeSettings& settings, 186 virtual bool CreateHostImpl(const LayerTreeSettings& settings,
190 std::unique_ptr<OutputSurface> output_surface) { 187 std::unique_ptr<OutputSurface> output_surface) {
191 return CreateHostImplWithTaskRunnerProvider( 188 return CreateHostImplWithTaskRunnerProvider(
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 std::unique_ptr<ScrollState> scroll_state( 447 std::unique_ptr<ScrollState> scroll_state(
451 new ScrollState(scroll_state_data)); 448 new ScrollState(scroll_state_data));
452 return scroll_state; 449 return scroll_state;
453 } 450 }
454 451
455 void DrawFrame() { 452 void DrawFrame() {
456 LayerTreeHostImpl::FrameData frame; 453 LayerTreeHostImpl::FrameData frame;
457 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 454 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
458 host_impl_->DrawLayers(&frame); 455 host_impl_->DrawLayers(&frame);
459 host_impl_->DidDrawAllLayers(frame); 456 host_impl_->DidDrawAllLayers(frame);
460 host_impl_->SwapBuffers(frame);
461 } 457 }
462 458
463 void pinch_zoom_pan_viewport_forces_commit_redraw(float device_scale_factor); 459 void pinch_zoom_pan_viewport_forces_commit_redraw(float device_scale_factor);
464 void pinch_zoom_pan_viewport_test(float device_scale_factor); 460 void pinch_zoom_pan_viewport_test(float device_scale_factor);
465 void pinch_zoom_pan_viewport_and_scroll_test(float device_scale_factor); 461 void pinch_zoom_pan_viewport_and_scroll_test(float device_scale_factor);
466 void pinch_zoom_pan_viewport_and_scroll_boundary_test( 462 void pinch_zoom_pan_viewport_and_scroll_boundary_test(
467 float device_scale_factor); 463 float device_scale_factor);
468 464
469 void SetupMouseMoveAtWithDeviceScale(float device_scale_factor); 465 void SetupMouseMoveAtWithDeviceScale(float device_scale_factor);
470 466
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 bool on_can_draw_state_changed_called_; 508 bool on_can_draw_state_changed_called_;
513 bool did_notify_ready_to_activate_; 509 bool did_notify_ready_to_activate_;
514 bool did_request_commit_; 510 bool did_request_commit_;
515 bool did_request_redraw_; 511 bool did_request_redraw_;
516 bool did_request_next_frame_; 512 bool did_request_next_frame_;
517 bool did_request_prepare_tiles_; 513 bool did_request_prepare_tiles_;
518 bool did_complete_page_scale_animation_; 514 bool did_complete_page_scale_animation_;
519 bool reduce_memory_result_; 515 bool reduce_memory_result_;
520 base::Closure animation_task_; 516 base::Closure animation_task_;
521 base::TimeDelta requested_animation_delay_; 517 base::TimeDelta requested_animation_delay_;
522 bool skip_draw_layers_in_on_draw_;
523 std::unique_ptr<LayerTreeHostImpl::FrameData> last_on_draw_frame_; 518 std::unique_ptr<LayerTreeHostImpl::FrameData> last_on_draw_frame_;
524 RenderPassList last_on_draw_render_passes_; 519 RenderPassList last_on_draw_render_passes_;
525 scoped_refptr<AnimationTimeline> timeline_; 520 scoped_refptr<AnimationTimeline> timeline_;
526 }; 521 };
527 522
528 // A test fixture for new animation timelines tests. 523 // A test fixture for new animation timelines tests.
529 class LayerTreeHostImplTimelinesTest : public LayerTreeHostImplTest { 524 class LayerTreeHostImplTimelinesTest : public LayerTreeHostImplTest {
530 public: 525 public:
531 void SetUp() override { 526 void SetUp() override {
532 CreateHostImpl(DefaultSettings(), CreateOutputSurface()); 527 CreateHostImpl(DefaultSettings(), CreateOutputSurface());
(...skipping 2952 matching lines...) Expand 10 before | Expand all | Expand 10 after
3485 DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); 3480 DidDrawCheckLayer::Create(host_impl_->active_tree(), 2));
3486 root->test_properties()->force_render_surface = true; 3481 root->test_properties()->force_render_surface = true;
3487 DidDrawCheckLayer* layer = 3482 DidDrawCheckLayer* layer =
3488 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[0]); 3483 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[0]);
3489 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 3484 host_impl_->active_tree()->BuildPropertyTreesForTesting();
3490 3485
3491 { 3486 {
3492 LayerTreeHostImpl::FrameData frame; 3487 LayerTreeHostImpl::FrameData frame;
3493 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 3488 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3494 host_impl_->DrawLayers(&frame); 3489 host_impl_->DrawLayers(&frame);
3495 host_impl_->SwapBuffers(frame);
3496 host_impl_->DidDrawAllLayers(frame); 3490 host_impl_->DidDrawAllLayers(frame);
3497 3491
3498 EXPECT_TRUE(layer->will_draw_called()); 3492 EXPECT_TRUE(layer->will_draw_called());
3499 EXPECT_TRUE(layer->append_quads_called()); 3493 EXPECT_TRUE(layer->append_quads_called());
3500 EXPECT_TRUE(layer->did_draw_called()); 3494 EXPECT_TRUE(layer->did_draw_called());
3501 } 3495 }
3502 3496
3503 host_impl_->SetViewportDamage(gfx::Rect(10, 10)); 3497 host_impl_->SetViewportDamage(gfx::Rect(10, 10));
3504 3498
3505 { 3499 {
3506 LayerTreeHostImpl::FrameData frame; 3500 LayerTreeHostImpl::FrameData frame;
3507 3501
3508 layer->set_will_draw_returns_false(); 3502 layer->set_will_draw_returns_false();
3509 layer->ClearDidDrawCheck(); 3503 layer->ClearDidDrawCheck();
3510 3504
3511 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 3505 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3512 host_impl_->DrawLayers(&frame); 3506 host_impl_->DrawLayers(&frame);
3513 host_impl_->SwapBuffers(frame);
3514 host_impl_->DidDrawAllLayers(frame); 3507 host_impl_->DidDrawAllLayers(frame);
3515 3508
3516 EXPECT_TRUE(layer->will_draw_called()); 3509 EXPECT_TRUE(layer->will_draw_called());
3517 EXPECT_FALSE(layer->append_quads_called()); 3510 EXPECT_FALSE(layer->append_quads_called());
3518 EXPECT_FALSE(layer->did_draw_called()); 3511 EXPECT_FALSE(layer->did_draw_called());
3519 } 3512 }
3520 } 3513 }
3521 3514
3522 TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) { 3515 TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) {
3523 // The root layer is always drawn, so run this test on a child layer that 3516 // The root layer is always drawn, so run this test on a child layer that
(...skipping 13 matching lines...) Expand all
3537 layer->SetBounds(gfx::Size(10, 10)); 3530 layer->SetBounds(gfx::Size(10, 10));
3538 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 3531 host_impl_->active_tree()->BuildPropertyTreesForTesting();
3539 3532
3540 LayerTreeHostImpl::FrameData frame; 3533 LayerTreeHostImpl::FrameData frame;
3541 3534
3542 EXPECT_FALSE(layer->will_draw_called()); 3535 EXPECT_FALSE(layer->will_draw_called());
3543 EXPECT_FALSE(layer->did_draw_called()); 3536 EXPECT_FALSE(layer->did_draw_called());
3544 3537
3545 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 3538 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3546 host_impl_->DrawLayers(&frame); 3539 host_impl_->DrawLayers(&frame);
3547 host_impl_->SwapBuffers(frame);
3548 host_impl_->DidDrawAllLayers(frame); 3540 host_impl_->DidDrawAllLayers(frame);
3549 3541
3550 EXPECT_FALSE(layer->will_draw_called()); 3542 EXPECT_FALSE(layer->will_draw_called());
3551 EXPECT_FALSE(layer->did_draw_called()); 3543 EXPECT_FALSE(layer->did_draw_called());
3552 3544
3553 EXPECT_TRUE(layer->visible_layer_rect().IsEmpty()); 3545 EXPECT_TRUE(layer->visible_layer_rect().IsEmpty());
3554 3546
3555 // Ensure visible_layer_rect for layer is not empty 3547 // Ensure visible_layer_rect for layer is not empty
3556 layer->SetPosition(gfx::PointF()); 3548 layer->SetPosition(gfx::PointF());
3557 layer->NoteLayerPropertyChanged(); 3549 layer->NoteLayerPropertyChanged();
3558 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 3550 host_impl_->active_tree()->BuildPropertyTreesForTesting();
3559 3551
3560 EXPECT_FALSE(layer->will_draw_called()); 3552 EXPECT_FALSE(layer->will_draw_called());
3561 EXPECT_FALSE(layer->did_draw_called()); 3553 EXPECT_FALSE(layer->did_draw_called());
3562 3554
3563 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 3555 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3564 host_impl_->DrawLayers(&frame); 3556 host_impl_->DrawLayers(&frame);
3565 host_impl_->SwapBuffers(frame);
3566 host_impl_->DidDrawAllLayers(frame); 3557 host_impl_->DidDrawAllLayers(frame);
3567 3558
3568 EXPECT_TRUE(layer->will_draw_called()); 3559 EXPECT_TRUE(layer->will_draw_called());
3569 EXPECT_TRUE(layer->did_draw_called()); 3560 EXPECT_TRUE(layer->did_draw_called());
3570 3561
3571 EXPECT_FALSE(layer->visible_layer_rect().IsEmpty()); 3562 EXPECT_FALSE(layer->visible_layer_rect().IsEmpty());
3572 } 3563 }
3573 3564
3574 TEST_F(LayerTreeHostImplTest, WillDrawNotCalledOnOccludedLayer) { 3565 TEST_F(LayerTreeHostImplTest, WillDrawNotCalledOnOccludedLayer) {
3575 gfx::Size big_size(1000, 1000); 3566 gfx::Size big_size(1000, 1000);
(...skipping 22 matching lines...) Expand all
3598 3589
3599 LayerTreeHostImpl::FrameData frame; 3590 LayerTreeHostImpl::FrameData frame;
3600 3591
3601 EXPECT_FALSE(occluded_layer->will_draw_called()); 3592 EXPECT_FALSE(occluded_layer->will_draw_called());
3602 EXPECT_FALSE(occluded_layer->did_draw_called()); 3593 EXPECT_FALSE(occluded_layer->did_draw_called());
3603 EXPECT_FALSE(top_layer->will_draw_called()); 3594 EXPECT_FALSE(top_layer->will_draw_called());
3604 EXPECT_FALSE(top_layer->did_draw_called()); 3595 EXPECT_FALSE(top_layer->did_draw_called());
3605 3596
3606 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 3597 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3607 host_impl_->DrawLayers(&frame); 3598 host_impl_->DrawLayers(&frame);
3608 host_impl_->SwapBuffers(frame);
3609 host_impl_->DidDrawAllLayers(frame); 3599 host_impl_->DidDrawAllLayers(frame);
3610 3600
3611 EXPECT_FALSE(occluded_layer->will_draw_called()); 3601 EXPECT_FALSE(occluded_layer->will_draw_called());
3612 EXPECT_FALSE(occluded_layer->did_draw_called()); 3602 EXPECT_FALSE(occluded_layer->did_draw_called());
3613 EXPECT_TRUE(top_layer->will_draw_called()); 3603 EXPECT_TRUE(top_layer->will_draw_called());
3614 EXPECT_TRUE(top_layer->did_draw_called()); 3604 EXPECT_TRUE(top_layer->did_draw_called());
3615 } 3605 }
3616 3606
3617 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { 3607 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) {
3618 host_impl_->active_tree()->SetRootLayerForTesting( 3608 host_impl_->active_tree()->SetRootLayerForTesting(
(...skipping 18 matching lines...) Expand all
3637 3627
3638 EXPECT_FALSE(root->did_draw_called()); 3628 EXPECT_FALSE(root->did_draw_called());
3639 EXPECT_FALSE(layer1->did_draw_called()); 3629 EXPECT_FALSE(layer1->did_draw_called());
3640 EXPECT_FALSE(layer2->did_draw_called()); 3630 EXPECT_FALSE(layer2->did_draw_called());
3641 3631
3642 LayerTreeHostImpl::FrameData frame; 3632 LayerTreeHostImpl::FrameData frame;
3643 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( 3633 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(
3644 *host_impl_->active_tree()->begin()); 3634 *host_impl_->active_tree()->begin());
3645 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 3635 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3646 host_impl_->DrawLayers(&frame); 3636 host_impl_->DrawLayers(&frame);
3647 host_impl_->SwapBuffers(frame);
3648 host_impl_->DidDrawAllLayers(frame); 3637 host_impl_->DidDrawAllLayers(frame);
3649 3638
3650 EXPECT_TRUE(root->did_draw_called()); 3639 EXPECT_TRUE(root->did_draw_called());
3651 EXPECT_TRUE(layer1->did_draw_called()); 3640 EXPECT_TRUE(layer1->did_draw_called());
3652 EXPECT_TRUE(layer2->did_draw_called()); 3641 EXPECT_TRUE(layer2->did_draw_called());
3653 3642
3654 EXPECT_NE(root->render_surface(), layer1->render_surface()); 3643 EXPECT_NE(root->render_surface(), layer1->render_surface());
3655 EXPECT_TRUE(layer1->render_surface()); 3644 EXPECT_TRUE(layer1->render_surface());
3656 } 3645 }
3657 3646
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
3808 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); 3797 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1));
3809 DidDrawCheckLayer* root = 3798 DidDrawCheckLayer* root =
3810 static_cast<DidDrawCheckLayer*>(*host_impl_->active_tree()->begin()); 3799 static_cast<DidDrawCheckLayer*>(*host_impl_->active_tree()->begin());
3811 root->test_properties()->force_render_surface = true; 3800 root->test_properties()->force_render_surface = true;
3812 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 3801 host_impl_->active_tree()->BuildPropertyTreesForTesting();
3813 3802
3814 LayerTreeHostImpl::FrameData frame; 3803 LayerTreeHostImpl::FrameData frame;
3815 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 3804 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3816 host_impl_->DrawLayers(&frame); 3805 host_impl_->DrawLayers(&frame);
3817 host_impl_->DidDrawAllLayers(frame); 3806 host_impl_->DidDrawAllLayers(frame);
3818 host_impl_->SwapBuffers(frame);
3819 3807
3820 for (size_t i = 0; i < cases.size(); ++i) { 3808 for (size_t i = 0; i < cases.size(); ++i) {
3821 // Clean up host_impl_ state. 3809 // Clean up host_impl_ state.
3822 const auto& testcase = cases[i]; 3810 const auto& testcase = cases[i];
3823 std::vector<LayerImpl*> to_remove; 3811 std::vector<LayerImpl*> to_remove;
3824 for (auto* child : root->test_properties()->children) 3812 for (auto* child : root->test_properties()->children)
3825 to_remove.push_back(child); 3813 to_remove.push_back(child);
3826 for (auto* child : to_remove) 3814 for (auto* child : to_remove)
3827 root->test_properties()->RemoveChild(child); 3815 root->test_properties()->RemoveChild(child);
3828 timeline()->ClearPlayers(); 3816 timeline()->ClearPlayers();
3829 3817
3830 std::ostringstream scope; 3818 std::ostringstream scope;
3831 scope << "Test case: " << i; 3819 scope << "Test case: " << i;
3832 SCOPED_TRACE(scope.str()); 3820 SCOPED_TRACE(scope.str());
3833 3821
3834 CreateLayerFromState(root, timeline(), testcase.layer_before); 3822 CreateLayerFromState(root, timeline(), testcase.layer_before);
3835 CreateLayerFromState(root, timeline(), testcase.layer_between); 3823 CreateLayerFromState(root, timeline(), testcase.layer_between);
3836 CreateLayerFromState(root, timeline(), testcase.layer_after); 3824 CreateLayerFromState(root, timeline(), testcase.layer_after);
3837 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 3825 host_impl_->active_tree()->BuildPropertyTreesForTesting();
3838 3826
3839 if (testcase.high_res_required) 3827 if (testcase.high_res_required)
3840 host_impl_->SetRequiresHighResToDraw(); 3828 host_impl_->SetRequiresHighResToDraw();
3841 3829
3842 LayerTreeHostImpl::FrameData frame; 3830 LayerTreeHostImpl::FrameData frame;
3843 EXPECT_EQ(testcase.expected_result, host_impl_->PrepareToDraw(&frame)); 3831 EXPECT_EQ(testcase.expected_result, host_impl_->PrepareToDraw(&frame));
3844 host_impl_->DrawLayers(&frame); 3832 host_impl_->DrawLayers(&frame);
3845 host_impl_->DidDrawAllLayers(frame); 3833 host_impl_->DidDrawAllLayers(frame);
3846 host_impl_->SwapBuffers(frame);
3847 } 3834 }
3848 } 3835 }
3849 3836
3850 TEST_F(LayerTreeHostImplTest, 3837 TEST_F(LayerTreeHostImplTest,
3851 PrepareToDrawWhenDrawAndSwapFullViewportEveryFrame) { 3838 PrepareToDrawWhenDrawAndSwapFullViewportEveryFrame) {
3852 CreateHostImpl(DefaultSettings(), 3839 CreateHostImpl(DefaultSettings(),
3853 FakeOutputSurface::CreateDelegatingSoftware()); 3840 FakeOutputSurface::CreateDelegatingSoftware());
3854 3841
3855 const gfx::Transform external_transform; 3842 const gfx::Transform external_transform;
3856 const gfx::Rect external_viewport; 3843 const gfx::Rect external_viewport;
(...skipping 2809 matching lines...) Expand 10 before | Expand all | Expand 10 after
6666 6653
6667 // Opaque layer, drawn without blending. 6654 // Opaque layer, drawn without blending.
6668 layer1->SetContentsOpaque(true); 6655 layer1->SetContentsOpaque(true);
6669 layer1->SetExpectation(false, false); 6656 layer1->SetExpectation(false, false);
6670 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 6657 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
6671 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 6658 host_impl_->active_tree()->BuildPropertyTreesForTesting();
6672 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 6659 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
6673 host_impl_->DrawLayers(&frame); 6660 host_impl_->DrawLayers(&frame);
6674 EXPECT_TRUE(layer1->quads_appended()); 6661 EXPECT_TRUE(layer1->quads_appended());
6675 host_impl_->DidDrawAllLayers(frame); 6662 host_impl_->DidDrawAllLayers(frame);
6676 host_impl_->SwapBuffers(frame);
6677 6663
6678 // Layer with translucent content and painting, so drawn with blending. 6664 // Layer with translucent content and painting, so drawn with blending.
6679 layer1->SetContentsOpaque(false); 6665 layer1->SetContentsOpaque(false);
6680 layer1->SetExpectation(true, false); 6666 layer1->SetExpectation(true, false);
6681 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 6667 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
6682 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 6668 host_impl_->active_tree()->BuildPropertyTreesForTesting();
6683 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 6669 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
6684 host_impl_->DrawLayers(&frame); 6670 host_impl_->DrawLayers(&frame);
6685 host_impl_->SwapBuffers(frame);
6686 EXPECT_TRUE(layer1->quads_appended()); 6671 EXPECT_TRUE(layer1->quads_appended());
6687 host_impl_->DidDrawAllLayers(frame); 6672 host_impl_->DidDrawAllLayers(frame);
6688 6673
6689 // Layer with translucent opacity, drawn with blending. 6674 // Layer with translucent opacity, drawn with blending.
6690 layer1->SetContentsOpaque(true); 6675 layer1->SetContentsOpaque(true);
6691 layer1->test_properties()->opacity = 0.5f; 6676 layer1->test_properties()->opacity = 0.5f;
6692 layer1->NoteLayerPropertyChanged(); 6677 layer1->NoteLayerPropertyChanged();
6693 layer1->SetExpectation(true, false); 6678 layer1->SetExpectation(true, false);
6694 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 6679 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
6695 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 6680 host_impl_->active_tree()->BuildPropertyTreesForTesting();
6696 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 6681 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
6697 host_impl_->DrawLayers(&frame); 6682 host_impl_->DrawLayers(&frame);
6698 host_impl_->SwapBuffers(frame);
6699 EXPECT_TRUE(layer1->quads_appended()); 6683 EXPECT_TRUE(layer1->quads_appended());
6700 host_impl_->DidDrawAllLayers(frame); 6684 host_impl_->DidDrawAllLayers(frame);
6701 6685
6702 // Layer with translucent opacity and painting, drawn with blending. 6686 // Layer with translucent opacity and painting, drawn with blending.
6703 layer1->SetContentsOpaque(true); 6687 layer1->SetContentsOpaque(true);
6704 layer1->test_properties()->opacity = 0.5f; 6688 layer1->test_properties()->opacity = 0.5f;
6705 layer1->NoteLayerPropertyChanged(); 6689 layer1->NoteLayerPropertyChanged();
6706 layer1->SetExpectation(true, false); 6690 layer1->SetExpectation(true, false);
6707 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 6691 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
6708 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 6692 host_impl_->active_tree()->BuildPropertyTreesForTesting();
6709 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 6693 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
6710 host_impl_->DrawLayers(&frame); 6694 host_impl_->DrawLayers(&frame);
6711 host_impl_->SwapBuffers(frame);
6712 EXPECT_TRUE(layer1->quads_appended()); 6695 EXPECT_TRUE(layer1->quads_appended());
6713 host_impl_->DidDrawAllLayers(frame); 6696 host_impl_->DidDrawAllLayers(frame);
6714 6697
6715 layer1->test_properties()->AddChild(BlendStateCheckLayer::Create( 6698 layer1->test_properties()->AddChild(BlendStateCheckLayer::Create(
6716 host_impl_->active_tree(), 3, host_impl_->resource_provider())); 6699 host_impl_->active_tree(), 3, host_impl_->resource_provider()));
6717 BlendStateCheckLayer* layer2 = static_cast<BlendStateCheckLayer*>( 6700 BlendStateCheckLayer* layer2 = static_cast<BlendStateCheckLayer*>(
6718 layer1->test_properties()->children[0]); 6701 layer1->test_properties()->children[0]);
6719 layer2->SetPosition(gfx::PointF(4.f, 4.f)); 6702 layer2->SetPosition(gfx::PointF(4.f, 4.f));
6720 6703
6721 // 2 opaque layers, drawn without blending. 6704 // 2 opaque layers, drawn without blending.
6722 layer1->SetContentsOpaque(true); 6705 layer1->SetContentsOpaque(true);
6723 layer1->test_properties()->opacity = 1.f; 6706 layer1->test_properties()->opacity = 1.f;
6724 layer1->NoteLayerPropertyChanged(); 6707 layer1->NoteLayerPropertyChanged();
6725 layer1->SetExpectation(false, false); 6708 layer1->SetExpectation(false, false);
6726 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 6709 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
6727 layer2->SetContentsOpaque(true); 6710 layer2->SetContentsOpaque(true);
6728 layer2->test_properties()->opacity = 1.f; 6711 layer2->test_properties()->opacity = 1.f;
6729 layer2->NoteLayerPropertyChanged(); 6712 layer2->NoteLayerPropertyChanged();
6730 layer2->SetExpectation(false, false); 6713 layer2->SetExpectation(false, false);
6731 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); 6714 layer2->SetUpdateRect(gfx::Rect(layer1->bounds()));
6732 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 6715 host_impl_->active_tree()->BuildPropertyTreesForTesting();
6733 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 6716 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
6734 host_impl_->DrawLayers(&frame); 6717 host_impl_->DrawLayers(&frame);
6735 host_impl_->SwapBuffers(frame);
6736 EXPECT_TRUE(layer1->quads_appended()); 6718 EXPECT_TRUE(layer1->quads_appended());
6737 EXPECT_TRUE(layer2->quads_appended()); 6719 EXPECT_TRUE(layer2->quads_appended());
6738 host_impl_->DidDrawAllLayers(frame); 6720 host_impl_->DidDrawAllLayers(frame);
6739 6721
6740 // Parent layer with translucent content, drawn with blending. 6722 // Parent layer with translucent content, drawn with blending.
6741 // Child layer with opaque content, drawn without blending. 6723 // Child layer with opaque content, drawn without blending.
6742 layer1->SetContentsOpaque(false); 6724 layer1->SetContentsOpaque(false);
6743 layer1->SetExpectation(true, false); 6725 layer1->SetExpectation(true, false);
6744 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 6726 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
6745 layer2->SetExpectation(false, false); 6727 layer2->SetExpectation(false, false);
6746 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); 6728 layer2->SetUpdateRect(gfx::Rect(layer1->bounds()));
6747 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 6729 host_impl_->active_tree()->BuildPropertyTreesForTesting();
6748 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 6730 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
6749 host_impl_->DrawLayers(&frame); 6731 host_impl_->DrawLayers(&frame);
6750 host_impl_->SwapBuffers(frame);
6751 EXPECT_TRUE(layer1->quads_appended()); 6732 EXPECT_TRUE(layer1->quads_appended());
6752 EXPECT_TRUE(layer2->quads_appended()); 6733 EXPECT_TRUE(layer2->quads_appended());
6753 host_impl_->DidDrawAllLayers(frame); 6734 host_impl_->DidDrawAllLayers(frame);
6754 6735
6755 // Parent layer with translucent content but opaque painting, drawn without 6736 // Parent layer with translucent content but opaque painting, drawn without
6756 // blending. 6737 // blending.
6757 // Child layer with opaque content, drawn without blending. 6738 // Child layer with opaque content, drawn without blending.
6758 layer1->SetContentsOpaque(true); 6739 layer1->SetContentsOpaque(true);
6759 layer1->SetExpectation(false, false); 6740 layer1->SetExpectation(false, false);
6760 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 6741 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
6761 layer2->SetExpectation(false, false); 6742 layer2->SetExpectation(false, false);
6762 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); 6743 layer2->SetUpdateRect(gfx::Rect(layer1->bounds()));
6763 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 6744 host_impl_->active_tree()->BuildPropertyTreesForTesting();
6764 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 6745 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
6765 host_impl_->DrawLayers(&frame); 6746 host_impl_->DrawLayers(&frame);
6766 host_impl_->SwapBuffers(frame);
6767 EXPECT_TRUE(layer1->quads_appended()); 6747 EXPECT_TRUE(layer1->quads_appended());
6768 EXPECT_TRUE(layer2->quads_appended()); 6748 EXPECT_TRUE(layer2->quads_appended());
6769 host_impl_->DidDrawAllLayers(frame); 6749 host_impl_->DidDrawAllLayers(frame);
6770 6750
6771 // Parent layer with translucent opacity and opaque content. Since it has a 6751 // Parent layer with translucent opacity and opaque content. Since it has a
6772 // drawing child, it's drawn to a render surface which carries the opacity, 6752 // drawing child, it's drawn to a render surface which carries the opacity,
6773 // so it's itself drawn without blending. 6753 // so it's itself drawn without blending.
6774 // Child layer with opaque content, drawn without blending (parent surface 6754 // Child layer with opaque content, drawn without blending (parent surface
6775 // carries the inherited opacity). 6755 // carries the inherited opacity).
6776 layer1->SetContentsOpaque(true); 6756 layer1->SetContentsOpaque(true);
6777 layer1->test_properties()->opacity = 0.5f; 6757 layer1->test_properties()->opacity = 0.5f;
6778 layer1->NoteLayerPropertyChanged(); 6758 layer1->NoteLayerPropertyChanged();
6779 layer1->test_properties()->force_render_surface = true; 6759 layer1->test_properties()->force_render_surface = true;
6780 layer1->SetExpectation(false, true); 6760 layer1->SetExpectation(false, true);
6781 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 6761 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
6782 layer2->SetExpectation(false, false); 6762 layer2->SetExpectation(false, false);
6783 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); 6763 layer2->SetUpdateRect(gfx::Rect(layer1->bounds()));
6784 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( 6764 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(
6785 host_impl_->active_tree()->root_layer_for_testing()); 6765 host_impl_->active_tree()->root_layer_for_testing());
6786 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 6766 host_impl_->active_tree()->BuildPropertyTreesForTesting();
6787 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 6767 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
6788 host_impl_->DrawLayers(&frame); 6768 host_impl_->DrawLayers(&frame);
6789 host_impl_->SwapBuffers(frame);
6790 EXPECT_TRUE(layer1->quads_appended()); 6769 EXPECT_TRUE(layer1->quads_appended());
6791 EXPECT_TRUE(layer2->quads_appended()); 6770 EXPECT_TRUE(layer2->quads_appended());
6792 host_impl_->DidDrawAllLayers(frame); 6771 host_impl_->DidDrawAllLayers(frame);
6793 layer1->test_properties()->force_render_surface = false; 6772 layer1->test_properties()->force_render_surface = false;
6794 6773
6795 // Draw again, but with child non-opaque, to make sure 6774 // Draw again, but with child non-opaque, to make sure
6796 // layer1 not culled. 6775 // layer1 not culled.
6797 layer1->SetContentsOpaque(true); 6776 layer1->SetContentsOpaque(true);
6798 layer1->test_properties()->opacity = 1.f; 6777 layer1->test_properties()->opacity = 1.f;
6799 layer1->NoteLayerPropertyChanged(); 6778 layer1->NoteLayerPropertyChanged();
6800 layer1->SetExpectation(false, false); 6779 layer1->SetExpectation(false, false);
6801 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 6780 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
6802 layer2->SetContentsOpaque(true); 6781 layer2->SetContentsOpaque(true);
6803 layer2->test_properties()->opacity = 0.5f; 6782 layer2->test_properties()->opacity = 0.5f;
6804 layer2->NoteLayerPropertyChanged(); 6783 layer2->NoteLayerPropertyChanged();
6805 layer2->SetExpectation(true, false); 6784 layer2->SetExpectation(true, false);
6806 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); 6785 layer2->SetUpdateRect(gfx::Rect(layer1->bounds()));
6807 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 6786 host_impl_->active_tree()->BuildPropertyTreesForTesting();
6808 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 6787 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
6809 host_impl_->DrawLayers(&frame); 6788 host_impl_->DrawLayers(&frame);
6810 host_impl_->SwapBuffers(frame);
6811 EXPECT_TRUE(layer1->quads_appended()); 6789 EXPECT_TRUE(layer1->quads_appended());
6812 EXPECT_TRUE(layer2->quads_appended()); 6790 EXPECT_TRUE(layer2->quads_appended());
6813 host_impl_->DidDrawAllLayers(frame); 6791 host_impl_->DidDrawAllLayers(frame);
6814 6792
6815 // A second way of making the child non-opaque. 6793 // A second way of making the child non-opaque.
6816 layer1->SetContentsOpaque(true); 6794 layer1->SetContentsOpaque(true);
6817 layer1->test_properties()->opacity = 1.f; 6795 layer1->test_properties()->opacity = 1.f;
6818 layer1->NoteLayerPropertyChanged(); 6796 layer1->NoteLayerPropertyChanged();
6819 layer1->SetExpectation(false, false); 6797 layer1->SetExpectation(false, false);
6820 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 6798 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
6821 layer2->SetContentsOpaque(false); 6799 layer2->SetContentsOpaque(false);
6822 layer2->test_properties()->opacity = 1.f; 6800 layer2->test_properties()->opacity = 1.f;
6823 layer2->NoteLayerPropertyChanged(); 6801 layer2->NoteLayerPropertyChanged();
6824 layer2->SetExpectation(true, false); 6802 layer2->SetExpectation(true, false);
6825 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); 6803 layer2->SetUpdateRect(gfx::Rect(layer1->bounds()));
6826 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 6804 host_impl_->active_tree()->BuildPropertyTreesForTesting();
6827 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 6805 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
6828 host_impl_->DrawLayers(&frame); 6806 host_impl_->DrawLayers(&frame);
6829 host_impl_->SwapBuffers(frame);
6830 EXPECT_TRUE(layer1->quads_appended()); 6807 EXPECT_TRUE(layer1->quads_appended());
6831 EXPECT_TRUE(layer2->quads_appended()); 6808 EXPECT_TRUE(layer2->quads_appended());
6832 host_impl_->DidDrawAllLayers(frame); 6809 host_impl_->DidDrawAllLayers(frame);
6833 6810
6834 // And when the layer says its not opaque but is painted opaque, it is not 6811 // And when the layer says its not opaque but is painted opaque, it is not
6835 // blended. 6812 // blended.
6836 layer1->SetContentsOpaque(true); 6813 layer1->SetContentsOpaque(true);
6837 layer1->test_properties()->opacity = 1.f; 6814 layer1->test_properties()->opacity = 1.f;
6838 layer1->NoteLayerPropertyChanged(); 6815 layer1->NoteLayerPropertyChanged();
6839 layer1->SetExpectation(false, false); 6816 layer1->SetExpectation(false, false);
6840 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 6817 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
6841 layer2->SetContentsOpaque(true); 6818 layer2->SetContentsOpaque(true);
6842 layer2->test_properties()->opacity = 1.f; 6819 layer2->test_properties()->opacity = 1.f;
6843 layer2->NoteLayerPropertyChanged(); 6820 layer2->NoteLayerPropertyChanged();
6844 layer2->SetExpectation(false, false); 6821 layer2->SetExpectation(false, false);
6845 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); 6822 layer2->SetUpdateRect(gfx::Rect(layer1->bounds()));
6846 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 6823 host_impl_->active_tree()->BuildPropertyTreesForTesting();
6847 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 6824 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
6848 host_impl_->DrawLayers(&frame); 6825 host_impl_->DrawLayers(&frame);
6849 host_impl_->SwapBuffers(frame);
6850 EXPECT_TRUE(layer1->quads_appended()); 6826 EXPECT_TRUE(layer1->quads_appended());
6851 EXPECT_TRUE(layer2->quads_appended()); 6827 EXPECT_TRUE(layer2->quads_appended());
6852 host_impl_->DidDrawAllLayers(frame); 6828 host_impl_->DidDrawAllLayers(frame);
6853 6829
6854 // Layer with partially opaque contents, drawn with blending. 6830 // Layer with partially opaque contents, drawn with blending.
6855 layer1->SetContentsOpaque(false); 6831 layer1->SetContentsOpaque(false);
6856 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); 6832 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5));
6857 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 5)); 6833 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 5));
6858 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); 6834 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
6859 layer1->SetExpectation(true, false); 6835 layer1->SetExpectation(true, false);
6860 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 6836 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
6861 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 6837 host_impl_->active_tree()->BuildPropertyTreesForTesting();
6862 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 6838 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
6863 host_impl_->DrawLayers(&frame); 6839 host_impl_->DrawLayers(&frame);
6864 host_impl_->SwapBuffers(frame);
6865 EXPECT_TRUE(layer1->quads_appended()); 6840 EXPECT_TRUE(layer1->quads_appended());
6866 host_impl_->DidDrawAllLayers(frame); 6841 host_impl_->DidDrawAllLayers(frame);
6867 6842
6868 // Layer with partially opaque contents partially culled, drawn with blending. 6843 // Layer with partially opaque contents partially culled, drawn with blending.
6869 layer1->SetContentsOpaque(false); 6844 layer1->SetContentsOpaque(false);
6870 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); 6845 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5));
6871 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 2)); 6846 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 2));
6872 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); 6847 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
6873 layer1->SetExpectation(true, false); 6848 layer1->SetExpectation(true, false);
6874 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 6849 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
6875 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 6850 host_impl_->active_tree()->BuildPropertyTreesForTesting();
6876 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 6851 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
6877 host_impl_->DrawLayers(&frame); 6852 host_impl_->DrawLayers(&frame);
6878 host_impl_->SwapBuffers(frame);
6879 EXPECT_TRUE(layer1->quads_appended()); 6853 EXPECT_TRUE(layer1->quads_appended());
6880 host_impl_->DidDrawAllLayers(frame); 6854 host_impl_->DidDrawAllLayers(frame);
6881 6855
6882 // Layer with partially opaque contents culled, drawn with blending. 6856 // Layer with partially opaque contents culled, drawn with blending.
6883 layer1->SetContentsOpaque(false); 6857 layer1->SetContentsOpaque(false);
6884 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); 6858 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5));
6885 layer1->SetQuadVisibleRect(gfx::Rect(7, 5, 3, 5)); 6859 layer1->SetQuadVisibleRect(gfx::Rect(7, 5, 3, 5));
6886 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); 6860 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
6887 layer1->SetExpectation(true, false); 6861 layer1->SetExpectation(true, false);
6888 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 6862 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
6889 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 6863 host_impl_->active_tree()->BuildPropertyTreesForTesting();
6890 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 6864 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
6891 host_impl_->DrawLayers(&frame); 6865 host_impl_->DrawLayers(&frame);
6892 host_impl_->SwapBuffers(frame);
6893 EXPECT_TRUE(layer1->quads_appended()); 6866 EXPECT_TRUE(layer1->quads_appended());
6894 host_impl_->DidDrawAllLayers(frame); 6867 host_impl_->DidDrawAllLayers(frame);
6895 6868
6896 // Layer with partially opaque contents and translucent contents culled, drawn 6869 // Layer with partially opaque contents and translucent contents culled, drawn
6897 // without blending. 6870 // without blending.
6898 layer1->SetContentsOpaque(false); 6871 layer1->SetContentsOpaque(false);
6899 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); 6872 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5));
6900 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 2, 5)); 6873 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 2, 5));
6901 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); 6874 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
6902 layer1->SetExpectation(false, false); 6875 layer1->SetExpectation(false, false);
6903 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 6876 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
6904 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 6877 host_impl_->active_tree()->BuildPropertyTreesForTesting();
6905 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 6878 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
6906 host_impl_->DrawLayers(&frame); 6879 host_impl_->DrawLayers(&frame);
6907 host_impl_->SwapBuffers(frame);
6908 EXPECT_TRUE(layer1->quads_appended()); 6880 EXPECT_TRUE(layer1->quads_appended());
6909 host_impl_->DidDrawAllLayers(frame); 6881 host_impl_->DidDrawAllLayers(frame);
6910 } 6882 }
6911 6883
6912 static bool MayContainVideoBitSetOnFrameData(LayerTreeHostImpl* host_impl) { 6884 static bool MayContainVideoBitSetOnFrameData(LayerTreeHostImpl* host_impl) {
6913 host_impl->active_tree()->BuildPropertyTreesForTesting(); 6885 host_impl->active_tree()->BuildPropertyTreesForTesting();
6914 LayerTreeHostImpl::FrameData frame; 6886 LayerTreeHostImpl::FrameData frame;
6915 EXPECT_EQ(DRAW_SUCCESS, host_impl->PrepareToDraw(&frame)); 6887 EXPECT_EQ(DRAW_SUCCESS, host_impl->PrepareToDraw(&frame));
6916 host_impl->DrawLayers(&frame); 6888 host_impl->DrawLayers(&frame);
6917 host_impl->SwapBuffers(frame);
6918 host_impl->DidDrawAllLayers(frame); 6889 host_impl->DidDrawAllLayers(frame);
6919 return frame.may_contain_video; 6890 return frame.may_contain_video;
6920 } 6891 }
6921 6892
6922 TEST_F(LayerTreeHostImplTest, MayContainVideo) { 6893 TEST_F(LayerTreeHostImplTest, MayContainVideo) {
6923 gfx::Size big_size(1000, 1000); 6894 gfx::Size big_size(1000, 1000);
6924 host_impl_->SetViewportSize(big_size); 6895 host_impl_->SetViewportSize(big_size);
6925 6896
6926 int layer_id = 1; 6897 int layer_id = 1;
6927 host_impl_->active_tree()->SetRootLayerForTesting( 6898 host_impl_->active_tree()->SetRootLayerForTesting(
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
7204 host_impl_->SetViewportSize(DipSizeToPixelSize(viewport_size_)); 7175 host_impl_->SetViewportSize(DipSizeToPixelSize(viewport_size_));
7205 SetupActiveTreeLayers(); 7176 SetupActiveTreeLayers();
7206 EXPECT_SCOPED(TestLayerCoversFullViewport()); 7177 EXPECT_SCOPED(TestLayerCoversFullViewport());
7207 EXPECT_SCOPED(TestEmptyLayer()); 7178 EXPECT_SCOPED(TestEmptyLayer());
7208 EXPECT_SCOPED(TestLayerInMiddleOfViewport()); 7179 EXPECT_SCOPED(TestLayerInMiddleOfViewport());
7209 EXPECT_SCOPED(TestLayerIsLargerThanViewport()); 7180 EXPECT_SCOPED(TestLayerIsLargerThanViewport());
7210 } 7181 }
7211 7182
7212 TEST_F(LayerTreeHostImplViewportCoveredTest, ActiveTreeGrowViewportInvalid) { 7183 TEST_F(LayerTreeHostImplViewportCoveredTest, ActiveTreeGrowViewportInvalid) {
7213 viewport_size_ = gfx::Size(1000, 1000); 7184 viewport_size_ = gfx::Size(1000, 1000);
7214 skip_draw_layers_in_on_draw_ = true; // Resourceless can't draw tiled quads.
7215 7185
7216 bool software = true; 7186 bool software = true;
7217 CreateHostImpl(DefaultSettings(), CreateFakeOutputSurface(software)); 7187 CreateHostImpl(DefaultSettings(), CreateFakeOutputSurface(software));
7218 7188
7219 // Pending tree to force active_tree size invalid. Not used otherwise. 7189 // Pending tree to force active_tree size invalid. Not used otherwise.
7220 host_impl_->CreatePendingTree(); 7190 host_impl_->CreatePendingTree();
7221 host_impl_->SetViewportSize(DipSizeToPixelSize(viewport_size_)); 7191 host_impl_->SetViewportSize(DipSizeToPixelSize(viewport_size_));
7222 EXPECT_TRUE(host_impl_->active_tree()->ViewportSizeInvalid()); 7192 EXPECT_TRUE(host_impl_->active_tree()->ViewportSizeInvalid());
7223 7193
7224 SetupActiveTreeLayers(); 7194 SetupActiveTreeLayers();
7225 EXPECT_SCOPED(TestEmptyLayerWithOnDraw()); 7195 EXPECT_SCOPED(TestEmptyLayerWithOnDraw());
7226 EXPECT_SCOPED(TestLayerInMiddleOfViewportWithOnDraw()); 7196 EXPECT_SCOPED(TestLayerInMiddleOfViewportWithOnDraw());
7227 EXPECT_SCOPED(TestLayerIsLargerThanViewportWithOnDraw()); 7197 EXPECT_SCOPED(TestLayerIsLargerThanViewportWithOnDraw());
7228 } 7198 }
7229 7199
7230 TEST_F(LayerTreeHostImplViewportCoveredTest, ActiveTreeShrinkViewportInvalid) { 7200 TEST_F(LayerTreeHostImplViewportCoveredTest, ActiveTreeShrinkViewportInvalid) {
7231 viewport_size_ = gfx::Size(1000, 1000); 7201 viewport_size_ = gfx::Size(1000, 1000);
7232 skip_draw_layers_in_on_draw_ = true; // Resourceless can't draw tiled quads.
7233 7202
7234 bool software = true; 7203 bool software = true;
7235 CreateHostImpl(DefaultSettings(), CreateFakeOutputSurface(software)); 7204 CreateHostImpl(DefaultSettings(), CreateFakeOutputSurface(software));
7236 7205
7237 // Set larger viewport and activate it to active tree. 7206 // Set larger viewport and activate it to active tree.
7238 host_impl_->CreatePendingTree(); 7207 host_impl_->CreatePendingTree();
7239 gfx::Size larger_viewport(viewport_size_.width() + 100, 7208 gfx::Size larger_viewport(viewport_size_.width() + 100,
7240 viewport_size_.height() + 100); 7209 viewport_size_.height() + 100);
7241 host_impl_->SetViewportSize(DipSizeToPixelSize(larger_viewport)); 7210 host_impl_->SetViewportSize(DipSizeToPixelSize(larger_viewport));
7242 EXPECT_TRUE(host_impl_->active_tree()->ViewportSizeInvalid()); 7211 EXPECT_TRUE(host_impl_->active_tree()->ViewportSizeInvalid());
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
7305 root->test_properties()->AddChild(std::move(child)); 7274 root->test_properties()->AddChild(std::move(child));
7306 layer_tree_host_impl->active_tree()->SetRootLayerForTesting(std::move(root)); 7275 layer_tree_host_impl->active_tree()->SetRootLayerForTesting(std::move(root));
7307 layer_tree_host_impl->active_tree()->BuildPropertyTreesForTesting(); 7276 layer_tree_host_impl->active_tree()->BuildPropertyTreesForTesting();
7308 7277
7309 LayerTreeHostImpl::FrameData frame; 7278 LayerTreeHostImpl::FrameData frame;
7310 7279
7311 // First frame, the entire screen should get swapped. 7280 // First frame, the entire screen should get swapped.
7312 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); 7281 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame));
7313 layer_tree_host_impl->DrawLayers(&frame); 7282 layer_tree_host_impl->DrawLayers(&frame);
7314 layer_tree_host_impl->DidDrawAllLayers(frame); 7283 layer_tree_host_impl->DidDrawAllLayers(frame);
7315 layer_tree_host_impl->SwapBuffers(frame);
7316 gfx::Rect expected_swap_rect(500, 500); 7284 gfx::Rect expected_swap_rect(500, 500);
7317 EXPECT_EQ(expected_swap_rect.ToString(), 7285 EXPECT_EQ(expected_swap_rect.ToString(),
7318 fake_output_surface->last_swap_rect().ToString()); 7286 fake_output_surface->last_swap_rect().ToString());
7319 7287
7320 // Second frame, only the damaged area should get swapped. Damage should be 7288 // Second frame, only the damaged area should get swapped. Damage should be
7321 // the union of old and new child rects: gfx::Rect(26, 28). 7289 // the union of old and new child rects: gfx::Rect(26, 28).
7322 layer_tree_host_impl->active_tree() 7290 layer_tree_host_impl->active_tree()
7323 ->root_layer_for_testing() 7291 ->root_layer_for_testing()
7324 ->test_properties() 7292 ->test_properties()
7325 ->children[0] 7293 ->children[0]
7326 ->SetPosition(gfx::PointF()); 7294 ->SetPosition(gfx::PointF());
7327 layer_tree_host_impl->active_tree() 7295 layer_tree_host_impl->active_tree()
7328 ->root_layer_for_testing() 7296 ->root_layer_for_testing()
7329 ->test_properties() 7297 ->test_properties()
7330 ->children[0] 7298 ->children[0]
7331 ->NoteLayerPropertyChanged(); 7299 ->NoteLayerPropertyChanged();
7332 layer_tree_host_impl->active_tree()->BuildPropertyTreesForTesting(); 7300 layer_tree_host_impl->active_tree()->BuildPropertyTreesForTesting();
7333 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); 7301 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame));
7334 layer_tree_host_impl->DrawLayers(&frame); 7302 layer_tree_host_impl->DrawLayers(&frame);
7335 host_impl_->DidDrawAllLayers(frame); 7303 host_impl_->DidDrawAllLayers(frame);
7336 layer_tree_host_impl->SwapBuffers(frame);
7337 7304
7338 expected_swap_rect = gfx::Rect(26, 28); 7305 expected_swap_rect = gfx::Rect(26, 28);
7339 EXPECT_EQ(expected_swap_rect.ToString(), 7306 EXPECT_EQ(expected_swap_rect.ToString(),
7340 fake_output_surface->last_swap_rect().ToString()); 7307 fake_output_surface->last_swap_rect().ToString());
7341 7308
7342 layer_tree_host_impl->SetViewportSize(gfx::Size(10, 10)); 7309 layer_tree_host_impl->SetViewportSize(gfx::Size(10, 10));
7343 // This will damage everything. 7310 // This will damage everything.
7344 layer_tree_host_impl->active_tree() 7311 layer_tree_host_impl->active_tree()
7345 ->root_layer_for_testing() 7312 ->root_layer_for_testing()
7346 ->SetBackgroundColor(SK_ColorBLACK); 7313 ->SetBackgroundColor(SK_ColorBLACK);
7347 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); 7314 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame));
7348 layer_tree_host_impl->DrawLayers(&frame); 7315 layer_tree_host_impl->DrawLayers(&frame);
7349 host_impl_->DidDrawAllLayers(frame); 7316 host_impl_->DidDrawAllLayers(frame);
7350 layer_tree_host_impl->SwapBuffers(frame);
7351 7317
7352 expected_swap_rect = gfx::Rect(10, 10); 7318 expected_swap_rect = gfx::Rect(10, 10);
7353 EXPECT_EQ(expected_swap_rect.ToString(), 7319 EXPECT_EQ(expected_swap_rect.ToString(),
7354 fake_output_surface->last_swap_rect().ToString()); 7320 fake_output_surface->last_swap_rect().ToString());
7355 7321
7356 layer_tree_host_impl->ReleaseOutputSurface(); 7322 layer_tree_host_impl->ReleaseOutputSurface();
7357 } 7323 }
7358 7324
7359 TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) { 7325 TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) {
7360 std::unique_ptr<LayerImpl> root = 7326 std::unique_ptr<LayerImpl> root =
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
7568 7534
7569 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_layer)); 7535 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_layer));
7570 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 7536 host_impl_->active_tree()->BuildPropertyTreesForTesting();
7571 7537
7572 EXPECT_EQ(0u, context3d->NumTextures()); 7538 EXPECT_EQ(0u, context3d->NumTextures());
7573 7539
7574 LayerTreeHostImpl::FrameData frame; 7540 LayerTreeHostImpl::FrameData frame;
7575 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 7541 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
7576 host_impl_->DrawLayers(&frame); 7542 host_impl_->DrawLayers(&frame);
7577 host_impl_->DidDrawAllLayers(frame); 7543 host_impl_->DidDrawAllLayers(frame);
7578 host_impl_->SwapBuffers(frame);
7579 7544
7580 EXPECT_GT(context3d->NumTextures(), 0u); 7545 EXPECT_GT(context3d->NumTextures(), 0u);
7581 7546
7582 // Kill the layer tree. 7547 // Kill the layer tree.
7583 host_impl_->active_tree()->DetachLayers(); 7548 host_impl_->active_tree()->DetachLayers();
7584 // There should be no textures left in use after. 7549 // There should be no textures left in use after.
7585 EXPECT_EQ(0u, context3d->NumTextures()); 7550 EXPECT_EQ(0u, context3d->NumTextures());
7586 } 7551 }
7587 7552
7588 class MockDrawQuadsToFillScreenContext : public TestWebGraphicsContext3D { 7553 class MockDrawQuadsToFillScreenContext : public TestWebGraphicsContext3D {
(...skipping 15 matching lines...) Expand all
7604 host_impl_->active_tree()->set_has_transparent_background(false); 7569 host_impl_->active_tree()->set_has_transparent_background(false);
7605 LayerTreeHostImpl::FrameData frame; 7570 LayerTreeHostImpl::FrameData frame;
7606 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 7571 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
7607 { 7572 {
7608 const auto& root_pass = frame.render_passes.back(); 7573 const auto& root_pass = frame.render_passes.back();
7609 ASSERT_EQ(1u, root_pass->quad_list.size()); 7574 ASSERT_EQ(1u, root_pass->quad_list.size());
7610 EXPECT_EQ(DrawQuad::SOLID_COLOR, root_pass->quad_list.front()->material); 7575 EXPECT_EQ(DrawQuad::SOLID_COLOR, root_pass->quad_list.front()->material);
7611 } 7576 }
7612 host_impl_->DrawLayers(&frame); 7577 host_impl_->DrawLayers(&frame);
7613 host_impl_->DidDrawAllLayers(frame); 7578 host_impl_->DidDrawAllLayers(frame);
7614 host_impl_->SwapBuffers(frame);
7615 7579
7616 // Cause damage so we would draw something if possible. 7580 // Cause damage so we would draw something if possible.
7617 host_impl_->SetFullViewportDamage(); 7581 host_impl_->SetFullViewportDamage();
7618 7582
7619 // Verify no quads are drawn when transparent background is set. 7583 // Verify no quads are drawn when transparent background is set.
7620 host_impl_->active_tree()->set_has_transparent_background(true); 7584 host_impl_->active_tree()->set_has_transparent_background(true);
7621 host_impl_->SetFullViewportDamage(); 7585 host_impl_->SetFullViewportDamage();
7622 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 7586 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
7623 { 7587 {
7624 const auto& root_pass = frame.render_passes.back(); 7588 const auto& root_pass = frame.render_passes.back();
7625 ASSERT_EQ(0u, root_pass->quad_list.size()); 7589 ASSERT_EQ(0u, root_pass->quad_list.size());
7626 } 7590 }
7627 host_impl_->DrawLayers(&frame); 7591 host_impl_->DrawLayers(&frame);
7628 host_impl_->DidDrawAllLayers(frame); 7592 host_impl_->DidDrawAllLayers(frame);
7629 host_impl_->SwapBuffers(frame);
7630 } 7593 }
7631 7594
7632 class LayerTreeHostImplTestWithDelegatingRenderer 7595 class LayerTreeHostImplTestWithDelegatingRenderer
7633 : public LayerTreeHostImplTest { 7596 : public LayerTreeHostImplTest {
7634 protected: 7597 protected:
7635 std::unique_ptr<OutputSurface> CreateOutputSurface() override { 7598 std::unique_ptr<OutputSurface> CreateOutputSurface() override {
7636 return FakeOutputSurface::CreateDelegating3d(); 7599 return FakeOutputSurface::CreateDelegating3d();
7637 } 7600 }
7638 7601
7639 void DrawFrameAndTestDamage(const gfx::Rect& expected_damage) { 7602 void DrawFrameAndTestDamage(const gfx::Rect& expected_damage) {
(...skipping 23 matching lines...) Expand all
7663 gfx::Rect expected_child_visible_rect(child->bounds()); 7626 gfx::Rect expected_child_visible_rect(child->bounds());
7664 EXPECT_EQ(expected_child_visible_rect, 7627 EXPECT_EQ(expected_child_visible_rect,
7665 root_render_pass->quad_list.front()->visible_rect); 7628 root_render_pass->quad_list.front()->visible_rect);
7666 7629
7667 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); 7630 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing();
7668 gfx::Rect expected_root_visible_rect(root->bounds()); 7631 gfx::Rect expected_root_visible_rect(root->bounds());
7669 EXPECT_EQ(expected_root_visible_rect, 7632 EXPECT_EQ(expected_root_visible_rect,
7670 root_render_pass->quad_list.ElementAt(1)->visible_rect); 7633 root_render_pass->quad_list.ElementAt(1)->visible_rect);
7671 } 7634 }
7672 7635
7673 host_impl_->DrawLayers(&frame); 7636 EXPECT_EQ(expect_to_draw, host_impl_->DrawLayers(&frame));
7674 host_impl_->DidDrawAllLayers(frame); 7637 host_impl_->DidDrawAllLayers(frame);
7675 EXPECT_EQ(expect_to_draw, host_impl_->SwapBuffers(frame));
7676 } 7638 }
7677 }; 7639 };
7678 7640
7679 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) { 7641 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) {
7680 std::unique_ptr<SolidColorLayerImpl> root = 7642 std::unique_ptr<SolidColorLayerImpl> root =
7681 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); 7643 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1);
7682 root->SetPosition(gfx::PointF()); 7644 root->SetPosition(gfx::PointF());
7683 root->SetBounds(gfx::Size(10, 10)); 7645 root->SetBounds(gfx::Size(10, 10));
7684 root->SetDrawsContent(true); 7646 root->SetDrawsContent(true);
7685 root->test_properties()->force_render_surface = true; 7647 root->test_properties()->force_render_surface = true;
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
8050 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); 8012 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing();
8051 root->test_properties()->copy_requests.push_back( 8013 root->test_properties()->copy_requests.push_back(
8052 CopyOutputRequest::CreateRequest( 8014 CopyOutputRequest::CreateRequest(
8053 base::Bind(&ShutdownReleasesContext_Callback))); 8015 base::Bind(&ShutdownReleasesContext_Callback)));
8054 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 8016 host_impl_->active_tree()->BuildPropertyTreesForTesting();
8055 8017
8056 LayerTreeHostImpl::FrameData frame; 8018 LayerTreeHostImpl::FrameData frame;
8057 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 8019 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
8058 host_impl_->DrawLayers(&frame); 8020 host_impl_->DrawLayers(&frame);
8059 host_impl_->DidDrawAllLayers(frame); 8021 host_impl_->DidDrawAllLayers(frame);
8060 host_impl_->SwapBuffers(frame);
8061 8022
8062 // The CopyOutputResult's callback has a ref on the ContextProvider and a 8023 // The CopyOutputResult's callback has a ref on the ContextProvider and a
8063 // texture in a texture mailbox. 8024 // texture in a texture mailbox.
8064 EXPECT_FALSE(context_provider->HasOneRef()); 8025 EXPECT_FALSE(context_provider->HasOneRef());
8065 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures()); 8026 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures());
8066 8027
8067 host_impl_->ReleaseOutputSurface(); 8028 host_impl_->ReleaseOutputSurface();
8068 host_impl_ = nullptr; 8029 host_impl_ = nullptr;
8069 8030
8070 // The CopyOutputResult's callback was cancelled, the CopyOutputResult 8031 // The CopyOutputResult's callback was cancelled, the CopyOutputResult
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
8476 // that is a drawn RSLL member, then we should accept this hit. 8437 // that is a drawn RSLL member, then we should accept this hit.
8477 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 8438 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
8478 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 8439 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
8479 InputHandler::WHEEL) 8440 InputHandler::WHEEL)
8480 .thread); 8441 .thread);
8481 8442
8482 EXPECT_EQ(7, host_impl_->CurrentlyScrollingLayer()->id()); 8443 EXPECT_EQ(7, host_impl_->CurrentlyScrollingLayer()->id());
8483 } 8444 }
8484 8445
8485 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed 8446 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed
8486 // to CompositorFrameMetadata after SwapBuffers(); 8447 // in CompositorFrameMetadata.
8487 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { 8448 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) {
8488 std::unique_ptr<SolidColorLayerImpl> root = 8449 std::unique_ptr<SolidColorLayerImpl> root =
8489 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); 8450 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1);
8490 root->SetPosition(gfx::PointF()); 8451 root->SetPosition(gfx::PointF());
8491 root->SetBounds(gfx::Size(10, 10)); 8452 root->SetBounds(gfx::Size(10, 10));
8492 root->SetDrawsContent(true); 8453 root->SetDrawsContent(true);
8493 root->test_properties()->force_render_surface = true; 8454 root->test_properties()->force_render_surface = true;
8494 8455
8495 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); 8456 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root));
8496 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 8457 host_impl_->active_tree()->BuildPropertyTreesForTesting();
8497 8458
8498 FakeOutputSurface* fake_output_surface = 8459 FakeOutputSurface* fake_output_surface =
8499 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); 8460 static_cast<FakeOutputSurface*>(host_impl_->output_surface());
8500 8461
8501 ui::LatencyInfo latency_info; 8462 ui::LatencyInfo latency_info;
8502 latency_info.AddLatencyNumber( 8463 latency_info.AddLatencyNumber(
8503 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, 0); 8464 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, 0);
8504 std::unique_ptr<SwapPromise> swap_promise( 8465 std::unique_ptr<SwapPromise> swap_promise(
8505 new LatencyInfoSwapPromise(latency_info)); 8466 new LatencyInfoSwapPromise(latency_info));
8506 host_impl_->active_tree()->QueuePinnedSwapPromise(std::move(swap_promise)); 8467 host_impl_->active_tree()->QueuePinnedSwapPromise(std::move(swap_promise));
8507 8468
8508 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); 8469 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize());
8509 LayerTreeHostImpl::FrameData frame; 8470 LayerTreeHostImpl::FrameData frame;
8510 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 8471 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
8511 host_impl_->DrawLayers(&frame); 8472 EXPECT_TRUE(host_impl_->DrawLayers(&frame));
8512 host_impl_->DidDrawAllLayers(frame); 8473 host_impl_->DidDrawAllLayers(frame);
8513 EXPECT_TRUE(host_impl_->SwapBuffers(frame));
8514 8474
8515 const std::vector<ui::LatencyInfo>& metadata_latency_after = 8475 const std::vector<ui::LatencyInfo>& metadata_latency_after =
8516 fake_output_surface->last_sent_frame()->metadata.latency_info; 8476 fake_output_surface->last_sent_frame()->metadata.latency_info;
8517 EXPECT_EQ(1u, metadata_latency_after.size()); 8477 EXPECT_EQ(1u, metadata_latency_after.size());
8518 EXPECT_TRUE(metadata_latency_after[0].FindLatency( 8478 EXPECT_TRUE(metadata_latency_after[0].FindLatency(
8519 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, NULL)); 8479 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, NULL));
8520 } 8480 }
8521 8481
8522 TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) { 8482 TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) {
8523 int root_layer_id = 1; 8483 int root_layer_id = 1;
(...skipping 21 matching lines...) Expand all
8545 selection.start.edge_top = selection_top; 8505 selection.start.edge_top = selection_top;
8546 selection.end = selection.start; 8506 selection.end = selection.start;
8547 host_impl_->active_tree()->RegisterSelection(selection); 8507 host_impl_->active_tree()->RegisterSelection(selection);
8548 8508
8549 // Trigger a draw-swap sequence. 8509 // Trigger a draw-swap sequence.
8550 host_impl_->SetNeedsRedraw(); 8510 host_impl_->SetNeedsRedraw();
8551 8511
8552 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); 8512 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize());
8553 LayerTreeHostImpl::FrameData frame; 8513 LayerTreeHostImpl::FrameData frame;
8554 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 8514 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
8555 host_impl_->DrawLayers(&frame); 8515 EXPECT_TRUE(host_impl_->DrawLayers(&frame));
8556 host_impl_->DidDrawAllLayers(frame); 8516 host_impl_->DidDrawAllLayers(frame);
8557 EXPECT_TRUE(host_impl_->SwapBuffers(frame));
8558 8517
8559 // Ensure the selection bounds have propagated to the frame metadata. 8518 // Ensure the selection bounds have propagated to the frame metadata.
8560 const Selection<gfx::SelectionBound>& selection_after = 8519 const Selection<gfx::SelectionBound>& selection_after =
8561 fake_output_surface->last_sent_frame()->metadata.selection; 8520 fake_output_surface->last_sent_frame()->metadata.selection;
8562 EXPECT_EQ(selection.start.type, selection_after.start.type()); 8521 EXPECT_EQ(selection.start.type, selection_after.start.type());
8563 EXPECT_EQ(selection.end.type, selection_after.end.type()); 8522 EXPECT_EQ(selection.end.type, selection_after.end.type());
8564 EXPECT_EQ(gfx::PointF(selection_bottom), selection_after.start.edge_bottom()); 8523 EXPECT_EQ(gfx::PointF(selection_bottom), selection_after.start.edge_bottom());
8565 EXPECT_EQ(gfx::PointF(selection_top), selection_after.start.edge_top()); 8524 EXPECT_EQ(gfx::PointF(selection_top), selection_after.start.edge_top());
8566 EXPECT_TRUE(selection_after.start.visible()); 8525 EXPECT_TRUE(selection_after.start.visible());
8567 EXPECT_TRUE(selection_after.start.visible()); 8526 EXPECT_TRUE(selection_after.start.visible());
(...skipping 2645 matching lines...) Expand 10 before | Expand all | Expand 10 after
11213 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); 11172 EXPECT_TRUE(host_impl_->use_gpu_rasterization());
11214 11173
11215 // Re-initialize with a software output surface. 11174 // Re-initialize with a software output surface.
11216 output_surface_ = FakeOutputSurface::CreateDelegatingSoftware(); 11175 output_surface_ = FakeOutputSurface::CreateDelegatingSoftware();
11217 host_impl_->InitializeRenderer(output_surface_.get()); 11176 host_impl_->InitializeRenderer(output_surface_.get());
11218 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); 11177 EXPECT_FALSE(host_impl_->use_gpu_rasterization());
11219 } 11178 }
11220 11179
11221 } // namespace 11180 } // namespace
11222 } // namespace cc 11181 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/proxy_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698