| 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 "base/message_loop.h" | 5 #include "base/message_loop.h" |
| 6 #include "cc/layers/append_quads_data.h" | 6 #include "cc/layers/append_quads_data.h" |
| 7 #include "cc/output/gl_renderer.h" | 7 #include "cc/output/gl_renderer.h" |
| 8 #include "cc/quads/draw_quad.h" | 8 #include "cc/quads/draw_quad.h" |
| 9 #include "cc/quads/picture_draw_quad.h" | 9 #include "cc/quads/picture_draw_quad.h" |
| 10 #include "cc/resources/platform_color.h" | 10 #include "cc/resources/platform_color.h" |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 | 546 |
| 547 this->SetUpRenderPassList(); | 547 this->SetUpRenderPassList(); |
| 548 EXPECT_TRUE(this->RunPixelTest( | 548 EXPECT_TRUE(this->RunPixelTest( |
| 549 &this->pass_list_, | 549 &this->pass_list_, |
| 550 base::FilePath(FILE_PATH_LITERAL("background_filter.png")), | 550 base::FilePath(FILE_PATH_LITERAL("background_filter.png")), |
| 551 ExactPixelComparator(true))); | 551 ExactPixelComparator(true))); |
| 552 } | 552 } |
| 553 | 553 |
| 554 // Software renderer does not support anti-aliased edges. | 554 // Software renderer does not support anti-aliased edges. |
| 555 TEST_F(GLRendererPixelTest, AntiAliasing) { | 555 TEST_F(GLRendererPixelTest, AntiAliasing) { |
| 556 gfx::Rect rect(0, 0, 200, 200); | 556 gfx::Rect rect(this->device_viewport_size_); |
| 557 | 557 |
| 558 RenderPass::Id id(1, 1); | 558 RenderPass::Id id(1, 1); |
| 559 scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); | 559 scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); |
| 560 | 560 |
| 561 gfx::Transform red_content_to_target_transform; | 561 gfx::Transform red_content_to_target_transform; |
| 562 red_content_to_target_transform.Rotate(10); | 562 red_content_to_target_transform.Rotate(10); |
| 563 scoped_ptr<SharedQuadState> red_shared_state = | 563 scoped_ptr<SharedQuadState> red_shared_state = |
| 564 CreateTestSharedQuadState(red_content_to_target_transform, rect); | 564 CreateTestSharedQuadState(red_content_to_target_transform, rect); |
| 565 | 565 |
| 566 scoped_ptr<SolidColorDrawQuad> red = SolidColorDrawQuad::Create(); | 566 scoped_ptr<SolidColorDrawQuad> red = SolidColorDrawQuad::Create(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 592 | 592 |
| 593 EXPECT_TRUE(this->RunPixelTest( | 593 EXPECT_TRUE(this->RunPixelTest( |
| 594 &pass_list, | 594 &pass_list, |
| 595 base::FilePath(FILE_PATH_LITERAL("anti_aliasing.png")), | 595 base::FilePath(FILE_PATH_LITERAL("anti_aliasing.png")), |
| 596 ExactPixelComparator(true))); | 596 ExactPixelComparator(true))); |
| 597 } | 597 } |
| 598 | 598 |
| 599 // This test tests that anti-aliasing works for axis aligned quads. | 599 // This test tests that anti-aliasing works for axis aligned quads. |
| 600 // Anti-aliasing is only supported in the gl renderer. | 600 // Anti-aliasing is only supported in the gl renderer. |
| 601 TEST_F(GLRendererPixelTest, AxisAligned) { | 601 TEST_F(GLRendererPixelTest, AxisAligned) { |
| 602 gfx::Rect rect(0, 0, 200, 200); | 602 gfx::Rect rect(this->device_viewport_size_); |
| 603 | 603 |
| 604 RenderPass::Id id(1, 1); | 604 RenderPass::Id id(1, 1); |
| 605 gfx::Transform transform_to_root; | 605 gfx::Transform transform_to_root; |
| 606 scoped_ptr<RenderPass> pass = | 606 scoped_ptr<RenderPass> pass = |
| 607 CreateTestRenderPass(id, rect, transform_to_root); | 607 CreateTestRenderPass(id, rect, transform_to_root); |
| 608 | 608 |
| 609 gfx::Transform red_content_to_target_transform; | 609 gfx::Transform red_content_to_target_transform; |
| 610 red_content_to_target_transform.Translate(50, 50); | 610 red_content_to_target_transform.Translate(50, 50); |
| 611 red_content_to_target_transform.Scale( | 611 red_content_to_target_transform.Scale( |
| 612 0.5f + 1.0f / (rect.width() * 2.0f), | 612 0.5f + 1.0f / (rect.width() * 2.0f), |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 | 644 |
| 645 EXPECT_TRUE(this->RunPixelTest( | 645 EXPECT_TRUE(this->RunPixelTest( |
| 646 &pass_list, | 646 &pass_list, |
| 647 base::FilePath(FILE_PATH_LITERAL("axis_aligned.png")), | 647 base::FilePath(FILE_PATH_LITERAL("axis_aligned.png")), |
| 648 ExactPixelComparator(true))); | 648 ExactPixelComparator(true))); |
| 649 } | 649 } |
| 650 | 650 |
| 651 // This test tests that forcing anti-aliasing off works as expected. | 651 // This test tests that forcing anti-aliasing off works as expected. |
| 652 // Anti-aliasing is only supported in the gl renderer. | 652 // Anti-aliasing is only supported in the gl renderer. |
| 653 TEST_F(GLRendererPixelTest, ForceAntiAliasingOff) { | 653 TEST_F(GLRendererPixelTest, ForceAntiAliasingOff) { |
| 654 gfx::Rect rect(0, 0, 200, 200); | 654 gfx::Rect rect(this->device_viewport_size_); |
| 655 | 655 |
| 656 RenderPass::Id id(1, 1); | 656 RenderPass::Id id(1, 1); |
| 657 gfx::Transform transform_to_root; | 657 gfx::Transform transform_to_root; |
| 658 scoped_ptr<RenderPass> pass = | 658 scoped_ptr<RenderPass> pass = |
| 659 CreateTestRenderPass(id, rect, transform_to_root); | 659 CreateTestRenderPass(id, rect, transform_to_root); |
| 660 | 660 |
| 661 gfx::Transform hole_content_to_target_transform; | 661 gfx::Transform hole_content_to_target_transform; |
| 662 hole_content_to_target_transform.Translate(50, 50); | 662 hole_content_to_target_transform.Translate(50, 50); |
| 663 hole_content_to_target_transform.Scale( | 663 hole_content_to_target_transform.Scale( |
| 664 0.5f + 1.0f / (rect.width() * 2.0f), | 664 0.5f + 1.0f / (rect.width() * 2.0f), |
| (...skipping 17 matching lines...) Expand all Loading... |
| 682 | 682 |
| 683 RenderPassList pass_list; | 683 RenderPassList pass_list; |
| 684 pass_list.push_back(pass.Pass()); | 684 pass_list.push_back(pass.Pass()); |
| 685 | 685 |
| 686 EXPECT_TRUE(this->RunPixelTest( | 686 EXPECT_TRUE(this->RunPixelTest( |
| 687 &pass_list, | 687 &pass_list, |
| 688 base::FilePath(FILE_PATH_LITERAL("force_anti_aliasing_off.png")), | 688 base::FilePath(FILE_PATH_LITERAL("force_anti_aliasing_off.png")), |
| 689 ExactPixelComparator(false))); | 689 ExactPixelComparator(false))); |
| 690 } | 690 } |
| 691 | 691 |
| 692 static void SyncPointCallback(int* callback_count) { | |
| 693 ++(*callback_count); | |
| 694 base::MessageLoop::current()->QuitWhenIdle(); | |
| 695 } | |
| 696 | |
| 697 static void OtherCallback(int* callback_count) { | |
| 698 ++(*callback_count); | |
| 699 base::MessageLoop::current()->QuitWhenIdle(); | |
| 700 } | |
| 701 | |
| 702 TEST_F(GLRendererPixelTest, SignalSyncPointOnLostContext) { | |
| 703 int sync_point_callback_count = 0; | |
| 704 int other_callback_count = 0; | |
| 705 unsigned sync_point = output_surface_->context3d()->insertSyncPoint(); | |
| 706 | |
| 707 output_surface_->context3d()->loseContextCHROMIUM( | |
| 708 GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB); | |
| 709 | |
| 710 SyncPointHelper::SignalSyncPoint( | |
| 711 output_surface_->context3d(), | |
| 712 sync_point, | |
| 713 base::Bind(&SyncPointCallback, &sync_point_callback_count)); | |
| 714 EXPECT_EQ(0, sync_point_callback_count); | |
| 715 EXPECT_EQ(0, other_callback_count); | |
| 716 | |
| 717 // Make the sync point happen. | |
| 718 output_surface_->context3d()->finish(); | |
| 719 // Post a task after the sync point. | |
| 720 base::MessageLoop::current()->PostTask( | |
| 721 FROM_HERE, | |
| 722 base::Bind(&OtherCallback, &other_callback_count)); | |
| 723 | |
| 724 base::MessageLoop::current()->Run(); | |
| 725 | |
| 726 // The sync point shouldn't have happened since the context was lost. | |
| 727 EXPECT_EQ(0, sync_point_callback_count); | |
| 728 EXPECT_EQ(1, other_callback_count); | |
| 729 } | |
| 730 | |
| 731 TEST_F(GLRendererPixelTest, SignalSyncPoint) { | |
| 732 int sync_point_callback_count = 0; | |
| 733 int other_callback_count = 0; | |
| 734 unsigned sync_point = output_surface_->context3d()->insertSyncPoint(); | |
| 735 | |
| 736 SyncPointHelper::SignalSyncPoint( | |
| 737 output_surface_->context3d(), | |
| 738 sync_point, | |
| 739 base::Bind(&SyncPointCallback, &sync_point_callback_count)); | |
| 740 EXPECT_EQ(0, sync_point_callback_count); | |
| 741 EXPECT_EQ(0, other_callback_count); | |
| 742 | |
| 743 // Make the sync point happen. | |
| 744 output_surface_->context3d()->finish(); | |
| 745 // Post a task after the sync point. | |
| 746 base::MessageLoop::current()->PostTask( | |
| 747 FROM_HERE, | |
| 748 base::Bind(&OtherCallback, &other_callback_count)); | |
| 749 | |
| 750 base::MessageLoop::current()->Run(); | |
| 751 | |
| 752 // The sync point should have happened. | |
| 753 EXPECT_EQ(1, sync_point_callback_count); | |
| 754 EXPECT_EQ(1, other_callback_count); | |
| 755 } | |
| 756 | |
| 757 TEST_F(GLRendererPixelTest, PictureDrawQuadIdentityScale) { | 692 TEST_F(GLRendererPixelTest, PictureDrawQuadIdentityScale) { |
| 758 gfx::Size pile_tile_size(1000, 1000); | 693 gfx::Size pile_tile_size(1000, 1000); |
| 759 gfx::Rect viewport(this->device_viewport_size_); | 694 gfx::Rect viewport(this->device_viewport_size_); |
| 760 // TODO(enne): the renderer should figure this out on its own. | 695 // TODO(enne): the renderer should figure this out on its own. |
| 761 bool contents_swizzled = !PlatformColor::SameComponentOrder(GL_RGBA); | 696 bool contents_swizzled = !PlatformColor::SameComponentOrder(GL_RGBA); |
| 762 | 697 |
| 763 RenderPass::Id id(1, 1); | 698 RenderPass::Id id(1, 1); |
| 764 gfx::Transform transform_to_root; | 699 gfx::Transform transform_to_root; |
| 765 scoped_ptr<RenderPass> pass = | 700 scoped_ptr<RenderPass> pass = |
| 766 CreateTestRenderPass(id, viewport, transform_to_root); | 701 CreateTestRenderPass(id, viewport, transform_to_root); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 830 pass_list.push_back(pass.Pass()); | 765 pass_list.push_back(pass.Pass()); |
| 831 | 766 |
| 832 EXPECT_TRUE(this->RunPixelTest( | 767 EXPECT_TRUE(this->RunPixelTest( |
| 833 &pass_list, | 768 &pass_list, |
| 834 base::FilePath(FILE_PATH_LITERAL("green_with_blue_corner.png")), | 769 base::FilePath(FILE_PATH_LITERAL("green_with_blue_corner.png")), |
| 835 ExactPixelComparator(true))); | 770 ExactPixelComparator(true))); |
| 836 } | 771 } |
| 837 | 772 |
| 838 TEST_F(GLRendererPixelTest, PictureDrawQuadNonIdentityScale) { | 773 TEST_F(GLRendererPixelTest, PictureDrawQuadNonIdentityScale) { |
| 839 gfx::Size pile_tile_size(1000, 1000); | 774 gfx::Size pile_tile_size(1000, 1000); |
| 840 gfx::Rect viewport(gfx::Size(200, 200)); | 775 gfx::Rect viewport(this->device_viewport_size_); |
| 841 // TODO(enne): the renderer should figure this out on its own. | 776 // TODO(enne): the renderer should figure this out on its own. |
| 842 bool contents_swizzled = !PlatformColor::SameComponentOrder(GL_RGBA); | 777 bool contents_swizzled = !PlatformColor::SameComponentOrder(GL_RGBA); |
| 843 | 778 |
| 844 RenderPass::Id id(1, 1); | 779 RenderPass::Id id(1, 1); |
| 845 gfx::Transform transform_to_root; | 780 gfx::Transform transform_to_root; |
| 846 scoped_ptr<RenderPass> pass = | 781 scoped_ptr<RenderPass> pass = |
| 847 CreateTestRenderPass(id, viewport, transform_to_root); | 782 CreateTestRenderPass(id, viewport, transform_to_root); |
| 848 | 783 |
| 849 // As scaling up the blue checkerboards will cause sampling on the GPU, | 784 // As scaling up the blue checkerboards will cause sampling on the GPU, |
| 850 // a few extra "cleanup rects" need to be added to clobber the blending | 785 // a few extra "cleanup rects" need to be added to clobber the blending |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 971 pass->quad_list.push_back(half_color_quad.PassAs<DrawQuad>()); | 906 pass->quad_list.push_back(half_color_quad.PassAs<DrawQuad>()); |
| 972 | 907 |
| 973 RenderPassList pass_list; | 908 RenderPassList pass_list; |
| 974 pass_list.push_back(pass.Pass()); | 909 pass_list.push_back(pass.Pass()); |
| 975 | 910 |
| 976 EXPECT_TRUE(this->RunPixelTest( | 911 EXPECT_TRUE(this->RunPixelTest( |
| 977 &pass_list, | 912 &pass_list, |
| 978 base::FilePath(FILE_PATH_LITERAL("four_blue_green_checkers.png")), | 913 base::FilePath(FILE_PATH_LITERAL("four_blue_green_checkers.png")), |
| 979 ExactPixelComparator(true))); | 914 ExactPixelComparator(true))); |
| 980 } | 915 } |
| 981 | |
| 982 #endif // !defined(OS_ANDROID) | 916 #endif // !defined(OS_ANDROID) |
| 983 | 917 |
| 984 } // namespace | 918 } // namespace |
| 985 } // namespace cc | 919 } // namespace cc |
| OLD | NEW |