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