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 1004 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 if (layer_tree_host()->source_frame_number() == 1) { |
1095 case 1: | |
1096 // Remove the TextureLayer on the main thread while the mailbox is in | 1095 // 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 | 1096 // the impl tree, but don't delete the TextureLayer until after the impl |
1098 // tree side is deleted. | 1097 // tree side is deleted. |
1099 layer_->RemoveFromParent(); | 1098 layer_->RemoveFromParent(); |
1100 break; | |
1101 case 2: | |
1102 layer_ = NULL; | |
1103 break; | |
1104 } | 1099 } |
1105 } | 1100 } |
1106 | 1101 |
| 1102 virtual void SwapBuffersCompleteOnThread(LayerTreeHostImpl *impl) OVERRIDE { |
| 1103 if (impl->active_tree()->source_frame_number() == 1) { |
| 1104 proxy()->MainThreadTaskRunner()->PostTask( |
| 1105 FROM_HERE, |
| 1106 base::Bind( |
| 1107 &TextureLayerWithMailboxImplThreadDeleted::DeleteTextureLayer, |
| 1108 base::Unretained(this))); |
| 1109 } |
| 1110 } |
| 1111 |
| 1112 virtual void DeleteTextureLayer() { |
| 1113 layer_ = NULL; |
| 1114 } |
| 1115 |
1107 virtual void AfterTest() OVERRIDE { | 1116 virtual void AfterTest() OVERRIDE { |
1108 EXPECT_EQ(1, callback_count_); | 1117 EXPECT_EQ(1, callback_count_); |
1109 } | 1118 } |
1110 | 1119 |
1111 private: | 1120 private: |
1112 int callback_count_; | 1121 int callback_count_; |
1113 scoped_refptr<Layer> root_; | 1122 scoped_refptr<Layer> root_; |
1114 scoped_refptr<TextureLayer> layer_; | 1123 scoped_refptr<TextureLayer> layer_; |
1115 }; | 1124 }; |
1116 | 1125 |
1117 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( | 1126 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
1118 TextureLayerWithMailboxImplThreadDeleted); | 1127 TextureLayerWithMailboxImplThreadDeleted); |
1119 | 1128 |
1120 } // namespace | 1129 } // namespace |
1121 } // namespace cc | 1130 } // namespace cc |
OLD | NEW |