OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/output/gl_renderer.h" | 5 #include "cc/output/gl_renderer.h" |
6 | 6 |
| 7 #include "base/message_loop.h" |
7 #include "cc/layers/append_quads_data.h" | 8 #include "cc/layers/append_quads_data.h" |
8 #include "cc/quads/draw_quad.h" | 9 #include "cc/quads/draw_quad.h" |
| 10 #include "cc/resources/sync_point_helper.h" |
9 #include "cc/test/pixel_test.h" | 11 #include "cc/test/pixel_test.h" |
| 12 #include "gpu/GLES2/gl2extchromium.h" |
10 #include "third_party/skia/include/core/SkImageFilter.h" | 13 #include "third_party/skia/include/core/SkImageFilter.h" |
11 #include "third_party/skia/include/core/SkMatrix.h" | 14 #include "third_party/skia/include/core/SkMatrix.h" |
12 #include "third_party/skia/include/effects/SkColorFilterImageFilter.h" | 15 #include "third_party/skia/include/effects/SkColorFilterImageFilter.h" |
13 #include "third_party/skia/include/effects/SkColorMatrixFilter.h" | 16 #include "third_party/skia/include/effects/SkColorMatrixFilter.h" |
14 | 17 |
15 namespace cc { | 18 namespace cc { |
16 namespace { | 19 namespace { |
17 | 20 |
18 class GLRendererPixelTest : public PixelTest {}; | 21 class GLRendererPixelTest : public PixelTest {}; |
19 | 22 |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 | 559 |
557 RenderPassList pass_list; | 560 RenderPassList pass_list; |
558 pass_list.push_back(pass.Pass()); | 561 pass_list.push_back(pass.Pass()); |
559 | 562 |
560 EXPECT_TRUE(RunPixelTest( | 563 EXPECT_TRUE(RunPixelTest( |
561 &pass_list, | 564 &pass_list, |
562 base::FilePath(FILE_PATH_LITERAL("axis_aligned.png")), | 565 base::FilePath(FILE_PATH_LITERAL("axis_aligned.png")), |
563 ExactPixelComparator(true))); | 566 ExactPixelComparator(true))); |
564 } | 567 } |
565 | 568 |
| 569 static void SyncPointCallback(int* callback_count) { |
| 570 ++(*callback_count); |
| 571 base::MessageLoop::current()->QuitWhenIdle(); |
| 572 } |
| 573 |
| 574 static void OtherCallback(int* callback_count) { |
| 575 ++(*callback_count); |
| 576 base::MessageLoop::current()->QuitWhenIdle(); |
| 577 } |
| 578 |
| 579 TEST_F(GLRendererPixelTest, SignalSyncPointOnLostContext) { |
| 580 int sync_point_callback_count = 0; |
| 581 int other_callback_count = 0; |
| 582 unsigned sync_point = output_surface_->context3d()->insertSyncPoint(); |
| 583 |
| 584 output_surface_->context3d()->loseContextCHROMIUM( |
| 585 GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB); |
| 586 |
| 587 SyncPointHelper::SignalSyncPoint( |
| 588 output_surface_->context3d(), |
| 589 sync_point, |
| 590 base::Bind(&SyncPointCallback, &sync_point_callback_count)); |
| 591 EXPECT_EQ(0, sync_point_callback_count); |
| 592 EXPECT_EQ(0, other_callback_count); |
| 593 |
| 594 // Make the sync point happen. |
| 595 output_surface_->context3d()->finish(); |
| 596 // Post a task after the sync point. |
| 597 base::MessageLoop::current()->PostTask( |
| 598 FROM_HERE, |
| 599 base::Bind(&OtherCallback, &other_callback_count)); |
| 600 |
| 601 base::MessageLoop::current()->Run(); |
| 602 |
| 603 // The sync point shouldn't have happened since the context was lost. |
| 604 EXPECT_EQ(0, sync_point_callback_count); |
| 605 EXPECT_EQ(1, other_callback_count); |
| 606 } |
| 607 |
| 608 TEST_F(GLRendererPixelTest, SignalSyncPoint) { |
| 609 int sync_point_callback_count = 0; |
| 610 int other_callback_count = 0; |
| 611 unsigned sync_point = output_surface_->context3d()->insertSyncPoint(); |
| 612 |
| 613 SyncPointHelper::SignalSyncPoint( |
| 614 output_surface_->context3d(), |
| 615 sync_point, |
| 616 base::Bind(&SyncPointCallback, &sync_point_callback_count)); |
| 617 EXPECT_EQ(0, sync_point_callback_count); |
| 618 EXPECT_EQ(0, other_callback_count); |
| 619 |
| 620 // Make the sync point happen. |
| 621 output_surface_->context3d()->finish(); |
| 622 // Post a task after the sync point. |
| 623 base::MessageLoop::current()->PostTask( |
| 624 FROM_HERE, |
| 625 base::Bind(&OtherCallback, &other_callback_count)); |
| 626 |
| 627 base::MessageLoop::current()->Run(); |
| 628 |
| 629 // The sync point should have happened. |
| 630 EXPECT_EQ(1, sync_point_callback_count); |
| 631 EXPECT_EQ(1, other_callback_count); |
| 632 } |
566 #endif | 633 #endif |
567 | 634 |
568 } // namespace | 635 } // namespace |
569 } // namespace cc | 636 } // namespace cc |
OLD | NEW |