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 5094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5105 } | 5105 } |
5106 virtual void AfterTest() OVERRIDE {} | 5106 virtual void AfterTest() OVERRIDE {} |
5107 | 5107 |
5108 private: | 5108 private: |
5109 FakeContentLayerClient client_; | 5109 FakeContentLayerClient client_; |
5110 scoped_refptr<FakeContentLayer> root_layer_; | 5110 scoped_refptr<FakeContentLayer> root_layer_; |
5111 }; | 5111 }; |
5112 | 5112 |
5113 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoQuadsForEmptyLayer); | 5113 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoQuadsForEmptyLayer); |
5114 | 5114 |
| 5115 class LayerTreeHostTestNoQuadsForZeroOpacityLayer : public LayerTreeHostTest { |
| 5116 protected: |
| 5117 virtual void SetupTree() OVERRIDE { |
| 5118 LayerTreeHostTest::SetupTree(); |
| 5119 parent_layer_ = FakeContentLayer::Create(&client_); |
| 5120 parent_layer_->SetBounds(gfx::Size(40, 40)); |
| 5121 parent_layer_->SetOpacity(0.f); |
| 5122 parent_layer_->SetIsDrawable(true); |
| 5123 |
| 5124 layer_tree_host()->SetRootLayer(SolidColorLayer::Create()); |
| 5125 layer_tree_host()->root_layer()->AddChild(parent_layer_); |
| 5126 |
| 5127 wheel_handler_ = FakeContentLayer::Create(NULL); |
| 5128 wheel_handler_->SetBounds(gfx::Size(10, 10)); |
| 5129 wheel_handler_->SetHaveWheelEventHandlers(true); |
| 5130 wheel_handler_->SetIsDrawable(true); |
| 5131 parent_layer_->AddChild(wheel_handler_); |
| 5132 |
| 5133 sibling_ = FakeContentLayer::Create(NULL); |
| 5134 sibling_->SetBounds(gfx::Size(30, 30)); |
| 5135 sibling_->SetPosition(gfx::Point(10, 0)); |
| 5136 sibling_->SetIsDrawable(true); |
| 5137 parent_layer_->AddChild(sibling_); |
| 5138 |
| 5139 LayerTreeHostTest::SetupTree(); |
| 5140 } |
| 5141 |
| 5142 virtual void BeginTest() OVERRIDE { |
| 5143 PostSetNeedsCommitToMainThread(); |
| 5144 } |
| 5145 |
| 5146 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
| 5147 LayerImpl* root = impl->RootLayer(); |
| 5148 ASSERT_EQ(1u, root->children().size()); |
| 5149 |
| 5150 FakeContentLayerImpl* parent = |
| 5151 static_cast<FakeContentLayerImpl*>(root->children()[0]); |
| 5152 EXPECT_TRUE(parent->DrawsContent()); |
| 5153 EXPECT_FALSE(parent->opacity()); |
| 5154 EXPECT_FALSE(parent->draw_opacity()); |
| 5155 EXPECT_EQ(0u, parent->append_quads_count()); |
| 5156 ASSERT_EQ(2u, parent->children().size()); |
| 5157 |
| 5158 FakeContentLayerImpl* child = |
| 5159 static_cast<FakeContentLayerImpl*>(parent->children()[0]); |
| 5160 EXPECT_TRUE(child->opacity()); |
| 5161 EXPECT_FALSE(child->draw_opacity()); |
| 5162 EXPECT_EQ(0u, child->append_quads_count()); |
| 5163 |
| 5164 child = static_cast<FakeContentLayerImpl*>(parent->children()[1]); |
| 5165 EXPECT_TRUE(child->opacity()); |
| 5166 EXPECT_FALSE(child->draw_opacity()); |
| 5167 EXPECT_EQ(0u, child->append_quads_count()); |
| 5168 } |
| 5169 |
| 5170 virtual void DidCommit() OVERRIDE { |
| 5171 // The layer is transparent, so it should not be updated. |
| 5172 EXPECT_EQ(0u, parent_layer_->update_count()); |
| 5173 ASSERT_EQ(2u, parent_layer_->children().size()); |
| 5174 |
| 5175 EXPECT_EQ(0u, wheel_handler_->update_count()); |
| 5176 EXPECT_EQ(0u, sibling_->update_count()); |
| 5177 |
| 5178 EndTest(); |
| 5179 } |
| 5180 virtual void AfterTest() OVERRIDE {} |
| 5181 |
| 5182 private: |
| 5183 FakeContentLayerClient client_; |
| 5184 scoped_refptr<FakeContentLayer> parent_layer_; |
| 5185 scoped_refptr<FakeContentLayer> wheel_handler_; |
| 5186 scoped_refptr<FakeContentLayer> sibling_; |
| 5187 }; |
| 5188 |
| 5189 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoQuadsForZeroOpacityLayer); |
5115 | 5190 |
5116 } // namespace | 5191 } // namespace |
5117 | 5192 |
5118 class LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface | 5193 class LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface |
5119 : public LayerTreeHostTest { | 5194 : public LayerTreeHostTest { |
5120 protected: | 5195 protected: |
5121 LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface() | 5196 LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface() |
5122 : first_output_surface_memory_limit_(4321234), | 5197 : first_output_surface_memory_limit_(4321234), |
5123 second_output_surface_memory_limit_(1234321) {} | 5198 second_output_surface_memory_limit_(1234321) {} |
5124 | 5199 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5196 size_t second_output_surface_memory_limit_; | 5271 size_t second_output_surface_memory_limit_; |
5197 FakeContentLayerClient client_; | 5272 FakeContentLayerClient client_; |
5198 scoped_refptr<FakeContentLayer> root_; | 5273 scoped_refptr<FakeContentLayer> root_; |
5199 }; | 5274 }; |
5200 | 5275 |
5201 // No output to copy for delegated renderers. | 5276 // No output to copy for delegated renderers. |
5202 SINGLE_AND_MULTI_THREAD_TEST_F( | 5277 SINGLE_AND_MULTI_THREAD_TEST_F( |
5203 LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface); | 5278 LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface); |
5204 | 5279 |
5205 } // namespace cc | 5280 } // namespace cc |
OLD | NEW |