| 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 return fuzzy_.Compare(actual_bmp, expected_bmp); | 132 return fuzzy_.Compare(actual_bmp, expected_bmp); |
| 133 } | 133 } |
| 134 | 134 |
| 135 #if !defined(OS_ANDROID) | 135 #if !defined(OS_ANDROID) |
| 136 TYPED_TEST(RendererPixelTest, SimpleGreenRect) { | 136 TYPED_TEST(RendererPixelTest, SimpleGreenRect) { |
| 137 gfx::Rect rect(this->device_viewport_size_); | 137 gfx::Rect rect(this->device_viewport_size_); |
| 138 | 138 |
| 139 RenderPass::Id id(1, 1); | 139 RenderPass::Id id(1, 1); |
| 140 scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); | 140 scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); |
| 141 | 141 |
| 142 gfx::Transform content_to_target_transform; | |
| 143 scoped_ptr<SharedQuadState> shared_state = | 142 scoped_ptr<SharedQuadState> shared_state = |
| 144 CreateTestSharedQuadState(content_to_target_transform, rect); | 143 CreateTestSharedQuadState(gfx::Transform(), rect); |
| 145 | 144 |
| 146 scoped_ptr<SolidColorDrawQuad> color_quad = SolidColorDrawQuad::Create(); | 145 scoped_ptr<SolidColorDrawQuad> color_quad = SolidColorDrawQuad::Create(); |
| 147 color_quad->SetNew(shared_state.get(), rect, SK_ColorGREEN, false); | 146 color_quad->SetNew(shared_state.get(), rect, SK_ColorGREEN, false); |
| 148 | 147 |
| 149 pass->quad_list.push_back(color_quad.PassAs<DrawQuad>()); | 148 pass->quad_list.push_back(color_quad.PassAs<DrawQuad>()); |
| 150 | 149 |
| 151 RenderPassList pass_list; | 150 RenderPassList pass_list; |
| 152 pass_list.push_back(pass.Pass()); | 151 pass_list.push_back(pass.Pass()); |
| 153 | 152 |
| 154 EXPECT_TRUE(this->RunPixelTest( | 153 EXPECT_TRUE(this->RunPixelTest( |
| 155 &pass_list, | 154 &pass_list, |
| 156 base::FilePath(FILE_PATH_LITERAL("green.png")), | 155 base::FilePath(FILE_PATH_LITERAL("green.png")), |
| 157 ExactPixelComparator(true))); | 156 ExactPixelComparator(true))); |
| 158 } | 157 } |
| 159 | 158 |
| 159 TYPED_TEST(RendererPixelTest, SimpleGreenRect_NonRootRenderPass) { |
| 160 gfx::Rect rect(this->device_viewport_size_); |
| 161 gfx::Rect small_rect(100, 100); |
| 162 |
| 163 RenderPass::Id child_id(2, 1); |
| 164 scoped_ptr<RenderPass> child_pass = |
| 165 CreateTestRenderPass(child_id, small_rect, gfx::Transform()); |
| 166 |
| 167 scoped_ptr<SharedQuadState> child_shared_state = |
| 168 CreateTestSharedQuadState(gfx::Transform(), small_rect); |
| 169 |
| 170 scoped_ptr<SolidColorDrawQuad> color_quad = SolidColorDrawQuad::Create(); |
| 171 color_quad->SetNew(child_shared_state.get(), rect, SK_ColorGREEN, false); |
| 172 child_pass->quad_list.push_back(color_quad.PassAs<DrawQuad>()); |
| 173 |
| 174 RenderPass::Id root_id(1, 1); |
| 175 scoped_ptr<RenderPass> root_pass = |
| 176 CreateTestRenderPass(root_id, rect, gfx::Transform()); |
| 177 |
| 178 scoped_ptr<SharedQuadState> root_shared_state = |
| 179 CreateTestSharedQuadState(gfx::Transform(), rect); |
| 180 |
| 181 scoped_ptr<DrawQuad> render_pass_quad = |
| 182 CreateTestRenderPassDrawQuad(root_shared_state.get(), |
| 183 small_rect, |
| 184 child_id); |
| 185 root_pass->quad_list.push_back(render_pass_quad.PassAs<DrawQuad>()); |
| 186 |
| 187 RenderPass* child_pass_ptr = child_pass.get(); |
| 188 |
| 189 RenderPassList pass_list; |
| 190 pass_list.push_back(child_pass.Pass()); |
| 191 pass_list.push_back(root_pass.Pass()); |
| 192 |
| 193 EXPECT_TRUE(this->RunPixelTestWithReadbackTarget( |
| 194 &pass_list, |
| 195 child_pass_ptr, |
| 196 base::FilePath(FILE_PATH_LITERAL("green_small.png")), |
| 197 ExactPixelComparator(true))); |
| 198 } |
| 199 |
| 160 TYPED_TEST(RendererPixelTest, FastPassColorFilterAlpha) { | 200 TYPED_TEST(RendererPixelTest, FastPassColorFilterAlpha) { |
| 161 gfx::Rect viewport_rect(this->device_viewport_size_); | 201 gfx::Rect viewport_rect(this->device_viewport_size_); |
| 162 | 202 |
| 163 RenderPass::Id root_pass_id(1, 1); | 203 RenderPass::Id root_pass_id(1, 1); |
| 164 scoped_ptr<RenderPass> root_pass = | 204 scoped_ptr<RenderPass> root_pass = |
| 165 CreateTestRootRenderPass(root_pass_id, viewport_rect); | 205 CreateTestRootRenderPass(root_pass_id, viewport_rect); |
| 166 | 206 |
| 167 RenderPass::Id child_pass_id(2, 2); | 207 RenderPass::Id child_pass_id(2, 2); |
| 168 gfx::Rect pass_rect(this->device_viewport_size_); | 208 gfx::Rect pass_rect(this->device_viewport_size_); |
| 169 gfx::Transform transform_to_root; | 209 gfx::Transform transform_to_root; |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 | 586 |
| 547 this->SetUpRenderPassList(); | 587 this->SetUpRenderPassList(); |
| 548 EXPECT_TRUE(this->RunPixelTest( | 588 EXPECT_TRUE(this->RunPixelTest( |
| 549 &this->pass_list_, | 589 &this->pass_list_, |
| 550 base::FilePath(FILE_PATH_LITERAL("background_filter.png")), | 590 base::FilePath(FILE_PATH_LITERAL("background_filter.png")), |
| 551 ExactPixelComparator(true))); | 591 ExactPixelComparator(true))); |
| 552 } | 592 } |
| 553 | 593 |
| 554 // Software renderer does not support anti-aliased edges. | 594 // Software renderer does not support anti-aliased edges. |
| 555 TEST_F(GLRendererPixelTest, AntiAliasing) { | 595 TEST_F(GLRendererPixelTest, AntiAliasing) { |
| 556 gfx::Rect rect(0, 0, 200, 200); | 596 gfx::Rect rect(this->device_viewport_size_); |
| 557 | 597 |
| 558 RenderPass::Id id(1, 1); | 598 RenderPass::Id id(1, 1); |
| 559 scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); | 599 scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); |
| 560 | 600 |
| 561 gfx::Transform red_content_to_target_transform; | 601 gfx::Transform red_content_to_target_transform; |
| 562 red_content_to_target_transform.Rotate(10); | 602 red_content_to_target_transform.Rotate(10); |
| 563 scoped_ptr<SharedQuadState> red_shared_state = | 603 scoped_ptr<SharedQuadState> red_shared_state = |
| 564 CreateTestSharedQuadState(red_content_to_target_transform, rect); | 604 CreateTestSharedQuadState(red_content_to_target_transform, rect); |
| 565 | 605 |
| 566 scoped_ptr<SolidColorDrawQuad> red = SolidColorDrawQuad::Create(); | 606 scoped_ptr<SolidColorDrawQuad> red = SolidColorDrawQuad::Create(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 592 | 632 |
| 593 EXPECT_TRUE(this->RunPixelTest( | 633 EXPECT_TRUE(this->RunPixelTest( |
| 594 &pass_list, | 634 &pass_list, |
| 595 base::FilePath(FILE_PATH_LITERAL("anti_aliasing.png")), | 635 base::FilePath(FILE_PATH_LITERAL("anti_aliasing.png")), |
| 596 ExactPixelComparator(true))); | 636 ExactPixelComparator(true))); |
| 597 } | 637 } |
| 598 | 638 |
| 599 // This test tests that anti-aliasing works for axis aligned quads. | 639 // This test tests that anti-aliasing works for axis aligned quads. |
| 600 // Anti-aliasing is only supported in the gl renderer. | 640 // Anti-aliasing is only supported in the gl renderer. |
| 601 TEST_F(GLRendererPixelTest, AxisAligned) { | 641 TEST_F(GLRendererPixelTest, AxisAligned) { |
| 602 gfx::Rect rect(0, 0, 200, 200); | 642 gfx::Rect rect(this->device_viewport_size_); |
| 603 | 643 |
| 604 RenderPass::Id id(1, 1); | 644 RenderPass::Id id(1, 1); |
| 605 gfx::Transform transform_to_root; | 645 gfx::Transform transform_to_root; |
| 606 scoped_ptr<RenderPass> pass = | 646 scoped_ptr<RenderPass> pass = |
| 607 CreateTestRenderPass(id, rect, transform_to_root); | 647 CreateTestRenderPass(id, rect, transform_to_root); |
| 608 | 648 |
| 609 gfx::Transform red_content_to_target_transform; | 649 gfx::Transform red_content_to_target_transform; |
| 610 red_content_to_target_transform.Translate(50, 50); | 650 red_content_to_target_transform.Translate(50, 50); |
| 611 red_content_to_target_transform.Scale( | 651 red_content_to_target_transform.Scale( |
| 612 0.5f + 1.0f / (rect.width() * 2.0f), | 652 0.5f + 1.0f / (rect.width() * 2.0f), |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 | 684 |
| 645 EXPECT_TRUE(this->RunPixelTest( | 685 EXPECT_TRUE(this->RunPixelTest( |
| 646 &pass_list, | 686 &pass_list, |
| 647 base::FilePath(FILE_PATH_LITERAL("axis_aligned.png")), | 687 base::FilePath(FILE_PATH_LITERAL("axis_aligned.png")), |
| 648 ExactPixelComparator(true))); | 688 ExactPixelComparator(true))); |
| 649 } | 689 } |
| 650 | 690 |
| 651 // This test tests that forcing anti-aliasing off works as expected. | 691 // This test tests that forcing anti-aliasing off works as expected. |
| 652 // Anti-aliasing is only supported in the gl renderer. | 692 // Anti-aliasing is only supported in the gl renderer. |
| 653 TEST_F(GLRendererPixelTest, ForceAntiAliasingOff) { | 693 TEST_F(GLRendererPixelTest, ForceAntiAliasingOff) { |
| 654 gfx::Rect rect(0, 0, 200, 200); | 694 gfx::Rect rect(this->device_viewport_size_); |
| 655 | 695 |
| 656 RenderPass::Id id(1, 1); | 696 RenderPass::Id id(1, 1); |
| 657 gfx::Transform transform_to_root; | 697 gfx::Transform transform_to_root; |
| 658 scoped_ptr<RenderPass> pass = | 698 scoped_ptr<RenderPass> pass = |
| 659 CreateTestRenderPass(id, rect, transform_to_root); | 699 CreateTestRenderPass(id, rect, transform_to_root); |
| 660 | 700 |
| 661 gfx::Transform hole_content_to_target_transform; | 701 gfx::Transform hole_content_to_target_transform; |
| 662 hole_content_to_target_transform.Translate(50, 50); | 702 hole_content_to_target_transform.Translate(50, 50); |
| 663 hole_content_to_target_transform.Scale( | 703 hole_content_to_target_transform.Scale( |
| 664 0.5f + 1.0f / (rect.width() * 2.0f), | 704 0.5f + 1.0f / (rect.width() * 2.0f), |
| (...skipping 17 matching lines...) Expand all Loading... |
| 682 | 722 |
| 683 RenderPassList pass_list; | 723 RenderPassList pass_list; |
| 684 pass_list.push_back(pass.Pass()); | 724 pass_list.push_back(pass.Pass()); |
| 685 | 725 |
| 686 EXPECT_TRUE(this->RunPixelTest( | 726 EXPECT_TRUE(this->RunPixelTest( |
| 687 &pass_list, | 727 &pass_list, |
| 688 base::FilePath(FILE_PATH_LITERAL("force_anti_aliasing_off.png")), | 728 base::FilePath(FILE_PATH_LITERAL("force_anti_aliasing_off.png")), |
| 689 ExactPixelComparator(false))); | 729 ExactPixelComparator(false))); |
| 690 } | 730 } |
| 691 | 731 |
| 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) { | 732 TEST_F(GLRendererPixelTest, PictureDrawQuadIdentityScale) { |
| 758 gfx::Size pile_tile_size(1000, 1000); | 733 gfx::Size pile_tile_size(1000, 1000); |
| 759 gfx::Rect viewport(this->device_viewport_size_); | 734 gfx::Rect viewport(this->device_viewport_size_); |
| 760 // TODO(enne): the renderer should figure this out on its own. | 735 // TODO(enne): the renderer should figure this out on its own. |
| 761 bool contents_swizzled = !PlatformColor::SameComponentOrder(GL_RGBA); | 736 bool contents_swizzled = !PlatformColor::SameComponentOrder(GL_RGBA); |
| 762 | 737 |
| 763 RenderPass::Id id(1, 1); | 738 RenderPass::Id id(1, 1); |
| 764 gfx::Transform transform_to_root; | 739 gfx::Transform transform_to_root; |
| 765 scoped_ptr<RenderPass> pass = | 740 scoped_ptr<RenderPass> pass = |
| 766 CreateTestRenderPass(id, viewport, transform_to_root); | 741 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()); | 805 pass_list.push_back(pass.Pass()); |
| 831 | 806 |
| 832 EXPECT_TRUE(this->RunPixelTest( | 807 EXPECT_TRUE(this->RunPixelTest( |
| 833 &pass_list, | 808 &pass_list, |
| 834 base::FilePath(FILE_PATH_LITERAL("green_with_blue_corner.png")), | 809 base::FilePath(FILE_PATH_LITERAL("green_with_blue_corner.png")), |
| 835 ExactPixelComparator(true))); | 810 ExactPixelComparator(true))); |
| 836 } | 811 } |
| 837 | 812 |
| 838 TEST_F(GLRendererPixelTest, PictureDrawQuadNonIdentityScale) { | 813 TEST_F(GLRendererPixelTest, PictureDrawQuadNonIdentityScale) { |
| 839 gfx::Size pile_tile_size(1000, 1000); | 814 gfx::Size pile_tile_size(1000, 1000); |
| 840 gfx::Rect viewport(gfx::Size(200, 200)); | 815 gfx::Rect viewport(this->device_viewport_size_); |
| 841 // TODO(enne): the renderer should figure this out on its own. | 816 // TODO(enne): the renderer should figure this out on its own. |
| 842 bool contents_swizzled = !PlatformColor::SameComponentOrder(GL_RGBA); | 817 bool contents_swizzled = !PlatformColor::SameComponentOrder(GL_RGBA); |
| 843 | 818 |
| 844 RenderPass::Id id(1, 1); | 819 RenderPass::Id id(1, 1); |
| 845 gfx::Transform transform_to_root; | 820 gfx::Transform transform_to_root; |
| 846 scoped_ptr<RenderPass> pass = | 821 scoped_ptr<RenderPass> pass = |
| 847 CreateTestRenderPass(id, viewport, transform_to_root); | 822 CreateTestRenderPass(id, viewport, transform_to_root); |
| 848 | 823 |
| 849 // As scaling up the blue checkerboards will cause sampling on the GPU, | 824 // 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 | 825 // 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>()); | 946 pass->quad_list.push_back(half_color_quad.PassAs<DrawQuad>()); |
| 972 | 947 |
| 973 RenderPassList pass_list; | 948 RenderPassList pass_list; |
| 974 pass_list.push_back(pass.Pass()); | 949 pass_list.push_back(pass.Pass()); |
| 975 | 950 |
| 976 EXPECT_TRUE(this->RunPixelTest( | 951 EXPECT_TRUE(this->RunPixelTest( |
| 977 &pass_list, | 952 &pass_list, |
| 978 base::FilePath(FILE_PATH_LITERAL("four_blue_green_checkers.png")), | 953 base::FilePath(FILE_PATH_LITERAL("four_blue_green_checkers.png")), |
| 979 ExactPixelComparator(true))); | 954 ExactPixelComparator(true))); |
| 980 } | 955 } |
| 981 | |
| 982 #endif // !defined(OS_ANDROID) | 956 #endif // !defined(OS_ANDROID) |
| 983 | 957 |
| 984 } // namespace | 958 } // namespace |
| 985 } // namespace cc | 959 } // namespace cc |
| OLD | NEW |