Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "cc/layers/texture_layer_client.h" | 10 #include "cc/layers/texture_layer_client.h" |
| (...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 833 { | 833 { |
| 834 base::AutoLock lock(lock_); | 834 base::AutoLock lock(lock_); |
| 835 expected_used_textures_on_commit_ = 1; | 835 expected_used_textures_on_commit_ = 1; |
| 836 } | 836 } |
| 837 } | 837 } |
| 838 | 838 |
| 839 virtual void BeginTest() OVERRIDE { | 839 virtual void BeginTest() OVERRIDE { |
| 840 PostSetNeedsCommitToMainThread(); | 840 PostSetNeedsCommitToMainThread(); |
| 841 } | 841 } |
| 842 | 842 |
| 843 virtual void DidCommitAndDrawFrame() OVERRIDE { | 843 virtual void DidCommit() OVERRIDE { |
|
enne (OOO)
2013/08/02 19:41:25
This test seems like it depends on PrepareToDrawOn
brianderson
2013/08/02 23:04:31
I changed a number of DidCommitAndDrawFrame's to D
| |
| 844 ++commit_count_; | 844 ++commit_count_; |
| 845 switch (commit_count_) { | 845 switch (commit_count_) { |
| 846 case 1: | 846 case 1: |
| 847 texture_layer_->ClearClient(); | 847 texture_layer_->ClearClient(); |
| 848 texture_layer_->SetNeedsDisplay(); | 848 texture_layer_->SetNeedsDisplay(); |
| 849 { | 849 { |
| 850 base::AutoLock lock(lock_); | 850 base::AutoLock lock(lock_); |
| 851 expected_used_textures_on_commit_ = 0; | 851 expected_used_textures_on_commit_ = 0; |
| 852 } | 852 } |
| 853 texture_ = 0; | 853 texture_ = 0; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 956 LayerImpl* root = host_impl->RootLayer(); | 956 LayerImpl* root = host_impl->RootLayer(); |
| 957 TextureLayerImpl* texture_layer = | 957 TextureLayerImpl* texture_layer = |
| 958 static_cast<TextureLayerImpl*>(root->children()[0]); | 958 static_cast<TextureLayerImpl*>(root->children()[0]); |
| 959 if (++draw_count_ == 1) | 959 if (++draw_count_ == 1) |
| 960 EXPECT_EQ(0u, texture_layer->texture_id()); | 960 EXPECT_EQ(0u, texture_layer->texture_id()); |
| 961 else | 961 else |
| 962 EXPECT_EQ(texture_, texture_layer->texture_id()); | 962 EXPECT_EQ(texture_, texture_layer->texture_id()); |
| 963 return true; | 963 return true; |
| 964 } | 964 } |
| 965 | 965 |
| 966 virtual void DidCommitAndDrawFrame() OVERRIDE { | 966 virtual void DidCommit() OVERRIDE { |
|
enne (OOO)
2013/08/02 19:41:25
There's test logic in PrepareToDrawOnThread that s
brianderson
2013/08/02 23:04:31
Trigger happy again. Fixed.
| |
| 967 EndTest(); | 967 EndTest(); |
| 968 } | 968 } |
| 969 | 969 |
| 970 virtual void AfterTest() OVERRIDE {} | 970 virtual void AfterTest() OVERRIDE {} |
| 971 | 971 |
| 972 private: | 972 private: |
| 973 scoped_refptr<TextureLayer> texture_layer_; | 973 scoped_refptr<TextureLayer> texture_layer_; |
| 974 scoped_ptr<TestWebGraphicsContext3D> texture_context_; | 974 scoped_ptr<TestWebGraphicsContext3D> texture_context_; |
| 975 unsigned texture_; | 975 unsigned texture_; |
| 976 int draw_count_; | 976 int draw_count_; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1015 virtual void BeginTest() OVERRIDE { | 1015 virtual void BeginTest() OVERRIDE { |
| 1016 callback_count_ = 0; | 1016 callback_count_ = 0; |
| 1017 | 1017 |
| 1018 // Set the mailbox on the main thread. | 1018 // Set the mailbox on the main thread. |
| 1019 SetMailbox('1'); | 1019 SetMailbox('1'); |
| 1020 EXPECT_EQ(0, callback_count_); | 1020 EXPECT_EQ(0, callback_count_); |
| 1021 | 1021 |
| 1022 PostSetNeedsCommitToMainThread(); | 1022 PostSetNeedsCommitToMainThread(); |
| 1023 } | 1023 } |
| 1024 | 1024 |
| 1025 virtual void DidCommitAndDrawFrame() OVERRIDE { | 1025 virtual void DidCommit() OVERRIDE { |
| 1026 switch (layer_tree_host()->source_frame_number()) { | 1026 switch (layer_tree_host()->source_frame_number()) { |
| 1027 case 1: | 1027 case 1: |
| 1028 // Delete the TextureLayer on the main thread while the mailbox is in | 1028 // Delete the TextureLayer on the main thread while the mailbox is in |
| 1029 // the impl tree. | 1029 // the impl tree. |
| 1030 layer_->RemoveFromParent(); | 1030 layer_->RemoveFromParent(); |
| 1031 layer_ = NULL; | 1031 layer_ = NULL; |
| 1032 break; | 1032 break; |
| 1033 } | 1033 } |
| 1034 } | 1034 } |
| 1035 | 1035 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1083 virtual void BeginTest() OVERRIDE { | 1083 virtual void BeginTest() OVERRIDE { |
| 1084 callback_count_ = 0; | 1084 callback_count_ = 0; |
| 1085 | 1085 |
| 1086 // Set the mailbox on the main thread. | 1086 // Set the mailbox on the main thread. |
| 1087 SetMailbox('1'); | 1087 SetMailbox('1'); |
| 1088 EXPECT_EQ(0, callback_count_); | 1088 EXPECT_EQ(0, callback_count_); |
| 1089 | 1089 |
| 1090 PostSetNeedsCommitToMainThread(); | 1090 PostSetNeedsCommitToMainThread(); |
| 1091 } | 1091 } |
| 1092 | 1092 |
| 1093 virtual void DidCommitAndDrawFrame() OVERRIDE { | 1093 virtual void DidCommit() OVERRIDE { |
| 1094 switch (layer_tree_host()->source_frame_number()) { | 1094 switch (layer_tree_host()->source_frame_number()) { |
| 1095 case 1: | 1095 case 1: |
| 1096 // Remove the TextureLayer on the main thread while the mailbox is in | 1096 // Remove the TextureLayer on the main thread while the mailbox is in |
| 1097 // the impl tree, but don't delete the TextureLayer until after the impl | 1097 // the impl tree, but don't delete the TextureLayer until after the impl |
| 1098 // tree side is deleted. | 1098 // tree side is deleted. |
| 1099 layer_->RemoveFromParent(); | 1099 layer_->RemoveFromParent(); |
| 1100 break; | 1100 break; |
| 1101 case 2: | 1101 case 2: |
| 1102 layer_ = NULL; | 1102 layer_ = NULL; |
| 1103 break; | 1103 break; |
| 1104 } | 1104 } |
| 1105 } | 1105 } |
| 1106 | 1106 |
| 1107 virtual void AfterTest() OVERRIDE { | 1107 virtual void AfterTest() OVERRIDE { |
| 1108 EXPECT_EQ(1, callback_count_); | 1108 EXPECT_EQ(1, callback_count_); |
| 1109 } | 1109 } |
| 1110 | 1110 |
| 1111 private: | 1111 private: |
| 1112 int callback_count_; | 1112 int callback_count_; |
| 1113 scoped_refptr<Layer> root_; | 1113 scoped_refptr<Layer> root_; |
| 1114 scoped_refptr<TextureLayer> layer_; | 1114 scoped_refptr<TextureLayer> layer_; |
| 1115 }; | 1115 }; |
| 1116 | 1116 |
| 1117 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( | 1117 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
| 1118 TextureLayerWithMailboxImplThreadDeleted); | 1118 TextureLayerWithMailboxImplThreadDeleted); |
| 1119 | 1119 |
| 1120 } // namespace | 1120 } // namespace |
| 1121 } // namespace cc | 1121 } // namespace cc |
| OLD | NEW |