Chromium Code Reviews| 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 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 522 virtual void AfterTest() OVERRIDE { EXPECT_EQ(5, num_draws_); } | 522 virtual void AfterTest() OVERRIDE { EXPECT_EQ(5, num_draws_); } |
| 523 | 523 |
| 524 private: | 524 private: |
| 525 int num_draws_; | 525 int num_draws_; |
| 526 const gfx::Size bounds_; | 526 const gfx::Size bounds_; |
| 527 const gfx::Rect invalid_rect_; | 527 const gfx::Rect invalid_rect_; |
| 528 FakeContentLayerClient client_; | 528 FakeContentLayerClient client_; |
| 529 scoped_refptr<ContentLayer> root_layer_; | 529 scoped_refptr<ContentLayer> root_layer_; |
| 530 }; | 530 }; |
| 531 | 531 |
| 532 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSetNextCommitForcesRedraw); | 532 SINGLE_AND_MULTI_THREAD_BLOCKNOTIFY_TEST_F( |
| 533 LayerTreeHostTestSetNextCommitForcesRedraw); | |
| 533 | 534 |
| 534 // Tests that if a layer is not drawn because of some reason in the parent then | 535 // Tests that if a layer is not drawn because of some reason in the parent then |
| 535 // its damage is preserved until the next time it is drawn. | 536 // its damage is preserved until the next time it is drawn. |
| 536 class LayerTreeHostTestUndrawnLayersDamageLater : public LayerTreeHostTest { | 537 class LayerTreeHostTestUndrawnLayersDamageLater : public LayerTreeHostTest { |
| 537 public: | 538 public: |
| 538 LayerTreeHostTestUndrawnLayersDamageLater() | 539 LayerTreeHostTestUndrawnLayersDamageLater() |
| 539 : root_layer_(ContentLayer::Create(&client_)) {} | 540 : root_layer_(ContentLayer::Create(&client_)) {} |
| 540 | 541 |
| 541 virtual void SetupTree() OVERRIDE { | 542 virtual void SetupTree() OVERRIDE { |
| 542 root_layer_->SetIsDrawable(true); | 543 root_layer_->SetIsDrawable(true); |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 730 | 731 |
| 731 virtual void BeginTest() OVERRIDE { | 732 virtual void BeginTest() OVERRIDE { |
| 732 layer_tree_host()->SetViewportSize(gfx::Size(20, 20)); | 733 layer_tree_host()->SetViewportSize(gfx::Size(20, 20)); |
| 733 layer_tree_host()->set_background_color(SK_ColorGRAY); | 734 layer_tree_host()->set_background_color(SK_ColorGRAY); |
| 734 | 735 |
| 735 PostSetNeedsCommitToMainThread(); | 736 PostSetNeedsCommitToMainThread(); |
| 736 } | 737 } |
| 737 | 738 |
| 738 virtual void BeginCommitOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 739 virtual void BeginCommitOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
| 739 EXPECT_EQ(frame_count_with_pending_tree_, 0); | 740 EXPECT_EQ(frame_count_with_pending_tree_, 0); |
| 740 impl->BlockNotifyReadyToActivateForTesting(true); | 741 if (impl->settings().impl_side_painting) |
| 742 impl->BlockNotifyReadyToActivateForTesting(true); | |
| 741 } | 743 } |
| 742 | 744 |
| 743 virtual void WillBeginImplFrameOnThread(LayerTreeHostImpl* impl, | 745 virtual void WillBeginImplFrameOnThread(LayerTreeHostImpl* impl, |
| 744 const BeginFrameArgs& args) OVERRIDE { | 746 const BeginFrameArgs& args) OVERRIDE { |
| 745 if (impl->pending_tree()) | 747 if (impl->pending_tree()) |
| 746 frame_count_with_pending_tree_++; | 748 frame_count_with_pending_tree_++; |
| 747 | 749 |
| 748 if (frame_count_with_pending_tree_ == 1) { | 750 if (frame_count_with_pending_tree_ == 1) { |
| 749 EXPECT_EQ(first_frame_time_.ToInternalValue(), 0); | 751 EXPECT_EQ(first_frame_time_.ToInternalValue(), 0); |
| 750 first_frame_time_ = impl->CurrentBeginFrameArgs().frame_time; | 752 first_frame_time_ = impl->CurrentBeginFrameArgs().frame_time; |
| 751 } else if (frame_count_with_pending_tree_ == 2) { | 753 } else if (frame_count_with_pending_tree_ == 2 && |
| 754 impl->settings().impl_side_painting) { | |
| 752 impl->BlockNotifyReadyToActivateForTesting(false); | 755 impl->BlockNotifyReadyToActivateForTesting(false); |
| 753 } | 756 } |
| 754 } | 757 } |
| 755 | 758 |
| 756 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 759 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
| 757 if (frame_count_with_pending_tree_ > 1) { | 760 if (frame_count_with_pending_tree_ > 1) { |
| 758 EXPECT_NE(first_frame_time_.ToInternalValue(), 0); | 761 EXPECT_NE(first_frame_time_.ToInternalValue(), 0); |
| 759 EXPECT_NE(first_frame_time_.ToInternalValue(), | 762 EXPECT_NE(first_frame_time_.ToInternalValue(), |
| 760 impl->CurrentBeginFrameArgs().frame_time.ToInternalValue()); | 763 impl->CurrentBeginFrameArgs().frame_time.ToInternalValue()); |
| 761 EndTest(); | 764 EndTest(); |
| 762 return; | 765 return; |
| 763 } | 766 } |
| 764 | 767 |
| 765 EXPECT_FALSE(impl->settings().impl_side_painting); | 768 EXPECT_FALSE(impl->settings().impl_side_painting); |
| 766 EndTest(); | 769 EndTest(); |
| 767 } | 770 } |
| 768 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 771 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
| 769 if (impl->settings().impl_side_painting) | 772 if (impl->settings().impl_side_painting) |
| 770 EXPECT_NE(frame_count_with_pending_tree_, 1); | 773 EXPECT_NE(frame_count_with_pending_tree_, 1); |
| 771 } | 774 } |
| 772 | 775 |
| 773 virtual void AfterTest() OVERRIDE {} | 776 virtual void AfterTest() OVERRIDE {} |
| 774 | 777 |
| 775 private: | 778 private: |
| 776 int frame_count_with_pending_tree_; | 779 int frame_count_with_pending_tree_; |
| 777 base::TimeTicks first_frame_time_; | 780 base::TimeTicks first_frame_time_; |
| 778 }; | 781 }; |
| 779 | 782 |
| 780 SINGLE_AND_MULTI_THREAD_TEST_F( | 783 SINGLE_AND_MULTI_THREAD_BLOCKNOTIFY_TEST_F( |
| 781 LayerTreeHostTestFrameTimeUpdatesAfterActivationFails); | 784 LayerTreeHostTestFrameTimeUpdatesAfterActivationFails); |
| 782 | 785 |
| 783 // This test verifies that LayerTreeHostImpl's current frame time gets | 786 // This test verifies that LayerTreeHostImpl's current frame time gets |
| 784 // updated in consecutive frames when it draws in each frame. | 787 // updated in consecutive frames when it draws in each frame. |
| 785 class LayerTreeHostTestFrameTimeUpdatesAfterDraw : public LayerTreeHostTest { | 788 class LayerTreeHostTestFrameTimeUpdatesAfterDraw : public LayerTreeHostTest { |
| 786 public: | 789 public: |
| 787 LayerTreeHostTestFrameTimeUpdatesAfterDraw() : frame_(0) {} | 790 LayerTreeHostTestFrameTimeUpdatesAfterDraw() : frame_(0) {} |
| 788 | 791 |
| 789 virtual void BeginTest() OVERRIDE { | 792 virtual void BeginTest() OVERRIDE { |
| 790 layer_tree_host()->SetViewportSize(gfx::Size(20, 20)); | 793 layer_tree_host()->SetViewportSize(gfx::Size(20, 20)); |
| (...skipping 1421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2212 EXPECT_FALSE(layer_tree_host()->root_layer()->can_use_lcd_text()); | 2215 EXPECT_FALSE(layer_tree_host()->root_layer()->can_use_lcd_text()); |
| 2213 EndTest(); | 2216 EndTest(); |
| 2214 break; | 2217 break; |
| 2215 } | 2218 } |
| 2216 } | 2219 } |
| 2217 | 2220 |
| 2218 private: | 2221 private: |
| 2219 NotificationClient client_; | 2222 NotificationClient client_; |
| 2220 }; | 2223 }; |
| 2221 | 2224 |
| 2222 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestLCDNotification); | 2225 SINGLE_AND_MULTI_THREAD_NOIMPL_TEST_F(LayerTreeHostTestLCDNotification); |
|
danakj
2014/09/03 21:14:24
Why is this happening?
enne (OOO)
2014/09/03 21:36:25
Fixed. OOPS.
| |
| 2223 | 2226 |
| 2224 // Verify that the BeginFrame notification is used to initiate rendering. | 2227 // Verify that the BeginFrame notification is used to initiate rendering. |
| 2225 class LayerTreeHostTestBeginFrameNotification : public LayerTreeHostTest { | 2228 class LayerTreeHostTestBeginFrameNotification : public LayerTreeHostTest { |
| 2226 public: | 2229 public: |
| 2227 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { | 2230 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
| 2228 settings->begin_frame_scheduling_enabled = true; | 2231 settings->begin_frame_scheduling_enabled = true; |
| 2229 } | 2232 } |
| 2230 | 2233 |
| 2231 virtual void BeginTest() OVERRIDE { | 2234 virtual void BeginTest() OVERRIDE { |
| 2232 // This will trigger a SetNeedsBeginFrame which will trigger a | 2235 // This will trigger a SetNeedsBeginFrame which will trigger a |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2396 | 2399 |
| 2397 virtual bool FillsBoundsCompletely() const OVERRIDE { return false; } | 2400 virtual bool FillsBoundsCompletely() const OVERRIDE { return false; } |
| 2398 | 2401 |
| 2399 private: | 2402 private: |
| 2400 Layer* layer_; | 2403 Layer* layer_; |
| 2401 }; | 2404 }; |
| 2402 | 2405 |
| 2403 LayerTreeHostTestChangeLayerPropertiesInPaintContents() : num_commits_(0) {} | 2406 LayerTreeHostTestChangeLayerPropertiesInPaintContents() : num_commits_(0) {} |
| 2404 | 2407 |
| 2405 virtual void SetupTree() OVERRIDE { | 2408 virtual void SetupTree() OVERRIDE { |
| 2406 scoped_refptr<ContentLayer> root_layer = ContentLayer::Create(&client_); | 2409 if (layer_tree_host()->settings().impl_side_painting) { |
| 2410 scoped_refptr<PictureLayer> root_layer = PictureLayer::Create(&client_); | |
| 2411 layer_tree_host()->SetRootLayer(root_layer); | |
| 2412 } else { | |
| 2413 scoped_refptr<ContentLayer> root_layer = ContentLayer::Create(&client_); | |
| 2414 layer_tree_host()->SetRootLayer(root_layer); | |
| 2415 } | |
| 2416 Layer* root_layer = layer_tree_host()->root_layer(); | |
| 2407 root_layer->SetIsDrawable(true); | 2417 root_layer->SetIsDrawable(true); |
| 2408 root_layer->SetBounds(gfx::Size(1, 1)); | 2418 root_layer->SetBounds(gfx::Size(1, 1)); |
| 2409 | 2419 |
| 2410 layer_tree_host()->SetRootLayer(root_layer); | 2420 client_.set_layer(root_layer); |
| 2411 client_.set_layer(root_layer.get()); | |
| 2412 | 2421 |
| 2413 LayerTreeHostTest::SetupTree(); | 2422 LayerTreeHostTest::SetupTree(); |
| 2414 } | 2423 } |
| 2415 | 2424 |
| 2416 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 2425 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
| 2417 virtual void AfterTest() OVERRIDE {} | 2426 virtual void AfterTest() OVERRIDE {} |
| 2418 | 2427 |
| 2419 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 2428 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 2420 num_commits_++; | 2429 num_commits_++; |
| 2421 if (num_commits_ == 1) { | 2430 if (num_commits_ == 1) { |
| 2422 LayerImpl* root_layer = host_impl->active_tree()->root_layer(); | 2431 LayerImpl* root_layer = host_impl->active_tree()->root_layer(); |
| 2423 EXPECT_SIZE_EQ(gfx::Size(1, 1), root_layer->bounds()); | 2432 EXPECT_SIZE_EQ(gfx::Size(1, 1), root_layer->bounds()); |
| 2424 } else { | 2433 } else { |
| 2425 LayerImpl* root_layer = host_impl->active_tree()->root_layer(); | 2434 LayerImpl* root_layer = host_impl->active_tree()->root_layer(); |
| 2426 EXPECT_SIZE_EQ(gfx::Size(2, 2), root_layer->bounds()); | 2435 EXPECT_SIZE_EQ(gfx::Size(2, 2), root_layer->bounds()); |
| 2427 EndTest(); | 2436 EndTest(); |
| 2428 } | 2437 } |
| 2429 } | 2438 } |
| 2430 | 2439 |
| 2431 private: | 2440 private: |
| 2432 SetBoundsClient client_; | 2441 SetBoundsClient client_; |
| 2433 int num_commits_; | 2442 int num_commits_; |
| 2434 }; | 2443 }; |
| 2435 | 2444 |
| 2436 SINGLE_THREAD_TEST_F(LayerTreeHostTestChangeLayerPropertiesInPaintContents); | 2445 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 2446 LayerTreeHostTestChangeLayerPropertiesInPaintContents); | |
| 2437 | 2447 |
| 2438 class MockIOSurfaceWebGraphicsContext3D : public TestWebGraphicsContext3D { | 2448 class MockIOSurfaceWebGraphicsContext3D : public TestWebGraphicsContext3D { |
| 2439 public: | 2449 public: |
| 2440 MockIOSurfaceWebGraphicsContext3D() { | 2450 MockIOSurfaceWebGraphicsContext3D() { |
| 2441 test_capabilities_.gpu.iosurface = true; | 2451 test_capabilities_.gpu.iosurface = true; |
| 2442 test_capabilities_.gpu.texture_rectangle = true; | 2452 test_capabilities_.gpu.texture_rectangle = true; |
| 2443 } | 2453 } |
| 2444 | 2454 |
| 2445 virtual GLuint createTexture() OVERRIDE { | 2455 virtual GLuint createTexture() OVERRIDE { |
| 2446 return 1; | 2456 return 1; |
| (...skipping 2586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5033 const gfx::Size bounds_; | 5043 const gfx::Size bounds_; |
| 5034 FakeContentLayerClient client_; | 5044 FakeContentLayerClient client_; |
| 5035 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; | 5045 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; |
| 5036 scoped_refptr<FakePictureLayer> picture_layer_; | 5046 scoped_refptr<FakePictureLayer> picture_layer_; |
| 5037 Layer* child_layer_; | 5047 Layer* child_layer_; |
| 5038 }; | 5048 }; |
| 5039 | 5049 |
| 5040 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); | 5050 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); |
| 5041 | 5051 |
| 5042 } // namespace cc | 5052 } // namespace cc |
| OLD | NEW |