Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Side by Side Diff: cc/trees/layer_tree_host_unittest.cc

Issue 508373002: cc: Single-threaded impl-side painting for unit tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Also abort remaining swap promises for synchronous composite Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 1608 matching lines...) Expand 10 before | Expand all | Expand 10 after
2399 2402
2400 virtual bool FillsBoundsCompletely() const OVERRIDE { return false; } 2403 virtual bool FillsBoundsCompletely() const OVERRIDE { return false; }
2401 2404
2402 private: 2405 private:
2403 Layer* layer_; 2406 Layer* layer_;
2404 }; 2407 };
2405 2408
2406 LayerTreeHostTestChangeLayerPropertiesInPaintContents() : num_commits_(0) {} 2409 LayerTreeHostTestChangeLayerPropertiesInPaintContents() : num_commits_(0) {}
2407 2410
2408 virtual void SetupTree() OVERRIDE { 2411 virtual void SetupTree() OVERRIDE {
2409 scoped_refptr<ContentLayer> root_layer = ContentLayer::Create(&client_); 2412 if (layer_tree_host()->settings().impl_side_painting) {
2413 scoped_refptr<PictureLayer> root_layer = PictureLayer::Create(&client_);
2414 layer_tree_host()->SetRootLayer(root_layer);
2415 } else {
2416 scoped_refptr<ContentLayer> root_layer = ContentLayer::Create(&client_);
2417 layer_tree_host()->SetRootLayer(root_layer);
2418 }
2419 Layer* root_layer = layer_tree_host()->root_layer();
2410 root_layer->SetIsDrawable(true); 2420 root_layer->SetIsDrawable(true);
2411 root_layer->SetBounds(gfx::Size(1, 1)); 2421 root_layer->SetBounds(gfx::Size(1, 1));
2412 2422
2413 layer_tree_host()->SetRootLayer(root_layer); 2423 client_.set_layer(root_layer);
2414 client_.set_layer(root_layer.get());
2415 2424
2416 LayerTreeHostTest::SetupTree(); 2425 LayerTreeHostTest::SetupTree();
2417 } 2426 }
2418 2427
2419 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 2428 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
2420 virtual void AfterTest() OVERRIDE {} 2429 virtual void AfterTest() OVERRIDE {}
2421 2430
2422 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 2431 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
2423 num_commits_++; 2432 num_commits_++;
2424 if (num_commits_ == 1) { 2433 if (num_commits_ == 1) {
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(1, 1), root_layer->bounds()); 2435 EXPECT_SIZE_EQ(gfx::Size(1, 1), root_layer->bounds());
2427 } else { 2436 } else {
2428 LayerImpl* root_layer = host_impl->active_tree()->root_layer(); 2437 LayerImpl* root_layer = host_impl->active_tree()->root_layer();
2429 EXPECT_SIZE_EQ(gfx::Size(2, 2), root_layer->bounds()); 2438 EXPECT_SIZE_EQ(gfx::Size(2, 2), root_layer->bounds());
2430 EndTest(); 2439 EndTest();
2431 } 2440 }
2432 } 2441 }
2433 2442
2434 private: 2443 private:
2435 SetBoundsClient client_; 2444 SetBoundsClient client_;
2436 int num_commits_; 2445 int num_commits_;
2437 }; 2446 };
2438 2447
2439 SINGLE_THREAD_TEST_F(LayerTreeHostTestChangeLayerPropertiesInPaintContents); 2448 SINGLE_AND_MULTI_THREAD_TEST_F(
2449 LayerTreeHostTestChangeLayerPropertiesInPaintContents);
2440 2450
2441 class MockIOSurfaceWebGraphicsContext3D : public TestWebGraphicsContext3D { 2451 class MockIOSurfaceWebGraphicsContext3D : public TestWebGraphicsContext3D {
2442 public: 2452 public:
2443 MockIOSurfaceWebGraphicsContext3D() { 2453 MockIOSurfaceWebGraphicsContext3D() {
2444 test_capabilities_.gpu.iosurface = true; 2454 test_capabilities_.gpu.iosurface = true;
2445 test_capabilities_.gpu.texture_rectangle = true; 2455 test_capabilities_.gpu.texture_rectangle = true;
2446 } 2456 }
2447 2457
2448 virtual GLuint createTexture() OVERRIDE { 2458 virtual GLuint createTexture() OVERRIDE {
2449 return 1; 2459 return 1;
(...skipping 2623 matching lines...) Expand 10 before | Expand all | Expand 10 after
5073 bool visible_; 5083 bool visible_;
5074 5084
5075 FakeContentLayerClient client_; 5085 FakeContentLayerClient client_;
5076 scoped_refptr<FakePictureLayer> picture_layer_; 5086 scoped_refptr<FakePictureLayer> picture_layer_;
5077 }; 5087 };
5078 5088
5079 // TODO(vmpstr): Enable with single thread impl-side painting. 5089 // TODO(vmpstr): Enable with single thread impl-side painting.
5080 MULTI_THREAD_TEST_F(LayerTreeHostTestActivateOnInvisible); 5090 MULTI_THREAD_TEST_F(LayerTreeHostTestActivateOnInvisible);
5081 5091
5082 } // namespace cc 5092 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698