| 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 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 GLsizei numAttachments, | 549 GLsizei numAttachments, |
| 550 const GLenum* attachments)); | 550 const GLenum* attachments)); |
| 551 MOCK_METHOD1(clear, void(GLbitfield mask)); | 551 MOCK_METHOD1(clear, void(GLbitfield mask)); |
| 552 }; | 552 }; |
| 553 | 553 |
| 554 TEST_F(GLRendererTest, OpaqueBackground) { | 554 TEST_F(GLRendererTest, OpaqueBackground) { |
| 555 scoped_ptr<ClearCountingContext> context_owned(new ClearCountingContext); | 555 scoped_ptr<ClearCountingContext> context_owned(new ClearCountingContext); |
| 556 ClearCountingContext* context = context_owned.get(); | 556 ClearCountingContext* context = context_owned.get(); |
| 557 | 557 |
| 558 FakeOutputSurfaceClient output_surface_client; | 558 FakeOutputSurfaceClient output_surface_client; |
| 559 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 559 scoped_ptr<OutputSurface> output_surface( |
| 560 context_owned.PassAs<TestWebGraphicsContext3D>())); | 560 FakeOutputSurface::Create3d(context_owned.Pass())); |
| 561 CHECK(output_surface->BindToClient(&output_surface_client)); | 561 CHECK(output_surface->BindToClient(&output_surface_client)); |
| 562 | 562 |
| 563 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( | 563 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( |
| 564 new TestSharedBitmapManager()); | 564 new TestSharedBitmapManager()); |
| 565 scoped_ptr<ResourceProvider> resource_provider( | 565 scoped_ptr<ResourceProvider> resource_provider( |
| 566 ResourceProvider::Create(output_surface.get(), | 566 ResourceProvider::Create(output_surface.get(), |
| 567 shared_bitmap_manager.get(), | 567 shared_bitmap_manager.get(), |
| 568 NULL, | 568 NULL, |
| 569 0, | 569 0, |
| 570 false, | 570 false, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 601 viewport_rect, | 601 viewport_rect, |
| 602 false); | 602 false); |
| 603 Mock::VerifyAndClearExpectations(context); | 603 Mock::VerifyAndClearExpectations(context); |
| 604 } | 604 } |
| 605 | 605 |
| 606 TEST_F(GLRendererTest, TransparentBackground) { | 606 TEST_F(GLRendererTest, TransparentBackground) { |
| 607 scoped_ptr<ClearCountingContext> context_owned(new ClearCountingContext); | 607 scoped_ptr<ClearCountingContext> context_owned(new ClearCountingContext); |
| 608 ClearCountingContext* context = context_owned.get(); | 608 ClearCountingContext* context = context_owned.get(); |
| 609 | 609 |
| 610 FakeOutputSurfaceClient output_surface_client; | 610 FakeOutputSurfaceClient output_surface_client; |
| 611 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 611 scoped_ptr<OutputSurface> output_surface( |
| 612 context_owned.PassAs<TestWebGraphicsContext3D>())); | 612 FakeOutputSurface::Create3d(context_owned.Pass())); |
| 613 CHECK(output_surface->BindToClient(&output_surface_client)); | 613 CHECK(output_surface->BindToClient(&output_surface_client)); |
| 614 | 614 |
| 615 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( | 615 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( |
| 616 new TestSharedBitmapManager()); | 616 new TestSharedBitmapManager()); |
| 617 scoped_ptr<ResourceProvider> resource_provider( | 617 scoped_ptr<ResourceProvider> resource_provider( |
| 618 ResourceProvider::Create(output_surface.get(), | 618 ResourceProvider::Create(output_surface.get(), |
| 619 shared_bitmap_manager.get(), | 619 shared_bitmap_manager.get(), |
| 620 NULL, | 620 NULL, |
| 621 0, | 621 0, |
| 622 false, | 622 false, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 646 false); | 646 false); |
| 647 | 647 |
| 648 Mock::VerifyAndClearExpectations(context); | 648 Mock::VerifyAndClearExpectations(context); |
| 649 } | 649 } |
| 650 | 650 |
| 651 TEST_F(GLRendererTest, OffscreenOutputSurface) { | 651 TEST_F(GLRendererTest, OffscreenOutputSurface) { |
| 652 scoped_ptr<ClearCountingContext> context_owned(new ClearCountingContext); | 652 scoped_ptr<ClearCountingContext> context_owned(new ClearCountingContext); |
| 653 ClearCountingContext* context = context_owned.get(); | 653 ClearCountingContext* context = context_owned.get(); |
| 654 | 654 |
| 655 FakeOutputSurfaceClient output_surface_client; | 655 FakeOutputSurfaceClient output_surface_client; |
| 656 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::CreateOffscreen( | 656 scoped_ptr<OutputSurface> output_surface( |
| 657 context_owned.PassAs<TestWebGraphicsContext3D>())); | 657 FakeOutputSurface::CreateOffscreen(context_owned.Pass())); |
| 658 CHECK(output_surface->BindToClient(&output_surface_client)); | 658 CHECK(output_surface->BindToClient(&output_surface_client)); |
| 659 | 659 |
| 660 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( | 660 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( |
| 661 new TestSharedBitmapManager()); | 661 new TestSharedBitmapManager()); |
| 662 scoped_ptr<ResourceProvider> resource_provider( | 662 scoped_ptr<ResourceProvider> resource_provider( |
| 663 ResourceProvider::Create(output_surface.get(), | 663 ResourceProvider::Create(output_surface.get(), |
| 664 shared_bitmap_manager.get(), | 664 shared_bitmap_manager.get(), |
| 665 NULL, | 665 NULL, |
| 666 0, | 666 0, |
| 667 false, | 667 false, |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 | 725 |
| 726 private: | 726 private: |
| 727 bool last_call_was_set_visibility_; | 727 bool last_call_was_set_visibility_; |
| 728 }; | 728 }; |
| 729 | 729 |
| 730 TEST_F(GLRendererTest, VisibilityChangeIsLastCall) { | 730 TEST_F(GLRendererTest, VisibilityChangeIsLastCall) { |
| 731 scoped_ptr<VisibilityChangeIsLastCallTrackingContext> context_owned( | 731 scoped_ptr<VisibilityChangeIsLastCallTrackingContext> context_owned( |
| 732 new VisibilityChangeIsLastCallTrackingContext); | 732 new VisibilityChangeIsLastCallTrackingContext); |
| 733 VisibilityChangeIsLastCallTrackingContext* context = context_owned.get(); | 733 VisibilityChangeIsLastCallTrackingContext* context = context_owned.get(); |
| 734 | 734 |
| 735 scoped_refptr<TestContextProvider> provider = TestContextProvider::Create( | 735 scoped_refptr<TestContextProvider> provider = |
| 736 context_owned.PassAs<TestWebGraphicsContext3D>()); | 736 TestContextProvider::Create(context_owned.Pass()); |
| 737 | 737 |
| 738 provider->support()->SetSurfaceVisibleCallback(base::Bind( | 738 provider->support()->SetSurfaceVisibleCallback(base::Bind( |
| 739 &VisibilityChangeIsLastCallTrackingContext::set_last_call_was_visibility, | 739 &VisibilityChangeIsLastCallTrackingContext::set_last_call_was_visibility, |
| 740 base::Unretained(context))); | 740 base::Unretained(context))); |
| 741 | 741 |
| 742 FakeOutputSurfaceClient output_surface_client; | 742 FakeOutputSurfaceClient output_surface_client; |
| 743 scoped_ptr<OutputSurface> output_surface( | 743 scoped_ptr<OutputSurface> output_surface( |
| 744 FakeOutputSurface::Create3d(provider)); | 744 FakeOutputSurface::Create3d(provider)); |
| 745 CHECK(output_surface->BindToClient(&output_surface_client)); | 745 CHECK(output_surface->BindToClient(&output_surface_client)); |
| 746 | 746 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 804 private: | 804 private: |
| 805 GLenum active_texture_; | 805 GLenum active_texture_; |
| 806 }; | 806 }; |
| 807 | 807 |
| 808 TEST_F(GLRendererTest, ActiveTextureState) { | 808 TEST_F(GLRendererTest, ActiveTextureState) { |
| 809 scoped_ptr<TextureStateTrackingContext> context_owned( | 809 scoped_ptr<TextureStateTrackingContext> context_owned( |
| 810 new TextureStateTrackingContext); | 810 new TextureStateTrackingContext); |
| 811 TextureStateTrackingContext* context = context_owned.get(); | 811 TextureStateTrackingContext* context = context_owned.get(); |
| 812 | 812 |
| 813 FakeOutputSurfaceClient output_surface_client; | 813 FakeOutputSurfaceClient output_surface_client; |
| 814 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 814 scoped_ptr<OutputSurface> output_surface( |
| 815 context_owned.PassAs<TestWebGraphicsContext3D>())); | 815 FakeOutputSurface::Create3d(context_owned.Pass())); |
| 816 CHECK(output_surface->BindToClient(&output_surface_client)); | 816 CHECK(output_surface->BindToClient(&output_surface_client)); |
| 817 | 817 |
| 818 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( | 818 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( |
| 819 new TestSharedBitmapManager()); | 819 new TestSharedBitmapManager()); |
| 820 scoped_ptr<ResourceProvider> resource_provider( | 820 scoped_ptr<ResourceProvider> resource_provider( |
| 821 ResourceProvider::Create(output_surface.get(), | 821 ResourceProvider::Create(output_surface.get(), |
| 822 shared_bitmap_manager.get(), | 822 shared_bitmap_manager.get(), |
| 823 NULL, | 823 NULL, |
| 824 0, | 824 0, |
| 825 false, | 825 false, |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 895 MOCK_METHOD4(drawElements, | 895 MOCK_METHOD4(drawElements, |
| 896 void(GLenum mode, GLsizei count, GLenum type, GLintptr offset)); | 896 void(GLenum mode, GLsizei count, GLenum type, GLintptr offset)); |
| 897 }; | 897 }; |
| 898 | 898 |
| 899 TEST_F(GLRendererTest, ShouldClearRootRenderPass) { | 899 TEST_F(GLRendererTest, ShouldClearRootRenderPass) { |
| 900 scoped_ptr<NoClearRootRenderPassMockContext> mock_context_owned( | 900 scoped_ptr<NoClearRootRenderPassMockContext> mock_context_owned( |
| 901 new NoClearRootRenderPassMockContext); | 901 new NoClearRootRenderPassMockContext); |
| 902 NoClearRootRenderPassMockContext* mock_context = mock_context_owned.get(); | 902 NoClearRootRenderPassMockContext* mock_context = mock_context_owned.get(); |
| 903 | 903 |
| 904 FakeOutputSurfaceClient output_surface_client; | 904 FakeOutputSurfaceClient output_surface_client; |
| 905 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 905 scoped_ptr<OutputSurface> output_surface( |
| 906 mock_context_owned.PassAs<TestWebGraphicsContext3D>())); | 906 FakeOutputSurface::Create3d(mock_context_owned.Pass())); |
| 907 CHECK(output_surface->BindToClient(&output_surface_client)); | 907 CHECK(output_surface->BindToClient(&output_surface_client)); |
| 908 | 908 |
| 909 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( | 909 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( |
| 910 new TestSharedBitmapManager()); | 910 new TestSharedBitmapManager()); |
| 911 scoped_ptr<ResourceProvider> resource_provider( | 911 scoped_ptr<ResourceProvider> resource_provider( |
| 912 ResourceProvider::Create(output_surface.get(), | 912 ResourceProvider::Create(output_surface.get(), |
| 913 shared_bitmap_manager.get(), | 913 shared_bitmap_manager.get(), |
| 914 NULL, | 914 NULL, |
| 915 0, | 915 0, |
| 916 false, | 916 false, |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 993 | 993 |
| 994 private: | 994 private: |
| 995 bool scissor_enabled_; | 995 bool scissor_enabled_; |
| 996 }; | 996 }; |
| 997 | 997 |
| 998 TEST_F(GLRendererTest, ScissorTestWhenClearing) { | 998 TEST_F(GLRendererTest, ScissorTestWhenClearing) { |
| 999 scoped_ptr<ScissorTestOnClearCheckingContext> context_owned( | 999 scoped_ptr<ScissorTestOnClearCheckingContext> context_owned( |
| 1000 new ScissorTestOnClearCheckingContext); | 1000 new ScissorTestOnClearCheckingContext); |
| 1001 | 1001 |
| 1002 FakeOutputSurfaceClient output_surface_client; | 1002 FakeOutputSurfaceClient output_surface_client; |
| 1003 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 1003 scoped_ptr<OutputSurface> output_surface( |
| 1004 context_owned.PassAs<TestWebGraphicsContext3D>())); | 1004 FakeOutputSurface::Create3d(context_owned.Pass())); |
| 1005 CHECK(output_surface->BindToClient(&output_surface_client)); | 1005 CHECK(output_surface->BindToClient(&output_surface_client)); |
| 1006 | 1006 |
| 1007 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( | 1007 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( |
| 1008 new TestSharedBitmapManager()); | 1008 new TestSharedBitmapManager()); |
| 1009 scoped_ptr<ResourceProvider> resource_provider( | 1009 scoped_ptr<ResourceProvider> resource_provider( |
| 1010 ResourceProvider::Create(output_surface.get(), | 1010 ResourceProvider::Create(output_surface.get(), |
| 1011 shared_bitmap_manager.get(), | 1011 shared_bitmap_manager.get(), |
| 1012 NULL, | 1012 NULL, |
| 1013 0, | 1013 0, |
| 1014 false, | 1014 false, |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1091 virtual void Reshape(const gfx::Size& size, float scale_factor) OVERRIDE {} | 1091 virtual void Reshape(const gfx::Size& size, float scale_factor) OVERRIDE {} |
| 1092 void set_fixed_size(const gfx::Size& size) { surface_size_ = size; } | 1092 void set_fixed_size(const gfx::Size& size) { surface_size_ = size; } |
| 1093 }; | 1093 }; |
| 1094 | 1094 |
| 1095 TEST_F(GLRendererTest, NoDiscardOnPartialUpdates) { | 1095 TEST_F(GLRendererTest, NoDiscardOnPartialUpdates) { |
| 1096 scoped_ptr<DiscardCheckingContext> context_owned(new DiscardCheckingContext); | 1096 scoped_ptr<DiscardCheckingContext> context_owned(new DiscardCheckingContext); |
| 1097 DiscardCheckingContext* context = context_owned.get(); | 1097 DiscardCheckingContext* context = context_owned.get(); |
| 1098 | 1098 |
| 1099 FakeOutputSurfaceClient output_surface_client; | 1099 FakeOutputSurfaceClient output_surface_client; |
| 1100 scoped_ptr<NonReshapableOutputSurface> output_surface( | 1100 scoped_ptr<NonReshapableOutputSurface> output_surface( |
| 1101 new NonReshapableOutputSurface( | 1101 new NonReshapableOutputSurface(context_owned.Pass())); |
| 1102 context_owned.PassAs<TestWebGraphicsContext3D>())); | |
| 1103 CHECK(output_surface->BindToClient(&output_surface_client)); | 1102 CHECK(output_surface->BindToClient(&output_surface_client)); |
| 1104 output_surface->set_fixed_size(gfx::Size(100, 100)); | 1103 output_surface->set_fixed_size(gfx::Size(100, 100)); |
| 1105 | 1104 |
| 1106 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( | 1105 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( |
| 1107 new TestSharedBitmapManager()); | 1106 new TestSharedBitmapManager()); |
| 1108 scoped_ptr<ResourceProvider> resource_provider( | 1107 scoped_ptr<ResourceProvider> resource_provider( |
| 1109 ResourceProvider::Create(output_surface.get(), | 1108 ResourceProvider::Create(output_surface.get(), |
| 1110 shared_bitmap_manager.get(), | 1109 shared_bitmap_manager.get(), |
| 1111 NULL, | 1110 NULL, |
| 1112 0, | 1111 0, |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1283 | 1282 |
| 1284 TEST_F(GLRendererTest, ScissorAndViewportWithinNonreshapableSurface) { | 1283 TEST_F(GLRendererTest, ScissorAndViewportWithinNonreshapableSurface) { |
| 1285 // In Android WebView, the OutputSurface is unable to respect reshape() calls | 1284 // In Android WebView, the OutputSurface is unable to respect reshape() calls |
| 1286 // and maintains a fixed size. This test verifies that glViewport and | 1285 // and maintains a fixed size. This test verifies that glViewport and |
| 1287 // glScissor's Y coordinate is flipped correctly in this environment, and that | 1286 // glScissor's Y coordinate is flipped correctly in this environment, and that |
| 1288 // the glViewport can be at a nonzero origin within the surface. | 1287 // the glViewport can be at a nonzero origin within the surface. |
| 1289 scoped_ptr<FlippedScissorAndViewportContext> context_owned( | 1288 scoped_ptr<FlippedScissorAndViewportContext> context_owned( |
| 1290 new FlippedScissorAndViewportContext); | 1289 new FlippedScissorAndViewportContext); |
| 1291 | 1290 |
| 1292 FakeOutputSurfaceClient output_surface_client; | 1291 FakeOutputSurfaceClient output_surface_client; |
| 1293 scoped_ptr<OutputSurface> output_surface(new NonReshapableOutputSurface( | 1292 scoped_ptr<OutputSurface> output_surface( |
| 1294 context_owned.PassAs<TestWebGraphicsContext3D>())); | 1293 new NonReshapableOutputSurface(context_owned.Pass())); |
| 1295 CHECK(output_surface->BindToClient(&output_surface_client)); | 1294 CHECK(output_surface->BindToClient(&output_surface_client)); |
| 1296 | 1295 |
| 1297 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( | 1296 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( |
| 1298 new TestSharedBitmapManager()); | 1297 new TestSharedBitmapManager()); |
| 1299 scoped_ptr<ResourceProvider> resource_provider( | 1298 scoped_ptr<ResourceProvider> resource_provider( |
| 1300 ResourceProvider::Create(output_surface.get(), | 1299 ResourceProvider::Create(output_surface.get(), |
| 1301 shared_bitmap_manager.get(), | 1300 shared_bitmap_manager.get(), |
| 1302 NULL, | 1301 NULL, |
| 1303 0, | 1302 0, |
| 1304 false, | 1303 false, |
| (...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1837 base::MessageLoop::current()->Run(); | 1836 base::MessageLoop::current()->Run(); |
| 1838 | 1837 |
| 1839 // The sync point should have happened. | 1838 // The sync point should have happened. |
| 1840 EXPECT_EQ(1, sync_point_callback_count); | 1839 EXPECT_EQ(1, sync_point_callback_count); |
| 1841 EXPECT_EQ(1, other_callback_count); | 1840 EXPECT_EQ(1, other_callback_count); |
| 1842 } | 1841 } |
| 1843 #endif // OS_ANDROID | 1842 #endif // OS_ANDROID |
| 1844 | 1843 |
| 1845 } // namespace | 1844 } // namespace |
| 1846 } // namespace cc | 1845 } // namespace cc |
| OLD | NEW |