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 "cc/output/compositor_frame_metadata.h" | 7 #include "cc/output/compositor_frame_metadata.h" |
8 #include "cc/quads/draw_quad.h" | 8 #include "cc/quads/draw_quad.h" |
9 #include "cc/resources/prioritized_resource_manager.h" | 9 #include "cc/resources/prioritized_resource_manager.h" |
10 #include "cc/resources/resource_provider.h" | 10 #include "cc/resources/resource_provider.h" |
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 &mock_client, output_surface.get(), resource_provider.get()); | 806 &mock_client, output_surface.get(), resource_provider.get()); |
807 EXPECT_TRUE(renderer.Initialize()); | 807 EXPECT_TRUE(renderer.Initialize()); |
808 | 808 |
809 gfx::Rect viewport_rect(mock_client.DeviceViewportSize()); | 809 gfx::Rect viewport_rect(mock_client.DeviceViewportSize()); |
810 ScopedPtrVector<RenderPass>& render_passes = | 810 ScopedPtrVector<RenderPass>& render_passes = |
811 *mock_client.render_passes_in_draw_order(); | 811 *mock_client.render_passes_in_draw_order(); |
812 render_passes.clear(); | 812 render_passes.clear(); |
813 | 813 |
814 RenderPass::Id root_pass_id(1, 0); | 814 RenderPass::Id root_pass_id(1, 0); |
815 TestRenderPass* root_pass = AddRenderPass( | 815 TestRenderPass* root_pass = AddRenderPass( |
816 render_passes, root_pass_id, viewport_rect, gfx::Transform()); | 816 &render_passes, root_pass_id, viewport_rect, gfx::Transform()); |
817 AddQuad(root_pass, viewport_rect, SK_ColorGREEN); | 817 AddQuad(root_pass, viewport_rect, SK_ColorGREEN); |
818 | 818 |
819 RenderPass::Id child_pass_id(2, 0); | 819 RenderPass::Id child_pass_id(2, 0); |
820 TestRenderPass* child_pass = AddRenderPass( | 820 TestRenderPass* child_pass = AddRenderPass( |
821 render_passes, child_pass_id, viewport_rect, gfx::Transform()); | 821 &render_passes, child_pass_id, viewport_rect, gfx::Transform()); |
822 AddQuad(child_pass, viewport_rect, SK_ColorBLUE); | 822 AddQuad(child_pass, viewport_rect, SK_ColorBLUE); |
823 | 823 |
824 AddRenderPassQuad(root_pass, child_pass); | 824 AddRenderPassQuad(root_pass, child_pass); |
825 | 825 |
826 // First render pass is not the root one, clearing should happen. | 826 // First render pass is not the root one, clearing should happen. |
827 EXPECT_CALL(*mock_context, clear(GL_COLOR_BUFFER_BIT)).Times(AtLeast(1)); | 827 EXPECT_CALL(*mock_context, clear(GL_COLOR_BUFFER_BIT)).Times(AtLeast(1)); |
828 | 828 |
829 Expectation first_render_pass = | 829 Expectation first_render_pass = |
830 EXPECT_CALL(*mock_context, drawElements(_, _, _, _)).Times(1); | 830 EXPECT_CALL(*mock_context, drawElements(_, _, _, _)).Times(1); |
831 | 831 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
878 EXPECT_FALSE(renderer.Capabilities().using_partial_swap); | 878 EXPECT_FALSE(renderer.Capabilities().using_partial_swap); |
879 | 879 |
880 gfx::Rect viewport_rect(mock_client.DeviceViewportSize()); | 880 gfx::Rect viewport_rect(mock_client.DeviceViewportSize()); |
881 ScopedPtrVector<RenderPass>& render_passes = | 881 ScopedPtrVector<RenderPass>& render_passes = |
882 *mock_client.render_passes_in_draw_order(); | 882 *mock_client.render_passes_in_draw_order(); |
883 render_passes.clear(); | 883 render_passes.clear(); |
884 | 884 |
885 gfx::Rect grand_child_rect(25, 25); | 885 gfx::Rect grand_child_rect(25, 25); |
886 RenderPass::Id grand_child_pass_id(3, 0); | 886 RenderPass::Id grand_child_pass_id(3, 0); |
887 TestRenderPass* grand_child_pass = AddRenderPass( | 887 TestRenderPass* grand_child_pass = AddRenderPass( |
888 render_passes, grand_child_pass_id, grand_child_rect, gfx::Transform()); | 888 & render_passes, grand_child_pass_id, grand_child_rect, gfx::Transform()); |
889 AddClippedQuad(grand_child_pass, grand_child_rect, SK_ColorYELLOW); | 889 AddClippedQuad(grand_child_pass, grand_child_rect, SK_ColorYELLOW); |
890 | 890 |
891 gfx::Rect child_rect(50, 50); | 891 gfx::Rect child_rect(50, 50); |
892 RenderPass::Id child_pass_id(2, 0); | 892 RenderPass::Id child_pass_id(2, 0); |
893 TestRenderPass* child_pass = | 893 TestRenderPass* child_pass = |
894 AddRenderPass(render_passes, child_pass_id, child_rect, gfx::Transform()); | 894 AddRenderPass(&render_passes, child_pass_id, child_rect, gfx::Transform())
; |
895 AddQuad(child_pass, child_rect, SK_ColorBLUE); | 895 AddQuad(child_pass, child_rect, SK_ColorBLUE); |
896 | 896 |
897 RenderPass::Id root_pass_id(1, 0); | 897 RenderPass::Id root_pass_id(1, 0); |
898 TestRenderPass* root_pass = AddRenderPass( | 898 TestRenderPass* root_pass = AddRenderPass( |
899 render_passes, root_pass_id, viewport_rect, gfx::Transform()); | 899 & render_passes, root_pass_id, viewport_rect, gfx::Transform()); |
900 AddQuad(root_pass, viewport_rect, SK_ColorGREEN); | 900 AddQuad(root_pass, viewport_rect, SK_ColorGREEN); |
901 | 901 |
902 AddRenderPassQuad(root_pass, child_pass); | 902 AddRenderPassQuad(root_pass, child_pass); |
903 AddRenderPassQuad(child_pass, grand_child_pass); | 903 AddRenderPassQuad(child_pass, grand_child_pass); |
904 | 904 |
905 renderer.DecideRenderPassAllocationsForFrame( | 905 renderer.DecideRenderPassAllocationsForFrame( |
906 *mock_client.render_passes_in_draw_order()); | 906 *mock_client.render_passes_in_draw_order()); |
907 renderer.DrawFrame(*mock_client.render_passes_in_draw_order()); | 907 renderer.DrawFrame(*mock_client.render_passes_in_draw_order()); |
908 } | 908 } |
909 | 909 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 | 958 |
959 void SwapBuffers() { renderer_.SwapBuffers(); } | 959 void SwapBuffers() { renderer_.SwapBuffers(); } |
960 | 960 |
961 void DrawFrame() { | 961 void DrawFrame() { |
962 gfx::Rect viewport_rect(DeviceViewportSize()); | 962 gfx::Rect viewport_rect(DeviceViewportSize()); |
963 ScopedPtrVector<RenderPass>* render_passes = render_passes_in_draw_order(); | 963 ScopedPtrVector<RenderPass>* render_passes = render_passes_in_draw_order(); |
964 render_passes->clear(); | 964 render_passes->clear(); |
965 | 965 |
966 RenderPass::Id render_pass_id(1, 0); | 966 RenderPass::Id render_pass_id(1, 0); |
967 TestRenderPass* render_pass = AddRenderPass( | 967 TestRenderPass* render_pass = AddRenderPass( |
968 *render_passes, render_pass_id, viewport_rect, gfx::Transform()); | 968 render_passes, render_pass_id, viewport_rect, gfx::Transform()); |
969 AddQuad(render_pass, viewport_rect, SK_ColorGREEN); | 969 AddQuad(render_pass, viewport_rect, SK_ColorGREEN); |
970 | 970 |
971 EXPECT_CALL(output_surface_, EnsureBackbuffer()).WillRepeatedly(Return()); | 971 EXPECT_CALL(output_surface_, EnsureBackbuffer()).WillRepeatedly(Return()); |
972 | 972 |
973 EXPECT_CALL(output_surface_, Reshape(_)).Times(1); | 973 EXPECT_CALL(output_surface_, Reshape(_)).Times(1); |
974 | 974 |
975 EXPECT_CALL(output_surface_, BindFramebuffer()).Times(1); | 975 EXPECT_CALL(output_surface_, BindFramebuffer()).Times(1); |
976 | 976 |
977 EXPECT_CALL(*context(), drawElements(_, _, _, _)).Times(1); | 977 EXPECT_CALL(*context(), drawElements(_, _, _, _)).Times(1); |
978 | 978 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1022 } | 1022 } |
1023 }; | 1023 }; |
1024 | 1024 |
1025 TEST_F(MockOutputSurfaceTestWithSendCompositorFrame, DrawFrame) { | 1025 TEST_F(MockOutputSurfaceTestWithSendCompositorFrame, DrawFrame) { |
1026 EXPECT_CALL(output_surface_, SendFrameToParentCompositor(_)).Times(1); | 1026 EXPECT_CALL(output_surface_, SendFrameToParentCompositor(_)).Times(1); |
1027 DrawFrame(); | 1027 DrawFrame(); |
1028 } | 1028 } |
1029 | 1029 |
1030 } // namespace | 1030 } // namespace |
1031 } // namespace cc | 1031 } // namespace cc |
OLD | NEW |