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