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

Side by Side Diff: cc/layers/texture_layer_unittest.cc

Issue 151093005: cc: Update Main RendererCapabilities on DeferredInitialize (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cancel commits with stale caps, no tests yet Created 6 years, 10 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 | Annotate | Revision Log
OLDNEW
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/layers/texture_layer.h" 5 #include "cc/layers/texture_layer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 root_->SetBounds(bounds); 788 root_->SetBounds(bounds);
789 789
790 layer_ = TextureLayer::CreateForMailbox(NULL); 790 layer_ = TextureLayer::CreateForMailbox(NULL);
791 layer_->SetIsDrawable(true); 791 layer_->SetIsDrawable(true);
792 layer_->SetAnchorPoint(gfx::PointF()); 792 layer_->SetAnchorPoint(gfx::PointF());
793 layer_->SetBounds(bounds); 793 layer_->SetBounds(bounds);
794 794
795 root_->AddChild(layer_); 795 root_->AddChild(layer_);
796 layer_tree_host()->SetRootLayer(root_); 796 layer_tree_host()->SetRootLayer(root_);
797 layer_tree_host()->SetViewportSize(bounds); 797 layer_tree_host()->SetViewportSize(bounds);
798 SetMailbox('1');
799 EXPECT_EQ(0, callback_count_);
800
801 // Case #1: change mailbox before the commit. The old mailbox should be
802 // released immediately.
803 SetMailbox('2');
804 EXPECT_EQ(1, callback_count_);
805 PostSetNeedsCommitToMainThread(); 798 PostSetNeedsCommitToMainThread();
806 } 799 }
807 800
808 virtual void DidCommit() OVERRIDE { 801 virtual void DidCommit() OVERRIDE {
809 ++commit_count_; 802 ++commit_count_;
810 switch (commit_count_) { 803 switch (commit_count_) {
811 case 1: 804 case 1:
805 // First commit from setting up tree. Nothing to check.
806 SetMailbox('1');
807 EXPECT_EQ(0, callback_count_);
808 break;
809 case 2:
812 // Case #2: change mailbox after the commit (and draw), where the 810 // Case #2: change mailbox after the commit (and draw), where the
813 // layer draws. The old mailbox should be released during the next 811 // layer draws. The old mailbox should be released during the next
814 // commit. 812 // commit.
815 SetMailbox('3'); 813 SetMailbox('2');
814 EXPECT_EQ(0, callback_count_);
815 break;
816 case 3:
816 EXPECT_EQ(1, callback_count_); 817 EXPECT_EQ(1, callback_count_);
817 break;
818 case 2:
819 EXPECT_EQ(2, callback_count_);
820 // Case #3: change mailbox when the layer doesn't draw. The old 818 // Case #3: change mailbox when the layer doesn't draw. The old
821 // mailbox should be released during the next commit. 819 // mailbox should be released during the next commit.
822 layer_->SetBounds(gfx::Size()); 820 layer_->SetBounds(gfx::Size());
823 SetMailbox('4'); 821 SetMailbox('3');
824 break; 822 break;
825 case 3: 823 case 4:
826 EXPECT_EQ(3, callback_count_); 824 EXPECT_EQ(2, callback_count_);
827 // Case #4: release mailbox that was committed but never drawn. The 825 // Case #4: release mailbox that was committed but never drawn. The
828 // old mailbox should be released during the next commit. 826 // old mailbox should be released during the next commit.
829 layer_->SetTextureMailbox(TextureMailbox(), 827 layer_->SetTextureMailbox(TextureMailbox(),
830 scoped_ptr<SingleReleaseCallback>()); 828 scoped_ptr<SingleReleaseCallback>());
831 break; 829 break;
832 case 4: 830 case 5:
833 if (layer_tree_host()->settings().impl_side_painting) { 831 if (layer_tree_host()->settings().impl_side_painting) {
834 // With impl painting, the texture mailbox will still be on the impl 832 // With impl painting, the texture mailbox will still be on the impl
835 // thread when the commit finishes, because the layer is not drawble 833 // thread when the commit finishes, because the layer is not drawble
836 // when it has no texture mailbox, and thus does not block the commit 834 // when it has no texture mailbox, and thus does not block the commit
837 // on activation. So, we wait for activation. 835 // on activation. So, we wait for activation.
838 // TODO(danakj): fix this. crbug.com/277953 836 // TODO(danakj): fix this. crbug.com/277953
839 layer_tree_host()->SetNeedsCommit(); 837 layer_tree_host()->SetNeedsCommit();
840 break; 838 break;
841 } else { 839 } else {
842 ++commit_count_; 840 ++commit_count_;
843 } 841 }
844 case 5: 842 case 6:
845 EXPECT_EQ(4, callback_count_); 843 EXPECT_EQ(3, callback_count_);
846 // Restore a mailbox for the next step. 844 // Restore a mailbox for the next step.
847 SetMailbox('5'); 845 SetMailbox('4');
848 break; 846 break;
849 case 6: 847 case 7:
850 // Case #5: remove layer from tree. Callback should *not* be called, the 848 // Case #5: remove layer from tree. Callback should *not* be called, the
851 // mailbox is returned to the main thread. 849 // mailbox is returned to the main thread.
852 EXPECT_EQ(4, callback_count_); 850 EXPECT_EQ(3, callback_count_);
853 layer_->RemoveFromParent(); 851 layer_->RemoveFromParent();
854 break; 852 break;
855 case 7: 853 case 8:
856 if (layer_tree_host()->settings().impl_side_painting) { 854 if (layer_tree_host()->settings().impl_side_painting) {
857 // With impl painting, the texture mailbox will still be on the impl 855 // With impl painting, the texture mailbox will still be on the impl
858 // thread when the commit finishes, because the layer is not around to 856 // thread when the commit finishes, because the layer is not around to
859 // block the commit on activation anymore. So, we wait for activation. 857 // block the commit on activation anymore. So, we wait for activation.
860 // TODO(danakj): fix this. crbug.com/277953 858 // TODO(danakj): fix this. crbug.com/277953
861 layer_tree_host()->SetNeedsCommit(); 859 layer_tree_host()->SetNeedsCommit();
862 break; 860 break;
863 } else { 861 } else {
864 ++commit_count_; 862 ++commit_count_;
865 } 863 }
866 case 8: 864 case 9:
867 EXPECT_EQ(4, callback_count_); 865 EXPECT_EQ(3, callback_count_);
868 // Resetting the mailbox will call the callback now. 866 // Resetting the mailbox will call the callback now.
869 layer_->SetTextureMailbox(TextureMailbox(), 867 layer_->SetTextureMailbox(TextureMailbox(),
870 scoped_ptr<SingleReleaseCallback>()); 868 scoped_ptr<SingleReleaseCallback>());
871 EXPECT_EQ(5, callback_count_); 869 EXPECT_EQ(4, callback_count_);
872 EndTest(); 870 EndTest();
873 break; 871 break;
874 default: 872 default:
875 NOTREACHED(); 873 NOTREACHED();
876 break; 874 break;
877 } 875 }
878 } 876 }
879 877
880 virtual void AfterTest() OVERRIDE {} 878 virtual void AfterTest() OVERRIDE {}
881 879
(...skipping 1291 matching lines...) Expand 10 before | Expand all | Expand 10 after
2173 int callback_count_; 2171 int callback_count_;
2174 scoped_refptr<Layer> root_; 2172 scoped_refptr<Layer> root_;
2175 scoped_refptr<TextureLayer> layer_; 2173 scoped_refptr<TextureLayer> layer_;
2176 }; 2174 };
2177 2175
2178 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( 2176 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
2179 TextureLayerWithMailboxImplThreadDeleted); 2177 TextureLayerWithMailboxImplThreadDeleted);
2180 2178
2181 } // namespace 2179 } // namespace
2182 } // namespace cc 2180 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/texture_layer.cc ('k') | cc/output/renderer.h » ('j') | cc/trees/thread_proxy.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698