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

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

Issue 21917004: Change ScrollbarLayer to use UI resource (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and merge 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/trees/layer_tree_host_impl.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 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after
1104 1104
1105 private: 1105 private:
1106 FakeContentLayerClient client_; 1106 FakeContentLayerClient client_;
1107 scoped_refptr<NoScaleContentLayer> root_layer_; 1107 scoped_refptr<NoScaleContentLayer> root_layer_;
1108 scoped_refptr<ContentLayer> child_layer_; 1108 scoped_refptr<ContentLayer> child_layer_;
1109 }; 1109 };
1110 1110
1111 MULTI_THREAD_TEST_F(LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers); 1111 MULTI_THREAD_TEST_F(LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers);
1112 1112
1113 // Verify atomicity of commits and reuse of textures. 1113 // Verify atomicity of commits and reuse of textures.
1114 class LayerTreeHostTestAtomicCommit : public LayerTreeHostTest { 1114 class LayerTreeHostTestDirectRendererAtomicCommit : public LayerTreeHostTest {
1115 public: 1115 public:
1116 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { 1116 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE {
1117 // Make sure partial texture updates are turned off. 1117 // Make sure partial texture updates are turned off.
1118 settings->max_partial_texture_updates = 0; 1118 settings->max_partial_texture_updates = 0;
1119 // Linear fade animator prevents scrollbars from drawing immediately. 1119 // Linear fade animator prevents scrollbars from drawing immediately.
1120 settings->use_linear_fade_scrollbar_animator = false; 1120 settings->use_linear_fade_scrollbar_animator = false;
1121 } 1121 }
1122 1122
1123 virtual void SetupTree() OVERRIDE { 1123 virtual void SetupTree() OVERRIDE {
1124 layer_ = FakeContentLayer::Create(&client_); 1124 layer_ = FakeContentLayer::Create(&client_);
(...skipping 30 matching lines...) Expand all
1155 // Number of textures used for commit should be one for each layer. 1155 // Number of textures used for commit should be one for each layer.
1156 EXPECT_EQ(2u, context->NumUsedTextures()); 1156 EXPECT_EQ(2u, context->NumUsedTextures());
1157 // Verify that used texture is correct. 1157 // Verify that used texture is correct.
1158 EXPECT_TRUE(context->UsedTexture(context->TextureAt(0))); 1158 EXPECT_TRUE(context->UsedTexture(context->TextureAt(0)));
1159 EXPECT_TRUE(context->UsedTexture(context->TextureAt(1))); 1159 EXPECT_TRUE(context->UsedTexture(context->TextureAt(1)));
1160 1160
1161 context->ResetUsedTextures(); 1161 context->ResetUsedTextures();
1162 PostSetNeedsCommitToMainThread(); 1162 PostSetNeedsCommitToMainThread();
1163 break; 1163 break;
1164 case 1: 1164 case 1:
1165 // Number of textures should be doubled as the first textures 1165 // Number of textures should be one for scrollbar layer since it was
1166 // are used by impl thread and cannot by used for update. 1166 // requested and deleted on the impl-thread, and double for the content
1167 ASSERT_EQ(4u, context->NumTextures()); 1167 // layer since its first texture is used by impl thread and cannot by
1168 // Number of textures used for commit should still be 1168 // used for update.
1169 // one for each layer. 1169 ASSERT_EQ(3u, context->NumTextures());
1170 // Number of textures used for commit should be one for each layer.
1170 EXPECT_EQ(2u, context->NumUsedTextures()); 1171 EXPECT_EQ(2u, context->NumUsedTextures());
1171 // First textures should not have been used. 1172 // First textures should not have been used.
1172 EXPECT_FALSE(context->UsedTexture(context->TextureAt(0))); 1173 EXPECT_FALSE(context->UsedTexture(context->TextureAt(0)));
1173 EXPECT_FALSE(context->UsedTexture(context->TextureAt(1))); 1174 EXPECT_TRUE(context->UsedTexture(context->TextureAt(1)));
1174 // New textures should have been used. 1175 // New textures should have been used.
1175 EXPECT_TRUE(context->UsedTexture(context->TextureAt(2))); 1176 EXPECT_TRUE(context->UsedTexture(context->TextureAt(2)));
1176 EXPECT_TRUE(context->UsedTexture(context->TextureAt(3)));
1177
1178 context->ResetUsedTextures(); 1177 context->ResetUsedTextures();
1179 PostSetNeedsCommitToMainThread(); 1178 PostSetNeedsCommitToMainThread();
1180 break; 1179 break;
1181 case 2: 1180 case 2:
1182 EndTest(); 1181 EndTest();
1183 break; 1182 break;
1184 default: 1183 default:
1185 NOTREACHED(); 1184 NOTREACHED();
1186 break; 1185 break;
1187 } 1186 }
(...skipping 14 matching lines...) Expand all
1202 context->ResetUsedTextures(); 1201 context->ResetUsedTextures();
1203 } 1202 }
1204 1203
1205 virtual void Layout() OVERRIDE { 1204 virtual void Layout() OVERRIDE {
1206 layer_->SetNeedsDisplay(); 1205 layer_->SetNeedsDisplay();
1207 scrollbar_->SetNeedsDisplay(); 1206 scrollbar_->SetNeedsDisplay();
1208 } 1207 }
1209 1208
1210 virtual void AfterTest() OVERRIDE {} 1209 virtual void AfterTest() OVERRIDE {}
1211 1210
1212 private: 1211 protected:
1213 FakeContentLayerClient client_; 1212 FakeContentLayerClient client_;
1214 scoped_refptr<FakeContentLayer> layer_; 1213 scoped_refptr<FakeContentLayer> layer_;
1215 scoped_refptr<FakeScrollbarLayer> scrollbar_; 1214 scoped_refptr<FakeScrollbarLayer> scrollbar_;
1216 int drew_frame_; 1215 int drew_frame_;
1217 }; 1216 };
1218 1217
1219 MULTI_THREAD_TEST_F(LayerTreeHostTestAtomicCommit); 1218 MULTI_THREAD_DIRECT_RENDERER_TEST_F(
1219 LayerTreeHostTestDirectRendererAtomicCommit);
1220
1221 class LayerTreeHostTestDelegatingRendererAtomicCommit
1222 : public LayerTreeHostTestDirectRendererAtomicCommit {
1223 public:
1224 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE {
1225 ASSERT_EQ(0u, layer_tree_host()->settings().max_partial_texture_updates);
1226
1227 TestWebGraphicsContext3D* context = static_cast<TestWebGraphicsContext3D*>(
1228 impl->output_surface()->context3d());
1229
1230 switch (impl->active_tree()->source_frame_number()) {
1231 case 0:
1232 // Number of textures should be one for each layer
1233 ASSERT_EQ(2u, context->NumTextures());
1234 // Number of textures used for commit should be one for each layer.
1235 EXPECT_EQ(2u, context->NumUsedTextures());
1236 // Verify that used texture is correct.
1237 EXPECT_TRUE(context->UsedTexture(context->TextureAt(0)));
1238 EXPECT_TRUE(context->UsedTexture(context->TextureAt(1)));
1239 context->ResetUsedTextures();
1240 PostSetNeedsCommitToMainThread();
1241 break;
1242 case 1:
1243 // Number of textures should be doubled as the first context layer
1244 // texture is being used by the impl-thread and cannot be used for
1245 // update. The scrollbar behavior is different direct renderer because
1246 // UI resource deletion with delegating renderer occurs after tree
1247 // activation.
1248 ASSERT_EQ(4u, context->NumTextures());
1249 // Number of textures used for commit should still be
1250 // one for each layer.
1251 EXPECT_EQ(2u, context->NumUsedTextures());
1252 // First textures should not have been used.
1253 EXPECT_FALSE(context->UsedTexture(context->TextureAt(0)));
1254 EXPECT_FALSE(context->UsedTexture(context->TextureAt(1)));
1255 // New textures should have been used.
1256 EXPECT_TRUE(context->UsedTexture(context->TextureAt(2)));
1257 EXPECT_TRUE(context->UsedTexture(context->TextureAt(3)));
1258 context->ResetUsedTextures();
1259 PostSetNeedsCommitToMainThread();
1260 break;
1261 case 2:
1262 EndTest();
1263 break;
1264 default:
1265 NOTREACHED();
1266 break;
1267 }
1268 }
1269 };
1270
1271 MULTI_THREAD_DELEGATING_RENDERER_TEST_F(
1272 LayerTreeHostTestDelegatingRendererAtomicCommit);
1220 1273
1221 static void SetLayerPropertiesForTesting(Layer* layer, 1274 static void SetLayerPropertiesForTesting(Layer* layer,
1222 Layer* parent, 1275 Layer* parent,
1223 const gfx::Transform& transform, 1276 const gfx::Transform& transform,
1224 gfx::PointF anchor, 1277 gfx::PointF anchor,
1225 gfx::PointF position, 1278 gfx::PointF position,
1226 gfx::Size bounds, 1279 gfx::Size bounds,
1227 bool opaque) { 1280 bool opaque) {
1228 layer->RemoveAllChildren(); 1281 layer->RemoveAllChildren();
1229 if (parent) 1282 if (parent)
(...skipping 3061 matching lines...) Expand 10 before | Expand all | Expand 10 after
4291 int num_will_begin_frames_; 4344 int num_will_begin_frames_;
4292 int num_impl_commits_; 4345 int num_impl_commits_;
4293 }; 4346 };
4294 4347
4295 // Commits can only be aborted when using the thread proxy. 4348 // Commits can only be aborted when using the thread proxy.
4296 MULTI_THREAD_TEST_F(LayerTreeHostTestAbortEvictedTextures); 4349 MULTI_THREAD_TEST_F(LayerTreeHostTestAbortEvictedTextures);
4297 4350
4298 } // namespace 4351 } // namespace
4299 4352
4300 } // namespace cc 4353 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698