| 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 5067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5078 } | 5078 } |
| 5079 | 5079 |
| 5080 virtual void AfterTest() OVERRIDE {} | 5080 virtual void AfterTest() OVERRIDE {} |
| 5081 | 5081 |
| 5082 FakeContentLayerClient client_; | 5082 FakeContentLayerClient client_; |
| 5083 scoped_ptr<FakeScopedUIResource> ui_resource_; | 5083 scoped_ptr<FakeScopedUIResource> ui_resource_; |
| 5084 }; | 5084 }; |
| 5085 | 5085 |
| 5086 MULTI_THREAD_TEST_F(LayerTreeHostTestHighResRequiredAfterEvictingUIResources); | 5086 MULTI_THREAD_TEST_F(LayerTreeHostTestHighResRequiredAfterEvictingUIResources); |
| 5087 | 5087 |
| 5088 class LayerTreeHostTestHybridGpuRasterizationSetting |
| 5089 : public LayerTreeHostTest { |
| 5090 protected: |
| 5091 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
| 5092 settings->impl_side_painting = true; |
| 5093 settings->gpu_rasterization_state = |
| 5094 LayerTreeSettings::HybridGpuRasterization; |
| 5095 } |
| 5096 |
| 5097 virtual void SetupTree() OVERRIDE { |
| 5098 LayerTreeHostTest::SetupTree(); |
| 5099 |
| 5100 scoped_refptr<Layer> parent = PictureLayer::Create(&client_); |
| 5101 parent->SetBounds(gfx::Size(10, 10)); |
| 5102 layer_tree_host()->root_layer()->AddChild(parent); |
| 5103 |
| 5104 scoped_refptr<Layer> child = PictureLayer::Create(&client_); |
| 5105 child->SetBounds(gfx::Size(10, 10)); |
| 5106 parent->AddChild(child); |
| 5107 |
| 5108 parent->SetHasGpuRasterizationHint(true); |
| 5109 } |
| 5110 |
| 5111 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
| 5112 |
| 5113 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 5114 LayerImpl* root = host_impl->pending_tree()->root_layer(); |
| 5115 PictureLayerImpl* parent = |
| 5116 static_cast<PictureLayerImpl*>(root->children()[0]); |
| 5117 PictureLayerImpl* child = |
| 5118 static_cast<PictureLayerImpl*>(parent->children()[0]); |
| 5119 |
| 5120 // Only layers with a GPU rasterization hint should use GPU rasterization. |
| 5121 EXPECT_TRUE(parent->ShouldUseGpuRasterization()); |
| 5122 EXPECT_FALSE(child->ShouldUseGpuRasterization()); |
| 5123 } |
| 5124 |
| 5125 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 5126 LayerImpl* root = host_impl->active_tree()->root_layer(); |
| 5127 PictureLayerImpl* parent = |
| 5128 static_cast<PictureLayerImpl*>(root->children()[0]); |
| 5129 PictureLayerImpl* child = |
| 5130 static_cast<PictureLayerImpl*>(parent->children()[0]); |
| 5131 |
| 5132 // Only layers with a GPU rasterization hint should use GPU rasterization. |
| 5133 EXPECT_TRUE(parent->ShouldUseGpuRasterization()); |
| 5134 EXPECT_FALSE(child->ShouldUseGpuRasterization()); |
| 5135 EndTest(); |
| 5136 } |
| 5137 |
| 5138 virtual void AfterTest() OVERRIDE {} |
| 5139 |
| 5140 FakeContentLayerClient client_; |
| 5141 }; |
| 5142 |
| 5143 MULTI_THREAD_TEST_F( |
| 5144 LayerTreeHostTestHybridGpuRasterizationSetting); |
| 5145 |
| 5146 class LayerTreeHostTestUniversalGpuRasterizationSetting |
| 5147 : public LayerTreeHostTest { |
| 5148 protected: |
| 5149 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
| 5150 settings->impl_side_painting = true; |
| 5151 settings->gpu_rasterization_state = |
| 5152 LayerTreeSettings::UniversalGpuRasterization; |
| 5153 } |
| 5154 |
| 5155 virtual void SetupTree() OVERRIDE { |
| 5156 LayerTreeHostTest::SetupTree(); |
| 5157 |
| 5158 scoped_refptr<Layer> parent = PictureLayer::Create(&client_); |
| 5159 parent->SetBounds(gfx::Size(10, 10)); |
| 5160 layer_tree_host()->root_layer()->AddChild(parent); |
| 5161 |
| 5162 scoped_refptr<Layer> child = PictureLayer::Create(&client_); |
| 5163 child->SetBounds(gfx::Size(10, 10)); |
| 5164 parent->AddChild(child); |
| 5165 |
| 5166 parent->SetHasGpuRasterizationHint(true); |
| 5167 } |
| 5168 |
| 5169 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
| 5170 |
| 5171 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 5172 LayerImpl* root = host_impl->pending_tree()->root_layer(); |
| 5173 PictureLayerImpl* parent = |
| 5174 static_cast<PictureLayerImpl*>(root->children()[0]); |
| 5175 PictureLayerImpl* child = |
| 5176 static_cast<PictureLayerImpl*>(parent->children()[0]); |
| 5177 |
| 5178 // All layers should use GPU rasterization, regardless of whether a GPU |
| 5179 // rasterization hint has been set. |
| 5180 EXPECT_TRUE(parent->ShouldUseGpuRasterization()); |
| 5181 EXPECT_TRUE(child->ShouldUseGpuRasterization()); |
| 5182 } |
| 5183 |
| 5184 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 5185 LayerImpl* root = host_impl->active_tree()->root_layer(); |
| 5186 PictureLayerImpl* parent = |
| 5187 static_cast<PictureLayerImpl*>(root->children()[0]); |
| 5188 PictureLayerImpl* child = |
| 5189 static_cast<PictureLayerImpl*>(parent->children()[0]); |
| 5190 |
| 5191 // All layers should use GPU rasterization, regardless of whether a GPU |
| 5192 // rasterization hint has been set. |
| 5193 EXPECT_TRUE(parent->ShouldUseGpuRasterization()); |
| 5194 EXPECT_TRUE(child->ShouldUseGpuRasterization()); |
| 5195 EndTest(); |
| 5196 } |
| 5197 |
| 5198 virtual void AfterTest() OVERRIDE {} |
| 5199 |
| 5200 FakeContentLayerClient client_; |
| 5201 }; |
| 5202 |
| 5203 MULTI_THREAD_TEST_F( |
| 5204 LayerTreeHostTestUniversalGpuRasterizationSetting); |
| 5205 |
| 5088 } // namespace cc | 5206 } // namespace cc |
| OLD | NEW |