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

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

Issue 2108033004: cc: Re-enable GPU rasterization after content veto. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
« cc/trees/layer_tree_host.cc ('K') | « cc/trees/layer_tree_host.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 4947 matching lines...) Expand 10 before | Expand all | Expand 10 after
4958 4958
4959 void BeginTest() override { 4959 void BeginTest() override {
4960 // Verify default value. 4960 // Verify default value.
4961 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger()); 4961 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger());
4962 4962
4963 // Gpu rasterization trigger is relevant. 4963 // Gpu rasterization trigger is relevant.
4964 layer_tree_host()->SetHasGpuRasterizationTrigger(true); 4964 layer_tree_host()->SetHasGpuRasterizationTrigger(true);
4965 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); 4965 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger());
4966 4966
4967 // Content-based veto is relevant as well. 4967 // Content-based veto is relevant as well.
4968 recording_source_->SetUnsuitableForGpuRasterization(); 4968 recording_source_->SetForceUnsuitableForGpuRasterization(true);
4969 4969
4970 // Veto will take effect when layers are updated. 4970 // Veto will take effect when layers are updated.
4971 // The results will be verified after commit is completed below. 4971 // The results will be verified after commit is completed below.
4972 // Since we are manually marking the source as unsuitable, 4972 // Since we are manually marking the source as unsuitable,
4973 // make sure that the layer gets a chance to update. 4973 // make sure that the layer gets a chance to update.
4974 layer_->SetNeedsDisplay(); 4974 layer_->SetNeedsDisplay();
4975 PostSetNeedsCommitToMainThread(); 4975 PostSetNeedsCommitToMainThread();
4976 } 4976 }
4977 4977
4978 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { 4978 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
(...skipping 16 matching lines...) Expand all
4995 4995
4996 void AfterTest() override {} 4996 void AfterTest() override {}
4997 4997
4998 FakeContentLayerClient layer_client_; 4998 FakeContentLayerClient layer_client_;
4999 FakePictureLayer* layer_; 4999 FakePictureLayer* layer_;
5000 FakeRecordingSource* recording_source_; 5000 FakeRecordingSource* recording_source_;
5001 }; 5001 };
5002 5002
5003 MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationEnabled); 5003 MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationEnabled);
5004 5004
5005 class LayerTreeHostTestGpuRasterizationReenabled : public LayerTreeHostTest {
5006 protected:
5007 void InitializeSettings(LayerTreeSettings* settings) override {
5008 EXPECT_FALSE(settings->gpu_rasterization_enabled);
5009 settings->gpu_rasterization_enabled = true;
5010 }
5011
5012 void SetupTree() override {
5013 LayerTreeHostTest::SetupTree();
5014
5015 std::unique_ptr<FakeRecordingSource> recording_source(
5016 new FakeRecordingSource);
5017 recording_source_ = recording_source.get();
5018
5019 scoped_refptr<FakePictureLayer> layer =
5020 FakePictureLayer::CreateWithRecordingSource(
5021 &layer_client_, std::move(recording_source));
5022 layer_ = layer.get();
5023 layer->SetBounds(gfx::Size(10, 10));
5024 layer->SetIsDrawable(true);
5025 layer_tree_host()->root_layer()->AddChild(layer);
5026 layer_client_.set_bounds(layer_->bounds());
5027 }
5028
5029 void BeginTest() override {
5030 // Verify default value.
5031 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger());
5032
5033 // Gpu rasterization trigger is relevant.
5034 layer_tree_host()->SetHasGpuRasterizationTrigger(true);
5035 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger());
5036
5037 // Content-based veto is relevant as well.
5038 recording_source_->SetForceUnsuitableForGpuRasterization(true);
5039
5040 // Veto will take effect when layers are updated.
5041 // The results will be verified after commit is completed below.
5042 // Since we are manually marking the source as unsuitable,
5043 // make sure that the layer gets a chance to update.
5044 layer_->SetNeedsDisplay();
5045 PostSetNeedsCommitToMainThread();
5046 }
5047
5048 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
5049 SCOPED_TRACE(base::StringPrintf("commit %d", num_commits_));
5050 if (expected_gpu_enabled_) {
5051 EXPECT_TRUE(host_impl->use_gpu_rasterization());
5052 } else {
5053 EXPECT_FALSE(host_impl->use_gpu_rasterization());
5054 }
5055
5056 ++num_commits_;
5057 // Every 10 commits, we will try to reenable the gpu rasterization until
5058 // (and we won't reenable after we've done it 5 times).
5059 //
5060 // So, the test expects on a multiple of 10 commits to have gpu enabled,
5061 // next commit we'll disable it and expect that it's disabled, and the next
5062 // commit we'll make content suitable again which should be picked up on the
5063 // next multiple of 10. At commit 60, we would've re-enabled it 5 times
5064 // already, so we expect it to remain disabled.
5065 if (num_commits_ >= 60) {
5066 expected_gpu_enabled_ = false;
5067 } else if ((num_commits_ % 10) == 0) {
5068 expected_gpu_enabled_ = true;
5069 } else if ((num_commits_ % 10) == 1) {
5070 recording_source_->SetForceUnsuitableForGpuRasterization(true);
5071 expected_gpu_enabled_ = false;
5072 } else if ((num_commits_ % 10) == 2) {
5073 recording_source_->SetForceUnsuitableForGpuRasterization(false);
5074 }
5075
5076 PostSetNeedsCommitToMainThread();
5077 if (num_commits_ > 80)
5078 EndTest();
5079 }
5080
5081 void AfterTest() override {}
5082
5083 FakeContentLayerClient layer_client_;
5084 FakePictureLayer* layer_;
5085 FakeRecordingSource* recording_source_;
5086 int num_commits_ = 0;
5087 bool expected_gpu_enabled_ = false;
5088 };
5089
5090 MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationReenabled);
5091
5005 class LayerTreeHostTestGpuRasterizationForced : public LayerTreeHostTest { 5092 class LayerTreeHostTestGpuRasterizationForced : public LayerTreeHostTest {
5006 protected: 5093 protected:
5007 void InitializeSettings(LayerTreeSettings* settings) override { 5094 void InitializeSettings(LayerTreeSettings* settings) override {
5008 EXPECT_FALSE(settings->gpu_rasterization_forced); 5095 EXPECT_FALSE(settings->gpu_rasterization_forced);
5009 settings->gpu_rasterization_forced = true; 5096 settings->gpu_rasterization_forced = true;
5010 } 5097 }
5011 5098
5012 void SetupTree() override { 5099 void SetupTree() override {
5013 LayerTreeHostTest::SetupTree(); 5100 LayerTreeHostTest::SetupTree();
5014 5101
(...skipping 14 matching lines...) Expand all
5029 5116
5030 void BeginTest() override { 5117 void BeginTest() override {
5031 // Verify default value. 5118 // Verify default value.
5032 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger()); 5119 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger());
5033 5120
5034 // With gpu rasterization forced, gpu rasterization trigger is irrelevant. 5121 // With gpu rasterization forced, gpu rasterization trigger is irrelevant.
5035 layer_tree_host()->SetHasGpuRasterizationTrigger(true); 5122 layer_tree_host()->SetHasGpuRasterizationTrigger(true);
5036 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); 5123 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger());
5037 5124
5038 // Content-based veto is irrelevant as well. 5125 // Content-based veto is irrelevant as well.
5039 recording_source_->SetUnsuitableForGpuRasterization(); 5126 recording_source_->SetForceUnsuitableForGpuRasterization(true);
5040 5127
5041 // Veto will take effect when layers are updated. 5128 // Veto will take effect when layers are updated.
5042 // The results will be verified after commit is completed below. 5129 // The results will be verified after commit is completed below.
5043 // Since we are manually marking the source as unsuitable, 5130 // Since we are manually marking the source as unsuitable,
5044 // make sure that the layer gets a chance to update. 5131 // make sure that the layer gets a chance to update.
5045 layer_->SetNeedsDisplay(); 5132 layer_->SetNeedsDisplay();
5046 PostSetNeedsCommitToMainThread(); 5133 PostSetNeedsCommitToMainThread();
5047 } 5134 }
5048 5135
5049 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { 5136 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
(...skipping 1641 matching lines...) Expand 10 before | Expand all | Expand 10 after
6691 EndTest(); 6778 EndTest();
6692 } 6779 }
6693 6780
6694 void AfterTest() override {} 6781 void AfterTest() override {}
6695 }; 6782 };
6696 6783
6697 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPaintedDeviceScaleFactor); 6784 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPaintedDeviceScaleFactor);
6698 6785
6699 } // namespace 6786 } // namespace
6700 } // namespace cc 6787 } // namespace cc
OLDNEW
« cc/trees/layer_tree_host.cc ('K') | « cc/trees/layer_tree_host.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698