Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(109)

Side by Side Diff: cc/trees/layer_tree_host_unittest_context.cc

Issue 738983002: Move output surface fallback from cc to embedders (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_host_unittest.cc ('k') | cc/trees/layer_tree_host_unittest_copyrequest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/layer_tree_host.h" 5 #include "cc/trees/layer_tree_host.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "cc/layers/content_layer.h" 8 #include "cc/layers/content_layer.h"
9 #include "cc/layers/delegated_frame_provider.h" 9 #include "cc/layers/delegated_frame_provider.h"
10 #include "cc/layers/delegated_frame_resource_collection.h" 10 #include "cc/layers/delegated_frame_resource_collection.h"
11 #include "cc/layers/heads_up_display_layer.h" 11 #include "cc/layers/heads_up_display_layer.h"
12 #include "cc/layers/io_surface_layer.h" 12 #include "cc/layers/io_surface_layer.h"
13 #include "cc/layers/layer_impl.h" 13 #include "cc/layers/layer_impl.h"
14 #include "cc/layers/painted_scrollbar_layer.h" 14 #include "cc/layers/painted_scrollbar_layer.h"
15 #include "cc/layers/picture_layer.h" 15 #include "cc/layers/picture_layer.h"
16 #include "cc/layers/texture_layer.h" 16 #include "cc/layers/texture_layer.h"
17 #include "cc/layers/texture_layer_impl.h" 17 #include "cc/layers/texture_layer_impl.h"
18 #include "cc/layers/video_layer.h" 18 #include "cc/layers/video_layer.h"
19 #include "cc/layers/video_layer_impl.h" 19 #include "cc/layers/video_layer_impl.h"
20 #include "cc/output/filter_operations.h" 20 #include "cc/output/filter_operations.h"
21 #include "cc/resources/single_release_callback.h" 21 #include "cc/resources/single_release_callback.h"
22 #include "cc/test/failure_output_surface.h"
22 #include "cc/test/fake_content_layer.h" 23 #include "cc/test/fake_content_layer.h"
23 #include "cc/test/fake_content_layer_client.h" 24 #include "cc/test/fake_content_layer_client.h"
24 #include "cc/test/fake_content_layer_impl.h" 25 #include "cc/test/fake_content_layer_impl.h"
25 #include "cc/test/fake_delegated_renderer_layer.h" 26 #include "cc/test/fake_delegated_renderer_layer.h"
26 #include "cc/test/fake_delegated_renderer_layer_impl.h" 27 #include "cc/test/fake_delegated_renderer_layer_impl.h"
27 #include "cc/test/fake_layer_tree_host_client.h" 28 #include "cc/test/fake_layer_tree_host_client.h"
28 #include "cc/test/fake_output_surface.h" 29 #include "cc/test/fake_output_surface.h"
29 #include "cc/test/fake_output_surface_client.h" 30 #include "cc/test/fake_output_surface_client.h"
30 #include "cc/test/fake_painted_scrollbar_layer.h" 31 #include "cc/test/fake_painted_scrollbar_layer.h"
31 #include "cc/test/fake_picture_layer.h" 32 #include "cc/test/fake_picture_layer.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 CHECK(context3d_); 75 CHECK(context3d_);
75 context3d_->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, 76 context3d_->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB,
76 GL_INNOCENT_CONTEXT_RESET_ARB); 77 GL_INNOCENT_CONTEXT_RESET_ARB);
77 context3d_ = NULL; 78 context3d_ = NULL;
78 } 79 }
79 80
80 virtual scoped_ptr<TestWebGraphicsContext3D> CreateContext3d() { 81 virtual scoped_ptr<TestWebGraphicsContext3D> CreateContext3d() {
81 return TestWebGraphicsContext3D::Create(); 82 return TestWebGraphicsContext3D::Create();
82 } 83 }
83 84
84 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface( 85 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override {
85 bool fallback) override {
86 if (times_to_fail_create_) { 86 if (times_to_fail_create_) {
87 --times_to_fail_create_; 87 --times_to_fail_create_;
88 ExpectCreateToFail(); 88 ExpectCreateToFail();
89 return nullptr; 89 return make_scoped_ptr(new FailureOutputSurface(delegating_renderer()));
90 } 90 }
91 91
92 scoped_ptr<TestWebGraphicsContext3D> context3d = CreateContext3d(); 92 scoped_ptr<TestWebGraphicsContext3D> context3d = CreateContext3d();
93 context3d_ = context3d.get(); 93 context3d_ = context3d.get();
94 94
95 if (context_should_support_io_surface_) { 95 if (context_should_support_io_surface_) {
96 context3d_->set_have_extension_io_surface(true); 96 context3d_->set_have_extension_io_surface(true);
97 context3d_->set_have_extension_egl_image(true); 97 context3d_->set_have_extension_egl_image(true);
98 } 98 }
99 99
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 LayerTreeHostContextTestLostContextSucceeds() 167 LayerTreeHostContextTestLostContextSucceeds()
168 : LayerTreeHostContextTest(), 168 : LayerTreeHostContextTest(),
169 test_case_(0), 169 test_case_(0),
170 num_losses_(0), 170 num_losses_(0),
171 num_losses_last_test_case_(-1), 171 num_losses_last_test_case_(-1),
172 recovered_context_(true), 172 recovered_context_(true),
173 first_initialized_(false) {} 173 first_initialized_(false) {}
174 174
175 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 175 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
176 176
177 void RequestNewOutputSurface(bool fallback) override { 177 void RequestNewOutputSurface() override {
178 if (async_output_surface_creation_) { 178 if (async_output_surface_creation_) {
179 MainThreadTaskRunner()->PostTask( 179 MainThreadTaskRunner()->PostTask(
180 FROM_HERE, 180 FROM_HERE, base::Bind(&LayerTreeHostContextTestLostContextSucceeds::
181 base::Bind(&LayerTreeHostContextTestLostContextSucceeds:: 181 CreateAndSetOutputSurface,
182 CreateAndSetOutputSurface, 182 base::Unretained(this)));
183 base::Unretained(this),
184 fallback));
185 } else { 183 } else {
186 CreateAndSetOutputSurface(fallback); 184 CreateAndSetOutputSurface();
187 } 185 }
188 } 186 }
189 187
190 void CreateAndSetOutputSurface(bool fallback) { 188 void CreateAndSetOutputSurface() {
191 layer_tree_host()->SetOutputSurface( 189 scoped_ptr<OutputSurface> surface(
192 LayerTreeHostContextTest::CreateOutputSurface(fallback)); 190 LayerTreeHostContextTest::CreateOutputSurface());
191 CHECK(surface);
192 layer_tree_host()->SetOutputSurface(surface.Pass());
193 } 193 }
194 194
195 void DidInitializeOutputSurface() override { 195 void DidInitializeOutputSurface() override {
196 if (first_initialized_) 196 if (first_initialized_)
197 ++num_losses_; 197 ++num_losses_;
198 else 198 else
199 first_initialized_ = true; 199 first_initialized_ = true;
200 200
201 recovered_context_ = true; 201 recovered_context_ = true;
202 } 202 }
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 357
358 void WillBeginTest() override { 358 void WillBeginTest() override {
359 // Override and do not signal SetLayerTreeHostClientReady. 359 // Override and do not signal SetLayerTreeHostClientReady.
360 } 360 }
361 361
362 void BeginTest() override { 362 void BeginTest() override {
363 PostSetNeedsCommitToMainThread(); 363 PostSetNeedsCommitToMainThread();
364 EndTest(); 364 EndTest();
365 } 365 }
366 366
367 scoped_ptr<OutputSurface> CreateOutputSurface(bool fallback) override { 367 scoped_ptr<OutputSurface> CreateOutputSurface() override {
368 EXPECT_TRUE(false); 368 EXPECT_TRUE(false);
369 return nullptr; 369 return nullptr;
370 } 370 }
371 371
372 void DidInitializeOutputSurface() override { EXPECT_TRUE(false); } 372 void DidInitializeOutputSurface() override { EXPECT_TRUE(false); }
373 373
374 void AfterTest() override {} 374 void AfterTest() override {}
375 }; 375 };
376 376
377 SINGLE_AND_MULTI_THREAD_TEST_F( 377 SINGLE_AND_MULTI_THREAD_TEST_F(
378 LayerTreeHostClientNotReadyDoesNotCreateOutputSurface); 378 LayerTreeHostClientNotReadyDoesNotCreateOutputSurface);
379 379
380 class MultipleCompositeDoesNotCreateOutputSurface 380 class MultipleCompositeDoesNotCreateOutputSurface
381 : public LayerTreeHostContextTest { 381 : public LayerTreeHostContextTest {
382 public: 382 public:
383 MultipleCompositeDoesNotCreateOutputSurface() 383 MultipleCompositeDoesNotCreateOutputSurface()
384 : LayerTreeHostContextTest(), request_count_(0) {} 384 : LayerTreeHostContextTest(), request_count_(0) {}
385 385
386 void InitializeSettings(LayerTreeSettings* settings) override { 386 void InitializeSettings(LayerTreeSettings* settings) override {
387 settings->single_thread_proxy_scheduler = false; 387 settings->single_thread_proxy_scheduler = false;
388 } 388 }
389 389
390 void RequestNewOutputSurface(bool fallback) override { 390 void RequestNewOutputSurface() override {
391 EXPECT_GE(1, ++request_count_); 391 EXPECT_GE(1, ++request_count_);
392 EndTest(); 392 EndTest();
393 } 393 }
394 394
395 void BeginTest() override { 395 void BeginTest() override {
396 layer_tree_host()->Composite(base::TimeTicks()); 396 layer_tree_host()->Composite(base::TimeTicks());
397 layer_tree_host()->Composite(base::TimeTicks()); 397 layer_tree_host()->Composite(base::TimeTicks());
398 } 398 }
399 399
400 scoped_ptr<OutputSurface> CreateOutputSurface(bool fallback) override { 400 scoped_ptr<OutputSurface> CreateOutputSurface() override {
401 EXPECT_TRUE(false); 401 EXPECT_TRUE(false);
402 return nullptr; 402 return nullptr;
403 } 403 }
404 404
405 void DidInitializeOutputSurface() override { EXPECT_TRUE(false); } 405 void DidInitializeOutputSurface() override { EXPECT_TRUE(false); }
406 406
407 void AfterTest() override {} 407 void AfterTest() override {}
408 408
409 int request_count_; 409 int request_count_;
410 }; 410 };
411 411
412 SINGLE_THREAD_NOIMPL_TEST_F(MultipleCompositeDoesNotCreateOutputSurface); 412 SINGLE_THREAD_NOIMPL_TEST_F(MultipleCompositeDoesNotCreateOutputSurface);
413 413
414 class FailedCreateDoesNotCreateExtraOutputSurface 414 class FailedCreateDoesNotCreateExtraOutputSurface
415 : public LayerTreeHostContextTest { 415 : public LayerTreeHostContextTest {
416 public: 416 public:
417 FailedCreateDoesNotCreateExtraOutputSurface() 417 FailedCreateDoesNotCreateExtraOutputSurface()
418 : LayerTreeHostContextTest(), request_count_(0) {} 418 : LayerTreeHostContextTest(), request_count_(0) {}
419 419
420 void InitializeSettings(LayerTreeSettings* settings) override { 420 void InitializeSettings(LayerTreeSettings* settings) override {
421 settings->single_thread_proxy_scheduler = false; 421 settings->single_thread_proxy_scheduler = false;
422 } 422 }
423 423
424 void RequestNewOutputSurface(bool fallback) override { 424 void RequestNewOutputSurface() override {
425 if (request_count_ == 0) { 425 if (request_count_ == 0) {
426 ExpectCreateToFail(); 426 ExpectCreateToFail();
427 layer_tree_host()->SetOutputSurface(nullptr); 427 layer_tree_host()->SetOutputSurface(
428 make_scoped_ptr(new FailureOutputSurface(false)));
428 } 429 }
429 EXPECT_GE(2, ++request_count_);
430 EndTest();
431 } 430 }
432 431
433 void BeginTest() override { 432 void BeginTest() override {
434 layer_tree_host()->Composite(base::TimeTicks()); 433 layer_tree_host()->Composite(base::TimeTicks());
435 layer_tree_host()->Composite(base::TimeTicks()); 434 layer_tree_host()->Composite(base::TimeTicks());
436 } 435 }
437 436
438 scoped_ptr<OutputSurface> CreateOutputSurface(bool fallback) override {
439 EXPECT_TRUE(false);
440 return nullptr;
441 }
442
443 void DidInitializeOutputSurface() override { EXPECT_TRUE(false); } 437 void DidInitializeOutputSurface() override { EXPECT_TRUE(false); }
444 438
439 void DidFailToInitializeOutputSurface() override {
440 LayerTreeHostContextTest::DidFailToInitializeOutputSurface();
441 EXPECT_GE(2, ++request_count_);
442 EndTest();
443 }
444
445 void AfterTest() override {} 445 void AfterTest() override {}
446 446
447 int request_count_; 447 int request_count_;
448 }; 448 };
449 449
450 SINGLE_THREAD_NOIMPL_TEST_F(FailedCreateDoesNotCreateExtraOutputSurface); 450 SINGLE_THREAD_NOIMPL_TEST_F(FailedCreateDoesNotCreateExtraOutputSurface);
451 451
452 class LayerTreeHostContextTestCommitAfterDelayedOutputSurface 452 class LayerTreeHostContextTestCommitAfterDelayedOutputSurface
453 : public LayerTreeHostContextTest { 453 : public LayerTreeHostContextTest {
454 public: 454 public:
455 LayerTreeHostContextTestCommitAfterDelayedOutputSurface() 455 LayerTreeHostContextTestCommitAfterDelayedOutputSurface()
456 : LayerTreeHostContextTest(), creating_output_(false) {} 456 : LayerTreeHostContextTest(), creating_output_(false) {}
457 457
458 void InitializeSettings(LayerTreeSettings* settings) override { 458 void InitializeSettings(LayerTreeSettings* settings) override {
459 settings->single_thread_proxy_scheduler = false; 459 settings->single_thread_proxy_scheduler = false;
460 } 460 }
461 461
462 void RequestNewOutputSurface(bool fallback) override { 462 void RequestNewOutputSurface() override {
463 MainThreadTaskRunner()->PostTask( 463 MainThreadTaskRunner()->PostTask(
464 FROM_HERE, 464 FROM_HERE,
465 base::Bind(&LayerTreeHostContextTestCommitAfterDelayedOutputSurface:: 465 base::Bind(&LayerTreeHostContextTestCommitAfterDelayedOutputSurface::
466 CreateAndSetOutputSurface, 466 CreateAndSetOutputSurface,
467 base::Unretained(this), 467 base::Unretained(this)));
468 fallback));
469 } 468 }
470 469
471 void CreateAndSetOutputSurface(bool fallback) { 470 void CreateAndSetOutputSurface() {
472 creating_output_ = true; 471 creating_output_ = true;
473 layer_tree_host()->SetOutputSurface( 472 layer_tree_host()->SetOutputSurface(
474 LayerTreeHostContextTest::CreateOutputSurface(fallback)); 473 LayerTreeHostContextTest::CreateOutputSurface());
475 } 474 }
476 475
477 void BeginTest() override { layer_tree_host()->Composite(base::TimeTicks()); } 476 void BeginTest() override { layer_tree_host()->Composite(base::TimeTicks()); }
478 477
479 void ScheduleComposite() override { 478 void ScheduleComposite() override {
480 if (creating_output_) 479 if (creating_output_)
481 EndTest(); 480 EndTest();
482 } 481 }
483 482
484 void AfterTest() override {} 483 void AfterTest() override {}
485 484
486 bool creating_output_; 485 bool creating_output_;
487 }; 486 };
488 487
489 SINGLE_THREAD_NOIMPL_TEST_F( 488 SINGLE_THREAD_NOIMPL_TEST_F(
490 LayerTreeHostContextTestCommitAfterDelayedOutputSurface); 489 LayerTreeHostContextTestCommitAfterDelayedOutputSurface);
491 490
492 class LayerTreeHostContextTestAvoidUnnecessaryComposite 491 class LayerTreeHostContextTestAvoidUnnecessaryComposite
493 : public LayerTreeHostContextTest { 492 : public LayerTreeHostContextTest {
494 public: 493 public:
495 LayerTreeHostContextTestAvoidUnnecessaryComposite() 494 LayerTreeHostContextTestAvoidUnnecessaryComposite()
496 : LayerTreeHostContextTest(), in_composite_(false) {} 495 : LayerTreeHostContextTest(), in_composite_(false) {}
497 496
498 void InitializeSettings(LayerTreeSettings* settings) override { 497 void InitializeSettings(LayerTreeSettings* settings) override {
499 settings->single_thread_proxy_scheduler = false; 498 settings->single_thread_proxy_scheduler = false;
500 } 499 }
501 500
502 void RequestNewOutputSurface(bool fallback) override { 501 void RequestNewOutputSurface() override {
503 layer_tree_host()->SetOutputSurface( 502 layer_tree_host()->SetOutputSurface(
504 LayerTreeHostContextTest::CreateOutputSurface(fallback)); 503 LayerTreeHostContextTest::CreateOutputSurface());
505 EndTest(); 504 EndTest();
506 } 505 }
507 506
508 void BeginTest() override { 507 void BeginTest() override {
509 in_composite_ = true; 508 in_composite_ = true;
510 layer_tree_host()->Composite(base::TimeTicks()); 509 layer_tree_host()->Composite(base::TimeTicks());
511 in_composite_ = false; 510 in_composite_ = false;
512 } 511 }
513 512
514 void ScheduleComposite() override { EXPECT_FALSE(in_composite_); } 513 void ScheduleComposite() override { EXPECT_FALSE(in_composite_); }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 protected: 571 protected:
573 FakeContentLayerClient client_; 572 FakeContentLayerClient client_;
574 scoped_refptr<Layer> root_; 573 scoped_refptr<Layer> root_;
575 scoped_refptr<Layer> layer_; 574 scoped_refptr<Layer> layer_;
576 }; 575 };
577 576
578 // This test uses TiledLayer and PictureLayer to check for a working context. 577 // This test uses TiledLayer and PictureLayer to check for a working context.
579 SINGLE_AND_MULTI_THREAD_TEST_F( 578 SINGLE_AND_MULTI_THREAD_TEST_F(
580 LayerTreeHostContextTestLostContextSucceedsWithContent); 579 LayerTreeHostContextTestLostContextSucceedsWithContent);
581 580
582 class LayerTreeHostContextTestCreateOutputSurfaceFails 581 class LayerTreeHostContextTestCreateOutputSurfaceFailsOnce
583 : public LayerTreeHostContextTest { 582 : public LayerTreeHostContextTest {
584 public: 583 public:
585 // Run a test that initially fails OutputSurface creation |times_to_fail| 584 LayerTreeHostContextTestCreateOutputSurfaceFailsOnce()
586 // times. If |expect_fallback_attempt| is |true|, an attempt to create a 585 : times_to_fail_(1), times_initialized_(0) {
587 // fallback/software OutputSurface is expected to occur.
588 LayerTreeHostContextTestCreateOutputSurfaceFails(int times_to_fail,
589 bool expect_fallback_attempt)
590 : times_to_fail_(times_to_fail),
591 expect_fallback_attempt_(expect_fallback_attempt),
592 did_attempt_fallback_(false),
593 times_initialized_(0) {
594 times_to_fail_create_ = times_to_fail_; 586 times_to_fail_create_ = times_to_fail_;
595 } 587 }
596 588
597 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 589 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
598 590
599 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(
600 bool fallback) override {
601 scoped_ptr<FakeOutputSurface> surface =
602 LayerTreeHostContextTest::CreateFakeOutputSurface(fallback);
603
604 if (surface)
605 EXPECT_EQ(times_to_fail_, times_create_failed_);
606
607 did_attempt_fallback_ = fallback;
608 return surface.Pass();
609 }
610
611 void DidInitializeOutputSurface() override { times_initialized_++; } 591 void DidInitializeOutputSurface() override { times_initialized_++; }
612 592
613 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { EndTest(); } 593 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { EndTest(); }
614 594
615 void AfterTest() override { 595 void AfterTest() override {
616 EXPECT_EQ(times_to_fail_, times_create_failed_); 596 EXPECT_EQ(times_to_fail_, times_create_failed_);
617 EXPECT_NE(0, times_initialized_); 597 EXPECT_NE(0, times_initialized_);
618 EXPECT_EQ(expect_fallback_attempt_, did_attempt_fallback_);
619 } 598 }
620 599
621 private: 600 private:
622 int times_to_fail_; 601 int times_to_fail_;
623 bool expect_fallback_attempt_;
624 bool did_attempt_fallback_;
625 int times_initialized_; 602 int times_initialized_;
626 }; 603 };
627 604
628 class LayerTreeHostContextTestCreateOutputSurfaceFailsOnce
629 : public LayerTreeHostContextTestCreateOutputSurfaceFails {
630 public:
631 LayerTreeHostContextTestCreateOutputSurfaceFailsOnce()
632 : LayerTreeHostContextTestCreateOutputSurfaceFails(1, false) {}
633 };
634
635 SINGLE_AND_MULTI_THREAD_TEST_F( 605 SINGLE_AND_MULTI_THREAD_TEST_F(
636 LayerTreeHostContextTestCreateOutputSurfaceFailsOnce); 606 LayerTreeHostContextTestCreateOutputSurfaceFailsOnce);
637 607
638 // After 4 failures we expect an attempt to create a fallback/software
639 // OutputSurface.
640 class LayerTreeHostContextTestCreateOutputSurfaceFailsWithFallback
641 : public LayerTreeHostContextTestCreateOutputSurfaceFails {
642 public:
643 LayerTreeHostContextTestCreateOutputSurfaceFailsWithFallback()
644 : LayerTreeHostContextTestCreateOutputSurfaceFails(4, true) {}
645 };
646
647 SINGLE_AND_MULTI_THREAD_TEST_F(
648 LayerTreeHostContextTestCreateOutputSurfaceFailsWithFallback);
649
650 class LayerTreeHostContextTestLostContextAndEvictTextures 608 class LayerTreeHostContextTestLostContextAndEvictTextures
651 : public LayerTreeHostContextTest { 609 : public LayerTreeHostContextTest {
652 public: 610 public:
653 LayerTreeHostContextTestLostContextAndEvictTextures() 611 LayerTreeHostContextTestLostContextAndEvictTextures()
654 : LayerTreeHostContextTest(), 612 : LayerTreeHostContextTest(),
655 impl_host_(0), 613 impl_host_(0),
656 num_commits_(0), 614 num_commits_(0),
657 lost_context_(false) {} 615 lost_context_(false) {}
658 616
659 void SetupTree() override { 617 void SetupTree() override {
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
1169 LayerTreeHostImpl::FrameData* frame, 1127 LayerTreeHostImpl::FrameData* frame,
1170 DrawResult draw_result) override { 1128 DrawResult draw_result) override {
1171 if (host_impl->active_tree()->source_frame_number() == 2) { 1129 if (host_impl->active_tree()->source_frame_number() == 2) {
1172 // Lose the context during draw on the second commit. This will cause 1130 // Lose the context during draw on the second commit. This will cause
1173 // a third commit to recover. 1131 // a third commit to recover.
1174 context3d_->set_times_bind_texture_succeeds(0); 1132 context3d_->set_times_bind_texture_succeeds(0);
1175 } 1133 }
1176 return draw_result; 1134 return draw_result;
1177 } 1135 }
1178 1136
1179 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface( 1137 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override {
1180 bool fallback) override {
1181 // This will get called twice: 1138 // This will get called twice:
1182 // First when we create the initial output surface... 1139 // First when we create the initial output surface...
1183 if (layer_tree_host()->source_frame_number() > 0) { 1140 if (layer_tree_host()->source_frame_number() > 0) {
1184 // ... and then again after we forced the context to be lost. 1141 // ... and then again after we forced the context to be lost.
1185 lost_context_ = true; 1142 lost_context_ = true;
1186 } 1143 }
1187 return LayerTreeHostContextTest::CreateFakeOutputSurface(fallback); 1144 return LayerTreeHostContextTest::CreateFakeOutputSurface();
1188 } 1145 }
1189 1146
1190 void DidCommitAndDrawFrame() override { 1147 void DidCommitAndDrawFrame() override {
1191 ASSERT_TRUE(layer_tree_host()->hud_layer()); 1148 ASSERT_TRUE(layer_tree_host()->hud_layer());
1192 // End the test once we know the 3nd frame drew. 1149 // End the test once we know the 3nd frame drew.
1193 if (layer_tree_host()->source_frame_number() < 5) { 1150 if (layer_tree_host()->source_frame_number() < 5) {
1194 layer_tree_host()->root_layer()->SetNeedsDisplay(); 1151 layer_tree_host()->root_layer()->SetNeedsDisplay();
1195 layer_tree_host()->SetNeedsCommit(); 1152 layer_tree_host()->SetNeedsCommit();
1196 } else { 1153 } else {
1197 EndTest(); 1154 EndTest();
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
1843 void AfterTest() override {} 1800 void AfterTest() override {}
1844 1801
1845 bool deferred_; 1802 bool deferred_;
1846 }; 1803 };
1847 1804
1848 SINGLE_AND_MULTI_THREAD_TEST_F( 1805 SINGLE_AND_MULTI_THREAD_TEST_F(
1849 LayerTreeHostContextTestLoseAfterSendingBeginMainFrame); 1806 LayerTreeHostContextTestLoseAfterSendingBeginMainFrame);
1850 1807
1851 } // namespace 1808 } // namespace
1852 } // namespace cc 1809 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_unittest.cc ('k') | cc/trees/layer_tree_host_unittest_copyrequest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698