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 5071 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5082 : public LayerTreeHostTestOffscreenContext { | 5082 : public LayerTreeHostTestOffscreenContext { |
5083 protected: | 5083 protected: |
5084 LayerTreeHostTestOffscreenContext_WithContext() { with_context_ = true; } | 5084 LayerTreeHostTestOffscreenContext_WithContext() { with_context_ = true; } |
5085 }; | 5085 }; |
5086 | 5086 |
5087 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestOffscreenContext_WithContext); | 5087 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestOffscreenContext_WithContext); |
5088 | 5088 |
5089 class LayerTreeHostTestNoQuadsForEmptyLayer : public LayerTreeHostTest { | 5089 class LayerTreeHostTestNoQuadsForEmptyLayer : public LayerTreeHostTest { |
5090 protected: | 5090 protected: |
5091 virtual void SetupTree() OVERRIDE { | 5091 virtual void SetupTree() OVERRIDE { |
5092 LayerTreeHostTest::SetupTree(); | |
5093 root_layer_ = FakeContentLayer::Create(&client_); | 5092 root_layer_ = FakeContentLayer::Create(&client_); |
5094 root_layer_->SetBounds(gfx::Size(10, 10)); | 5093 root_layer_->SetBounds(gfx::Size(10, 10)); |
5095 root_layer_->SetIsDrawable(false); | 5094 root_layer_->SetIsDrawable(false); |
5096 root_layer_->SetHaveWheelEventHandlers(true); | 5095 root_layer_->SetHaveWheelEventHandlers(true); |
5097 layer_tree_host()->SetRootLayer(root_layer_); | 5096 layer_tree_host()->SetRootLayer(root_layer_); |
5098 LayerTreeHostTest::SetupTree(); | 5097 LayerTreeHostTest::SetupTree(); |
5099 } | 5098 } |
5100 | 5099 |
5101 virtual void BeginTest() OVERRIDE { | 5100 virtual void BeginTest() OVERRIDE { |
5102 PostSetNeedsCommitToMainThread(); | 5101 PostSetNeedsCommitToMainThread(); |
(...skipping 13 matching lines...) Expand all Loading... |
5116 } | 5115 } |
5117 virtual void AfterTest() OVERRIDE {} | 5116 virtual void AfterTest() OVERRIDE {} |
5118 | 5117 |
5119 private: | 5118 private: |
5120 FakeContentLayerClient client_; | 5119 FakeContentLayerClient client_; |
5121 scoped_refptr<FakeContentLayer> root_layer_; | 5120 scoped_refptr<FakeContentLayer> root_layer_; |
5122 }; | 5121 }; |
5123 | 5122 |
5124 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoQuadsForEmptyLayer); | 5123 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoQuadsForEmptyLayer); |
5125 | 5124 |
| 5125 class LayerTreeHostTestNoQuadsForZeroOpacityLayer : public LayerTreeHostTest { |
| 5126 protected: |
| 5127 virtual void SetupTree() OVERRIDE { |
| 5128 parent_layer_ = FakeContentLayer::Create(&parent_client_); |
| 5129 parent_layer_->SetBounds(gfx::Size(40, 40)); |
| 5130 parent_layer_->SetOpacity(0.f); |
| 5131 parent_layer_->SetIsDrawable(true); |
| 5132 |
| 5133 scoped_refptr<Layer> root = SolidColorLayer::Create(); |
| 5134 root->SetBounds(gfx::Size(60, 60)); |
| 5135 root->SetOpacity(1.f); |
| 5136 root->SetIsDrawable(true); |
| 5137 root->AddChild(parent_layer_); |
| 5138 layer_tree_host()->SetRootLayer(root); |
| 5139 |
| 5140 wheel_handler_ = FakeContentLayer::Create(NULL); |
| 5141 wheel_handler_->SetBounds(gfx::Size(10, 10)); |
| 5142 wheel_handler_->SetHaveWheelEventHandlers(true); |
| 5143 wheel_handler_->SetIsDrawable(true); |
| 5144 parent_layer_->AddChild(wheel_handler_); |
| 5145 |
| 5146 sibling_ = FakeContentLayer::Create(NULL); |
| 5147 sibling_->SetBounds(gfx::Size(30, 30)); |
| 5148 sibling_->SetPosition(gfx::Point(10, 0)); |
| 5149 sibling_->SetIsDrawable(true); |
| 5150 parent_layer_->AddChild(sibling_); |
| 5151 |
| 5152 LayerTreeHostTest::SetupTree(); |
| 5153 } |
| 5154 |
| 5155 virtual void BeginTest() OVERRIDE { |
| 5156 PostSetNeedsCommitToMainThread(); |
| 5157 } |
| 5158 |
| 5159 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
| 5160 LayerTreeHostTest::DrawLayersOnThread(impl); |
| 5161 FakeContentLayerImpl* parent = |
| 5162 static_cast<FakeContentLayerImpl*>(impl->RootLayer()->children()[0]); |
| 5163 EXPECT_TRUE(parent->DrawsContent()); |
| 5164 EXPECT_FALSE(parent->opacity()); |
| 5165 EXPECT_EQ(0u, parent->append_quads_count()); |
| 5166 ASSERT_EQ(2u, parent->children().size()); |
| 5167 |
| 5168 FakeContentLayerImpl* child = |
| 5169 static_cast<FakeContentLayerImpl*>(parent->children()[0]); |
| 5170 EXPECT_TRUE(child->opacity()); |
| 5171 EXPECT_EQ(0u, child->append_quads_count()); |
| 5172 |
| 5173 child = static_cast<FakeContentLayerImpl*>(parent->children()[1]); |
| 5174 EXPECT_TRUE(child->opacity()); |
| 5175 EXPECT_EQ(0u, child->append_quads_count()); |
| 5176 } |
| 5177 |
| 5178 virtual void DidCommit() OVERRIDE { |
| 5179 // The layer is transparent, so it should not be updated. |
| 5180 EXPECT_EQ(0u, parent_layer_->update_count()); |
| 5181 ASSERT_EQ(2u, parent_layer_->children().size()); |
| 5182 |
| 5183 EXPECT_EQ(0u, wheel_handler_->update_count()); |
| 5184 EXPECT_EQ(0u, sibling_->update_count()); |
| 5185 |
| 5186 EndTest(); |
| 5187 } |
| 5188 virtual void AfterTest() OVERRIDE {} |
| 5189 |
| 5190 private: |
| 5191 FakeContentLayerClient parent_client_; |
| 5192 scoped_refptr<FakeContentLayer> parent_layer_; |
| 5193 scoped_refptr<FakeContentLayer> wheel_handler_; |
| 5194 scoped_refptr<FakeContentLayer> sibling_; |
| 5195 }; |
| 5196 |
| 5197 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoQuadsForZeroOpacityLayer); |
5126 | 5198 |
5127 } // namespace | 5199 } // namespace |
5128 | 5200 |
5129 class LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface | 5201 class LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface |
5130 : public LayerTreeHostTest { | 5202 : public LayerTreeHostTest { |
5131 protected: | 5203 protected: |
5132 LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface() | 5204 LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface() |
5133 : first_output_surface_memory_limit_(4321234), | 5205 : first_output_surface_memory_limit_(4321234), |
5134 second_output_surface_memory_limit_(1234321) {} | 5206 second_output_surface_memory_limit_(1234321) {} |
5135 | 5207 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5205 size_t second_output_surface_memory_limit_; | 5277 size_t second_output_surface_memory_limit_; |
5206 FakeContentLayerClient client_; | 5278 FakeContentLayerClient client_; |
5207 scoped_refptr<FakeContentLayer> root_; | 5279 scoped_refptr<FakeContentLayer> root_; |
5208 }; | 5280 }; |
5209 | 5281 |
5210 // No output to copy for delegated renderers. | 5282 // No output to copy for delegated renderers. |
5211 SINGLE_AND_MULTI_THREAD_TEST_F( | 5283 SINGLE_AND_MULTI_THREAD_TEST_F( |
5212 LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface); | 5284 LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface); |
5213 | 5285 |
5214 } // namespace cc | 5286 } // namespace cc |
OLD | NEW |