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

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

Issue 2712983003: [cc] Set BeginFrame sequence numbers on CompositorFrames from Scheduler. (Closed)
Patch Set: sync Created 3 years, 9 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
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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 using ::testing::Mock; 85 using ::testing::Mock;
86 using ::testing::Return; 86 using ::testing::Return;
87 using ::testing::AnyNumber; 87 using ::testing::AnyNumber;
88 using ::testing::AtLeast; 88 using ::testing::AtLeast;
89 using ::testing::_; 89 using ::testing::_;
90 using media::VideoFrame; 90 using media::VideoFrame;
91 91
92 namespace cc { 92 namespace cc {
93 namespace { 93 namespace {
94 94
95 struct TestFrameData : public LayerTreeHostImpl::FrameData {
96 TestFrameData() {
97 // Set sequence number to something valid, so DCHECKs don't complain.
98 begin_frame_sequence_number = 1;
99 }
100 };
101
95 class LayerTreeHostImplTest : public testing::Test, 102 class LayerTreeHostImplTest : public testing::Test,
96 public LayerTreeHostImplClient { 103 public LayerTreeHostImplClient {
97 public: 104 public:
98 LayerTreeHostImplTest() 105 LayerTreeHostImplTest()
99 : task_runner_provider_(base::ThreadTaskRunnerHandle::Get()), 106 : task_runner_provider_(base::ThreadTaskRunnerHandle::Get()),
100 always_main_thread_blocked_(&task_runner_provider_), 107 always_main_thread_blocked_(&task_runner_provider_),
101 on_can_draw_state_changed_called_(false), 108 on_can_draw_state_changed_called_(false),
102 did_notify_ready_to_activate_(false), 109 did_notify_ready_to_activate_(false),
103 did_request_commit_(false), 110 did_request_commit_(false),
104 did_request_redraw_(false), 111 did_request_redraw_(false),
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 animation_task_ = task; 165 animation_task_ = task;
159 requested_animation_delay_ = delay; 166 requested_animation_delay_ = delay;
160 } 167 }
161 void DidActivateSyncTree() override {} 168 void DidActivateSyncTree() override {}
162 void WillPrepareTiles() override {} 169 void WillPrepareTiles() override {}
163 void DidPrepareTiles() override {} 170 void DidPrepareTiles() override {}
164 void DidCompletePageScaleAnimationOnImplThread() override { 171 void DidCompletePageScaleAnimationOnImplThread() override {
165 did_complete_page_scale_animation_ = true; 172 did_complete_page_scale_animation_ = true;
166 } 173 }
167 void OnDrawForCompositorFrameSink(bool resourceless_software_draw) override { 174 void OnDrawForCompositorFrameSink(bool resourceless_software_draw) override {
168 std::unique_ptr<LayerTreeHostImpl::FrameData> frame( 175 std::unique_ptr<TestFrameData> frame(new TestFrameData);
169 new LayerTreeHostImpl::FrameData);
170 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(frame.get())); 176 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(frame.get()));
171 last_on_draw_render_passes_.clear(); 177 last_on_draw_render_passes_.clear();
172 RenderPass::CopyAll(frame->render_passes, &last_on_draw_render_passes_); 178 RenderPass::CopyAll(frame->render_passes, &last_on_draw_render_passes_);
173 host_impl_->DrawLayers(frame.get()); 179 host_impl_->DrawLayers(frame.get());
174 host_impl_->DidDrawAllLayers(*frame); 180 host_impl_->DidDrawAllLayers(*frame);
175 last_on_draw_frame_ = std::move(frame); 181 last_on_draw_frame_ = std::move(frame);
176 } 182 }
177 void NeedsImplSideInvalidation() override { 183 void NeedsImplSideInvalidation() override {
178 did_request_impl_side_invalidation_ = true; 184 did_request_impl_side_invalidation_ = true;
179 } 185 }
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 455
450 std::unique_ptr<ScrollState> EndState() { 456 std::unique_ptr<ScrollState> EndState() {
451 ScrollStateData scroll_state_data; 457 ScrollStateData scroll_state_data;
452 scroll_state_data.is_ending = true; 458 scroll_state_data.is_ending = true;
453 std::unique_ptr<ScrollState> scroll_state( 459 std::unique_ptr<ScrollState> scroll_state(
454 new ScrollState(scroll_state_data)); 460 new ScrollState(scroll_state_data));
455 return scroll_state; 461 return scroll_state;
456 } 462 }
457 463
458 void DrawFrame() { 464 void DrawFrame() {
459 LayerTreeHostImpl::FrameData frame; 465 TestFrameData frame;
460 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 466 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
461 host_impl_->DrawLayers(&frame); 467 host_impl_->DrawLayers(&frame);
462 host_impl_->DidDrawAllLayers(frame); 468 host_impl_->DidDrawAllLayers(frame);
463 } 469 }
464 470
465 void pinch_zoom_pan_viewport_forces_commit_redraw(float device_scale_factor); 471 void pinch_zoom_pan_viewport_forces_commit_redraw(float device_scale_factor);
466 void pinch_zoom_pan_viewport_test(float device_scale_factor); 472 void pinch_zoom_pan_viewport_test(float device_scale_factor);
467 void pinch_zoom_pan_viewport_and_scroll_test(float device_scale_factor); 473 void pinch_zoom_pan_viewport_and_scroll_test(float device_scale_factor);
468 void pinch_zoom_pan_viewport_and_scroll_boundary_test( 474 void pinch_zoom_pan_viewport_and_scroll_boundary_test(
469 float device_scale_factor); 475 float device_scale_factor);
470 476
471 void SetupMouseMoveAtWithDeviceScale(float device_scale_factor); 477 void SetupMouseMoveAtWithDeviceScale(float device_scale_factor);
472 478
473 void SetupMouseMoveAtTestScrollbarStates(bool main_thread_scrolling); 479 void SetupMouseMoveAtTestScrollbarStates(bool main_thread_scrolling);
474 480
475 scoped_refptr<AnimationTimeline> timeline() { return timeline_; } 481 scoped_refptr<AnimationTimeline> timeline() { return timeline_; }
476 482
477 protected: 483 protected:
478 virtual std::unique_ptr<CompositorFrameSink> CreateCompositorFrameSink() { 484 virtual std::unique_ptr<CompositorFrameSink> CreateCompositorFrameSink() {
479 return FakeCompositorFrameSink::Create3dForGpuRasterization(); 485 return FakeCompositorFrameSink::Create3dForGpuRasterization();
480 } 486 }
481 487
482 void DrawOneFrame() { 488 void DrawOneFrame() {
483 LayerTreeHostImpl::FrameData frame_data; 489 TestFrameData frame_data;
484 host_impl_->PrepareToDraw(&frame_data); 490 host_impl_->PrepareToDraw(&frame_data);
485 host_impl_->DidDrawAllLayers(frame_data); 491 host_impl_->DidDrawAllLayers(frame_data);
486 } 492 }
487 493
488 static void SetScrollOffsetDelta(LayerImpl* layer_impl, 494 static void SetScrollOffsetDelta(LayerImpl* layer_impl,
489 const gfx::Vector2dF& delta) { 495 const gfx::Vector2dF& delta) {
490 if (layer_impl->layer_tree_impl() 496 if (layer_impl->layer_tree_impl()
491 ->property_trees() 497 ->property_trees()
492 ->scroll_tree.SetScrollOffsetDeltaForTesting(layer_impl->id(), 498 ->scroll_tree.SetScrollOffsetDeltaForTesting(layer_impl->id(),
493 delta)) 499 delta))
(...skipping 29 matching lines...) Expand all
523 bool did_notify_ready_to_activate_; 529 bool did_notify_ready_to_activate_;
524 bool did_request_commit_; 530 bool did_request_commit_;
525 bool did_request_redraw_; 531 bool did_request_redraw_;
526 bool did_request_next_frame_; 532 bool did_request_next_frame_;
527 bool did_request_prepare_tiles_; 533 bool did_request_prepare_tiles_;
528 bool did_complete_page_scale_animation_; 534 bool did_complete_page_scale_animation_;
529 bool reduce_memory_result_; 535 bool reduce_memory_result_;
530 bool did_request_impl_side_invalidation_; 536 bool did_request_impl_side_invalidation_;
531 base::Closure animation_task_; 537 base::Closure animation_task_;
532 base::TimeDelta requested_animation_delay_; 538 base::TimeDelta requested_animation_delay_;
533 std::unique_ptr<LayerTreeHostImpl::FrameData> last_on_draw_frame_; 539 std::unique_ptr<TestFrameData> last_on_draw_frame_;
534 RenderPassList last_on_draw_render_passes_; 540 RenderPassList last_on_draw_render_passes_;
535 scoped_refptr<AnimationTimeline> timeline_; 541 scoped_refptr<AnimationTimeline> timeline_;
536 std::unique_ptr<base::Thread> image_worker_; 542 std::unique_ptr<base::Thread> image_worker_;
537 }; 543 };
538 544
539 // A test fixture for new animation timelines tests. 545 // A test fixture for new animation timelines tests.
540 class LayerTreeHostImplTimelinesTest : public LayerTreeHostImplTest { 546 class LayerTreeHostImplTimelinesTest : public LayerTreeHostImplTest {
541 public: 547 public:
542 void SetUp() override { 548 void SetUp() override {
543 CreateHostImpl(DefaultSettings(), CreateCompositorFrameSink()); 549 CreateHostImpl(DefaultSettings(), CreateCompositorFrameSink());
(...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after
1560 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2, now)); 1566 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2, now));
1561 1567
1562 host_impl_->ActivateAnimations(); 1568 host_impl_->ActivateAnimations();
1563 host_impl_->Animate(); 1569 host_impl_->Animate();
1564 1570
1565 EXPECT_FALSE(child->was_ever_ready_since_last_transform_animation()); 1571 EXPECT_FALSE(child->was_ever_ready_since_last_transform_animation());
1566 1572
1567 host_impl_->ResetRequiresHighResToDraw(); 1573 host_impl_->ResetRequiresHighResToDraw();
1568 1574
1569 // Child layer has an animating transform but missing tiles. 1575 // Child layer has an animating transform but missing tiles.
1570 FakeLayerTreeHostImpl::FrameData frame; 1576 TestFrameData frame;
1571 DrawResult result = host_impl_->PrepareToDraw(&frame); 1577 DrawResult result = host_impl_->PrepareToDraw(&frame);
1572 EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS, result); 1578 EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS, result);
1573 host_impl_->DidDrawAllLayers(frame); 1579 host_impl_->DidDrawAllLayers(frame);
1574 1580
1575 child->set_has_missing_tiles(false); 1581 child->set_has_missing_tiles(false);
1576 1582
1577 // Child layer has an animating and no missing tiles. 1583 // Child layer has an animating and no missing tiles.
1578 result = host_impl_->PrepareToDraw(&frame); 1584 result = host_impl_->PrepareToDraw(&frame);
1579 EXPECT_EQ(DRAW_SUCCESS, result); 1585 EXPECT_EQ(DRAW_SUCCESS, result);
1580 EXPECT_TRUE(child->was_ever_ready_since_last_transform_animation()); 1586 EXPECT_TRUE(child->was_ever_ready_since_last_transform_animation());
(...skipping 1871 matching lines...) Expand 10 before | Expand all | Expand 10 after
3452 static_cast<DidDrawCheckLayer*>(*host_impl_->active_tree()->begin()); 3458 static_cast<DidDrawCheckLayer*>(*host_impl_->active_tree()->begin());
3453 3459
3454 root->test_properties()->AddChild( 3460 root->test_properties()->AddChild(
3455 DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); 3461 DidDrawCheckLayer::Create(host_impl_->active_tree(), 2));
3456 root->test_properties()->force_render_surface = true; 3462 root->test_properties()->force_render_surface = true;
3457 DidDrawCheckLayer* layer = 3463 DidDrawCheckLayer* layer =
3458 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[0]); 3464 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[0]);
3459 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 3465 host_impl_->active_tree()->BuildPropertyTreesForTesting();
3460 3466
3461 { 3467 {
3462 LayerTreeHostImpl::FrameData frame; 3468 TestFrameData frame;
3463 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 3469 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3464 host_impl_->DrawLayers(&frame); 3470 host_impl_->DrawLayers(&frame);
3465 host_impl_->DidDrawAllLayers(frame); 3471 host_impl_->DidDrawAllLayers(frame);
3466 3472
3467 EXPECT_TRUE(layer->will_draw_called()); 3473 EXPECT_TRUE(layer->will_draw_called());
3468 EXPECT_TRUE(layer->append_quads_called()); 3474 EXPECT_TRUE(layer->append_quads_called());
3469 EXPECT_TRUE(layer->did_draw_called()); 3475 EXPECT_TRUE(layer->did_draw_called());
3470 } 3476 }
3471 3477
3472 host_impl_->SetViewportDamage(gfx::Rect(10, 10)); 3478 host_impl_->SetViewportDamage(gfx::Rect(10, 10));
3473 3479
3474 { 3480 {
3475 LayerTreeHostImpl::FrameData frame; 3481 TestFrameData frame;
3476 3482
3477 layer->set_will_draw_returns_false(); 3483 layer->set_will_draw_returns_false();
3478 layer->ClearDidDrawCheck(); 3484 layer->ClearDidDrawCheck();
3479 3485
3480 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 3486 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3481 host_impl_->DrawLayers(&frame); 3487 host_impl_->DrawLayers(&frame);
3482 host_impl_->DidDrawAllLayers(frame); 3488 host_impl_->DidDrawAllLayers(frame);
3483 3489
3484 EXPECT_TRUE(layer->will_draw_called()); 3490 EXPECT_TRUE(layer->will_draw_called());
3485 EXPECT_FALSE(layer->append_quads_called()); 3491 EXPECT_FALSE(layer->append_quads_called());
(...skipping 12 matching lines...) Expand all
3498 root->test_properties()->force_render_surface = true; 3504 root->test_properties()->force_render_surface = true;
3499 root->test_properties()->AddChild( 3505 root->test_properties()->AddChild(
3500 DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); 3506 DidDrawCheckLayer::Create(host_impl_->active_tree(), 2));
3501 DidDrawCheckLayer* layer = 3507 DidDrawCheckLayer* layer =
3502 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[0]); 3508 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[0]);
3503 // Ensure visible_layer_rect for layer is empty. 3509 // Ensure visible_layer_rect for layer is empty.
3504 layer->SetPosition(gfx::PointF(100.f, 100.f)); 3510 layer->SetPosition(gfx::PointF(100.f, 100.f));
3505 layer->SetBounds(gfx::Size(10, 10)); 3511 layer->SetBounds(gfx::Size(10, 10));
3506 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 3512 host_impl_->active_tree()->BuildPropertyTreesForTesting();
3507 3513
3508 LayerTreeHostImpl::FrameData frame; 3514 TestFrameData frame;
3509 3515
3510 EXPECT_FALSE(layer->will_draw_called()); 3516 EXPECT_FALSE(layer->will_draw_called());
3511 EXPECT_FALSE(layer->did_draw_called()); 3517 EXPECT_FALSE(layer->did_draw_called());
3512 3518
3513 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 3519 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3514 host_impl_->DrawLayers(&frame); 3520 host_impl_->DrawLayers(&frame);
3515 host_impl_->DidDrawAllLayers(frame); 3521 host_impl_->DidDrawAllLayers(frame);
3516 3522
3517 EXPECT_FALSE(layer->will_draw_called()); 3523 EXPECT_FALSE(layer->will_draw_called());
3518 EXPECT_FALSE(layer->did_draw_called()); 3524 EXPECT_FALSE(layer->did_draw_called());
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
3555 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); 3561 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3));
3556 root->test_properties()->force_render_surface = true; 3562 root->test_properties()->force_render_surface = true;
3557 DidDrawCheckLayer* top_layer = 3563 DidDrawCheckLayer* top_layer =
3558 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[1]); 3564 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[1]);
3559 // This layer covers the occluded_layer above. Make this layer large so it can 3565 // This layer covers the occluded_layer above. Make this layer large so it can
3560 // occlude. 3566 // occlude.
3561 top_layer->SetBounds(big_size); 3567 top_layer->SetBounds(big_size);
3562 top_layer->SetContentsOpaque(true); 3568 top_layer->SetContentsOpaque(true);
3563 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 3569 host_impl_->active_tree()->BuildPropertyTreesForTesting();
3564 3570
3565 LayerTreeHostImpl::FrameData frame; 3571 TestFrameData frame;
3566 3572
3567 EXPECT_FALSE(occluded_layer->will_draw_called()); 3573 EXPECT_FALSE(occluded_layer->will_draw_called());
3568 EXPECT_FALSE(occluded_layer->did_draw_called()); 3574 EXPECT_FALSE(occluded_layer->did_draw_called());
3569 EXPECT_FALSE(top_layer->will_draw_called()); 3575 EXPECT_FALSE(top_layer->will_draw_called());
3570 EXPECT_FALSE(top_layer->did_draw_called()); 3576 EXPECT_FALSE(top_layer->did_draw_called());
3571 3577
3572 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 3578 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3573 host_impl_->DrawLayers(&frame); 3579 host_impl_->DrawLayers(&frame);
3574 host_impl_->DidDrawAllLayers(frame); 3580 host_impl_->DidDrawAllLayers(frame);
3575 3581
(...skipping 21 matching lines...) Expand all
3597 static_cast<DidDrawCheckLayer*>(layer1->test_properties()->children[0]); 3603 static_cast<DidDrawCheckLayer*>(layer1->test_properties()->children[0]);
3598 3604
3599 layer1->test_properties()->force_render_surface = true; 3605 layer1->test_properties()->force_render_surface = true;
3600 layer1->test_properties()->should_flatten_transform = true; 3606 layer1->test_properties()->should_flatten_transform = true;
3601 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 3607 host_impl_->active_tree()->BuildPropertyTreesForTesting();
3602 3608
3603 EXPECT_FALSE(root->did_draw_called()); 3609 EXPECT_FALSE(root->did_draw_called());
3604 EXPECT_FALSE(layer1->did_draw_called()); 3610 EXPECT_FALSE(layer1->did_draw_called());
3605 EXPECT_FALSE(layer2->did_draw_called()); 3611 EXPECT_FALSE(layer2->did_draw_called());
3606 3612
3607 LayerTreeHostImpl::FrameData frame; 3613 TestFrameData frame;
3608 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( 3614 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(
3609 *host_impl_->active_tree()->begin()); 3615 *host_impl_->active_tree()->begin());
3610 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 3616 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3611 host_impl_->DrawLayers(&frame); 3617 host_impl_->DrawLayers(&frame);
3612 host_impl_->DidDrawAllLayers(frame); 3618 host_impl_->DidDrawAllLayers(frame);
3613 3619
3614 EXPECT_TRUE(root->did_draw_called()); 3620 EXPECT_TRUE(root->did_draw_called());
3615 EXPECT_TRUE(layer1->did_draw_called()); 3621 EXPECT_TRUE(layer1->did_draw_called());
3616 EXPECT_TRUE(layer2->did_draw_called()); 3622 EXPECT_TRUE(layer2->did_draw_called());
3617 3623
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
3768 cases.back().layer_before.has_missing_tile = true; 3774 cases.back().layer_before.has_missing_tile = true;
3769 cases.back().layer_before.is_animating = true; 3775 cases.back().layer_before.is_animating = true;
3770 3776
3771 host_impl_->active_tree()->SetRootLayerForTesting( 3777 host_impl_->active_tree()->SetRootLayerForTesting(
3772 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); 3778 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1));
3773 DidDrawCheckLayer* root = 3779 DidDrawCheckLayer* root =
3774 static_cast<DidDrawCheckLayer*>(*host_impl_->active_tree()->begin()); 3780 static_cast<DidDrawCheckLayer*>(*host_impl_->active_tree()->begin());
3775 root->test_properties()->force_render_surface = true; 3781 root->test_properties()->force_render_surface = true;
3776 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 3782 host_impl_->active_tree()->BuildPropertyTreesForTesting();
3777 3783
3778 LayerTreeHostImpl::FrameData frame; 3784 TestFrameData frame;
3779 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 3785 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3780 host_impl_->DrawLayers(&frame); 3786 host_impl_->DrawLayers(&frame);
3781 host_impl_->DidDrawAllLayers(frame); 3787 host_impl_->DidDrawAllLayers(frame);
3782 3788
3783 for (size_t i = 0; i < cases.size(); ++i) { 3789 for (size_t i = 0; i < cases.size(); ++i) {
3784 // Clean up host_impl_ state. 3790 // Clean up host_impl_ state.
3785 const auto& testcase = cases[i]; 3791 const auto& testcase = cases[i];
3786 std::vector<LayerImpl*> to_remove; 3792 std::vector<LayerImpl*> to_remove;
3787 for (auto* child : root->test_properties()->children) 3793 for (auto* child : root->test_properties()->children)
3788 to_remove.push_back(child); 3794 to_remove.push_back(child);
3789 for (auto* child : to_remove) 3795 for (auto* child : to_remove)
3790 root->test_properties()->RemoveChild(child); 3796 root->test_properties()->RemoveChild(child);
3791 timeline()->ClearPlayers(); 3797 timeline()->ClearPlayers();
3792 3798
3793 std::ostringstream scope; 3799 std::ostringstream scope;
3794 scope << "Test case: " << i; 3800 scope << "Test case: " << i;
3795 SCOPED_TRACE(scope.str()); 3801 SCOPED_TRACE(scope.str());
3796 3802
3797 CreateLayerFromState(root, timeline(), testcase.layer_before); 3803 CreateLayerFromState(root, timeline(), testcase.layer_before);
3798 CreateLayerFromState(root, timeline(), testcase.layer_between); 3804 CreateLayerFromState(root, timeline(), testcase.layer_between);
3799 CreateLayerFromState(root, timeline(), testcase.layer_after); 3805 CreateLayerFromState(root, timeline(), testcase.layer_after);
3800 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 3806 host_impl_->active_tree()->BuildPropertyTreesForTesting();
3801 3807
3802 if (testcase.high_res_required) 3808 if (testcase.high_res_required)
3803 host_impl_->SetRequiresHighResToDraw(); 3809 host_impl_->SetRequiresHighResToDraw();
3804 3810
3805 LayerTreeHostImpl::FrameData frame; 3811 TestFrameData frame;
3806 EXPECT_EQ(testcase.expected_result, host_impl_->PrepareToDraw(&frame)); 3812 EXPECT_EQ(testcase.expected_result, host_impl_->PrepareToDraw(&frame));
3807 host_impl_->DrawLayers(&frame); 3813 host_impl_->DrawLayers(&frame);
3808 host_impl_->DidDrawAllLayers(frame); 3814 host_impl_->DidDrawAllLayers(frame);
3809 } 3815 }
3810 } 3816 }
3811 3817
3812 TEST_F(LayerTreeHostImplTest, 3818 TEST_F(LayerTreeHostImplTest,
3813 PrepareToDrawWhenDrawAndSwapFullViewportEveryFrame) { 3819 PrepareToDrawWhenDrawAndSwapFullViewportEveryFrame) {
3814 CreateHostImpl(DefaultSettings(), FakeCompositorFrameSink::CreateSoftware()); 3820 CreateHostImpl(DefaultSettings(), FakeCompositorFrameSink::CreateSoftware());
3815 3821
(...skipping 1338 matching lines...) Expand 10 before | Expand all | Expand 10 after
5154 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 5160 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
5155 InputHandler::TOUCHSCREEN); 5161 InputHandler::TOUCHSCREEN);
5156 host_impl_->PinchGestureBegin(); 5162 host_impl_->PinchGestureBegin();
5157 host_impl_->PinchGestureUpdate(new_page_scale, gfx::Point()); 5163 host_impl_->PinchGestureUpdate(new_page_scale, gfx::Point());
5158 host_impl_->PinchGestureEnd(); 5164 host_impl_->PinchGestureEnd();
5159 host_impl_->ScrollEnd(EndState().get()); 5165 host_impl_->ScrollEnd(EndState().get());
5160 DrawOneFrame(); 5166 DrawOneFrame();
5161 5167
5162 // Make sure all the layers are drawn with the page scale delta applied, i.e., 5168 // Make sure all the layers are drawn with the page scale delta applied, i.e.,
5163 // the page scale delta on the root layer is applied hierarchically. 5169 // the page scale delta on the root layer is applied hierarchically.
5164 LayerTreeHostImpl::FrameData frame; 5170 TestFrameData frame;
5165 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 5171 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
5166 host_impl_->DrawLayers(&frame); 5172 host_impl_->DrawLayers(&frame);
5167 host_impl_->DidDrawAllLayers(frame); 5173 host_impl_->DidDrawAllLayers(frame);
5168 5174
5169 EXPECT_EQ(1.f, root->DrawTransform().matrix().getDouble(0, 0)); 5175 EXPECT_EQ(1.f, root->DrawTransform().matrix().getDouble(0, 0));
5170 EXPECT_EQ(1.f, root->DrawTransform().matrix().getDouble(1, 1)); 5176 EXPECT_EQ(1.f, root->DrawTransform().matrix().getDouble(1, 1));
5171 EXPECT_EQ(new_page_scale, scroll->DrawTransform().matrix().getDouble(0, 0)); 5177 EXPECT_EQ(new_page_scale, scroll->DrawTransform().matrix().getDouble(0, 0));
5172 EXPECT_EQ(new_page_scale, scroll->DrawTransform().matrix().getDouble(1, 1)); 5178 EXPECT_EQ(new_page_scale, scroll->DrawTransform().matrix().getDouble(1, 1));
5173 EXPECT_EQ(new_page_scale, child->DrawTransform().matrix().getDouble(0, 0)); 5179 EXPECT_EQ(new_page_scale, child->DrawTransform().matrix().getDouble(0, 0));
5174 EXPECT_EQ(new_page_scale, child->DrawTransform().matrix().getDouble(1, 1)); 5180 EXPECT_EQ(new_page_scale, child->DrawTransform().matrix().getDouble(1, 1));
(...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after
5998 DrawFrame(); 6004 DrawFrame();
5999 CheckLayerScrollDelta(scroll_layer, gfx::Vector2dF(0.f, 0.f)); 6005 CheckLayerScrollDelta(scroll_layer, gfx::Vector2dF(0.f, 0.f));
6000 EXPECT_FALSE(host_impl_->active_tree()->needs_update_draw_properties()); 6006 EXPECT_FALSE(host_impl_->active_tree()->needs_update_draw_properties());
6001 6007
6002 // Set external scroll delta on delegate and notify LayerTreeHost. 6008 // Set external scroll delta on delegate and notify LayerTreeHost.
6003 gfx::ScrollOffset scroll_offset(10.f, 10.f); 6009 gfx::ScrollOffset scroll_offset(10.f, 10.f);
6004 host_impl_->SetSynchronousInputHandlerRootScrollOffset(scroll_offset); 6010 host_impl_->SetSynchronousInputHandlerRootScrollOffset(scroll_offset);
6005 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 6011 host_impl_->active_tree()->BuildPropertyTreesForTesting();
6006 6012
6007 // Check scroll delta reflected in layer. 6013 // Check scroll delta reflected in layer.
6008 LayerTreeHostImpl::FrameData frame; 6014 TestFrameData frame;
6009 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 6015 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
6010 host_impl_->DrawLayers(&frame); 6016 host_impl_->DrawLayers(&frame);
6011 host_impl_->DidDrawAllLayers(frame); 6017 host_impl_->DidDrawAllLayers(frame);
6012 EXPECT_FALSE(frame.has_no_damage); 6018 EXPECT_FALSE(frame.has_no_damage);
6013 CheckLayerScrollDelta(scroll_layer, ScrollOffsetToVector2dF(scroll_offset)); 6019 CheckLayerScrollDelta(scroll_layer, ScrollOffsetToVector2dF(scroll_offset));
6014 } 6020 }
6015 6021
6016 TEST_F(LayerTreeHostImplTest, OverscrollRoot) { 6022 TEST_F(LayerTreeHostImplTest, OverscrollRoot) {
6017 InputHandlerScrollResult scroll_result; 6023 InputHandlerScrollResult scroll_result;
6018 SetupScrollAndContentsLayers(gfx::Size(100, 100)); 6024 SetupScrollAndContentsLayers(gfx::Size(100, 100));
(...skipping 924 matching lines...) Expand 10 before | Expand all | Expand 10 after
6943 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); 6949 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root));
6944 } 6950 }
6945 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); 6951 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing();
6946 6952
6947 root->test_properties()->AddChild(BlendStateCheckLayer::Create( 6953 root->test_properties()->AddChild(BlendStateCheckLayer::Create(
6948 host_impl_->active_tree(), 2, host_impl_->resource_provider())); 6954 host_impl_->active_tree(), 2, host_impl_->resource_provider()));
6949 BlendStateCheckLayer* layer1 = 6955 BlendStateCheckLayer* layer1 =
6950 static_cast<BlendStateCheckLayer*>(root->test_properties()->children[0]); 6956 static_cast<BlendStateCheckLayer*>(root->test_properties()->children[0]);
6951 layer1->SetPosition(gfx::PointF(2.f, 2.f)); 6957 layer1->SetPosition(gfx::PointF(2.f, 2.f));
6952 6958
6953 LayerTreeHostImpl::FrameData frame; 6959 TestFrameData frame;
6954 6960
6955 // Opaque layer, drawn without blending. 6961 // Opaque layer, drawn without blending.
6956 layer1->SetContentsOpaque(true); 6962 layer1->SetContentsOpaque(true);
6957 layer1->SetExpectation(false, false); 6963 layer1->SetExpectation(false, false);
6958 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 6964 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
6959 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 6965 host_impl_->active_tree()->BuildPropertyTreesForTesting();
6960 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 6966 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
6961 host_impl_->DrawLayers(&frame); 6967 host_impl_->DrawLayers(&frame);
6962 EXPECT_TRUE(layer1->quads_appended()); 6968 EXPECT_TRUE(layer1->quads_appended());
6963 host_impl_->DidDrawAllLayers(frame); 6969 host_impl_->DidDrawAllLayers(frame);
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
7185 host_impl_->active_tree()->set_needs_update_draw_properties(); 7191 host_impl_->active_tree()->set_needs_update_draw_properties();
7186 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 7192 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
7187 host_impl_->DrawLayers(&frame); 7193 host_impl_->DrawLayers(&frame);
7188 EXPECT_TRUE(layer1->quads_appended()); 7194 EXPECT_TRUE(layer1->quads_appended());
7189 host_impl_->DidDrawAllLayers(frame); 7195 host_impl_->DidDrawAllLayers(frame);
7190 } 7196 }
7191 7197
7192 static bool MayContainVideoBitSetOnFrameData(LayerTreeHostImpl* host_impl) { 7198 static bool MayContainVideoBitSetOnFrameData(LayerTreeHostImpl* host_impl) {
7193 host_impl->active_tree()->BuildPropertyTreesForTesting(); 7199 host_impl->active_tree()->BuildPropertyTreesForTesting();
7194 host_impl->active_tree()->set_needs_update_draw_properties(); 7200 host_impl->active_tree()->set_needs_update_draw_properties();
7195 LayerTreeHostImpl::FrameData frame; 7201 TestFrameData frame;
7196 EXPECT_EQ(DRAW_SUCCESS, host_impl->PrepareToDraw(&frame)); 7202 EXPECT_EQ(DRAW_SUCCESS, host_impl->PrepareToDraw(&frame));
7197 host_impl->DrawLayers(&frame); 7203 host_impl->DrawLayers(&frame);
7198 host_impl->DidDrawAllLayers(frame); 7204 host_impl->DidDrawAllLayers(frame);
7199 return frame.may_contain_video; 7205 return frame.may_contain_video;
7200 } 7206 }
7201 7207
7202 TEST_F(LayerTreeHostImplTest, MayContainVideo) { 7208 TEST_F(LayerTreeHostImplTest, MayContainVideo) {
7203 gfx::Size big_size(1000, 1000); 7209 gfx::Size big_size(1000, 1000);
7204 host_impl_->SetViewportSize(big_size); 7210 host_impl_->SetViewportSize(big_size);
7205 7211
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
7275 7281
7276 // Expect no gutter rects. 7282 // Expect no gutter rects.
7277 void TestLayerCoversFullViewport() { 7283 void TestLayerCoversFullViewport() {
7278 gfx::Rect layer_rect(viewport_size_); 7284 gfx::Rect layer_rect(viewport_size_);
7279 child_->SetPosition(gfx::PointF(layer_rect.origin())); 7285 child_->SetPosition(gfx::PointF(layer_rect.origin()));
7280 child_->SetBounds(layer_rect.size()); 7286 child_->SetBounds(layer_rect.size());
7281 child_->SetQuadRect(gfx::Rect(layer_rect.size())); 7287 child_->SetQuadRect(gfx::Rect(layer_rect.size()));
7282 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); 7288 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size()));
7283 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 7289 host_impl_->active_tree()->BuildPropertyTreesForTesting();
7284 7290
7285 LayerTreeHostImpl::FrameData frame; 7291 TestFrameData frame;
7286 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 7292 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
7287 ASSERT_EQ(1u, frame.render_passes.size()); 7293 ASSERT_EQ(1u, frame.render_passes.size());
7288 7294
7289 EXPECT_EQ(0u, CountGutterQuads(frame.render_passes[0]->quad_list)); 7295 EXPECT_EQ(0u, CountGutterQuads(frame.render_passes[0]->quad_list));
7290 EXPECT_EQ(1u, frame.render_passes[0]->quad_list.size()); 7296 EXPECT_EQ(1u, frame.render_passes[0]->quad_list.size());
7291 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list); 7297 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list);
7292 7298
7293 VerifyQuadsExactlyCoverViewport(frame.render_passes[0]->quad_list); 7299 VerifyQuadsExactlyCoverViewport(frame.render_passes[0]->quad_list);
7294 host_impl_->DidDrawAllLayers(frame); 7300 host_impl_->DidDrawAllLayers(frame);
7295 } 7301 }
(...skipping 13 matching lines...) Expand all
7309 7315
7310 EXPECT_EQ(1u, CountGutterQuads(render_passes[0]->quad_list)); 7316 EXPECT_EQ(1u, CountGutterQuads(render_passes[0]->quad_list));
7311 EXPECT_EQ(1u, render_passes[0]->quad_list.size()); 7317 EXPECT_EQ(1u, render_passes[0]->quad_list.size());
7312 ValidateTextureDrawQuads(render_passes[0]->quad_list); 7318 ValidateTextureDrawQuads(render_passes[0]->quad_list);
7313 7319
7314 VerifyQuadsExactlyCoverViewport(render_passes[0]->quad_list); 7320 VerifyQuadsExactlyCoverViewport(render_passes[0]->quad_list);
7315 } 7321 }
7316 7322
7317 void TestEmptyLayer() { 7323 void TestEmptyLayer() {
7318 SetUpEmptylayer(); 7324 SetUpEmptylayer();
7319 LayerTreeHostImpl::FrameData frame; 7325 TestFrameData frame;
7320 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 7326 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
7321 VerifyEmptyLayerRenderPasses(frame.render_passes); 7327 VerifyEmptyLayerRenderPasses(frame.render_passes);
7322 host_impl_->DidDrawAllLayers(frame); 7328 host_impl_->DidDrawAllLayers(frame);
7323 } 7329 }
7324 7330
7325 void TestEmptyLayerWithOnDraw() { 7331 void TestEmptyLayerWithOnDraw() {
7326 SetUpEmptylayer(); 7332 SetUpEmptylayer();
7327 gfx::Transform identity; 7333 gfx::Transform identity;
7328 gfx::Rect viewport(viewport_size_); 7334 gfx::Rect viewport(viewport_size_);
7329 bool resourceless_software_draw = true; 7335 bool resourceless_software_draw = true;
(...skipping 16 matching lines...) Expand all
7346 7352
7347 EXPECT_EQ(4u, CountGutterQuads(render_passes[0]->quad_list)); 7353 EXPECT_EQ(4u, CountGutterQuads(render_passes[0]->quad_list));
7348 EXPECT_EQ(5u, render_passes[0]->quad_list.size()); 7354 EXPECT_EQ(5u, render_passes[0]->quad_list.size());
7349 ValidateTextureDrawQuads(render_passes[0]->quad_list); 7355 ValidateTextureDrawQuads(render_passes[0]->quad_list);
7350 7356
7351 VerifyQuadsExactlyCoverViewport(render_passes[0]->quad_list); 7357 VerifyQuadsExactlyCoverViewport(render_passes[0]->quad_list);
7352 } 7358 }
7353 7359
7354 void TestLayerInMiddleOfViewport() { 7360 void TestLayerInMiddleOfViewport() {
7355 SetUpLayerInMiddleOfViewport(); 7361 SetUpLayerInMiddleOfViewport();
7356 LayerTreeHostImpl::FrameData frame; 7362 TestFrameData frame;
7357 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 7363 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
7358 VerifyLayerInMiddleOfViewport(frame.render_passes); 7364 VerifyLayerInMiddleOfViewport(frame.render_passes);
7359 host_impl_->DidDrawAllLayers(frame); 7365 host_impl_->DidDrawAllLayers(frame);
7360 } 7366 }
7361 7367
7362 void TestLayerInMiddleOfViewportWithOnDraw() { 7368 void TestLayerInMiddleOfViewportWithOnDraw() {
7363 SetUpLayerInMiddleOfViewport(); 7369 SetUpLayerInMiddleOfViewport();
7364 gfx::Transform identity; 7370 gfx::Transform identity;
7365 gfx::Rect viewport(viewport_size_); 7371 gfx::Rect viewport(viewport_size_);
7366 bool resourceless_software_draw = true; 7372 bool resourceless_software_draw = true;
(...skipping 15 matching lines...) Expand all
7382 void VerifyLayerIsLargerThanViewport(const RenderPassList& render_passes) { 7388 void VerifyLayerIsLargerThanViewport(const RenderPassList& render_passes) {
7383 ASSERT_EQ(1u, render_passes.size()); 7389 ASSERT_EQ(1u, render_passes.size());
7384 7390
7385 EXPECT_EQ(0u, CountGutterQuads(render_passes[0]->quad_list)); 7391 EXPECT_EQ(0u, CountGutterQuads(render_passes[0]->quad_list));
7386 EXPECT_EQ(1u, render_passes[0]->quad_list.size()); 7392 EXPECT_EQ(1u, render_passes[0]->quad_list.size());
7387 ValidateTextureDrawQuads(render_passes[0]->quad_list); 7393 ValidateTextureDrawQuads(render_passes[0]->quad_list);
7388 } 7394 }
7389 7395
7390 void TestLayerIsLargerThanViewport() { 7396 void TestLayerIsLargerThanViewport() {
7391 SetUpLayerIsLargerThanViewport(); 7397 SetUpLayerIsLargerThanViewport();
7392 LayerTreeHostImpl::FrameData frame; 7398 TestFrameData frame;
7393 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 7399 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
7394 VerifyLayerIsLargerThanViewport(frame.render_passes); 7400 VerifyLayerIsLargerThanViewport(frame.render_passes);
7395 host_impl_->DidDrawAllLayers(frame); 7401 host_impl_->DidDrawAllLayers(frame);
7396 } 7402 }
7397 7403
7398 void TestLayerIsLargerThanViewportWithOnDraw() { 7404 void TestLayerIsLargerThanViewportWithOnDraw() {
7399 SetUpLayerIsLargerThanViewport(); 7405 SetUpLayerIsLargerThanViewport();
7400 gfx::Transform identity; 7406 gfx::Transform identity;
7401 gfx::Rect viewport(viewport_size_); 7407 gfx::Rect viewport(viewport_size_);
7402 bool resourceless_software_draw = true; 7408 bool resourceless_software_draw = true;
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
7580 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); 7586 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2);
7581 child->SetPosition(gfx::PointF(12.f, 13.f)); 7587 child->SetPosition(gfx::PointF(12.f, 13.f));
7582 child->SetBounds(gfx::Size(14, 15)); 7588 child->SetBounds(gfx::Size(14, 15));
7583 child->SetDrawsContent(true); 7589 child->SetDrawsContent(true);
7584 root->SetBounds(gfx::Size(500, 500)); 7590 root->SetBounds(gfx::Size(500, 500));
7585 root->SetDrawsContent(true); 7591 root->SetDrawsContent(true);
7586 root->test_properties()->AddChild(std::move(child)); 7592 root->test_properties()->AddChild(std::move(child));
7587 layer_tree_host_impl->active_tree()->SetRootLayerForTesting(std::move(root)); 7593 layer_tree_host_impl->active_tree()->SetRootLayerForTesting(std::move(root));
7588 layer_tree_host_impl->active_tree()->BuildPropertyTreesForTesting(); 7594 layer_tree_host_impl->active_tree()->BuildPropertyTreesForTesting();
7589 7595
7590 LayerTreeHostImpl::FrameData frame; 7596 TestFrameData frame;
7591 7597
7592 // First frame, the entire screen should get swapped. 7598 // First frame, the entire screen should get swapped.
7593 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); 7599 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame));
7594 layer_tree_host_impl->DrawLayers(&frame); 7600 layer_tree_host_impl->DrawLayers(&frame);
7595 layer_tree_host_impl->DidDrawAllLayers(frame); 7601 layer_tree_host_impl->DidDrawAllLayers(frame);
7596 gfx::Rect expected_swap_rect(500, 500); 7602 gfx::Rect expected_swap_rect(500, 500);
7597 EXPECT_EQ(expected_swap_rect.ToString(), 7603 EXPECT_EQ(expected_swap_rect.ToString(),
7598 fake_compositor_frame_sink->last_swap_rect().ToString()); 7604 fake_compositor_frame_sink->last_swap_rect().ToString());
7599 7605
7600 // Second frame, only the damaged area should get swapped. Damage should be 7606 // Second frame, only the damaged area should get swapped. Damage should be
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
7642 child->SetBounds(gfx::Size(10, 10)); 7648 child->SetBounds(gfx::Size(10, 10));
7643 child->SetDrawsContent(true); 7649 child->SetDrawsContent(true);
7644 root->SetBounds(gfx::Size(10, 10)); 7650 root->SetBounds(gfx::Size(10, 10));
7645 root->SetDrawsContent(true); 7651 root->SetDrawsContent(true);
7646 root->test_properties()->force_render_surface = true; 7652 root->test_properties()->force_render_surface = true;
7647 root->test_properties()->AddChild(std::move(child)); 7653 root->test_properties()->AddChild(std::move(child));
7648 7654
7649 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); 7655 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root));
7650 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 7656 host_impl_->active_tree()->BuildPropertyTreesForTesting();
7651 7657
7652 LayerTreeHostImpl::FrameData frame; 7658 TestFrameData frame;
7653 7659
7654 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 7660 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
7655 EXPECT_EQ(1u, frame.render_surface_layer_list->size()); 7661 EXPECT_EQ(1u, frame.render_surface_layer_list->size());
7656 EXPECT_EQ(1u, frame.render_passes.size()); 7662 EXPECT_EQ(1u, frame.render_passes.size());
7657 host_impl_->DidDrawAllLayers(frame); 7663 host_impl_->DidDrawAllLayers(frame);
7658 } 7664 }
7659 7665
7660 class FakeLayerWithQuads : public LayerImpl { 7666 class FakeLayerWithQuads : public LayerImpl {
7661 public: 7667 public:
7662 static std::unique_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { 7668 static std::unique_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
7761 TestTaskGraphRunner task_graph_runner; 7767 TestTaskGraphRunner task_graph_runner;
7762 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); 7768 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create());
7763 provider->BindToCurrentThread(); 7769 provider->BindToCurrentThread();
7764 provider->TestContext3d()->set_have_post_sub_buffer(true); 7770 provider->TestContext3d()->set_have_post_sub_buffer(true);
7765 std::unique_ptr<CompositorFrameSink> compositor_frame_sink( 7771 std::unique_ptr<CompositorFrameSink> compositor_frame_sink(
7766 FakeCompositorFrameSink::Create3d(provider)); 7772 FakeCompositorFrameSink::Create3d(provider));
7767 std::unique_ptr<LayerTreeHostImpl> my_host_impl = SetupLayersForOpacity( 7773 std::unique_ptr<LayerTreeHostImpl> my_host_impl = SetupLayersForOpacity(
7768 DefaultSettings(), true, this, &task_runner_provider_, &task_graph_runner, 7774 DefaultSettings(), true, this, &task_runner_provider_, &task_graph_runner,
7769 &stats_instrumentation_, compositor_frame_sink.get()); 7775 &stats_instrumentation_, compositor_frame_sink.get());
7770 { 7776 {
7771 LayerTreeHostImpl::FrameData frame; 7777 TestFrameData frame;
7772 EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame)); 7778 EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame));
7773 7779
7774 // Verify all quads have been computed 7780 // Verify all quads have been computed
7775 ASSERT_EQ(2U, frame.render_passes.size()); 7781 ASSERT_EQ(2U, frame.render_passes.size());
7776 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); 7782 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size());
7777 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); 7783 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size());
7778 EXPECT_EQ(DrawQuad::SOLID_COLOR, 7784 EXPECT_EQ(DrawQuad::SOLID_COLOR,
7779 frame.render_passes[0]->quad_list.front()->material); 7785 frame.render_passes[0]->quad_list.front()->material);
7780 EXPECT_EQ(DrawQuad::RENDER_PASS, 7786 EXPECT_EQ(DrawQuad::RENDER_PASS,
7781 frame.render_passes[1]->quad_list.front()->material); 7787 frame.render_passes[1]->quad_list.front()->material);
7782 7788
7783 my_host_impl->DrawLayers(&frame); 7789 my_host_impl->DrawLayers(&frame);
7784 my_host_impl->DidDrawAllLayers(frame); 7790 my_host_impl->DidDrawAllLayers(frame);
7785 } 7791 }
7786 my_host_impl->ReleaseCompositorFrameSink(); 7792 my_host_impl->ReleaseCompositorFrameSink();
7787 } 7793 }
7788 7794
7789 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) { 7795 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) {
7790 TestTaskGraphRunner task_graph_runner; 7796 TestTaskGraphRunner task_graph_runner;
7791 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); 7797 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create());
7792 provider->BindToCurrentThread(); 7798 provider->BindToCurrentThread();
7793 provider->TestContext3d()->set_have_post_sub_buffer(true); 7799 provider->TestContext3d()->set_have_post_sub_buffer(true);
7794 std::unique_ptr<CompositorFrameSink> compositor_frame_sink( 7800 std::unique_ptr<CompositorFrameSink> compositor_frame_sink(
7795 FakeCompositorFrameSink::Create3d(provider)); 7801 FakeCompositorFrameSink::Create3d(provider));
7796 std::unique_ptr<LayerTreeHostImpl> my_host_impl = SetupLayersForOpacity( 7802 std::unique_ptr<LayerTreeHostImpl> my_host_impl = SetupLayersForOpacity(
7797 DefaultSettings(), false, this, &task_runner_provider_, 7803 DefaultSettings(), false, this, &task_runner_provider_,
7798 &task_graph_runner, &stats_instrumentation_, compositor_frame_sink.get()); 7804 &task_graph_runner, &stats_instrumentation_, compositor_frame_sink.get());
7799 { 7805 {
7800 LayerTreeHostImpl::FrameData frame; 7806 TestFrameData frame;
7801 EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame)); 7807 EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame));
7802 7808
7803 // Verify all quads have been computed 7809 // Verify all quads have been computed
7804 ASSERT_EQ(2U, frame.render_passes.size()); 7810 ASSERT_EQ(2U, frame.render_passes.size());
7805 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); 7811 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size());
7806 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); 7812 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size());
7807 EXPECT_EQ(DrawQuad::SOLID_COLOR, 7813 EXPECT_EQ(DrawQuad::SOLID_COLOR,
7808 frame.render_passes[0]->quad_list.front()->material); 7814 frame.render_passes[0]->quad_list.front()->material);
7809 EXPECT_EQ(DrawQuad::RENDER_PASS, 7815 EXPECT_EQ(DrawQuad::RENDER_PASS,
7810 frame.render_passes[1]->quad_list.front()->material); 7816 frame.render_passes[1]->quad_list.front()->material);
(...skipping 25 matching lines...) Expand all
7836 host_impl_->active_tree(), 4, &provider, media::VIDEO_ROTATION_0); 7842 host_impl_->active_tree(), 4, &provider, media::VIDEO_ROTATION_0);
7837 video_layer->SetBounds(gfx::Size(10, 10)); 7843 video_layer->SetBounds(gfx::Size(10, 10));
7838 video_layer->SetDrawsContent(true); 7844 video_layer->SetDrawsContent(true);
7839 root_layer->test_properties()->AddChild(std::move(video_layer)); 7845 root_layer->test_properties()->AddChild(std::move(video_layer));
7840 7846
7841 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_layer)); 7847 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_layer));
7842 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 7848 host_impl_->active_tree()->BuildPropertyTreesForTesting();
7843 7849
7844 EXPECT_EQ(0u, context3d->NumTextures()); 7850 EXPECT_EQ(0u, context3d->NumTextures());
7845 7851
7846 LayerTreeHostImpl::FrameData frame; 7852 TestFrameData frame;
7847 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 7853 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
7848 host_impl_->DrawLayers(&frame); 7854 host_impl_->DrawLayers(&frame);
7849 host_impl_->DidDrawAllLayers(frame); 7855 host_impl_->DidDrawAllLayers(frame);
7850 7856
7851 EXPECT_GT(context3d->NumTextures(), 0u); 7857 EXPECT_GT(context3d->NumTextures(), 0u);
7852 7858
7853 // Kill the layer tree. 7859 // Kill the layer tree.
7854 host_impl_->active_tree()->DetachLayers(); 7860 host_impl_->active_tree()->DetachLayers();
7855 // There should be no textures left in use after. 7861 // There should be no textures left in use after.
7856 EXPECT_EQ(0u, context3d->NumTextures()); 7862 EXPECT_EQ(0u, context3d->NumTextures());
7857 } 7863 }
7858 7864
7859 class MockDrawQuadsToFillScreenContext : public TestWebGraphicsContext3D { 7865 class MockDrawQuadsToFillScreenContext : public TestWebGraphicsContext3D {
7860 public: 7866 public:
7861 MOCK_METHOD1(useProgram, void(GLuint program)); 7867 MOCK_METHOD1(useProgram, void(GLuint program));
7862 MOCK_METHOD4(drawElements, 7868 MOCK_METHOD4(drawElements,
7863 void(GLenum mode, GLsizei count, GLenum type, GLintptr offset)); 7869 void(GLenum mode, GLsizei count, GLenum type, GLintptr offset));
7864 }; 7870 };
7865 7871
7866 TEST_F(LayerTreeHostImplTest, HasTransparentBackground) { 7872 TEST_F(LayerTreeHostImplTest, HasTransparentBackground) {
7867 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); 7873 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1));
7868 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 7874 host_impl_->active_tree()->BuildPropertyTreesForTesting();
7869 7875
7870 host_impl_->active_tree()->set_background_color(SK_ColorWHITE); 7876 host_impl_->active_tree()->set_background_color(SK_ColorWHITE);
7871 7877
7872 // Verify one quad is drawn when transparent background set is not set. 7878 // Verify one quad is drawn when transparent background set is not set.
7873 host_impl_->active_tree()->set_has_transparent_background(false); 7879 host_impl_->active_tree()->set_has_transparent_background(false);
7874 LayerTreeHostImpl::FrameData frame; 7880 TestFrameData frame;
7875 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 7881 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
7876 { 7882 {
7877 const auto& root_pass = frame.render_passes.back(); 7883 const auto& root_pass = frame.render_passes.back();
7878 ASSERT_EQ(1u, root_pass->quad_list.size()); 7884 ASSERT_EQ(1u, root_pass->quad_list.size());
7879 EXPECT_EQ(DrawQuad::SOLID_COLOR, root_pass->quad_list.front()->material); 7885 EXPECT_EQ(DrawQuad::SOLID_COLOR, root_pass->quad_list.front()->material);
7880 } 7886 }
7881 host_impl_->DrawLayers(&frame); 7887 host_impl_->DrawLayers(&frame);
7882 host_impl_->DidDrawAllLayers(frame); 7888 host_impl_->DidDrawAllLayers(frame);
7883 7889
7884 // Cause damage so we would draw something if possible. 7890 // Cause damage so we would draw something if possible.
(...skipping 13 matching lines...) Expand all
7898 7904
7899 class LayerTreeHostImplTestDrawAndTestDamage : public LayerTreeHostImplTest { 7905 class LayerTreeHostImplTestDrawAndTestDamage : public LayerTreeHostImplTest {
7900 protected: 7906 protected:
7901 std::unique_ptr<CompositorFrameSink> CreateCompositorFrameSink() override { 7907 std::unique_ptr<CompositorFrameSink> CreateCompositorFrameSink() override {
7902 return FakeCompositorFrameSink::Create3d(); 7908 return FakeCompositorFrameSink::Create3d();
7903 } 7909 }
7904 7910
7905 void DrawFrameAndTestDamage(const gfx::Rect& expected_damage) { 7911 void DrawFrameAndTestDamage(const gfx::Rect& expected_damage) {
7906 bool expect_to_draw = !expected_damage.IsEmpty(); 7912 bool expect_to_draw = !expected_damage.IsEmpty();
7907 7913
7908 LayerTreeHostImpl::FrameData frame; 7914 TestFrameData frame;
7909 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 7915 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
7910 7916
7911 if (!expect_to_draw) { 7917 if (!expect_to_draw) {
7912 // With no damage, we don't draw, and no quads are created. 7918 // With no damage, we don't draw, and no quads are created.
7913 ASSERT_EQ(0u, frame.render_passes.size()); 7919 ASSERT_EQ(0u, frame.render_passes.size());
7914 } else { 7920 } else {
7915 ASSERT_EQ(1u, frame.render_passes.size()); 7921 ASSERT_EQ(1u, frame.render_passes.size());
7916 7922
7917 // Verify the damage rect for the root render pass. 7923 // Verify the damage rect for the root render pass.
7918 const RenderPass* root_render_pass = frame.render_passes.back().get(); 7924 const RenderPass* root_render_pass = frame.render_passes.back().get();
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
8028 scrolling_layer->layer_tree_impl() 8034 scrolling_layer->layer_tree_impl()
8029 ->property_trees() 8035 ->property_trees()
8030 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scrolling_layer->id(), 8036 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scrolling_layer->id(),
8031 scroll_offset); 8037 scroll_offset);
8032 host_impl_->ActivateSyncTree(); 8038 host_impl_->ActivateSyncTree();
8033 8039
8034 bool update_lcd_text = false; 8040 bool update_lcd_text = false;
8035 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); 8041 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text);
8036 ASSERT_EQ(1u, host_impl_->active_tree()->RenderSurfaceLayerList().size()); 8042 ASSERT_EQ(1u, host_impl_->active_tree()->RenderSurfaceLayerList().size());
8037 8043
8038 LayerTreeHostImpl::FrameData frame; 8044 TestFrameData frame;
8039 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 8045 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
8040 8046
8041 ASSERT_EQ(1u, frame.render_passes.size()); 8047 ASSERT_EQ(1u, frame.render_passes.size());
8042 ASSERT_LE(1u, frame.render_passes[0]->quad_list.size()); 8048 ASSERT_LE(1u, frame.render_passes[0]->quad_list.size());
8043 const DrawQuad* quad = frame.render_passes[0]->quad_list.front(); 8049 const DrawQuad* quad = frame.render_passes[0]->quad_list.front();
8044 8050
8045 bool clipped = false, force_aa = false; 8051 bool clipped = false, force_aa = false;
8046 gfx::QuadF device_layer_quad = MathUtil::MapQuad( 8052 gfx::QuadF device_layer_quad = MathUtil::MapQuad(
8047 quad->shared_quad_state->quad_to_target_transform, 8053 quad->shared_quad_state->quad_to_target_transform,
8048 gfx::QuadF(gfx::RectF(quad->shared_quad_state->visible_quad_layer_rect)), 8054 gfx::QuadF(gfx::RectF(quad->shared_quad_state->visible_quad_layer_rect)),
(...skipping 14 matching lines...) Expand all
8063 8069
8064 void DidReceiveCompositorFrameAckOnImplThread() override { acks_received_++; } 8070 void DidReceiveCompositorFrameAckOnImplThread() override { acks_received_++; }
8065 8071
8066 int acks_received_ = 0; 8072 int acks_received_ = 0;
8067 }; 8073 };
8068 8074
8069 TEST_F(CompositorFrameMetadataTest, CompositorFrameAckCountsAsSwapComplete) { 8075 TEST_F(CompositorFrameMetadataTest, CompositorFrameAckCountsAsSwapComplete) {
8070 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); 8076 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1));
8071 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 8077 host_impl_->active_tree()->BuildPropertyTreesForTesting();
8072 { 8078 {
8073 LayerTreeHostImpl::FrameData frame; 8079 TestFrameData frame;
8074 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 8080 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
8075 host_impl_->DrawLayers(&frame); 8081 host_impl_->DrawLayers(&frame);
8076 host_impl_->DidDrawAllLayers(frame); 8082 host_impl_->DidDrawAllLayers(frame);
8077 } 8083 }
8078 host_impl_->ReclaimResources(ReturnedResourceArray()); 8084 host_impl_->ReclaimResources(ReturnedResourceArray());
8079 host_impl_->DidReceiveCompositorFrameAck(); 8085 host_impl_->DidReceiveCompositorFrameAck();
8080 EXPECT_EQ(acks_received_, 1); 8086 EXPECT_EQ(acks_received_, 1);
8081 } 8087 }
8082 8088
8083 class CountingSoftwareDevice : public SoftwareOutputDevice { 8089 class CountingSoftwareDevice : public SoftwareOutputDevice {
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
8403 CreateHostImpl(DefaultSettings(), std::move(compositor_frame_sink)); 8409 CreateHostImpl(DefaultSettings(), std::move(compositor_frame_sink));
8404 8410
8405 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); 8411 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1));
8406 8412
8407 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); 8413 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing();
8408 root->test_properties()->copy_requests.push_back( 8414 root->test_properties()->copy_requests.push_back(
8409 CopyOutputRequest::CreateRequest( 8415 CopyOutputRequest::CreateRequest(
8410 base::Bind(&ShutdownReleasesContext_Callback))); 8416 base::Bind(&ShutdownReleasesContext_Callback)));
8411 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 8417 host_impl_->active_tree()->BuildPropertyTreesForTesting();
8412 8418
8413 LayerTreeHostImpl::FrameData frame; 8419 TestFrameData frame;
8414 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 8420 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
8415 host_impl_->DrawLayers(&frame); 8421 host_impl_->DrawLayers(&frame);
8416 host_impl_->DidDrawAllLayers(frame); 8422 host_impl_->DidDrawAllLayers(frame);
8417 8423
8418 // The CopyOutputResult's callback has a ref on the ContextProvider and a 8424 // The CopyOutputResult's callback has a ref on the ContextProvider and a
8419 // texture in a texture mailbox. 8425 // texture in a texture mailbox.
8420 EXPECT_FALSE(context_provider->HasOneRef()); 8426 EXPECT_FALSE(context_provider->HasOneRef());
8421 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures()); 8427 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures());
8422 8428
8423 host_impl_->ReleaseCompositorFrameSink(); 8429 host_impl_->ReleaseCompositorFrameSink();
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
8747 host_impl_->compositor_frame_sink()); 8753 host_impl_->compositor_frame_sink());
8748 8754
8749 ui::LatencyInfo latency_info; 8755 ui::LatencyInfo latency_info;
8750 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, 8756 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0,
8751 0); 8757 0);
8752 std::unique_ptr<SwapPromise> swap_promise( 8758 std::unique_ptr<SwapPromise> swap_promise(
8753 new LatencyInfoSwapPromise(latency_info)); 8759 new LatencyInfoSwapPromise(latency_info));
8754 host_impl_->active_tree()->QueuePinnedSwapPromise(std::move(swap_promise)); 8760 host_impl_->active_tree()->QueuePinnedSwapPromise(std::move(swap_promise));
8755 8761
8756 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); 8762 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize());
8757 LayerTreeHostImpl::FrameData frame; 8763 TestFrameData frame;
8758 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 8764 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
8759 EXPECT_TRUE(host_impl_->DrawLayers(&frame)); 8765 EXPECT_TRUE(host_impl_->DrawLayers(&frame));
8760 host_impl_->DidDrawAllLayers(frame); 8766 host_impl_->DidDrawAllLayers(frame);
8761 8767
8762 const std::vector<ui::LatencyInfo>& metadata_latency_after = 8768 const std::vector<ui::LatencyInfo>& metadata_latency_after =
8763 fake_compositor_frame_sink->last_sent_frame()->metadata.latency_info; 8769 fake_compositor_frame_sink->last_sent_frame()->metadata.latency_info;
8764 EXPECT_EQ(1u, metadata_latency_after.size()); 8770 EXPECT_EQ(1u, metadata_latency_after.size());
8765 EXPECT_TRUE(metadata_latency_after[0].FindLatency( 8771 EXPECT_TRUE(metadata_latency_after[0].FindLatency(
8766 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, NULL)); 8772 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, NULL));
8767 } 8773 }
(...skipping 23 matching lines...) Expand all
8791 selection.start.layer_id = root_layer_id; 8797 selection.start.layer_id = root_layer_id;
8792 selection.start.edge_bottom = selection_bottom; 8798 selection.start.edge_bottom = selection_bottom;
8793 selection.start.edge_top = selection_top; 8799 selection.start.edge_top = selection_top;
8794 selection.end = selection.start; 8800 selection.end = selection.start;
8795 host_impl_->active_tree()->RegisterSelection(selection); 8801 host_impl_->active_tree()->RegisterSelection(selection);
8796 8802
8797 // Trigger a draw-swap sequence. 8803 // Trigger a draw-swap sequence.
8798 host_impl_->SetNeedsRedraw(); 8804 host_impl_->SetNeedsRedraw();
8799 8805
8800 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); 8806 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize());
8801 LayerTreeHostImpl::FrameData frame; 8807 TestFrameData frame;
8802 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 8808 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
8803 EXPECT_TRUE(host_impl_->DrawLayers(&frame)); 8809 EXPECT_TRUE(host_impl_->DrawLayers(&frame));
8804 host_impl_->DidDrawAllLayers(frame); 8810 host_impl_->DidDrawAllLayers(frame);
8805 8811
8806 // Ensure the selection bounds have propagated to the frame metadata. 8812 // Ensure the selection bounds have propagated to the frame metadata.
8807 const Selection<gfx::SelectionBound>& selection_after = 8813 const Selection<gfx::SelectionBound>& selection_after =
8808 fake_compositor_frame_sink->last_sent_frame()->metadata.selection; 8814 fake_compositor_frame_sink->last_sent_frame()->metadata.selection;
8809 EXPECT_EQ(selection.start.type, selection_after.start.type()); 8815 EXPECT_EQ(selection.start.type, selection_after.start.type());
8810 EXPECT_EQ(selection.end.type, selection_after.end.type()); 8816 EXPECT_EQ(selection.end.type, selection_after.end.type());
8811 EXPECT_EQ(gfx::PointF(selection_bottom), selection_after.start.edge_bottom()); 8817 EXPECT_EQ(gfx::PointF(selection_bottom), selection_after.start.edge_bottom());
(...skipping 2203 matching lines...) Expand 10 before | Expand all | Expand 10 after
11015 EXPECT_LE(1, num_lost_surfaces_); 11021 EXPECT_LE(1, num_lost_surfaces_);
11016 } 11022 }
11017 11023
11018 size_t CountRenderPassesWithId(const RenderPassList& list, int id) { 11024 size_t CountRenderPassesWithId(const RenderPassList& list, int id) {
11019 return std::count_if( 11025 return std::count_if(
11020 list.begin(), list.end(), 11026 list.begin(), list.end(),
11021 [id](const std::unique_ptr<RenderPass>& p) { return p->id == id; }); 11027 [id](const std::unique_ptr<RenderPass>& p) { return p->id == id; });
11022 } 11028 }
11023 11029
11024 TEST_F(LayerTreeHostImplTest, RemoveUnreferencedRenderPass) { 11030 TEST_F(LayerTreeHostImplTest, RemoveUnreferencedRenderPass) {
11025 LayerTreeHostImpl::FrameData frame; 11031 TestFrameData frame;
11026 frame.render_passes.push_back(RenderPass::Create()); 11032 frame.render_passes.push_back(RenderPass::Create());
11027 RenderPass* pass3 = frame.render_passes.back().get(); 11033 RenderPass* pass3 = frame.render_passes.back().get();
11028 frame.render_passes.push_back(RenderPass::Create()); 11034 frame.render_passes.push_back(RenderPass::Create());
11029 RenderPass* pass2 = frame.render_passes.back().get(); 11035 RenderPass* pass2 = frame.render_passes.back().get();
11030 frame.render_passes.push_back(RenderPass::Create()); 11036 frame.render_passes.push_back(RenderPass::Create());
11031 RenderPass* pass1 = frame.render_passes.back().get(); 11037 RenderPass* pass1 = frame.render_passes.back().get();
11032 11038
11033 pass1->SetNew(1, gfx::Rect(), gfx::Rect(), gfx::Transform()); 11039 pass1->SetNew(1, gfx::Rect(), gfx::Rect(), gfx::Transform());
11034 pass2->SetNew(2, gfx::Rect(), gfx::Rect(), gfx::Transform()); 11040 pass2->SetNew(2, gfx::Rect(), gfx::Rect(), gfx::Transform());
11035 pass3->SetNew(3, gfx::Rect(), gfx::Rect(), gfx::Transform()); 11041 pass3->SetNew(3, gfx::Rect(), gfx::Rect(), gfx::Transform());
(...skipping 16 matching lines...) Expand all
11052 // But pass2 is not referenced by pass1. So pass2 and pass3 should be culled. 11058 // But pass2 is not referenced by pass1. So pass2 and pass3 should be culled.
11053 FakeLayerTreeHostImpl::RemoveRenderPasses(&frame); 11059 FakeLayerTreeHostImpl::RemoveRenderPasses(&frame);
11054 EXPECT_EQ(1u, frame.render_passes.size()); 11060 EXPECT_EQ(1u, frame.render_passes.size());
11055 EXPECT_EQ(1u, CountRenderPassesWithId(frame.render_passes, 1)); 11061 EXPECT_EQ(1u, CountRenderPassesWithId(frame.render_passes, 1));
11056 EXPECT_EQ(0u, CountRenderPassesWithId(frame.render_passes, 2)); 11062 EXPECT_EQ(0u, CountRenderPassesWithId(frame.render_passes, 2));
11057 EXPECT_EQ(0u, CountRenderPassesWithId(frame.render_passes, 3)); 11063 EXPECT_EQ(0u, CountRenderPassesWithId(frame.render_passes, 3));
11058 EXPECT_EQ(1, frame.render_passes[0]->id); 11064 EXPECT_EQ(1, frame.render_passes[0]->id);
11059 } 11065 }
11060 11066
11061 TEST_F(LayerTreeHostImplTest, RemoveEmptyRenderPass) { 11067 TEST_F(LayerTreeHostImplTest, RemoveEmptyRenderPass) {
11062 LayerTreeHostImpl::FrameData frame; 11068 TestFrameData frame;
11063 frame.render_passes.push_back(RenderPass::Create()); 11069 frame.render_passes.push_back(RenderPass::Create());
11064 RenderPass* pass3 = frame.render_passes.back().get(); 11070 RenderPass* pass3 = frame.render_passes.back().get();
11065 frame.render_passes.push_back(RenderPass::Create()); 11071 frame.render_passes.push_back(RenderPass::Create());
11066 RenderPass* pass2 = frame.render_passes.back().get(); 11072 RenderPass* pass2 = frame.render_passes.back().get();
11067 frame.render_passes.push_back(RenderPass::Create()); 11073 frame.render_passes.push_back(RenderPass::Create());
11068 RenderPass* pass1 = frame.render_passes.back().get(); 11074 RenderPass* pass1 = frame.render_passes.back().get();
11069 11075
11070 pass1->SetNew(1, gfx::Rect(), gfx::Rect(), gfx::Transform()); 11076 pass1->SetNew(1, gfx::Rect(), gfx::Rect(), gfx::Transform());
11071 pass2->SetNew(2, gfx::Rect(), gfx::Rect(), gfx::Transform()); 11077 pass2->SetNew(2, gfx::Rect(), gfx::Rect(), gfx::Transform());
11072 pass3->SetNew(3, gfx::Rect(), gfx::Rect(), gfx::Transform()); 11078 pass3->SetNew(3, gfx::Rect(), gfx::Rect(), gfx::Transform());
(...skipping 21 matching lines...) Expand all
11094 EXPECT_EQ(1u, CountRenderPassesWithId(frame.render_passes, 1)); 11100 EXPECT_EQ(1u, CountRenderPassesWithId(frame.render_passes, 1));
11095 EXPECT_EQ(0u, CountRenderPassesWithId(frame.render_passes, 2)); 11101 EXPECT_EQ(0u, CountRenderPassesWithId(frame.render_passes, 2));
11096 EXPECT_EQ(0u, CountRenderPassesWithId(frame.render_passes, 3)); 11102 EXPECT_EQ(0u, CountRenderPassesWithId(frame.render_passes, 3));
11097 EXPECT_EQ(1, frame.render_passes[0]->id); 11103 EXPECT_EQ(1, frame.render_passes[0]->id);
11098 // The RenderPassDrawQuad should be removed from pass1. 11104 // The RenderPassDrawQuad should be removed from pass1.
11099 EXPECT_EQ(1u, pass1->quad_list.size()); 11105 EXPECT_EQ(1u, pass1->quad_list.size());
11100 EXPECT_EQ(DrawQuad::SOLID_COLOR, pass1->quad_list.ElementAt(0)->material); 11106 EXPECT_EQ(DrawQuad::SOLID_COLOR, pass1->quad_list.ElementAt(0)->material);
11101 } 11107 }
11102 11108
11103 TEST_F(LayerTreeHostImplTest, DoNotRemoveEmptyRootRenderPass) { 11109 TEST_F(LayerTreeHostImplTest, DoNotRemoveEmptyRootRenderPass) {
11104 LayerTreeHostImpl::FrameData frame; 11110 TestFrameData frame;
11105 frame.render_passes.push_back(RenderPass::Create()); 11111 frame.render_passes.push_back(RenderPass::Create());
11106 RenderPass* pass3 = frame.render_passes.back().get(); 11112 RenderPass* pass3 = frame.render_passes.back().get();
11107 frame.render_passes.push_back(RenderPass::Create()); 11113 frame.render_passes.push_back(RenderPass::Create());
11108 RenderPass* pass2 = frame.render_passes.back().get(); 11114 RenderPass* pass2 = frame.render_passes.back().get();
11109 frame.render_passes.push_back(RenderPass::Create()); 11115 frame.render_passes.push_back(RenderPass::Create());
11110 RenderPass* pass1 = frame.render_passes.back().get(); 11116 RenderPass* pass1 = frame.render_passes.back().get();
11111 11117
11112 pass1->SetNew(1, gfx::Rect(), gfx::Rect(), gfx::Transform()); 11118 pass1->SetNew(1, gfx::Rect(), gfx::Rect(), gfx::Transform());
11113 pass2->SetNew(2, gfx::Rect(), gfx::Rect(), gfx::Transform()); 11119 pass2->SetNew(2, gfx::Rect(), gfx::Rect(), gfx::Transform());
11114 pass3->SetNew(3, gfx::Rect(), gfx::Rect(), gfx::Transform()); 11120 pass3->SetNew(3, gfx::Rect(), gfx::Rect(), gfx::Transform());
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
11160 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2); 11166 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2);
11161 FakeVideoFrameController controller; 11167 FakeVideoFrameController controller;
11162 11168
11163 host_impl_->WillBeginImplFrame(begin_frame_args); 11169 host_impl_->WillBeginImplFrame(begin_frame_args);
11164 EXPECT_FALSE(controller.begin_frame_args().IsValid()); 11170 EXPECT_FALSE(controller.begin_frame_args().IsValid());
11165 host_impl_->AddVideoFrameController(&controller); 11171 host_impl_->AddVideoFrameController(&controller);
11166 EXPECT_TRUE(controller.begin_frame_args().IsValid()); 11172 EXPECT_TRUE(controller.begin_frame_args().IsValid());
11167 host_impl_->DidFinishImplFrame(); 11173 host_impl_->DidFinishImplFrame();
11168 11174
11169 EXPECT_FALSE(controller.did_draw_frame()); 11175 EXPECT_FALSE(controller.did_draw_frame());
11170 LayerTreeHostImpl::FrameData frame; 11176 TestFrameData frame;
11171 host_impl_->DidDrawAllLayers(frame); 11177 host_impl_->DidDrawAllLayers(frame);
11172 EXPECT_TRUE(controller.did_draw_frame()); 11178 EXPECT_TRUE(controller.did_draw_frame());
11173 11179
11174 controller.OnBeginFrame(begin_frame_args); 11180 controller.OnBeginFrame(begin_frame_args);
11175 EXPECT_FALSE(controller.did_draw_frame()); 11181 EXPECT_FALSE(controller.did_draw_frame());
11176 host_impl_->RemoveVideoFrameController(&controller); 11182 host_impl_->RemoveVideoFrameController(&controller);
11177 host_impl_->DidDrawAllLayers(frame); 11183 host_impl_->DidDrawAllLayers(frame);
11178 EXPECT_FALSE(controller.did_draw_frame()); 11184 EXPECT_FALSE(controller.did_draw_frame());
11179 } 11185 }
11180 11186
11181 TEST_F(LayerTreeHostImplTest, AddVideoFrameControllerOutsideFrame) { 11187 TEST_F(LayerTreeHostImplTest, AddVideoFrameControllerOutsideFrame) {
11182 BeginFrameArgs begin_frame_args = 11188 BeginFrameArgs begin_frame_args =
11183 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2); 11189 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2);
11184 FakeVideoFrameController controller; 11190 FakeVideoFrameController controller;
11185 11191
11186 host_impl_->WillBeginImplFrame(begin_frame_args); 11192 host_impl_->WillBeginImplFrame(begin_frame_args);
11187 host_impl_->DidFinishImplFrame(); 11193 host_impl_->DidFinishImplFrame();
11188 11194
11189 EXPECT_FALSE(controller.begin_frame_args().IsValid()); 11195 EXPECT_FALSE(controller.begin_frame_args().IsValid());
11190 host_impl_->AddVideoFrameController(&controller); 11196 host_impl_->AddVideoFrameController(&controller);
11191 EXPECT_FALSE(controller.begin_frame_args().IsValid()); 11197 EXPECT_FALSE(controller.begin_frame_args().IsValid());
11192 11198
11193 begin_frame_args = CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 3); 11199 begin_frame_args = CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 3);
11194 EXPECT_FALSE(controller.begin_frame_args().IsValid()); 11200 EXPECT_FALSE(controller.begin_frame_args().IsValid());
11195 host_impl_->WillBeginImplFrame(begin_frame_args); 11201 host_impl_->WillBeginImplFrame(begin_frame_args);
11196 EXPECT_TRUE(controller.begin_frame_args().IsValid()); 11202 EXPECT_TRUE(controller.begin_frame_args().IsValid());
11197 11203
11198 EXPECT_FALSE(controller.did_draw_frame()); 11204 EXPECT_FALSE(controller.did_draw_frame());
11199 LayerTreeHostImpl::FrameData frame; 11205 TestFrameData frame;
11200 host_impl_->DidDrawAllLayers(frame); 11206 host_impl_->DidDrawAllLayers(frame);
11201 EXPECT_TRUE(controller.did_draw_frame()); 11207 EXPECT_TRUE(controller.did_draw_frame());
11202 11208
11203 controller.OnBeginFrame(begin_frame_args); 11209 controller.OnBeginFrame(begin_frame_args);
11204 EXPECT_FALSE(controller.did_draw_frame()); 11210 EXPECT_FALSE(controller.did_draw_frame());
11205 host_impl_->RemoveVideoFrameController(&controller); 11211 host_impl_->RemoveVideoFrameController(&controller);
11206 host_impl_->DidDrawAllLayers(frame); 11212 host_impl_->DidDrawAllLayers(frame);
11207 EXPECT_FALSE(controller.did_draw_frame()); 11213 EXPECT_FALSE(controller.did_draw_frame());
11208 } 11214 }
11209 11215
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
11851 else 11857 else
11852 EXPECT_FALSE(tile->HasRasterTask()); 11858 EXPECT_FALSE(tile->HasRasterTask());
11853 } 11859 }
11854 Region expected_invalidation( 11860 Region expected_invalidation(
11855 raster_source->GetRectForImage(checkerable_image->uniqueID())); 11861 raster_source->GetRectForImage(checkerable_image->uniqueID()));
11856 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); 11862 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation()));
11857 } 11863 }
11858 11864
11859 } // namespace 11865 } // namespace
11860 } // namespace cc 11866 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698