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

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

Issue 628443002: replace OVERRIDE and FINAL with override and final in cc/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on master Created 6 years, 2 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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 class LayerTreeHostDelegatedTestCaseSingleDelegatedLayer 244 class LayerTreeHostDelegatedTestCaseSingleDelegatedLayer
245 : public LayerTreeHostDelegatedTest, 245 : public LayerTreeHostDelegatedTest,
246 public DelegatedFrameResourceCollectionClient { 246 public DelegatedFrameResourceCollectionClient {
247 public: 247 public:
248 LayerTreeHostDelegatedTestCaseSingleDelegatedLayer() 248 LayerTreeHostDelegatedTestCaseSingleDelegatedLayer()
249 : resource_collection_(new DelegatedFrameResourceCollection), 249 : resource_collection_(new DelegatedFrameResourceCollection),
250 available_(false) { 250 available_(false) {
251 resource_collection_->SetClient(this); 251 resource_collection_->SetClient(this);
252 } 252 }
253 253
254 virtual void SetupTree() OVERRIDE { 254 virtual void SetupTree() override {
255 root_ = Layer::Create(); 255 root_ = Layer::Create();
256 root_->SetBounds(gfx::Size(15, 15)); 256 root_->SetBounds(gfx::Size(15, 15));
257 257
258 layer_tree_host()->SetRootLayer(root_); 258 layer_tree_host()->SetRootLayer(root_);
259 LayerTreeHostDelegatedTest::SetupTree(); 259 LayerTreeHostDelegatedTest::SetupTree();
260 } 260 }
261 261
262 virtual void BeginTest() OVERRIDE { 262 virtual void BeginTest() override {
263 resource_collection_->SetClient(this); 263 resource_collection_->SetClient(this);
264 PostSetNeedsCommitToMainThread(); 264 PostSetNeedsCommitToMainThread();
265 } 265 }
266 266
267 void SetFrameData(scoped_ptr<DelegatedFrameData> frame_data) { 267 void SetFrameData(scoped_ptr<DelegatedFrameData> frame_data) {
268 RenderPass* root_pass = frame_data->render_pass_list.back(); 268 RenderPass* root_pass = frame_data->render_pass_list.back();
269 gfx::Size frame_size = root_pass->output_rect.size(); 269 gfx::Size frame_size = root_pass->output_rect.size();
270 270
271 if (frame_provider_.get() && frame_size == frame_provider_->frame_size()) { 271 if (frame_provider_.get() && frame_size == frame_provider_->frame_size()) {
272 frame_provider_->SetFrameData(frame_data.Pass()); 272 frame_provider_->SetFrameData(frame_data.Pass());
(...skipping 16 matching lines...) Expand all
289 DelegatedFrameProvider* frame_provider) { 289 DelegatedFrameProvider* frame_provider) {
290 scoped_refptr<DelegatedRendererLayer> delegated = 290 scoped_refptr<DelegatedRendererLayer> delegated =
291 FakeDelegatedRendererLayer::Create(frame_provider); 291 FakeDelegatedRendererLayer::Create(frame_provider);
292 delegated->SetBounds(gfx::Size(10, 10)); 292 delegated->SetBounds(gfx::Size(10, 10));
293 delegated->SetIsDrawable(true); 293 delegated->SetIsDrawable(true);
294 294
295 root_->AddChild(delegated); 295 root_->AddChild(delegated);
296 return delegated; 296 return delegated;
297 } 297 }
298 298
299 virtual void AfterTest() OVERRIDE { resource_collection_->SetClient(NULL); } 299 virtual void AfterTest() override { resource_collection_->SetClient(NULL); }
300 300
301 // DelegatedFrameProviderClient implementation. 301 // DelegatedFrameProviderClient implementation.
302 virtual void UnusedResourcesAreAvailable() OVERRIDE { available_ = true; } 302 virtual void UnusedResourcesAreAvailable() override { available_ = true; }
303 303
304 bool TestAndResetAvailable() { 304 bool TestAndResetAvailable() {
305 bool available = available_; 305 bool available = available_;
306 available_ = false; 306 available_ = false;
307 return available; 307 return available;
308 } 308 }
309 309
310 protected: 310 protected:
311 scoped_refptr<DelegatedFrameResourceCollection> resource_collection_; 311 scoped_refptr<DelegatedFrameResourceCollection> resource_collection_;
312 scoped_refptr<DelegatedFrameProvider> frame_provider_; 312 scoped_refptr<DelegatedFrameProvider> frame_provider_;
313 scoped_refptr<Layer> root_; 313 scoped_refptr<Layer> root_;
314 scoped_refptr<DelegatedRendererLayer> delegated_; 314 scoped_refptr<DelegatedRendererLayer> delegated_;
315 bool available_; 315 bool available_;
316 }; 316 };
317 317
318 class LayerTreeHostDelegatedTestCreateChildId 318 class LayerTreeHostDelegatedTestCreateChildId
319 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer { 319 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer {
320 public: 320 public:
321 LayerTreeHostDelegatedTestCreateChildId() 321 LayerTreeHostDelegatedTestCreateChildId()
322 : LayerTreeHostDelegatedTestCaseSingleDelegatedLayer(), 322 : LayerTreeHostDelegatedTestCaseSingleDelegatedLayer(),
323 num_activates_(0), 323 num_activates_(0),
324 did_reset_child_id_(false) {} 324 did_reset_child_id_(false) {}
325 325
326 virtual void DidCommit() OVERRIDE { 326 virtual void DidCommit() override {
327 if (TestEnded()) 327 if (TestEnded())
328 return; 328 return;
329 SetFrameData(CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1))); 329 SetFrameData(CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)));
330 } 330 }
331 331
332 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 332 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
333 if (host_impl->active_tree()->source_frame_number() < 1) 333 if (host_impl->active_tree()->source_frame_number() < 1)
334 return; 334 return;
335 335
336 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); 336 LayerImpl* root_impl = host_impl->active_tree()->root_layer();
337 FakeDelegatedRendererLayerImpl* delegated_impl = 337 FakeDelegatedRendererLayerImpl* delegated_impl =
338 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); 338 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]);
339 339
340 TestContextProvider* context_provider = static_cast<TestContextProvider*>( 340 TestContextProvider* context_provider = static_cast<TestContextProvider*>(
341 host_impl->output_surface()->context_provider()); 341 host_impl->output_surface()->context_provider());
342 342
(...skipping 10 matching lines...) Expand all
353 break; 353 break;
354 case 3: 354 case 3:
355 EXPECT_TRUE(delegated_impl->ChildId()); 355 EXPECT_TRUE(delegated_impl->ChildId());
356 EXPECT_TRUE(did_reset_child_id_); 356 EXPECT_TRUE(did_reset_child_id_);
357 EndTest(); 357 EndTest();
358 break; 358 break;
359 } 359 }
360 } 360 }
361 361
362 virtual void InitializedRendererOnThread(LayerTreeHostImpl* host_impl, 362 virtual void InitializedRendererOnThread(LayerTreeHostImpl* host_impl,
363 bool success) OVERRIDE { 363 bool success) override {
364 EXPECT_TRUE(success); 364 EXPECT_TRUE(success);
365 365
366 if (num_activates_ < 2) 366 if (num_activates_ < 2)
367 return; 367 return;
368 368
369 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); 369 LayerImpl* root_impl = host_impl->active_tree()->root_layer();
370 FakeDelegatedRendererLayerImpl* delegated_impl = 370 FakeDelegatedRendererLayerImpl* delegated_impl =
371 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); 371 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]);
372 372
373 EXPECT_EQ(2, num_activates_); 373 EXPECT_EQ(2, num_activates_);
(...skipping 10 matching lines...) Expand all
384 384
385 // Test that we can gracefully handle invalid frames after the context was lost. 385 // Test that we can gracefully handle invalid frames after the context was lost.
386 // For example, we might be trying to use the previous frame in that case and 386 // For example, we might be trying to use the previous frame in that case and
387 // have to make sure we don't crash because our resource accounting goes wrong. 387 // have to make sure we don't crash because our resource accounting goes wrong.
388 class LayerTreeHostDelegatedTestInvalidFrameAfterContextLost 388 class LayerTreeHostDelegatedTestInvalidFrameAfterContextLost
389 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer { 389 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer {
390 public: 390 public:
391 LayerTreeHostDelegatedTestInvalidFrameAfterContextLost() 391 LayerTreeHostDelegatedTestInvalidFrameAfterContextLost()
392 : num_activates_(0), num_output_surfaces_initialized_(0) {} 392 : num_activates_(0), num_output_surfaces_initialized_(0) {}
393 393
394 virtual void DidCommit() OVERRIDE { 394 virtual void DidCommit() override {
395 if (TestEnded()) 395 if (TestEnded())
396 return; 396 return;
397 scoped_ptr<DelegatedFrameData> frame1 = 397 scoped_ptr<DelegatedFrameData> frame1 =
398 CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); 398 CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1));
399 AddTextureQuad(frame1.get(), 999); 399 AddTextureQuad(frame1.get(), 999);
400 AddTransferableResource(frame1.get(), 999); 400 AddTransferableResource(frame1.get(), 999);
401 SetFrameData(frame1.Pass()); 401 SetFrameData(frame1.Pass());
402 } 402 }
403 403
404 virtual void DidInitializeOutputSurface() OVERRIDE { 404 virtual void DidInitializeOutputSurface() override {
405 if (!num_output_surfaces_initialized_++) 405 if (!num_output_surfaces_initialized_++)
406 return; 406 return;
407 407
408 scoped_refptr<DelegatedRendererLayer> old_delegated = delegated_; 408 scoped_refptr<DelegatedRendererLayer> old_delegated = delegated_;
409 SetFrameData( 409 SetFrameData(
410 CreateInvalidFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1))); 410 CreateInvalidFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)));
411 // Make sure we end up using the same layer, or we won't test the right 411 // Make sure we end up using the same layer, or we won't test the right
412 // thing, which is to make sure we can handle an invalid frame when using 412 // thing, which is to make sure we can handle an invalid frame when using
413 // a stale layer from before the context was lost. 413 // a stale layer from before the context was lost.
414 DCHECK(delegated_.get() == old_delegated.get()); 414 DCHECK(delegated_.get() == old_delegated.get());
415 } 415 }
416 416
417 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 417 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
418 if (host_impl->active_tree()->source_frame_number() < 1) 418 if (host_impl->active_tree()->source_frame_number() < 1)
419 return; 419 return;
420 420
421 TestContextProvider* context_provider = static_cast<TestContextProvider*>( 421 TestContextProvider* context_provider = static_cast<TestContextProvider*>(
422 host_impl->output_surface()->context_provider()); 422 host_impl->output_surface()->context_provider());
423 423
424 ++num_activates_; 424 ++num_activates_;
425 switch (num_activates_) { 425 switch (num_activates_) {
426 case 2: 426 case 2:
427 context_provider->ContextGL()->LoseContextCHROMIUM( 427 context_provider->ContextGL()->LoseContextCHROMIUM(
428 GL_GUILTY_CONTEXT_RESET_ARB, 428 GL_GUILTY_CONTEXT_RESET_ARB,
429 GL_INNOCENT_CONTEXT_RESET_ARB); 429 GL_INNOCENT_CONTEXT_RESET_ARB);
430 break; 430 break;
431 case 3: 431 case 3:
432 EndTest(); 432 EndTest();
433 break; 433 break;
434 } 434 }
435 } 435 }
436 436
437 virtual void InitializedRendererOnThread(LayerTreeHostImpl* host_impl, 437 virtual void InitializedRendererOnThread(LayerTreeHostImpl* host_impl,
438 bool success) OVERRIDE { 438 bool success) override {
439 EXPECT_TRUE(success); 439 EXPECT_TRUE(success);
440 440
441 if (num_activates_ < 2) 441 if (num_activates_ < 2)
442 return; 442 return;
443 443
444 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); 444 LayerImpl* root_impl = host_impl->active_tree()->root_layer();
445 FakeDelegatedRendererLayerImpl* delegated_impl = 445 FakeDelegatedRendererLayerImpl* delegated_impl =
446 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); 446 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]);
447 447
448 EXPECT_EQ(2, num_activates_); 448 EXPECT_EQ(2, num_activates_);
449 // Resources should have gotten cleared after the context was lost. 449 // Resources should have gotten cleared after the context was lost.
450 EXPECT_EQ(0U, delegated_impl->Resources().size()); 450 EXPECT_EQ(0U, delegated_impl->Resources().size());
451 } 451 }
452 452
453 virtual void AfterTest() OVERRIDE { 453 virtual void AfterTest() override {
454 LayerTreeHostDelegatedTestCaseSingleDelegatedLayer::AfterTest(); 454 LayerTreeHostDelegatedTestCaseSingleDelegatedLayer::AfterTest();
455 EXPECT_EQ(2, num_output_surfaces_initialized_); 455 EXPECT_EQ(2, num_output_surfaces_initialized_);
456 } 456 }
457 457
458 protected: 458 protected:
459 int num_activates_; 459 int num_activates_;
460 int num_output_surfaces_initialized_; 460 int num_output_surfaces_initialized_;
461 }; 461 };
462 462
463 SINGLE_AND_MULTI_THREAD_TEST_F( 463 SINGLE_AND_MULTI_THREAD_TEST_F(
464 LayerTreeHostDelegatedTestInvalidFrameAfterContextLost); 464 LayerTreeHostDelegatedTestInvalidFrameAfterContextLost);
465 465
466 class LayerTreeHostDelegatedTestLayerUsesFrameDamage 466 class LayerTreeHostDelegatedTestLayerUsesFrameDamage
467 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer { 467 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer {
468 public: 468 public:
469 LayerTreeHostDelegatedTestLayerUsesFrameDamage() 469 LayerTreeHostDelegatedTestLayerUsesFrameDamage()
470 : LayerTreeHostDelegatedTestCaseSingleDelegatedLayer(), 470 : LayerTreeHostDelegatedTestCaseSingleDelegatedLayer(),
471 first_draw_for_source_frame_(true) {} 471 first_draw_for_source_frame_(true) {}
472 472
473 virtual void DidCommit() OVERRIDE { 473 virtual void DidCommit() override {
474 int next_source_frame_number = layer_tree_host()->source_frame_number(); 474 int next_source_frame_number = layer_tree_host()->source_frame_number();
475 switch (next_source_frame_number) { 475 switch (next_source_frame_number) {
476 case 1: 476 case 1:
477 // The first time the layer gets a frame the whole layer should be 477 // The first time the layer gets a frame the whole layer should be
478 // damaged. 478 // damaged.
479 SetFrameData( 479 SetFrameData(
480 CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1))); 480 CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)));
481 break; 481 break;
482 case 2: 482 case 2:
483 // A different frame size will damage the whole layer. 483 // A different frame size will damage the whole layer.
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 SetFrameData( 576 SetFrameData(
577 CreateFrameData(gfx::Rect(0, 0, 10, 10), gfx::Rect(3, 3, 1, 1))); 577 CreateFrameData(gfx::Rect(0, 0, 10, 10), gfx::Rect(3, 3, 1, 1)));
578 break; 578 break;
579 } 579 }
580 first_draw_for_source_frame_ = true; 580 first_draw_for_source_frame_ = true;
581 } 581 }
582 582
583 virtual DrawResult PrepareToDrawOnThread( 583 virtual DrawResult PrepareToDrawOnThread(
584 LayerTreeHostImpl* host_impl, 584 LayerTreeHostImpl* host_impl,
585 LayerTreeHostImpl::FrameData* frame, 585 LayerTreeHostImpl::FrameData* frame,
586 DrawResult draw_result) OVERRIDE { 586 DrawResult draw_result) override {
587 EXPECT_EQ(DRAW_SUCCESS, draw_result); 587 EXPECT_EQ(DRAW_SUCCESS, draw_result);
588 588
589 if (!first_draw_for_source_frame_) 589 if (!first_draw_for_source_frame_)
590 return draw_result; 590 return draw_result;
591 591
592 gfx::Rect damage_rect; 592 gfx::Rect damage_rect;
593 if (!frame->has_no_damage) { 593 if (!frame->has_no_damage) {
594 damage_rect = frame->render_passes.back()->damage_rect; 594 damage_rect = frame->render_passes.back()->damage_rect;
595 } else { 595 } else {
596 // If there is no damage, then we have no render passes to send. 596 // If there is no damage, then we have no render passes to send.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 protected: 667 protected:
668 scoped_refptr<DelegatedRendererLayer> delegated_copy_; 668 scoped_refptr<DelegatedRendererLayer> delegated_copy_;
669 bool first_draw_for_source_frame_; 669 bool first_draw_for_source_frame_;
670 }; 670 };
671 671
672 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDelegatedTestLayerUsesFrameDamage); 672 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDelegatedTestLayerUsesFrameDamage);
673 673
674 class LayerTreeHostDelegatedTestMergeResources 674 class LayerTreeHostDelegatedTestMergeResources
675 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer { 675 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer {
676 public: 676 public:
677 virtual void BeginTest() OVERRIDE { 677 virtual void BeginTest() override {
678 // Push two frames to the delegated renderer layer with no commit between. 678 // Push two frames to the delegated renderer layer with no commit between.
679 679
680 // The first frame has resource 999. 680 // The first frame has resource 999.
681 scoped_ptr<DelegatedFrameData> frame1 = 681 scoped_ptr<DelegatedFrameData> frame1 =
682 CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); 682 CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1));
683 AddTextureQuad(frame1.get(), 999); 683 AddTextureQuad(frame1.get(), 999);
684 AddTransferableResource(frame1.get(), 999); 684 AddTransferableResource(frame1.get(), 999);
685 SetFrameData(frame1.Pass()); 685 SetFrameData(frame1.Pass());
686 686
687 // The second frame uses resource 999 still, but also adds 555. 687 // The second frame uses resource 999 still, but also adds 555.
(...skipping 12 matching lines...) Expand all
700 &returned_resources); 700 &returned_resources);
701 { 701 {
702 unsigned expected[] = {999}; 702 unsigned expected[] = {999};
703 EXPECT_RESOURCES(expected, returned_resources); 703 EXPECT_RESOURCES(expected, returned_resources);
704 EXPECT_TRUE(TestAndResetAvailable()); 704 EXPECT_TRUE(TestAndResetAvailable());
705 } 705 }
706 706
707 PostSetNeedsCommitToMainThread(); 707 PostSetNeedsCommitToMainThread();
708 } 708 }
709 709
710 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 710 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
711 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); 711 LayerImpl* root_impl = host_impl->active_tree()->root_layer();
712 FakeDelegatedRendererLayerImpl* delegated_impl = 712 FakeDelegatedRendererLayerImpl* delegated_impl =
713 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); 713 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]);
714 714
715 const ResourceProvider::ResourceIdMap& map = 715 const ResourceProvider::ResourceIdMap& map =
716 host_impl->resource_provider()->GetChildToParentMap( 716 host_impl->resource_provider()->GetChildToParentMap(
717 delegated_impl->ChildId()); 717 delegated_impl->ChildId());
718 718
719 // Both frames' resources should be in the parent's resource provider. 719 // Both frames' resources should be in the parent's resource provider.
720 EXPECT_EQ(2u, map.size()); 720 EXPECT_EQ(2u, map.size());
721 EXPECT_EQ(1u, map.count(999)); 721 EXPECT_EQ(1u, map.count(999));
722 EXPECT_EQ(1u, map.count(555)); 722 EXPECT_EQ(1u, map.count(555));
723 723
724 EXPECT_EQ(2u, delegated_impl->Resources().size()); 724 EXPECT_EQ(2u, delegated_impl->Resources().size());
725 EXPECT_EQ(1u, delegated_impl->Resources().count(999)); 725 EXPECT_EQ(1u, delegated_impl->Resources().count(999));
726 EXPECT_EQ(1u, delegated_impl->Resources().count(555)); 726 EXPECT_EQ(1u, delegated_impl->Resources().count(555));
727 727
728 EndTest(); 728 EndTest();
729 } 729 }
730 }; 730 };
731 731
732 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDelegatedTestMergeResources); 732 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDelegatedTestMergeResources);
733 733
734 class LayerTreeHostDelegatedTestRemapResourcesInQuads 734 class LayerTreeHostDelegatedTestRemapResourcesInQuads
735 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer { 735 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer {
736 public: 736 public:
737 virtual void BeginTest() OVERRIDE { 737 virtual void BeginTest() override {
738 // Generate a frame with two resources in it. 738 // Generate a frame with two resources in it.
739 scoped_ptr<DelegatedFrameData> frame = 739 scoped_ptr<DelegatedFrameData> frame =
740 CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); 740 CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1));
741 AddTextureQuad(frame.get(), 999); 741 AddTextureQuad(frame.get(), 999);
742 AddTransferableResource(frame.get(), 999); 742 AddTransferableResource(frame.get(), 999);
743 AddTextureQuad(frame.get(), 555); 743 AddTextureQuad(frame.get(), 555);
744 AddTransferableResource(frame.get(), 555); 744 AddTransferableResource(frame.get(), 555);
745 SetFrameData(frame.Pass()); 745 SetFrameData(frame.Pass());
746 746
747 PostSetNeedsCommitToMainThread(); 747 PostSetNeedsCommitToMainThread();
748 } 748 }
749 749
750 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 750 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
751 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); 751 LayerImpl* root_impl = host_impl->active_tree()->root_layer();
752 FakeDelegatedRendererLayerImpl* delegated_impl = 752 FakeDelegatedRendererLayerImpl* delegated_impl =
753 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); 753 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]);
754 754
755 const ResourceProvider::ResourceIdMap& map = 755 const ResourceProvider::ResourceIdMap& map =
756 host_impl->resource_provider()->GetChildToParentMap( 756 host_impl->resource_provider()->GetChildToParentMap(
757 delegated_impl->ChildId()); 757 delegated_impl->ChildId());
758 758
759 // The frame's resource should be in the parent's resource provider. 759 // The frame's resource should be in the parent's resource provider.
760 EXPECT_EQ(2u, map.size()); 760 EXPECT_EQ(2u, map.size());
(...skipping 15 matching lines...) Expand all
776 776
777 EndTest(); 777 EndTest();
778 } 778 }
779 }; 779 };
780 780
781 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDelegatedTestRemapResourcesInQuads); 781 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDelegatedTestRemapResourcesInQuads);
782 782
783 class LayerTreeHostDelegatedTestReturnUnusedResources 783 class LayerTreeHostDelegatedTestReturnUnusedResources
784 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer { 784 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer {
785 public: 785 public:
786 virtual void BeginTest() OVERRIDE { 786 virtual void BeginTest() override {
787 PostSetNeedsCommitToMainThread(); 787 PostSetNeedsCommitToMainThread();
788 } 788 }
789 789
790 virtual void DidCommitAndDrawFrame() OVERRIDE { 790 virtual void DidCommitAndDrawFrame() override {
791 scoped_ptr<DelegatedFrameData> frame; 791 scoped_ptr<DelegatedFrameData> frame;
792 ReturnedResourceArray resources; 792 ReturnedResourceArray resources;
793 793
794 int next_source_frame_number = layer_tree_host()->source_frame_number(); 794 int next_source_frame_number = layer_tree_host()->source_frame_number();
795 switch (next_source_frame_number) { 795 switch (next_source_frame_number) {
796 case 1: 796 case 1:
797 // Generate a frame with two resources in it. 797 // Generate a frame with two resources in it.
798 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); 798 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1));
799 AddTextureQuad(frame.get(), 999); 799 AddTextureQuad(frame.get(), 999);
800 AddTransferableResource(frame.get(), 999); 800 AddTransferableResource(frame.get(), 999);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 849
850 // Resources are never immediately released. 850 // Resources are never immediately released.
851 ReturnedResourceArray empty_resources; 851 ReturnedResourceArray empty_resources;
852 resource_collection_->TakeUnusedResourcesForChildCompositor( 852 resource_collection_->TakeUnusedResourcesForChildCompositor(
853 &empty_resources); 853 &empty_resources);
854 EXPECT_EQ(0u, empty_resources.size()); 854 EXPECT_EQ(0u, empty_resources.size());
855 EXPECT_FALSE(TestAndResetAvailable()); 855 EXPECT_FALSE(TestAndResetAvailable());
856 } 856 }
857 857
858 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, 858 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl,
859 bool result) OVERRIDE { 859 bool result) override {
860 ReturnUnusedResourcesFromParent(host_impl); 860 ReturnUnusedResourcesFromParent(host_impl);
861 } 861 }
862 }; 862 };
863 863
864 SINGLE_AND_MULTI_THREAD_TEST_F( 864 SINGLE_AND_MULTI_THREAD_TEST_F(
865 LayerTreeHostDelegatedTestReturnUnusedResources); 865 LayerTreeHostDelegatedTestReturnUnusedResources);
866 866
867 class LayerTreeHostDelegatedTestReusedResources 867 class LayerTreeHostDelegatedTestReusedResources
868 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer { 868 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer {
869 public: 869 public:
870 virtual void BeginTest() OVERRIDE { 870 virtual void BeginTest() override {
871 PostSetNeedsCommitToMainThread(); 871 PostSetNeedsCommitToMainThread();
872 } 872 }
873 873
874 virtual void DidCommitAndDrawFrame() OVERRIDE { 874 virtual void DidCommitAndDrawFrame() override {
875 scoped_ptr<DelegatedFrameData> frame; 875 scoped_ptr<DelegatedFrameData> frame;
876 ReturnedResourceArray resources; 876 ReturnedResourceArray resources;
877 877
878 int next_source_frame_number = layer_tree_host()->source_frame_number(); 878 int next_source_frame_number = layer_tree_host()->source_frame_number();
879 switch (next_source_frame_number) { 879 switch (next_source_frame_number) {
880 case 1: 880 case 1:
881 // Generate a frame with some resources in it. 881 // Generate a frame with some resources in it.
882 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); 882 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1));
883 AddTextureQuad(frame.get(), 999); 883 AddTextureQuad(frame.get(), 999);
884 AddTransferableResource(frame.get(), 999); 884 AddTransferableResource(frame.get(), 999);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 unsigned expected[] = {999, 999}; 921 unsigned expected[] = {999, 999};
922 EXPECT_RESOURCES(expected, resources); 922 EXPECT_RESOURCES(expected, resources);
923 EXPECT_TRUE(TestAndResetAvailable()); 923 EXPECT_TRUE(TestAndResetAvailable());
924 } 924 }
925 EndTest(); 925 EndTest();
926 break; 926 break;
927 } 927 }
928 } 928 }
929 929
930 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, 930 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl,
931 bool result) OVERRIDE { 931 bool result) override {
932 ReturnUnusedResourcesFromParent(host_impl); 932 ReturnUnusedResourcesFromParent(host_impl);
933 } 933 }
934 }; 934 };
935 935
936 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDelegatedTestReusedResources); 936 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDelegatedTestReusedResources);
937 937
938 class LayerTreeHostDelegatedTestFrameBeforeAck 938 class LayerTreeHostDelegatedTestFrameBeforeAck
939 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer { 939 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer {
940 public: 940 public:
941 virtual void BeginTest() OVERRIDE { 941 virtual void BeginTest() override {
942 PostSetNeedsCommitToMainThread(); 942 PostSetNeedsCommitToMainThread();
943 } 943 }
944 944
945 virtual void DidCommitAndDrawFrame() OVERRIDE { 945 virtual void DidCommitAndDrawFrame() override {
946 scoped_ptr<DelegatedFrameData> frame; 946 scoped_ptr<DelegatedFrameData> frame;
947 ReturnedResourceArray resources; 947 ReturnedResourceArray resources;
948 948
949 int next_source_frame_number = layer_tree_host()->source_frame_number(); 949 int next_source_frame_number = layer_tree_host()->source_frame_number();
950 switch (next_source_frame_number) { 950 switch (next_source_frame_number) {
951 case 1: 951 case 1:
952 // Generate a frame with some resources in it. 952 // Generate a frame with some resources in it.
953 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); 953 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1));
954 AddTextureQuad(frame.get(), 999); 954 AddTextureQuad(frame.get(), 999);
955 AddTransferableResource(frame.get(), 999); 955 AddTransferableResource(frame.get(), 999);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
990 // frame. 990 // frame.
991 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); 991 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1));
992 AddTextureQuad(frame.get(), 999); 992 AddTextureQuad(frame.get(), 999);
993 AddTextureQuad(frame.get(), 555); 993 AddTextureQuad(frame.get(), 555);
994 AddTextureQuad(frame.get(), 444); 994 AddTextureQuad(frame.get(), 444);
995 SetFrameData(frame.Pass()); 995 SetFrameData(frame.Pass());
996 break; 996 break;
997 } 997 }
998 } 998 }
999 999
1000 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 1000 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
1001 if (host_impl->active_tree()->source_frame_number() != 3) 1001 if (host_impl->active_tree()->source_frame_number() != 3)
1002 return; 1002 return;
1003 1003
1004 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); 1004 LayerImpl* root_impl = host_impl->active_tree()->root_layer();
1005 FakeDelegatedRendererLayerImpl* delegated_impl = 1005 FakeDelegatedRendererLayerImpl* delegated_impl =
1006 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); 1006 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]);
1007 1007
1008 const ResourceProvider::ResourceIdMap& map = 1008 const ResourceProvider::ResourceIdMap& map =
1009 host_impl->resource_provider()->GetChildToParentMap( 1009 host_impl->resource_provider()->GetChildToParentMap(
1010 delegated_impl->ChildId()); 1010 delegated_impl->ChildId());
(...skipping 10 matching lines...) Expand all
1021 const RenderPass* pass = delegated_impl->RenderPassesInDrawOrder()[0]; 1021 const RenderPass* pass = delegated_impl->RenderPassesInDrawOrder()[0];
1022 EXPECT_EQ(1u, pass->quad_list.size()); 1022 EXPECT_EQ(1u, pass->quad_list.size());
1023 const TextureDrawQuad* quad = 1023 const TextureDrawQuad* quad =
1024 TextureDrawQuad::MaterialCast(pass->quad_list.front()); 1024 TextureDrawQuad::MaterialCast(pass->quad_list.front());
1025 EXPECT_EQ(map.find(999)->second, quad->resource_id); 1025 EXPECT_EQ(map.find(999)->second, quad->resource_id);
1026 1026
1027 EndTest(); 1027 EndTest();
1028 } 1028 }
1029 1029
1030 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, 1030 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl,
1031 bool result) OVERRIDE { 1031 bool result) override {
1032 ReturnUnusedResourcesFromParent(host_impl); 1032 ReturnUnusedResourcesFromParent(host_impl);
1033 } 1033 }
1034 }; 1034 };
1035 1035
1036 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDelegatedTestFrameBeforeAck); 1036 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDelegatedTestFrameBeforeAck);
1037 1037
1038 class LayerTreeHostDelegatedTestFrameBeforeTakeResources 1038 class LayerTreeHostDelegatedTestFrameBeforeTakeResources
1039 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer { 1039 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer {
1040 public: 1040 public:
1041 virtual void BeginTest() OVERRIDE { 1041 virtual void BeginTest() override {
1042 PostSetNeedsCommitToMainThread(); 1042 PostSetNeedsCommitToMainThread();
1043 } 1043 }
1044 1044
1045 virtual void DidCommitAndDrawFrame() OVERRIDE { 1045 virtual void DidCommitAndDrawFrame() override {
1046 scoped_ptr<DelegatedFrameData> frame; 1046 scoped_ptr<DelegatedFrameData> frame;
1047 ReturnedResourceArray resources; 1047 ReturnedResourceArray resources;
1048 1048
1049 int next_source_frame_number = layer_tree_host()->source_frame_number(); 1049 int next_source_frame_number = layer_tree_host()->source_frame_number();
1050 switch (next_source_frame_number) { 1050 switch (next_source_frame_number) {
1051 case 1: 1051 case 1:
1052 // Generate a frame with some resources in it. 1052 // Generate a frame with some resources in it.
1053 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); 1053 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1));
1054 AddTextureQuad(frame.get(), 999); 1054 AddTextureQuad(frame.get(), 999);
1055 AddTransferableResource(frame.get(), 999); 1055 AddTransferableResource(frame.get(), 999);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 break; 1102 break;
1103 case 4: 1103 case 4:
1104 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); 1104 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources);
1105 EXPECT_EQ(0u, resources.size()); 1105 EXPECT_EQ(0u, resources.size());
1106 EXPECT_FALSE(TestAndResetAvailable()); 1106 EXPECT_FALSE(TestAndResetAvailable());
1107 EndTest(); 1107 EndTest();
1108 break; 1108 break;
1109 } 1109 }
1110 } 1110 }
1111 1111
1112 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 1112 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
1113 if (host_impl->active_tree()->source_frame_number() != 3) 1113 if (host_impl->active_tree()->source_frame_number() != 3)
1114 return; 1114 return;
1115 1115
1116 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); 1116 LayerImpl* root_impl = host_impl->active_tree()->root_layer();
1117 FakeDelegatedRendererLayerImpl* delegated_impl = 1117 FakeDelegatedRendererLayerImpl* delegated_impl =
1118 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); 1118 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]);
1119 1119
1120 const ResourceProvider::ResourceIdMap& map = 1120 const ResourceProvider::ResourceIdMap& map =
1121 host_impl->resource_provider()->GetChildToParentMap( 1121 host_impl->resource_provider()->GetChildToParentMap(
1122 delegated_impl->ChildId()); 1122 delegated_impl->ChildId());
(...skipping 17 matching lines...) Expand all
1140 EXPECT_EQ(map.find(999)->second, quad1->resource_id); 1140 EXPECT_EQ(map.find(999)->second, quad1->resource_id);
1141 const TextureDrawQuad* quad2 = 1141 const TextureDrawQuad* quad2 =
1142 TextureDrawQuad::MaterialCast(pass->quad_list.ElementAt(1)); 1142 TextureDrawQuad::MaterialCast(pass->quad_list.ElementAt(1));
1143 EXPECT_EQ(map.find(555)->second, quad2->resource_id); 1143 EXPECT_EQ(map.find(555)->second, quad2->resource_id);
1144 const TextureDrawQuad* quad3 = 1144 const TextureDrawQuad* quad3 =
1145 TextureDrawQuad::MaterialCast(pass->quad_list.ElementAt(2)); 1145 TextureDrawQuad::MaterialCast(pass->quad_list.ElementAt(2));
1146 EXPECT_EQ(map.find(444)->second, quad3->resource_id); 1146 EXPECT_EQ(map.find(444)->second, quad3->resource_id);
1147 } 1147 }
1148 1148
1149 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, 1149 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl,
1150 bool result) OVERRIDE { 1150 bool result) override {
1151 ReturnUnusedResourcesFromParent(host_impl); 1151 ReturnUnusedResourcesFromParent(host_impl);
1152 } 1152 }
1153 }; 1153 };
1154 1154
1155 SINGLE_AND_MULTI_THREAD_TEST_F( 1155 SINGLE_AND_MULTI_THREAD_TEST_F(
1156 LayerTreeHostDelegatedTestFrameBeforeTakeResources); 1156 LayerTreeHostDelegatedTestFrameBeforeTakeResources);
1157 1157
1158 class LayerTreeHostDelegatedTestBadFrame 1158 class LayerTreeHostDelegatedTestBadFrame
1159 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer { 1159 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer {
1160 public: 1160 public:
1161 virtual void BeginTest() OVERRIDE { 1161 virtual void BeginTest() override {
1162 PostSetNeedsCommitToMainThread(); 1162 PostSetNeedsCommitToMainThread();
1163 } 1163 }
1164 1164
1165 virtual void DidCommitAndDrawFrame() OVERRIDE { 1165 virtual void DidCommitAndDrawFrame() override {
1166 scoped_ptr<DelegatedFrameData> frame; 1166 scoped_ptr<DelegatedFrameData> frame;
1167 ReturnedResourceArray resources; 1167 ReturnedResourceArray resources;
1168 1168
1169 int next_source_frame_number = layer_tree_host()->source_frame_number(); 1169 int next_source_frame_number = layer_tree_host()->source_frame_number();
1170 switch (next_source_frame_number) { 1170 switch (next_source_frame_number) {
1171 case 1: 1171 case 1:
1172 // Generate a frame with some resources in it. 1172 // Generate a frame with some resources in it.
1173 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); 1173 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1));
1174 AddTextureQuad(frame.get(), 999); 1174 AddTextureQuad(frame.get(), 999);
1175 AddTransferableResource(frame.get(), 999); 1175 AddTransferableResource(frame.get(), 999);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1223 EXPECT_RESOURCES(expected, resources); 1223 EXPECT_RESOURCES(expected, resources);
1224 EXPECT_TRUE(TestAndResetAvailable()); 1224 EXPECT_TRUE(TestAndResetAvailable());
1225 } 1225 }
1226 1226
1227 EndTest(); 1227 EndTest();
1228 break; 1228 break;
1229 } 1229 }
1230 } 1230 }
1231 1231
1232 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, 1232 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl,
1233 bool result) OVERRIDE { 1233 bool result) override {
1234 if (host_impl->active_tree()->source_frame_number() < 1) 1234 if (host_impl->active_tree()->source_frame_number() < 1)
1235 return; 1235 return;
1236 1236
1237 ReturnUnusedResourcesFromParent(host_impl); 1237 ReturnUnusedResourcesFromParent(host_impl);
1238 1238
1239 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); 1239 LayerImpl* root_impl = host_impl->active_tree()->root_layer();
1240 FakeDelegatedRendererLayerImpl* delegated_impl = 1240 FakeDelegatedRendererLayerImpl* delegated_impl =
1241 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); 1241 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]);
1242 1242
1243 const ResourceProvider::ResourceIdMap& map = 1243 const ResourceProvider::ResourceIdMap& map =
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1305 } 1305 }
1306 } 1306 }
1307 } 1307 }
1308 }; 1308 };
1309 1309
1310 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDelegatedTestBadFrame); 1310 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDelegatedTestBadFrame);
1311 1311
1312 class LayerTreeHostDelegatedTestUnnamedResource 1312 class LayerTreeHostDelegatedTestUnnamedResource
1313 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer { 1313 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer {
1314 public: 1314 public:
1315 virtual void BeginTest() OVERRIDE { 1315 virtual void BeginTest() override {
1316 PostSetNeedsCommitToMainThread(); 1316 PostSetNeedsCommitToMainThread();
1317 } 1317 }
1318 1318
1319 virtual void DidCommit() OVERRIDE { 1319 virtual void DidCommit() override {
1320 scoped_ptr<DelegatedFrameData> frame; 1320 scoped_ptr<DelegatedFrameData> frame;
1321 ReturnedResourceArray resources; 1321 ReturnedResourceArray resources;
1322 1322
1323 int next_source_frame_number = layer_tree_host()->source_frame_number(); 1323 int next_source_frame_number = layer_tree_host()->source_frame_number();
1324 switch (next_source_frame_number) { 1324 switch (next_source_frame_number) {
1325 case 1: 1325 case 1:
1326 // This frame includes two resources in it, but only uses one. 1326 // This frame includes two resources in it, but only uses one.
1327 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); 1327 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1));
1328 AddTransferableResource(frame.get(), 999); 1328 AddTransferableResource(frame.get(), 999);
1329 AddTextureQuad(frame.get(), 555); 1329 AddTextureQuad(frame.get(), 555);
(...skipping 15 matching lines...) Expand all
1345 unsigned expected[] = {999}; 1345 unsigned expected[] = {999};
1346 EXPECT_RESOURCES(expected, resources); 1346 EXPECT_RESOURCES(expected, resources);
1347 EXPECT_TRUE(TestAndResetAvailable()); 1347 EXPECT_TRUE(TestAndResetAvailable());
1348 } 1348 }
1349 1349
1350 EndTest(); 1350 EndTest();
1351 break; 1351 break;
1352 } 1352 }
1353 } 1353 }
1354 1354
1355 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 1355 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
1356 if (host_impl->active_tree()->source_frame_number() != 1) 1356 if (host_impl->active_tree()->source_frame_number() != 1)
1357 return; 1357 return;
1358 1358
1359 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); 1359 LayerImpl* root_impl = host_impl->active_tree()->root_layer();
1360 FakeDelegatedRendererLayerImpl* delegated_impl = 1360 FakeDelegatedRendererLayerImpl* delegated_impl =
1361 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); 1361 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]);
1362 1362
1363 const ResourceProvider::ResourceIdMap& map = 1363 const ResourceProvider::ResourceIdMap& map =
1364 host_impl->resource_provider()->GetChildToParentMap( 1364 host_impl->resource_provider()->GetChildToParentMap(
1365 delegated_impl->ChildId()); 1365 delegated_impl->ChildId());
1366 1366
1367 // The layer only held on to the resource that was used. 1367 // The layer only held on to the resource that was used.
1368 EXPECT_EQ(1u, map.size()); 1368 EXPECT_EQ(1u, map.size());
1369 EXPECT_EQ(1u, map.count(555)); 1369 EXPECT_EQ(1u, map.count(555));
1370 1370
1371 EXPECT_EQ(1u, delegated_impl->Resources().size()); 1371 EXPECT_EQ(1u, delegated_impl->Resources().size());
1372 EXPECT_EQ(1u, delegated_impl->Resources().count(555)); 1372 EXPECT_EQ(1u, delegated_impl->Resources().count(555));
1373 } 1373 }
1374 }; 1374 };
1375 1375
1376 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDelegatedTestUnnamedResource); 1376 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDelegatedTestUnnamedResource);
1377 1377
1378 class LayerTreeHostDelegatedTestDontLeakResource 1378 class LayerTreeHostDelegatedTestDontLeakResource
1379 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer { 1379 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer {
1380 public: 1380 public:
1381 virtual void BeginTest() OVERRIDE { 1381 virtual void BeginTest() override {
1382 PostSetNeedsCommitToMainThread(); 1382 PostSetNeedsCommitToMainThread();
1383 } 1383 }
1384 1384
1385 virtual void DidCommitAndDrawFrame() OVERRIDE { 1385 virtual void DidCommitAndDrawFrame() override {
1386 scoped_ptr<DelegatedFrameData> frame; 1386 scoped_ptr<DelegatedFrameData> frame;
1387 ReturnedResourceArray resources; 1387 ReturnedResourceArray resources;
1388 1388
1389 int next_source_frame_number = layer_tree_host()->source_frame_number(); 1389 int next_source_frame_number = layer_tree_host()->source_frame_number();
1390 switch (next_source_frame_number) { 1390 switch (next_source_frame_number) {
1391 case 1: 1391 case 1:
1392 // This frame includes two resources in it. 1392 // This frame includes two resources in it.
1393 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); 1393 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1));
1394 AddTextureQuad(frame.get(), 999); 1394 AddTextureQuad(frame.get(), 999);
1395 AddTransferableResource(frame.get(), 999); 1395 AddTransferableResource(frame.get(), 999);
(...skipping 27 matching lines...) Expand all
1423 { 1423 {
1424 unsigned expected[] = {555}; 1424 unsigned expected[] = {555};
1425 EXPECT_RESOURCES(expected, resources); 1425 EXPECT_RESOURCES(expected, resources);
1426 EXPECT_TRUE(TestAndResetAvailable()); 1426 EXPECT_TRUE(TestAndResetAvailable());
1427 } 1427 }
1428 EndTest(); 1428 EndTest();
1429 break; 1429 break;
1430 } 1430 }
1431 } 1431 }
1432 1432
1433 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 1433 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
1434 if (host_impl->active_tree()->source_frame_number() != 1) 1434 if (host_impl->active_tree()->source_frame_number() != 1)
1435 return; 1435 return;
1436 1436
1437 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); 1437 LayerImpl* root_impl = host_impl->active_tree()->root_layer();
1438 FakeDelegatedRendererLayerImpl* delegated_impl = 1438 FakeDelegatedRendererLayerImpl* delegated_impl =
1439 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); 1439 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]);
1440 1440
1441 const ResourceProvider::ResourceIdMap& map = 1441 const ResourceProvider::ResourceIdMap& map =
1442 host_impl->resource_provider()->GetChildToParentMap( 1442 host_impl->resource_provider()->GetChildToParentMap(
1443 delegated_impl->ChildId()); 1443 delegated_impl->ChildId());
1444 1444
1445 // The layer only held on to the resource that was used. 1445 // The layer only held on to the resource that was used.
1446 EXPECT_EQ(1u, map.size()); 1446 EXPECT_EQ(1u, map.size());
1447 EXPECT_EQ(1u, map.count(555)); 1447 EXPECT_EQ(1u, map.count(555));
1448 1448
1449 EXPECT_EQ(1u, delegated_impl->Resources().size()); 1449 EXPECT_EQ(1u, delegated_impl->Resources().size());
1450 EXPECT_EQ(1u, delegated_impl->Resources().count(555)); 1450 EXPECT_EQ(1u, delegated_impl->Resources().count(555));
1451 } 1451 }
1452 1452
1453 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, 1453 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl,
1454 bool result) OVERRIDE { 1454 bool result) override {
1455 ReturnUnusedResourcesFromParent(host_impl); 1455 ReturnUnusedResourcesFromParent(host_impl);
1456 } 1456 }
1457 }; 1457 };
1458 1458
1459 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDelegatedTestDontLeakResource); 1459 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDelegatedTestDontLeakResource);
1460 1460
1461 class LayerTreeHostDelegatedTestResourceSentToParent 1461 class LayerTreeHostDelegatedTestResourceSentToParent
1462 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer { 1462 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer {
1463 public: 1463 public:
1464 virtual void DidCommitAndDrawFrame() OVERRIDE { 1464 virtual void DidCommitAndDrawFrame() override {
1465 scoped_ptr<DelegatedFrameData> frame; 1465 scoped_ptr<DelegatedFrameData> frame;
1466 ReturnedResourceArray resources; 1466 ReturnedResourceArray resources;
1467 1467
1468 int next_source_frame_number = layer_tree_host()->source_frame_number(); 1468 int next_source_frame_number = layer_tree_host()->source_frame_number();
1469 switch (next_source_frame_number) { 1469 switch (next_source_frame_number) {
1470 case 1: 1470 case 1:
1471 // This frame includes two resources in it. 1471 // This frame includes two resources in it.
1472 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); 1472 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1));
1473 AddTextureQuad(frame.get(), 999); 1473 AddTextureQuad(frame.get(), 999);
1474 AddTransferableResource(frame.get(), 999); 1474 AddTransferableResource(frame.get(), 999);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1509 const ResourceProvider::ResourceIdMap& map = 1509 const ResourceProvider::ResourceIdMap& map =
1510 host_impl->resource_provider()->GetChildToParentMap( 1510 host_impl->resource_provider()->GetChildToParentMap(
1511 delegated_impl->ChildId()); 1511 delegated_impl->ChildId());
1512 1512
1513 // Receive 999 back from the grandparent. 1513 // Receive 999 back from the grandparent.
1514 CompositorFrameAck ack; 1514 CompositorFrameAck ack;
1515 output_surface()->ReturnResource(map.find(999)->second, &ack); 1515 output_surface()->ReturnResource(map.find(999)->second, &ack);
1516 host_impl->ReclaimResources(&ack); 1516 host_impl->ReclaimResources(&ack);
1517 } 1517 }
1518 1518
1519 virtual void UnusedResourcesAreAvailable() OVERRIDE { 1519 virtual void UnusedResourcesAreAvailable() override {
1520 EXPECT_EQ(3, layer_tree_host()->source_frame_number()); 1520 EXPECT_EQ(3, layer_tree_host()->source_frame_number());
1521 1521
1522 ReturnedResourceArray resources; 1522 ReturnedResourceArray resources;
1523 1523
1524 // 999 was returned from the grandparent and could be released. 1524 // 999 was returned from the grandparent and could be released.
1525 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); 1525 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources);
1526 { 1526 {
1527 unsigned expected[] = {999}; 1527 unsigned expected[] = {999};
1528 EXPECT_RESOURCES(expected, resources); 1528 EXPECT_RESOURCES(expected, resources);
1529 } 1529 }
1530 1530
1531 EndTest(); 1531 EndTest();
1532 } 1532 }
1533 1533
1534 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 1534 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
1535 if (host_impl->active_tree()->source_frame_number() < 1) 1535 if (host_impl->active_tree()->source_frame_number() < 1)
1536 return; 1536 return;
1537 1537
1538 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); 1538 LayerImpl* root_impl = host_impl->active_tree()->root_layer();
1539 FakeDelegatedRendererLayerImpl* delegated_impl = 1539 FakeDelegatedRendererLayerImpl* delegated_impl =
1540 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); 1540 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]);
1541 1541
1542 const ResourceProvider::ResourceIdMap& map = 1542 const ResourceProvider::ResourceIdMap& map =
1543 host_impl->resource_provider()->GetChildToParentMap( 1543 host_impl->resource_provider()->GetChildToParentMap(
1544 delegated_impl->ChildId()); 1544 delegated_impl->ChildId());
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1585 1585
1586 base::Closure receive_resource_on_thread_; 1586 base::Closure receive_resource_on_thread_;
1587 }; 1587 };
1588 1588
1589 SINGLE_AND_MULTI_THREAD_DELEGATING_RENDERER_TEST_F( 1589 SINGLE_AND_MULTI_THREAD_DELEGATING_RENDERER_TEST_F(
1590 LayerTreeHostDelegatedTestResourceSentToParent); 1590 LayerTreeHostDelegatedTestResourceSentToParent);
1591 1591
1592 class LayerTreeHostDelegatedTestCommitWithoutTake 1592 class LayerTreeHostDelegatedTestCommitWithoutTake
1593 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer { 1593 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer {
1594 public: 1594 public:
1595 virtual void BeginTest() OVERRIDE { 1595 virtual void BeginTest() override {
1596 // Prevent drawing with resources that are sent to the grandparent. 1596 // Prevent drawing with resources that are sent to the grandparent.
1597 layer_tree_host()->SetViewportSize(gfx::Size()); 1597 layer_tree_host()->SetViewportSize(gfx::Size());
1598 PostSetNeedsCommitToMainThread(); 1598 PostSetNeedsCommitToMainThread();
1599 } 1599 }
1600 1600
1601 virtual void DidCommit() OVERRIDE { 1601 virtual void DidCommit() override {
1602 scoped_ptr<DelegatedFrameData> frame; 1602 scoped_ptr<DelegatedFrameData> frame;
1603 ReturnedResourceArray resources; 1603 ReturnedResourceArray resources;
1604 1604
1605 int next_source_frame_number = layer_tree_host()->source_frame_number(); 1605 int next_source_frame_number = layer_tree_host()->source_frame_number();
1606 switch (next_source_frame_number) { 1606 switch (next_source_frame_number) {
1607 case 1: 1607 case 1:
1608 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); 1608 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1));
1609 AddTextureQuad(frame.get(), 999); 1609 AddTextureQuad(frame.get(), 999);
1610 AddTransferableResource(frame.get(), 999); 1610 AddTransferableResource(frame.get(), 999);
1611 AddTextureQuad(frame.get(), 555); 1611 AddTextureQuad(frame.get(), 555);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1657 unsigned expected[] = {555, 555, 555, 999}; 1657 unsigned expected[] = {555, 555, 555, 999};
1658 EXPECT_RESOURCES(expected, resources); 1658 EXPECT_RESOURCES(expected, resources);
1659 EXPECT_TRUE(TestAndResetAvailable()); 1659 EXPECT_TRUE(TestAndResetAvailable());
1660 } 1660 }
1661 1661
1662 EndTest(); 1662 EndTest();
1663 break; 1663 break;
1664 } 1664 }
1665 } 1665 }
1666 1666
1667 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 1667 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
1668 if (host_impl->active_tree()->source_frame_number() < 1) 1668 if (host_impl->active_tree()->source_frame_number() < 1)
1669 return; 1669 return;
1670 1670
1671 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); 1671 LayerImpl* root_impl = host_impl->active_tree()->root_layer();
1672 FakeDelegatedRendererLayerImpl* delegated_impl = 1672 FakeDelegatedRendererLayerImpl* delegated_impl =
1673 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); 1673 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]);
1674 1674
1675 const ResourceProvider::ResourceIdMap& map = 1675 const ResourceProvider::ResourceIdMap& map =
1676 host_impl->resource_provider()->GetChildToParentMap( 1676 host_impl->resource_provider()->GetChildToParentMap(
1677 delegated_impl->ChildId()); 1677 delegated_impl->ChildId());
(...skipping 29 matching lines...) Expand all
1707 } 1707 }
1708 }; 1708 };
1709 1709
1710 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDelegatedTestCommitWithoutTake); 1710 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDelegatedTestCommitWithoutTake);
1711 1711
1712 class DelegatedFrameIsActivatedDuringCommit 1712 class DelegatedFrameIsActivatedDuringCommit
1713 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer { 1713 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer {
1714 protected: 1714 protected:
1715 DelegatedFrameIsActivatedDuringCommit() : returned_resource_count_(0) {} 1715 DelegatedFrameIsActivatedDuringCommit() : returned_resource_count_(0) {}
1716 1716
1717 virtual void BeginTest() OVERRIDE { 1717 virtual void BeginTest() override {
1718 activate_count_ = 0; 1718 activate_count_ = 0;
1719 1719
1720 scoped_ptr<DelegatedFrameData> frame = 1720 scoped_ptr<DelegatedFrameData> frame =
1721 CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); 1721 CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1));
1722 AddTextureQuad(frame.get(), 999); 1722 AddTextureQuad(frame.get(), 999);
1723 AddTransferableResource(frame.get(), 999); 1723 AddTransferableResource(frame.get(), 999);
1724 SetFrameData(frame.Pass()); 1724 SetFrameData(frame.Pass());
1725 1725
1726 PostSetNeedsCommitToMainThread(); 1726 PostSetNeedsCommitToMainThread();
1727 } 1727 }
1728 1728
1729 virtual void WillActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { 1729 virtual void WillActivateTreeOnThread(LayerTreeHostImpl* impl) override {
1730 ++activate_count_; 1730 ++activate_count_;
1731 } 1731 }
1732 1732
1733 virtual void DidCommit() OVERRIDE { 1733 virtual void DidCommit() override {
1734 switch (layer_tree_host()->source_frame_number()) { 1734 switch (layer_tree_host()->source_frame_number()) {
1735 case 1: { 1735 case 1: {
1736 // The first frame has been activated. Set a new frame, and 1736 // The first frame has been activated. Set a new frame, and
1737 // expect the next commit to finish *after* it is activated. 1737 // expect the next commit to finish *after* it is activated.
1738 scoped_ptr<DelegatedFrameData> frame = 1738 scoped_ptr<DelegatedFrameData> frame =
1739 CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); 1739 CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1));
1740 AddTextureQuad(frame.get(), 555); 1740 AddTextureQuad(frame.get(), 555);
1741 AddTransferableResource(frame.get(), 555); 1741 AddTransferableResource(frame.get(), 555);
1742 SetFrameData(frame.Pass()); 1742 SetFrameData(frame.Pass());
1743 break; 1743 break;
1744 } 1744 }
1745 case 2: 1745 case 2:
1746 // The second frame has been activated. Remove the layer from 1746 // The second frame has been activated. Remove the layer from
1747 // the tree to cause another commit/activation. The commit should 1747 // the tree to cause another commit/activation. The commit should
1748 // finish *after* the layer is removed from the active tree. 1748 // finish *after* the layer is removed from the active tree.
1749 delegated_->RemoveFromParent(); 1749 delegated_->RemoveFromParent();
1750 break; 1750 break;
1751 case 3: 1751 case 3:
1752 // Finish the test by releasing resources on the next frame. 1752 // Finish the test by releasing resources on the next frame.
1753 scoped_ptr<DelegatedFrameData> frame = 1753 scoped_ptr<DelegatedFrameData> frame =
1754 CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); 1754 CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1));
1755 SetFrameData(frame.Pass()); 1755 SetFrameData(frame.Pass());
1756 break; 1756 break;
1757 } 1757 }
1758 } 1758 }
1759 1759
1760 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 1760 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
1761 switch (host_impl->active_tree()->source_frame_number()) { 1761 switch (host_impl->active_tree()->source_frame_number()) {
1762 case 0: { 1762 case 0: {
1763 // The activate for the 1st frame should have happened before now. 1763 // The activate for the 1st frame should have happened before now.
1764 EXPECT_EQ(1, activate_count_); 1764 EXPECT_EQ(1, activate_count_);
1765 break; 1765 break;
1766 } 1766 }
1767 case 1: { 1767 case 1: {
1768 // The activate for the 2nd frame should have happened before now. 1768 // The activate for the 2nd frame should have happened before now.
1769 EXPECT_EQ(2, activate_count_); 1769 EXPECT_EQ(2, activate_count_);
1770 break; 1770 break;
1771 } 1771 }
1772 case 2: { 1772 case 2: {
1773 // The activate to remove the layer should have happened before now. 1773 // The activate to remove the layer should have happened before now.
1774 EXPECT_EQ(3, activate_count_); 1774 EXPECT_EQ(3, activate_count_);
1775 break; 1775 break;
1776 } 1776 }
1777 case 3: { 1777 case 3: {
1778 NOTREACHED(); 1778 NOTREACHED();
1779 break; 1779 break;
1780 } 1780 }
1781 } 1781 }
1782 } 1782 }
1783 1783
1784 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, 1784 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl,
1785 bool result) OVERRIDE { 1785 bool result) override {
1786 ReturnUnusedResourcesFromParent(host_impl); 1786 ReturnUnusedResourcesFromParent(host_impl);
1787 } 1787 }
1788 1788
1789 virtual void UnusedResourcesAreAvailable() OVERRIDE { 1789 virtual void UnusedResourcesAreAvailable() override {
1790 LayerTreeHostDelegatedTestCaseSingleDelegatedLayer:: 1790 LayerTreeHostDelegatedTestCaseSingleDelegatedLayer::
1791 UnusedResourcesAreAvailable(); 1791 UnusedResourcesAreAvailable();
1792 ReturnedResourceArray resources; 1792 ReturnedResourceArray resources;
1793 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); 1793 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources);
1794 EXPECT_TRUE(TestAndResetAvailable()); 1794 EXPECT_TRUE(TestAndResetAvailable());
1795 returned_resource_count_ += resources.size(); 1795 returned_resource_count_ += resources.size();
1796 if (returned_resource_count_ == 2) 1796 if (returned_resource_count_ == 2)
1797 EndTest(); 1797 EndTest();
1798 } 1798 }
1799 1799
1800 int activate_count_; 1800 int activate_count_;
1801 size_t returned_resource_count_; 1801 size_t returned_resource_count_;
1802 }; 1802 };
1803 1803
1804 SINGLE_AND_MULTI_THREAD_TEST_F( 1804 SINGLE_AND_MULTI_THREAD_TEST_F(
1805 DelegatedFrameIsActivatedDuringCommit); 1805 DelegatedFrameIsActivatedDuringCommit);
1806 1806
1807 class LayerTreeHostDelegatedTestTwoImplLayers 1807 class LayerTreeHostDelegatedTestTwoImplLayers
1808 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer { 1808 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer {
1809 public: 1809 public:
1810 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 1810 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1811 1811
1812 virtual void DidCommitAndDrawFrame() OVERRIDE { 1812 virtual void DidCommitAndDrawFrame() override {
1813 scoped_ptr<DelegatedFrameData> frame; 1813 scoped_ptr<DelegatedFrameData> frame;
1814 ReturnedResourceArray resources; 1814 ReturnedResourceArray resources;
1815 1815
1816 int next_source_frame_number = layer_tree_host()->source_frame_number(); 1816 int next_source_frame_number = layer_tree_host()->source_frame_number();
1817 switch (next_source_frame_number) { 1817 switch (next_source_frame_number) {
1818 case 1: 1818 case 1:
1819 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); 1819 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1));
1820 AddTextureQuad(frame.get(), 999); 1820 AddTextureQuad(frame.get(), 999);
1821 AddTransferableResource(frame.get(), 999); 1821 AddTransferableResource(frame.get(), 999);
1822 AddTextureQuad(frame.get(), 555); 1822 AddTextureQuad(frame.get(), 555);
(...skipping 27 matching lines...) Expand all
1850 unsigned expected[] = {555, 999}; 1850 unsigned expected[] = {555, 999};
1851 EXPECT_RESOURCES(expected, resources); 1851 EXPECT_RESOURCES(expected, resources);
1852 EXPECT_TRUE(TestAndResetAvailable()); 1852 EXPECT_TRUE(TestAndResetAvailable());
1853 } 1853 }
1854 EndTest(); 1854 EndTest();
1855 break; 1855 break;
1856 } 1856 }
1857 } 1857 }
1858 1858
1859 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, 1859 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl,
1860 bool result) OVERRIDE { 1860 bool result) override {
1861 ReturnUnusedResourcesFromParent(host_impl); 1861 ReturnUnusedResourcesFromParent(host_impl);
1862 } 1862 }
1863 }; 1863 };
1864 1864
1865 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDelegatedTestTwoImplLayers); 1865 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDelegatedTestTwoImplLayers);
1866 1866
1867 class LayerTreeHostDelegatedTestTwoImplLayersTwoFrames 1867 class LayerTreeHostDelegatedTestTwoImplLayersTwoFrames
1868 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer { 1868 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer {
1869 public: 1869 public:
1870 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 1870 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1871 1871
1872 virtual void DidCommitAndDrawFrame() OVERRIDE { 1872 virtual void DidCommitAndDrawFrame() override {
1873 scoped_ptr<DelegatedFrameData> frame; 1873 scoped_ptr<DelegatedFrameData> frame;
1874 ReturnedResourceArray resources; 1874 ReturnedResourceArray resources;
1875 1875
1876 int next_source_frame_number = layer_tree_host()->source_frame_number(); 1876 int next_source_frame_number = layer_tree_host()->source_frame_number();
1877 switch (next_source_frame_number) { 1877 switch (next_source_frame_number) {
1878 case 1: 1878 case 1:
1879 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); 1879 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1));
1880 AddTextureQuad(frame.get(), 999); 1880 AddTextureQuad(frame.get(), 999);
1881 AddTransferableResource(frame.get(), 999); 1881 AddTransferableResource(frame.get(), 999);
1882 AddTextureQuad(frame.get(), 555); 1882 AddTextureQuad(frame.get(), 555);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1919 unsigned expected[] = {555, 555, 999, 999}; 1919 unsigned expected[] = {555, 555, 999, 999};
1920 EXPECT_RESOURCES(expected, resources); 1920 EXPECT_RESOURCES(expected, resources);
1921 EXPECT_TRUE(TestAndResetAvailable()); 1921 EXPECT_TRUE(TestAndResetAvailable());
1922 } 1922 }
1923 EndTest(); 1923 EndTest();
1924 break; 1924 break;
1925 } 1925 }
1926 } 1926 }
1927 1927
1928 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, 1928 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl,
1929 bool result) OVERRIDE { 1929 bool result) override {
1930 ReturnUnusedResourcesFromParent(host_impl); 1930 ReturnUnusedResourcesFromParent(host_impl);
1931 } 1931 }
1932 }; 1932 };
1933 1933
1934 SINGLE_AND_MULTI_THREAD_TEST_F( 1934 SINGLE_AND_MULTI_THREAD_TEST_F(
1935 LayerTreeHostDelegatedTestTwoImplLayersTwoFrames); 1935 LayerTreeHostDelegatedTestTwoImplLayersTwoFrames);
1936 1936
1937 class LayerTreeHostDelegatedTestTwoLayers 1937 class LayerTreeHostDelegatedTestTwoLayers
1938 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer { 1938 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer {
1939 public: 1939 public:
1940 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 1940 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1941 1941
1942 virtual void DidCommitAndDrawFrame() OVERRIDE { 1942 virtual void DidCommitAndDrawFrame() override {
1943 scoped_ptr<DelegatedFrameData> frame; 1943 scoped_ptr<DelegatedFrameData> frame;
1944 ReturnedResourceArray resources; 1944 ReturnedResourceArray resources;
1945 1945
1946 int next_source_frame_number = layer_tree_host()->source_frame_number(); 1946 int next_source_frame_number = layer_tree_host()->source_frame_number();
1947 switch (next_source_frame_number) { 1947 switch (next_source_frame_number) {
1948 case 1: 1948 case 1:
1949 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); 1949 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1));
1950 AddTextureQuad(frame.get(), 999); 1950 AddTextureQuad(frame.get(), 999);
1951 AddTransferableResource(frame.get(), 999); 1951 AddTransferableResource(frame.get(), 999);
1952 AddTextureQuad(frame.get(), 555); 1952 AddTextureQuad(frame.get(), 555);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
2006 unsigned expected[] = {555, 999}; 2006 unsigned expected[] = {555, 999};
2007 EXPECT_RESOURCES(expected, resources); 2007 EXPECT_RESOURCES(expected, resources);
2008 EXPECT_TRUE(TestAndResetAvailable()); 2008 EXPECT_TRUE(TestAndResetAvailable());
2009 } 2009 }
2010 EndTest(); 2010 EndTest();
2011 break; 2011 break;
2012 } 2012 }
2013 } 2013 }
2014 2014
2015 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, 2015 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl,
2016 bool result) OVERRIDE { 2016 bool result) override {
2017 ReturnUnusedResourcesFromParent(host_impl); 2017 ReturnUnusedResourcesFromParent(host_impl);
2018 } 2018 }
2019 2019
2020 scoped_refptr<DelegatedRendererLayer> delegated_thief_; 2020 scoped_refptr<DelegatedRendererLayer> delegated_thief_;
2021 }; 2021 };
2022 2022
2023 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDelegatedTestTwoLayers); 2023 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDelegatedTestTwoLayers);
2024 2024
2025 class LayerTreeHostDelegatedTestRemoveAndAddToTree 2025 class LayerTreeHostDelegatedTestRemoveAndAddToTree
2026 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer { 2026 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer {
2027 public: 2027 public:
2028 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 2028 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); }
2029 2029
2030 virtual void DidCommitAndDrawFrame() OVERRIDE { 2030 virtual void DidCommitAndDrawFrame() override {
2031 scoped_ptr<DelegatedFrameData> frame; 2031 scoped_ptr<DelegatedFrameData> frame;
2032 ReturnedResourceArray resources; 2032 ReturnedResourceArray resources;
2033 2033
2034 int next_source_frame_number = layer_tree_host()->source_frame_number(); 2034 int next_source_frame_number = layer_tree_host()->source_frame_number();
2035 switch (next_source_frame_number) { 2035 switch (next_source_frame_number) {
2036 case 1: 2036 case 1:
2037 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); 2037 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1));
2038 AddTextureQuad(frame.get(), 999); 2038 AddTextureQuad(frame.get(), 999);
2039 AddTransferableResource(frame.get(), 999); 2039 AddTransferableResource(frame.get(), 999);
2040 AddTextureQuad(frame.get(), 555); 2040 AddTextureQuad(frame.get(), 555);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
2098 unsigned expected[] = {777, 888}; 2098 unsigned expected[] = {777, 888};
2099 EXPECT_RESOURCES(expected, resources); 2099 EXPECT_RESOURCES(expected, resources);
2100 EXPECT_TRUE(TestAndResetAvailable()); 2100 EXPECT_TRUE(TestAndResetAvailable());
2101 } 2101 }
2102 EndTest(); 2102 EndTest();
2103 break; 2103 break;
2104 } 2104 }
2105 } 2105 }
2106 2106
2107 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, 2107 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl,
2108 bool result) OVERRIDE { 2108 bool result) override {
2109 ReturnUnusedResourcesFromParent(host_impl); 2109 ReturnUnusedResourcesFromParent(host_impl);
2110 } 2110 }
2111 2111
2112 scoped_refptr<DelegatedRendererLayer> delegated_thief_; 2112 scoped_refptr<DelegatedRendererLayer> delegated_thief_;
2113 }; 2113 };
2114 2114
2115 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDelegatedTestRemoveAndAddToTree); 2115 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDelegatedTestRemoveAndAddToTree);
2116 2116
2117 class LayerTreeHostDelegatedTestRemoveAndChangeResources 2117 class LayerTreeHostDelegatedTestRemoveAndChangeResources
2118 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer { 2118 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer {
2119 public: 2119 public:
2120 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 2120 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); }
2121 2121
2122 virtual void DidCommitAndDrawFrame() OVERRIDE { 2122 virtual void DidCommitAndDrawFrame() override {
2123 scoped_ptr<DelegatedFrameData> frame; 2123 scoped_ptr<DelegatedFrameData> frame;
2124 ReturnedResourceArray resources; 2124 ReturnedResourceArray resources;
2125 2125
2126 int next_source_frame_number = layer_tree_host()->source_frame_number(); 2126 int next_source_frame_number = layer_tree_host()->source_frame_number();
2127 switch (next_source_frame_number) { 2127 switch (next_source_frame_number) {
2128 case 1: 2128 case 1:
2129 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); 2129 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1));
2130 AddTextureQuad(frame.get(), 999); 2130 AddTextureQuad(frame.get(), 999);
2131 AddTransferableResource(frame.get(), 999); 2131 AddTransferableResource(frame.get(), 999);
2132 AddTextureQuad(frame.get(), 555); 2132 AddTextureQuad(frame.get(), 555);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
2180 unsigned expected[] = {777, 888}; 2180 unsigned expected[] = {777, 888};
2181 EXPECT_RESOURCES(expected, resources); 2181 EXPECT_RESOURCES(expected, resources);
2182 EXPECT_TRUE(TestAndResetAvailable()); 2182 EXPECT_TRUE(TestAndResetAvailable());
2183 } 2183 }
2184 EndTest(); 2184 EndTest();
2185 break; 2185 break;
2186 } 2186 }
2187 } 2187 }
2188 2188
2189 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, 2189 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl,
2190 bool result) OVERRIDE { 2190 bool result) override {
2191 ReturnUnusedResourcesFromParent(host_impl); 2191 ReturnUnusedResourcesFromParent(host_impl);
2192 } 2192 }
2193 2193
2194 scoped_refptr<DelegatedRendererLayer> delegated_thief_; 2194 scoped_refptr<DelegatedRendererLayer> delegated_thief_;
2195 }; 2195 };
2196 2196
2197 SINGLE_AND_MULTI_THREAD_TEST_F( 2197 SINGLE_AND_MULTI_THREAD_TEST_F(
2198 LayerTreeHostDelegatedTestRemoveAndChangeResources); 2198 LayerTreeHostDelegatedTestRemoveAndChangeResources);
2199 2199
2200 } // namespace 2200 } // namespace
2201 } // namespace cc 2201 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_unittest_damage.cc ('k') | cc/trees/layer_tree_host_unittest_no_message_loop.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698