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 <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 // Changing visibility to public. | 333 // Changing visibility to public. |
334 using GLRenderer::DoDrawQuad; | 334 using GLRenderer::DoDrawQuad; |
335 using GLRenderer::BeginDrawingFrame; | 335 using GLRenderer::BeginDrawingFrame; |
336 using GLRenderer::FinishDrawingQuadList; | 336 using GLRenderer::FinishDrawingQuadList; |
337 using GLRenderer::stencil_enabled; | 337 using GLRenderer::stencil_enabled; |
338 }; | 338 }; |
339 | 339 |
340 class GLRendererWithDefaultHarnessTest : public GLRendererTest { | 340 class GLRendererWithDefaultHarnessTest : public GLRendererTest { |
341 protected: | 341 protected: |
342 GLRendererWithDefaultHarnessTest() { | 342 GLRendererWithDefaultHarnessTest() { |
343 output_surface_ = | 343 output_surface_ = FakeOutputSurface::Create3d(); |
344 FakeOutputSurface::Create3d(TestWebGraphicsContext3D::Create()); | 344 output_surface_->BindToClient(&output_surface_client_); |
345 CHECK(output_surface_->BindToClient(&output_surface_client_)); | |
346 | 345 |
347 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); | 346 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); |
348 resource_provider_ = FakeResourceProvider::Create( | 347 resource_provider_ = FakeResourceProvider::Create( |
349 output_surface_->context_provider(), shared_bitmap_manager_.get()); | 348 output_surface_->context_provider(), shared_bitmap_manager_.get()); |
350 renderer_ = base::MakeUnique<FakeRendererGL>( | 349 renderer_ = base::MakeUnique<FakeRendererGL>( |
351 &settings_, output_surface_.get(), resource_provider_.get()); | 350 &settings_, output_surface_.get(), resource_provider_.get()); |
352 renderer_->Initialize(); | 351 renderer_->Initialize(); |
353 renderer_->SetVisible(true); | 352 renderer_->SetVisible(true); |
354 } | 353 } |
355 | 354 |
356 void SwapBuffers() { renderer_->SwapBuffers(std::vector<ui::LatencyInfo>()); } | 355 void SwapBuffers() { renderer_->SwapBuffers(std::vector<ui::LatencyInfo>()); } |
357 | 356 |
358 RendererSettings settings_; | 357 RendererSettings settings_; |
359 FakeOutputSurfaceClient output_surface_client_; | 358 FakeOutputSurfaceClient output_surface_client_; |
360 std::unique_ptr<FakeOutputSurface> output_surface_; | 359 std::unique_ptr<FakeOutputSurface> output_surface_; |
361 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager_; | 360 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager_; |
362 std::unique_ptr<ResourceProvider> resource_provider_; | 361 std::unique_ptr<ResourceProvider> resource_provider_; |
363 std::unique_ptr<FakeRendererGL> renderer_; | 362 std::unique_ptr<FakeRendererGL> renderer_; |
364 }; | 363 }; |
365 | 364 |
366 // Closing the namespace here so that GLRendererShaderTest can take advantage | 365 // Closing the namespace here so that GLRendererShaderTest can take advantage |
367 // of the friend relationship with GLRenderer and all of the mock classes | 366 // of the friend relationship with GLRenderer and all of the mock classes |
368 // declared above it. | 367 // declared above it. |
369 } // namespace | 368 } // namespace |
370 | 369 |
371 class GLRendererShaderTest : public GLRendererTest { | 370 class GLRendererShaderTest : public GLRendererTest { |
372 protected: | 371 protected: |
373 GLRendererShaderTest() { | 372 GLRendererShaderTest() { |
374 output_surface_ = FakeOutputSurface::Create3d(); | 373 output_surface_ = FakeOutputSurface::Create3d(); |
375 CHECK(output_surface_->BindToClient(&output_surface_client_)); | 374 output_surface_->BindToClient(&output_surface_client_); |
376 | 375 |
377 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); | 376 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); |
378 resource_provider_ = FakeResourceProvider::Create( | 377 resource_provider_ = FakeResourceProvider::Create( |
379 output_surface_->context_provider(), shared_bitmap_manager_.get()); | 378 output_surface_->context_provider(), shared_bitmap_manager_.get()); |
380 renderer_.reset(new FakeRendererGL(&settings_, output_surface_.get(), | 379 renderer_.reset(new FakeRendererGL(&settings_, output_surface_.get(), |
381 resource_provider_.get())); | 380 resource_provider_.get())); |
382 renderer_->Initialize(); | 381 renderer_->Initialize(); |
383 renderer_->SetVisible(true); | 382 renderer_->SetVisible(true); |
384 } | 383 } |
385 | 384 |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 } | 591 } |
593 void getVertexAttribiv(GLuint index, GLenum pname, GLint* value) override { | 592 void getVertexAttribiv(GLuint index, GLenum pname, GLint* value) override { |
594 ADD_FAILURE(); | 593 ADD_FAILURE(); |
595 } | 594 } |
596 GLsizeiptr getVertexAttribOffset(GLuint index, GLenum pname) override { | 595 GLsizeiptr getVertexAttribOffset(GLuint index, GLenum pname) override { |
597 ADD_FAILURE(); | 596 ADD_FAILURE(); |
598 return 0; | 597 return 0; |
599 } | 598 } |
600 }; | 599 }; |
601 TEST_F(GLRendererTest, InitializationDoesNotMakeSynchronousCalls) { | 600 TEST_F(GLRendererTest, InitializationDoesNotMakeSynchronousCalls) { |
| 601 auto context = base::MakeUnique<ForbidSynchronousCallContext>(); |
| 602 auto provider = TestContextProvider::Create(std::move(context)); |
| 603 provider->BindToCurrentThread(); |
| 604 |
602 FakeOutputSurfaceClient output_surface_client; | 605 FakeOutputSurfaceClient output_surface_client; |
603 std::unique_ptr<OutputSurface> output_surface( | 606 std::unique_ptr<OutputSurface> output_surface( |
604 FakeOutputSurface::Create3d(std::unique_ptr<TestWebGraphicsContext3D>( | 607 FakeOutputSurface::Create3d(std::move(provider))); |
605 new ForbidSynchronousCallContext))); | 608 output_surface->BindToClient(&output_surface_client); |
606 CHECK(output_surface->BindToClient(&output_surface_client)); | |
607 | 609 |
608 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager( | 610 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager( |
609 new TestSharedBitmapManager()); | 611 new TestSharedBitmapManager()); |
610 std::unique_ptr<ResourceProvider> resource_provider = | 612 std::unique_ptr<ResourceProvider> resource_provider = |
611 FakeResourceProvider::Create(output_surface->context_provider(), | 613 FakeResourceProvider::Create(output_surface->context_provider(), |
612 shared_bitmap_manager.get()); | 614 shared_bitmap_manager.get()); |
613 | 615 |
614 RendererSettings settings; | 616 RendererSettings settings; |
615 FakeRendererGL renderer(&settings, output_surface.get(), | 617 FakeRendererGL renderer(&settings, output_surface.get(), |
616 resource_provider.get()); | 618 resource_provider.get()); |
617 } | 619 } |
618 | 620 |
619 class LoseContextOnFirstGetContext : public TestWebGraphicsContext3D { | 621 class LoseContextOnFirstGetContext : public TestWebGraphicsContext3D { |
620 public: | 622 public: |
621 LoseContextOnFirstGetContext() {} | 623 LoseContextOnFirstGetContext() {} |
622 | 624 |
623 void getProgramiv(GLuint program, GLenum pname, GLint* value) override { | 625 void getProgramiv(GLuint program, GLenum pname, GLint* value) override { |
624 context_lost_ = true; | 626 context_lost_ = true; |
625 *value = 0; | 627 *value = 0; |
626 } | 628 } |
627 | 629 |
628 void getShaderiv(GLuint shader, GLenum pname, GLint* value) override { | 630 void getShaderiv(GLuint shader, GLenum pname, GLint* value) override { |
629 context_lost_ = true; | 631 context_lost_ = true; |
630 *value = 0; | 632 *value = 0; |
631 } | 633 } |
632 }; | 634 }; |
633 | 635 |
634 TEST_F(GLRendererTest, InitializationWithQuicklyLostContextDoesNotAssert) { | 636 TEST_F(GLRendererTest, InitializationWithQuicklyLostContextDoesNotAssert) { |
| 637 auto context = base::MakeUnique<LoseContextOnFirstGetContext>(); |
| 638 auto provider = TestContextProvider::Create(std::move(context)); |
| 639 provider->BindToCurrentThread(); |
| 640 |
635 FakeOutputSurfaceClient output_surface_client; | 641 FakeOutputSurfaceClient output_surface_client; |
636 std::unique_ptr<OutputSurface> output_surface( | 642 std::unique_ptr<OutputSurface> output_surface( |
637 FakeOutputSurface::Create3d(std::unique_ptr<TestWebGraphicsContext3D>( | 643 FakeOutputSurface::Create3d(std::move(provider))); |
638 new LoseContextOnFirstGetContext))); | 644 output_surface->BindToClient(&output_surface_client); |
639 CHECK(output_surface->BindToClient(&output_surface_client)); | |
640 | 645 |
641 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager( | 646 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager( |
642 new TestSharedBitmapManager()); | 647 new TestSharedBitmapManager()); |
643 std::unique_ptr<ResourceProvider> resource_provider = | 648 std::unique_ptr<ResourceProvider> resource_provider = |
644 FakeResourceProvider::Create(output_surface->context_provider(), | 649 FakeResourceProvider::Create(output_surface->context_provider(), |
645 shared_bitmap_manager.get()); | 650 shared_bitmap_manager.get()); |
646 | 651 |
647 RendererSettings settings; | 652 RendererSettings settings; |
648 FakeRendererGL renderer(&settings, output_surface.get(), | 653 FakeRendererGL renderer(&settings, output_surface.get(), |
649 resource_provider.get()); | 654 resource_provider.get()); |
650 } | 655 } |
651 | 656 |
652 class ClearCountingContext : public TestWebGraphicsContext3D { | 657 class ClearCountingContext : public TestWebGraphicsContext3D { |
653 public: | 658 public: |
654 ClearCountingContext() { test_capabilities_.discard_framebuffer = true; } | 659 ClearCountingContext() { test_capabilities_.discard_framebuffer = true; } |
655 | 660 |
656 MOCK_METHOD3(discardFramebufferEXT, | 661 MOCK_METHOD3(discardFramebufferEXT, |
657 void(GLenum target, | 662 void(GLenum target, |
658 GLsizei numAttachments, | 663 GLsizei numAttachments, |
659 const GLenum* attachments)); | 664 const GLenum* attachments)); |
660 MOCK_METHOD1(clear, void(GLbitfield mask)); | 665 MOCK_METHOD1(clear, void(GLbitfield mask)); |
661 }; | 666 }; |
662 | 667 |
663 TEST_F(GLRendererTest, OpaqueBackground) { | 668 TEST_F(GLRendererTest, OpaqueBackground) { |
664 std::unique_ptr<ClearCountingContext> context_owned(new ClearCountingContext); | 669 std::unique_ptr<ClearCountingContext> context_owned(new ClearCountingContext); |
665 ClearCountingContext* context = context_owned.get(); | 670 ClearCountingContext* context = context_owned.get(); |
666 | 671 |
| 672 auto provider = TestContextProvider::Create(std::move(context_owned)); |
| 673 provider->BindToCurrentThread(); |
| 674 |
667 FakeOutputSurfaceClient output_surface_client; | 675 FakeOutputSurfaceClient output_surface_client; |
668 std::unique_ptr<OutputSurface> output_surface( | 676 std::unique_ptr<OutputSurface> output_surface( |
669 FakeOutputSurface::Create3d(std::move(context_owned))); | 677 FakeOutputSurface::Create3d(std::move(provider))); |
670 CHECK(output_surface->BindToClient(&output_surface_client)); | 678 output_surface->BindToClient(&output_surface_client); |
671 | 679 |
672 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager( | 680 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager( |
673 new TestSharedBitmapManager()); | 681 new TestSharedBitmapManager()); |
674 std::unique_ptr<ResourceProvider> resource_provider = | 682 std::unique_ptr<ResourceProvider> resource_provider = |
675 FakeResourceProvider::Create(output_surface->context_provider(), | 683 FakeResourceProvider::Create(output_surface->context_provider(), |
676 shared_bitmap_manager.get()); | 684 shared_bitmap_manager.get()); |
677 | 685 |
678 RendererSettings settings; | 686 RendererSettings settings; |
679 FakeRendererGL renderer(&settings, output_surface.get(), | 687 FakeRendererGL renderer(&settings, output_surface.get(), |
680 resource_provider.get()); | 688 resource_provider.get()); |
(...skipping 17 matching lines...) Expand all Loading... |
698 EXPECT_CALL(*context, clear(_)).Times(1); | 706 EXPECT_CALL(*context, clear(_)).Times(1); |
699 #endif | 707 #endif |
700 DrawFrame(&renderer, viewport_size); | 708 DrawFrame(&renderer, viewport_size); |
701 Mock::VerifyAndClearExpectations(context); | 709 Mock::VerifyAndClearExpectations(context); |
702 } | 710 } |
703 | 711 |
704 TEST_F(GLRendererTest, TransparentBackground) { | 712 TEST_F(GLRendererTest, TransparentBackground) { |
705 std::unique_ptr<ClearCountingContext> context_owned(new ClearCountingContext); | 713 std::unique_ptr<ClearCountingContext> context_owned(new ClearCountingContext); |
706 ClearCountingContext* context = context_owned.get(); | 714 ClearCountingContext* context = context_owned.get(); |
707 | 715 |
| 716 auto provider = TestContextProvider::Create(std::move(context_owned)); |
| 717 provider->BindToCurrentThread(); |
| 718 |
708 FakeOutputSurfaceClient output_surface_client; | 719 FakeOutputSurfaceClient output_surface_client; |
709 std::unique_ptr<OutputSurface> output_surface( | 720 std::unique_ptr<OutputSurface> output_surface( |
710 FakeOutputSurface::Create3d(std::move(context_owned))); | 721 FakeOutputSurface::Create3d(std::move(provider))); |
711 CHECK(output_surface->BindToClient(&output_surface_client)); | 722 output_surface->BindToClient(&output_surface_client); |
712 | 723 |
713 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager( | 724 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager( |
714 new TestSharedBitmapManager()); | 725 new TestSharedBitmapManager()); |
715 std::unique_ptr<ResourceProvider> resource_provider = | 726 std::unique_ptr<ResourceProvider> resource_provider = |
716 FakeResourceProvider::Create(output_surface->context_provider(), | 727 FakeResourceProvider::Create(output_surface->context_provider(), |
717 shared_bitmap_manager.get()); | 728 shared_bitmap_manager.get()); |
718 | 729 |
719 RendererSettings settings; | 730 RendererSettings settings; |
720 FakeRendererGL renderer(&settings, output_surface.get(), | 731 FakeRendererGL renderer(&settings, output_surface.get(), |
721 resource_provider.get()); | 732 resource_provider.get()); |
(...skipping 10 matching lines...) Expand all Loading... |
732 EXPECT_CALL(*context, clear(_)).Times(1); | 743 EXPECT_CALL(*context, clear(_)).Times(1); |
733 DrawFrame(&renderer, viewport_size); | 744 DrawFrame(&renderer, viewport_size); |
734 | 745 |
735 Mock::VerifyAndClearExpectations(context); | 746 Mock::VerifyAndClearExpectations(context); |
736 } | 747 } |
737 | 748 |
738 TEST_F(GLRendererTest, OffscreenOutputSurface) { | 749 TEST_F(GLRendererTest, OffscreenOutputSurface) { |
739 std::unique_ptr<ClearCountingContext> context_owned(new ClearCountingContext); | 750 std::unique_ptr<ClearCountingContext> context_owned(new ClearCountingContext); |
740 ClearCountingContext* context = context_owned.get(); | 751 ClearCountingContext* context = context_owned.get(); |
741 | 752 |
| 753 auto provider = TestContextProvider::Create(std::move(context_owned)); |
| 754 provider->BindToCurrentThread(); |
| 755 |
742 FakeOutputSurfaceClient output_surface_client; | 756 FakeOutputSurfaceClient output_surface_client; |
743 std::unique_ptr<OutputSurface> output_surface( | 757 std::unique_ptr<OutputSurface> output_surface( |
744 FakeOutputSurface::CreateOffscreen(std::move(context_owned))); | 758 FakeOutputSurface::CreateOffscreen(std::move(provider))); |
745 CHECK(output_surface->BindToClient(&output_surface_client)); | 759 output_surface->BindToClient(&output_surface_client); |
746 | 760 |
747 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager( | 761 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager( |
748 new TestSharedBitmapManager()); | 762 new TestSharedBitmapManager()); |
749 std::unique_ptr<ResourceProvider> resource_provider = | 763 std::unique_ptr<ResourceProvider> resource_provider = |
750 FakeResourceProvider::Create(output_surface->context_provider(), | 764 FakeResourceProvider::Create(output_surface->context_provider(), |
751 shared_bitmap_manager.get()); | 765 shared_bitmap_manager.get()); |
752 | 766 |
753 RendererSettings settings; | 767 RendererSettings settings; |
754 FakeRendererGL renderer(&settings, output_surface.get(), | 768 FakeRendererGL renderer(&settings, output_surface.get(), |
755 resource_provider.get()); | 769 resource_provider.get()); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 | 802 |
789 private: | 803 private: |
790 GLenum active_texture_; | 804 GLenum active_texture_; |
791 }; | 805 }; |
792 | 806 |
793 TEST_F(GLRendererTest, ActiveTextureState) { | 807 TEST_F(GLRendererTest, ActiveTextureState) { |
794 std::unique_ptr<TextureStateTrackingContext> context_owned( | 808 std::unique_ptr<TextureStateTrackingContext> context_owned( |
795 new TextureStateTrackingContext); | 809 new TextureStateTrackingContext); |
796 TextureStateTrackingContext* context = context_owned.get(); | 810 TextureStateTrackingContext* context = context_owned.get(); |
797 | 811 |
| 812 auto provider = TestContextProvider::Create(std::move(context_owned)); |
| 813 provider->BindToCurrentThread(); |
| 814 |
798 FakeOutputSurfaceClient output_surface_client; | 815 FakeOutputSurfaceClient output_surface_client; |
799 std::unique_ptr<OutputSurface> output_surface( | 816 std::unique_ptr<OutputSurface> output_surface( |
800 FakeOutputSurface::Create3d(std::move(context_owned))); | 817 FakeOutputSurface::Create3d(std::move(provider))); |
801 CHECK(output_surface->BindToClient(&output_surface_client)); | 818 output_surface->BindToClient(&output_surface_client); |
802 | 819 |
803 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager( | 820 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager( |
804 new TestSharedBitmapManager()); | 821 new TestSharedBitmapManager()); |
805 std::unique_ptr<ResourceProvider> resource_provider = | 822 std::unique_ptr<ResourceProvider> resource_provider = |
806 FakeResourceProvider::Create(output_surface->context_provider(), | 823 FakeResourceProvider::Create(output_surface->context_provider(), |
807 shared_bitmap_manager.get()); | 824 shared_bitmap_manager.get()); |
808 | 825 |
809 RendererSettings settings; | 826 RendererSettings settings; |
810 FakeRendererGL renderer(&settings, output_surface.get(), | 827 FakeRendererGL renderer(&settings, output_surface.get(), |
811 resource_provider.get()); | 828 resource_provider.get()); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
869 MOCK_METHOD1(clear, void(GLbitfield mask)); | 886 MOCK_METHOD1(clear, void(GLbitfield mask)); |
870 MOCK_METHOD4(drawElements, | 887 MOCK_METHOD4(drawElements, |
871 void(GLenum mode, GLsizei count, GLenum type, GLintptr offset)); | 888 void(GLenum mode, GLsizei count, GLenum type, GLintptr offset)); |
872 }; | 889 }; |
873 | 890 |
874 TEST_F(GLRendererTest, ShouldClearRootRenderPass) { | 891 TEST_F(GLRendererTest, ShouldClearRootRenderPass) { |
875 std::unique_ptr<NoClearRootRenderPassMockContext> mock_context_owned( | 892 std::unique_ptr<NoClearRootRenderPassMockContext> mock_context_owned( |
876 new NoClearRootRenderPassMockContext); | 893 new NoClearRootRenderPassMockContext); |
877 NoClearRootRenderPassMockContext* mock_context = mock_context_owned.get(); | 894 NoClearRootRenderPassMockContext* mock_context = mock_context_owned.get(); |
878 | 895 |
| 896 auto provider = TestContextProvider::Create(std::move(mock_context_owned)); |
| 897 provider->BindToCurrentThread(); |
| 898 |
879 FakeOutputSurfaceClient output_surface_client; | 899 FakeOutputSurfaceClient output_surface_client; |
880 std::unique_ptr<OutputSurface> output_surface( | 900 std::unique_ptr<OutputSurface> output_surface( |
881 FakeOutputSurface::Create3d(std::move(mock_context_owned))); | 901 FakeOutputSurface::Create3d(std::move(provider))); |
882 CHECK(output_surface->BindToClient(&output_surface_client)); | 902 output_surface->BindToClient(&output_surface_client); |
883 | 903 |
884 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager( | 904 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager( |
885 new TestSharedBitmapManager()); | 905 new TestSharedBitmapManager()); |
886 std::unique_ptr<ResourceProvider> resource_provider = | 906 std::unique_ptr<ResourceProvider> resource_provider = |
887 FakeResourceProvider::Create(output_surface->context_provider(), | 907 FakeResourceProvider::Create(output_surface->context_provider(), |
888 shared_bitmap_manager.get()); | 908 shared_bitmap_manager.get()); |
889 | 909 |
890 RendererSettings settings; | 910 RendererSettings settings; |
891 settings.should_clear_root_render_pass = false; | 911 settings.should_clear_root_render_pass = false; |
892 | 912 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 scissor_enabled_ = false; | 974 scissor_enabled_ = false; |
955 } | 975 } |
956 | 976 |
957 private: | 977 private: |
958 bool scissor_enabled_ = false; | 978 bool scissor_enabled_ = false; |
959 }; | 979 }; |
960 | 980 |
961 TEST_F(GLRendererTest, ScissorTestWhenClearing) { | 981 TEST_F(GLRendererTest, ScissorTestWhenClearing) { |
962 auto gl_owned = base::MakeUnique<ScissorTestOnClearCheckingGLES2Interface>(); | 982 auto gl_owned = base::MakeUnique<ScissorTestOnClearCheckingGLES2Interface>(); |
963 | 983 |
| 984 auto provider = TestContextProvider::Create(std::move(gl_owned)); |
| 985 provider->BindToCurrentThread(); |
| 986 |
964 FakeOutputSurfaceClient output_surface_client; | 987 FakeOutputSurfaceClient output_surface_client; |
965 std::unique_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 988 std::unique_ptr<OutputSurface> output_surface( |
966 TestContextProvider::Create(std::move(gl_owned)))); | 989 FakeOutputSurface::Create3d(std::move(provider))); |
967 CHECK(output_surface->BindToClient(&output_surface_client)); | 990 output_surface->BindToClient(&output_surface_client); |
968 | 991 |
969 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager( | 992 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager( |
970 new TestSharedBitmapManager()); | 993 new TestSharedBitmapManager()); |
971 std::unique_ptr<ResourceProvider> resource_provider = | 994 std::unique_ptr<ResourceProvider> resource_provider = |
972 FakeResourceProvider::Create(output_surface->context_provider(), | 995 FakeResourceProvider::Create(output_surface->context_provider(), |
973 shared_bitmap_manager.get()); | 996 shared_bitmap_manager.get()); |
974 | 997 |
975 RendererSettings settings; | 998 RendererSettings settings; |
976 FakeRendererGL renderer(&settings, output_surface.get(), | 999 FakeRendererGL renderer(&settings, output_surface.get(), |
977 resource_provider.get()); | 1000 resource_provider.get()); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1027 void reset_discarded() { discarded_ = 0; } | 1050 void reset_discarded() { discarded_ = 0; } |
1028 | 1051 |
1029 private: | 1052 private: |
1030 int discarded_ = 0; | 1053 int discarded_ = 0; |
1031 }; | 1054 }; |
1032 | 1055 |
1033 TEST_F(GLRendererTest, NoDiscardOnPartialUpdates) { | 1056 TEST_F(GLRendererTest, NoDiscardOnPartialUpdates) { |
1034 auto gl_owned = base::MakeUnique<DiscardCheckingGLES2Interface>(); | 1057 auto gl_owned = base::MakeUnique<DiscardCheckingGLES2Interface>(); |
1035 auto* gl = gl_owned.get(); | 1058 auto* gl = gl_owned.get(); |
1036 | 1059 |
| 1060 auto provider = TestContextProvider::Create(std::move(gl_owned)); |
| 1061 provider->BindToCurrentThread(); |
| 1062 |
1037 FakeOutputSurfaceClient output_surface_client; | 1063 FakeOutputSurfaceClient output_surface_client; |
1038 auto output_surface = FakeOutputSurface::Create3d(std::move(gl_owned)); | 1064 auto output_surface = FakeOutputSurface::Create3d(std::move(provider)); |
1039 CHECK(output_surface->BindToClient(&output_surface_client)); | 1065 output_surface->BindToClient(&output_surface_client); |
1040 | 1066 |
1041 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager( | 1067 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager( |
1042 new TestSharedBitmapManager()); | 1068 new TestSharedBitmapManager()); |
1043 std::unique_ptr<ResourceProvider> resource_provider = | 1069 std::unique_ptr<ResourceProvider> resource_provider = |
1044 FakeResourceProvider::Create(output_surface->context_provider(), | 1070 FakeResourceProvider::Create(output_surface->context_provider(), |
1045 shared_bitmap_manager.get()); | 1071 shared_bitmap_manager.get()); |
1046 | 1072 |
1047 RendererSettings settings; | 1073 RendererSettings settings; |
1048 settings.partial_swap_enabled = true; | 1074 settings.partial_swap_enabled = true; |
1049 FakeRendererGL renderer(&settings, output_surface.get(), | 1075 FakeRendererGL renderer(&settings, output_surface.get(), |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1108 }; | 1134 }; |
1109 | 1135 |
1110 TEST_F(GLRendererTest, DrawFramePreservesFramebuffer) { | 1136 TEST_F(GLRendererTest, DrawFramePreservesFramebuffer) { |
1111 // When using render-to-FBO to display the surface, all rendering is done | 1137 // When using render-to-FBO to display the surface, all rendering is done |
1112 // to a non-zero FBO. Make sure that the framebuffer is always restored to | 1138 // to a non-zero FBO. Make sure that the framebuffer is always restored to |
1113 // the correct framebuffer during rendering, if changed. | 1139 // the correct framebuffer during rendering, if changed. |
1114 // Note: there is one path that will set it to 0, but that is after the render | 1140 // Note: there is one path that will set it to 0, but that is after the render |
1115 // has finished. | 1141 // has finished. |
1116 FakeOutputSurfaceClient output_surface_client; | 1142 FakeOutputSurfaceClient output_surface_client; |
1117 std::unique_ptr<FakeOutputSurface> output_surface( | 1143 std::unique_ptr<FakeOutputSurface> output_surface( |
1118 FakeOutputSurface::Create3d(TestWebGraphicsContext3D::Create())); | 1144 FakeOutputSurface::Create3d()); |
1119 CHECK(output_surface->BindToClient(&output_surface_client)); | 1145 output_surface->BindToClient(&output_surface_client); |
1120 | 1146 |
1121 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager( | 1147 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager( |
1122 new TestSharedBitmapManager()); | 1148 new TestSharedBitmapManager()); |
1123 std::unique_ptr<ResourceProvider> resource_provider = | 1149 std::unique_ptr<ResourceProvider> resource_provider = |
1124 FakeResourceProvider::Create(output_surface->context_provider(), | 1150 FakeResourceProvider::Create(output_surface->context_provider(), |
1125 shared_bitmap_manager.get()); | 1151 shared_bitmap_manager.get()); |
1126 | 1152 |
1127 RendererSettings settings; | 1153 RendererSettings settings; |
1128 FakeRendererGL renderer(&settings, output_surface.get(), | 1154 FakeRendererGL renderer(&settings, output_surface.get(), |
1129 resource_provider.get()); | 1155 resource_provider.get()); |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1446 // through the OutputSurface abstraction. | 1472 // through the OutputSurface abstraction. |
1447 MOCK_METHOD2(bindFramebuffer, void(GLenum target, GLuint framebuffer)); | 1473 MOCK_METHOD2(bindFramebuffer, void(GLenum target, GLuint framebuffer)); |
1448 MOCK_METHOD3(reshapeWithScaleFactor, | 1474 MOCK_METHOD3(reshapeWithScaleFactor, |
1449 void(int width, int height, float scale_factor)); | 1475 void(int width, int height, float scale_factor)); |
1450 MOCK_METHOD4(drawElements, | 1476 MOCK_METHOD4(drawElements, |
1451 void(GLenum mode, GLsizei count, GLenum type, GLintptr offset)); | 1477 void(GLenum mode, GLsizei count, GLenum type, GLintptr offset)); |
1452 }; | 1478 }; |
1453 | 1479 |
1454 class MockOutputSurface : public OutputSurface { | 1480 class MockOutputSurface : public OutputSurface { |
1455 public: | 1481 public: |
1456 MockOutputSurface() | 1482 explicit MockOutputSurface(scoped_refptr<ContextProvider> provider) |
1457 : OutputSurface(TestContextProvider::Create( | 1483 : OutputSurface(std::move(provider)) {} |
1458 base::MakeUnique<StrictMock<OutputSurfaceMockContext>>())) {} | |
1459 virtual ~MockOutputSurface() {} | 1484 virtual ~MockOutputSurface() {} |
1460 | 1485 |
| 1486 void BindToClient(OutputSurfaceClient*) override {} |
| 1487 |
1461 MOCK_METHOD0(EnsureBackbuffer, void()); | 1488 MOCK_METHOD0(EnsureBackbuffer, void()); |
1462 MOCK_METHOD0(DiscardBackbuffer, void()); | 1489 MOCK_METHOD0(DiscardBackbuffer, void()); |
1463 MOCK_METHOD4(Reshape, | 1490 MOCK_METHOD4(Reshape, |
1464 void(const gfx::Size& size, | 1491 void(const gfx::Size& size, |
1465 float scale_factor, | 1492 float scale_factor, |
1466 const gfx::ColorSpace& color_space, | 1493 const gfx::ColorSpace& color_space, |
1467 bool has_alpha)); | 1494 bool has_alpha)); |
1468 MOCK_METHOD0(BindFramebuffer, void()); | 1495 MOCK_METHOD0(BindFramebuffer, void()); |
1469 MOCK_METHOD0(GetFramebufferCopyTextureFormat, GLenum()); | 1496 MOCK_METHOD0(GetFramebufferCopyTextureFormat, GLenum()); |
1470 MOCK_METHOD1(SwapBuffers_, void(OutputSurfaceFrame& frame)); // NOLINT | 1497 MOCK_METHOD1(SwapBuffers_, void(OutputSurfaceFrame& frame)); // NOLINT |
1471 void SwapBuffers(OutputSurfaceFrame frame) override { SwapBuffers_(frame); } | 1498 void SwapBuffers(OutputSurfaceFrame frame) override { SwapBuffers_(frame); } |
1472 MOCK_CONST_METHOD0(GetOverlayCandidateValidator, | 1499 MOCK_CONST_METHOD0(GetOverlayCandidateValidator, |
1473 OverlayCandidateValidator*()); | 1500 OverlayCandidateValidator*()); |
1474 MOCK_CONST_METHOD0(IsDisplayedAsOverlayPlane, bool()); | 1501 MOCK_CONST_METHOD0(IsDisplayedAsOverlayPlane, bool()); |
1475 MOCK_CONST_METHOD0(GetOverlayTextureId, unsigned()); | 1502 MOCK_CONST_METHOD0(GetOverlayTextureId, unsigned()); |
1476 MOCK_CONST_METHOD0(SurfaceIsSuspendForRecycle, bool()); | 1503 MOCK_CONST_METHOD0(SurfaceIsSuspendForRecycle, bool()); |
1477 MOCK_CONST_METHOD0(HasExternalStencilTest, bool()); | 1504 MOCK_CONST_METHOD0(HasExternalStencilTest, bool()); |
1478 MOCK_METHOD0(ApplyExternalStencil, void()); | 1505 MOCK_METHOD0(ApplyExternalStencil, void()); |
1479 }; | 1506 }; |
1480 | 1507 |
1481 class MockOutputSurfaceTest : public GLRendererTest { | 1508 class MockOutputSurfaceTest : public GLRendererTest { |
1482 protected: | 1509 protected: |
1483 virtual void SetUp() { | 1510 void SetUp() override { |
| 1511 auto context = base::MakeUnique<StrictMock<OutputSurfaceMockContext>>(); |
| 1512 context_ = context.get(); |
| 1513 auto provider = TestContextProvider::Create(std::move(context)); |
| 1514 provider->BindToCurrentThread(); |
| 1515 output_surface_ = |
| 1516 base::MakeUnique<StrictMock<MockOutputSurface>>(std::move(provider)); |
| 1517 |
1484 FakeOutputSurfaceClient output_surface_client_; | 1518 FakeOutputSurfaceClient output_surface_client_; |
1485 CHECK(output_surface_.BindToClient(&output_surface_client_)); | 1519 output_surface_->BindToClient(&output_surface_client_); |
1486 | 1520 |
1487 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); | 1521 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); |
1488 resource_provider_ = FakeResourceProvider::Create( | 1522 resource_provider_ = FakeResourceProvider::Create( |
1489 output_surface_.context_provider(), shared_bitmap_manager_.get()); | 1523 output_surface_->context_provider(), shared_bitmap_manager_.get()); |
1490 | 1524 |
1491 renderer_.reset(new FakeRendererGL(&settings_, &output_surface_, | 1525 renderer_.reset(new FakeRendererGL(&settings_, output_surface_.get(), |
1492 resource_provider_.get())); | 1526 resource_provider_.get())); |
1493 EXPECT_CALL(output_surface_, GetOverlayCandidateValidator()).Times(1); | 1527 EXPECT_CALL(*output_surface_, GetOverlayCandidateValidator()).Times(1); |
1494 renderer_->Initialize(); | 1528 renderer_->Initialize(); |
1495 | 1529 |
1496 EXPECT_CALL(output_surface_, EnsureBackbuffer()).Times(1); | 1530 EXPECT_CALL(*output_surface_, EnsureBackbuffer()).Times(1); |
1497 renderer_->SetVisible(true); | 1531 renderer_->SetVisible(true); |
1498 Mock::VerifyAndClearExpectations(&output_surface_); | 1532 Mock::VerifyAndClearExpectations(output_surface_.get()); |
1499 } | 1533 } |
1500 | 1534 |
1501 void SwapBuffers() { renderer_->SwapBuffers(std::vector<ui::LatencyInfo>()); } | 1535 void SwapBuffers() { renderer_->SwapBuffers(std::vector<ui::LatencyInfo>()); } |
1502 | 1536 |
1503 void DrawFrame(float device_scale_factor, | 1537 void DrawFrame(float device_scale_factor, |
1504 const gfx::Size& viewport_size, | 1538 const gfx::Size& viewport_size, |
1505 bool transparent) { | 1539 bool transparent) { |
1506 RenderPassId render_pass_id(1, 0); | 1540 RenderPassId render_pass_id(1, 0); |
1507 RenderPass* render_pass = | 1541 RenderPass* render_pass = |
1508 AddRenderPass(&render_passes_in_draw_order_, render_pass_id, | 1542 AddRenderPass(&render_passes_in_draw_order_, render_pass_id, |
1509 gfx::Rect(viewport_size), gfx::Transform()); | 1543 gfx::Rect(viewport_size), gfx::Transform()); |
1510 AddQuad(render_pass, gfx::Rect(viewport_size), SK_ColorGREEN); | 1544 AddQuad(render_pass, gfx::Rect(viewport_size), SK_ColorGREEN); |
1511 render_pass->has_transparent_background = transparent; | 1545 render_pass->has_transparent_background = transparent; |
1512 | 1546 |
1513 EXPECT_CALL(output_surface_, EnsureBackbuffer()).WillRepeatedly(Return()); | 1547 EXPECT_CALL(*output_surface_, EnsureBackbuffer()).WillRepeatedly(Return()); |
1514 | 1548 |
1515 EXPECT_CALL(output_surface_, | 1549 EXPECT_CALL(*output_surface_, |
1516 Reshape(viewport_size, device_scale_factor, _, transparent)) | 1550 Reshape(viewport_size, device_scale_factor, _, transparent)) |
1517 .Times(1); | 1551 .Times(1); |
1518 | 1552 |
1519 EXPECT_CALL(output_surface_, BindFramebuffer()).Times(1); | 1553 EXPECT_CALL(*output_surface_, BindFramebuffer()).Times(1); |
1520 | 1554 |
1521 EXPECT_CALL(*Context(), drawElements(_, _, _, _)).Times(1); | 1555 EXPECT_CALL(*context_, drawElements(_, _, _, _)).Times(1); |
1522 | 1556 |
1523 renderer_->DecideRenderPassAllocationsForFrame( | 1557 renderer_->DecideRenderPassAllocationsForFrame( |
1524 render_passes_in_draw_order_); | 1558 render_passes_in_draw_order_); |
1525 renderer_->DrawFrame(&render_passes_in_draw_order_, device_scale_factor, | 1559 renderer_->DrawFrame(&render_passes_in_draw_order_, device_scale_factor, |
1526 gfx::ColorSpace(), viewport_size); | 1560 gfx::ColorSpace(), viewport_size); |
1527 } | 1561 } |
1528 | 1562 |
1529 OutputSurfaceMockContext* Context() { | |
1530 return static_cast<OutputSurfaceMockContext*>( | |
1531 static_cast<TestContextProvider*>(output_surface_.context_provider()) | |
1532 ->TestContext3d()); | |
1533 } | |
1534 | |
1535 RendererSettings settings_; | 1563 RendererSettings settings_; |
1536 FakeOutputSurfaceClient output_surface_client_; | 1564 FakeOutputSurfaceClient output_surface_client_; |
1537 StrictMock<MockOutputSurface> output_surface_; | 1565 OutputSurfaceMockContext* context_ = nullptr; |
| 1566 std::unique_ptr<StrictMock<MockOutputSurface>> output_surface_; |
1538 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager_; | 1567 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager_; |
1539 std::unique_ptr<ResourceProvider> resource_provider_; | 1568 std::unique_ptr<ResourceProvider> resource_provider_; |
1540 std::unique_ptr<FakeRendererGL> renderer_; | 1569 std::unique_ptr<FakeRendererGL> renderer_; |
1541 }; | 1570 }; |
1542 | 1571 |
1543 TEST_F(MockOutputSurfaceTest, BackbufferDiscard) { | 1572 TEST_F(MockOutputSurfaceTest, BackbufferDiscard) { |
1544 // Drop backbuffer on hide. | 1573 // Drop backbuffer on hide. |
1545 EXPECT_CALL(output_surface_, DiscardBackbuffer()).Times(1); | 1574 EXPECT_CALL(*output_surface_, DiscardBackbuffer()).Times(1); |
1546 renderer_->SetVisible(false); | 1575 renderer_->SetVisible(false); |
1547 Mock::VerifyAndClearExpectations(&output_surface_); | 1576 Mock::VerifyAndClearExpectations(output_surface_.get()); |
1548 | 1577 |
1549 // Restore backbuffer on show. | 1578 // Restore backbuffer on show. |
1550 EXPECT_CALL(output_surface_, EnsureBackbuffer()).Times(1); | 1579 EXPECT_CALL(*output_surface_, EnsureBackbuffer()).Times(1); |
1551 renderer_->SetVisible(true); | 1580 renderer_->SetVisible(true); |
1552 Mock::VerifyAndClearExpectations(&output_surface_); | 1581 Mock::VerifyAndClearExpectations(output_surface_.get()); |
1553 } | 1582 } |
1554 | 1583 |
1555 class TestOverlayProcessor : public OverlayProcessor { | 1584 class TestOverlayProcessor : public OverlayProcessor { |
1556 public: | 1585 public: |
1557 class Strategy : public OverlayProcessor::Strategy { | 1586 class Strategy : public OverlayProcessor::Strategy { |
1558 public: | 1587 public: |
1559 Strategy() {} | 1588 Strategy() {} |
1560 ~Strategy() override {} | 1589 ~Strategy() override {} |
1561 MOCK_METHOD3(Attempt, | 1590 MOCK_METHOD3(Attempt, |
1562 bool(ResourceProvider* resource_provider, | 1591 bool(ResourceProvider* resource_provider, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1594 void MailboxReleased(const gpu::SyncToken& sync_token, | 1623 void MailboxReleased(const gpu::SyncToken& sync_token, |
1595 bool lost_resource, | 1624 bool lost_resource, |
1596 BlockingTaskRunner* main_thread_task_runner) {} | 1625 BlockingTaskRunner* main_thread_task_runner) {} |
1597 | 1626 |
1598 void IgnoreCopyResult(std::unique_ptr<CopyOutputResult> result) {} | 1627 void IgnoreCopyResult(std::unique_ptr<CopyOutputResult> result) {} |
1599 | 1628 |
1600 TEST_F(GLRendererTest, DontOverlayWithCopyRequests) { | 1629 TEST_F(GLRendererTest, DontOverlayWithCopyRequests) { |
1601 FakeOutputSurfaceClient output_surface_client; | 1630 FakeOutputSurfaceClient output_surface_client; |
1602 std::unique_ptr<FakeOutputSurface> output_surface( | 1631 std::unique_ptr<FakeOutputSurface> output_surface( |
1603 FakeOutputSurface::Create3d()); | 1632 FakeOutputSurface::Create3d()); |
1604 CHECK(output_surface->BindToClient(&output_surface_client)); | 1633 output_surface->BindToClient(&output_surface_client); |
1605 | 1634 |
1606 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager( | 1635 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager( |
1607 new TestSharedBitmapManager()); | 1636 new TestSharedBitmapManager()); |
1608 std::unique_ptr<ResourceProvider> resource_provider = | 1637 std::unique_ptr<ResourceProvider> resource_provider = |
1609 FakeResourceProvider::Create(output_surface->context_provider(), | 1638 FakeResourceProvider::Create(output_surface->context_provider(), |
1610 shared_bitmap_manager.get()); | 1639 shared_bitmap_manager.get()); |
1611 std::unique_ptr<TextureMailboxDeleter> mailbox_deleter( | 1640 std::unique_ptr<TextureMailboxDeleter> mailbox_deleter( |
1612 new TextureMailboxDeleter(base::ThreadTaskRunnerHandle::Get())); | 1641 new TextureMailboxDeleter(base::ThreadTaskRunnerHandle::Get())); |
1613 | 1642 |
1614 RendererSettings settings; | 1643 RendererSettings settings; |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1742 unsigned overlay_texture_id, | 1771 unsigned overlay_texture_id, |
1743 const gfx::Rect& display_bounds, | 1772 const gfx::Rect& display_bounds, |
1744 const gfx::RectF& uv_rect)); | 1773 const gfx::RectF& uv_rect)); |
1745 }; | 1774 }; |
1746 | 1775 |
1747 TEST_F(GLRendererTest, OverlaySyncTokensAreProcessed) { | 1776 TEST_F(GLRendererTest, OverlaySyncTokensAreProcessed) { |
1748 std::unique_ptr<WaitSyncTokenCountingContext> context_owned( | 1777 std::unique_ptr<WaitSyncTokenCountingContext> context_owned( |
1749 new WaitSyncTokenCountingContext); | 1778 new WaitSyncTokenCountingContext); |
1750 WaitSyncTokenCountingContext* context = context_owned.get(); | 1779 WaitSyncTokenCountingContext* context = context_owned.get(); |
1751 | 1780 |
| 1781 auto provider = TestContextProvider::Create(std::move(context_owned)); |
| 1782 provider->BindToCurrentThread(); |
| 1783 |
1752 MockOverlayScheduler overlay_scheduler; | 1784 MockOverlayScheduler overlay_scheduler; |
1753 scoped_refptr<TestContextProvider> context_provider = | 1785 provider->support()->SetScheduleOverlayPlaneCallback(base::Bind( |
1754 TestContextProvider::Create(std::move(context_owned)); | |
1755 context_provider->support()->SetScheduleOverlayPlaneCallback(base::Bind( | |
1756 &MockOverlayScheduler::Schedule, base::Unretained(&overlay_scheduler))); | 1786 &MockOverlayScheduler::Schedule, base::Unretained(&overlay_scheduler))); |
1757 | 1787 |
1758 FakeOutputSurfaceClient output_surface_client; | 1788 FakeOutputSurfaceClient output_surface_client; |
1759 std::unique_ptr<OutputSurface> output_surface( | 1789 std::unique_ptr<OutputSurface> output_surface( |
1760 FakeOutputSurface::Create3d(context_provider)); | 1790 FakeOutputSurface::Create3d(std::move(provider))); |
1761 CHECK(output_surface->BindToClient(&output_surface_client)); | 1791 output_surface->BindToClient(&output_surface_client); |
1762 | 1792 |
1763 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager( | 1793 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager( |
1764 new TestSharedBitmapManager()); | 1794 new TestSharedBitmapManager()); |
1765 std::unique_ptr<ResourceProvider> resource_provider = | 1795 std::unique_ptr<ResourceProvider> resource_provider = |
1766 FakeResourceProvider::Create(output_surface->context_provider(), | 1796 FakeResourceProvider::Create(output_surface->context_provider(), |
1767 shared_bitmap_manager.get()); | 1797 shared_bitmap_manager.get()); |
1768 std::unique_ptr<TextureMailboxDeleter> mailbox_deleter( | 1798 std::unique_ptr<TextureMailboxDeleter> mailbox_deleter( |
1769 new TextureMailboxDeleter(base::ThreadTaskRunnerHandle::Get())); | 1799 new TextureMailboxDeleter(base::ThreadTaskRunnerHandle::Get())); |
1770 | 1800 |
1771 RendererSettings settings; | 1801 RendererSettings settings; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1835 MOCK_METHOD1(Disable, void(GLenum cap)); | 1865 MOCK_METHOD1(Disable, void(GLenum cap)); |
1836 MOCK_METHOD4(Scissor, void(GLint x, GLint y, GLsizei width, GLsizei height)); | 1866 MOCK_METHOD4(Scissor, void(GLint x, GLint y, GLsizei width, GLsizei height)); |
1837 }; | 1867 }; |
1838 | 1868 |
1839 class GLRendererPartialSwapTest : public GLRendererTest { | 1869 class GLRendererPartialSwapTest : public GLRendererTest { |
1840 protected: | 1870 protected: |
1841 void RunTest(bool partial_swap) { | 1871 void RunTest(bool partial_swap) { |
1842 auto gl_owned = base::MakeUnique<PartialSwapMockGLES2Interface>(); | 1872 auto gl_owned = base::MakeUnique<PartialSwapMockGLES2Interface>(); |
1843 auto* gl = gl_owned.get(); | 1873 auto* gl = gl_owned.get(); |
1844 | 1874 |
| 1875 auto provider = TestContextProvider::Create(std::move(gl_owned)); |
| 1876 provider->BindToCurrentThread(); |
| 1877 |
1845 FakeOutputSurfaceClient output_surface_client; | 1878 FakeOutputSurfaceClient output_surface_client; |
1846 std::unique_ptr<FakeOutputSurface> output_surface( | 1879 std::unique_ptr<FakeOutputSurface> output_surface( |
1847 FakeOutputSurface::Create3d(std::move(gl_owned))); | 1880 FakeOutputSurface::Create3d(std::move(provider))); |
1848 CHECK(output_surface->BindToClient(&output_surface_client)); | 1881 output_surface->BindToClient(&output_surface_client); |
1849 | 1882 |
1850 std::unique_ptr<ResourceProvider> resource_provider = | 1883 std::unique_ptr<ResourceProvider> resource_provider = |
1851 FakeResourceProvider::Create(output_surface->context_provider(), | 1884 FakeResourceProvider::Create(output_surface->context_provider(), |
1852 nullptr); | 1885 nullptr); |
1853 | 1886 |
1854 RendererSettings settings; | 1887 RendererSettings settings; |
1855 settings.partial_swap_enabled = partial_swap; | 1888 settings.partial_swap_enabled = partial_swap; |
1856 FakeRendererGL renderer(&settings, output_surface.get(), | 1889 FakeRendererGL renderer(&settings, output_surface.get(), |
1857 resource_provider.get()); | 1890 resource_provider.get()); |
1858 renderer.Initialize(); | 1891 renderer.Initialize(); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1916 MockContextSupport() {} | 1949 MockContextSupport() {} |
1917 MOCK_METHOD1(SetAggressivelyFreeResources, | 1950 MOCK_METHOD1(SetAggressivelyFreeResources, |
1918 void(bool aggressively_free_resources)); | 1951 void(bool aggressively_free_resources)); |
1919 }; | 1952 }; |
1920 | 1953 |
1921 void SetUp() override { | 1954 void SetUp() override { |
1922 auto context_support = base::MakeUnique<MockContextSupport>(); | 1955 auto context_support = base::MakeUnique<MockContextSupport>(); |
1923 context_support_ptr_ = context_support.get(); | 1956 context_support_ptr_ = context_support.get(); |
1924 auto context_provider = TestContextProvider::Create( | 1957 auto context_provider = TestContextProvider::Create( |
1925 TestWebGraphicsContext3D::Create(), std::move(context_support)); | 1958 TestWebGraphicsContext3D::Create(), std::move(context_support)); |
| 1959 context_provider->BindToCurrentThread(); |
1926 output_surface_ = FakeOutputSurface::Create3d(std::move(context_provider)); | 1960 output_surface_ = FakeOutputSurface::Create3d(std::move(context_provider)); |
1927 output_surface_->BindToClient(&output_surface_client_); | 1961 output_surface_->BindToClient(&output_surface_client_); |
1928 resource_provider_ = FakeResourceProvider::Create( | 1962 resource_provider_ = FakeResourceProvider::Create( |
1929 output_surface_->context_provider(), nullptr); | 1963 output_surface_->context_provider(), nullptr); |
1930 renderer_ = | 1964 renderer_ = |
1931 base::MakeUnique<GLRenderer>(&settings_, output_surface_.get(), | 1965 base::MakeUnique<GLRenderer>(&settings_, output_surface_.get(), |
1932 resource_provider_.get(), nullptr, 0); | 1966 resource_provider_.get(), nullptr, 0); |
1933 renderer_->Initialize(); | 1967 renderer_->Initialize(); |
1934 } | 1968 } |
1935 | 1969 |
(...skipping 11 matching lines...) Expand all Loading... |
1947 renderer_->SetVisible(true); | 1981 renderer_->SetVisible(true); |
1948 Mock::VerifyAndClearExpectations(context_support_ptr_); | 1982 Mock::VerifyAndClearExpectations(context_support_ptr_); |
1949 | 1983 |
1950 EXPECT_CALL(*context_support_ptr_, SetAggressivelyFreeResources(true)); | 1984 EXPECT_CALL(*context_support_ptr_, SetAggressivelyFreeResources(true)); |
1951 renderer_->SetVisible(false); | 1985 renderer_->SetVisible(false); |
1952 Mock::VerifyAndClearExpectations(context_support_ptr_); | 1986 Mock::VerifyAndClearExpectations(context_support_ptr_); |
1953 } | 1987 } |
1954 | 1988 |
1955 } // namespace | 1989 } // namespace |
1956 } // namespace cc | 1990 } // namespace cc |
OLD | NEW |