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