Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: cc/trees/layer_tree_host_unittest.cc

Issue 181063022: cc: Trigger GPU rasterization based on a per-layer hint (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use a single switch with string values Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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<Layer> 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(
5142 LayerTreeHostTestHybridRasterizationSetting);
5143
5144 class LayerTreeHostTestGpuRasterizationSetting : public LayerTreeHostTest {
5145 protected:
5146 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE {
5147 settings->impl_side_painting = true;
5148 settings->rasterization_site = LayerTreeSettings::GpuRasterization;
5149 }
5150
5151 virtual void SetupTree() OVERRIDE {
5152 LayerTreeHostTest::SetupTree();
5153
5154 scoped_refptr<Layer> parent = PictureLayer::Create(&client_);
5155 parent->SetBounds(gfx::Size(10, 10));
5156 layer_tree_host()->root_layer()->AddChild(parent);
5157
5158 scoped_refptr<Layer> child = PictureLayer::Create(&client_);
5159 child->SetBounds(gfx::Size(10, 10));
5160 parent->AddChild(child);
5161
5162 parent->SetHasGpuRasterizationHint(true);
5163 }
5164
5165 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
5166
5167 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
5168 LayerImpl* root = host_impl->pending_tree()->root_layer();
5169 PictureLayerImpl* parent =
5170 static_cast<PictureLayerImpl*>(root->children()[0]);
5171 PictureLayerImpl* child =
5172 static_cast<PictureLayerImpl*>(parent->children()[0]);
5173
5174 // All layers should use GPU rasterization, regardless of whether a GPU
5175 // rasterization hint has been set.
5176 EXPECT_TRUE(parent->ShouldUseGpuRasterization());
5177 EXPECT_TRUE(child->ShouldUseGpuRasterization());
5178 }
5179
5180 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
5181 LayerImpl* root = host_impl->active_tree()->root_layer();
5182 PictureLayerImpl* parent =
5183 static_cast<PictureLayerImpl*>(root->children()[0]);
5184 PictureLayerImpl* child =
5185 static_cast<PictureLayerImpl*>(parent->children()[0]);
5186
5187 // All layers should use GPU rasterization, regardless of whether a GPU
5188 // rasterization hint has been set.
5189 EXPECT_TRUE(parent->ShouldUseGpuRasterization());
5190 EXPECT_TRUE(child->ShouldUseGpuRasterization());
5191 EndTest();
5192 }
5193
5194 virtual void AfterTest() OVERRIDE {}
5195
5196 FakeContentLayerClient client_;
5197 };
5198
5199 MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationSetting);
5200
5088 } // namespace cc 5201 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698