OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "ui/compositor/layer.h" | 5 #include "ui/compositor/layer.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
(...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1109 | 1109 |
1110 // The CompositorDelegate (us) should have been told to draw for a move. | 1110 // The CompositorDelegate (us) should have been told to draw for a move. |
1111 WaitForDraw(); | 1111 WaitForDraw(); |
1112 | 1112 |
1113 l1->SetBounds(gfx::Rect(5, 5, 100, 100)); | 1113 l1->SetBounds(gfx::Rect(5, 5, 100, 100)); |
1114 | 1114 |
1115 // The CompositorDelegate (us) should have been told to draw for a resize. | 1115 // The CompositorDelegate (us) should have been told to draw for a resize. |
1116 WaitForDraw(); | 1116 WaitForDraw(); |
1117 } | 1117 } |
1118 | 1118 |
1119 static void EmptyReleaseCallback(const gpu::SyncToken& sync_token, | |
1120 bool is_lost) {} | |
1121 | |
1122 // Checks that the damage rect for a TextureLayer is empty after a commit. | 1119 // Checks that the damage rect for a TextureLayer is empty after a commit. |
1123 TEST_F(LayerWithNullDelegateTest, EmptyDamagedRect) { | 1120 TEST_F(LayerWithNullDelegateTest, EmptyDamagedRect) { |
| 1121 base::RunLoop run_loop; |
| 1122 cc::ReleaseCallback callback = |
| 1123 base::Bind([](base::RunLoop* run_loop, const gpu::SyncToken& sync_token, |
| 1124 bool is_lost) { run_loop->Quit(); }, |
| 1125 base::Unretained(&run_loop)); |
| 1126 |
1124 std::unique_ptr<Layer> root(CreateLayer(LAYER_SOLID_COLOR)); | 1127 std::unique_ptr<Layer> root(CreateLayer(LAYER_SOLID_COLOR)); |
1125 cc::TextureMailbox mailbox(gpu::Mailbox::Generate(), gpu::SyncToken(), | 1128 cc::TextureMailbox mailbox(gpu::Mailbox::Generate(), gpu::SyncToken(), |
1126 GL_TEXTURE_2D); | 1129 GL_TEXTURE_2D); |
1127 root->SetTextureMailbox(mailbox, cc::SingleReleaseCallback::Create( | 1130 root->SetTextureMailbox(mailbox, cc::SingleReleaseCallback::Create(callback), |
1128 base::Bind(EmptyReleaseCallback)), | |
1129 gfx::Size(10, 10)); | 1131 gfx::Size(10, 10)); |
1130 compositor()->SetRootLayer(root.get()); | 1132 compositor()->SetRootLayer(root.get()); |
1131 | 1133 |
1132 root->SetBounds(gfx::Rect(0, 0, 10, 10)); | 1134 root->SetBounds(gfx::Rect(0, 0, 10, 10)); |
1133 root->SetVisible(true); | 1135 root->SetVisible(true); |
1134 WaitForCommit(); | 1136 WaitForCommit(); |
1135 | 1137 |
1136 gfx::Rect damaged_rect(0, 0, 5, 5); | 1138 gfx::Rect damaged_rect(0, 0, 5, 5); |
1137 root->SchedulePaint(damaged_rect); | 1139 root->SchedulePaint(damaged_rect); |
1138 EXPECT_EQ(damaged_rect, root->damaged_region_for_testing().bounds()); | 1140 EXPECT_EQ(damaged_rect, root->damaged_region_for_testing().bounds()); |
1139 WaitForCommit(); | 1141 WaitForCommit(); |
1140 EXPECT_TRUE(root->damaged_region_for_testing().IsEmpty()); | 1142 EXPECT_TRUE(root->damaged_region_for_testing().IsEmpty()); |
1141 | 1143 |
1142 compositor()->SetRootLayer(nullptr); | 1144 // The texture mailbox has a reference from an in-flight texture layer. |
1143 root.reset(); | 1145 // We clear the texture mailbox from the root layer and draw a new frame |
1144 WaitForCommit(); | 1146 // to ensure that the texture mailbox is released. |
| 1147 root->SetShowSolidColorContent(); |
| 1148 Draw(); |
| 1149 |
| 1150 // Wait for texture mailbox release to avoid DCHECKs. |
| 1151 run_loop.Run(); |
1145 } | 1152 } |
1146 | 1153 |
1147 void ExpectRgba(int x, int y, SkColor expected_color, SkColor actual_color) { | 1154 void ExpectRgba(int x, int y, SkColor expected_color, SkColor actual_color) { |
1148 EXPECT_EQ(expected_color, actual_color) | 1155 EXPECT_EQ(expected_color, actual_color) |
1149 << "Pixel error at x=" << x << " y=" << y << "; " | 1156 << "Pixel error at x=" << x << " y=" << y << "; " |
1150 << "actual RGBA=(" | 1157 << "actual RGBA=(" |
1151 << SkColorGetR(actual_color) << "," | 1158 << SkColorGetR(actual_color) << "," |
1152 << SkColorGetG(actual_color) << "," | 1159 << SkColorGetG(actual_color) << "," |
1153 << SkColorGetB(actual_color) << "," | 1160 << SkColorGetB(actual_color) << "," |
1154 << SkColorGetA(actual_color) << "); " | 1161 << SkColorGetA(actual_color) << "); " |
(...skipping 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2235 layer.set_name("foo"); | 2242 layer.set_name("foo"); |
2236 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> debug_info = | 2243 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> debug_info = |
2237 layer.TakeDebugInfo(nullptr); | 2244 layer.TakeDebugInfo(nullptr); |
2238 std::string trace_format("bar,"); | 2245 std::string trace_format("bar,"); |
2239 debug_info->AppendAsTraceFormat(&trace_format); | 2246 debug_info->AppendAsTraceFormat(&trace_format); |
2240 std::string expected("bar,{\"layer_name\":\"foo\"}"); | 2247 std::string expected("bar,{\"layer_name\":\"foo\"}"); |
2241 EXPECT_EQ(expected, trace_format); | 2248 EXPECT_EQ(expected, trace_format); |
2242 } | 2249 } |
2243 | 2250 |
2244 } // namespace ui | 2251 } // namespace ui |
OLD | NEW |