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

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

Issue 448303002: Use custom ListContainer to allocate DrawQuads (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@perftest
Patch Set: fix win trybot compile error Created 6 years, 3 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 EXPECT_EQ(2u, map.size()); 760 EXPECT_EQ(2u, map.size());
761 EXPECT_EQ(1u, map.count(999)); 761 EXPECT_EQ(1u, map.count(999));
762 EXPECT_EQ(1u, map.count(555)); 762 EXPECT_EQ(1u, map.count(555));
763 763
764 ResourceProvider::ResourceId parent_resource_id1 = map.find(999)->second; 764 ResourceProvider::ResourceId parent_resource_id1 = map.find(999)->second;
765 EXPECT_NE(parent_resource_id1, 999u); 765 EXPECT_NE(parent_resource_id1, 999u);
766 ResourceProvider::ResourceId parent_resource_id2 = map.find(555)->second; 766 ResourceProvider::ResourceId parent_resource_id2 = map.find(555)->second;
767 EXPECT_NE(parent_resource_id2, 555u); 767 EXPECT_NE(parent_resource_id2, 555u);
768 768
769 // The resources in the quads should be remapped to the parent's namespace. 769 // The resources in the quads should be remapped to the parent's namespace.
770 const TextureDrawQuad* quad1 = TextureDrawQuad::MaterialCast( 770 QuadList::ConstIterator iter =
771 delegated_impl->RenderPassesInDrawOrder()[0]->quad_list[0]); 771 delegated_impl->RenderPassesInDrawOrder()[0]->quad_list.begin();
772 const TextureDrawQuad* quad1 = TextureDrawQuad::MaterialCast(&*iter);
772 EXPECT_EQ(parent_resource_id1, quad1->resource_id); 773 EXPECT_EQ(parent_resource_id1, quad1->resource_id);
773 const TextureDrawQuad* quad2 = TextureDrawQuad::MaterialCast( 774 ++iter;
774 delegated_impl->RenderPassesInDrawOrder()[0]->quad_list[1]); 775 const TextureDrawQuad* quad2 = TextureDrawQuad::MaterialCast(&*iter);
775 EXPECT_EQ(parent_resource_id2, quad2->resource_id); 776 EXPECT_EQ(parent_resource_id2, quad2->resource_id);
776 777
777 EndTest(); 778 EndTest();
778 } 779 }
779 }; 780 };
780 781
781 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDelegatedTestRemapResourcesInQuads); 782 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDelegatedTestRemapResourcesInQuads);
782 783
783 class LayerTreeHostDelegatedTestReturnUnusedResources 784 class LayerTreeHostDelegatedTestReturnUnusedResources
784 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer { 785 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer {
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1013 // one with resource 999) on the impl tree. And only 999 will be present 1014 // one with resource 999) on the impl tree. And only 999 will be present
1014 // in the parent's resource provider. 1015 // in the parent's resource provider.
1015 EXPECT_EQ(1u, map.size()); 1016 EXPECT_EQ(1u, map.size());
1016 EXPECT_EQ(1u, map.count(999)); 1017 EXPECT_EQ(1u, map.count(999));
1017 1018
1018 EXPECT_EQ(1u, delegated_impl->Resources().size()); 1019 EXPECT_EQ(1u, delegated_impl->Resources().size());
1019 EXPECT_EQ(1u, delegated_impl->Resources().count(999)); 1020 EXPECT_EQ(1u, delegated_impl->Resources().count(999));
1020 1021
1021 const RenderPass* pass = delegated_impl->RenderPassesInDrawOrder()[0]; 1022 const RenderPass* pass = delegated_impl->RenderPassesInDrawOrder()[0];
1022 EXPECT_EQ(1u, pass->quad_list.size()); 1023 EXPECT_EQ(1u, pass->quad_list.size());
1023 const TextureDrawQuad* quad = TextureDrawQuad::MaterialCast( 1024 const TextureDrawQuad* quad =
1024 pass->quad_list[0]); 1025 TextureDrawQuad::MaterialCast(pass->quad_list.front());
1025 EXPECT_EQ(map.find(999)->second, quad->resource_id); 1026 EXPECT_EQ(map.find(999)->second, quad->resource_id);
1026 1027
1027 EndTest(); 1028 EndTest();
1028 } 1029 }
1029 1030
1030 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, 1031 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl,
1031 bool result) OVERRIDE { 1032 bool result) OVERRIDE {
1032 ReturnUnusedResourcesFromParent(host_impl); 1033 ReturnUnusedResourcesFromParent(host_impl);
1033 } 1034 }
1034 }; 1035 };
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1128 EXPECT_EQ(1u, map.count(555)); 1129 EXPECT_EQ(1u, map.count(555));
1129 EXPECT_EQ(1u, map.count(444)); 1130 EXPECT_EQ(1u, map.count(444));
1130 1131
1131 EXPECT_EQ(3u, delegated_impl->Resources().size()); 1132 EXPECT_EQ(3u, delegated_impl->Resources().size());
1132 EXPECT_EQ(1u, delegated_impl->Resources().count(999)); 1133 EXPECT_EQ(1u, delegated_impl->Resources().count(999));
1133 EXPECT_EQ(1u, delegated_impl->Resources().count(555)); 1134 EXPECT_EQ(1u, delegated_impl->Resources().count(555));
1134 EXPECT_EQ(1u, delegated_impl->Resources().count(444)); 1135 EXPECT_EQ(1u, delegated_impl->Resources().count(444));
1135 1136
1136 const RenderPass* pass = delegated_impl->RenderPassesInDrawOrder()[0]; 1137 const RenderPass* pass = delegated_impl->RenderPassesInDrawOrder()[0];
1137 EXPECT_EQ(3u, pass->quad_list.size()); 1138 EXPECT_EQ(3u, pass->quad_list.size());
1138 const TextureDrawQuad* quad1 = TextureDrawQuad::MaterialCast( 1139 QuadList::ConstIterator iter = pass->quad_list.begin();
1139 pass->quad_list[0]); 1140 const TextureDrawQuad* quad1 = TextureDrawQuad::MaterialCast(&*iter);
1140 EXPECT_EQ(map.find(999)->second, quad1->resource_id); 1141 EXPECT_EQ(map.find(999)->second, quad1->resource_id);
1141 const TextureDrawQuad* quad2 = TextureDrawQuad::MaterialCast( 1142 ++iter;
1142 pass->quad_list[1]); 1143 const TextureDrawQuad* quad2 = TextureDrawQuad::MaterialCast(&*iter);
1143 EXPECT_EQ(map.find(555)->second, quad2->resource_id); 1144 EXPECT_EQ(map.find(555)->second, quad2->resource_id);
1144 const TextureDrawQuad* quad3 = TextureDrawQuad::MaterialCast( 1145 ++iter;
1145 pass->quad_list[2]); 1146 const TextureDrawQuad* quad3 = TextureDrawQuad::MaterialCast(&*iter);
1146 EXPECT_EQ(map.find(444)->second, quad3->resource_id); 1147 EXPECT_EQ(map.find(444)->second, quad3->resource_id);
1147 } 1148 }
1148 1149
1149 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, 1150 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl,
1150 bool result) OVERRIDE { 1151 bool result) OVERRIDE {
1151 ReturnUnusedResourcesFromParent(host_impl); 1152 ReturnUnusedResourcesFromParent(host_impl);
1152 } 1153 }
1153 }; 1154 };
1154 1155
1155 SINGLE_AND_MULTI_THREAD_TEST_F( 1156 SINGLE_AND_MULTI_THREAD_TEST_F(
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1251 EXPECT_EQ(2u, map.size()); 1252 EXPECT_EQ(2u, map.size());
1252 EXPECT_EQ(1u, map.count(999)); 1253 EXPECT_EQ(1u, map.count(999));
1253 EXPECT_EQ(1u, map.count(555)); 1254 EXPECT_EQ(1u, map.count(555));
1254 1255
1255 EXPECT_EQ(2u, delegated_impl->Resources().size()); 1256 EXPECT_EQ(2u, delegated_impl->Resources().size());
1256 EXPECT_EQ(1u, delegated_impl->Resources().count(999)); 1257 EXPECT_EQ(1u, delegated_impl->Resources().count(999));
1257 EXPECT_EQ(1u, delegated_impl->Resources().count(555)); 1258 EXPECT_EQ(1u, delegated_impl->Resources().count(555));
1258 1259
1259 const RenderPass* pass = delegated_impl->RenderPassesInDrawOrder()[0]; 1260 const RenderPass* pass = delegated_impl->RenderPassesInDrawOrder()[0];
1260 EXPECT_EQ(2u, pass->quad_list.size()); 1261 EXPECT_EQ(2u, pass->quad_list.size());
1261 const TextureDrawQuad* quad1 = TextureDrawQuad::MaterialCast( 1262 QuadList::ConstIterator iter = pass->quad_list.begin();
1262 pass->quad_list[0]); 1263 const TextureDrawQuad* quad1 = TextureDrawQuad::MaterialCast(&*iter);
1263 EXPECT_EQ(map.find(999)->second, quad1->resource_id); 1264 EXPECT_EQ(map.find(999)->second, quad1->resource_id);
1264 const TextureDrawQuad* quad2 = TextureDrawQuad::MaterialCast( 1265 ++iter;
1265 pass->quad_list[1]); 1266 const TextureDrawQuad* quad2 = TextureDrawQuad::MaterialCast(&*iter);
1266 EXPECT_EQ(map.find(555)->second, quad2->resource_id); 1267 EXPECT_EQ(map.find(555)->second, quad2->resource_id);
1267 break; 1268 break;
1268 } 1269 }
1269 case 2: { 1270 case 2: {
1270 // We only keep resources from the last valid frame. 1271 // We only keep resources from the last valid frame.
1271 EXPECT_EQ(2u, map.size()); 1272 EXPECT_EQ(2u, map.size());
1272 EXPECT_EQ(1u, map.count(999)); 1273 EXPECT_EQ(1u, map.count(999));
1273 EXPECT_EQ(1u, map.count(555)); 1274 EXPECT_EQ(1u, map.count(555));
1274 1275
1275 EXPECT_EQ(2u, delegated_impl->Resources().size()); 1276 EXPECT_EQ(2u, delegated_impl->Resources().size());
1276 EXPECT_EQ(1u, delegated_impl->Resources().count(999)); 1277 EXPECT_EQ(1u, delegated_impl->Resources().count(999));
1277 EXPECT_EQ(1u, delegated_impl->Resources().count(555)); 1278 EXPECT_EQ(1u, delegated_impl->Resources().count(555));
1278 1279
1279 // The bad frame is dropped though, we still have the frame with 999 and 1280 // The bad frame is dropped though, we still have the frame with 999 and
1280 // 555 in it. 1281 // 555 in it.
1281 const RenderPass* pass = delegated_impl->RenderPassesInDrawOrder()[0]; 1282 const RenderPass* pass = delegated_impl->RenderPassesInDrawOrder()[0];
1282 EXPECT_EQ(2u, pass->quad_list.size()); 1283 EXPECT_EQ(2u, pass->quad_list.size());
1283 const TextureDrawQuad* quad1 = TextureDrawQuad::MaterialCast( 1284 QuadList::ConstIterator iter = pass->quad_list.begin();
1284 pass->quad_list[0]); 1285 const TextureDrawQuad* quad1 = TextureDrawQuad::MaterialCast(&*iter);
1285 EXPECT_EQ(map.find(999)->second, quad1->resource_id); 1286 EXPECT_EQ(map.find(999)->second, quad1->resource_id);
1286 const TextureDrawQuad* quad2 = TextureDrawQuad::MaterialCast( 1287 ++iter;
1287 pass->quad_list[1]); 1288 const TextureDrawQuad* quad2 = TextureDrawQuad::MaterialCast(&*iter);
1288 EXPECT_EQ(map.find(555)->second, quad2->resource_id); 1289 EXPECT_EQ(map.find(555)->second, quad2->resource_id);
1289 break; 1290 break;
1290 } 1291 }
1291 case 3: { 1292 case 3: {
1292 // We have the new good frame with just 999 in it. 1293 // We have the new good frame with just 999 in it.
1293 EXPECT_EQ(1u, map.size()); 1294 EXPECT_EQ(1u, map.size());
1294 EXPECT_EQ(1u, map.count(999)); 1295 EXPECT_EQ(1u, map.count(999));
1295 1296
1296 EXPECT_EQ(1u, delegated_impl->Resources().size()); 1297 EXPECT_EQ(1u, delegated_impl->Resources().size());
1297 EXPECT_EQ(1u, delegated_impl->Resources().count(999)); 1298 EXPECT_EQ(1u, delegated_impl->Resources().count(999));
1298 1299
1299 const RenderPass* pass = delegated_impl->RenderPassesInDrawOrder()[0]; 1300 const RenderPass* pass = delegated_impl->RenderPassesInDrawOrder()[0];
1300 EXPECT_EQ(1u, pass->quad_list.size()); 1301 EXPECT_EQ(1u, pass->quad_list.size());
1301 const TextureDrawQuad* quad1 = TextureDrawQuad::MaterialCast( 1302 const TextureDrawQuad* quad1 =
1302 pass->quad_list[0]); 1303 TextureDrawQuad::MaterialCast(pass->quad_list.front());
1303 EXPECT_EQ(map.find(999)->second, quad1->resource_id); 1304 EXPECT_EQ(map.find(999)->second, quad1->resource_id);
1304 break; 1305 break;
1305 } 1306 }
1306 } 1307 }
1307 } 1308 }
1308 }; 1309 };
1309 1310
1310 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDelegatedTestBadFrame); 1311 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDelegatedTestBadFrame);
1311 1312
1312 class LayerTreeHostDelegatedTestUnnamedResource 1313 class LayerTreeHostDelegatedTestUnnamedResource
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after
2192 } 2193 }
2193 2194
2194 scoped_refptr<DelegatedRendererLayer> delegated_thief_; 2195 scoped_refptr<DelegatedRendererLayer> delegated_thief_;
2195 }; 2196 };
2196 2197
2197 SINGLE_AND_MULTI_THREAD_TEST_F( 2198 SINGLE_AND_MULTI_THREAD_TEST_F(
2198 LayerTreeHostDelegatedTestRemoveAndChangeResources); 2199 LayerTreeHostDelegatedTestRemoveAndChangeResources);
2199 2200
2200 } // namespace 2201 } // namespace
2201 } // namespace cc 2202 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698