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 <set> | 7 #include <set> |
8 | 8 |
9 #include "cc/base/math_util.h" | 9 #include "cc/base/math_util.h" |
10 #include "cc/output/compositor_frame_metadata.h" | 10 #include "cc/output/compositor_frame_metadata.h" |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 // Begin drawing a frame while a framebuffer is discarded. | 307 // Begin drawing a frame while a framebuffer is discarded. |
308 // Expected: will recreate framebuffer. | 308 // Expected: will recreate framebuffer. |
309 TEST_F(GLRendererWithDefaultHarnessTest, | 309 TEST_F(GLRendererWithDefaultHarnessTest, |
310 DiscardedBackbufferIsRecreatedForScopeDuration) { | 310 DiscardedBackbufferIsRecreatedForScopeDuration) { |
311 gfx::Rect viewport_rect(1, 1); | 311 gfx::Rect viewport_rect(1, 1); |
312 renderer_->SetVisible(false); | 312 renderer_->SetVisible(false); |
313 EXPECT_TRUE(renderer_->IsBackbufferDiscarded()); | 313 EXPECT_TRUE(renderer_->IsBackbufferDiscarded()); |
314 EXPECT_EQ(1, renderer_client_.set_full_root_layer_damage_count()); | 314 EXPECT_EQ(1, renderer_client_.set_full_root_layer_damage_count()); |
315 | 315 |
316 AddRenderPass(&render_passes_in_draw_order_, | 316 AddRenderPass(&render_passes_in_draw_order_, |
317 RenderPass::Id(1, 0), | 317 RenderPassId(1, 0), |
318 viewport_rect, | 318 viewport_rect, |
319 gfx::Transform()); | 319 gfx::Transform()); |
320 | 320 |
321 renderer_->SetVisible(true); | 321 renderer_->SetVisible(true); |
322 renderer_->DrawFrame(&render_passes_in_draw_order_, | 322 renderer_->DrawFrame(&render_passes_in_draw_order_, |
323 1.f, | 323 1.f, |
324 viewport_rect, | 324 viewport_rect, |
325 viewport_rect, | 325 viewport_rect, |
326 false); | 326 false); |
327 EXPECT_FALSE(renderer_->IsBackbufferDiscarded()); | 327 EXPECT_FALSE(renderer_->IsBackbufferDiscarded()); |
328 | 328 |
329 SwapBuffers(); | 329 SwapBuffers(); |
330 EXPECT_EQ(1u, output_surface_->num_sent_frames()); | 330 EXPECT_EQ(1u, output_surface_->num_sent_frames()); |
331 } | 331 } |
332 | 332 |
333 TEST_F(GLRendererWithDefaultHarnessTest, ExternalStencil) { | 333 TEST_F(GLRendererWithDefaultHarnessTest, ExternalStencil) { |
334 gfx::Rect viewport_rect(1, 1); | 334 gfx::Rect viewport_rect(1, 1); |
335 EXPECT_FALSE(renderer_->stencil_enabled()); | 335 EXPECT_FALSE(renderer_->stencil_enabled()); |
336 | 336 |
337 output_surface_->set_has_external_stencil_test(true); | 337 output_surface_->set_has_external_stencil_test(true); |
338 | 338 |
339 TestRenderPass* root_pass = AddRenderPass(&render_passes_in_draw_order_, | 339 TestRenderPass* root_pass = AddRenderPass(&render_passes_in_draw_order_, |
340 RenderPass::Id(1, 0), | 340 RenderPassId(1, 0), |
341 viewport_rect, | 341 viewport_rect, |
342 gfx::Transform()); | 342 gfx::Transform()); |
343 root_pass->has_transparent_background = false; | 343 root_pass->has_transparent_background = false; |
344 | 344 |
345 renderer_->DrawFrame(&render_passes_in_draw_order_, | 345 renderer_->DrawFrame(&render_passes_in_draw_order_, |
346 1.f, | 346 1.f, |
347 viewport_rect, | 347 viewport_rect, |
348 viewport_rect, | 348 viewport_rect, |
349 false); | 349 false); |
350 EXPECT_TRUE(renderer_->stencil_enabled()); | 350 EXPECT_TRUE(renderer_->stencil_enabled()); |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 | 549 |
550 LayerTreeSettings settings; | 550 LayerTreeSettings settings; |
551 FakeRendererClient renderer_client; | 551 FakeRendererClient renderer_client; |
552 FakeRendererGL renderer(&renderer_client, | 552 FakeRendererGL renderer(&renderer_client, |
553 &settings, | 553 &settings, |
554 output_surface.get(), | 554 output_surface.get(), |
555 resource_provider.get()); | 555 resource_provider.get()); |
556 | 556 |
557 gfx::Rect viewport_rect(1, 1); | 557 gfx::Rect viewport_rect(1, 1); |
558 TestRenderPass* root_pass = AddRenderPass(&render_passes_in_draw_order_, | 558 TestRenderPass* root_pass = AddRenderPass(&render_passes_in_draw_order_, |
559 RenderPass::Id(1, 0), | 559 RenderPassId(1, 0), |
560 viewport_rect, | 560 viewport_rect, |
561 gfx::Transform()); | 561 gfx::Transform()); |
562 root_pass->has_transparent_background = false; | 562 root_pass->has_transparent_background = false; |
563 | 563 |
564 // On DEBUG builds, render passes with opaque background clear to blue to | 564 // On DEBUG builds, render passes with opaque background clear to blue to |
565 // easily see regions that were not drawn on the screen. | 565 // easily see regions that were not drawn on the screen. |
566 EXPECT_CALL(*context, discardFramebufferEXT(GL_FRAMEBUFFER, _, _)) | 566 EXPECT_CALL(*context, discardFramebufferEXT(GL_FRAMEBUFFER, _, _)) |
567 .With(Args<2, 1>(ElementsAre(GL_COLOR_EXT))) | 567 .With(Args<2, 1>(ElementsAre(GL_COLOR_EXT))) |
568 .Times(1); | 568 .Times(1); |
569 #ifdef NDEBUG | 569 #ifdef NDEBUG |
(...skipping 25 matching lines...) Expand all Loading... |
595 | 595 |
596 LayerTreeSettings settings; | 596 LayerTreeSettings settings; |
597 FakeRendererClient renderer_client; | 597 FakeRendererClient renderer_client; |
598 FakeRendererGL renderer(&renderer_client, | 598 FakeRendererGL renderer(&renderer_client, |
599 &settings, | 599 &settings, |
600 output_surface.get(), | 600 output_surface.get(), |
601 resource_provider.get()); | 601 resource_provider.get()); |
602 | 602 |
603 gfx::Rect viewport_rect(1, 1); | 603 gfx::Rect viewport_rect(1, 1); |
604 TestRenderPass* root_pass = AddRenderPass(&render_passes_in_draw_order_, | 604 TestRenderPass* root_pass = AddRenderPass(&render_passes_in_draw_order_, |
605 RenderPass::Id(1, 0), | 605 RenderPassId(1, 0), |
606 viewport_rect, | 606 viewport_rect, |
607 gfx::Transform()); | 607 gfx::Transform()); |
608 root_pass->has_transparent_background = true; | 608 root_pass->has_transparent_background = true; |
609 | 609 |
610 EXPECT_CALL(*context, discardFramebufferEXT(GL_FRAMEBUFFER, 1, _)).Times(1); | 610 EXPECT_CALL(*context, discardFramebufferEXT(GL_FRAMEBUFFER, 1, _)).Times(1); |
611 EXPECT_CALL(*context, clear(_)).Times(1); | 611 EXPECT_CALL(*context, clear(_)).Times(1); |
612 renderer.DrawFrame(&render_passes_in_draw_order_, | 612 renderer.DrawFrame(&render_passes_in_draw_order_, |
613 1.f, | 613 1.f, |
614 viewport_rect, | 614 viewport_rect, |
615 viewport_rect, | 615 viewport_rect, |
(...skipping 18 matching lines...) Expand all Loading... |
634 | 634 |
635 LayerTreeSettings settings; | 635 LayerTreeSettings settings; |
636 FakeRendererClient renderer_client; | 636 FakeRendererClient renderer_client; |
637 FakeRendererGL renderer(&renderer_client, | 637 FakeRendererGL renderer(&renderer_client, |
638 &settings, | 638 &settings, |
639 output_surface.get(), | 639 output_surface.get(), |
640 resource_provider.get()); | 640 resource_provider.get()); |
641 | 641 |
642 gfx::Rect viewport_rect(1, 1); | 642 gfx::Rect viewport_rect(1, 1); |
643 AddRenderPass(&render_passes_in_draw_order_, | 643 AddRenderPass(&render_passes_in_draw_order_, |
644 RenderPass::Id(1, 0), | 644 RenderPassId(1, 0), |
645 viewport_rect, | 645 viewport_rect, |
646 gfx::Transform()); | 646 gfx::Transform()); |
647 | 647 |
648 EXPECT_CALL(*context, discardFramebufferEXT(GL_FRAMEBUFFER, _, _)) | 648 EXPECT_CALL(*context, discardFramebufferEXT(GL_FRAMEBUFFER, _, _)) |
649 .With(Args<2, 1>(ElementsAre(GL_COLOR_ATTACHMENT0))) | 649 .With(Args<2, 1>(ElementsAre(GL_COLOR_ATTACHMENT0))) |
650 .Times(1); | 650 .Times(1); |
651 EXPECT_CALL(*context, clear(_)).Times(AnyNumber()); | 651 EXPECT_CALL(*context, clear(_)).Times(AnyNumber()); |
652 renderer.DrawFrame(&render_passes_in_draw_order_, | 652 renderer.DrawFrame(&render_passes_in_draw_order_, |
653 1.f, | 653 1.f, |
654 viewport_rect, | 654 viewport_rect, |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 | 715 |
716 LayerTreeSettings settings; | 716 LayerTreeSettings settings; |
717 FakeRendererClient renderer_client; | 717 FakeRendererClient renderer_client; |
718 FakeRendererGL renderer(&renderer_client, | 718 FakeRendererGL renderer(&renderer_client, |
719 &settings, | 719 &settings, |
720 output_surface.get(), | 720 output_surface.get(), |
721 resource_provider.get()); | 721 resource_provider.get()); |
722 | 722 |
723 gfx::Rect viewport_rect(1, 1); | 723 gfx::Rect viewport_rect(1, 1); |
724 AddRenderPass(&render_passes_in_draw_order_, | 724 AddRenderPass(&render_passes_in_draw_order_, |
725 RenderPass::Id(1, 0), | 725 RenderPassId(1, 0), |
726 viewport_rect, | 726 viewport_rect, |
727 gfx::Transform()); | 727 gfx::Transform()); |
728 | 728 |
729 // Ensure that the call to SetSurfaceVisible is the last call issue to the | 729 // Ensure that the call to SetSurfaceVisible is the last call issue to the |
730 // GPU process, after glFlush is called, and after the RendererClient's | 730 // GPU process, after glFlush is called, and after the RendererClient's |
731 // SetManagedMemoryPolicy is called. Plumb this tracking between both the | 731 // SetManagedMemoryPolicy is called. Plumb this tracking between both the |
732 // RenderClient and the Context by giving them both a pointer to a variable on | 732 // RenderClient and the Context by giving them both a pointer to a variable on |
733 // the stack. | 733 // the stack. |
734 renderer.SetVisible(true); | 734 renderer.SetVisible(true); |
735 renderer.DrawFrame(&render_passes_in_draw_order_, | 735 renderer.DrawFrame(&render_passes_in_draw_order_, |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
781 LayerTreeSettings settings; | 781 LayerTreeSettings settings; |
782 FakeRendererClient renderer_client; | 782 FakeRendererClient renderer_client; |
783 FakeRendererGL renderer(&renderer_client, | 783 FakeRendererGL renderer(&renderer_client, |
784 &settings, | 784 &settings, |
785 output_surface.get(), | 785 output_surface.get(), |
786 resource_provider.get()); | 786 resource_provider.get()); |
787 | 787 |
788 // During initialization we are allowed to set any texture parameters. | 788 // During initialization we are allowed to set any texture parameters. |
789 EXPECT_CALL(*context, texParameteri(_, _, _)).Times(AnyNumber()); | 789 EXPECT_CALL(*context, texParameteri(_, _, _)).Times(AnyNumber()); |
790 | 790 |
791 RenderPass::Id id(1, 1); | 791 RenderPassId id(1, 1); |
792 TestRenderPass* root_pass = AddRenderPass( | 792 TestRenderPass* root_pass = AddRenderPass( |
793 &render_passes_in_draw_order_, id, gfx::Rect(100, 100), gfx::Transform()); | 793 &render_passes_in_draw_order_, id, gfx::Rect(100, 100), gfx::Transform()); |
794 root_pass->AppendOneOfEveryQuadType(resource_provider.get(), | 794 root_pass->AppendOneOfEveryQuadType(resource_provider.get(), |
795 RenderPass::Id(2, 1)); | 795 RenderPassId(2, 1)); |
796 | 796 |
797 renderer.DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); | 797 renderer.DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); |
798 | 798 |
799 // Set up expected texture filter state transitions that match the quads | 799 // Set up expected texture filter state transitions that match the quads |
800 // created in AppendOneOfEveryQuadType(). | 800 // created in AppendOneOfEveryQuadType(). |
801 Mock::VerifyAndClearExpectations(context); | 801 Mock::VerifyAndClearExpectations(context); |
802 { | 802 { |
803 InSequence sequence; | 803 InSequence sequence; |
804 | 804 |
805 // The sync points for all quads are waited on first. This sync point is | 805 // The sync points for all quads are waited on first. This sync point is |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 settings.should_clear_root_render_pass = false; | 867 settings.should_clear_root_render_pass = false; |
868 | 868 |
869 FakeRendererClient renderer_client; | 869 FakeRendererClient renderer_client; |
870 FakeRendererGL renderer(&renderer_client, | 870 FakeRendererGL renderer(&renderer_client, |
871 &settings, | 871 &settings, |
872 output_surface.get(), | 872 output_surface.get(), |
873 resource_provider.get()); | 873 resource_provider.get()); |
874 | 874 |
875 gfx::Rect viewport_rect(10, 10); | 875 gfx::Rect viewport_rect(10, 10); |
876 | 876 |
877 RenderPass::Id root_pass_id(1, 0); | 877 RenderPassId root_pass_id(1, 0); |
878 TestRenderPass* root_pass = AddRenderPass(&render_passes_in_draw_order_, | 878 TestRenderPass* root_pass = AddRenderPass(&render_passes_in_draw_order_, |
879 root_pass_id, | 879 root_pass_id, |
880 viewport_rect, | 880 viewport_rect, |
881 gfx::Transform()); | 881 gfx::Transform()); |
882 AddQuad(root_pass, viewport_rect, SK_ColorGREEN); | 882 AddQuad(root_pass, viewport_rect, SK_ColorGREEN); |
883 | 883 |
884 RenderPass::Id child_pass_id(2, 0); | 884 RenderPassId child_pass_id(2, 0); |
885 TestRenderPass* child_pass = AddRenderPass(&render_passes_in_draw_order_, | 885 TestRenderPass* child_pass = AddRenderPass(&render_passes_in_draw_order_, |
886 child_pass_id, | 886 child_pass_id, |
887 viewport_rect, | 887 viewport_rect, |
888 gfx::Transform()); | 888 gfx::Transform()); |
889 AddQuad(child_pass, viewport_rect, SK_ColorBLUE); | 889 AddQuad(child_pass, viewport_rect, SK_ColorBLUE); |
890 | 890 |
891 AddRenderPassQuad(root_pass, child_pass); | 891 AddRenderPassQuad(root_pass, child_pass); |
892 | 892 |
893 #ifdef NDEBUG | 893 #ifdef NDEBUG |
894 GLint clear_bits = GL_COLOR_BUFFER_BIT; | 894 GLint clear_bits = GL_COLOR_BUFFER_BIT; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
959 FakeRendererClient renderer_client; | 959 FakeRendererClient renderer_client; |
960 FakeRendererGL renderer(&renderer_client, | 960 FakeRendererGL renderer(&renderer_client, |
961 &settings, | 961 &settings, |
962 output_surface.get(), | 962 output_surface.get(), |
963 resource_provider.get()); | 963 resource_provider.get()); |
964 EXPECT_FALSE(renderer.Capabilities().using_partial_swap); | 964 EXPECT_FALSE(renderer.Capabilities().using_partial_swap); |
965 | 965 |
966 gfx::Rect viewport_rect(1, 1); | 966 gfx::Rect viewport_rect(1, 1); |
967 | 967 |
968 gfx::Rect grand_child_rect(25, 25); | 968 gfx::Rect grand_child_rect(25, 25); |
969 RenderPass::Id grand_child_pass_id(3, 0); | 969 RenderPassId grand_child_pass_id(3, 0); |
970 TestRenderPass* grand_child_pass = | 970 TestRenderPass* grand_child_pass = |
971 AddRenderPass(&render_passes_in_draw_order_, | 971 AddRenderPass(&render_passes_in_draw_order_, |
972 grand_child_pass_id, | 972 grand_child_pass_id, |
973 grand_child_rect, | 973 grand_child_rect, |
974 gfx::Transform()); | 974 gfx::Transform()); |
975 AddClippedQuad(grand_child_pass, grand_child_rect, SK_ColorYELLOW); | 975 AddClippedQuad(grand_child_pass, grand_child_rect, SK_ColorYELLOW); |
976 | 976 |
977 gfx::Rect child_rect(50, 50); | 977 gfx::Rect child_rect(50, 50); |
978 RenderPass::Id child_pass_id(2, 0); | 978 RenderPassId child_pass_id(2, 0); |
979 TestRenderPass* child_pass = AddRenderPass(&render_passes_in_draw_order_, | 979 TestRenderPass* child_pass = AddRenderPass(&render_passes_in_draw_order_, |
980 child_pass_id, | 980 child_pass_id, |
981 child_rect, | 981 child_rect, |
982 gfx::Transform()); | 982 gfx::Transform()); |
983 AddQuad(child_pass, child_rect, SK_ColorBLUE); | 983 AddQuad(child_pass, child_rect, SK_ColorBLUE); |
984 | 984 |
985 RenderPass::Id root_pass_id(1, 0); | 985 RenderPassId root_pass_id(1, 0); |
986 TestRenderPass* root_pass = AddRenderPass(&render_passes_in_draw_order_, | 986 TestRenderPass* root_pass = AddRenderPass(&render_passes_in_draw_order_, |
987 root_pass_id, | 987 root_pass_id, |
988 viewport_rect, | 988 viewport_rect, |
989 gfx::Transform()); | 989 gfx::Transform()); |
990 AddQuad(root_pass, viewport_rect, SK_ColorGREEN); | 990 AddQuad(root_pass, viewport_rect, SK_ColorGREEN); |
991 | 991 |
992 AddRenderPassQuad(root_pass, child_pass); | 992 AddRenderPassQuad(root_pass, child_pass); |
993 AddRenderPassQuad(child_pass, grand_child_pass); | 993 AddRenderPassQuad(child_pass, grand_child_pass); |
994 | 994 |
995 renderer.DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); | 995 renderer.DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1055 &settings, | 1055 &settings, |
1056 output_surface.get(), | 1056 output_surface.get(), |
1057 resource_provider.get()); | 1057 resource_provider.get()); |
1058 EXPECT_TRUE(renderer.Capabilities().using_partial_swap); | 1058 EXPECT_TRUE(renderer.Capabilities().using_partial_swap); |
1059 | 1059 |
1060 gfx::Rect viewport_rect(100, 100); | 1060 gfx::Rect viewport_rect(100, 100); |
1061 gfx::Rect clip_rect(100, 100); | 1061 gfx::Rect clip_rect(100, 100); |
1062 | 1062 |
1063 { | 1063 { |
1064 // Partial frame, should not discard. | 1064 // Partial frame, should not discard. |
1065 RenderPass::Id root_pass_id(1, 0); | 1065 RenderPassId root_pass_id(1, 0); |
1066 TestRenderPass* root_pass = AddRenderPass(&render_passes_in_draw_order_, | 1066 TestRenderPass* root_pass = AddRenderPass(&render_passes_in_draw_order_, |
1067 root_pass_id, | 1067 root_pass_id, |
1068 viewport_rect, | 1068 viewport_rect, |
1069 gfx::Transform()); | 1069 gfx::Transform()); |
1070 AddQuad(root_pass, viewport_rect, SK_ColorGREEN); | 1070 AddQuad(root_pass, viewport_rect, SK_ColorGREEN); |
1071 root_pass->damage_rect = gfx::Rect(2, 2, 3, 3); | 1071 root_pass->damage_rect = gfx::Rect(2, 2, 3, 3); |
1072 | 1072 |
1073 renderer.DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); | 1073 renderer.DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); |
1074 renderer.DrawFrame(&render_passes_in_draw_order_, | 1074 renderer.DrawFrame(&render_passes_in_draw_order_, |
1075 1.f, | 1075 1.f, |
1076 viewport_rect, | 1076 viewport_rect, |
1077 clip_rect, | 1077 clip_rect, |
1078 false); | 1078 false); |
1079 EXPECT_EQ(0, context->discarded()); | 1079 EXPECT_EQ(0, context->discarded()); |
1080 context->reset(); | 1080 context->reset(); |
1081 } | 1081 } |
1082 { | 1082 { |
1083 // Full frame, should discard. | 1083 // Full frame, should discard. |
1084 RenderPass::Id root_pass_id(1, 0); | 1084 RenderPassId root_pass_id(1, 0); |
1085 TestRenderPass* root_pass = AddRenderPass(&render_passes_in_draw_order_, | 1085 TestRenderPass* root_pass = AddRenderPass(&render_passes_in_draw_order_, |
1086 root_pass_id, | 1086 root_pass_id, |
1087 viewport_rect, | 1087 viewport_rect, |
1088 gfx::Transform()); | 1088 gfx::Transform()); |
1089 AddQuad(root_pass, viewport_rect, SK_ColorGREEN); | 1089 AddQuad(root_pass, viewport_rect, SK_ColorGREEN); |
1090 root_pass->damage_rect = root_pass->output_rect; | 1090 root_pass->damage_rect = root_pass->output_rect; |
1091 | 1091 |
1092 renderer.DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); | 1092 renderer.DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); |
1093 renderer.DrawFrame(&render_passes_in_draw_order_, | 1093 renderer.DrawFrame(&render_passes_in_draw_order_, |
1094 1.f, | 1094 1.f, |
1095 viewport_rect, | 1095 viewport_rect, |
1096 clip_rect, | 1096 clip_rect, |
1097 false); | 1097 false); |
1098 EXPECT_EQ(1, context->discarded()); | 1098 EXPECT_EQ(1, context->discarded()); |
1099 context->reset(); | 1099 context->reset(); |
1100 } | 1100 } |
1101 { | 1101 { |
1102 // Full frame, external scissor is set, should not discard. | 1102 // Full frame, external scissor is set, should not discard. |
1103 output_surface->set_has_external_stencil_test(true); | 1103 output_surface->set_has_external_stencil_test(true); |
1104 RenderPass::Id root_pass_id(1, 0); | 1104 RenderPassId root_pass_id(1, 0); |
1105 TestRenderPass* root_pass = AddRenderPass(&render_passes_in_draw_order_, | 1105 TestRenderPass* root_pass = AddRenderPass(&render_passes_in_draw_order_, |
1106 root_pass_id, | 1106 root_pass_id, |
1107 viewport_rect, | 1107 viewport_rect, |
1108 gfx::Transform()); | 1108 gfx::Transform()); |
1109 AddQuad(root_pass, viewport_rect, SK_ColorGREEN); | 1109 AddQuad(root_pass, viewport_rect, SK_ColorGREEN); |
1110 root_pass->damage_rect = root_pass->output_rect; | 1110 root_pass->damage_rect = root_pass->output_rect; |
1111 root_pass->has_transparent_background = false; | 1111 root_pass->has_transparent_background = false; |
1112 | 1112 |
1113 renderer.DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); | 1113 renderer.DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); |
1114 renderer.DrawFrame(&render_passes_in_draw_order_, | 1114 renderer.DrawFrame(&render_passes_in_draw_order_, |
1115 1.f, | 1115 1.f, |
1116 viewport_rect, | 1116 viewport_rect, |
1117 clip_rect, | 1117 clip_rect, |
1118 false); | 1118 false); |
1119 EXPECT_EQ(0, context->discarded()); | 1119 EXPECT_EQ(0, context->discarded()); |
1120 context->reset(); | 1120 context->reset(); |
1121 output_surface->set_has_external_stencil_test(false); | 1121 output_surface->set_has_external_stencil_test(false); |
1122 } | 1122 } |
1123 { | 1123 { |
1124 // Full frame, clipped, should not discard. | 1124 // Full frame, clipped, should not discard. |
1125 clip_rect = gfx::Rect(10, 10, 10, 10); | 1125 clip_rect = gfx::Rect(10, 10, 10, 10); |
1126 RenderPass::Id root_pass_id(1, 0); | 1126 RenderPassId root_pass_id(1, 0); |
1127 TestRenderPass* root_pass = AddRenderPass(&render_passes_in_draw_order_, | 1127 TestRenderPass* root_pass = AddRenderPass(&render_passes_in_draw_order_, |
1128 root_pass_id, | 1128 root_pass_id, |
1129 viewport_rect, | 1129 viewport_rect, |
1130 gfx::Transform()); | 1130 gfx::Transform()); |
1131 AddQuad(root_pass, viewport_rect, SK_ColorGREEN); | 1131 AddQuad(root_pass, viewport_rect, SK_ColorGREEN); |
1132 root_pass->damage_rect = root_pass->output_rect; | 1132 root_pass->damage_rect = root_pass->output_rect; |
1133 | 1133 |
1134 renderer.DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); | 1134 renderer.DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); |
1135 renderer.DrawFrame(&render_passes_in_draw_order_, | 1135 renderer.DrawFrame(&render_passes_in_draw_order_, |
1136 1.f, | 1136 1.f, |
1137 viewport_rect, | 1137 viewport_rect, |
1138 clip_rect, | 1138 clip_rect, |
1139 false); | 1139 false); |
1140 EXPECT_EQ(0, context->discarded()); | 1140 EXPECT_EQ(0, context->discarded()); |
1141 context->reset(); | 1141 context->reset(); |
1142 } | 1142 } |
1143 { | 1143 { |
1144 // Full frame, doesn't cover the surface, should not discard. | 1144 // Full frame, doesn't cover the surface, should not discard. |
1145 viewport_rect = gfx::Rect(10, 10, 10, 10); | 1145 viewport_rect = gfx::Rect(10, 10, 10, 10); |
1146 RenderPass::Id root_pass_id(1, 0); | 1146 RenderPassId root_pass_id(1, 0); |
1147 TestRenderPass* root_pass = AddRenderPass(&render_passes_in_draw_order_, | 1147 TestRenderPass* root_pass = AddRenderPass(&render_passes_in_draw_order_, |
1148 root_pass_id, | 1148 root_pass_id, |
1149 viewport_rect, | 1149 viewport_rect, |
1150 gfx::Transform()); | 1150 gfx::Transform()); |
1151 AddQuad(root_pass, viewport_rect, SK_ColorGREEN); | 1151 AddQuad(root_pass, viewport_rect, SK_ColorGREEN); |
1152 root_pass->damage_rect = root_pass->output_rect; | 1152 root_pass->damage_rect = root_pass->output_rect; |
1153 | 1153 |
1154 renderer.DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); | 1154 renderer.DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); |
1155 renderer.DrawFrame(&render_passes_in_draw_order_, | 1155 renderer.DrawFrame(&render_passes_in_draw_order_, |
1156 1.f, | 1156 1.f, |
1157 viewport_rect, | 1157 viewport_rect, |
1158 clip_rect, | 1158 clip_rect, |
1159 false); | 1159 false); |
1160 EXPECT_EQ(0, context->discarded()); | 1160 EXPECT_EQ(0, context->discarded()); |
1161 context->reset(); | 1161 context->reset(); |
1162 } | 1162 } |
1163 { | 1163 { |
1164 // Full frame, doesn't cover the surface (no offset), should not discard. | 1164 // Full frame, doesn't cover the surface (no offset), should not discard. |
1165 clip_rect = gfx::Rect(100, 100); | 1165 clip_rect = gfx::Rect(100, 100); |
1166 viewport_rect = gfx::Rect(50, 50); | 1166 viewport_rect = gfx::Rect(50, 50); |
1167 RenderPass::Id root_pass_id(1, 0); | 1167 RenderPassId root_pass_id(1, 0); |
1168 TestRenderPass* root_pass = AddRenderPass(&render_passes_in_draw_order_, | 1168 TestRenderPass* root_pass = AddRenderPass(&render_passes_in_draw_order_, |
1169 root_pass_id, | 1169 root_pass_id, |
1170 viewport_rect, | 1170 viewport_rect, |
1171 gfx::Transform()); | 1171 gfx::Transform()); |
1172 AddQuad(root_pass, viewport_rect, SK_ColorGREEN); | 1172 AddQuad(root_pass, viewport_rect, SK_ColorGREEN); |
1173 root_pass->damage_rect = root_pass->output_rect; | 1173 root_pass->damage_rect = root_pass->output_rect; |
1174 | 1174 |
1175 renderer.DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); | 1175 renderer.DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); |
1176 renderer.DrawFrame(&render_passes_in_draw_order_, | 1176 renderer.DrawFrame(&render_passes_in_draw_order_, |
1177 1.f, | 1177 1.f, |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1238 FakeRendererGL renderer(&renderer_client, | 1238 FakeRendererGL renderer(&renderer_client, |
1239 &settings, | 1239 &settings, |
1240 output_surface.get(), | 1240 output_surface.get(), |
1241 resource_provider.get()); | 1241 resource_provider.get()); |
1242 EXPECT_FALSE(renderer.Capabilities().using_partial_swap); | 1242 EXPECT_FALSE(renderer.Capabilities().using_partial_swap); |
1243 | 1243 |
1244 gfx::Rect device_viewport_rect(10, 10, 100, 100); | 1244 gfx::Rect device_viewport_rect(10, 10, 100, 100); |
1245 gfx::Rect viewport_rect(device_viewport_rect.size()); | 1245 gfx::Rect viewport_rect(device_viewport_rect.size()); |
1246 gfx::Rect quad_rect = gfx::Rect(20, 20, 20, 20); | 1246 gfx::Rect quad_rect = gfx::Rect(20, 20, 20, 20); |
1247 | 1247 |
1248 RenderPass::Id root_pass_id(1, 0); | 1248 RenderPassId root_pass_id(1, 0); |
1249 TestRenderPass* root_pass = AddRenderPass(&render_passes_in_draw_order_, | 1249 TestRenderPass* root_pass = AddRenderPass(&render_passes_in_draw_order_, |
1250 root_pass_id, | 1250 root_pass_id, |
1251 viewport_rect, | 1251 viewport_rect, |
1252 gfx::Transform()); | 1252 gfx::Transform()); |
1253 AddClippedQuad(root_pass, quad_rect, SK_ColorGREEN); | 1253 AddClippedQuad(root_pass, quad_rect, SK_ColorGREEN); |
1254 | 1254 |
1255 renderer.DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); | 1255 renderer.DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); |
1256 renderer.DrawFrame(&render_passes_in_draw_order_, | 1256 renderer.DrawFrame(&render_passes_in_draw_order_, |
1257 1.f, | 1257 1.f, |
1258 device_viewport_rect, | 1258 device_viewport_rect, |
1259 device_viewport_rect, | 1259 device_viewport_rect, |
1260 false); | 1260 false); |
1261 } | 1261 } |
1262 | 1262 |
1263 TEST_F(GLRendererShaderTest, DrawRenderPassQuadShaderPermutations) { | 1263 TEST_F(GLRendererShaderTest, DrawRenderPassQuadShaderPermutations) { |
1264 gfx::Rect viewport_rect(1, 1); | 1264 gfx::Rect viewport_rect(1, 1); |
1265 | 1265 |
1266 gfx::Rect child_rect(50, 50); | 1266 gfx::Rect child_rect(50, 50); |
1267 RenderPass::Id child_pass_id(2, 0); | 1267 RenderPassId child_pass_id(2, 0); |
1268 TestRenderPass* child_pass; | 1268 TestRenderPass* child_pass; |
1269 | 1269 |
1270 RenderPass::Id root_pass_id(1, 0); | 1270 RenderPassId root_pass_id(1, 0); |
1271 TestRenderPass* root_pass; | 1271 TestRenderPass* root_pass; |
1272 | 1272 |
1273 ResourceProvider::ResourceId mask = resource_provider_->CreateResource( | 1273 ResourceProvider::ResourceId mask = resource_provider_->CreateResource( |
1274 gfx::Size(20, 12), | 1274 gfx::Size(20, 12), |
1275 GL_CLAMP_TO_EDGE, | 1275 GL_CLAMP_TO_EDGE, |
1276 ResourceProvider::TextureUsageAny, | 1276 ResourceProvider::TextureUsageAny, |
1277 resource_provider_->best_texture_format()); | 1277 resource_provider_->best_texture_format()); |
1278 resource_provider_->AllocateForTesting(mask); | 1278 resource_provider_->AllocateForTesting(mask); |
1279 | 1279 |
1280 SkScalar matrix[20]; | 1280 SkScalar matrix[20]; |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1487 viewport_rect, | 1487 viewport_rect, |
1488 viewport_rect, | 1488 viewport_rect, |
1489 false); | 1489 false); |
1490 TestRenderPassMaskColorMatrixProgramAA(TexCoordPrecisionMedium); | 1490 TestRenderPassMaskColorMatrixProgramAA(TexCoordPrecisionMedium); |
1491 } | 1491 } |
1492 | 1492 |
1493 // At this time, the AA code path cannot be taken if the surface's rect would | 1493 // At this time, the AA code path cannot be taken if the surface's rect would |
1494 // project incorrectly by the given transform, because of w<0 clipping. | 1494 // project incorrectly by the given transform, because of w<0 clipping. |
1495 TEST_F(GLRendererShaderTest, DrawRenderPassQuadSkipsAAForClippingTransform) { | 1495 TEST_F(GLRendererShaderTest, DrawRenderPassQuadSkipsAAForClippingTransform) { |
1496 gfx::Rect child_rect(50, 50); | 1496 gfx::Rect child_rect(50, 50); |
1497 RenderPass::Id child_pass_id(2, 0); | 1497 RenderPassId child_pass_id(2, 0); |
1498 TestRenderPass* child_pass; | 1498 TestRenderPass* child_pass; |
1499 | 1499 |
1500 gfx::Rect viewport_rect(1, 1); | 1500 gfx::Rect viewport_rect(1, 1); |
1501 RenderPass::Id root_pass_id(1, 0); | 1501 RenderPassId root_pass_id(1, 0); |
1502 TestRenderPass* root_pass; | 1502 TestRenderPass* root_pass; |
1503 | 1503 |
1504 gfx::Transform transform_preventing_aa; | 1504 gfx::Transform transform_preventing_aa; |
1505 transform_preventing_aa.ApplyPerspectiveDepth(40.0); | 1505 transform_preventing_aa.ApplyPerspectiveDepth(40.0); |
1506 transform_preventing_aa.RotateAboutYAxis(-20.0); | 1506 transform_preventing_aa.RotateAboutYAxis(-20.0); |
1507 transform_preventing_aa.Scale(30.0, 1.0); | 1507 transform_preventing_aa.Scale(30.0, 1.0); |
1508 | 1508 |
1509 // Verify that the test transform and test rect actually do cause the clipped | 1509 // Verify that the test transform and test rect actually do cause the clipped |
1510 // flag to trigger. Otherwise we are not testing the intended scenario. | 1510 // flag to trigger. Otherwise we are not testing the intended scenario. |
1511 bool clipped = false; | 1511 bool clipped = false; |
(...skipping 20 matching lines...) Expand all Loading... |
1532 viewport_rect, | 1532 viewport_rect, |
1533 false); | 1533 false); |
1534 | 1534 |
1535 // If use_aa incorrectly ignores clipping, it will use the | 1535 // If use_aa incorrectly ignores clipping, it will use the |
1536 // RenderPassProgramAA shader instead of the RenderPassProgram. | 1536 // RenderPassProgramAA shader instead of the RenderPassProgram. |
1537 TestRenderPassProgram(TexCoordPrecisionMedium); | 1537 TestRenderPassProgram(TexCoordPrecisionMedium); |
1538 } | 1538 } |
1539 | 1539 |
1540 TEST_F(GLRendererShaderTest, DrawSolidColorShader) { | 1540 TEST_F(GLRendererShaderTest, DrawSolidColorShader) { |
1541 gfx::Rect viewport_rect(1, 1); | 1541 gfx::Rect viewport_rect(1, 1); |
1542 RenderPass::Id root_pass_id(1, 0); | 1542 RenderPassId root_pass_id(1, 0); |
1543 TestRenderPass* root_pass; | 1543 TestRenderPass* root_pass; |
1544 | 1544 |
1545 gfx::Transform pixel_aligned_transform_causing_aa; | 1545 gfx::Transform pixel_aligned_transform_causing_aa; |
1546 pixel_aligned_transform_causing_aa.Translate(25.5f, 25.5f); | 1546 pixel_aligned_transform_causing_aa.Translate(25.5f, 25.5f); |
1547 pixel_aligned_transform_causing_aa.Scale(0.5f, 0.5f); | 1547 pixel_aligned_transform_causing_aa.Scale(0.5f, 0.5f); |
1548 | 1548 |
1549 root_pass = AddRenderPass(&render_passes_in_draw_order_, | 1549 root_pass = AddRenderPass(&render_passes_in_draw_order_, |
1550 root_pass_id, | 1550 root_pass_id, |
1551 viewport_rect, | 1551 viewport_rect, |
1552 gfx::Transform()); | 1552 gfx::Transform()); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1612 renderer_.reset(new FakeRendererGL(&renderer_client_, | 1612 renderer_.reset(new FakeRendererGL(&renderer_client_, |
1613 &settings_, | 1613 &settings_, |
1614 &output_surface_, | 1614 &output_surface_, |
1615 resource_provider_.get())); | 1615 resource_provider_.get())); |
1616 } | 1616 } |
1617 | 1617 |
1618 void SwapBuffers() { renderer_->SwapBuffers(CompositorFrameMetadata()); } | 1618 void SwapBuffers() { renderer_->SwapBuffers(CompositorFrameMetadata()); } |
1619 | 1619 |
1620 void DrawFrame(float device_scale_factor, | 1620 void DrawFrame(float device_scale_factor, |
1621 const gfx::Rect& device_viewport_rect) { | 1621 const gfx::Rect& device_viewport_rect) { |
1622 RenderPass::Id render_pass_id(1, 0); | 1622 RenderPassId render_pass_id(1, 0); |
1623 TestRenderPass* render_pass = AddRenderPass(&render_passes_in_draw_order_, | 1623 TestRenderPass* render_pass = AddRenderPass(&render_passes_in_draw_order_, |
1624 render_pass_id, | 1624 render_pass_id, |
1625 device_viewport_rect, | 1625 device_viewport_rect, |
1626 gfx::Transform()); | 1626 gfx::Transform()); |
1627 AddQuad(render_pass, device_viewport_rect, SK_ColorGREEN); | 1627 AddQuad(render_pass, device_viewport_rect, SK_ColorGREEN); |
1628 | 1628 |
1629 EXPECT_CALL(output_surface_, EnsureBackbuffer()).WillRepeatedly(Return()); | 1629 EXPECT_CALL(output_surface_, EnsureBackbuffer()).WillRepeatedly(Return()); |
1630 | 1630 |
1631 EXPECT_CALL(output_surface_, | 1631 EXPECT_CALL(output_surface_, |
1632 Reshape(device_viewport_rect.size(), device_scale_factor)) | 1632 Reshape(device_viewport_rect.size(), device_scale_factor)) |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1762 base::MessageLoop::current()->Run(); | 1762 base::MessageLoop::current()->Run(); |
1763 | 1763 |
1764 // The sync point should have happened. | 1764 // The sync point should have happened. |
1765 EXPECT_EQ(1, sync_point_callback_count); | 1765 EXPECT_EQ(1, sync_point_callback_count); |
1766 EXPECT_EQ(1, other_callback_count); | 1766 EXPECT_EQ(1, other_callback_count); |
1767 } | 1767 } |
1768 #endif // OS_ANDROID | 1768 #endif // OS_ANDROID |
1769 | 1769 |
1770 } // namespace | 1770 } // namespace |
1771 } // namespace cc | 1771 } // namespace cc |
OLD | NEW |