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

Unified 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, 10 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 side-by-side diff with in-line comments
Download patch
Index: cc/trees/layer_tree_host_unittest.cc
diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc
index 82129936c89c1c01bbea7cfd32bbb997df53e825..2a49913c117bff3629c82f6afa67cf5ccf5c9be2 100644
--- a/cc/trees/layer_tree_host_unittest.cc
+++ b/cc/trees/layer_tree_host_unittest.cc
@@ -5085,4 +5085,117 @@ class LayerTreeHostTestHighResRequiredAfterEvictingUIResources
MULTI_THREAD_TEST_F(LayerTreeHostTestHighResRequiredAfterEvictingUIResources);
+class LayerTreeHostTestHybridRasterizationSetting : public LayerTreeHostTest {
+ protected:
+ virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE {
+ settings->impl_side_painting = true;
+ settings->rasterization_site = LayerTreeSettings::HybridRasterization;
+ }
+
+ virtual void SetupTree() OVERRIDE {
+ LayerTreeHostTest::SetupTree();
+
+ scoped_refptr<Layer> parent = PictureLayer::Create(&client_);
+ parent->SetBounds(gfx::Size(10, 10));
+ layer_tree_host()->root_layer()->AddChild(parent);
+
+ scoped_refptr<Layer> child = PictureLayer::Create(&client_);
+ child->SetBounds(gfx::Size(10, 10));
+ parent->AddChild(child);
+
+ parent->SetHasGpuRasterizationHint(true);
+ }
+
+ virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
+
+ virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
+ LayerImpl* root = host_impl->pending_tree()->root_layer();
+ PictureLayerImpl* parent =
+ static_cast<PictureLayerImpl*>(root->children()[0]);
+ PictureLayerImpl* child =
+ static_cast<PictureLayerImpl*>(parent->children()[0]);
+
+ // Only layers with a GPU rasterization hint should use GPU rasterization.
+ EXPECT_TRUE(parent->ShouldUseGpuRasterization());
+ EXPECT_FALSE(child->ShouldUseGpuRasterization());
+ }
+
+ virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
+ LayerImpl* root = host_impl->active_tree()->root_layer();
+ PictureLayerImpl* parent =
+ static_cast<PictureLayerImpl*>(root->children()[0]);
+ PictureLayerImpl* child =
+ static_cast<PictureLayerImpl*>(parent->children()[0]);
+
+ // Only layers with a GPU rasterization hint should use GPU rasterization.
+ EXPECT_TRUE(parent->ShouldUseGpuRasterization());
+ EXPECT_FALSE(child->ShouldUseGpuRasterization());
+ EndTest();
+ }
+
+ virtual void AfterTest() OVERRIDE {}
+
+ FakeContentLayerClient client_;
+};
+
+MULTI_THREAD_TEST_F(
+ LayerTreeHostTestHybridRasterizationSetting);
+
+class LayerTreeHostTestGpuRasterizationSetting : public LayerTreeHostTest {
+ protected:
+ virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE {
+ settings->impl_side_painting = true;
+ settings->rasterization_site = LayerTreeSettings::GpuRasterization;
+ }
+
+ virtual void SetupTree() OVERRIDE {
+ LayerTreeHostTest::SetupTree();
+
+ scoped_refptr<Layer> parent = PictureLayer::Create(&client_);
+ parent->SetBounds(gfx::Size(10, 10));
+ layer_tree_host()->root_layer()->AddChild(parent);
+
+ scoped_refptr<Layer> child = PictureLayer::Create(&client_);
+ child->SetBounds(gfx::Size(10, 10));
+ parent->AddChild(child);
+
+ parent->SetHasGpuRasterizationHint(true);
+ }
+
+ virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
+
+ virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
+ LayerImpl* root = host_impl->pending_tree()->root_layer();
+ PictureLayerImpl* parent =
+ static_cast<PictureLayerImpl*>(root->children()[0]);
+ PictureLayerImpl* child =
+ static_cast<PictureLayerImpl*>(parent->children()[0]);
+
+ // All layers should use GPU rasterization, regardless of whether a GPU
+ // rasterization hint has been set.
+ EXPECT_TRUE(parent->ShouldUseGpuRasterization());
+ EXPECT_TRUE(child->ShouldUseGpuRasterization());
+ }
+
+ virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
+ LayerImpl* root = host_impl->active_tree()->root_layer();
+ PictureLayerImpl* parent =
+ static_cast<PictureLayerImpl*>(root->children()[0]);
+ PictureLayerImpl* child =
+ static_cast<PictureLayerImpl*>(parent->children()[0]);
+
+ // All layers should use GPU rasterization, regardless of whether a GPU
+ // rasterization hint has been set.
+ EXPECT_TRUE(parent->ShouldUseGpuRasterization());
+ EXPECT_TRUE(child->ShouldUseGpuRasterization());
+ EndTest();
+ }
+
+ virtual void AfterTest() OVERRIDE {}
+
+ FakeContentLayerClient client_;
+};
+
+MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationSetting);
+
} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698