Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/trees/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "cc/layers/content_layer.h" | 8 #include "cc/layers/content_layer.h" |
| 9 #include "cc/layers/delegated_frame_provider.h" | 9 #include "cc/layers/delegated_frame_provider.h" |
| 10 #include "cc/layers/delegated_frame_resource_collection.h" | 10 #include "cc/layers/delegated_frame_resource_collection.h" |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 #include "cc/resources/single_release_callback.h" | 21 #include "cc/resources/single_release_callback.h" |
| 22 #include "cc/test/fake_content_layer.h" | 22 #include "cc/test/fake_content_layer.h" |
| 23 #include "cc/test/fake_content_layer_client.h" | 23 #include "cc/test/fake_content_layer_client.h" |
| 24 #include "cc/test/fake_content_layer_impl.h" | 24 #include "cc/test/fake_content_layer_impl.h" |
| 25 #include "cc/test/fake_delegated_renderer_layer.h" | 25 #include "cc/test/fake_delegated_renderer_layer.h" |
| 26 #include "cc/test/fake_delegated_renderer_layer_impl.h" | 26 #include "cc/test/fake_delegated_renderer_layer_impl.h" |
| 27 #include "cc/test/fake_layer_tree_host_client.h" | 27 #include "cc/test/fake_layer_tree_host_client.h" |
| 28 #include "cc/test/fake_output_surface.h" | 28 #include "cc/test/fake_output_surface.h" |
| 29 #include "cc/test/fake_output_surface_client.h" | 29 #include "cc/test/fake_output_surface_client.h" |
| 30 #include "cc/test/fake_painted_scrollbar_layer.h" | 30 #include "cc/test/fake_painted_scrollbar_layer.h" |
| 31 #include "cc/test/fake_picture_layer.h" | |
| 32 #include "cc/test/fake_picture_layer_impl.h" | |
| 31 #include "cc/test/fake_scoped_ui_resource.h" | 33 #include "cc/test/fake_scoped_ui_resource.h" |
| 32 #include "cc/test/fake_scrollbar.h" | 34 #include "cc/test/fake_scrollbar.h" |
| 33 #include "cc/test/fake_video_frame_provider.h" | 35 #include "cc/test/fake_video_frame_provider.h" |
| 34 #include "cc/test/layer_tree_test.h" | 36 #include "cc/test/layer_tree_test.h" |
| 35 #include "cc/test/render_pass_test_common.h" | 37 #include "cc/test/render_pass_test_common.h" |
| 36 #include "cc/test/test_context_provider.h" | 38 #include "cc/test/test_context_provider.h" |
| 37 #include "cc/test/test_shared_bitmap_manager.h" | 39 #include "cc/test/test_shared_bitmap_manager.h" |
| 38 #include "cc/test/test_web_graphics_context_3d.h" | 40 #include "cc/test/test_web_graphics_context_3d.h" |
| 39 #include "cc/trees/layer_tree_host_impl.h" | 41 #include "cc/trees/layer_tree_host_impl.h" |
| 40 #include "cc/trees/layer_tree_impl.h" | 42 #include "cc/trees/layer_tree_impl.h" |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 316 LayerTreeHostClientNotReadyDoesNotCreateOutputSurface); | 318 LayerTreeHostClientNotReadyDoesNotCreateOutputSurface); |
| 317 | 319 |
| 318 class LayerTreeHostContextTestLostContextSucceedsWithContent | 320 class LayerTreeHostContextTestLostContextSucceedsWithContent |
| 319 : public LayerTreeHostContextTestLostContextSucceeds { | 321 : public LayerTreeHostContextTestLostContextSucceeds { |
| 320 public: | 322 public: |
| 321 virtual void SetupTree() OVERRIDE { | 323 virtual void SetupTree() OVERRIDE { |
| 322 root_ = Layer::Create(); | 324 root_ = Layer::Create(); |
| 323 root_->SetBounds(gfx::Size(10, 10)); | 325 root_->SetBounds(gfx::Size(10, 10)); |
| 324 root_->SetIsDrawable(true); | 326 root_->SetIsDrawable(true); |
| 325 | 327 |
| 326 content_ = FakeContentLayer::Create(&client_); | 328 // Paint non-solid color. |
| 327 content_->SetBounds(gfx::Size(10, 10)); | 329 SkPaint paint; |
| 328 content_->SetIsDrawable(true); | 330 paint.setColor(SkColorSetARGB(100, 80, 200, 200)); |
| 331 client_.add_draw_rect(gfx::Rect(0, 0, 5, 5), paint); | |
| 332 client_.add_draw_rect(gfx::Rect(10, 10, 10, 10), paint); | |
| 333 client_.add_draw_rect(gfx::Rect(30, 30, 5, 5), paint); | |
| 334 client_.add_draw_rect(gfx::Rect(50, 50, 5, 5), paint); | |
| 329 | 335 |
| 330 root_->AddChild(content_); | 336 if (layer_tree_host()->settings().impl_side_painting) |
| 337 layer_ = FakePictureLayer::Create(&client_); | |
| 338 else | |
| 339 layer_ = FakeContentLayer::Create(&client_); | |
| 340 layer_->SetBounds(gfx::Size(10, 10)); | |
| 341 layer_->SetIsDrawable(true); | |
| 342 | |
| 343 root_->AddChild(layer_); | |
| 331 | 344 |
| 332 layer_tree_host()->SetRootLayer(root_); | 345 layer_tree_host()->SetRootLayer(root_); |
| 333 LayerTreeHostContextTest::SetupTree(); | 346 LayerTreeHostContextTest::SetupTree(); |
| 334 } | 347 } |
| 335 | 348 |
| 336 virtual void InvalidateAndSetNeedsCommit() OVERRIDE { | 349 virtual void InvalidateAndSetNeedsCommit() OVERRIDE { |
| 337 // Invalidate the render surface so we don't try to use a cached copy of the | 350 // Invalidate the render surface so we don't try to use a cached copy of the |
| 338 // surface. We want to make sure to test the drawing paths for drawing to | 351 // surface. We want to make sure to test the drawing paths for drawing to |
| 339 // a child surface. | 352 // a child surface. |
| 340 content_->SetNeedsDisplay(); | 353 layer_->SetNeedsDisplay(); |
| 341 LayerTreeHostContextTestLostContextSucceeds::InvalidateAndSetNeedsCommit(); | 354 LayerTreeHostContextTestLostContextSucceeds::InvalidateAndSetNeedsCommit(); |
| 342 } | 355 } |
| 343 | 356 |
| 344 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 357 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 345 FakeContentLayerImpl* content_impl = static_cast<FakeContentLayerImpl*>( | 358 if (!host_impl->settings().impl_side_painting) { |
| 346 host_impl->active_tree()->root_layer()->children()[0]); | 359 FakeContentLayerImpl* content_impl = static_cast<FakeContentLayerImpl*>( |
| 347 // Even though the context was lost, we should have a resource. The | 360 host_impl->active_tree()->root_layer()->children()[0]); |
| 348 // TestWebGraphicsContext3D ensures that this resource is created with | 361 // Even though the context was lost, we should have a resource. The |
| 349 // the active context. | 362 // TestWebGraphicsContext3D ensures that this resource is created with |
| 350 EXPECT_TRUE(content_impl->HaveResourceForTileAt(0, 0)); | 363 // the active context. |
| 364 EXPECT_TRUE(content_impl->HaveResourceForTileAt(0, 0)); | |
| 365 } else { | |
| 366 FakePictureLayerImpl* picture_impl = static_cast<FakePictureLayerImpl*>( | |
| 367 host_impl->active_tree()->root_layer()->children()[0]); | |
| 368 EXPECT_TRUE(picture_impl->HighResTiling()->TileAt(0, 0)->IsReadyToDraw()); | |
| 369 } | |
| 351 } | 370 } |
| 352 | 371 |
| 353 protected: | 372 protected: |
| 354 FakeContentLayerClient client_; | 373 FakeContentLayerClient client_; |
| 355 scoped_refptr<Layer> root_; | 374 scoped_refptr<Layer> root_; |
| 356 scoped_refptr<ContentLayer> content_; | 375 scoped_refptr<Layer> layer_; |
| 357 }; | 376 }; |
| 358 | 377 |
| 359 // This test uses TiledLayer to check for a working context. | 378 // This test uses TiledLayer and PictureLayer to check for a working context. |
| 360 SINGLE_AND_MULTI_THREAD_NOIMPL_TEST_F( | 379 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 361 LayerTreeHostContextTestLostContextSucceedsWithContent); | 380 LayerTreeHostContextTestLostContextSucceedsWithContent); |
| 362 | 381 |
| 363 class LayerTreeHostContextTestCreateOutputSurfaceFails | 382 class LayerTreeHostContextTestCreateOutputSurfaceFails |
| 364 : public LayerTreeHostContextTest { | 383 : public LayerTreeHostContextTest { |
| 365 public: | 384 public: |
| 366 // Run a test that initially fails OutputSurface creation |times_to_fail| | 385 // Run a test that initially fails OutputSurface creation |times_to_fail| |
| 367 // times. If |expect_fallback_attempt| is |true|, an attempt to create a | 386 // times. If |expect_fallback_attempt| is |true|, an attempt to create a |
| 368 // fallback/software OutputSurface is expected to occur. | 387 // fallback/software OutputSurface is expected to occur. |
| 369 LayerTreeHostContextTestCreateOutputSurfaceFails(int times_to_fail, | 388 LayerTreeHostContextTestCreateOutputSurfaceFails(int times_to_fail, |
| 370 bool expect_fallback_attempt) | 389 bool expect_fallback_attempt) |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 430 }; | 449 }; |
| 431 | 450 |
| 432 SINGLE_AND_MULTI_THREAD_TEST_F( | 451 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 433 LayerTreeHostContextTestCreateOutputSurfaceFailsWithFallback); | 452 LayerTreeHostContextTestCreateOutputSurfaceFailsWithFallback); |
| 434 | 453 |
| 435 class LayerTreeHostContextTestLostContextAndEvictTextures | 454 class LayerTreeHostContextTestLostContextAndEvictTextures |
| 436 : public LayerTreeHostContextTest { | 455 : public LayerTreeHostContextTest { |
| 437 public: | 456 public: |
| 438 LayerTreeHostContextTestLostContextAndEvictTextures() | 457 LayerTreeHostContextTestLostContextAndEvictTextures() |
| 439 : LayerTreeHostContextTest(), | 458 : LayerTreeHostContextTest(), |
| 440 layer_(FakeContentLayer::Create(&client_)), | |
| 441 impl_host_(0), | 459 impl_host_(0), |
| 442 num_commits_(0) {} | 460 num_commits_(0) {} |
| 443 | 461 |
| 444 virtual void SetupTree() OVERRIDE { | 462 virtual void SetupTree() OVERRIDE { |
| 445 layer_->SetBounds(gfx::Size(10, 20)); | 463 if (layer_tree_host()->settings().impl_side_painting) { |
| 446 layer_tree_host()->SetRootLayer(layer_); | 464 picture_layer_ = FakePictureLayer::Create(&client_); |
| 465 picture_layer_->SetBounds(gfx::Size(10, 20)); | |
| 466 layer_tree_host()->SetRootLayer(picture_layer_); | |
| 467 } else { | |
| 468 content_layer_ = FakeContentLayer::Create(&client_); | |
| 469 content_layer_->SetBounds(gfx::Size(10, 20)); | |
| 470 layer_tree_host()->SetRootLayer(content_layer_); | |
| 471 } | |
| 472 | |
| 447 LayerTreeHostContextTest::SetupTree(); | 473 LayerTreeHostContextTest::SetupTree(); |
| 448 } | 474 } |
| 449 | 475 |
| 450 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 476 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
| 451 | 477 |
| 452 void PostEvictTextures() { | 478 void PostEvictTextures() { |
| 453 if (HasImplThread()) { | 479 if (HasImplThread()) { |
| 454 ImplThreadTaskRunner()->PostTask( | 480 ImplThreadTaskRunner()->PostTask( |
| 455 FROM_HERE, | 481 FROM_HERE, |
| 456 base::Bind(&LayerTreeHostContextTestLostContextAndEvictTextures:: | 482 base::Bind(&LayerTreeHostContextTestLostContextAndEvictTextures:: |
| 457 EvictTexturesOnImplThread, | 483 EvictTexturesOnImplThread, |
| 458 base::Unretained(this))); | 484 base::Unretained(this))); |
| 459 } else { | 485 } else { |
| 460 DebugScopedSetImplThread impl(proxy()); | 486 DebugScopedSetImplThread impl(proxy()); |
| 461 EvictTexturesOnImplThread(); | 487 EvictTexturesOnImplThread(); |
| 462 } | 488 } |
| 463 } | 489 } |
| 464 | 490 |
| 465 void EvictTexturesOnImplThread() { | 491 void EvictTexturesOnImplThread() { |
| 466 impl_host_->EvictTexturesForTesting(); | 492 impl_host_->EvictTexturesForTesting(); |
|
danakj
2014/09/10 16:03:32
can you after this, do:
EXPECT_FALSE(picture_impl
sohanjg
2014/09/11 06:07:57
Done.
| |
| 467 if (lose_after_evict_) | 493 if (lose_after_evict_) |
| 468 LoseContext(); | 494 LoseContext(); |
| 469 } | 495 } |
| 470 | 496 |
| 471 virtual void DidCommitAndDrawFrame() OVERRIDE { | 497 virtual void DidCommitAndDrawFrame() OVERRIDE { |
| 472 if (num_commits_ > 1) | 498 if (num_commits_ > 1) |
| 473 return; | 499 return; |
| 474 EXPECT_TRUE(layer_->HaveBackingAt(0, 0)); | 500 if (!layer_tree_host()->settings().impl_side_painting) { |
| 501 EXPECT_TRUE(content_layer_->HaveBackingAt(0, 0)); | |
| 502 } | |
| 475 PostEvictTextures(); | 503 PostEvictTextures(); |
| 476 } | 504 } |
| 477 | 505 |
| 478 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 506 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
| 479 LayerTreeHostContextTest::CommitCompleteOnThread(impl); | 507 if (impl->settings().impl_side_painting) { |
| 480 if (num_commits_ > 1) | 508 FakePictureLayerImpl* picture_impl = static_cast<FakePictureLayerImpl*>( |
| 481 return; | 509 impl->active_tree()->root_layer()->children()[0]); |
| 482 ++num_commits_; | 510 EXPECT_TRUE(picture_impl->HighResTiling()->TileAt(0, 0)->IsReadyToDraw()); |
| 483 if (!lose_after_evict_) | 511 } |
| 484 LoseContext(); | 512 |
| 485 impl_host_ = impl; | 513 impl_host_ = impl; |
| 486 } | 514 } |
| 487 | 515 |
| 488 virtual void DidInitializeOutputSurface() OVERRIDE { EndTest(); } | 516 virtual void DidInitializeOutputSurface() OVERRIDE { EndTest(); } |
| 489 | 517 |
| 490 virtual void AfterTest() OVERRIDE {} | 518 virtual void AfterTest() OVERRIDE {} |
| 491 | 519 |
| 492 protected: | 520 protected: |
| 493 bool lose_after_evict_; | 521 bool lose_after_evict_; |
| 494 FakeContentLayerClient client_; | 522 FakeContentLayerClient client_; |
| 495 scoped_refptr<FakeContentLayer> layer_; | 523 scoped_refptr<FakeContentLayer> content_layer_; |
| 524 scoped_refptr<FakePictureLayer> picture_layer_; | |
| 496 LayerTreeHostImpl* impl_host_; | 525 LayerTreeHostImpl* impl_host_; |
| 497 int num_commits_; | 526 int num_commits_; |
| 498 }; | 527 }; |
| 499 | 528 |
| 500 TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures, | 529 TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures, |
| 501 LoseAfterEvict_SingleThread_DirectRenderer) { | 530 LoseAfterEvict_SingleThread_DirectRenderer) { |
| 502 lose_after_evict_ = true; | 531 lose_after_evict_ = true; |
| 503 RunTest(false, false, false); | 532 RunTest(false, false, false); |
| 504 } | 533 } |
| 505 | 534 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 561 TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures, | 590 TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures, |
| 562 LoseBeforeEvict_MultiThread_DelegatingRenderer_ImplSidePaint) { | 591 LoseBeforeEvict_MultiThread_DelegatingRenderer_ImplSidePaint) { |
| 563 lose_after_evict_ = false; | 592 lose_after_evict_ = false; |
| 564 RunTest(true, true, true); | 593 RunTest(true, true, true); |
| 565 } | 594 } |
| 566 | 595 |
| 567 class LayerTreeHostContextTestLostContextWhileUpdatingResources | 596 class LayerTreeHostContextTestLostContextWhileUpdatingResources |
| 568 : public LayerTreeHostContextTest { | 597 : public LayerTreeHostContextTest { |
| 569 public: | 598 public: |
| 570 LayerTreeHostContextTestLostContextWhileUpdatingResources() | 599 LayerTreeHostContextTestLostContextWhileUpdatingResources() |
| 571 : parent_(FakeContentLayer::Create(&client_)), | 600 : num_children_(50), times_to_lose_on_end_query_(3) {} |
| 572 num_children_(50), | |
| 573 times_to_lose_on_end_query_(3) {} | |
| 574 | 601 |
| 575 virtual scoped_ptr<TestWebGraphicsContext3D> CreateContext3d() OVERRIDE { | 602 virtual scoped_ptr<TestWebGraphicsContext3D> CreateContext3d() OVERRIDE { |
| 576 scoped_ptr<TestWebGraphicsContext3D> context = | 603 scoped_ptr<TestWebGraphicsContext3D> context = |
| 577 LayerTreeHostContextTest::CreateContext3d(); | 604 LayerTreeHostContextTest::CreateContext3d(); |
| 578 if (times_to_lose_on_end_query_) { | 605 if (times_to_lose_on_end_query_) { |
| 579 --times_to_lose_on_end_query_; | 606 --times_to_lose_on_end_query_; |
| 580 context->set_times_end_query_succeeds(5); | 607 context->set_times_end_query_succeeds(5); |
| 581 } | 608 } |
| 582 return context.Pass(); | 609 return context.Pass(); |
| 583 } | 610 } |
| 584 | 611 |
| 585 virtual void SetupTree() OVERRIDE { | 612 virtual void SetupTree() OVERRIDE { |
| 613 if (layer_tree_host()->settings().impl_side_painting) | |
| 614 parent_ = FakePictureLayer::Create(&client_); | |
| 615 else | |
| 616 parent_ = FakeContentLayer::Create(&client_); | |
| 617 | |
| 586 parent_->SetBounds(gfx::Size(num_children_, 1)); | 618 parent_->SetBounds(gfx::Size(num_children_, 1)); |
| 587 | 619 |
| 588 for (int i = 0; i < num_children_; i++) { | 620 for (int i = 0; i < num_children_; i++) { |
| 589 scoped_refptr<FakeContentLayer> child = | 621 scoped_refptr<Layer> child; |
| 590 FakeContentLayer::Create(&client_); | 622 if (layer_tree_host()->settings().impl_side_painting) |
| 623 child = FakePictureLayer::Create(&client_); | |
| 624 else | |
| 625 child = FakeContentLayer::Create(&client_); | |
| 591 child->SetPosition(gfx::PointF(i, 0.f)); | 626 child->SetPosition(gfx::PointF(i, 0.f)); |
| 592 child->SetBounds(gfx::Size(1, 1)); | 627 child->SetBounds(gfx::Size(1, 1)); |
| 593 parent_->AddChild(child); | 628 parent_->AddChild(child); |
| 594 } | 629 } |
| 595 | 630 |
| 596 layer_tree_host()->SetRootLayer(parent_); | 631 layer_tree_host()->SetRootLayer(parent_); |
| 597 LayerTreeHostContextTest::SetupTree(); | 632 LayerTreeHostContextTest::SetupTree(); |
| 598 } | 633 } |
| 599 | 634 |
| 600 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 635 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
| 601 | 636 |
| 602 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 637 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 603 EXPECT_EQ(0, times_to_lose_on_end_query_); | 638 EXPECT_EQ(0, times_to_lose_on_end_query_); |
| 604 EndTest(); | 639 EndTest(); |
| 605 } | 640 } |
| 606 | 641 |
| 607 virtual void AfterTest() OVERRIDE { | 642 virtual void AfterTest() OVERRIDE { |
| 608 EXPECT_EQ(0, times_to_lose_on_end_query_); | 643 EXPECT_EQ(0, times_to_lose_on_end_query_); |
| 609 } | 644 } |
| 610 | 645 |
| 611 private: | 646 private: |
| 612 FakeContentLayerClient client_; | 647 FakeContentLayerClient client_; |
| 613 scoped_refptr<FakeContentLayer> parent_; | 648 scoped_refptr<Layer> parent_; |
| 614 int num_children_; | 649 int num_children_; |
| 615 int times_to_lose_on_end_query_; | 650 int times_to_lose_on_end_query_; |
| 616 }; | 651 }; |
| 617 | 652 |
| 618 SINGLE_AND_MULTI_THREAD_NOIMPL_TEST_F( | 653 SINGLE_AND_MULTI_THREAD_NOIMPL_TEST_F( |
| 619 LayerTreeHostContextTestLostContextWhileUpdatingResources); | 654 LayerTreeHostContextTestLostContextWhileUpdatingResources); |
| 620 | 655 |
| 621 class LayerTreeHostContextTestLayersNotified : public LayerTreeHostContextTest { | 656 class LayerTreeHostContextTestLayersNotified : public LayerTreeHostContextTest { |
| 622 public: | 657 public: |
| 623 LayerTreeHostContextTestLayersNotified() | 658 LayerTreeHostContextTestLayersNotified() |
| 624 : LayerTreeHostContextTest(), num_commits_(0) {} | 659 : LayerTreeHostContextTest(), num_commits_(0) {} |
| 625 | 660 |
| 626 virtual void SetupTree() OVERRIDE { | 661 virtual void SetupTree() OVERRIDE { |
| 627 root_ = FakeContentLayer::Create(&client_); | 662 if (layer_tree_host()->settings().impl_side_painting) { |
| 628 child_ = FakeContentLayer::Create(&client_); | 663 root_ = FakePictureLayer::Create(&client_); |
| 629 grandchild_ = FakeContentLayer::Create(&client_); | 664 child_ = FakePictureLayer::Create(&client_); |
| 665 grandchild_ = FakePictureLayer::Create(&client_); | |
| 666 } else { | |
| 667 root_ = FakeContentLayer::Create(&client_); | |
| 668 child_ = FakeContentLayer::Create(&client_); | |
| 669 grandchild_ = FakeContentLayer::Create(&client_); | |
| 670 } | |
| 630 | 671 |
| 631 root_->AddChild(child_); | 672 root_->AddChild(child_); |
| 632 child_->AddChild(grandchild_); | 673 child_->AddChild(grandchild_); |
| 633 | 674 |
| 634 layer_tree_host()->SetRootLayer(root_); | 675 layer_tree_host()->SetRootLayer(root_); |
| 635 LayerTreeHostContextTest::SetupTree(); | 676 LayerTreeHostContextTest::SetupTree(); |
| 636 } | 677 } |
| 637 | 678 |
| 638 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 679 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
| 639 | 680 |
| 640 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 681 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 641 LayerTreeHostContextTest::DidActivateTreeOnThread(host_impl); | 682 LayerTreeHostContextTest::DidActivateTreeOnThread(host_impl); |
| 642 | 683 |
| 643 FakeContentLayerImpl* root = static_cast<FakeContentLayerImpl*>( | 684 FakePictureLayerImpl* root_picture = NULL; |
| 644 host_impl->active_tree()->root_layer()); | 685 FakePictureLayerImpl* child_picture = NULL; |
| 645 FakeContentLayerImpl* child = | 686 FakePictureLayerImpl* grandchild_picture = NULL; |
| 646 static_cast<FakeContentLayerImpl*>(root->children()[0]); | 687 FakeContentLayerImpl* root_content = NULL; |
| 647 FakeContentLayerImpl* grandchild = | 688 FakeContentLayerImpl* child_content = NULL; |
| 648 static_cast<FakeContentLayerImpl*>(child->children()[0]); | 689 FakeContentLayerImpl* grandchild_content = NULL; |
| 690 | |
| 691 if (layer_tree_host()->settings().impl_side_painting) { | |
| 692 root_picture = static_cast<FakePictureLayerImpl*>( | |
| 693 host_impl->active_tree()->root_layer()); | |
| 694 child_picture = | |
| 695 static_cast<FakePictureLayerImpl*>(root_picture->children()[0]); | |
| 696 grandchild_picture = | |
| 697 static_cast<FakePictureLayerImpl*>(child_picture->children()[0]); | |
| 698 | |
| 699 } else { | |
| 700 root_content = static_cast<FakeContentLayerImpl*>( | |
| 701 host_impl->active_tree()->root_layer()); | |
| 702 child_content = | |
| 703 static_cast<FakeContentLayerImpl*>(root_content->children()[0]); | |
| 704 grandchild_content = | |
| 705 static_cast<FakeContentLayerImpl*>(child_content->children()[0]); | |
| 706 } | |
| 649 | 707 |
| 650 ++num_commits_; | 708 ++num_commits_; |
| 651 switch (num_commits_) { | 709 switch (num_commits_) { |
| 652 case 1: | 710 case 1: |
| 653 EXPECT_EQ(0u, root->lost_output_surface_count()); | 711 if (layer_tree_host()->settings().impl_side_painting) { |
| 654 EXPECT_EQ(0u, child->lost_output_surface_count()); | 712 EXPECT_EQ(0u, root_picture->lost_output_surface_count()); |
| 655 EXPECT_EQ(0u, grandchild->lost_output_surface_count()); | 713 EXPECT_EQ(0u, child_picture->lost_output_surface_count()); |
| 714 EXPECT_EQ(0u, grandchild_picture->lost_output_surface_count()); | |
| 715 } else { | |
| 716 EXPECT_EQ(0u, root_content->lost_output_surface_count()); | |
| 717 EXPECT_EQ(0u, child_content->lost_output_surface_count()); | |
| 718 EXPECT_EQ(0u, grandchild_content->lost_output_surface_count()); | |
| 719 } | |
| 720 | |
| 656 // Lose the context and struggle to recreate it. | 721 // Lose the context and struggle to recreate it. |
| 657 LoseContext(); | 722 LoseContext(); |
| 658 times_to_fail_create_ = 1; | 723 times_to_fail_create_ = 1; |
| 659 break; | 724 break; |
| 660 case 2: | 725 case 2: |
| 661 EXPECT_GE(1u, root->lost_output_surface_count()); | 726 if (layer_tree_host()->settings().impl_side_painting) { |
| 662 EXPECT_GE(1u, child->lost_output_surface_count()); | 727 EXPECT_TRUE(root_picture->lost_output_surface_count()); |
| 663 EXPECT_GE(1u, grandchild->lost_output_surface_count()); | 728 EXPECT_TRUE(child_picture->lost_output_surface_count()); |
| 729 EXPECT_TRUE(grandchild_picture->lost_output_surface_count()); | |
| 730 } else { | |
| 731 EXPECT_TRUE(root_content->lost_output_surface_count()); | |
| 732 EXPECT_TRUE(child_content->lost_output_surface_count()); | |
| 733 EXPECT_TRUE(grandchild_content->lost_output_surface_count()); | |
| 734 } | |
| 735 | |
| 664 EndTest(); | 736 EndTest(); |
| 665 break; | 737 break; |
| 666 default: | 738 default: |
| 667 NOTREACHED(); | 739 NOTREACHED(); |
| 668 } | 740 } |
| 669 } | 741 } |
| 670 | 742 |
| 671 virtual void AfterTest() OVERRIDE {} | 743 virtual void AfterTest() OVERRIDE {} |
| 672 | 744 |
| 673 private: | 745 private: |
| 674 int num_commits_; | 746 int num_commits_; |
| 675 | 747 |
| 676 FakeContentLayerClient client_; | 748 FakeContentLayerClient client_; |
| 677 scoped_refptr<FakeContentLayer> root_; | 749 scoped_refptr<Layer> root_; |
| 678 scoped_refptr<FakeContentLayer> child_; | 750 scoped_refptr<Layer> child_; |
| 679 scoped_refptr<FakeContentLayer> grandchild_; | 751 scoped_refptr<Layer> grandchild_; |
| 680 }; | 752 }; |
| 681 | 753 |
| 682 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestLayersNotified); | 754 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestLayersNotified); |
| 683 | 755 |
| 684 class LayerTreeHostContextTestDontUseLostResources | 756 class LayerTreeHostContextTestDontUseLostResources |
| 685 : public LayerTreeHostContextTest { | 757 : public LayerTreeHostContextTest { |
| 686 public: | 758 public: |
| 687 LayerTreeHostContextTestDontUseLostResources() : lost_context_(false) { | 759 LayerTreeHostContextTestDontUseLostResources() : lost_context_(false) { |
| 688 context_should_support_io_surface_ = true; | 760 context_should_support_io_surface_ = true; |
| 689 | 761 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 747 scoped_refptr<Layer> root = Layer::Create(); | 819 scoped_refptr<Layer> root = Layer::Create(); |
| 748 root->SetBounds(gfx::Size(10, 10)); | 820 root->SetBounds(gfx::Size(10, 10)); |
| 749 root->SetIsDrawable(true); | 821 root->SetIsDrawable(true); |
| 750 | 822 |
| 751 scoped_refptr<FakeDelegatedRendererLayer> delegated = | 823 scoped_refptr<FakeDelegatedRendererLayer> delegated = |
| 752 FakeDelegatedRendererLayer::Create(delegated_frame_provider_.get()); | 824 FakeDelegatedRendererLayer::Create(delegated_frame_provider_.get()); |
| 753 delegated->SetBounds(gfx::Size(10, 10)); | 825 delegated->SetBounds(gfx::Size(10, 10)); |
| 754 delegated->SetIsDrawable(true); | 826 delegated->SetIsDrawable(true); |
| 755 root->AddChild(delegated); | 827 root->AddChild(delegated); |
| 756 | 828 |
| 757 scoped_refptr<ContentLayer> content = ContentLayer::Create(&client_); | 829 scoped_refptr<Layer> layer; |
| 758 content->SetBounds(gfx::Size(10, 10)); | 830 if (layer_tree_host()->settings().impl_side_painting) |
| 759 content->SetIsDrawable(true); | 831 layer = PictureLayer::Create(&client_); |
| 760 root->AddChild(content); | 832 else |
| 833 layer = ContentLayer::Create(&client_); | |
| 834 layer->SetBounds(gfx::Size(10, 10)); | |
| 835 layer->SetIsDrawable(true); | |
| 836 root->AddChild(layer); | |
| 761 | 837 |
| 762 scoped_refptr<TextureLayer> texture = TextureLayer::CreateForMailbox(NULL); | 838 scoped_refptr<TextureLayer> texture = TextureLayer::CreateForMailbox(NULL); |
| 763 texture->SetBounds(gfx::Size(10, 10)); | 839 texture->SetBounds(gfx::Size(10, 10)); |
| 764 texture->SetIsDrawable(true); | 840 texture->SetIsDrawable(true); |
| 765 texture->SetTextureMailbox( | 841 texture->SetTextureMailbox( |
| 766 TextureMailbox(mailbox, GL_TEXTURE_2D, sync_point), | 842 TextureMailbox(mailbox, GL_TEXTURE_2D, sync_point), |
| 767 SingleReleaseCallback::Create( | 843 SingleReleaseCallback::Create( |
| 768 base::Bind(&LayerTreeHostContextTestDontUseLostResources:: | 844 base::Bind(&LayerTreeHostContextTestDontUseLostResources:: |
| 769 EmptyReleaseCallback))); | 845 EmptyReleaseCallback))); |
| 770 root->AddChild(texture); | 846 root->AddChild(texture); |
| 771 | 847 |
| 772 scoped_refptr<ContentLayer> mask = ContentLayer::Create(&client_); | 848 scoped_refptr<Layer> mask; |
| 849 if (layer_tree_host()->settings().impl_side_painting) | |
| 850 mask = PictureLayer::Create(&client_); | |
| 851 else | |
| 852 mask = ContentLayer::Create(&client_); | |
| 773 mask->SetBounds(gfx::Size(10, 10)); | 853 mask->SetBounds(gfx::Size(10, 10)); |
| 774 | 854 |
| 775 scoped_refptr<ContentLayer> content_with_mask = | 855 scoped_refptr<Layer> layer_with_mask; |
| 776 ContentLayer::Create(&client_); | 856 if (layer_tree_host()->settings().impl_side_painting) |
| 777 content_with_mask->SetBounds(gfx::Size(10, 10)); | 857 layer_with_mask = PictureLayer::Create(&client_); |
| 778 content_with_mask->SetIsDrawable(true); | 858 else |
| 779 content_with_mask->SetMaskLayer(mask.get()); | 859 layer_with_mask = ContentLayer::Create(&client_); |
| 780 root->AddChild(content_with_mask); | 860 layer_with_mask->SetBounds(gfx::Size(10, 10)); |
| 861 layer_with_mask->SetIsDrawable(true); | |
| 862 layer_with_mask->SetMaskLayer(mask.get()); | |
| 863 root->AddChild(layer_with_mask); | |
| 781 | 864 |
| 782 scoped_refptr<VideoLayer> video_color = | 865 scoped_refptr<VideoLayer> video_color = |
| 783 VideoLayer::Create(&color_frame_provider_, media::VIDEO_ROTATION_0); | 866 VideoLayer::Create(&color_frame_provider_, media::VIDEO_ROTATION_0); |
| 784 video_color->SetBounds(gfx::Size(10, 10)); | 867 video_color->SetBounds(gfx::Size(10, 10)); |
| 785 video_color->SetIsDrawable(true); | 868 video_color->SetIsDrawable(true); |
| 786 root->AddChild(video_color); | 869 root->AddChild(video_color); |
| 787 | 870 |
| 788 scoped_refptr<VideoLayer> video_hw = | 871 scoped_refptr<VideoLayer> video_hw = |
| 789 VideoLayer::Create(&hw_frame_provider_, media::VIDEO_ROTATION_0); | 872 VideoLayer::Create(&hw_frame_provider_, media::VIDEO_ROTATION_0); |
| 790 video_hw->SetBounds(gfx::Size(10, 10)); | 873 video_hw->SetBounds(gfx::Size(10, 10)); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 831 root->AddChild(io_surface); | 914 root->AddChild(io_surface); |
| 832 } | 915 } |
| 833 | 916 |
| 834 // Enable the hud. | 917 // Enable the hud. |
| 835 LayerTreeDebugState debug_state; | 918 LayerTreeDebugState debug_state; |
| 836 debug_state.show_property_changed_rects = true; | 919 debug_state.show_property_changed_rects = true; |
| 837 layer_tree_host()->SetDebugState(debug_state); | 920 layer_tree_host()->SetDebugState(debug_state); |
| 838 | 921 |
| 839 scoped_refptr<PaintedScrollbarLayer> scrollbar = | 922 scoped_refptr<PaintedScrollbarLayer> scrollbar = |
| 840 PaintedScrollbarLayer::Create( | 923 PaintedScrollbarLayer::Create( |
| 841 scoped_ptr<Scrollbar>(new FakeScrollbar).Pass(), content->id()); | 924 scoped_ptr<Scrollbar>(new FakeScrollbar).Pass(), layer->id()); |
| 842 scrollbar->SetBounds(gfx::Size(10, 10)); | 925 scrollbar->SetBounds(gfx::Size(10, 10)); |
| 843 scrollbar->SetIsDrawable(true); | 926 scrollbar->SetIsDrawable(true); |
| 844 root->AddChild(scrollbar); | 927 root->AddChild(scrollbar); |
| 845 | 928 |
| 846 layer_tree_host()->SetRootLayer(root); | 929 layer_tree_host()->SetRootLayer(root); |
| 847 LayerTreeHostContextTest::SetupTree(); | 930 LayerTreeHostContextTest::SetupTree(); |
| 848 } | 931 } |
| 849 | 932 |
| 850 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 933 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
| 851 | 934 |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1404 } | 1487 } |
| 1405 } | 1488 } |
| 1406 }; | 1489 }; |
| 1407 | 1490 |
| 1408 SINGLE_AND_MULTI_THREAD_TEST_F(UIResourceLostEviction); | 1491 SINGLE_AND_MULTI_THREAD_TEST_F(UIResourceLostEviction); |
| 1409 | 1492 |
| 1410 class LayerTreeHostContextTestSurfaceCreateCallback | 1493 class LayerTreeHostContextTestSurfaceCreateCallback |
| 1411 : public LayerTreeHostContextTest { | 1494 : public LayerTreeHostContextTest { |
| 1412 public: | 1495 public: |
| 1413 LayerTreeHostContextTestSurfaceCreateCallback() | 1496 LayerTreeHostContextTestSurfaceCreateCallback() |
| 1414 : LayerTreeHostContextTest(), | 1497 : LayerTreeHostContextTest() {} |
| 1415 layer_(FakeContentLayer::Create(&client_)) {} | |
| 1416 | 1498 |
| 1417 virtual void SetupTree() OVERRIDE { | 1499 virtual void SetupTree() OVERRIDE { |
| 1418 layer_->SetBounds(gfx::Size(10, 20)); | 1500 if (layer_tree_host()->settings().impl_side_painting) { |
| 1419 layer_tree_host()->SetRootLayer(layer_); | 1501 picture_layer_ = FakePictureLayer::Create(&client_); |
| 1502 picture_layer_->SetBounds(gfx::Size(10, 20)); | |
| 1503 layer_tree_host()->SetRootLayer(picture_layer_); | |
| 1504 } else { | |
| 1505 content_layer_ = FakeContentLayer::Create(&client_); | |
| 1506 content_layer_->SetBounds(gfx::Size(10, 20)); | |
| 1507 layer_tree_host()->SetRootLayer(content_layer_); | |
| 1508 } | |
| 1509 | |
| 1420 LayerTreeHostContextTest::SetupTree(); | 1510 LayerTreeHostContextTest::SetupTree(); |
| 1421 } | 1511 } |
| 1422 | 1512 |
| 1423 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 1513 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
| 1424 | 1514 |
| 1425 virtual void DidCommit() OVERRIDE { | 1515 virtual void DidCommit() OVERRIDE { |
| 1426 switch (layer_tree_host()->source_frame_number()) { | 1516 switch (layer_tree_host()->source_frame_number()) { |
| 1427 case 1: | 1517 case 1: |
| 1428 EXPECT_EQ(1u, layer_->output_surface_created_count()); | 1518 if (layer_tree_host()->settings().impl_side_painting) |
| 1519 EXPECT_EQ(1u, picture_layer_->output_surface_created_count()); | |
| 1520 else | |
| 1521 EXPECT_EQ(1u, content_layer_->output_surface_created_count()); | |
| 1429 layer_tree_host()->SetNeedsCommit(); | 1522 layer_tree_host()->SetNeedsCommit(); |
| 1430 break; | 1523 break; |
| 1431 case 2: | 1524 case 2: |
| 1432 EXPECT_EQ(1u, layer_->output_surface_created_count()); | 1525 if (layer_tree_host()->settings().impl_side_painting) |
| 1526 EXPECT_EQ(1u, picture_layer_->output_surface_created_count()); | |
| 1527 else | |
| 1528 EXPECT_EQ(1u, content_layer_->output_surface_created_count()); | |
| 1433 layer_tree_host()->SetNeedsCommit(); | 1529 layer_tree_host()->SetNeedsCommit(); |
| 1434 break; | 1530 break; |
| 1435 case 3: | 1531 case 3: |
| 1436 EXPECT_EQ(1u, layer_->output_surface_created_count()); | 1532 if (layer_tree_host()->settings().impl_side_painting) |
| 1533 EXPECT_EQ(1u, picture_layer_->output_surface_created_count()); | |
| 1534 else | |
| 1535 EXPECT_EQ(1u, content_layer_->output_surface_created_count()); | |
| 1437 break; | 1536 break; |
| 1438 case 4: | 1537 case 4: |
| 1439 EXPECT_EQ(2u, layer_->output_surface_created_count()); | 1538 if (layer_tree_host()->settings().impl_side_painting) |
| 1539 EXPECT_EQ(2u, picture_layer_->output_surface_created_count()); | |
| 1540 else | |
| 1541 EXPECT_EQ(2u, content_layer_->output_surface_created_count()); | |
| 1440 layer_tree_host()->SetNeedsCommit(); | 1542 layer_tree_host()->SetNeedsCommit(); |
| 1441 break; | 1543 break; |
| 1442 } | 1544 } |
| 1443 } | 1545 } |
| 1444 | 1546 |
| 1445 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 1547 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
| 1446 LayerTreeHostContextTest::CommitCompleteOnThread(impl); | 1548 LayerTreeHostContextTest::CommitCompleteOnThread(impl); |
| 1447 switch (LastCommittedSourceFrameNumber(impl)) { | 1549 switch (LastCommittedSourceFrameNumber(impl)) { |
| 1448 case 0: | 1550 case 0: |
| 1449 break; | 1551 break; |
| 1450 case 1: | 1552 case 1: |
| 1451 break; | 1553 break; |
| 1452 case 2: | 1554 case 2: |
| 1453 LoseContext(); | 1555 LoseContext(); |
| 1454 break; | 1556 break; |
| 1455 case 3: | 1557 case 3: |
| 1456 EndTest(); | 1558 EndTest(); |
| 1457 break; | 1559 break; |
| 1458 } | 1560 } |
| 1459 } | 1561 } |
| 1460 | 1562 |
| 1461 virtual void AfterTest() OVERRIDE {} | 1563 virtual void AfterTest() OVERRIDE {} |
| 1462 | 1564 |
| 1463 protected: | 1565 protected: |
| 1464 FakeContentLayerClient client_; | 1566 FakeContentLayerClient client_; |
| 1465 scoped_refptr<FakeContentLayer> layer_; | 1567 scoped_refptr<FakePictureLayer> picture_layer_; |
| 1568 scoped_refptr<FakeContentLayer> content_layer_; | |
| 1466 }; | 1569 }; |
| 1467 | 1570 |
| 1468 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestSurfaceCreateCallback); | 1571 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestSurfaceCreateCallback); |
| 1469 | 1572 |
| 1470 class LayerTreeHostContextTestLoseAfterSendingBeginMainFrame | 1573 class LayerTreeHostContextTestLoseAfterSendingBeginMainFrame |
| 1471 : public LayerTreeHostContextTest { | 1574 : public LayerTreeHostContextTest { |
| 1472 protected: | 1575 protected: |
| 1473 virtual void BeginTest() OVERRIDE { | 1576 virtual void BeginTest() OVERRIDE { |
| 1474 deferred_ = false; | 1577 deferred_ = false; |
| 1475 PostSetNeedsCommitToMainThread(); | 1578 PostSetNeedsCommitToMainThread(); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1521 virtual void AfterTest() OVERRIDE {} | 1624 virtual void AfterTest() OVERRIDE {} |
| 1522 | 1625 |
| 1523 bool deferred_; | 1626 bool deferred_; |
| 1524 }; | 1627 }; |
| 1525 | 1628 |
| 1526 SINGLE_AND_MULTI_THREAD_TEST_F( | 1629 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 1527 LayerTreeHostContextTestLoseAfterSendingBeginMainFrame); | 1630 LayerTreeHostContextTestLoseAfterSendingBeginMainFrame); |
| 1528 | 1631 |
| 1529 } // namespace | 1632 } // namespace |
| 1530 } // namespace cc | 1633 } // namespace cc |
| OLD | NEW |