| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/trees/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 | 432 |
| 433 private: | 433 private: |
| 434 FakeContentLayerClient client_; | 434 FakeContentLayerClient client_; |
| 435 scoped_refptr<Layer> root_layer_; | 435 scoped_refptr<Layer> root_layer_; |
| 436 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_; | 436 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_; |
| 437 }; | 437 }; |
| 438 | 438 |
| 439 SINGLE_AND_MULTI_THREAD_TEST_F( | 439 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 440 LayerTreeHostTestNoExtraCommitFromScrollbarInvalidate); | 440 LayerTreeHostTestNoExtraCommitFromScrollbarInvalidate); |
| 441 | 441 |
| 442 class LayerTreeHostTestCompositeAndReadback : public LayerTreeHostTest { | |
| 443 public: | |
| 444 LayerTreeHostTestCompositeAndReadback() : num_commits_(0) {} | |
| 445 | |
| 446 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | |
| 447 | |
| 448 virtual void DidCommit() OVERRIDE { | |
| 449 num_commits_++; | |
| 450 if (num_commits_ == 1) { | |
| 451 char pixels[4]; | |
| 452 layer_tree_host()->CompositeAndReadback(&pixels, gfx::Rect(0, 0, 1, 1)); | |
| 453 } else if (num_commits_ == 2) { | |
| 454 // This is inside the readback. We should get another commit after it. | |
| 455 } else if (num_commits_ == 3) { | |
| 456 EndTest(); | |
| 457 } else { | |
| 458 NOTREACHED(); | |
| 459 } | |
| 460 } | |
| 461 | |
| 462 virtual void AfterTest() OVERRIDE {} | |
| 463 | |
| 464 private: | |
| 465 int num_commits_; | |
| 466 }; | |
| 467 | |
| 468 MULTI_THREAD_TEST_F(LayerTreeHostTestCompositeAndReadback); | |
| 469 | |
| 470 class LayerTreeHostTestCompositeAndReadbackBeforePreviousCommitDraws | |
| 471 : public LayerTreeHostTest { | |
| 472 public: | |
| 473 LayerTreeHostTestCompositeAndReadbackBeforePreviousCommitDraws() | |
| 474 : num_commits_(0) {} | |
| 475 | |
| 476 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | |
| 477 | |
| 478 virtual void DidCommit() OVERRIDE { | |
| 479 num_commits_++; | |
| 480 if (num_commits_ == 1) { | |
| 481 layer_tree_host()->SetNeedsCommit(); | |
| 482 } else if (num_commits_ == 2) { | |
| 483 char pixels[4]; | |
| 484 layer_tree_host()->CompositeAndReadback(&pixels, gfx::Rect(0, 0, 1, 1)); | |
| 485 } else if (num_commits_ == 3) { | |
| 486 // This is inside the readback. We should get another commit after it. | |
| 487 } else if (num_commits_ == 4) { | |
| 488 EndTest(); | |
| 489 } else { | |
| 490 NOTREACHED(); | |
| 491 } | |
| 492 } | |
| 493 | |
| 494 virtual void AfterTest() OVERRIDE {} | |
| 495 | |
| 496 private: | |
| 497 int num_commits_; | |
| 498 }; | |
| 499 | |
| 500 MULTI_THREAD_TEST_F( | |
| 501 LayerTreeHostTestCompositeAndReadbackBeforePreviousCommitDraws); | |
| 502 | |
| 503 class LayerTreeHostTestCompositeAndReadbackDuringForcedDraw | |
| 504 : public LayerTreeHostTest { | |
| 505 protected: | |
| 506 static const int kFirstCommitSourceFrameNumber = 0; | |
| 507 static const int kReadbackSourceFrameNumber = 1; | |
| 508 static const int kReadbackReplacementAndForcedDrawSourceFrameNumber = 2; | |
| 509 | |
| 510 LayerTreeHostTestCompositeAndReadbackDuringForcedDraw() | |
| 511 : did_post_readback_(false) {} | |
| 512 | |
| 513 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { | |
| 514 // This enables forced draws after a single prepare to draw failure. | |
| 515 settings->timeout_and_draw_when_animation_checkerboards = true; | |
| 516 settings->maximum_number_of_failed_draws_before_draw_is_forced_ = 1; | |
| 517 } | |
| 518 | |
| 519 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | |
| 520 | |
| 521 virtual DrawResult PrepareToDrawOnThread( | |
| 522 LayerTreeHostImpl* host_impl, | |
| 523 LayerTreeHostImpl::FrameData* frame_data, | |
| 524 DrawResult draw_result) OVERRIDE { | |
| 525 int sfn = host_impl->active_tree()->source_frame_number(); | |
| 526 EXPECT_TRUE(sfn == kFirstCommitSourceFrameNumber || | |
| 527 sfn == kReadbackSourceFrameNumber || | |
| 528 sfn == kReadbackReplacementAndForcedDrawSourceFrameNumber) | |
| 529 << sfn; | |
| 530 | |
| 531 // Before we react to the failed draw by initiating the forced draw | |
| 532 // sequence, start a readback on the main thread. | |
| 533 if (sfn == kFirstCommitSourceFrameNumber && !did_post_readback_) { | |
| 534 did_post_readback_ = true; | |
| 535 PostReadbackToMainThread(); | |
| 536 } | |
| 537 | |
| 538 // Aborting for checkerboarding animations will result in a forced draw. | |
| 539 return DRAW_ABORTED_CHECKERBOARD_ANIMATIONS; | |
| 540 } | |
| 541 | |
| 542 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | |
| 543 // We should only draw for the readback and the forced draw. | |
| 544 int sfn = host_impl->active_tree()->source_frame_number(); | |
| 545 EXPECT_TRUE(sfn == kReadbackSourceFrameNumber || | |
| 546 sfn == kReadbackReplacementAndForcedDrawSourceFrameNumber) | |
| 547 << sfn; | |
| 548 } | |
| 549 | |
| 550 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, | |
| 551 bool result) OVERRIDE { | |
| 552 // We should only swap for the forced draw. | |
| 553 int sfn = host_impl->active_tree()->source_frame_number(); | |
| 554 EXPECT_TRUE(sfn == kReadbackReplacementAndForcedDrawSourceFrameNumber) | |
| 555 << sfn; | |
| 556 EndTest(); | |
| 557 } | |
| 558 | |
| 559 virtual void AfterTest() OVERRIDE {} | |
| 560 | |
| 561 bool did_post_readback_; | |
| 562 }; | |
| 563 | |
| 564 MULTI_THREAD_TEST_F(LayerTreeHostTestCompositeAndReadbackDuringForcedDraw); | |
| 565 | |
| 566 class LayerTreeHostTestCompositeAndReadbackAfterForcedDraw | |
| 567 : public LayerTreeHostTest { | |
| 568 protected: | |
| 569 static const int kFirstCommitSourceFrameNumber = 0; | |
| 570 static const int kForcedDrawSourceFrameNumber = 1; | |
| 571 static const int kReadbackSourceFrameNumber = 2; | |
| 572 static const int kReadbackReplacementSourceFrameNumber = 3; | |
| 573 | |
| 574 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { | |
| 575 // This enables forced draws after a single prepare to draw failure. | |
| 576 settings->timeout_and_draw_when_animation_checkerboards = true; | |
| 577 settings->maximum_number_of_failed_draws_before_draw_is_forced_ = 1; | |
| 578 } | |
| 579 | |
| 580 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | |
| 581 | |
| 582 virtual DrawResult PrepareToDrawOnThread( | |
| 583 LayerTreeHostImpl* host_impl, | |
| 584 LayerTreeHostImpl::FrameData* frame_data, | |
| 585 DrawResult draw_result) OVERRIDE { | |
| 586 int sfn = host_impl->active_tree()->source_frame_number(); | |
| 587 EXPECT_TRUE(sfn == kFirstCommitSourceFrameNumber || | |
| 588 sfn == kForcedDrawSourceFrameNumber || | |
| 589 sfn == kReadbackSourceFrameNumber || | |
| 590 sfn == kReadbackReplacementSourceFrameNumber) | |
| 591 << sfn; | |
| 592 | |
| 593 // Aborting for checkerboarding animations will result in a forced draw. | |
| 594 return DRAW_ABORTED_CHECKERBOARD_ANIMATIONS; | |
| 595 } | |
| 596 | |
| 597 virtual void DidCommit() OVERRIDE { | |
| 598 if (layer_tree_host()->source_frame_number() == | |
| 599 kForcedDrawSourceFrameNumber) { | |
| 600 // Avoid aborting the forced draw commit so source_frame_number | |
| 601 // increments. | |
| 602 layer_tree_host()->SetNeedsCommit(); | |
| 603 } else if (layer_tree_host()->source_frame_number() == | |
| 604 kReadbackSourceFrameNumber) { | |
| 605 // Perform a readback immediately after the forced draw's commit. | |
| 606 char pixels[4]; | |
| 607 layer_tree_host()->CompositeAndReadback(&pixels, gfx::Rect(0, 0, 1, 1)); | |
| 608 } | |
| 609 } | |
| 610 | |
| 611 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | |
| 612 // We should only draw for the the forced draw, readback, and | |
| 613 // replacement commit. | |
| 614 int sfn = host_impl->active_tree()->source_frame_number(); | |
| 615 EXPECT_TRUE(sfn == kForcedDrawSourceFrameNumber || | |
| 616 sfn == kReadbackSourceFrameNumber || | |
| 617 sfn == kReadbackReplacementSourceFrameNumber) | |
| 618 << sfn; | |
| 619 } | |
| 620 | |
| 621 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, | |
| 622 bool result) OVERRIDE { | |
| 623 // We should only swap for the forced draw and replacement commit. | |
| 624 int sfn = host_impl->active_tree()->source_frame_number(); | |
| 625 EXPECT_TRUE(sfn == kForcedDrawSourceFrameNumber || | |
| 626 sfn == kReadbackReplacementSourceFrameNumber) | |
| 627 << sfn; | |
| 628 | |
| 629 if (sfn == kReadbackReplacementSourceFrameNumber) | |
| 630 EndTest(); | |
| 631 } | |
| 632 | |
| 633 virtual void AfterTest() OVERRIDE {} | |
| 634 }; | |
| 635 | |
| 636 MULTI_THREAD_TEST_F(LayerTreeHostTestCompositeAndReadbackAfterForcedDraw); | |
| 637 | |
| 638 class LayerTreeHostTestSetNextCommitForcesRedraw : public LayerTreeHostTest { | 442 class LayerTreeHostTestSetNextCommitForcesRedraw : public LayerTreeHostTest { |
| 639 public: | 443 public: |
| 640 LayerTreeHostTestSetNextCommitForcesRedraw() | 444 LayerTreeHostTestSetNextCommitForcesRedraw() |
| 641 : num_draws_(0), | 445 : num_draws_(0), |
| 642 bounds_(50, 50), | 446 bounds_(50, 50), |
| 643 invalid_rect_(10, 10, 20, 20), | 447 invalid_rect_(10, 10, 20, 20), |
| 644 root_layer_(ContentLayer::Create(&client_)) {} | 448 root_layer_(ContentLayer::Create(&client_)) {} |
| 645 | 449 |
| 646 virtual void BeginTest() OVERRIDE { | 450 virtual void BeginTest() OVERRIDE { |
| 647 root_layer_->SetIsDrawable(true); | 451 root_layer_->SetIsDrawable(true); |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 882 | 686 |
| 883 private: | 687 private: |
| 884 scoped_refptr<Layer> root_layer_; | 688 scoped_refptr<Layer> root_layer_; |
| 885 scoped_refptr<Layer> parent_layer_; | 689 scoped_refptr<Layer> parent_layer_; |
| 886 scoped_refptr<Layer> child_layer_; | 690 scoped_refptr<Layer> child_layer_; |
| 887 }; | 691 }; |
| 888 | 692 |
| 889 SINGLE_AND_MULTI_THREAD_TEST_F( | 693 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 890 LayerTreeHostTestUndrawnLayersPushContentBoundsLater); | 694 LayerTreeHostTestUndrawnLayersPushContentBoundsLater); |
| 891 | 695 |
| 892 // If the layerTreeHost says it can't draw, Then we should not try to draw. | |
| 893 class LayerTreeHostTestCanDrawBlocksDrawing : public LayerTreeHostTest { | |
| 894 public: | |
| 895 LayerTreeHostTestCanDrawBlocksDrawing() : done_(false) {} | |
| 896 | |
| 897 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | |
| 898 | |
| 899 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { | |
| 900 if (done_) | |
| 901 return; | |
| 902 // Only the initial draw should bring us here. | |
| 903 EXPECT_TRUE(impl->CanDraw()); | |
| 904 EXPECT_EQ(0, impl->active_tree()->source_frame_number()); | |
| 905 } | |
| 906 | |
| 907 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { | |
| 908 if (done_) | |
| 909 return; | |
| 910 if (LastCommittedSourceFrameNumber(impl) >= 1) { | |
| 911 // After the first commit, we should not be able to draw. | |
| 912 EXPECT_FALSE(impl->CanDraw()); | |
| 913 } | |
| 914 } | |
| 915 | |
| 916 virtual void DidCommit() OVERRIDE { | |
| 917 switch (layer_tree_host()->source_frame_number()) { | |
| 918 case 1: | |
| 919 // Make the viewport empty so the host says it can't draw. | |
| 920 layer_tree_host()->SetViewportSize(gfx::Size(0, 0)); | |
| 921 break; | |
| 922 case 2: { | |
| 923 char pixels[4]; | |
| 924 layer_tree_host()->CompositeAndReadback(&pixels, gfx::Rect(0, 0, 1, 1)); | |
| 925 break; | |
| 926 } | |
| 927 case 3: | |
| 928 // Let it draw so we go idle and end the test. | |
| 929 layer_tree_host()->SetViewportSize(gfx::Size(1, 1)); | |
| 930 done_ = true; | |
| 931 EndTest(); | |
| 932 break; | |
| 933 } | |
| 934 } | |
| 935 | |
| 936 virtual void AfterTest() OVERRIDE {} | |
| 937 | |
| 938 private: | |
| 939 bool done_; | |
| 940 }; | |
| 941 | |
| 942 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestCanDrawBlocksDrawing); | |
| 943 | |
| 944 // A compositeAndReadback while invisible should force a normal commit without | |
| 945 // assertion. | |
| 946 class LayerTreeHostTestCompositeAndReadbackWhileInvisible | |
| 947 : public LayerTreeHostTest { | |
| 948 public: | |
| 949 LayerTreeHostTestCompositeAndReadbackWhileInvisible() : num_commits_(0) {} | |
| 950 | |
| 951 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | |
| 952 | |
| 953 virtual void DidCommitAndDrawFrame() OVERRIDE { | |
| 954 num_commits_++; | |
| 955 if (num_commits_ == 1) { | |
| 956 layer_tree_host()->SetVisible(false); | |
| 957 layer_tree_host()->SetNeedsCommit(); | |
| 958 layer_tree_host()->SetNeedsCommit(); | |
| 959 char pixels[4]; | |
| 960 layer_tree_host()->CompositeAndReadback(&pixels, gfx::Rect(0, 0, 1, 1)); | |
| 961 } else { | |
| 962 EndTest(); | |
| 963 } | |
| 964 } | |
| 965 | |
| 966 virtual void AfterTest() OVERRIDE {} | |
| 967 | |
| 968 private: | |
| 969 int num_commits_; | |
| 970 }; | |
| 971 | |
| 972 MULTI_THREAD_TEST_F(LayerTreeHostTestCompositeAndReadbackWhileInvisible); | |
| 973 | |
| 974 class LayerTreeHostTestAbortFrameWhenInvisible : public LayerTreeHostTest { | 696 class LayerTreeHostTestAbortFrameWhenInvisible : public LayerTreeHostTest { |
| 975 public: | 697 public: |
| 976 LayerTreeHostTestAbortFrameWhenInvisible() {} | 698 LayerTreeHostTestAbortFrameWhenInvisible() {} |
| 977 | 699 |
| 978 virtual void BeginTest() OVERRIDE { | 700 virtual void BeginTest() OVERRIDE { |
| 979 // Request a commit (from the main thread), Which will trigger the commit | 701 // Request a commit (from the main thread), Which will trigger the commit |
| 980 // flow from the impl side. | 702 // flow from the impl side. |
| 981 layer_tree_host()->SetNeedsCommit(); | 703 layer_tree_host()->SetNeedsCommit(); |
| 982 // Then mark ourselves as not visible before processing any more messages | 704 // Then mark ourselves as not visible before processing any more messages |
| 983 // on the main thread. | 705 // on the main thread. |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1394 | 1116 |
| 1395 LayerImpl* root = impl->active_tree()->root_layer(); | 1117 LayerImpl* root = impl->active_tree()->root_layer(); |
| 1396 LayerImpl* child = impl->active_tree()->root_layer()->children()[0]; | 1118 LayerImpl* child = impl->active_tree()->root_layer()->children()[0]; |
| 1397 | 1119 |
| 1398 // Positions remain in layout pixels. | 1120 // Positions remain in layout pixels. |
| 1399 EXPECT_EQ(gfx::Point(0, 0), root->position()); | 1121 EXPECT_EQ(gfx::Point(0, 0), root->position()); |
| 1400 EXPECT_EQ(gfx::Point(2, 2), child->position()); | 1122 EXPECT_EQ(gfx::Point(2, 2), child->position()); |
| 1401 | 1123 |
| 1402 // Compute all the layer transforms for the frame. | 1124 // Compute all the layer transforms for the frame. |
| 1403 LayerTreeHostImpl::FrameData frame_data; | 1125 LayerTreeHostImpl::FrameData frame_data; |
| 1404 impl->PrepareToDraw(&frame_data, gfx::Rect()); | 1126 impl->PrepareToDraw(&frame_data); |
| 1405 impl->DidDrawAllLayers(frame_data); | 1127 impl->DidDrawAllLayers(frame_data); |
| 1406 | 1128 |
| 1407 const LayerImplList& render_surface_layer_list = | 1129 const LayerImplList& render_surface_layer_list = |
| 1408 *frame_data.render_surface_layer_list; | 1130 *frame_data.render_surface_layer_list; |
| 1409 | 1131 |
| 1410 // Both layers should be drawing into the root render surface. | 1132 // Both layers should be drawing into the root render surface. |
| 1411 ASSERT_EQ(1u, render_surface_layer_list.size()); | 1133 ASSERT_EQ(1u, render_surface_layer_list.size()); |
| 1412 ASSERT_EQ(root->render_surface(), | 1134 ASSERT_EQ(root->render_surface(), |
| 1413 render_surface_layer_list[0]->render_surface()); | 1135 render_surface_layer_list[0]->render_surface()); |
| 1414 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); | 1136 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1838 virtual void AfterTest() OVERRIDE {} | 1560 virtual void AfterTest() OVERRIDE {} |
| 1839 | 1561 |
| 1840 private: | 1562 private: |
| 1841 bool once_; | 1563 bool once_; |
| 1842 base::Lock lock_; | 1564 base::Lock lock_; |
| 1843 int draw_count_; | 1565 int draw_count_; |
| 1844 }; | 1566 }; |
| 1845 | 1567 |
| 1846 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestFinishAllRendering); | 1568 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestFinishAllRendering); |
| 1847 | 1569 |
| 1848 class LayerTreeHostTestCompositeAndReadbackCleanup : public LayerTreeHostTest { | |
| 1849 public: | |
| 1850 virtual void BeginTest() OVERRIDE { | |
| 1851 Layer* root_layer = layer_tree_host()->root_layer(); | |
| 1852 | |
| 1853 char pixels[4]; | |
| 1854 layer_tree_host()->CompositeAndReadback(static_cast<void*>(&pixels), | |
| 1855 gfx::Rect(0, 0, 1, 1)); | |
| 1856 EXPECT_FALSE(root_layer->render_surface()); | |
| 1857 | |
| 1858 EndTest(); | |
| 1859 } | |
| 1860 | |
| 1861 virtual void AfterTest() OVERRIDE {} | |
| 1862 }; | |
| 1863 | |
| 1864 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestCompositeAndReadbackCleanup); | |
| 1865 | |
| 1866 class LayerTreeHostTestSurfaceNotAllocatedForLayersOutsideMemoryLimit | 1570 class LayerTreeHostTestSurfaceNotAllocatedForLayersOutsideMemoryLimit |
| 1867 : public LayerTreeHostTest { | 1571 : public LayerTreeHostTest { |
| 1868 protected: | 1572 protected: |
| 1869 virtual void SetupTree() OVERRIDE { | 1573 virtual void SetupTree() OVERRIDE { |
| 1870 root_layer_ = FakeContentLayer::Create(&client_); | 1574 root_layer_ = FakeContentLayer::Create(&client_); |
| 1871 root_layer_->SetBounds(gfx::Size(100, 100)); | 1575 root_layer_->SetBounds(gfx::Size(100, 100)); |
| 1872 | 1576 |
| 1873 surface_layer1_ = FakeContentLayer::Create(&client_); | 1577 surface_layer1_ = FakeContentLayer::Create(&client_); |
| 1874 surface_layer1_->SetBounds(gfx::Size(100, 100)); | 1578 surface_layer1_->SetBounds(gfx::Size(100, 100)); |
| 1875 surface_layer1_->SetForceRenderSurface(true); | 1579 surface_layer1_->SetForceRenderSurface(true); |
| (...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2978 class LayerTreeHostTestNumFramesPending : public LayerTreeHostTest { | 2682 class LayerTreeHostTestNumFramesPending : public LayerTreeHostTest { |
| 2979 public: | 2683 public: |
| 2980 virtual void BeginTest() OVERRIDE { | 2684 virtual void BeginTest() OVERRIDE { |
| 2981 frame_ = 0; | 2685 frame_ = 0; |
| 2982 PostSetNeedsCommitToMainThread(); | 2686 PostSetNeedsCommitToMainThread(); |
| 2983 } | 2687 } |
| 2984 | 2688 |
| 2985 // Round 1: commit + draw | 2689 // Round 1: commit + draw |
| 2986 // Round 2: commit only (no draw/swap) | 2690 // Round 2: commit only (no draw/swap) |
| 2987 // Round 3: draw only (no commit) | 2691 // Round 3: draw only (no commit) |
| 2988 // Round 4: composite & readback (2 commits, no draw/swap) | |
| 2989 // Round 5: commit + draw | |
| 2990 | 2692 |
| 2991 virtual void DidCommit() OVERRIDE { | 2693 virtual void DidCommit() OVERRIDE { |
| 2992 int commit = layer_tree_host()->source_frame_number(); | 2694 int commit = layer_tree_host()->source_frame_number(); |
| 2993 switch (commit) { | 2695 switch (commit) { |
| 2994 case 2: | 2696 case 2: |
| 2995 // Round 2 done. | 2697 // Round 2 done. |
| 2996 EXPECT_EQ(1, frame_); | 2698 EXPECT_EQ(1, frame_); |
| 2997 layer_tree_host()->SetNeedsRedraw(); | 2699 layer_tree_host()->SetNeedsRedraw(); |
| 2998 break; | 2700 break; |
| 2999 case 3: | |
| 3000 // CompositeAndReadback in Round 4, first commit. | |
| 3001 EXPECT_EQ(2, frame_); | |
| 3002 break; | |
| 3003 case 4: | |
| 3004 // Round 4 done. | |
| 3005 EXPECT_EQ(2, frame_); | |
| 3006 layer_tree_host()->SetNeedsCommit(); | |
| 3007 layer_tree_host()->SetNeedsRedraw(); | |
| 3008 break; | |
| 3009 } | 2701 } |
| 3010 } | 2702 } |
| 3011 | 2703 |
| 3012 virtual void DidCompleteSwapBuffers() OVERRIDE { | 2704 virtual void DidCompleteSwapBuffers() OVERRIDE { |
| 3013 int commit = layer_tree_host()->source_frame_number(); | 2705 int commit = layer_tree_host()->source_frame_number(); |
| 3014 ++frame_; | 2706 ++frame_; |
| 3015 char pixels[4] = {0}; | |
| 3016 switch (frame_) { | 2707 switch (frame_) { |
| 3017 case 1: | 2708 case 1: |
| 3018 // Round 1 done. | 2709 // Round 1 done. |
| 3019 EXPECT_EQ(1, commit); | 2710 EXPECT_EQ(1, commit); |
| 3020 layer_tree_host()->SetNeedsCommit(); | 2711 layer_tree_host()->SetNeedsCommit(); |
| 3021 break; | 2712 break; |
| 3022 case 2: | 2713 case 2: |
| 3023 // Round 3 done. | 2714 // Round 3 done. |
| 3024 EXPECT_EQ(2, commit); | 2715 EXPECT_EQ(2, commit); |
| 3025 layer_tree_host()->CompositeAndReadback(pixels, gfx::Rect(0, 0, 1, 1)); | |
| 3026 break; | |
| 3027 case 3: | |
| 3028 // Round 5 done. | |
| 3029 EXPECT_EQ(5, commit); | |
| 3030 EndTest(); | 2716 EndTest(); |
| 3031 break; | 2717 break; |
| 3032 } | 2718 } |
| 3033 } | 2719 } |
| 3034 | 2720 |
| 3035 virtual void AfterTest() OVERRIDE {} | 2721 virtual void AfterTest() OVERRIDE {} |
| 3036 | 2722 |
| 3037 protected: | 2723 protected: |
| 3038 int frame_; | 2724 int frame_; |
| 3039 }; | 2725 }; |
| (...skipping 2243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5283 const gfx::Size bounds_; | 4969 const gfx::Size bounds_; |
| 5284 FakeContentLayerClient client_; | 4970 FakeContentLayerClient client_; |
| 5285 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; | 4971 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; |
| 5286 scoped_refptr<FakePictureLayer> picture_layer_; | 4972 scoped_refptr<FakePictureLayer> picture_layer_; |
| 5287 Layer* child_layer_; | 4973 Layer* child_layer_; |
| 5288 }; | 4974 }; |
| 5289 | 4975 |
| 5290 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); | 4976 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); |
| 5291 | 4977 |
| 5292 } // namespace cc | 4978 } // namespace cc |
| OLD | NEW |