OLD | NEW |
---|---|
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 "base/synchronization/lock.h" | 7 #include "base/synchronization/lock.h" |
8 #include "cc/animation/timing_function.h" | 8 #include "cc/animation/timing_function.h" |
9 #include "cc/layers/content_layer.h" | 9 #include "cc/layers/content_layer.h" |
10 #include "cc/layers/content_layer_client.h" | 10 #include "cc/layers/content_layer_client.h" |
(...skipping 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1040 } | 1040 } |
1041 | 1041 |
1042 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE | 1042 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE |
1043 { | 1043 { |
1044 ASSERT_EQ(0u, m_layerTreeHost->settings().maxPartialTextureUpdates); | 1044 ASSERT_EQ(0u, m_layerTreeHost->settings().maxPartialTextureUpdates); |
1045 | 1045 |
1046 TestWebGraphicsContext3D* context = static_cast<TestWebGraphicsContext3D *>(impl->output_surface()->context3d()); | 1046 TestWebGraphicsContext3D* context = static_cast<TestWebGraphicsContext3D *>(impl->output_surface()->context3d()); |
1047 | 1047 |
1048 switch (impl->active_tree()->source_frame_number()) { | 1048 switch (impl->active_tree()->source_frame_number()) { |
1049 case 0: | 1049 case 0: |
1050 // Number of textures should be one for each layer | 1050 // Number of textures should be one for each layer plus an auxiliary |
danakj
2013/03/21 02:34:42
What if you only create the on-demand texture the
Leandro Graciá Gil
2013/03/21 03:35:50
I think I'll do that. Sounds much simpler.
Leandro Graciá Gil
2013/03/21 16:42:48
Done.
| |
1051 ASSERT_EQ(2, context->NumTextures()); | 1051 // texture for on-demand rasterization. |
1052 // Number of textures used for commit should be one for each layer. | 1052 ASSERT_EQ(3, context->NumTextures()); |
1053 EXPECT_EQ(2, context->NumUsedTextures()); | 1053 // Number of textures used for commit should be one for each layer |
1054 // plus the auxiliary one on startup. | |
1055 EXPECT_EQ(3, context->NumUsedTextures()); | |
1054 // Verify that used texture is correct. | 1056 // Verify that used texture is correct. |
1055 EXPECT_TRUE(context->UsedTexture(context->TextureAt(0))); | 1057 EXPECT_TRUE(context->UsedTexture(context->TextureAt(0))); |
1056 EXPECT_TRUE(context->UsedTexture(context->TextureAt(1))); | 1058 EXPECT_TRUE(context->UsedTexture(context->TextureAt(1))); |
1057 | 1059 |
1058 context->ResetUsedTextures(); | 1060 context->ResetUsedTextures(); |
1059 postSetNeedsCommitToMainThread(); | 1061 postSetNeedsCommitToMainThread(); |
1060 break; | 1062 break; |
1061 case 1: | 1063 case 1: |
1062 // Number of textures should be doubled as the first textures | 1064 // Number of textures should be doubled (excepting the auxiliary) |
1063 // are used by impl thread and cannot by used for update. | 1065 // as the first textures are used by impl thread and cannot by used |
1064 ASSERT_EQ(4, context->NumTextures()); | 1066 // for update. |
1067 ASSERT_EQ(5, context->NumTextures()); | |
1065 // Number of textures used for commit should still be one for each l ayer. | 1068 // Number of textures used for commit should still be one for each l ayer. |
1066 EXPECT_EQ(2, context->NumUsedTextures()); | 1069 EXPECT_EQ(2, context->NumUsedTextures()); |
1067 // First textures should not have been used. | 1070 // First textures should not have been used. |
1068 EXPECT_FALSE(context->UsedTexture(context->TextureAt(0))); | 1071 // Index 0 is used by the auxiliary texture. |
1069 EXPECT_FALSE(context->UsedTexture(context->TextureAt(1))); | 1072 EXPECT_FALSE(context->UsedTexture(context->TextureAt(1))); |
1073 EXPECT_FALSE(context->UsedTexture(context->TextureAt(2))); | |
1070 // New textures should have been used. | 1074 // New textures should have been used. |
1071 EXPECT_TRUE(context->UsedTexture(context->TextureAt(2))); | |
1072 EXPECT_TRUE(context->UsedTexture(context->TextureAt(3))); | 1075 EXPECT_TRUE(context->UsedTexture(context->TextureAt(3))); |
1076 EXPECT_TRUE(context->UsedTexture(context->TextureAt(4))); | |
1073 | 1077 |
1074 context->ResetUsedTextures(); | 1078 context->ResetUsedTextures(); |
1075 postSetNeedsCommitToMainThread(); | 1079 postSetNeedsCommitToMainThread(); |
1076 break; | 1080 break; |
1077 case 2: | 1081 case 2: |
1078 endTest(); | 1082 endTest(); |
1079 break; | 1083 break; |
1080 default: | 1084 default: |
1081 NOTREACHED(); | 1085 NOTREACHED(); |
1082 break; | 1086 break; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1172 } | 1176 } |
1173 | 1177 |
1174 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE | 1178 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE |
1175 { | 1179 { |
1176 ASSERT_EQ(1u, m_layerTreeHost->settings().maxPartialTextureUpdates); | 1180 ASSERT_EQ(1u, m_layerTreeHost->settings().maxPartialTextureUpdates); |
1177 | 1181 |
1178 TestWebGraphicsContext3D* context = static_cast<TestWebGraphicsContext3D *>(impl->output_surface()->context3d()); | 1182 TestWebGraphicsContext3D* context = static_cast<TestWebGraphicsContext3D *>(impl->output_surface()->context3d()); |
1179 | 1183 |
1180 switch (impl->active_tree()->source_frame_number()) { | 1184 switch (impl->active_tree()->source_frame_number()) { |
1181 case 0: | 1185 case 0: |
1182 // Number of textures should be one for each layer. | 1186 // Number of textures should be one for each layer plus an auxiliary |
1183 ASSERT_EQ(4, context->NumTextures()); | 1187 // texture for on-demand rasterization. |
1184 // Number of textures used for commit should be one for each layer. | 1188 ASSERT_EQ(5, context->NumTextures()); |
1185 EXPECT_EQ(4, context->NumUsedTextures()); | 1189 // Number of textures used for commit should be one for each layer |
1190 // plus the auxiliary one on startup. | |
1191 EXPECT_EQ(5, context->NumUsedTextures()); | |
1186 // Verify that used textures are correct. | 1192 // Verify that used textures are correct. |
1187 EXPECT_TRUE(context->UsedTexture(context->TextureAt(0))); | 1193 EXPECT_TRUE(context->UsedTexture(context->TextureAt(0))); |
1188 EXPECT_TRUE(context->UsedTexture(context->TextureAt(1))); | 1194 EXPECT_TRUE(context->UsedTexture(context->TextureAt(1))); |
1189 EXPECT_TRUE(context->UsedTexture(context->TextureAt(2))); | 1195 EXPECT_TRUE(context->UsedTexture(context->TextureAt(2))); |
1190 EXPECT_TRUE(context->UsedTexture(context->TextureAt(3))); | 1196 EXPECT_TRUE(context->UsedTexture(context->TextureAt(3))); |
1191 | 1197 |
1192 context->ResetUsedTextures(); | 1198 context->ResetUsedTextures(); |
1193 postSetNeedsCommitToMainThread(); | 1199 postSetNeedsCommitToMainThread(); |
1194 break; | 1200 break; |
1195 case 1: | 1201 case 1: |
1196 // Number of textures should be two for each content layer and one | 1202 // Number of textures should be two for each content layer, |
1203 // an auxiliary one for on-demand rasterization and one | |
1197 // for each scrollbar, since they always do a partial update. | 1204 // for each scrollbar, since they always do a partial update. |
1198 ASSERT_EQ(6, context->NumTextures()); | 1205 ASSERT_EQ(7, context->NumTextures()); |
1199 // Number of textures used for commit should be one for each content | 1206 // Number of textures used for commit should be one for each content |
1200 // layer, and one for the scrollbar layer that paints. | 1207 // layer, and one for the scrollbar layer that paints. |
1201 EXPECT_EQ(3, context->NumUsedTextures()); | 1208 EXPECT_EQ(3, context->NumUsedTextures()); |
1202 | 1209 |
1203 // First content textures should not have been used. | 1210 // First content textures should not have been used. |
1204 EXPECT_FALSE(context->UsedTexture(context->TextureAt(0))); | 1211 // Index 0 is used by the auxiliary texture. |
1205 EXPECT_FALSE(context->UsedTexture(context->TextureAt(1))); | 1212 EXPECT_FALSE(context->UsedTexture(context->TextureAt(1))); |
1213 EXPECT_FALSE(context->UsedTexture(context->TextureAt(2))); | |
1206 // The non-painting scrollbar's texture wasn't updated. | 1214 // The non-painting scrollbar's texture wasn't updated. |
1207 EXPECT_FALSE(context->UsedTexture(context->TextureAt(2))); | 1215 EXPECT_FALSE(context->UsedTexture(context->TextureAt(3))); |
1208 // The painting scrollbar's partial update texture was used. | 1216 // The painting scrollbar's partial update texture was used. |
1209 EXPECT_TRUE(context->UsedTexture(context->TextureAt(3))); | 1217 EXPECT_TRUE(context->UsedTexture(context->TextureAt(4))); |
1210 // New textures should have been used. | 1218 // New textures should have been used. |
1211 EXPECT_TRUE(context->UsedTexture(context->TextureAt(4))); | |
1212 EXPECT_TRUE(context->UsedTexture(context->TextureAt(5))); | 1219 EXPECT_TRUE(context->UsedTexture(context->TextureAt(5))); |
1220 EXPECT_TRUE(context->UsedTexture(context->TextureAt(6))); | |
1213 | 1221 |
1214 context->ResetUsedTextures(); | 1222 context->ResetUsedTextures(); |
1215 postSetNeedsCommitToMainThread(); | 1223 postSetNeedsCommitToMainThread(); |
1216 break; | 1224 break; |
1217 case 2: | 1225 case 2: |
1218 // Number of textures should be two for each content layer and one | 1226 // Number of textures should be two for each content layer, |
1227 // an auxiliary one for on-demand rasterization and one | |
1219 // for each scrollbar, since they always do a partial update. | 1228 // for each scrollbar, since they always do a partial update. |
1220 ASSERT_EQ(6, context->NumTextures()); | 1229 ASSERT_EQ(7, context->NumTextures()); |
1221 // Number of textures used for commit should be one for each content | 1230 // Number of textures used for commit should be one for each content |
1222 // layer, and one for the scrollbar layer that paints. | 1231 // layer, and one for the scrollbar layer that paints. |
1223 EXPECT_EQ(3, context->NumUsedTextures()); | 1232 EXPECT_EQ(3, context->NumUsedTextures()); |
1224 | 1233 |
1225 // The non-painting scrollbar's texture wasn't updated. | 1234 // The non-painting scrollbar's texture wasn't updated. |
1226 EXPECT_FALSE(context->UsedTexture(context->TextureAt(2))); | 1235 EXPECT_FALSE(context->UsedTexture(context->TextureAt(3))); |
1227 // The painting scrollbar does a partial update. | 1236 // The painting scrollbar does a partial update. |
1228 EXPECT_TRUE(context->UsedTexture(context->TextureAt(3))); | 1237 EXPECT_TRUE(context->UsedTexture(context->TextureAt(4))); |
1229 // One content layer does a partial update also. | 1238 // One content layer does a partial update also. |
1230 EXPECT_TRUE(context->UsedTexture(context->TextureAt(4))); | 1239 EXPECT_TRUE(context->UsedTexture(context->TextureAt(5))); |
1231 EXPECT_FALSE(context->UsedTexture(context->TextureAt(5))); | 1240 EXPECT_FALSE(context->UsedTexture(context->TextureAt(6))); |
1232 | 1241 |
1233 context->ResetUsedTextures(); | 1242 context->ResetUsedTextures(); |
1234 postSetNeedsCommitToMainThread(); | 1243 postSetNeedsCommitToMainThread(); |
1235 break; | 1244 break; |
1236 case 3: | 1245 case 3: |
1237 // No textures should be used for commit. | 1246 // No textures should be used for commit. |
1238 EXPECT_EQ(0, context->NumUsedTextures()); | 1247 EXPECT_EQ(0, context->NumUsedTextures()); |
1239 | 1248 |
1240 context->ResetUsedTextures(); | 1249 context->ResetUsedTextures(); |
1241 postSetNeedsCommitToMainThread(); | 1250 postSetNeedsCommitToMainThread(); |
(...skipping 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2352 private: | 2361 private: |
2353 FakeContentLayerClient m_client; | 2362 FakeContentLayerClient m_client; |
2354 scoped_refptr<ContentLayer> m_rootLayer; | 2363 scoped_refptr<ContentLayer> m_rootLayer; |
2355 int m_numCommits; | 2364 int m_numCommits; |
2356 }; | 2365 }; |
2357 | 2366 |
2358 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPinchZoomScrollbarNewRootLayer) | 2367 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPinchZoomScrollbarNewRootLayer) |
2359 | 2368 |
2360 } // namespace | 2369 } // namespace |
2361 } // namespace cc | 2370 } // namespace cc |
OLD | NEW |