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