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

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

Issue 1437413002: cc: Remove ScopedPtrVector and cc::remove_if. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 resource.mailbox_holder.texture_target = GL_TEXTURE_2D; 142 resource.mailbox_holder.texture_target = GL_TEXTURE_2D;
143 GLbyte arbitrary_mailbox[GL_MAILBOX_SIZE_CHROMIUM] = { 143 GLbyte arbitrary_mailbox[GL_MAILBOX_SIZE_CHROMIUM] = {
144 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 144 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2,
145 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 145 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4,
146 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4}; 146 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4};
147 resource.mailbox_holder.mailbox.SetName(arbitrary_mailbox); 147 resource.mailbox_holder.mailbox.SetName(arbitrary_mailbox);
148 frame->resource_list.push_back(resource); 148 frame->resource_list.push_back(resource);
149 } 149 }
150 150
151 void AddTextureQuad(DelegatedFrameData* frame, ResourceId resource_id) { 151 void AddTextureQuad(DelegatedFrameData* frame, ResourceId resource_id) {
152 RenderPass* render_pass = frame->render_pass_list[0]; 152 RenderPass* render_pass = frame->render_pass_list[0].get();
153 SharedQuadState* sqs = render_pass->CreateAndAppendSharedQuadState(); 153 SharedQuadState* sqs = render_pass->CreateAndAppendSharedQuadState();
154 TextureDrawQuad* quad = 154 TextureDrawQuad* quad =
155 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); 155 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>();
156 float vertex_opacity[4] = { 1.f, 1.f, 1.f, 1.f }; 156 float vertex_opacity[4] = { 1.f, 1.f, 1.f, 1.f };
157 quad->SetNew(sqs, 157 quad->SetNew(sqs,
158 gfx::Rect(0, 0, 10, 10), 158 gfx::Rect(0, 0, 10, 10),
159 gfx::Rect(0, 0, 10, 10), 159 gfx::Rect(0, 0, 10, 10),
160 gfx::Rect(0, 0, 10, 10), 160 gfx::Rect(0, 0, 10, 10),
161 resource_id, 161 resource_id,
162 false, 162 false,
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 layer_tree_host()->SetRootLayer(root_); 246 layer_tree_host()->SetRootLayer(root_);
247 LayerTreeHostDelegatedTest::SetupTree(); 247 LayerTreeHostDelegatedTest::SetupTree();
248 } 248 }
249 249
250 void BeginTest() override { 250 void BeginTest() override {
251 resource_collection_->SetClient(this); 251 resource_collection_->SetClient(this);
252 PostSetNeedsCommitToMainThread(); 252 PostSetNeedsCommitToMainThread();
253 } 253 }
254 254
255 void SetFrameData(scoped_ptr<DelegatedFrameData> frame_data) { 255 void SetFrameData(scoped_ptr<DelegatedFrameData> frame_data) {
256 RenderPass* root_pass = frame_data->render_pass_list.back(); 256 RenderPass* root_pass = frame_data->render_pass_list.back().get();
257 gfx::Size frame_size = root_pass->output_rect.size(); 257 gfx::Size frame_size = root_pass->output_rect.size();
258 258
259 if (frame_provider_.get() && frame_size == frame_provider_->frame_size()) { 259 if (frame_provider_.get() && frame_size == frame_provider_->frame_size()) {
260 frame_provider_->SetFrameData(frame_data.Pass()); 260 frame_provider_->SetFrameData(frame_data.Pass());
261 return; 261 return;
262 } 262 }
263 263
264 if (delegated_.get()) { 264 if (delegated_.get()) {
265 delegated_->RemoveFromParent(); 265 delegated_->RemoveFromParent();
266 delegated_ = NULL; 266 delegated_ = NULL;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 return; 316 return;
317 SetFrameData(CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1))); 317 SetFrameData(CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)));
318 } 318 }
319 319
320 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { 320 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
321 if (host_impl->active_tree()->source_frame_number() < 1) 321 if (host_impl->active_tree()->source_frame_number() < 1)
322 return; 322 return;
323 323
324 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); 324 LayerImpl* root_impl = host_impl->active_tree()->root_layer();
325 FakeDelegatedRendererLayerImpl* delegated_impl = 325 FakeDelegatedRendererLayerImpl* delegated_impl =
326 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); 326 static_cast<FakeDelegatedRendererLayerImpl*>(
327 root_impl->children()[0].get());
327 328
328 TestContextProvider* context_provider = static_cast<TestContextProvider*>( 329 TestContextProvider* context_provider = static_cast<TestContextProvider*>(
329 host_impl->output_surface()->context_provider()); 330 host_impl->output_surface()->context_provider());
330 331
331 ++num_activates_; 332 ++num_activates_;
332 switch (num_activates_) { 333 switch (num_activates_) {
333 case 2: 334 case 2:
334 EXPECT_TRUE(delegated_impl->ChildId()); 335 EXPECT_TRUE(delegated_impl->ChildId());
335 EXPECT_FALSE(did_reset_child_id_); 336 EXPECT_FALSE(did_reset_child_id_);
336 337
(...skipping 12 matching lines...) Expand all
349 350
350 void InitializedRendererOnThread(LayerTreeHostImpl* host_impl, 351 void InitializedRendererOnThread(LayerTreeHostImpl* host_impl,
351 bool success) override { 352 bool success) override {
352 EXPECT_TRUE(success); 353 EXPECT_TRUE(success);
353 354
354 if (num_activates_ < 2) 355 if (num_activates_ < 2)
355 return; 356 return;
356 357
357 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); 358 LayerImpl* root_impl = host_impl->active_tree()->root_layer();
358 FakeDelegatedRendererLayerImpl* delegated_impl = 359 FakeDelegatedRendererLayerImpl* delegated_impl =
359 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); 360 static_cast<FakeDelegatedRendererLayerImpl*>(
361 root_impl->children()[0].get());
360 362
361 EXPECT_EQ(2, num_activates_); 363 EXPECT_EQ(2, num_activates_);
362 EXPECT_FALSE(delegated_impl->ChildId()); 364 EXPECT_FALSE(delegated_impl->ChildId());
363 did_reset_child_id_ = true; 365 did_reset_child_id_ = true;
364 } 366 }
365 367
366 protected: 368 protected:
367 int num_activates_; 369 int num_activates_;
368 bool did_reset_child_id_; 370 bool did_reset_child_id_;
369 }; 371 };
370 372
371 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDelegatedTestCreateChildId); 373 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDelegatedTestCreateChildId);
372 374
373 class LayerTreeHostDelegatedTestDontUseLostChildIdAfterCommit 375 class LayerTreeHostDelegatedTestDontUseLostChildIdAfterCommit
374 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer { 376 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer {
375 protected: 377 protected:
376 void BeginTest() override { 378 void BeginTest() override {
377 SetFrameData(CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1))); 379 SetFrameData(CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)));
378 LayerTreeHostDelegatedTestCaseSingleDelegatedLayer::BeginTest(); 380 LayerTreeHostDelegatedTestCaseSingleDelegatedLayer::BeginTest();
379 } 381 }
380 382
381 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { 383 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
382 // Act like the context was lost while the layer is in the pending tree. 384 // Act like the context was lost while the layer is in the pending tree.
383 LayerImpl* root_impl = host_impl->sync_tree()->root_layer(); 385 LayerImpl* root_impl = host_impl->sync_tree()->root_layer();
384 FakeDelegatedRendererLayerImpl* delegated_impl = 386 FakeDelegatedRendererLayerImpl* delegated_impl =
385 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); 387 static_cast<FakeDelegatedRendererLayerImpl*>(
388 root_impl->children()[0].get());
386 delegated_impl->ReleaseResources(); 389 delegated_impl->ReleaseResources();
387 } 390 }
388 391
389 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { 392 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
390 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); 393 LayerImpl* root_impl = host_impl->active_tree()->root_layer();
391 FakeDelegatedRendererLayerImpl* delegated_impl = 394 FakeDelegatedRendererLayerImpl* delegated_impl =
392 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); 395 static_cast<FakeDelegatedRendererLayerImpl*>(
396 root_impl->children()[0].get());
393 397
394 // Should not try to activate a frame without a child id. If we did try to 398 // Should not try to activate a frame without a child id. If we did try to
395 // activate we would crash. 399 // activate we would crash.
396 EXPECT_FALSE(delegated_impl->ChildId()); 400 EXPECT_FALSE(delegated_impl->ChildId());
397 EndTest(); 401 EndTest();
398 } 402 }
399 }; 403 };
400 404
401 SINGLE_AND_MULTI_THREAD_TEST_F( 405 SINGLE_AND_MULTI_THREAD_TEST_F(
402 LayerTreeHostDelegatedTestDontUseLostChildIdAfterCommit); 406 LayerTreeHostDelegatedTestDontUseLostChildIdAfterCommit);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 459
456 void InitializedRendererOnThread(LayerTreeHostImpl* host_impl, 460 void InitializedRendererOnThread(LayerTreeHostImpl* host_impl,
457 bool success) override { 461 bool success) override {
458 EXPECT_TRUE(success); 462 EXPECT_TRUE(success);
459 463
460 if (num_activates_ < 2) 464 if (num_activates_ < 2)
461 return; 465 return;
462 466
463 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); 467 LayerImpl* root_impl = host_impl->active_tree()->root_layer();
464 FakeDelegatedRendererLayerImpl* delegated_impl = 468 FakeDelegatedRendererLayerImpl* delegated_impl =
465 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); 469 static_cast<FakeDelegatedRendererLayerImpl*>(
470 root_impl->children()[0].get());
466 471
467 EXPECT_EQ(2, num_activates_); 472 EXPECT_EQ(2, num_activates_);
468 // Resources should have gotten cleared after the context was lost. 473 // Resources should have gotten cleared after the context was lost.
469 EXPECT_EQ(0U, delegated_impl->Resources().size()); 474 EXPECT_EQ(0U, delegated_impl->Resources().size());
470 } 475 }
471 476
472 void AfterTest() override { 477 void AfterTest() override {
473 LayerTreeHostDelegatedTestCaseSingleDelegatedLayer::AfterTest(); 478 LayerTreeHostDelegatedTestCaseSingleDelegatedLayer::AfterTest();
474 EXPECT_EQ(2, num_output_surfaces_initialized_); 479 EXPECT_EQ(2, num_output_surfaces_initialized_);
475 } 480 }
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 EXPECT_RESOURCES(expected, returned_resources); 717 EXPECT_RESOURCES(expected, returned_resources);
713 EXPECT_TRUE(TestAndResetAvailable()); 718 EXPECT_TRUE(TestAndResetAvailable());
714 } 719 }
715 720
716 PostSetNeedsCommitToMainThread(); 721 PostSetNeedsCommitToMainThread();
717 } 722 }
718 723
719 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { 724 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
720 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); 725 LayerImpl* root_impl = host_impl->active_tree()->root_layer();
721 FakeDelegatedRendererLayerImpl* delegated_impl = 726 FakeDelegatedRendererLayerImpl* delegated_impl =
722 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); 727 static_cast<FakeDelegatedRendererLayerImpl*>(
728 root_impl->children()[0].get());
723 729
724 const ResourceProvider::ResourceIdMap& map = 730 const ResourceProvider::ResourceIdMap& map =
725 host_impl->resource_provider()->GetChildToParentMap( 731 host_impl->resource_provider()->GetChildToParentMap(
726 delegated_impl->ChildId()); 732 delegated_impl->ChildId());
727 733
728 // Both frames' resources should be in the parent's resource provider. 734 // Both frames' resources should be in the parent's resource provider.
729 EXPECT_EQ(2u, map.size()); 735 EXPECT_EQ(2u, map.size());
730 EXPECT_EQ(1u, map.count(999)); 736 EXPECT_EQ(1u, map.count(999));
731 EXPECT_EQ(1u, map.count(555)); 737 EXPECT_EQ(1u, map.count(555));
732 738
(...skipping 19 matching lines...) Expand all
752 AddTextureQuad(frame.get(), 555); 758 AddTextureQuad(frame.get(), 555);
753 AddTransferableResource(frame.get(), 555); 759 AddTransferableResource(frame.get(), 555);
754 SetFrameData(frame.Pass()); 760 SetFrameData(frame.Pass());
755 761
756 PostSetNeedsCommitToMainThread(); 762 PostSetNeedsCommitToMainThread();
757 } 763 }
758 764
759 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { 765 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
760 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); 766 LayerImpl* root_impl = host_impl->active_tree()->root_layer();
761 FakeDelegatedRendererLayerImpl* delegated_impl = 767 FakeDelegatedRendererLayerImpl* delegated_impl =
762 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); 768 static_cast<FakeDelegatedRendererLayerImpl*>(
769 root_impl->children()[0].get());
763 770
764 const ResourceProvider::ResourceIdMap& map = 771 const ResourceProvider::ResourceIdMap& map =
765 host_impl->resource_provider()->GetChildToParentMap( 772 host_impl->resource_provider()->GetChildToParentMap(
766 delegated_impl->ChildId()); 773 delegated_impl->ChildId());
767 774
768 // The frame's resource should be in the parent's resource provider. 775 // The frame's resource should be in the parent's resource provider.
769 EXPECT_EQ(2u, map.size()); 776 EXPECT_EQ(2u, map.size());
770 EXPECT_EQ(1u, map.count(999)); 777 EXPECT_EQ(1u, map.count(999));
771 EXPECT_EQ(1u, map.count(555)); 778 EXPECT_EQ(1u, map.count(555));
772 779
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 break; 1004 break;
998 } 1005 }
999 } 1006 }
1000 1007
1001 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { 1008 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
1002 if (host_impl->active_tree()->source_frame_number() != 3) 1009 if (host_impl->active_tree()->source_frame_number() != 3)
1003 return; 1010 return;
1004 1011
1005 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); 1012 LayerImpl* root_impl = host_impl->active_tree()->root_layer();
1006 FakeDelegatedRendererLayerImpl* delegated_impl = 1013 FakeDelegatedRendererLayerImpl* delegated_impl =
1007 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); 1014 static_cast<FakeDelegatedRendererLayerImpl*>(
1015 root_impl->children()[0].get());
1008 1016
1009 const ResourceProvider::ResourceIdMap& map = 1017 const ResourceProvider::ResourceIdMap& map =
1010 host_impl->resource_provider()->GetChildToParentMap( 1018 host_impl->resource_provider()->GetChildToParentMap(
1011 delegated_impl->ChildId()); 1019 delegated_impl->ChildId());
1012 1020
1013 // The bad frame should be dropped. So we should only have one quad (the 1021 // The bad frame should be dropped. So we should only have one quad (the
1014 // one with resource 999) on the impl tree. And only 999 will be present 1022 // one with resource 999) on the impl tree. And only 999 will be present
1015 // in the parent's resource provider. 1023 // in the parent's resource provider.
1016 EXPECT_EQ(1u, map.size()); 1024 EXPECT_EQ(1u, map.size());
1017 EXPECT_EQ(1u, map.count(999)); 1025 EXPECT_EQ(1u, map.count(999));
1018 1026
1019 EXPECT_EQ(1u, delegated_impl->Resources().size()); 1027 EXPECT_EQ(1u, delegated_impl->Resources().size());
1020 EXPECT_EQ(1u, delegated_impl->Resources().count(999)); 1028 EXPECT_EQ(1u, delegated_impl->Resources().count(999));
1021 1029
1022 const RenderPass* pass = delegated_impl->RenderPassesInDrawOrder()[0]; 1030 const RenderPass* pass = delegated_impl->RenderPassesInDrawOrder()[0].get();
1023 EXPECT_EQ(1u, pass->quad_list.size()); 1031 EXPECT_EQ(1u, pass->quad_list.size());
1024 const TextureDrawQuad* quad = 1032 const TextureDrawQuad* quad =
1025 TextureDrawQuad::MaterialCast(pass->quad_list.front()); 1033 TextureDrawQuad::MaterialCast(pass->quad_list.front());
1026 EXPECT_EQ(map.find(999)->second, quad->resource_id()); 1034 EXPECT_EQ(map.find(999)->second, quad->resource_id());
1027 1035
1028 EndTest(); 1036 EndTest();
1029 } 1037 }
1030 1038
1031 void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, bool result) override { 1039 void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, bool result) override {
1032 ReturnUnusedResourcesFromParent(host_impl); 1040 ReturnUnusedResourcesFromParent(host_impl);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1106 break; 1114 break;
1107 } 1115 }
1108 } 1116 }
1109 1117
1110 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { 1118 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
1111 if (host_impl->active_tree()->source_frame_number() != 3) 1119 if (host_impl->active_tree()->source_frame_number() != 3)
1112 return; 1120 return;
1113 1121
1114 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); 1122 LayerImpl* root_impl = host_impl->active_tree()->root_layer();
1115 FakeDelegatedRendererLayerImpl* delegated_impl = 1123 FakeDelegatedRendererLayerImpl* delegated_impl =
1116 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); 1124 static_cast<FakeDelegatedRendererLayerImpl*>(
1125 root_impl->children()[0].get());
1117 1126
1118 const ResourceProvider::ResourceIdMap& map = 1127 const ResourceProvider::ResourceIdMap& map =
1119 host_impl->resource_provider()->GetChildToParentMap( 1128 host_impl->resource_provider()->GetChildToParentMap(
1120 delegated_impl->ChildId()); 1129 delegated_impl->ChildId());
1121 1130
1122 // The third frame has all of the resources in it again, the delegated 1131 // The third frame has all of the resources in it again, the delegated
1123 // renderer layer should continue to own the resources for it. 1132 // renderer layer should continue to own the resources for it.
1124 EXPECT_EQ(3u, map.size()); 1133 EXPECT_EQ(3u, map.size());
1125 EXPECT_EQ(1u, map.count(999)); 1134 EXPECT_EQ(1u, map.count(999));
1126 EXPECT_EQ(1u, map.count(555)); 1135 EXPECT_EQ(1u, map.count(555));
1127 EXPECT_EQ(1u, map.count(444)); 1136 EXPECT_EQ(1u, map.count(444));
1128 1137
1129 EXPECT_EQ(3u, delegated_impl->Resources().size()); 1138 EXPECT_EQ(3u, delegated_impl->Resources().size());
1130 EXPECT_EQ(1u, delegated_impl->Resources().count(999)); 1139 EXPECT_EQ(1u, delegated_impl->Resources().count(999));
1131 EXPECT_EQ(1u, delegated_impl->Resources().count(555)); 1140 EXPECT_EQ(1u, delegated_impl->Resources().count(555));
1132 EXPECT_EQ(1u, delegated_impl->Resources().count(444)); 1141 EXPECT_EQ(1u, delegated_impl->Resources().count(444));
1133 1142
1134 const RenderPass* pass = delegated_impl->RenderPassesInDrawOrder()[0]; 1143 const RenderPass* pass = delegated_impl->RenderPassesInDrawOrder()[0].get();
1135 EXPECT_EQ(3u, pass->quad_list.size()); 1144 EXPECT_EQ(3u, pass->quad_list.size());
1136 const TextureDrawQuad* quad1 = 1145 const TextureDrawQuad* quad1 =
1137 TextureDrawQuad::MaterialCast(pass->quad_list.ElementAt(0)); 1146 TextureDrawQuad::MaterialCast(pass->quad_list.ElementAt(0));
1138 EXPECT_EQ(map.find(999)->second, quad1->resource_id()); 1147 EXPECT_EQ(map.find(999)->second, quad1->resource_id());
1139 const TextureDrawQuad* quad2 = 1148 const TextureDrawQuad* quad2 =
1140 TextureDrawQuad::MaterialCast(pass->quad_list.ElementAt(1)); 1149 TextureDrawQuad::MaterialCast(pass->quad_list.ElementAt(1));
1141 EXPECT_EQ(map.find(555)->second, quad2->resource_id()); 1150 EXPECT_EQ(map.find(555)->second, quad2->resource_id());
1142 const TextureDrawQuad* quad3 = 1151 const TextureDrawQuad* quad3 =
1143 TextureDrawQuad::MaterialCast(pass->quad_list.ElementAt(2)); 1152 TextureDrawQuad::MaterialCast(pass->quad_list.ElementAt(2));
1144 EXPECT_EQ(map.find(444)->second, quad3->resource_id()); 1153 EXPECT_EQ(map.find(444)->second, quad3->resource_id());
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1225 } 1234 }
1226 1235
1227 void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, bool result) override { 1236 void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, bool result) override {
1228 if (host_impl->active_tree()->source_frame_number() < 1) 1237 if (host_impl->active_tree()->source_frame_number() < 1)
1229 return; 1238 return;
1230 1239
1231 ReturnUnusedResourcesFromParent(host_impl); 1240 ReturnUnusedResourcesFromParent(host_impl);
1232 1241
1233 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); 1242 LayerImpl* root_impl = host_impl->active_tree()->root_layer();
1234 FakeDelegatedRendererLayerImpl* delegated_impl = 1243 FakeDelegatedRendererLayerImpl* delegated_impl =
1235 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); 1244 static_cast<FakeDelegatedRendererLayerImpl*>(
1245 root_impl->children()[0].get());
1236 1246
1237 const ResourceProvider::ResourceIdMap& map = 1247 const ResourceProvider::ResourceIdMap& map =
1238 host_impl->resource_provider()->GetChildToParentMap( 1248 host_impl->resource_provider()->GetChildToParentMap(
1239 delegated_impl->ChildId()); 1249 delegated_impl->ChildId());
1240 1250
1241 switch (host_impl->active_tree()->source_frame_number()) { 1251 switch (host_impl->active_tree()->source_frame_number()) {
1242 case 1: { 1252 case 1: {
1243 // We have the first good frame with just 999 and 555 in it. 1253 // We have the first good frame with just 999 and 555 in it.
1244 // layer. 1254 // layer.
1245 EXPECT_EQ(2u, map.size()); 1255 EXPECT_EQ(2u, map.size());
1246 EXPECT_EQ(1u, map.count(999)); 1256 EXPECT_EQ(1u, map.count(999));
1247 EXPECT_EQ(1u, map.count(555)); 1257 EXPECT_EQ(1u, map.count(555));
1248 1258
1249 EXPECT_EQ(2u, delegated_impl->Resources().size()); 1259 EXPECT_EQ(2u, delegated_impl->Resources().size());
1250 EXPECT_EQ(1u, delegated_impl->Resources().count(999)); 1260 EXPECT_EQ(1u, delegated_impl->Resources().count(999));
1251 EXPECT_EQ(1u, delegated_impl->Resources().count(555)); 1261 EXPECT_EQ(1u, delegated_impl->Resources().count(555));
1252 1262
1253 const RenderPass* pass = delegated_impl->RenderPassesInDrawOrder()[0]; 1263 const RenderPass* pass =
1264 delegated_impl->RenderPassesInDrawOrder()[0].get();
1254 EXPECT_EQ(2u, pass->quad_list.size()); 1265 EXPECT_EQ(2u, pass->quad_list.size());
1255 const TextureDrawQuad* quad1 = 1266 const TextureDrawQuad* quad1 =
1256 TextureDrawQuad::MaterialCast(pass->quad_list.ElementAt(0)); 1267 TextureDrawQuad::MaterialCast(pass->quad_list.ElementAt(0));
1257 EXPECT_EQ(map.find(999)->second, quad1->resource_id()); 1268 EXPECT_EQ(map.find(999)->second, quad1->resource_id());
1258 const TextureDrawQuad* quad2 = 1269 const TextureDrawQuad* quad2 =
1259 TextureDrawQuad::MaterialCast(pass->quad_list.ElementAt(1)); 1270 TextureDrawQuad::MaterialCast(pass->quad_list.ElementAt(1));
1260 EXPECT_EQ(map.find(555)->second, quad2->resource_id()); 1271 EXPECT_EQ(map.find(555)->second, quad2->resource_id());
1261 break; 1272 break;
1262 } 1273 }
1263 case 2: { 1274 case 2: {
1264 // We only keep resources from the last valid frame. 1275 // We only keep resources from the last valid frame.
1265 EXPECT_EQ(2u, map.size()); 1276 EXPECT_EQ(2u, map.size());
1266 EXPECT_EQ(1u, map.count(999)); 1277 EXPECT_EQ(1u, map.count(999));
1267 EXPECT_EQ(1u, map.count(555)); 1278 EXPECT_EQ(1u, map.count(555));
1268 1279
1269 EXPECT_EQ(2u, delegated_impl->Resources().size()); 1280 EXPECT_EQ(2u, delegated_impl->Resources().size());
1270 EXPECT_EQ(1u, delegated_impl->Resources().count(999)); 1281 EXPECT_EQ(1u, delegated_impl->Resources().count(999));
1271 EXPECT_EQ(1u, delegated_impl->Resources().count(555)); 1282 EXPECT_EQ(1u, delegated_impl->Resources().count(555));
1272 1283
1273 // The bad frame is dropped though, we still have the frame with 999 and 1284 // The bad frame is dropped though, we still have the frame with 999 and
1274 // 555 in it. 1285 // 555 in it.
1275 const RenderPass* pass = delegated_impl->RenderPassesInDrawOrder()[0]; 1286 const RenderPass* pass =
1287 delegated_impl->RenderPassesInDrawOrder()[0].get();
1276 EXPECT_EQ(2u, pass->quad_list.size()); 1288 EXPECT_EQ(2u, pass->quad_list.size());
1277 const TextureDrawQuad* quad1 = 1289 const TextureDrawQuad* quad1 =
1278 TextureDrawQuad::MaterialCast(pass->quad_list.ElementAt(0)); 1290 TextureDrawQuad::MaterialCast(pass->quad_list.ElementAt(0));
1279 EXPECT_EQ(map.find(999)->second, quad1->resource_id()); 1291 EXPECT_EQ(map.find(999)->second, quad1->resource_id());
1280 const TextureDrawQuad* quad2 = 1292 const TextureDrawQuad* quad2 =
1281 TextureDrawQuad::MaterialCast(pass->quad_list.ElementAt(1)); 1293 TextureDrawQuad::MaterialCast(pass->quad_list.ElementAt(1));
1282 EXPECT_EQ(map.find(555)->second, quad2->resource_id()); 1294 EXPECT_EQ(map.find(555)->second, quad2->resource_id());
1283 break; 1295 break;
1284 } 1296 }
1285 case 3: { 1297 case 3: {
1286 // We have the new good frame with just 999 in it. 1298 // We have the new good frame with just 999 in it.
1287 EXPECT_EQ(1u, map.size()); 1299 EXPECT_EQ(1u, map.size());
1288 EXPECT_EQ(1u, map.count(999)); 1300 EXPECT_EQ(1u, map.count(999));
1289 1301
1290 EXPECT_EQ(1u, delegated_impl->Resources().size()); 1302 EXPECT_EQ(1u, delegated_impl->Resources().size());
1291 EXPECT_EQ(1u, delegated_impl->Resources().count(999)); 1303 EXPECT_EQ(1u, delegated_impl->Resources().count(999));
1292 1304
1293 const RenderPass* pass = delegated_impl->RenderPassesInDrawOrder()[0]; 1305 const RenderPass* pass =
1306 delegated_impl->RenderPassesInDrawOrder()[0].get();
1294 EXPECT_EQ(1u, pass->quad_list.size()); 1307 EXPECT_EQ(1u, pass->quad_list.size());
1295 const TextureDrawQuad* quad1 = 1308 const TextureDrawQuad* quad1 =
1296 TextureDrawQuad::MaterialCast(pass->quad_list.front()); 1309 TextureDrawQuad::MaterialCast(pass->quad_list.front());
1297 EXPECT_EQ(map.find(999)->second, quad1->resource_id()); 1310 EXPECT_EQ(map.find(999)->second, quad1->resource_id());
1298 break; 1311 break;
1299 } 1312 }
1300 } 1313 }
1301 } 1314 }
1302 }; 1315 };
1303 1316
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1343 break; 1356 break;
1344 } 1357 }
1345 } 1358 }
1346 1359
1347 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { 1360 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
1348 if (host_impl->active_tree()->source_frame_number() != 1) 1361 if (host_impl->active_tree()->source_frame_number() != 1)
1349 return; 1362 return;
1350 1363
1351 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); 1364 LayerImpl* root_impl = host_impl->active_tree()->root_layer();
1352 FakeDelegatedRendererLayerImpl* delegated_impl = 1365 FakeDelegatedRendererLayerImpl* delegated_impl =
1353 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); 1366 static_cast<FakeDelegatedRendererLayerImpl*>(
1367 root_impl->children()[0].get());
1354 1368
1355 const ResourceProvider::ResourceIdMap& map = 1369 const ResourceProvider::ResourceIdMap& map =
1356 host_impl->resource_provider()->GetChildToParentMap( 1370 host_impl->resource_provider()->GetChildToParentMap(
1357 delegated_impl->ChildId()); 1371 delegated_impl->ChildId());
1358 1372
1359 // The layer only held on to the resource that was used. 1373 // The layer only held on to the resource that was used.
1360 EXPECT_EQ(1u, map.size()); 1374 EXPECT_EQ(1u, map.size());
1361 EXPECT_EQ(1u, map.count(555)); 1375 EXPECT_EQ(1u, map.count(555));
1362 1376
1363 EXPECT_EQ(1u, delegated_impl->Resources().size()); 1377 EXPECT_EQ(1u, delegated_impl->Resources().size());
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1419 break; 1433 break;
1420 } 1434 }
1421 } 1435 }
1422 1436
1423 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { 1437 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
1424 if (host_impl->active_tree()->source_frame_number() != 1) 1438 if (host_impl->active_tree()->source_frame_number() != 1)
1425 return; 1439 return;
1426 1440
1427 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); 1441 LayerImpl* root_impl = host_impl->active_tree()->root_layer();
1428 FakeDelegatedRendererLayerImpl* delegated_impl = 1442 FakeDelegatedRendererLayerImpl* delegated_impl =
1429 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); 1443 static_cast<FakeDelegatedRendererLayerImpl*>(
1444 root_impl->children()[0].get());
1430 1445
1431 const ResourceProvider::ResourceIdMap& map = 1446 const ResourceProvider::ResourceIdMap& map =
1432 host_impl->resource_provider()->GetChildToParentMap( 1447 host_impl->resource_provider()->GetChildToParentMap(
1433 delegated_impl->ChildId()); 1448 delegated_impl->ChildId());
1434 1449
1435 // The layer only held on to the resource that was used. 1450 // The layer only held on to the resource that was used.
1436 EXPECT_EQ(1u, map.size()); 1451 EXPECT_EQ(1u, map.size());
1437 EXPECT_EQ(1u, map.count(555)); 1452 EXPECT_EQ(1u, map.count(555));
1438 1453
1439 EXPECT_EQ(1u, delegated_impl->Resources().size()); 1454 EXPECT_EQ(1u, delegated_impl->Resources().size());
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1486 // The impl side will get back the resource at some point. 1501 // The impl side will get back the resource at some point.
1487 ImplThreadTaskRunner()->PostTask(FROM_HERE, 1502 ImplThreadTaskRunner()->PostTask(FROM_HERE,
1488 receive_resource_on_thread_); 1503 receive_resource_on_thread_);
1489 break; 1504 break;
1490 } 1505 }
1491 } 1506 }
1492 1507
1493 void ReceiveResourceOnThread(LayerTreeHostImpl* host_impl) { 1508 void ReceiveResourceOnThread(LayerTreeHostImpl* host_impl) {
1494 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); 1509 LayerImpl* root_impl = host_impl->active_tree()->root_layer();
1495 FakeDelegatedRendererLayerImpl* delegated_impl = 1510 FakeDelegatedRendererLayerImpl* delegated_impl =
1496 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); 1511 static_cast<FakeDelegatedRendererLayerImpl*>(
1512 root_impl->children()[0].get());
1497 1513
1498 const ResourceProvider::ResourceIdMap& map = 1514 const ResourceProvider::ResourceIdMap& map =
1499 host_impl->resource_provider()->GetChildToParentMap( 1515 host_impl->resource_provider()->GetChildToParentMap(
1500 delegated_impl->ChildId()); 1516 delegated_impl->ChildId());
1501 1517
1502 // Receive 999 back from the grandparent. 1518 // Receive 999 back from the grandparent.
1503 CompositorFrameAck ack; 1519 CompositorFrameAck ack;
1504 output_surface()->ReturnResource(map.find(999)->second, &ack); 1520 output_surface()->ReturnResource(map.find(999)->second, &ack);
1505 host_impl->ReclaimResources(&ack); 1521 host_impl->ReclaimResources(&ack);
1506 } 1522 }
(...skipping 12 matching lines...) Expand all
1519 1535
1520 EndTest(); 1536 EndTest();
1521 } 1537 }
1522 1538
1523 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { 1539 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
1524 if (host_impl->active_tree()->source_frame_number() < 1) 1540 if (host_impl->active_tree()->source_frame_number() < 1)
1525 return; 1541 return;
1526 1542
1527 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); 1543 LayerImpl* root_impl = host_impl->active_tree()->root_layer();
1528 FakeDelegatedRendererLayerImpl* delegated_impl = 1544 FakeDelegatedRendererLayerImpl* delegated_impl =
1529 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); 1545 static_cast<FakeDelegatedRendererLayerImpl*>(
1546 root_impl->children()[0].get());
1530 1547
1531 const ResourceProvider::ResourceIdMap& map = 1548 const ResourceProvider::ResourceIdMap& map =
1532 host_impl->resource_provider()->GetChildToParentMap( 1549 host_impl->resource_provider()->GetChildToParentMap(
1533 delegated_impl->ChildId()); 1550 delegated_impl->ChildId());
1534 1551
1535 switch (host_impl->active_tree()->source_frame_number()) { 1552 switch (host_impl->active_tree()->source_frame_number()) {
1536 case 1: { 1553 case 1: {
1537 EXPECT_EQ(2u, map.size()); 1554 EXPECT_EQ(2u, map.size());
1538 EXPECT_EQ(1u, map.count(999)); 1555 EXPECT_EQ(1u, map.count(999));
1539 EXPECT_EQ(1u, map.count(555)); 1556 EXPECT_EQ(1u, map.count(555));
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1652 break; 1669 break;
1653 } 1670 }
1654 } 1671 }
1655 1672
1656 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { 1673 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
1657 if (host_impl->active_tree()->source_frame_number() < 1) 1674 if (host_impl->active_tree()->source_frame_number() < 1)
1658 return; 1675 return;
1659 1676
1660 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); 1677 LayerImpl* root_impl = host_impl->active_tree()->root_layer();
1661 FakeDelegatedRendererLayerImpl* delegated_impl = 1678 FakeDelegatedRendererLayerImpl* delegated_impl =
1662 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); 1679 static_cast<FakeDelegatedRendererLayerImpl*>(
1680 root_impl->children()[0].get());
1663 1681
1664 const ResourceProvider::ResourceIdMap& map = 1682 const ResourceProvider::ResourceIdMap& map =
1665 host_impl->resource_provider()->GetChildToParentMap( 1683 host_impl->resource_provider()->GetChildToParentMap(
1666 delegated_impl->ChildId()); 1684 delegated_impl->ChildId());
1667 1685
1668 switch (host_impl->active_tree()->source_frame_number()) { 1686 switch (host_impl->active_tree()->source_frame_number()) {
1669 case 1: 1687 case 1:
1670 EXPECT_EQ(3u, map.size()); 1688 EXPECT_EQ(3u, map.size());
1671 EXPECT_EQ(1u, map.count(999)); 1689 EXPECT_EQ(1u, map.count(999));
1672 EXPECT_EQ(1u, map.count(555)); 1690 EXPECT_EQ(1u, map.count(555));
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
2197 break; 2215 break;
2198 } 2216 }
2199 } 2217 }
2200 2218
2201 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { 2219 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override {
2202 if (host_impl->active_tree()->source_frame_number() < 1) 2220 if (host_impl->active_tree()->source_frame_number() < 1)
2203 return; 2221 return;
2204 2222
2205 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); 2223 LayerImpl* root_impl = host_impl->active_tree()->root_layer();
2206 FakeDelegatedRendererLayerImpl* delegated_impl = 2224 FakeDelegatedRendererLayerImpl* delegated_impl =
2207 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); 2225 static_cast<FakeDelegatedRendererLayerImpl*>(
2226 root_impl->children()[0].get());
2208 const ResourceProvider::ResourceIdMap& map = 2227 const ResourceProvider::ResourceIdMap& map =
2209 host_impl->resource_provider()->GetChildToParentMap( 2228 host_impl->resource_provider()->GetChildToParentMap(
2210 delegated_impl->ChildId()); 2229 delegated_impl->ChildId());
2211 2230
2212 switch (host_impl->active_tree()->source_frame_number()) { 2231 switch (host_impl->active_tree()->source_frame_number()) {
2213 case 1: 2232 case 1:
2214 if (!host_impl->pending_tree()) { 2233 if (!host_impl->pending_tree()) {
2215 // Frame 2 is blocked from activating until another draw happens with 2234 // Frame 2 is blocked from activating until another draw happens with
2216 // Frame 1. This ensures we draw a different active frame from 2235 // Frame 1. This ensures we draw a different active frame from
2217 // what's in the pending tree. 2236 // what's in the pending tree.
(...skipping 26 matching lines...) Expand all
2244 } 2263 }
2245 2264
2246 bool drew_with_pending_tree_; 2265 bool drew_with_pending_tree_;
2247 }; 2266 };
2248 2267
2249 // This test blocks activation which is not supported for single thread mode. 2268 // This test blocks activation which is not supported for single thread mode.
2250 MULTI_THREAD_BLOCKNOTIFY_TEST_F(LayerTreeHostDelegatedTestActiveFrameIsValid); 2269 MULTI_THREAD_BLOCKNOTIFY_TEST_F(LayerTreeHostDelegatedTestActiveFrameIsValid);
2251 2270
2252 } // namespace 2271 } // namespace
2253 } // namespace cc 2272 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_unittest_damage.cc ('k') | cc/trees/layer_tree_host_unittest_occlusion.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698