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

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

Issue 21555004: Scrollbar Layer revert (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 4 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
« no previous file with comments | « cc/test/fake_scrollbar_layer.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 <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 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after
1101 1101
1102 private: 1102 private:
1103 FakeContentLayerClient client_; 1103 FakeContentLayerClient client_;
1104 scoped_refptr<NoScaleContentLayer> root_layer_; 1104 scoped_refptr<NoScaleContentLayer> root_layer_;
1105 scoped_refptr<ContentLayer> child_layer_; 1105 scoped_refptr<ContentLayer> child_layer_;
1106 }; 1106 };
1107 1107
1108 MULTI_THREAD_TEST_F(LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers); 1108 MULTI_THREAD_TEST_F(LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers);
1109 1109
1110 // Verify atomicity of commits and reuse of textures. 1110 // Verify atomicity of commits and reuse of textures.
1111 class LayerTreeHostTestDirectRendererAtomicCommit : public LayerTreeHostTest { 1111 class LayerTreeHostTestAtomicCommit : public LayerTreeHostTest {
1112 public: 1112 public:
1113 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { 1113 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE {
1114 // Make sure partial texture updates are turned off. 1114 // Make sure partial texture updates are turned off.
1115 settings->max_partial_texture_updates = 0; 1115 settings->max_partial_texture_updates = 0;
1116 // Linear fade animator prevents scrollbars from drawing immediately. 1116 // Linear fade animator prevents scrollbars from drawing immediately.
1117 settings->use_linear_fade_scrollbar_animator = false; 1117 settings->use_linear_fade_scrollbar_animator = false;
1118 } 1118 }
1119 1119
1120 virtual void SetupTree() OVERRIDE { 1120 virtual void SetupTree() OVERRIDE {
1121 layer_ = FakeContentLayer::Create(&client_); 1121 layer_ = FakeContentLayer::Create(&client_);
(...skipping 30 matching lines...) Expand all
1152 // Number of textures used for commit should be one for each layer. 1152 // Number of textures used for commit should be one for each layer.
1153 EXPECT_EQ(2u, context->NumUsedTextures()); 1153 EXPECT_EQ(2u, context->NumUsedTextures());
1154 // Verify that used texture is correct. 1154 // Verify that used texture is correct.
1155 EXPECT_TRUE(context->UsedTexture(context->TextureAt(0))); 1155 EXPECT_TRUE(context->UsedTexture(context->TextureAt(0)));
1156 EXPECT_TRUE(context->UsedTexture(context->TextureAt(1))); 1156 EXPECT_TRUE(context->UsedTexture(context->TextureAt(1)));
1157 1157
1158 context->ResetUsedTextures(); 1158 context->ResetUsedTextures();
1159 PostSetNeedsCommitToMainThread(); 1159 PostSetNeedsCommitToMainThread();
1160 break; 1160 break;
1161 case 1: 1161 case 1:
1162 // Number of textures should be one for scrollbar layer since it was 1162 // Number of textures should be doubled as the first textures
1163 // requested and deleted on the impl-thread, and double for the content 1163 // are used by impl thread and cannot by used for update.
1164 // layer since its first texture is used by impl thread and cannot by 1164 ASSERT_EQ(4u, context->NumTextures());
1165 // used for update. 1165 // Number of textures used for commit should still be
1166 ASSERT_EQ(3u, context->NumTextures()); 1166 // one for each layer.
1167 // Number of textures used for commit should be one for each layer.
1168 EXPECT_EQ(2u, context->NumUsedTextures()); 1167 EXPECT_EQ(2u, context->NumUsedTextures());
1169 // First textures should not have been used. 1168 // First textures should not have been used.
1170 EXPECT_FALSE(context->UsedTexture(context->TextureAt(0))); 1169 EXPECT_FALSE(context->UsedTexture(context->TextureAt(0)));
1171 EXPECT_TRUE(context->UsedTexture(context->TextureAt(1))); 1170 EXPECT_FALSE(context->UsedTexture(context->TextureAt(1)));
1172 // New textures should have been used. 1171 // New textures should have been used.
1173 EXPECT_TRUE(context->UsedTexture(context->TextureAt(2))); 1172 EXPECT_TRUE(context->UsedTexture(context->TextureAt(2)));
1173 EXPECT_TRUE(context->UsedTexture(context->TextureAt(3)));
1174
1174 context->ResetUsedTextures(); 1175 context->ResetUsedTextures();
1175 PostSetNeedsCommitToMainThread(); 1176 PostSetNeedsCommitToMainThread();
1176 break; 1177 break;
1177 case 2: 1178 case 2:
1178 EndTest(); 1179 EndTest();
1179 break; 1180 break;
1180 default: 1181 default:
1181 NOTREACHED(); 1182 NOTREACHED();
1182 break; 1183 break;
1183 } 1184 }
(...skipping 14 matching lines...) Expand all
1198 context->ResetUsedTextures(); 1199 context->ResetUsedTextures();
1199 } 1200 }
1200 1201
1201 virtual void Layout() OVERRIDE { 1202 virtual void Layout() OVERRIDE {
1202 layer_->SetNeedsDisplay(); 1203 layer_->SetNeedsDisplay();
1203 scrollbar_->SetNeedsDisplay(); 1204 scrollbar_->SetNeedsDisplay();
1204 } 1205 }
1205 1206
1206 virtual void AfterTest() OVERRIDE {} 1207 virtual void AfterTest() OVERRIDE {}
1207 1208
1208 protected: 1209 private:
1209 FakeContentLayerClient client_; 1210 FakeContentLayerClient client_;
1210 scoped_refptr<FakeContentLayer> layer_; 1211 scoped_refptr<FakeContentLayer> layer_;
1211 scoped_refptr<FakeScrollbarLayer> scrollbar_; 1212 scoped_refptr<FakeScrollbarLayer> scrollbar_;
1212 int drew_frame_; 1213 int drew_frame_;
1213 }; 1214 };
1214 1215
1215 MULTI_THREAD_DIRECT_RENDERER_TEST_F( 1216 MULTI_THREAD_TEST_F(LayerTreeHostTestAtomicCommit);
1216 LayerTreeHostTestDirectRendererAtomicCommit);
1217
1218 class LayerTreeHostTestDelegatingRendererAtomicCommit
1219 : public LayerTreeHostTestDirectRendererAtomicCommit {
1220 public:
1221 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE {
1222 ASSERT_EQ(0u, layer_tree_host()->settings().max_partial_texture_updates);
1223
1224 TestWebGraphicsContext3D* context = static_cast<TestWebGraphicsContext3D*>(
1225 impl->output_surface()->context3d());
1226
1227 switch (impl->active_tree()->source_frame_number()) {
1228 case 0:
1229 // Number of textures should be one for each layer
1230 ASSERT_EQ(2u, context->NumTextures());
1231 // Number of textures used for commit should be one for each layer.
1232 EXPECT_EQ(2u, context->NumUsedTextures());
1233 // Verify that used texture is correct.
1234 EXPECT_TRUE(context->UsedTexture(context->TextureAt(0)));
1235 EXPECT_TRUE(context->UsedTexture(context->TextureAt(1)));
1236 context->ResetUsedTextures();
1237 PostSetNeedsCommitToMainThread();
1238 break;
1239 case 1:
1240 // Number of textures should be doubled as the first context layer
1241 // texture is being used by the impl-thread and cannot be used for
1242 // update. The scrollbar behavior is different direct renderer because
1243 // UI resource deletion with delegating renderer occurs after tree
1244 // activation.
1245 ASSERT_EQ(4u, context->NumTextures());
1246 // Number of textures used for commit should still be
1247 // one for each layer.
1248 EXPECT_EQ(2u, context->NumUsedTextures());
1249 // First textures should not have been used.
1250 EXPECT_FALSE(context->UsedTexture(context->TextureAt(0)));
1251 EXPECT_FALSE(context->UsedTexture(context->TextureAt(1)));
1252 // New textures should have been used.
1253 EXPECT_TRUE(context->UsedTexture(context->TextureAt(2)));
1254 EXPECT_TRUE(context->UsedTexture(context->TextureAt(3)));
1255 context->ResetUsedTextures();
1256 PostSetNeedsCommitToMainThread();
1257 break;
1258 case 2:
1259 EndTest();
1260 break;
1261 default:
1262 NOTREACHED();
1263 break;
1264 }
1265 }
1266 };
1267
1268 MULTI_THREAD_DELEGATING_RENDERER_TEST_F(
1269 LayerTreeHostTestDelegatingRendererAtomicCommit);
1270 1217
1271 static void SetLayerPropertiesForTesting(Layer* layer, 1218 static void SetLayerPropertiesForTesting(Layer* layer,
1272 Layer* parent, 1219 Layer* parent,
1273 const gfx::Transform& transform, 1220 const gfx::Transform& transform,
1274 gfx::PointF anchor, 1221 gfx::PointF anchor,
1275 gfx::PointF position, 1222 gfx::PointF position,
1276 gfx::Size bounds, 1223 gfx::Size bounds,
1277 bool opaque) { 1224 bool opaque) {
1278 layer->RemoveAllChildren(); 1225 layer->RemoveAllChildren();
1279 if (parent) 1226 if (parent)
(...skipping 2789 matching lines...) Expand 10 before | Expand all | Expand 10 after
4069 TEST_F(LayerTreeHostTestTreeActivationCallback, DirectRenderer) { 4016 TEST_F(LayerTreeHostTestTreeActivationCallback, DirectRenderer) {
4070 RunTest(true, false, true); 4017 RunTest(true, false, true);
4071 } 4018 }
4072 4019
4073 TEST_F(LayerTreeHostTestTreeActivationCallback, DelegatingRenderer) { 4020 TEST_F(LayerTreeHostTestTreeActivationCallback, DelegatingRenderer) {
4074 RunTest(true, true, true); 4021 RunTest(true, true, true);
4075 } 4022 }
4076 4023
4077 } // namespace 4024 } // namespace
4078 } // namespace cc 4025 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/fake_scrollbar_layer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698