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

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

Issue 550073002: Revert of cc: Single-threaded impl-side painting for unit tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest_animation.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_BLOCKNOTIFY_TEST_F( 532 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSetNextCommitForcesRedraw);
533 LayerTreeHostTestSetNextCommitForcesRedraw);
534 533
535 // Tests that if a layer is not drawn because of some reason in the parent then 534 // Tests that if a layer is not drawn because of some reason in the parent then
536 // its damage is preserved until the next time it is drawn. 535 // its damage is preserved until the next time it is drawn.
537 class LayerTreeHostTestUndrawnLayersDamageLater : public LayerTreeHostTest { 536 class LayerTreeHostTestUndrawnLayersDamageLater : public LayerTreeHostTest {
538 public: 537 public:
539 LayerTreeHostTestUndrawnLayersDamageLater() 538 LayerTreeHostTestUndrawnLayersDamageLater()
540 : root_layer_(ContentLayer::Create(&client_)) {} 539 : root_layer_(ContentLayer::Create(&client_)) {}
541 540
542 virtual void SetupTree() OVERRIDE { 541 virtual void SetupTree() OVERRIDE {
543 root_layer_->SetIsDrawable(true); 542 root_layer_->SetIsDrawable(true);
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 730
732 virtual void BeginTest() OVERRIDE { 731 virtual void BeginTest() OVERRIDE {
733 layer_tree_host()->SetViewportSize(gfx::Size(20, 20)); 732 layer_tree_host()->SetViewportSize(gfx::Size(20, 20));
734 layer_tree_host()->set_background_color(SK_ColorGRAY); 733 layer_tree_host()->set_background_color(SK_ColorGRAY);
735 734
736 PostSetNeedsCommitToMainThread(); 735 PostSetNeedsCommitToMainThread();
737 } 736 }
738 737
739 virtual void BeginCommitOnThread(LayerTreeHostImpl* impl) OVERRIDE { 738 virtual void BeginCommitOnThread(LayerTreeHostImpl* impl) OVERRIDE {
740 EXPECT_EQ(frame_count_with_pending_tree_, 0); 739 EXPECT_EQ(frame_count_with_pending_tree_, 0);
741 if (impl->settings().impl_side_painting) 740 impl->BlockNotifyReadyToActivateForTesting(true);
742 impl->BlockNotifyReadyToActivateForTesting(true);
743 } 741 }
744 742
745 virtual void WillBeginImplFrameOnThread(LayerTreeHostImpl* impl, 743 virtual void WillBeginImplFrameOnThread(LayerTreeHostImpl* impl,
746 const BeginFrameArgs& args) OVERRIDE { 744 const BeginFrameArgs& args) OVERRIDE {
747 if (impl->pending_tree()) 745 if (impl->pending_tree())
748 frame_count_with_pending_tree_++; 746 frame_count_with_pending_tree_++;
749 747
750 if (frame_count_with_pending_tree_ == 1) { 748 if (frame_count_with_pending_tree_ == 1) {
751 EXPECT_EQ(first_frame_time_.ToInternalValue(), 0); 749 EXPECT_EQ(first_frame_time_.ToInternalValue(), 0);
752 first_frame_time_ = impl->CurrentBeginFrameArgs().frame_time; 750 first_frame_time_ = impl->CurrentBeginFrameArgs().frame_time;
753 } else if (frame_count_with_pending_tree_ == 2 && 751 } else if (frame_count_with_pending_tree_ == 2) {
754 impl->settings().impl_side_painting) {
755 impl->BlockNotifyReadyToActivateForTesting(false); 752 impl->BlockNotifyReadyToActivateForTesting(false);
756 } 753 }
757 } 754 }
758 755
759 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { 756 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE {
760 if (frame_count_with_pending_tree_ > 1) { 757 if (frame_count_with_pending_tree_ > 1) {
761 EXPECT_NE(first_frame_time_.ToInternalValue(), 0); 758 EXPECT_NE(first_frame_time_.ToInternalValue(), 0);
762 EXPECT_NE(first_frame_time_.ToInternalValue(), 759 EXPECT_NE(first_frame_time_.ToInternalValue(),
763 impl->CurrentBeginFrameArgs().frame_time.ToInternalValue()); 760 impl->CurrentBeginFrameArgs().frame_time.ToInternalValue());
764 EndTest(); 761 EndTest();
765 return; 762 return;
766 } 763 }
767 764
768 EXPECT_FALSE(impl->settings().impl_side_painting); 765 EXPECT_FALSE(impl->settings().impl_side_painting);
769 EndTest(); 766 EndTest();
770 } 767 }
771 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { 768 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE {
772 if (impl->settings().impl_side_painting) 769 if (impl->settings().impl_side_painting)
773 EXPECT_NE(frame_count_with_pending_tree_, 1); 770 EXPECT_NE(frame_count_with_pending_tree_, 1);
774 } 771 }
775 772
776 virtual void AfterTest() OVERRIDE {} 773 virtual void AfterTest() OVERRIDE {}
777 774
778 private: 775 private:
779 int frame_count_with_pending_tree_; 776 int frame_count_with_pending_tree_;
780 base::TimeTicks first_frame_time_; 777 base::TimeTicks first_frame_time_;
781 }; 778 };
782 779
783 SINGLE_AND_MULTI_THREAD_BLOCKNOTIFY_TEST_F( 780 SINGLE_AND_MULTI_THREAD_TEST_F(
784 LayerTreeHostTestFrameTimeUpdatesAfterActivationFails); 781 LayerTreeHostTestFrameTimeUpdatesAfterActivationFails);
785 782
786 // This test verifies that LayerTreeHostImpl's current frame time gets 783 // This test verifies that LayerTreeHostImpl's current frame time gets
787 // updated in consecutive frames when it draws in each frame. 784 // updated in consecutive frames when it draws in each frame.
788 class LayerTreeHostTestFrameTimeUpdatesAfterDraw : public LayerTreeHostTest { 785 class LayerTreeHostTestFrameTimeUpdatesAfterDraw : public LayerTreeHostTest {
789 public: 786 public:
790 LayerTreeHostTestFrameTimeUpdatesAfterDraw() : frame_(0) {} 787 LayerTreeHostTestFrameTimeUpdatesAfterDraw() : frame_(0) {}
791 788
792 virtual void BeginTest() OVERRIDE { 789 virtual void BeginTest() OVERRIDE {
793 layer_tree_host()->SetViewportSize(gfx::Size(20, 20)); 790 layer_tree_host()->SetViewportSize(gfx::Size(20, 20));
(...skipping 1605 matching lines...) Expand 10 before | Expand all | Expand 10 after
2399 2396
2400 virtual bool FillsBoundsCompletely() const OVERRIDE { return false; } 2397 virtual bool FillsBoundsCompletely() const OVERRIDE { return false; }
2401 2398
2402 private: 2399 private:
2403 Layer* layer_; 2400 Layer* layer_;
2404 }; 2401 };
2405 2402
2406 LayerTreeHostTestChangeLayerPropertiesInPaintContents() : num_commits_(0) {} 2403 LayerTreeHostTestChangeLayerPropertiesInPaintContents() : num_commits_(0) {}
2407 2404
2408 virtual void SetupTree() OVERRIDE { 2405 virtual void SetupTree() OVERRIDE {
2409 if (layer_tree_host()->settings().impl_side_painting) { 2406 scoped_refptr<ContentLayer> root_layer = ContentLayer::Create(&client_);
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();
2417 root_layer->SetIsDrawable(true); 2407 root_layer->SetIsDrawable(true);
2418 root_layer->SetBounds(gfx::Size(1, 1)); 2408 root_layer->SetBounds(gfx::Size(1, 1));
2419 2409
2420 client_.set_layer(root_layer); 2410 layer_tree_host()->SetRootLayer(root_layer);
2411 client_.set_layer(root_layer.get());
2421 2412
2422 LayerTreeHostTest::SetupTree(); 2413 LayerTreeHostTest::SetupTree();
2423 } 2414 }
2424 2415
2425 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 2416 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
2426 virtual void AfterTest() OVERRIDE {} 2417 virtual void AfterTest() OVERRIDE {}
2427 2418
2428 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 2419 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
2429 num_commits_++; 2420 num_commits_++;
2430 if (num_commits_ == 1) { 2421 if (num_commits_ == 1) {
2431 LayerImpl* root_layer = host_impl->active_tree()->root_layer(); 2422 LayerImpl* root_layer = host_impl->active_tree()->root_layer();
2432 EXPECT_SIZE_EQ(gfx::Size(1, 1), root_layer->bounds()); 2423 EXPECT_SIZE_EQ(gfx::Size(1, 1), root_layer->bounds());
2433 } else { 2424 } else {
2434 LayerImpl* root_layer = host_impl->active_tree()->root_layer(); 2425 LayerImpl* root_layer = host_impl->active_tree()->root_layer();
2435 EXPECT_SIZE_EQ(gfx::Size(2, 2), root_layer->bounds()); 2426 EXPECT_SIZE_EQ(gfx::Size(2, 2), root_layer->bounds());
2436 EndTest(); 2427 EndTest();
2437 } 2428 }
2438 } 2429 }
2439 2430
2440 private: 2431 private:
2441 SetBoundsClient client_; 2432 SetBoundsClient client_;
2442 int num_commits_; 2433 int num_commits_;
2443 }; 2434 };
2444 2435
2445 SINGLE_AND_MULTI_THREAD_TEST_F( 2436 SINGLE_THREAD_TEST_F(LayerTreeHostTestChangeLayerPropertiesInPaintContents);
2446 LayerTreeHostTestChangeLayerPropertiesInPaintContents);
2447 2437
2448 class MockIOSurfaceWebGraphicsContext3D : public TestWebGraphicsContext3D { 2438 class MockIOSurfaceWebGraphicsContext3D : public TestWebGraphicsContext3D {
2449 public: 2439 public:
2450 MockIOSurfaceWebGraphicsContext3D() { 2440 MockIOSurfaceWebGraphicsContext3D() {
2451 test_capabilities_.gpu.iosurface = true; 2441 test_capabilities_.gpu.iosurface = true;
2452 test_capabilities_.gpu.texture_rectangle = true; 2442 test_capabilities_.gpu.texture_rectangle = true;
2453 } 2443 }
2454 2444
2455 virtual GLuint createTexture() OVERRIDE { 2445 virtual GLuint createTexture() OVERRIDE {
2456 return 1; 2446 return 1;
(...skipping 2586 matching lines...) Expand 10 before | Expand all | Expand 10 after
5043 const gfx::Size bounds_; 5033 const gfx::Size bounds_;
5044 FakeContentLayerClient client_; 5034 FakeContentLayerClient client_;
5045 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; 5035 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_;
5046 scoped_refptr<FakePictureLayer> picture_layer_; 5036 scoped_refptr<FakePictureLayer> picture_layer_;
5047 Layer* child_layer_; 5037 Layer* child_layer_;
5048 }; 5038 };
5049 5039
5050 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); 5040 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting);
5051 5041
5052 } // namespace cc 5042 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest_animation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698