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