OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/trees/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 | 630 |
631 if (sfn == kReadbackReplacementSourceFrameNumber) | 631 if (sfn == kReadbackReplacementSourceFrameNumber) |
632 EndTest(); | 632 EndTest(); |
633 } | 633 } |
634 | 634 |
635 virtual void AfterTest() OVERRIDE {} | 635 virtual void AfterTest() OVERRIDE {} |
636 }; | 636 }; |
637 | 637 |
638 MULTI_THREAD_TEST_F(LayerTreeHostTestCompositeAndReadbackAfterForcedDraw); | 638 MULTI_THREAD_TEST_F(LayerTreeHostTestCompositeAndReadbackAfterForcedDraw); |
639 | 639 |
| 640 class LayerTreeHostTestSetNextCommitForcesRedraw : public LayerTreeHostTest { |
| 641 public: |
| 642 LayerTreeHostTestSetNextCommitForcesRedraw() |
| 643 : num_draws_(0), |
| 644 bounds_(50, 50), |
| 645 invalid_rect_(10, 10, 20, 20), |
| 646 root_layer_(ContentLayer::Create(&client_)) { |
| 647 } |
| 648 |
| 649 virtual void BeginTest() OVERRIDE { |
| 650 root_layer_->SetIsDrawable(true); |
| 651 root_layer_->SetBounds(bounds_); |
| 652 layer_tree_host()->SetRootLayer(root_layer_); |
| 653 layer_tree_host()->SetViewportSize(bounds_); |
| 654 PostSetNeedsCommitToMainThread(); |
| 655 } |
| 656 |
| 657 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 658 if (num_draws_ == 3 && host_impl->settings().impl_side_painting) |
| 659 host_impl->SetNeedsRedrawRect(invalid_rect_); |
| 660 } |
| 661 |
| 662 virtual bool PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
| 663 LayerTreeHostImpl::FrameData* frame_data, |
| 664 bool result) OVERRIDE { |
| 665 EXPECT_TRUE(result); |
| 666 |
| 667 gfx::RectF root_damage_rect; |
| 668 if (!frame_data->render_passes.empty()) |
| 669 root_damage_rect = frame_data->render_passes.back()->damage_rect; |
| 670 |
| 671 switch (num_draws_) { |
| 672 case 0: |
| 673 EXPECT_RECT_EQ(gfx::Rect(bounds_), root_damage_rect); |
| 674 break; |
| 675 case 1: |
| 676 case 2: |
| 677 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), root_damage_rect); |
| 678 break; |
| 679 case 3: |
| 680 EXPECT_RECT_EQ(invalid_rect_, root_damage_rect); |
| 681 break; |
| 682 case 4: |
| 683 EXPECT_RECT_EQ(gfx::Rect(bounds_), root_damage_rect); |
| 684 break; |
| 685 default: |
| 686 NOTREACHED(); |
| 687 } |
| 688 |
| 689 return result; |
| 690 } |
| 691 |
| 692 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 693 switch (num_draws_) { |
| 694 case 0: |
| 695 case 1: |
| 696 // Cycle through a couple of empty commits to ensure we're observing the |
| 697 // right behavior |
| 698 PostSetNeedsCommitToMainThread(); |
| 699 break; |
| 700 case 2: |
| 701 // Should force full frame damage on the next commit |
| 702 PostSetNextCommitForcesRedrawToMainThread(); |
| 703 PostSetNeedsCommitToMainThread(); |
| 704 if (host_impl->settings().impl_side_painting) |
| 705 host_impl->BlockNotifyReadyToActivateForTesting(true); |
| 706 else |
| 707 num_draws_++; |
| 708 break; |
| 709 case 3: |
| 710 host_impl->BlockNotifyReadyToActivateForTesting(false); |
| 711 break; |
| 712 default: |
| 713 EndTest(); |
| 714 break; |
| 715 } |
| 716 num_draws_++; |
| 717 } |
| 718 |
| 719 virtual void AfterTest() OVERRIDE { |
| 720 EXPECT_EQ(5, num_draws_); |
| 721 } |
| 722 |
| 723 private: |
| 724 int num_draws_; |
| 725 const gfx::Size bounds_; |
| 726 const gfx::Rect invalid_rect_; |
| 727 FakeContentLayerClient client_; |
| 728 scoped_refptr<ContentLayer> root_layer_; |
| 729 }; |
| 730 |
| 731 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSetNextCommitForcesRedraw); |
| 732 |
640 // If the layerTreeHost says it can't draw, Then we should not try to draw. | 733 // If the layerTreeHost says it can't draw, Then we should not try to draw. |
641 class LayerTreeHostTestCanDrawBlocksDrawing : public LayerTreeHostTest { | 734 class LayerTreeHostTestCanDrawBlocksDrawing : public LayerTreeHostTest { |
642 public: | 735 public: |
643 LayerTreeHostTestCanDrawBlocksDrawing() : num_commits_(0), done_(false) {} | 736 LayerTreeHostTestCanDrawBlocksDrawing() : num_commits_(0), done_(false) {} |
644 | 737 |
645 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 738 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
646 | 739 |
647 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 740 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
648 if (done_) | 741 if (done_) |
649 return; | 742 return; |
(...skipping 4369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5019 size_t second_output_surface_memory_limit_; | 5112 size_t second_output_surface_memory_limit_; |
5020 FakeContentLayerClient client_; | 5113 FakeContentLayerClient client_; |
5021 scoped_refptr<FakeContentLayer> root_; | 5114 scoped_refptr<FakeContentLayer> root_; |
5022 }; | 5115 }; |
5023 | 5116 |
5024 // No output to copy for delegated renderers. | 5117 // No output to copy for delegated renderers. |
5025 SINGLE_AND_MULTI_THREAD_TEST_F( | 5118 SINGLE_AND_MULTI_THREAD_TEST_F( |
5026 LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface); | 5119 LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface); |
5027 | 5120 |
5028 } // namespace cc | 5121 } // namespace cc |
OLD | NEW |