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_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 6696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6707 layer1->SetExpectation(false, false); | 6707 layer1->SetExpectation(false, false); |
6708 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6708 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6709 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 6709 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
6710 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 6710 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
6711 host_impl_->DrawLayers(&frame); | 6711 host_impl_->DrawLayers(&frame); |
6712 host_impl_->SwapBuffers(frame); | 6712 host_impl_->SwapBuffers(frame); |
6713 EXPECT_TRUE(layer1->quads_appended()); | 6713 EXPECT_TRUE(layer1->quads_appended()); |
6714 host_impl_->DidDrawAllLayers(frame); | 6714 host_impl_->DidDrawAllLayers(frame); |
6715 } | 6715 } |
6716 | 6716 |
| 6717 static bool MayContainVideoBitSetOnFrameData(LayerTreeHostImpl* host_impl) { |
| 6718 host_impl->active_tree()->BuildPropertyTreesForTesting(); |
| 6719 LayerTreeHostImpl::FrameData frame; |
| 6720 EXPECT_EQ(DRAW_SUCCESS, host_impl->PrepareToDraw(&frame)); |
| 6721 host_impl->DrawLayers(&frame); |
| 6722 host_impl->SwapBuffers(frame); |
| 6723 host_impl->DidDrawAllLayers(frame); |
| 6724 return frame.may_contain_video; |
| 6725 } |
| 6726 |
| 6727 TEST_F(LayerTreeHostImplTest, MayContainVideo) { |
| 6728 gfx::Size big_size(1000, 1000); |
| 6729 host_impl_->SetViewportSize(big_size); |
| 6730 |
| 6731 int layer_id = 1; |
| 6732 host_impl_->active_tree()->SetRootLayerForTesting( |
| 6733 DidDrawCheckLayer::Create(host_impl_->active_tree(), layer_id++)); |
| 6734 DidDrawCheckLayer* root = |
| 6735 static_cast<DidDrawCheckLayer*>(*host_impl_->active_tree()->begin()); |
| 6736 |
| 6737 root->test_properties()->AddChild( |
| 6738 DidDrawCheckLayer::Create(host_impl_->active_tree(), layer_id++)); |
| 6739 DidDrawCheckLayer* video_layer = |
| 6740 static_cast<DidDrawCheckLayer*>(root->test_properties()->children.back()); |
| 6741 video_layer->set_may_contain_video(true); |
| 6742 EXPECT_TRUE(MayContainVideoBitSetOnFrameData(host_impl_.get())); |
| 6743 |
| 6744 // Test with the video layer occluded. |
| 6745 root->test_properties()->AddChild( |
| 6746 DidDrawCheckLayer::Create(host_impl_->active_tree(), layer_id++)); |
| 6747 DidDrawCheckLayer* large_layer = |
| 6748 static_cast<DidDrawCheckLayer*>(root->test_properties()->children.back()); |
| 6749 large_layer->SetBounds(big_size); |
| 6750 large_layer->SetContentsOpaque(true); |
| 6751 EXPECT_FALSE(MayContainVideoBitSetOnFrameData(host_impl_.get())); |
| 6752 |
| 6753 // Remove the large layer. |
| 6754 root->test_properties()->RemoveChild(large_layer); |
| 6755 EXPECT_TRUE(MayContainVideoBitSetOnFrameData(host_impl_.get())); |
| 6756 |
| 6757 // Move the video layer so it goes beyond the root. |
| 6758 video_layer->SetPosition(gfx::PointF(100.f, 100.f)); |
| 6759 EXPECT_FALSE(MayContainVideoBitSetOnFrameData(host_impl_.get())); |
| 6760 |
| 6761 video_layer->SetPosition(gfx::PointF(0.f, 0.f)); |
| 6762 video_layer->NoteLayerPropertyChanged(); |
| 6763 EXPECT_TRUE(MayContainVideoBitSetOnFrameData(host_impl_.get())); |
| 6764 } |
| 6765 |
6717 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest { | 6766 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest { |
6718 protected: | 6767 protected: |
6719 LayerTreeHostImplViewportCoveredTest() : | 6768 LayerTreeHostImplViewportCoveredTest() : |
6720 gutter_quad_material_(DrawQuad::SOLID_COLOR), | 6769 gutter_quad_material_(DrawQuad::SOLID_COLOR), |
6721 child_(NULL), | 6770 child_(NULL), |
6722 did_activate_pending_tree_(false) {} | 6771 did_activate_pending_tree_(false) {} |
6723 | 6772 |
6724 std::unique_ptr<OutputSurface> CreateFakeOutputSurface(bool software) { | 6773 std::unique_ptr<OutputSurface> CreateFakeOutputSurface(bool software) { |
6725 if (software) | 6774 if (software) |
6726 return FakeOutputSurface::CreateDelegatingSoftware(); | 6775 return FakeOutputSurface::CreateDelegatingSoftware(); |
(...skipping 4090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10817 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); | 10866 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); |
10818 | 10867 |
10819 // Re-initialize with a software output surface. | 10868 // Re-initialize with a software output surface. |
10820 output_surface_ = FakeOutputSurface::CreateDelegatingSoftware(); | 10869 output_surface_ = FakeOutputSurface::CreateDelegatingSoftware(); |
10821 host_impl_->InitializeRenderer(output_surface_.get()); | 10870 host_impl_->InitializeRenderer(output_surface_.get()); |
10822 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 10871 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
10823 } | 10872 } |
10824 | 10873 |
10825 } // namespace | 10874 } // namespace |
10826 } // namespace cc | 10875 } // namespace cc |
OLD | NEW |