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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "cc/layers/heads_up_display_layer.h" | 9 #include "cc/layers/heads_up_display_layer.h" |
10 #include "cc/layers/layer_impl.h" | 10 #include "cc/layers/layer_impl.h" |
11 #include "cc/layers/painted_scrollbar_layer.h" | 11 #include "cc/layers/painted_scrollbar_layer.h" |
12 #include "cc/layers/picture_layer.h" | 12 #include "cc/layers/picture_layer.h" |
13 #include "cc/layers/texture_layer.h" | 13 #include "cc/layers/texture_layer.h" |
14 #include "cc/layers/texture_layer_impl.h" | 14 #include "cc/layers/texture_layer_impl.h" |
15 #include "cc/layers/video_layer.h" | 15 #include "cc/layers/video_layer.h" |
16 #include "cc/layers/video_layer_impl.h" | 16 #include "cc/layers/video_layer_impl.h" |
17 #include "cc/output/filter_operations.h" | 17 #include "cc/output/filter_operations.h" |
18 #include "cc/resources/single_release_callback.h" | 18 #include "cc/resources/single_release_callback.h" |
19 #include "cc/resources/ui_resource_manager.h" | 19 #include "cc/resources/ui_resource_manager.h" |
20 #include "cc/test/fake_content_layer_client.h" | 20 #include "cc/test/fake_content_layer_client.h" |
21 #include "cc/test/fake_layer_tree_host_client.h" | 21 #include "cc/test/fake_layer_tree_host_client.h" |
22 #include "cc/test/fake_output_surface.h" | |
23 #include "cc/test/fake_output_surface_client.h" | |
24 #include "cc/test/fake_painted_scrollbar_layer.h" | 22 #include "cc/test/fake_painted_scrollbar_layer.h" |
25 #include "cc/test/fake_picture_layer.h" | 23 #include "cc/test/fake_picture_layer.h" |
26 #include "cc/test/fake_picture_layer_impl.h" | 24 #include "cc/test/fake_picture_layer_impl.h" |
27 #include "cc/test/fake_resource_provider.h" | 25 #include "cc/test/fake_resource_provider.h" |
28 #include "cc/test/fake_scoped_ui_resource.h" | 26 #include "cc/test/fake_scoped_ui_resource.h" |
29 #include "cc/test/fake_scrollbar.h" | 27 #include "cc/test/fake_scrollbar.h" |
30 #include "cc/test/fake_video_frame_provider.h" | 28 #include "cc/test/fake_video_frame_provider.h" |
31 #include "cc/test/layer_tree_test.h" | 29 #include "cc/test/layer_tree_test.h" |
32 #include "cc/test/render_pass_test_utils.h" | 30 #include "cc/test/render_pass_test_utils.h" |
| 31 #include "cc/test/test_compositor_frame_sink.h" |
33 #include "cc/test/test_context_provider.h" | 32 #include "cc/test/test_context_provider.h" |
34 #include "cc/test/test_delegating_output_surface.h" | |
35 #include "cc/test/test_shared_bitmap_manager.h" | 33 #include "cc/test/test_shared_bitmap_manager.h" |
36 #include "cc/test/test_web_graphics_context_3d.h" | 34 #include "cc/test/test_web_graphics_context_3d.h" |
37 #include "cc/trees/layer_tree_host.h" | 35 #include "cc/trees/layer_tree_host.h" |
38 #include "cc/trees/layer_tree_host_impl.h" | 36 #include "cc/trees/layer_tree_host_impl.h" |
39 #include "cc/trees/layer_tree_impl.h" | 37 #include "cc/trees/layer_tree_impl.h" |
40 #include "cc/trees/single_thread_proxy.h" | 38 #include "cc/trees/single_thread_proxy.h" |
41 #include "gpu/GLES2/gl2extchromium.h" | 39 #include "gpu/GLES2/gl2extchromium.h" |
42 #include "media/base/media.h" | 40 #include "media/base/media.h" |
43 | 41 |
44 using media::VideoFrame; | 42 using media::VideoFrame; |
45 | 43 |
46 namespace cc { | 44 namespace cc { |
47 namespace { | 45 namespace { |
48 | 46 |
49 // These tests deal with losing the 3d graphics context. | 47 // These tests deal with losing the 3d graphics context. |
50 class LayerTreeHostContextTest : public LayerTreeTest { | 48 class LayerTreeHostContextTest : public LayerTreeTest { |
51 public: | 49 public: |
52 LayerTreeHostContextTest() | 50 LayerTreeHostContextTest() |
53 : LayerTreeTest(), | 51 : LayerTreeTest(), |
54 context3d_(NULL), | 52 context3d_(NULL), |
55 times_to_fail_create_(0), | 53 times_to_fail_create_(0), |
56 times_to_lose_during_commit_(0), | 54 times_to_lose_during_commit_(0), |
57 times_to_lose_during_draw_(0), | 55 times_to_lose_during_draw_(0), |
58 times_to_fail_recreate_(0), | 56 times_to_fail_recreate_(0), |
59 times_to_expect_create_failed_(0), | 57 times_to_expect_create_failed_(0), |
60 times_create_failed_(0), | 58 times_create_failed_(0), |
61 committed_at_least_once_(false), | 59 committed_at_least_once_(false), |
62 context_should_support_io_surface_(false), | 60 context_should_support_io_surface_(false), |
63 fallback_context_works_(false), | 61 fallback_context_works_(false), |
64 async_output_surface_creation_(false) { | 62 async_compositor_frame_sink_creation_(false) { |
65 media::InitializeMediaLibrary(); | 63 media::InitializeMediaLibrary(); |
66 } | 64 } |
67 | 65 |
68 void LoseContext() { | 66 void LoseContext() { |
69 // CreateFakeOutputSurface happens on a different thread, so lock context3d_ | 67 // CreateDisplayCompositorFrameSink happens on a different thread, so lock |
70 // to make sure we don't set it to null after recreating it there. | 68 // context3d_ to make sure we don't set it to null after recreating it |
| 69 // there. |
71 base::AutoLock lock(context3d_lock_); | 70 base::AutoLock lock(context3d_lock_); |
72 // For sanity-checking tests, they should only call this when the | 71 // For sanity-checking tests, they should only call this when the |
73 // context is not lost. | 72 // context is not lost. |
74 CHECK(context3d_); | 73 CHECK(context3d_); |
75 context3d_->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, | 74 context3d_->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, |
76 GL_INNOCENT_CONTEXT_RESET_ARB); | 75 GL_INNOCENT_CONTEXT_RESET_ARB); |
77 context3d_ = NULL; | 76 context3d_ = nullptr; |
78 } | 77 } |
79 | 78 |
80 virtual std::unique_ptr<TestWebGraphicsContext3D> CreateContext3d() { | 79 virtual std::unique_ptr<TestWebGraphicsContext3D> CreateContext3d() { |
81 return TestWebGraphicsContext3D::Create(); | 80 return TestWebGraphicsContext3D::Create(); |
82 } | 81 } |
83 | 82 |
84 std::unique_ptr<TestDelegatingOutputSurface> CreateDelegatingOutputSurface( | 83 std::unique_ptr<TestCompositorFrameSink> CreateCompositorFrameSink( |
85 scoped_refptr<ContextProvider> compositor_context_provider, | 84 scoped_refptr<ContextProvider> compositor_context_provider, |
86 scoped_refptr<ContextProvider> worker_context_provider) override { | 85 scoped_refptr<ContextProvider> worker_context_provider) override { |
87 if (times_to_fail_create_) { | 86 if (times_to_fail_create_) { |
88 --times_to_fail_create_; | 87 --times_to_fail_create_; |
89 ExpectCreateToFail(); | 88 ExpectCreateToFail(); |
90 auto test_compositor_context_provider = TestContextProvider::Create(); | 89 auto test_compositor_context_provider = TestContextProvider::Create(); |
91 test_compositor_context_provider->UnboundTestContext3d() | 90 test_compositor_context_provider->UnboundTestContext3d() |
92 ->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, | 91 ->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, |
93 GL_INNOCENT_CONTEXT_RESET_ARB); | 92 GL_INNOCENT_CONTEXT_RESET_ARB); |
94 compositor_context_provider = std::move(test_compositor_context_provider); | 93 compositor_context_provider = std::move(test_compositor_context_provider); |
95 } | 94 } |
96 return LayerTreeTest::CreateDelegatingOutputSurface( | 95 return LayerTreeTest::CreateCompositorFrameSink( |
97 std::move(compositor_context_provider), | 96 std::move(compositor_context_provider), |
98 std::move(worker_context_provider)); | 97 std::move(worker_context_provider)); |
99 } | 98 } |
100 | 99 |
101 std::unique_ptr<OutputSurface> CreateDisplayOutputSurface( | 100 std::unique_ptr<OutputSurface> CreateDisplayOutputSurface( |
102 scoped_refptr<ContextProvider> compositor_context_provider) override { | 101 scoped_refptr<ContextProvider> compositor_context_provider) override { |
103 std::unique_ptr<TestWebGraphicsContext3D> context3d = CreateContext3d(); | 102 std::unique_ptr<TestWebGraphicsContext3D> context3d = CreateContext3d(); |
104 if (context_should_support_io_surface_) { | 103 if (context_should_support_io_surface_) { |
105 context3d->set_have_extension_io_surface(true); | 104 context3d->set_have_extension_io_surface(true); |
106 context3d->set_have_extension_egl_image(true); | 105 context3d->set_have_extension_egl_image(true); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 | 138 |
140 if (!times_to_lose_during_commit_) | 139 if (!times_to_lose_during_commit_) |
141 return; | 140 return; |
142 --times_to_lose_during_commit_; | 141 --times_to_lose_during_commit_; |
143 LoseContext(); | 142 LoseContext(); |
144 | 143 |
145 times_to_fail_create_ = times_to_fail_recreate_; | 144 times_to_fail_create_ = times_to_fail_recreate_; |
146 times_to_fail_recreate_ = 0; | 145 times_to_fail_recreate_ = 0; |
147 } | 146 } |
148 | 147 |
149 void DidFailToInitializeOutputSurface() override { ++times_create_failed_; } | 148 void DidFailToInitializeCompositorFrameSink() override { |
| 149 ++times_create_failed_; |
| 150 } |
150 | 151 |
151 void TearDown() override { | 152 void TearDown() override { |
152 LayerTreeTest::TearDown(); | 153 LayerTreeTest::TearDown(); |
153 EXPECT_EQ(times_to_expect_create_failed_, times_create_failed_); | 154 EXPECT_EQ(times_to_expect_create_failed_, times_create_failed_); |
154 } | 155 } |
155 | 156 |
156 void ExpectCreateToFail() { ++times_to_expect_create_failed_; } | 157 void ExpectCreateToFail() { ++times_to_expect_create_failed_; } |
157 | 158 |
158 protected: | 159 protected: |
159 // Protects use of context3d_ so LoseContext and CreateFakeOutputSurface | 160 // Protects use of context3d_ so LoseContext and |
160 // can both use it on different threads. | 161 // CreateDisplayCompositorFrameSink can both use it on different threads. |
161 base::Lock context3d_lock_; | 162 base::Lock context3d_lock_; |
162 TestWebGraphicsContext3D* context3d_; | 163 TestWebGraphicsContext3D* context3d_; |
163 | 164 |
164 int times_to_fail_create_; | 165 int times_to_fail_create_; |
165 int times_to_lose_during_commit_; | 166 int times_to_lose_during_commit_; |
166 int times_to_lose_during_draw_; | 167 int times_to_lose_during_draw_; |
167 int times_to_fail_recreate_; | 168 int times_to_fail_recreate_; |
168 int times_to_expect_create_failed_; | 169 int times_to_expect_create_failed_; |
169 int times_create_failed_; | 170 int times_create_failed_; |
170 bool committed_at_least_once_; | 171 bool committed_at_least_once_; |
171 bool context_should_support_io_surface_; | 172 bool context_should_support_io_surface_; |
172 bool fallback_context_works_; | 173 bool fallback_context_works_; |
173 bool async_output_surface_creation_; | 174 bool async_compositor_frame_sink_creation_; |
174 }; | 175 }; |
175 | 176 |
176 class LayerTreeHostContextTestLostContextSucceeds | 177 class LayerTreeHostContextTestLostContextSucceeds |
177 : public LayerTreeHostContextTest { | 178 : public LayerTreeHostContextTest { |
178 public: | 179 public: |
179 LayerTreeHostContextTestLostContextSucceeds() | 180 LayerTreeHostContextTestLostContextSucceeds() |
180 : LayerTreeHostContextTest(), | 181 : LayerTreeHostContextTest(), |
181 test_case_(0), | 182 test_case_(0), |
182 num_losses_(0), | 183 num_losses_(0), |
183 num_losses_last_test_case_(-1), | 184 num_losses_last_test_case_(-1), |
184 recovered_context_(true), | 185 recovered_context_(true), |
185 first_initialized_(false) {} | 186 first_initialized_(false) {} |
186 | 187 |
187 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 188 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
188 | 189 |
189 void RequestNewOutputSurface() override { | 190 void RequestNewCompositorFrameSink() override { |
190 if (async_output_surface_creation_) { | 191 if (async_compositor_frame_sink_creation_) { |
191 MainThreadTaskRunner()->PostTask( | 192 MainThreadTaskRunner()->PostTask( |
192 FROM_HERE, base::Bind(&LayerTreeHostContextTestLostContextSucceeds:: | 193 FROM_HERE, base::Bind(&LayerTreeHostContextTestLostContextSucceeds:: |
193 AsyncRequestNewOutputSurface, | 194 AsyncRequestNewCompositorFrameSink, |
194 base::Unretained(this))); | 195 base::Unretained(this))); |
195 } else { | 196 } else { |
196 AsyncRequestNewOutputSurface(); | 197 AsyncRequestNewCompositorFrameSink(); |
197 } | 198 } |
198 } | 199 } |
199 | 200 |
200 void AsyncRequestNewOutputSurface() { | 201 void AsyncRequestNewCompositorFrameSink() { |
201 LayerTreeHostContextTest::RequestNewOutputSurface(); | 202 LayerTreeHostContextTest::RequestNewCompositorFrameSink(); |
202 } | 203 } |
203 | 204 |
204 void DidInitializeOutputSurface() override { | 205 void DidInitializeCompositorFrameSink() override { |
205 if (first_initialized_) | 206 if (first_initialized_) |
206 ++num_losses_; | 207 ++num_losses_; |
207 else | 208 else |
208 first_initialized_ = true; | 209 first_initialized_ = true; |
209 | 210 |
210 recovered_context_ = true; | 211 recovered_context_ = true; |
211 } | 212 } |
212 | 213 |
213 void AfterTest() override { EXPECT_EQ(11u, test_case_); } | 214 void AfterTest() override { EXPECT_EQ(11u, test_case_); } |
214 | 215 |
(...skipping 18 matching lines...) Expand all Loading... |
233 // Cause damage so we try to draw. | 234 // Cause damage so we try to draw. |
234 layer_tree()->root_layer()->SetNeedsDisplay(); | 235 layer_tree()->root_layer()->SetNeedsDisplay(); |
235 layer_tree_host()->SetNeedsCommit(); | 236 layer_tree_host()->SetNeedsCommit(); |
236 } | 237 } |
237 | 238 |
238 bool NextTestCase() { | 239 bool NextTestCase() { |
239 static const TestCase kTests[] = { | 240 static const TestCase kTests[] = { |
240 // Losing the context and failing to recreate it (or losing it again | 241 // Losing the context and failing to recreate it (or losing it again |
241 // immediately) a small number of times should succeed. | 242 // immediately) a small number of times should succeed. |
242 { | 243 { |
243 1, // times_to_lose_during_commit | 244 1, // times_to_lose_during_commit |
244 0, // times_to_lose_during_draw | 245 0, // times_to_lose_during_draw |
245 0, // times_to_fail_recreate | 246 0, // times_to_fail_recreate |
246 false, // fallback_context_works | 247 false, // fallback_context_works |
247 false, // async_output_surface_creation | 248 false, // async_compositor_frame_sink_creation |
248 }, | 249 }, |
249 { | 250 { |
250 0, // times_to_lose_during_commit | 251 0, // times_to_lose_during_commit |
251 1, // times_to_lose_during_draw | 252 1, // times_to_lose_during_draw |
252 0, // times_to_fail_recreate | 253 0, // times_to_fail_recreate |
253 false, // fallback_context_works | 254 false, // fallback_context_works |
254 false, // async_output_surface_creation | 255 false, // async_compositor_frame_sink_creation |
255 }, | 256 }, |
256 { | 257 { |
257 1, // times_to_lose_during_commit | 258 1, // times_to_lose_during_commit |
258 0, // times_to_lose_during_draw | 259 0, // times_to_lose_during_draw |
259 3, // times_to_fail_recreate | 260 3, // times_to_fail_recreate |
260 false, // fallback_context_works | 261 false, // fallback_context_works |
261 false, // async_output_surface_creation | 262 false, // async_compositor_frame_sink_creation |
262 }, | 263 }, |
263 { | 264 { |
264 0, // times_to_lose_during_commit | 265 0, // times_to_lose_during_commit |
265 1, // times_to_lose_during_draw | 266 1, // times_to_lose_during_draw |
266 3, // times_to_fail_recreate | 267 3, // times_to_fail_recreate |
267 false, // fallback_context_works | 268 false, // fallback_context_works |
268 false, // async_output_surface_creation | 269 false, // async_compositor_frame_sink_creation |
269 }, | 270 }, |
270 { | 271 { |
271 0, // times_to_lose_during_commit | 272 0, // times_to_lose_during_commit |
272 1, // times_to_lose_during_draw | 273 1, // times_to_lose_during_draw |
273 3, // times_to_fail_recreate | 274 3, // times_to_fail_recreate |
274 false, // fallback_context_works | 275 false, // fallback_context_works |
275 true, // async_output_surface_creation | 276 true, // async_compositor_frame_sink_creation |
276 }, | 277 }, |
277 // Losing the context and recreating it any number of times should | 278 // Losing the context and recreating it any number of times should |
278 // succeed. | 279 // succeed. |
279 { | 280 { |
280 10, // times_to_lose_during_commit | 281 10, // times_to_lose_during_commit |
281 0, // times_to_lose_during_draw | 282 0, // times_to_lose_during_draw |
282 0, // times_to_fail_recreate | 283 0, // times_to_fail_recreate |
283 false, // fallback_context_works | 284 false, // fallback_context_works |
284 false, // async_output_surface_creation | 285 false, // async_compositor_frame_sink_creation |
285 }, | 286 }, |
286 { | 287 { |
287 0, // times_to_lose_during_commit | 288 0, // times_to_lose_during_commit |
288 10, // times_to_lose_during_draw | 289 10, // times_to_lose_during_draw |
289 0, // times_to_fail_recreate | 290 0, // times_to_fail_recreate |
290 false, // fallback_context_works | 291 false, // fallback_context_works |
291 false, // async_output_surface_creation | 292 false, // async_compositor_frame_sink_creation |
292 }, | 293 }, |
293 { | 294 { |
294 10, // times_to_lose_during_commit | 295 10, // times_to_lose_during_commit |
295 0, // times_to_lose_during_draw | 296 0, // times_to_lose_during_draw |
296 0, // times_to_fail_recreate | 297 0, // times_to_fail_recreate |
297 false, // fallback_context_works | 298 false, // fallback_context_works |
298 true, // async_output_surface_creation | 299 true, // async_compositor_frame_sink_creation |
299 }, | 300 }, |
300 { | 301 { |
301 0, // times_to_lose_during_commit | 302 0, // times_to_lose_during_commit |
302 10, // times_to_lose_during_draw | 303 10, // times_to_lose_during_draw |
303 0, // times_to_fail_recreate | 304 0, // times_to_fail_recreate |
304 false, // fallback_context_works | 305 false, // fallback_context_works |
305 true, // async_output_surface_creation | 306 true, // async_compositor_frame_sink_creation |
306 }, | 307 }, |
307 // Losing the context, failing to reinitialize it, and making a fallback | 308 // Losing the context, failing to reinitialize it, and making a fallback |
308 // context should work. | 309 // context should work. |
309 { | 310 { |
310 0, // times_to_lose_during_commit | 311 0, // times_to_lose_during_commit |
311 1, // times_to_lose_during_draw | 312 1, // times_to_lose_during_draw |
312 0, // times_to_fail_recreate | 313 0, // times_to_fail_recreate |
313 true, // fallback_context_works | 314 true, // fallback_context_works |
314 false, // async_output_surface_creation | 315 false, // async_compositor_frame_sink_creation |
315 }, | 316 }, |
316 { | 317 { |
317 0, // times_to_lose_during_commit | 318 0, // times_to_lose_during_commit |
318 1, // times_to_lose_during_draw | 319 1, // times_to_lose_during_draw |
319 0, // times_to_fail_recreate | 320 0, // times_to_fail_recreate |
320 true, // fallback_context_works | 321 true, // fallback_context_works |
321 true, // async_output_surface_creation | 322 true, // async_compositor_frame_sink_creation |
322 }, | 323 }, |
323 }; | 324 }; |
324 | 325 |
325 if (test_case_ >= arraysize(kTests)) | 326 if (test_case_ >= arraysize(kTests)) |
326 return false; | 327 return false; |
327 // Make sure that we lost our context at least once in the last test run so | 328 // Make sure that we lost our context at least once in the last test run so |
328 // the test did something. | 329 // the test did something. |
329 EXPECT_GT(num_losses_, num_losses_last_test_case_); | 330 EXPECT_GT(num_losses_, num_losses_last_test_case_); |
330 num_losses_last_test_case_ = num_losses_; | 331 num_losses_last_test_case_ = num_losses_; |
331 | 332 |
332 times_to_lose_during_commit_ = | 333 times_to_lose_during_commit_ = |
333 kTests[test_case_].times_to_lose_during_commit; | 334 kTests[test_case_].times_to_lose_during_commit; |
334 times_to_lose_during_draw_ = kTests[test_case_].times_to_lose_during_draw; | 335 times_to_lose_during_draw_ = kTests[test_case_].times_to_lose_during_draw; |
335 times_to_fail_recreate_ = kTests[test_case_].times_to_fail_recreate; | 336 times_to_fail_recreate_ = kTests[test_case_].times_to_fail_recreate; |
336 fallback_context_works_ = kTests[test_case_].fallback_context_works; | 337 fallback_context_works_ = kTests[test_case_].fallback_context_works; |
337 async_output_surface_creation_ = | 338 async_compositor_frame_sink_creation_ = |
338 kTests[test_case_].async_output_surface_creation; | 339 kTests[test_case_].async_compositor_frame_sink_creation; |
339 ++test_case_; | 340 ++test_case_; |
340 return true; | 341 return true; |
341 } | 342 } |
342 | 343 |
343 struct TestCase { | 344 struct TestCase { |
344 int times_to_lose_during_commit; | 345 int times_to_lose_during_commit; |
345 int times_to_lose_during_draw; | 346 int times_to_lose_during_draw; |
346 int times_to_fail_recreate; | 347 int times_to_fail_recreate; |
347 bool fallback_context_works; | 348 bool fallback_context_works; |
348 bool async_output_surface_creation; | 349 bool async_compositor_frame_sink_creation; |
349 }; | 350 }; |
350 | 351 |
351 protected: | 352 protected: |
352 size_t test_case_; | 353 size_t test_case_; |
353 int num_losses_; | 354 int num_losses_; |
354 int num_losses_last_test_case_; | 355 int num_losses_last_test_case_; |
355 bool recovered_context_; | 356 bool recovered_context_; |
356 bool first_initialized_; | 357 bool first_initialized_; |
357 }; | 358 }; |
358 | 359 |
359 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestLostContextSucceeds); | 360 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestLostContextSucceeds); |
360 | 361 |
361 class LayerTreeHostClientNotVisibleDoesNotCreateOutputSurface | 362 class LayerTreeHostClientNotVisibleDoesNotCreateCompositorFrameSink |
362 : public LayerTreeHostContextTest { | 363 : public LayerTreeHostContextTest { |
363 public: | 364 public: |
364 LayerTreeHostClientNotVisibleDoesNotCreateOutputSurface() | 365 LayerTreeHostClientNotVisibleDoesNotCreateCompositorFrameSink() |
365 : LayerTreeHostContextTest() {} | 366 : LayerTreeHostContextTest() {} |
366 | 367 |
367 void WillBeginTest() override { | 368 void WillBeginTest() override { |
368 // Override to not become visible. | 369 // Override to not become visible. |
369 DCHECK(!layer_tree_host()->IsVisible()); | 370 DCHECK(!layer_tree_host()->IsVisible()); |
370 } | 371 } |
371 | 372 |
372 void BeginTest() override { | 373 void BeginTest() override { |
373 PostSetNeedsCommitToMainThread(); | 374 PostSetNeedsCommitToMainThread(); |
374 EndTest(); | 375 EndTest(); |
375 } | 376 } |
376 | 377 |
377 void RequestNewOutputSurface() override { | 378 void RequestNewCompositorFrameSink() override { |
378 ADD_FAILURE() << "RequestNewOutputSurface() should not be called"; | 379 ADD_FAILURE() << "RequestNewCompositorFrameSink() should not be called"; |
379 } | 380 } |
380 | 381 |
381 void DidInitializeOutputSurface() override { EXPECT_TRUE(false); } | 382 void DidInitializeCompositorFrameSink() override { EXPECT_TRUE(false); } |
382 | 383 |
383 void AfterTest() override {} | 384 void AfterTest() override {} |
384 }; | 385 }; |
385 | 386 |
386 SINGLE_AND_MULTI_THREAD_TEST_F( | 387 SINGLE_AND_MULTI_THREAD_TEST_F( |
387 LayerTreeHostClientNotVisibleDoesNotCreateOutputSurface); | 388 LayerTreeHostClientNotVisibleDoesNotCreateCompositorFrameSink); |
388 | 389 |
389 // This tests the OutputSurface release logic in the following sequence. | 390 // This tests the CompositorFrameSink release logic in the following sequence. |
390 // SetUp LTH and create and init OutputSurface | 391 // SetUp LTH and create and init CompositorFrameSink. |
391 // LTH::SetVisible(false); | 392 // LTH::SetVisible(false); |
392 // LTH::ReleaseOutputSurface(); | 393 // LTH::ReleaseCompositorFrameSink(); |
393 // ... | 394 // ... |
394 // LTH::SetVisible(true); | 395 // LTH::SetVisible(true); |
395 // Create and init new OutputSurface | 396 // Create and init new CompositorFrameSink |
396 class LayerTreeHostClientTakeAwayOutputSurface | 397 class LayerTreeHostClientTakeAwayCompositorFrameSink |
397 : public LayerTreeHostContextTest { | 398 : public LayerTreeHostContextTest { |
398 public: | 399 public: |
399 LayerTreeHostClientTakeAwayOutputSurface() | 400 LayerTreeHostClientTakeAwayCompositorFrameSink() |
400 : LayerTreeHostContextTest(), setos_counter_(0) {} | 401 : LayerTreeHostContextTest(), setos_counter_(0) {} |
401 | 402 |
402 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 403 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
403 | 404 |
404 void RequestNewOutputSurface() override { | 405 void RequestNewCompositorFrameSink() override { |
405 if (layer_tree_host()->IsVisible()) { | 406 if (layer_tree_host()->IsVisible()) { |
406 setos_counter_++; | 407 setos_counter_++; |
407 LayerTreeHostContextTest::RequestNewOutputSurface(); | 408 LayerTreeHostContextTest::RequestNewCompositorFrameSink(); |
408 } | 409 } |
409 } | 410 } |
410 | 411 |
411 void HideAndReleaseOutputSurface() { | 412 void HideAndReleaseCompositorFrameSink() { |
412 EXPECT_TRUE(layer_tree_host()->GetTaskRunnerProvider()->IsMainThread()); | 413 EXPECT_TRUE(layer_tree_host()->GetTaskRunnerProvider()->IsMainThread()); |
413 layer_tree_host()->SetVisible(false); | 414 layer_tree_host()->SetVisible(false); |
414 std::unique_ptr<OutputSurface> surface = | 415 std::unique_ptr<CompositorFrameSink> surface = |
415 layer_tree_host()->ReleaseOutputSurface(); | 416 layer_tree_host()->ReleaseCompositorFrameSink(); |
416 CHECK(surface); | 417 CHECK(surface); |
417 MainThreadTaskRunner()->PostTask( | 418 MainThreadTaskRunner()->PostTask( |
418 FROM_HERE, | 419 FROM_HERE, |
419 base::Bind(&LayerTreeHostClientTakeAwayOutputSurface::MakeVisible, | 420 base::Bind(&LayerTreeHostClientTakeAwayCompositorFrameSink::MakeVisible, |
420 base::Unretained(this))); | 421 base::Unretained(this))); |
421 } | 422 } |
422 | 423 |
423 void DidInitializeOutputSurface() override { | 424 void DidInitializeCompositorFrameSink() override { |
424 EXPECT_TRUE(layer_tree_host()->IsVisible()); | 425 EXPECT_TRUE(layer_tree_host()->IsVisible()); |
425 if (setos_counter_ == 1) { | 426 if (setos_counter_ == 1) { |
426 MainThreadTaskRunner()->PostTask( | 427 MainThreadTaskRunner()->PostTask( |
427 FROM_HERE, base::Bind(&LayerTreeHostClientTakeAwayOutputSurface:: | 428 FROM_HERE, |
428 HideAndReleaseOutputSurface, | 429 base::Bind(&LayerTreeHostClientTakeAwayCompositorFrameSink:: |
429 base::Unretained(this))); | 430 HideAndReleaseCompositorFrameSink, |
| 431 base::Unretained(this))); |
430 } else { | 432 } else { |
431 EndTest(); | 433 EndTest(); |
432 } | 434 } |
433 } | 435 } |
434 | 436 |
435 void MakeVisible() { | 437 void MakeVisible() { |
436 EXPECT_TRUE(layer_tree_host()->GetTaskRunnerProvider()->IsMainThread()); | 438 EXPECT_TRUE(layer_tree_host()->GetTaskRunnerProvider()->IsMainThread()); |
437 layer_tree_host()->SetVisible(true); | 439 layer_tree_host()->SetVisible(true); |
438 } | 440 } |
439 | 441 |
440 void AfterTest() override {} | 442 void AfterTest() override {} |
441 | 443 |
442 int setos_counter_; | 444 int setos_counter_; |
443 }; | 445 }; |
444 | 446 |
445 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostClientTakeAwayOutputSurface); | 447 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostClientTakeAwayCompositorFrameSink); |
446 | 448 |
447 class MultipleCompositeDoesNotCreateOutputSurface | 449 class MultipleCompositeDoesNotCreateCompositorFrameSink |
448 : public LayerTreeHostContextTest { | 450 : public LayerTreeHostContextTest { |
449 public: | 451 public: |
450 MultipleCompositeDoesNotCreateOutputSurface() | 452 MultipleCompositeDoesNotCreateCompositorFrameSink() |
451 : LayerTreeHostContextTest(), request_count_(0) {} | 453 : LayerTreeHostContextTest(), request_count_(0) {} |
452 | 454 |
453 void InitializeSettings(LayerTreeSettings* settings) override { | 455 void InitializeSettings(LayerTreeSettings* settings) override { |
454 settings->single_thread_proxy_scheduler = false; | 456 settings->single_thread_proxy_scheduler = false; |
455 settings->use_zero_copy = true; | 457 settings->use_zero_copy = true; |
456 } | 458 } |
457 | 459 |
458 void RequestNewOutputSurface() override { | 460 void RequestNewCompositorFrameSink() override { |
459 EXPECT_GE(1, ++request_count_); | 461 EXPECT_GE(1, ++request_count_); |
460 EndTest(); | 462 EndTest(); |
461 } | 463 } |
462 | 464 |
463 void BeginTest() override { | 465 void BeginTest() override { |
464 layer_tree_host()->Composite(base::TimeTicks::FromInternalValue(1)); | 466 layer_tree_host()->Composite(base::TimeTicks::FromInternalValue(1)); |
465 layer_tree_host()->Composite(base::TimeTicks::FromInternalValue(2)); | 467 layer_tree_host()->Composite(base::TimeTicks::FromInternalValue(2)); |
466 } | 468 } |
467 | 469 |
468 void DidInitializeOutputSurface() override { EXPECT_TRUE(false); } | 470 void DidInitializeCompositorFrameSink() override { EXPECT_TRUE(false); } |
469 | 471 |
470 void AfterTest() override {} | 472 void AfterTest() override {} |
471 | 473 |
472 int request_count_; | 474 int request_count_; |
473 }; | 475 }; |
474 | 476 |
475 // This test uses Composite() which only exists for single thread. | 477 // This test uses Composite() which only exists for single thread. |
476 SINGLE_THREAD_TEST_F(MultipleCompositeDoesNotCreateOutputSurface); | 478 SINGLE_THREAD_TEST_F(MultipleCompositeDoesNotCreateCompositorFrameSink); |
477 | 479 |
478 // This test makes sure that once a SingleThreadProxy issues a | 480 // This test makes sure that once a SingleThreadProxy issues a |
479 // DidFailToInitializeOutputSurface, that future Composite calls will not | 481 // DidFailToInitializeCompositorFrameSink, that future Composite calls will not |
480 // trigger additional requests for output surfaces. | 482 // trigger additional requests for output surfaces. |
481 class FailedCreateDoesNotCreateExtraOutputSurface | 483 class FailedCreateDoesNotCreateExtraCompositorFrameSink |
482 : public LayerTreeHostContextTest { | 484 : public LayerTreeHostContextTest { |
483 public: | 485 public: |
484 FailedCreateDoesNotCreateExtraOutputSurface() | 486 FailedCreateDoesNotCreateExtraCompositorFrameSink() |
485 : LayerTreeHostContextTest(), num_requests_(0), has_failed_(false) {} | 487 : LayerTreeHostContextTest(), num_requests_(0), has_failed_(false) {} |
486 | 488 |
487 void InitializeSettings(LayerTreeSettings* settings) override { | 489 void InitializeSettings(LayerTreeSettings* settings) override { |
488 settings->single_thread_proxy_scheduler = false; | 490 settings->single_thread_proxy_scheduler = false; |
489 settings->use_zero_copy = true; | 491 settings->use_zero_copy = true; |
490 } | 492 } |
491 | 493 |
492 void RequestNewOutputSurface() override { | 494 void RequestNewCompositorFrameSink() override { |
493 num_requests_++; | 495 num_requests_++; |
494 // There should be one initial request and then one request from | 496 // There should be one initial request and then one request from |
495 // the LayerTreeTest test hooks DidFailToInitializeOutputSurface (which is | 497 // the LayerTreeTest test hooks DidFailToInitializeCompositorFrameSink |
496 // hard to skip). This second request is just ignored and is test cruft. | 498 // (which is hard to skip). This second request is just ignored and is test |
| 499 // cruft. |
497 EXPECT_LE(num_requests_, 2); | 500 EXPECT_LE(num_requests_, 2); |
498 if (num_requests_ > 1) | 501 if (num_requests_ > 1) |
499 return; | 502 return; |
500 LayerTreeHostContextTest::RequestNewOutputSurface(); | 503 LayerTreeHostContextTest::RequestNewCompositorFrameSink(); |
501 } | 504 } |
502 | 505 |
503 std::unique_ptr<TestDelegatingOutputSurface> CreateDelegatingOutputSurface( | 506 std::unique_ptr<TestCompositorFrameSink> CreateCompositorFrameSink( |
504 scoped_refptr<ContextProvider> compositor_context_provider, | 507 scoped_refptr<ContextProvider> compositor_context_provider, |
505 scoped_refptr<ContextProvider> worker_context_provider) override { | 508 scoped_refptr<ContextProvider> worker_context_provider) override { |
506 ExpectCreateToFail(); | 509 ExpectCreateToFail(); |
507 auto test_compositor_context_provider = TestContextProvider::Create(); | 510 auto test_compositor_context_provider = TestContextProvider::Create(); |
508 test_compositor_context_provider->UnboundTestContext3d() | 511 test_compositor_context_provider->UnboundTestContext3d() |
509 ->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, | 512 ->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, |
510 GL_INNOCENT_CONTEXT_RESET_ARB); | 513 GL_INNOCENT_CONTEXT_RESET_ARB); |
511 return LayerTreeTest::CreateDelegatingOutputSurface( | 514 return LayerTreeTest::CreateCompositorFrameSink( |
512 std::move(test_compositor_context_provider), | 515 std::move(test_compositor_context_provider), |
513 std::move(worker_context_provider)); | 516 std::move(worker_context_provider)); |
514 } | 517 } |
515 | 518 |
516 void BeginTest() override { | 519 void BeginTest() override { |
517 // First composite tries to create a surface. | 520 // First composite tries to create a surface. |
518 layer_tree_host()->Composite(base::TimeTicks::FromInternalValue(1)); | 521 layer_tree_host()->Composite(base::TimeTicks::FromInternalValue(1)); |
519 EXPECT_EQ(num_requests_, 2); | 522 EXPECT_EQ(num_requests_, 2); |
520 EXPECT_TRUE(has_failed_); | 523 EXPECT_TRUE(has_failed_); |
521 | 524 |
522 // Second composite should not request or fail. | 525 // Second composite should not request or fail. |
523 layer_tree_host()->Composite(base::TimeTicks::FromInternalValue(2)); | 526 layer_tree_host()->Composite(base::TimeTicks::FromInternalValue(2)); |
524 EXPECT_EQ(num_requests_, 2); | 527 EXPECT_EQ(num_requests_, 2); |
525 EndTest(); | 528 EndTest(); |
526 } | 529 } |
527 | 530 |
528 void DidInitializeOutputSurface() override { EXPECT_TRUE(false); } | 531 void DidInitializeCompositorFrameSink() override { EXPECT_TRUE(false); } |
529 | 532 |
530 void DidFailToInitializeOutputSurface() override { | 533 void DidFailToInitializeCompositorFrameSink() override { |
531 LayerTreeHostContextTest::DidFailToInitializeOutputSurface(); | 534 LayerTreeHostContextTest::DidFailToInitializeCompositorFrameSink(); |
532 EXPECT_FALSE(has_failed_); | 535 EXPECT_FALSE(has_failed_); |
533 has_failed_ = true; | 536 has_failed_ = true; |
534 } | 537 } |
535 | 538 |
536 void AfterTest() override {} | 539 void AfterTest() override {} |
537 | 540 |
538 int num_requests_; | 541 int num_requests_; |
539 bool has_failed_; | 542 bool has_failed_; |
540 }; | 543 }; |
541 | 544 |
542 // This test uses Composite() which only exists for single thread. | 545 // This test uses Composite() which only exists for single thread. |
543 SINGLE_THREAD_TEST_F(FailedCreateDoesNotCreateExtraOutputSurface); | 546 SINGLE_THREAD_TEST_F(FailedCreateDoesNotCreateExtraCompositorFrameSink); |
544 | 547 |
545 class LayerTreeHostContextTestCommitAfterDelayedOutputSurface | 548 class LayerTreeHostContextTestCommitAfterDelayedCompositorFrameSink |
546 : public LayerTreeHostContextTest { | 549 : public LayerTreeHostContextTest { |
547 public: | 550 public: |
548 LayerTreeHostContextTestCommitAfterDelayedOutputSurface() | 551 LayerTreeHostContextTestCommitAfterDelayedCompositorFrameSink() |
549 : LayerTreeHostContextTest(), creating_output_(false) {} | 552 : LayerTreeHostContextTest(), creating_output_(false) {} |
550 | 553 |
551 void InitializeSettings(LayerTreeSettings* settings) override { | 554 void InitializeSettings(LayerTreeSettings* settings) override { |
552 settings->single_thread_proxy_scheduler = false; | 555 settings->single_thread_proxy_scheduler = false; |
553 settings->use_zero_copy = true; | 556 settings->use_zero_copy = true; |
554 } | 557 } |
555 | 558 |
556 void RequestNewOutputSurface() override { | 559 void RequestNewCompositorFrameSink() override { |
557 MainThreadTaskRunner()->PostTask( | 560 MainThreadTaskRunner()->PostTask( |
558 FROM_HERE, | 561 FROM_HERE, |
559 base::Bind(&LayerTreeHostContextTestCommitAfterDelayedOutputSurface:: | 562 base::Bind( |
560 CreateAndSetOutputSurface, | 563 &LayerTreeHostContextTestCommitAfterDelayedCompositorFrameSink:: |
561 base::Unretained(this))); | 564 CreateAndSetCompositorFrameSink, |
| 565 base::Unretained(this))); |
562 } | 566 } |
563 | 567 |
564 void CreateAndSetOutputSurface() { | 568 void CreateAndSetCompositorFrameSink() { |
565 creating_output_ = true; | 569 creating_output_ = true; |
566 LayerTreeHostContextTest::RequestNewOutputSurface(); | 570 LayerTreeHostContextTest::RequestNewCompositorFrameSink(); |
567 } | 571 } |
568 | 572 |
569 void BeginTest() override { | 573 void BeginTest() override { |
570 layer_tree_host()->Composite(base::TimeTicks::FromInternalValue(1)); | 574 layer_tree_host()->Composite(base::TimeTicks::FromInternalValue(1)); |
571 } | 575 } |
572 | 576 |
573 void ScheduleComposite() override { | 577 void ScheduleComposite() override { |
574 if (creating_output_) | 578 if (creating_output_) |
575 EndTest(); | 579 EndTest(); |
576 } | 580 } |
577 | 581 |
578 void AfterTest() override {} | 582 void AfterTest() override {} |
579 | 583 |
580 bool creating_output_; | 584 bool creating_output_; |
581 }; | 585 }; |
582 | 586 |
583 // This test uses Composite() which only exists for single thread. | 587 // This test uses Composite() which only exists for single thread. |
584 SINGLE_THREAD_TEST_F(LayerTreeHostContextTestCommitAfterDelayedOutputSurface); | 588 SINGLE_THREAD_TEST_F( |
| 589 LayerTreeHostContextTestCommitAfterDelayedCompositorFrameSink); |
585 | 590 |
586 class LayerTreeHostContextTestAvoidUnnecessaryComposite | 591 class LayerTreeHostContextTestAvoidUnnecessaryComposite |
587 : public LayerTreeHostContextTest { | 592 : public LayerTreeHostContextTest { |
588 public: | 593 public: |
589 LayerTreeHostContextTestAvoidUnnecessaryComposite() | 594 LayerTreeHostContextTestAvoidUnnecessaryComposite() |
590 : LayerTreeHostContextTest(), in_composite_(false) {} | 595 : LayerTreeHostContextTest(), in_composite_(false) {} |
591 | 596 |
592 void InitializeSettings(LayerTreeSettings* settings) override { | 597 void InitializeSettings(LayerTreeSettings* settings) override { |
593 settings->single_thread_proxy_scheduler = false; | 598 settings->single_thread_proxy_scheduler = false; |
594 settings->use_zero_copy = true; | 599 settings->use_zero_copy = true; |
595 } | 600 } |
596 | 601 |
597 void RequestNewOutputSurface() override { | 602 void RequestNewCompositorFrameSink() override { |
598 LayerTreeHostContextTest::RequestNewOutputSurface(); | 603 LayerTreeHostContextTest::RequestNewCompositorFrameSink(); |
599 EndTest(); | 604 EndTest(); |
600 } | 605 } |
601 | 606 |
602 void BeginTest() override { | 607 void BeginTest() override { |
603 in_composite_ = true; | 608 in_composite_ = true; |
604 layer_tree_host()->Composite(base::TimeTicks::FromInternalValue(1)); | 609 layer_tree_host()->Composite(base::TimeTicks::FromInternalValue(1)); |
605 in_composite_ = false; | 610 in_composite_ = false; |
606 } | 611 } |
607 | 612 |
608 void ScheduleComposite() override { EXPECT_FALSE(in_composite_); } | 613 void ScheduleComposite() override { EXPECT_FALSE(in_composite_); } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 | 664 |
660 protected: | 665 protected: |
661 FakeContentLayerClient client_; | 666 FakeContentLayerClient client_; |
662 scoped_refptr<Layer> root_; | 667 scoped_refptr<Layer> root_; |
663 scoped_refptr<Layer> layer_; | 668 scoped_refptr<Layer> layer_; |
664 }; | 669 }; |
665 | 670 |
666 SINGLE_AND_MULTI_THREAD_TEST_F( | 671 SINGLE_AND_MULTI_THREAD_TEST_F( |
667 LayerTreeHostContextTestLostContextSucceedsWithContent); | 672 LayerTreeHostContextTestLostContextSucceedsWithContent); |
668 | 673 |
669 class LayerTreeHostContextTestCreateOutputSurfaceFailsOnce | 674 class LayerTreeHostContextTestCreateCompositorFrameSinkFailsOnce |
670 : public LayerTreeHostContextTest { | 675 : public LayerTreeHostContextTest { |
671 public: | 676 public: |
672 LayerTreeHostContextTestCreateOutputSurfaceFailsOnce() | 677 LayerTreeHostContextTestCreateCompositorFrameSinkFailsOnce() |
673 : times_to_fail_(1), times_initialized_(0) { | 678 : times_to_fail_(1), times_initialized_(0) { |
674 times_to_fail_create_ = times_to_fail_; | 679 times_to_fail_create_ = times_to_fail_; |
675 } | 680 } |
676 | 681 |
677 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 682 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
678 | 683 |
679 void DidInitializeOutputSurface() override { times_initialized_++; } | 684 void DidInitializeCompositorFrameSink() override { times_initialized_++; } |
680 | 685 |
681 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { EndTest(); } | 686 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { EndTest(); } |
682 | 687 |
683 void AfterTest() override { | 688 void AfterTest() override { |
684 EXPECT_EQ(times_to_fail_, times_create_failed_); | 689 EXPECT_EQ(times_to_fail_, times_create_failed_); |
685 EXPECT_NE(0, times_initialized_); | 690 EXPECT_NE(0, times_initialized_); |
686 } | 691 } |
687 | 692 |
688 private: | 693 private: |
689 int times_to_fail_; | 694 int times_to_fail_; |
690 int times_initialized_; | 695 int times_initialized_; |
691 }; | 696 }; |
692 | 697 |
693 SINGLE_AND_MULTI_THREAD_TEST_F( | 698 SINGLE_AND_MULTI_THREAD_TEST_F( |
694 LayerTreeHostContextTestCreateOutputSurfaceFailsOnce); | 699 LayerTreeHostContextTestCreateCompositorFrameSinkFailsOnce); |
695 | 700 |
696 class LayerTreeHostContextTestLostContextAndEvictTextures | 701 class LayerTreeHostContextTestLostContextAndEvictTextures |
697 : public LayerTreeHostContextTest { | 702 : public LayerTreeHostContextTest { |
698 public: | 703 public: |
699 LayerTreeHostContextTestLostContextAndEvictTextures() | 704 LayerTreeHostContextTestLostContextAndEvictTextures() |
700 : LayerTreeHostContextTest(), | 705 : LayerTreeHostContextTest(), |
701 impl_host_(0), | 706 impl_host_(0), |
702 num_commits_(0), | 707 num_commits_(0), |
703 lost_context_(false) {} | 708 lost_context_(false) {} |
704 | 709 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 EXPECT_TRUE(picture_impl->HighResTiling() | 769 EXPECT_TRUE(picture_impl->HighResTiling() |
765 ->TileAt(0, 0) | 770 ->TileAt(0, 0) |
766 ->draw_info() | 771 ->draw_info() |
767 .IsReadyToDraw()); | 772 .IsReadyToDraw()); |
768 | 773 |
769 impl_host_ = impl; | 774 impl_host_ = impl; |
770 if (lost_context_) | 775 if (lost_context_) |
771 EndTest(); | 776 EndTest(); |
772 } | 777 } |
773 | 778 |
774 void DidInitializeOutputSurface() override {} | 779 void DidInitializeCompositorFrameSink() override {} |
775 | 780 |
776 void AfterTest() override {} | 781 void AfterTest() override {} |
777 | 782 |
778 protected: | 783 protected: |
779 bool lose_after_evict_; | 784 bool lose_after_evict_; |
780 FakeContentLayerClient client_; | 785 FakeContentLayerClient client_; |
781 LayerTreeHostImpl* impl_host_; | 786 LayerTreeHostImpl* impl_host_; |
782 int num_commits_; | 787 int num_commits_; |
783 bool lost_context_; | 788 bool lost_context_; |
784 }; | 789 }; |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
876 }; | 881 }; |
877 | 882 |
878 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestLayersNotified); | 883 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestLayersNotified); |
879 | 884 |
880 class LayerTreeHostContextTestDontUseLostResources | 885 class LayerTreeHostContextTestDontUseLostResources |
881 : public LayerTreeHostContextTest { | 886 : public LayerTreeHostContextTest { |
882 public: | 887 public: |
883 LayerTreeHostContextTestDontUseLostResources() : lost_context_(false) { | 888 LayerTreeHostContextTestDontUseLostResources() : lost_context_(false) { |
884 context_should_support_io_surface_ = true; | 889 context_should_support_io_surface_ = true; |
885 | 890 |
886 child_output_surface_ = FakeOutputSurface::CreateDelegating3d(); | 891 child_context_provider_ = TestContextProvider::Create(); |
887 child_output_surface_->BindToClient(&output_surface_client_); | 892 CHECK(child_context_provider_->BindToCurrentThread()); |
888 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); | 893 shared_bitmap_manager_.reset(new TestSharedBitmapManager); |
889 child_resource_provider_ = FakeResourceProvider::Create( | 894 child_resource_provider_ = FakeResourceProvider::Create( |
890 child_output_surface_.get(), shared_bitmap_manager_.get()); | 895 child_context_provider_.get(), shared_bitmap_manager_.get()); |
891 } | 896 } |
892 | 897 |
893 static void EmptyReleaseCallback(const gpu::SyncToken& sync_token, | 898 static void EmptyReleaseCallback(const gpu::SyncToken& sync_token, |
894 bool lost) {} | 899 bool lost) {} |
895 | 900 |
896 void SetupTree() override { | 901 void SetupTree() override { |
897 gpu::gles2::GLES2Interface* gl = | 902 gpu::gles2::GLES2Interface* gl = child_context_provider_->ContextGL(); |
898 child_output_surface_->context_provider()->ContextGL(); | |
899 | 903 |
900 std::unique_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); | 904 std::unique_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); |
901 | 905 |
902 std::unique_ptr<RenderPass> pass_for_quad = RenderPass::Create(); | 906 std::unique_ptr<RenderPass> pass_for_quad = RenderPass::Create(); |
903 pass_for_quad->SetNew( | 907 pass_for_quad->SetNew( |
904 // AppendOneOfEveryQuadType() makes a RenderPass quad with this id. | 908 // AppendOneOfEveryQuadType() makes a RenderPass quad with this id. |
905 RenderPassId(2, 1), | 909 RenderPassId(2, 1), |
906 gfx::Rect(0, 0, 10, 10), | 910 gfx::Rect(0, 0, 10, 10), |
907 gfx::Rect(0, 0, 10, 10), | 911 gfx::Rect(0, 0, 10, 10), |
908 gfx::Transform()); | 912 gfx::Transform()); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1036 LayerTreeHostImpl::FrameData* frame, | 1040 LayerTreeHostImpl::FrameData* frame, |
1037 DrawResult draw_result) override { | 1041 DrawResult draw_result) override { |
1038 if (host_impl->active_tree()->source_frame_number() == 2) { | 1042 if (host_impl->active_tree()->source_frame_number() == 2) { |
1039 // Lose the context during draw on the second commit. This will cause | 1043 // Lose the context during draw on the second commit. This will cause |
1040 // a third commit to recover. | 1044 // a third commit to recover. |
1041 context3d_->set_times_bind_texture_succeeds(0); | 1045 context3d_->set_times_bind_texture_succeeds(0); |
1042 } | 1046 } |
1043 return draw_result; | 1047 return draw_result; |
1044 } | 1048 } |
1045 | 1049 |
1046 void RequestNewOutputSurface() override { | 1050 void RequestNewCompositorFrameSink() override { |
1047 // This will get called twice: | 1051 // This will get called twice: |
1048 // First when we create the initial output surface... | 1052 // First when we create the initial CompositorFrameSink... |
1049 if (layer_tree_host()->SourceFrameNumber() > 0) { | 1053 if (layer_tree_host()->SourceFrameNumber() > 0) { |
1050 // ... and then again after we forced the context to be lost. | 1054 // ... and then again after we forced the context to be lost. |
1051 lost_context_ = true; | 1055 lost_context_ = true; |
1052 } | 1056 } |
1053 LayerTreeHostContextTest::RequestNewOutputSurface(); | 1057 LayerTreeHostContextTest::RequestNewCompositorFrameSink(); |
1054 } | 1058 } |
1055 | 1059 |
1056 void DidCommitAndDrawFrame() override { | 1060 void DidCommitAndDrawFrame() override { |
1057 ASSERT_TRUE(layer_tree()->hud_layer()); | 1061 ASSERT_TRUE(layer_tree()->hud_layer()); |
1058 // End the test once we know the 3nd frame drew. | 1062 // End the test once we know the 3nd frame drew. |
1059 if (layer_tree_host()->SourceFrameNumber() < 5) { | 1063 if (layer_tree_host()->SourceFrameNumber() < 5) { |
1060 layer_tree()->root_layer()->SetNeedsDisplay(); | 1064 layer_tree()->root_layer()->SetNeedsDisplay(); |
1061 layer_tree_host()->SetNeedsCommit(); | 1065 layer_tree_host()->SetNeedsCommit(); |
1062 } else { | 1066 } else { |
1063 EndTest(); | 1067 EndTest(); |
1064 } | 1068 } |
1065 } | 1069 } |
1066 | 1070 |
1067 void AfterTest() override { EXPECT_TRUE(lost_context_); } | 1071 void AfterTest() override { EXPECT_TRUE(lost_context_); } |
1068 | 1072 |
1069 private: | 1073 private: |
1070 FakeContentLayerClient client_; | 1074 FakeContentLayerClient client_; |
1071 bool lost_context_; | 1075 bool lost_context_; |
1072 | 1076 |
1073 FakeOutputSurfaceClient output_surface_client_; | 1077 scoped_refptr<TestContextProvider> child_context_provider_; |
1074 std::unique_ptr<FakeOutputSurface> child_output_surface_; | |
1075 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager_; | 1078 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager_; |
1076 std::unique_ptr<ResourceProvider> child_resource_provider_; | 1079 std::unique_ptr<ResourceProvider> child_resource_provider_; |
1077 | 1080 |
1078 scoped_refptr<VideoFrame> color_video_frame_; | 1081 scoped_refptr<VideoFrame> color_video_frame_; |
1079 scoped_refptr<VideoFrame> hw_video_frame_; | 1082 scoped_refptr<VideoFrame> hw_video_frame_; |
1080 scoped_refptr<VideoFrame> scaled_hw_video_frame_; | 1083 scoped_refptr<VideoFrame> scaled_hw_video_frame_; |
1081 | 1084 |
1082 FakeVideoFrameProvider color_frame_provider_; | 1085 FakeVideoFrameProvider color_frame_provider_; |
1083 FakeVideoFrameProvider hw_frame_provider_; | 1086 FakeVideoFrameProvider hw_frame_provider_; |
1084 FakeVideoFrameProvider scaled_hw_frame_provider_; | 1087 FakeVideoFrameProvider scaled_hw_frame_provider_; |
(...skipping 19 matching lines...) Expand all Loading... |
1104 LayerTreeHostContextTest::SetupTree(); | 1107 LayerTreeHostContextTest::SetupTree(); |
1105 } | 1108 } |
1106 | 1109 |
1107 void BeginTest() override { | 1110 void BeginTest() override { |
1108 times_to_lose_during_commit_ = 1; | 1111 times_to_lose_during_commit_ = 1; |
1109 PostSetNeedsCommitToMainThread(); | 1112 PostSetNeedsCommitToMainThread(); |
1110 } | 1113 } |
1111 | 1114 |
1112 void AfterTest() override {} | 1115 void AfterTest() override {} |
1113 | 1116 |
1114 void DidInitializeOutputSurface() override { EndTest(); } | 1117 void DidInitializeCompositorFrameSink() override { EndTest(); } |
1115 | 1118 |
1116 private: | 1119 private: |
1117 FakeContentLayerClient client_; | 1120 FakeContentLayerClient client_; |
1118 }; | 1121 }; |
1119 | 1122 |
1120 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestImplSidePainting); | 1123 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestImplSidePainting); |
1121 | 1124 |
1122 class ScrollbarLayerLostContext : public LayerTreeHostContextTest { | 1125 class ScrollbarLayerLostContext : public LayerTreeHostContextTest { |
1123 public: | 1126 public: |
1124 ScrollbarLayerLostContext() : commits_(0) {} | 1127 ScrollbarLayerLostContext() : commits_(0) {} |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1597 layer_tree_host()->SetDeferCommits(true); | 1600 layer_tree_host()->SetDeferCommits(true); |
1598 // Meanwhile, lose the context while we are in defer commits. | 1601 // Meanwhile, lose the context while we are in defer commits. |
1599 ImplThreadTaskRunner()->PostTask( | 1602 ImplThreadTaskRunner()->PostTask( |
1600 FROM_HERE, | 1603 FROM_HERE, |
1601 base::Bind(&LayerTreeHostContextTestLoseAfterSendingBeginMainFrame:: | 1604 base::Bind(&LayerTreeHostContextTestLoseAfterSendingBeginMainFrame:: |
1602 LoseContextOnImplThread, | 1605 LoseContextOnImplThread, |
1603 base::Unretained(this))); | 1606 base::Unretained(this))); |
1604 | 1607 |
1605 // After the first frame, we will lose the context and then not start | 1608 // After the first frame, we will lose the context and then not start |
1606 // allowing commits until that happens. The 2nd frame should not happen | 1609 // allowing commits until that happens. The 2nd frame should not happen |
1607 // before DidInitializeOutputSurface occurs. | 1610 // before DidInitializeCompositorFrameSink occurs. |
1608 lost_ = true; | 1611 lost_ = true; |
1609 } | 1612 } |
1610 | 1613 |
1611 void DidInitializeOutputSurface() override { | 1614 void DidInitializeCompositorFrameSink() override { |
1612 EXPECT_TRUE(lost_); | 1615 EXPECT_TRUE(lost_); |
1613 lost_ = false; | 1616 lost_ = false; |
1614 } | 1617 } |
1615 | 1618 |
1616 void LoseContextOnImplThread() { | 1619 void LoseContextOnImplThread() { |
1617 LoseContext(); | 1620 LoseContext(); |
1618 | 1621 |
1619 // After losing the context, stop deferring commits. | 1622 // After losing the context, stop deferring commits. |
1620 PostSetDeferCommitsToMainThread(false); | 1623 PostSetDeferCommitsToMainThread(false); |
1621 } | 1624 } |
1622 | 1625 |
1623 void DidCommitAndDrawFrame() override { EndTest(); } | 1626 void DidCommitAndDrawFrame() override { EndTest(); } |
1624 | 1627 |
1625 void AfterTest() override {} | 1628 void AfterTest() override {} |
1626 | 1629 |
1627 bool deferred_ = false; | 1630 bool deferred_ = false; |
1628 bool lost_ = true; | 1631 bool lost_ = true; |
1629 }; | 1632 }; |
1630 | 1633 |
1631 SINGLE_AND_MULTI_THREAD_TEST_F( | 1634 SINGLE_AND_MULTI_THREAD_TEST_F( |
1632 LayerTreeHostContextTestLoseAfterSendingBeginMainFrame); | 1635 LayerTreeHostContextTestLoseAfterSendingBeginMainFrame); |
1633 | 1636 |
1634 } // namespace | 1637 } // namespace |
1635 } // namespace cc | 1638 } // namespace cc |
OLD | NEW |