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() | 473 LayerTreeHostDelegatedTestLayerUsesFrameDamage() |
danakj
2015/01/05 19:45:14
nit: you can just remove this whole constructor i
sohanjg
2015/01/06 07:25:22
Done.
| |
474 : LayerTreeHostDelegatedTestCaseSingleDelegatedLayer(), | 474 : LayerTreeHostDelegatedTestCaseSingleDelegatedLayer() {} |
475 first_draw_for_source_frame_(true) {} | |
476 | 475 |
477 void DidCommit() override { | 476 void DidCommit() override { |
478 int next_source_frame_number = layer_tree_host()->source_frame_number(); | 477 int next_source_frame_number = layer_tree_host()->source_frame_number(); |
479 switch (next_source_frame_number) { | 478 switch (next_source_frame_number) { |
480 case 1: | 479 case 1: |
481 // The first time the layer gets a frame the whole layer should be | 480 // The first time the layer gets a frame the whole layer should be |
482 // damaged. | 481 // damaged. |
483 SetFrameData( | 482 SetFrameData( |
484 CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1))); | 483 CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1))); |
485 break; | 484 break; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
574 SetFrameData( | 573 SetFrameData( |
575 CreateFrameData(gfx::Rect(0, 0, 10, 10), gfx::Rect(4, 0, 1, 1))); | 574 CreateFrameData(gfx::Rect(0, 0, 10, 10), gfx::Rect(4, 0, 1, 1))); |
576 break; | 575 break; |
577 case 18: | 576 case 18: |
578 // Set another new frame, both layers should be damaged in the same | 577 // Set another new frame, both layers should be damaged in the same |
579 // ways. | 578 // ways. |
580 SetFrameData( | 579 SetFrameData( |
581 CreateFrameData(gfx::Rect(0, 0, 10, 10), gfx::Rect(3, 3, 1, 1))); | 580 CreateFrameData(gfx::Rect(0, 0, 10, 10), gfx::Rect(3, 3, 1, 1))); |
582 break; | 581 break; |
583 } | 582 } |
584 first_draw_for_source_frame_ = true; | |
585 } | 583 } |
586 | 584 |
587 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, | 585 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
588 LayerTreeHostImpl::FrameData* frame, | 586 LayerTreeHostImpl::FrameData* frame, |
589 DrawResult draw_result) override { | 587 DrawResult draw_result) override { |
590 EXPECT_EQ(DRAW_SUCCESS, draw_result); | 588 EXPECT_EQ(DRAW_SUCCESS, draw_result); |
591 | 589 |
592 if (!first_draw_for_source_frame_) | |
593 return draw_result; | |
594 | |
sohanjg
2015/01/05 12:39:58
I think we can assume, PrepareToDraw will happen o
danakj
2015/01/05 19:45:14
Yes but this is trying to prevent multiple draws f
sohanjg
2015/01/06 07:25:22
Acknowledged.
| |
595 gfx::Rect damage_rect; | 590 gfx::Rect damage_rect; |
596 if (!frame->has_no_damage) { | 591 if (!frame->has_no_damage) { |
597 damage_rect = frame->render_passes.back()->damage_rect; | 592 damage_rect = frame->render_passes.back()->damage_rect; |
598 } else { | 593 } else { |
599 // If there is no damage, then we have no render passes to send. | 594 // If there is no damage, then we have no render passes to send. |
600 EXPECT_TRUE(frame->render_passes.empty()); | 595 EXPECT_TRUE(frame->render_passes.empty()); |
601 } | 596 } |
602 | 597 |
603 switch (host_impl->active_tree()->source_frame_number()) { | 598 switch (host_impl->active_tree()->source_frame_number()) { |
604 case 0: | 599 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()); | 657 EXPECT_EQ(gfx::Rect(3, 3, 6, 1).ToString(), damage_rect.ToString()); |
663 EndTest(); | 658 EndTest(); |
664 break; | 659 break; |
665 } | 660 } |
666 | 661 |
667 return draw_result; | 662 return draw_result; |
668 } | 663 } |
669 | 664 |
670 protected: | 665 protected: |
671 scoped_refptr<DelegatedRendererLayer> delegated_copy_; | 666 scoped_refptr<DelegatedRendererLayer> delegated_copy_; |
672 bool first_draw_for_source_frame_; | |
673 }; | 667 }; |
674 | 668 |
675 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDelegatedTestLayerUsesFrameDamage); | 669 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDelegatedTestLayerUsesFrameDamage); |
676 | 670 |
677 class LayerTreeHostDelegatedTestMergeResources | 671 class LayerTreeHostDelegatedTestMergeResources |
678 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer { | 672 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer { |
679 public: | 673 public: |
680 void BeginTest() override { | 674 void BeginTest() override { |
681 // Push two frames to the delegated renderer layer with no commit between. | 675 // Push two frames to the delegated renderer layer with no commit between. |
682 | 676 |
(...skipping 1486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2169 } | 2163 } |
2170 | 2164 |
2171 scoped_refptr<DelegatedRendererLayer> delegated_thief_; | 2165 scoped_refptr<DelegatedRendererLayer> delegated_thief_; |
2172 }; | 2166 }; |
2173 | 2167 |
2174 SINGLE_AND_MULTI_THREAD_TEST_F( | 2168 SINGLE_AND_MULTI_THREAD_TEST_F( |
2175 LayerTreeHostDelegatedTestRemoveAndChangeResources); | 2169 LayerTreeHostDelegatedTestRemoveAndChangeResources); |
2176 | 2170 |
2177 } // namespace | 2171 } // namespace |
2178 } // namespace cc | 2172 } // namespace cc |
OLD | NEW |