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/debug/test_web_graphics_context_3d.h" | 10 #include "cc/debug/test_web_graphics_context_3d.h" |
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 | 695 |
696 FakeRendererClient renderer_client; | 696 FakeRendererClient renderer_client; |
697 FakeRendererGL renderer( | 697 FakeRendererGL renderer( |
698 &renderer_client, output_surface.get(), resource_provider.get()); | 698 &renderer_client, output_surface.get(), resource_provider.get()); |
699 | 699 |
700 renderer.Initialize(); | 700 renderer.Initialize(); |
701 } | 701 } |
702 | 702 |
703 class ClearCountingContext : public TestWebGraphicsContext3D { | 703 class ClearCountingContext : public TestWebGraphicsContext3D { |
704 public: | 704 public: |
705 ClearCountingContext() : clear_(0) {} | 705 ClearCountingContext() { |
| 706 test_capabilities_.discard_framebuffer = true; |
| 707 } |
706 | 708 |
707 virtual void clear(WGC3Dbitfield) { clear_++; } | 709 MOCK_METHOD3(discardFramebufferEXT, |
708 | 710 void(WGC3Denum target, |
709 int clear_count() const { return clear_; } | 711 WGC3Dsizei numAttachments, |
710 | 712 const WGC3Denum* attachments)); |
711 private: | 713 MOCK_METHOD1(clear, void(WGC3Dbitfield mask)); |
712 int clear_; | |
713 }; | 714 }; |
714 | 715 |
715 TEST(GLRendererTest2, OpaqueBackground) { | 716 TEST(GLRendererTest2, OpaqueBackground) { |
716 scoped_ptr<ClearCountingContext> context_owned(new ClearCountingContext); | 717 scoped_ptr<ClearCountingContext> context_owned(new ClearCountingContext); |
717 ClearCountingContext* context = context_owned.get(); | 718 ClearCountingContext* context = context_owned.get(); |
718 | 719 |
719 FakeOutputSurfaceClient output_surface_client; | 720 FakeOutputSurfaceClient output_surface_client; |
720 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 721 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
721 context_owned.PassAs<TestWebGraphicsContext3D>())); | 722 context_owned.PassAs<TestWebGraphicsContext3D>())); |
722 CHECK(output_surface->BindToClient(&output_surface_client)); | 723 CHECK(output_surface->BindToClient(&output_surface_client)); |
723 | 724 |
724 scoped_ptr<ResourceProvider> resource_provider( | 725 scoped_ptr<ResourceProvider> resource_provider( |
725 ResourceProvider::Create(output_surface.get(), 0)); | 726 ResourceProvider::Create(output_surface.get(), 0)); |
726 | 727 |
727 FakeRendererClient renderer_client; | 728 FakeRendererClient renderer_client; |
728 FakeRendererGL renderer( | 729 FakeRendererGL renderer( |
729 &renderer_client, output_surface.get(), resource_provider.get()); | 730 &renderer_client, output_surface.get(), resource_provider.get()); |
730 | 731 |
731 renderer_client.root_render_pass()->has_transparent_background = false; | 732 renderer_client.root_render_pass()->has_transparent_background = false; |
732 | 733 |
733 EXPECT_TRUE(renderer.Initialize()); | 734 EXPECT_TRUE(renderer.Initialize()); |
734 | 735 |
735 renderer.DrawFrame(renderer_client.render_passes_in_draw_order(), NULL); | |
736 | |
737 // On DEBUG builds, render passes with opaque background clear to blue to | 736 // On DEBUG builds, render passes with opaque background clear to blue to |
738 // easily see regions that were not drawn on the screen. | 737 // easily see regions that were not drawn on the screen. |
| 738 EXPECT_CALL(*context, discardFramebufferEXT(GL_FRAMEBUFFER, 1, _)) |
| 739 .Times(1); |
739 #ifdef NDEBUG | 740 #ifdef NDEBUG |
740 EXPECT_EQ(0, context->clear_count()); | 741 EXPECT_CALL(*context, clear(_)).Times(0); |
741 #else | 742 #else |
742 EXPECT_EQ(1, context->clear_count()); | 743 EXPECT_CALL(*context, clear(_)).Times(1); |
743 #endif | 744 #endif |
| 745 renderer.DrawFrame(renderer_client.render_passes_in_draw_order(), NULL); |
| 746 Mock::VerifyAndClearExpectations(context); |
744 } | 747 } |
745 | 748 |
746 TEST(GLRendererTest2, TransparentBackground) { | 749 TEST(GLRendererTest2, TransparentBackground) { |
747 scoped_ptr<ClearCountingContext> context_owned(new ClearCountingContext); | 750 scoped_ptr<ClearCountingContext> context_owned(new ClearCountingContext); |
748 ClearCountingContext* context = context_owned.get(); | 751 ClearCountingContext* context = context_owned.get(); |
749 | 752 |
750 FakeOutputSurfaceClient output_surface_client; | 753 FakeOutputSurfaceClient output_surface_client; |
751 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 754 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
752 context_owned.PassAs<TestWebGraphicsContext3D>())); | 755 context_owned.PassAs<TestWebGraphicsContext3D>())); |
753 CHECK(output_surface->BindToClient(&output_surface_client)); | 756 CHECK(output_surface->BindToClient(&output_surface_client)); |
754 | 757 |
755 scoped_ptr<ResourceProvider> resource_provider( | 758 scoped_ptr<ResourceProvider> resource_provider( |
756 ResourceProvider::Create(output_surface.get(), 0)); | 759 ResourceProvider::Create(output_surface.get(), 0)); |
757 | 760 |
758 FakeRendererClient renderer_client; | 761 FakeRendererClient renderer_client; |
759 FakeRendererGL renderer( | 762 FakeRendererGL renderer( |
760 &renderer_client, output_surface.get(), resource_provider.get()); | 763 &renderer_client, output_surface.get(), resource_provider.get()); |
761 | 764 |
762 renderer_client.root_render_pass()->has_transparent_background = true; | 765 renderer_client.root_render_pass()->has_transparent_background = true; |
763 | 766 |
764 EXPECT_TRUE(renderer.Initialize()); | 767 EXPECT_TRUE(renderer.Initialize()); |
765 | 768 |
| 769 EXPECT_CALL(*context, discardFramebufferEXT(GL_FRAMEBUFFER, 1, _)) |
| 770 .Times(1); |
| 771 EXPECT_CALL(*context, clear(_)).Times(1); |
766 renderer.DrawFrame(renderer_client.render_passes_in_draw_order(), NULL); | 772 renderer.DrawFrame(renderer_client.render_passes_in_draw_order(), NULL); |
767 | 773 |
768 EXPECT_EQ(1, context->clear_count()); | 774 Mock::VerifyAndClearExpectations(context); |
769 } | 775 } |
770 | 776 |
771 class VisibilityChangeIsLastCallTrackingContext | 777 class VisibilityChangeIsLastCallTrackingContext |
772 : public TestWebGraphicsContext3D { | 778 : public TestWebGraphicsContext3D { |
773 public: | 779 public: |
774 VisibilityChangeIsLastCallTrackingContext() | 780 VisibilityChangeIsLastCallTrackingContext() |
775 : last_call_was_set_visibility_(false) { | 781 : last_call_was_set_visibility_(false) { |
776 test_capabilities_.set_visibility = true; | 782 test_capabilities_.set_visibility = true; |
777 test_capabilities_.discard_backbuffer = true; | 783 test_capabilities_.discard_backbuffer = true; |
778 } | 784 } |
(...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1627 base::MessageLoop::current()->Run(); | 1633 base::MessageLoop::current()->Run(); |
1628 | 1634 |
1629 // The sync point should have happened. | 1635 // The sync point should have happened. |
1630 EXPECT_EQ(1, sync_point_callback_count); | 1636 EXPECT_EQ(1, sync_point_callback_count); |
1631 EXPECT_EQ(1, other_callback_count); | 1637 EXPECT_EQ(1, other_callback_count); |
1632 } | 1638 } |
1633 #endif // OS_ANDROID | 1639 #endif // OS_ANDROID |
1634 | 1640 |
1635 } // namespace | 1641 } // namespace |
1636 } // namespace cc | 1642 } // namespace cc |
OLD | NEW |