OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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.h" | 5 #include "cc/trees/layer_tree_host.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 int num_activates_; | 463 int num_activates_; |
464 int num_output_surfaces_initialized_; | 464 int num_output_surfaces_initialized_; |
465 }; | 465 }; |
466 | 466 |
467 SINGLE_AND_MULTI_THREAD_TEST_F( | 467 SINGLE_AND_MULTI_THREAD_TEST_F( |
468 LayerTreeHostDelegatedTestInvalidFrameAfterContextLost); | 468 LayerTreeHostDelegatedTestInvalidFrameAfterContextLost); |
469 | 469 |
470 class LayerTreeHostDelegatedTestLayerUsesFrameDamage | 470 class LayerTreeHostDelegatedTestLayerUsesFrameDamage |
471 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer { | 471 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer { |
472 public: | 472 public: |
473 LayerTreeHostDelegatedTestLayerUsesFrameDamage() | |
474 : LayerTreeHostDelegatedTestCaseSingleDelegatedLayer(), | |
475 first_draw_for_source_frame_(true) {} | |
476 | |
477 void DidCommit() override { | 473 void DidCommit() override { |
478 int next_source_frame_number = layer_tree_host()->source_frame_number(); | 474 int next_source_frame_number = layer_tree_host()->source_frame_number(); |
479 switch (next_source_frame_number) { | 475 switch (next_source_frame_number) { |
480 case 1: | 476 case 1: |
481 // The first time the layer gets a frame the whole layer should be | 477 // The first time the layer gets a frame the whole layer should be |
482 // damaged. | 478 // damaged. |
483 SetFrameData( | 479 SetFrameData( |
484 CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1))); | 480 CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1))); |
485 break; | 481 break; |
486 case 2: | 482 case 2: |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 SetFrameData( | 570 SetFrameData( |
575 CreateFrameData(gfx::Rect(0, 0, 10, 10), gfx::Rect(4, 0, 1, 1))); | 571 CreateFrameData(gfx::Rect(0, 0, 10, 10), gfx::Rect(4, 0, 1, 1))); |
576 break; | 572 break; |
577 case 18: | 573 case 18: |
578 // Set another new frame, both layers should be damaged in the same | 574 // Set another new frame, both layers should be damaged in the same |
579 // ways. | 575 // ways. |
580 SetFrameData( | 576 SetFrameData( |
581 CreateFrameData(gfx::Rect(0, 0, 10, 10), gfx::Rect(3, 3, 1, 1))); | 577 CreateFrameData(gfx::Rect(0, 0, 10, 10), gfx::Rect(3, 3, 1, 1))); |
582 break; | 578 break; |
583 } | 579 } |
584 first_draw_for_source_frame_ = true; | |
585 } | 580 } |
586 | 581 |
587 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, | 582 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
588 LayerTreeHostImpl::FrameData* frame, | 583 LayerTreeHostImpl::FrameData* frame, |
589 DrawResult draw_result) override { | 584 DrawResult draw_result) override { |
590 EXPECT_EQ(DRAW_SUCCESS, draw_result); | 585 EXPECT_EQ(DRAW_SUCCESS, draw_result); |
591 | 586 |
592 if (!first_draw_for_source_frame_) | |
593 return draw_result; | |
594 | |
595 gfx::Rect damage_rect; | 587 gfx::Rect damage_rect; |
596 if (!frame->has_no_damage) { | 588 if (!frame->has_no_damage) { |
597 damage_rect = frame->render_passes.back()->damage_rect; | 589 damage_rect = frame->render_passes.back()->damage_rect; |
598 } else { | 590 } else { |
599 // If there is no damage, then we have no render passes to send. | 591 // If there is no damage, then we have no render passes to send. |
600 EXPECT_TRUE(frame->render_passes.empty()); | 592 EXPECT_TRUE(frame->render_passes.empty()); |
601 } | 593 } |
602 | 594 |
603 switch (host_impl->active_tree()->source_frame_number()) { | 595 switch (host_impl->active_tree()->source_frame_number()) { |
604 case 0: | 596 case 0: |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 EXPECT_EQ(gfx::Rect(3, 3, 6, 1).ToString(), damage_rect.ToString()); | 654 EXPECT_EQ(gfx::Rect(3, 3, 6, 1).ToString(), damage_rect.ToString()); |
663 EndTest(); | 655 EndTest(); |
664 break; | 656 break; |
665 } | 657 } |
666 | 658 |
667 return draw_result; | 659 return draw_result; |
668 } | 660 } |
669 | 661 |
670 protected: | 662 protected: |
671 scoped_refptr<DelegatedRendererLayer> delegated_copy_; | 663 scoped_refptr<DelegatedRendererLayer> delegated_copy_; |
672 bool first_draw_for_source_frame_; | |
673 }; | 664 }; |
674 | 665 |
675 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDelegatedTestLayerUsesFrameDamage); | 666 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDelegatedTestLayerUsesFrameDamage); |
676 | 667 |
677 class LayerTreeHostDelegatedTestMergeResources | 668 class LayerTreeHostDelegatedTestMergeResources |
678 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer { | 669 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer { |
679 public: | 670 public: |
680 void BeginTest() override { | 671 void BeginTest() override { |
681 // Push two frames to the delegated renderer layer with no commit between. | 672 // Push two frames to the delegated renderer layer with no commit between. |
682 | 673 |
(...skipping 1486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2169 } | 2160 } |
2170 | 2161 |
2171 scoped_refptr<DelegatedRendererLayer> delegated_thief_; | 2162 scoped_refptr<DelegatedRendererLayer> delegated_thief_; |
2172 }; | 2163 }; |
2173 | 2164 |
2174 SINGLE_AND_MULTI_THREAD_TEST_F( | 2165 SINGLE_AND_MULTI_THREAD_TEST_F( |
2175 LayerTreeHostDelegatedTestRemoveAndChangeResources); | 2166 LayerTreeHostDelegatedTestRemoveAndChangeResources); |
2176 | 2167 |
2177 } // namespace | 2168 } // namespace |
2178 } // namespace cc | 2169 } // namespace cc |
OLD | NEW |