Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: cc/output/gl_renderer_unittest.cc

Issue 1866203004: Convert //cc from scoped_ptr to std::unique_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptrcc: rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/output/gl_renderer.cc ('k') | cc/output/output_surface.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 10
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/memory/ptr_util.h"
12 #include "base/single_thread_task_runner.h" 13 #include "base/single_thread_task_runner.h"
13 #include "base/thread_task_runner_handle.h" 14 #include "base/thread_task_runner_handle.h"
14 #include "cc/base/math_util.h" 15 #include "cc/base/math_util.h"
15 #include "cc/output/compositor_frame_metadata.h" 16 #include "cc/output/compositor_frame_metadata.h"
16 #include "cc/output/copy_output_request.h" 17 #include "cc/output/copy_output_request.h"
17 #include "cc/output/copy_output_result.h" 18 #include "cc/output/copy_output_result.h"
18 #include "cc/output/overlay_strategy_single_on_top.h" 19 #include "cc/output/overlay_strategy_single_on_top.h"
19 #include "cc/output/overlay_strategy_underlay.h" 20 #include "cc/output/overlay_strategy_underlay.h"
20 #include "cc/output/texture_mailbox_deleter.h" 21 #include "cc/output/texture_mailbox_deleter.h"
21 #include "cc/quads/texture_draw_quad.h" 22 #include "cc/quads/texture_draw_quad.h"
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 class GLRendererWithDefaultHarnessTest : public GLRendererTest { 340 class GLRendererWithDefaultHarnessTest : public GLRendererTest {
340 protected: 341 protected:
341 GLRendererWithDefaultHarnessTest() { 342 GLRendererWithDefaultHarnessTest() {
342 output_surface_ = 343 output_surface_ =
343 FakeOutputSurface::Create3d(TestWebGraphicsContext3D::Create()); 344 FakeOutputSurface::Create3d(TestWebGraphicsContext3D::Create());
344 CHECK(output_surface_->BindToClient(&output_surface_client_)); 345 CHECK(output_surface_->BindToClient(&output_surface_client_));
345 346
346 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); 347 shared_bitmap_manager_.reset(new TestSharedBitmapManager());
347 resource_provider_ = FakeResourceProvider::Create( 348 resource_provider_ = FakeResourceProvider::Create(
348 output_surface_.get(), shared_bitmap_manager_.get()); 349 output_surface_.get(), shared_bitmap_manager_.get());
349 renderer_ = make_scoped_ptr(new FakeRendererGL(&renderer_client_, 350 renderer_ = base::WrapUnique(
350 &settings_, 351 new FakeRendererGL(&renderer_client_, &settings_, output_surface_.get(),
351 output_surface_.get(), 352 resource_provider_.get()));
352 resource_provider_.get()));
353 } 353 }
354 354
355 void SwapBuffers() { renderer_->SwapBuffers(CompositorFrameMetadata()); } 355 void SwapBuffers() { renderer_->SwapBuffers(CompositorFrameMetadata()); }
356 356
357 RendererSettings settings_; 357 RendererSettings settings_;
358 FakeOutputSurfaceClient output_surface_client_; 358 FakeOutputSurfaceClient output_surface_client_;
359 scoped_ptr<FakeOutputSurface> output_surface_; 359 std::unique_ptr<FakeOutputSurface> output_surface_;
360 FakeRendererClient renderer_client_; 360 FakeRendererClient renderer_client_;
361 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; 361 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager_;
362 scoped_ptr<ResourceProvider> resource_provider_; 362 std::unique_ptr<ResourceProvider> resource_provider_;
363 scoped_ptr<FakeRendererGL> renderer_; 363 std::unique_ptr<FakeRendererGL> renderer_;
364 }; 364 };
365 365
366 // Closing the namespace here so that GLRendererShaderTest can take advantage 366 // Closing the namespace here so that GLRendererShaderTest can take advantage
367 // of the friend relationship with GLRenderer and all of the mock classes 367 // of the friend relationship with GLRenderer and all of the mock classes
368 // declared above it. 368 // declared above it.
369 } // namespace 369 } // namespace
370 370
371 class GLRendererShaderTest : public GLRendererTest { 371 class GLRendererShaderTest : public GLRendererTest {
372 protected: 372 protected:
373 GLRendererShaderTest() { 373 GLRendererShaderTest() {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 } 471 }
472 472
473 void TestSolidColorProgramAA() { 473 void TestSolidColorProgramAA() {
474 EXPECT_PROGRAM_VALID(&renderer_->solid_color_program_aa_); 474 EXPECT_PROGRAM_VALID(&renderer_->solid_color_program_aa_);
475 EXPECT_EQ(renderer_->solid_color_program_aa_.program(), 475 EXPECT_EQ(renderer_->solid_color_program_aa_.program(),
476 renderer_->program_shadow_); 476 renderer_->program_shadow_);
477 } 477 }
478 478
479 RendererSettings settings_; 479 RendererSettings settings_;
480 FakeOutputSurfaceClient output_surface_client_; 480 FakeOutputSurfaceClient output_surface_client_;
481 scoped_ptr<FakeOutputSurface> output_surface_; 481 std::unique_ptr<FakeOutputSurface> output_surface_;
482 FakeRendererClient renderer_client_; 482 FakeRendererClient renderer_client_;
483 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; 483 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager_;
484 scoped_ptr<ResourceProvider> resource_provider_; 484 std::unique_ptr<ResourceProvider> resource_provider_;
485 scoped_ptr<FakeRendererGL> renderer_; 485 std::unique_ptr<FakeRendererGL> renderer_;
486 }; 486 };
487 487
488 namespace { 488 namespace {
489 489
490 // Test GLRenderer DiscardBackbuffer functionality: 490 // Test GLRenderer DiscardBackbuffer functionality:
491 // Suggest discarding framebuffer when one exists and the renderer is not 491 // Suggest discarding framebuffer when one exists and the renderer is not
492 // visible. 492 // visible.
493 // Expected: it is discarded and damage tracker is reset. 493 // Expected: it is discarded and damage tracker is reset.
494 TEST_F( 494 TEST_F(
495 GLRendererWithDefaultHarnessTest, 495 GLRendererWithDefaultHarnessTest,
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 void getVertexAttribiv(GLuint index, GLenum pname, GLint* value) override { 660 void getVertexAttribiv(GLuint index, GLenum pname, GLint* value) override {
661 ADD_FAILURE(); 661 ADD_FAILURE();
662 } 662 }
663 GLsizeiptr getVertexAttribOffset(GLuint index, GLenum pname) override { 663 GLsizeiptr getVertexAttribOffset(GLuint index, GLenum pname) override {
664 ADD_FAILURE(); 664 ADD_FAILURE();
665 return 0; 665 return 0;
666 } 666 }
667 }; 667 };
668 TEST_F(GLRendererTest, InitializationDoesNotMakeSynchronousCalls) { 668 TEST_F(GLRendererTest, InitializationDoesNotMakeSynchronousCalls) {
669 FakeOutputSurfaceClient output_surface_client; 669 FakeOutputSurfaceClient output_surface_client;
670 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( 670 std::unique_ptr<OutputSurface> output_surface(
671 scoped_ptr<TestWebGraphicsContext3D>(new ForbidSynchronousCallContext))); 671 FakeOutputSurface::Create3d(std::unique_ptr<TestWebGraphicsContext3D>(
672 new ForbidSynchronousCallContext)));
672 CHECK(output_surface->BindToClient(&output_surface_client)); 673 CHECK(output_surface->BindToClient(&output_surface_client));
673 674
674 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 675 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager(
675 new TestSharedBitmapManager()); 676 new TestSharedBitmapManager());
676 scoped_ptr<ResourceProvider> resource_provider = FakeResourceProvider::Create( 677 std::unique_ptr<ResourceProvider> resource_provider =
677 output_surface.get(), shared_bitmap_manager.get()); 678 FakeResourceProvider::Create(output_surface.get(),
679 shared_bitmap_manager.get());
678 680
679 RendererSettings settings; 681 RendererSettings settings;
680 FakeRendererClient renderer_client; 682 FakeRendererClient renderer_client;
681 FakeRendererGL renderer(&renderer_client, 683 FakeRendererGL renderer(&renderer_client,
682 &settings, 684 &settings,
683 output_surface.get(), 685 output_surface.get(),
684 resource_provider.get()); 686 resource_provider.get());
685 } 687 }
686 688
687 class LoseContextOnFirstGetContext : public TestWebGraphicsContext3D { 689 class LoseContextOnFirstGetContext : public TestWebGraphicsContext3D {
688 public: 690 public:
689 LoseContextOnFirstGetContext() {} 691 LoseContextOnFirstGetContext() {}
690 692
691 void getProgramiv(GLuint program, GLenum pname, GLint* value) override { 693 void getProgramiv(GLuint program, GLenum pname, GLint* value) override {
692 context_lost_ = true; 694 context_lost_ = true;
693 *value = 0; 695 *value = 0;
694 } 696 }
695 697
696 void getShaderiv(GLuint shader, GLenum pname, GLint* value) override { 698 void getShaderiv(GLuint shader, GLenum pname, GLint* value) override {
697 context_lost_ = true; 699 context_lost_ = true;
698 *value = 0; 700 *value = 0;
699 } 701 }
700 }; 702 };
701 703
702 TEST_F(GLRendererTest, InitializationWithQuicklyLostContextDoesNotAssert) { 704 TEST_F(GLRendererTest, InitializationWithQuicklyLostContextDoesNotAssert) {
703 FakeOutputSurfaceClient output_surface_client; 705 FakeOutputSurfaceClient output_surface_client;
704 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( 706 std::unique_ptr<OutputSurface> output_surface(
705 scoped_ptr<TestWebGraphicsContext3D>(new LoseContextOnFirstGetContext))); 707 FakeOutputSurface::Create3d(std::unique_ptr<TestWebGraphicsContext3D>(
708 new LoseContextOnFirstGetContext)));
706 CHECK(output_surface->BindToClient(&output_surface_client)); 709 CHECK(output_surface->BindToClient(&output_surface_client));
707 710
708 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 711 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager(
709 new TestSharedBitmapManager()); 712 new TestSharedBitmapManager());
710 scoped_ptr<ResourceProvider> resource_provider = FakeResourceProvider::Create( 713 std::unique_ptr<ResourceProvider> resource_provider =
711 output_surface.get(), shared_bitmap_manager.get()); 714 FakeResourceProvider::Create(output_surface.get(),
715 shared_bitmap_manager.get());
712 716
713 RendererSettings settings; 717 RendererSettings settings;
714 FakeRendererClient renderer_client; 718 FakeRendererClient renderer_client;
715 FakeRendererGL renderer(&renderer_client, 719 FakeRendererGL renderer(&renderer_client,
716 &settings, 720 &settings,
717 output_surface.get(), 721 output_surface.get(),
718 resource_provider.get()); 722 resource_provider.get());
719 } 723 }
720 724
721 class ClearCountingContext : public TestWebGraphicsContext3D { 725 class ClearCountingContext : public TestWebGraphicsContext3D {
722 public: 726 public:
723 ClearCountingContext() { test_capabilities_.gpu.discard_framebuffer = true; } 727 ClearCountingContext() { test_capabilities_.gpu.discard_framebuffer = true; }
724 728
725 MOCK_METHOD3(discardFramebufferEXT, 729 MOCK_METHOD3(discardFramebufferEXT,
726 void(GLenum target, 730 void(GLenum target,
727 GLsizei numAttachments, 731 GLsizei numAttachments,
728 const GLenum* attachments)); 732 const GLenum* attachments));
729 MOCK_METHOD1(clear, void(GLbitfield mask)); 733 MOCK_METHOD1(clear, void(GLbitfield mask));
730 }; 734 };
731 735
732 TEST_F(GLRendererTest, OpaqueBackground) { 736 TEST_F(GLRendererTest, OpaqueBackground) {
733 scoped_ptr<ClearCountingContext> context_owned(new ClearCountingContext); 737 std::unique_ptr<ClearCountingContext> context_owned(new ClearCountingContext);
734 ClearCountingContext* context = context_owned.get(); 738 ClearCountingContext* context = context_owned.get();
735 739
736 FakeOutputSurfaceClient output_surface_client; 740 FakeOutputSurfaceClient output_surface_client;
737 scoped_ptr<OutputSurface> output_surface( 741 std::unique_ptr<OutputSurface> output_surface(
738 FakeOutputSurface::Create3d(std::move(context_owned))); 742 FakeOutputSurface::Create3d(std::move(context_owned)));
739 CHECK(output_surface->BindToClient(&output_surface_client)); 743 CHECK(output_surface->BindToClient(&output_surface_client));
740 744
741 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 745 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager(
742 new TestSharedBitmapManager()); 746 new TestSharedBitmapManager());
743 scoped_ptr<ResourceProvider> resource_provider = FakeResourceProvider::Create( 747 std::unique_ptr<ResourceProvider> resource_provider =
744 output_surface.get(), shared_bitmap_manager.get()); 748 FakeResourceProvider::Create(output_surface.get(),
749 shared_bitmap_manager.get());
745 750
746 RendererSettings settings; 751 RendererSettings settings;
747 FakeRendererClient renderer_client; 752 FakeRendererClient renderer_client;
748 FakeRendererGL renderer(&renderer_client, 753 FakeRendererGL renderer(&renderer_client,
749 &settings, 754 &settings,
750 output_surface.get(), 755 output_surface.get(),
751 resource_provider.get()); 756 resource_provider.get());
752 757
753 gfx::Rect viewport_rect(1, 1); 758 gfx::Rect viewport_rect(1, 1);
754 RenderPass* root_pass = 759 RenderPass* root_pass =
(...skipping 13 matching lines...) Expand all
768 #endif 773 #endif
769 renderer.DrawFrame(&render_passes_in_draw_order_, 774 renderer.DrawFrame(&render_passes_in_draw_order_,
770 1.f, 775 1.f,
771 viewport_rect, 776 viewport_rect,
772 viewport_rect, 777 viewport_rect,
773 false); 778 false);
774 Mock::VerifyAndClearExpectations(context); 779 Mock::VerifyAndClearExpectations(context);
775 } 780 }
776 781
777 TEST_F(GLRendererTest, TransparentBackground) { 782 TEST_F(GLRendererTest, TransparentBackground) {
778 scoped_ptr<ClearCountingContext> context_owned(new ClearCountingContext); 783 std::unique_ptr<ClearCountingContext> context_owned(new ClearCountingContext);
779 ClearCountingContext* context = context_owned.get(); 784 ClearCountingContext* context = context_owned.get();
780 785
781 FakeOutputSurfaceClient output_surface_client; 786 FakeOutputSurfaceClient output_surface_client;
782 scoped_ptr<OutputSurface> output_surface( 787 std::unique_ptr<OutputSurface> output_surface(
783 FakeOutputSurface::Create3d(std::move(context_owned))); 788 FakeOutputSurface::Create3d(std::move(context_owned)));
784 CHECK(output_surface->BindToClient(&output_surface_client)); 789 CHECK(output_surface->BindToClient(&output_surface_client));
785 790
786 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 791 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager(
787 new TestSharedBitmapManager()); 792 new TestSharedBitmapManager());
788 scoped_ptr<ResourceProvider> resource_provider = FakeResourceProvider::Create( 793 std::unique_ptr<ResourceProvider> resource_provider =
789 output_surface.get(), shared_bitmap_manager.get()); 794 FakeResourceProvider::Create(output_surface.get(),
795 shared_bitmap_manager.get());
790 796
791 RendererSettings settings; 797 RendererSettings settings;
792 FakeRendererClient renderer_client; 798 FakeRendererClient renderer_client;
793 FakeRendererGL renderer(&renderer_client, 799 FakeRendererGL renderer(&renderer_client,
794 &settings, 800 &settings,
795 output_surface.get(), 801 output_surface.get(),
796 resource_provider.get()); 802 resource_provider.get());
797 803
798 gfx::Rect viewport_rect(1, 1); 804 gfx::Rect viewport_rect(1, 1);
799 RenderPass* root_pass = 805 RenderPass* root_pass =
800 AddRenderPass(&render_passes_in_draw_order_, RenderPassId(1, 0), 806 AddRenderPass(&render_passes_in_draw_order_, RenderPassId(1, 0),
801 viewport_rect, gfx::Transform()); 807 viewport_rect, gfx::Transform());
802 root_pass->has_transparent_background = true; 808 root_pass->has_transparent_background = true;
803 809
804 EXPECT_CALL(*context, discardFramebufferEXT(GL_FRAMEBUFFER, 1, _)).Times(1); 810 EXPECT_CALL(*context, discardFramebufferEXT(GL_FRAMEBUFFER, 1, _)).Times(1);
805 EXPECT_CALL(*context, clear(_)).Times(1); 811 EXPECT_CALL(*context, clear(_)).Times(1);
806 renderer.DrawFrame(&render_passes_in_draw_order_, 812 renderer.DrawFrame(&render_passes_in_draw_order_,
807 1.f, 813 1.f,
808 viewport_rect, 814 viewport_rect,
809 viewport_rect, 815 viewport_rect,
810 false); 816 false);
811 817
812 Mock::VerifyAndClearExpectations(context); 818 Mock::VerifyAndClearExpectations(context);
813 } 819 }
814 820
815 TEST_F(GLRendererTest, OffscreenOutputSurface) { 821 TEST_F(GLRendererTest, OffscreenOutputSurface) {
816 scoped_ptr<ClearCountingContext> context_owned(new ClearCountingContext); 822 std::unique_ptr<ClearCountingContext> context_owned(new ClearCountingContext);
817 ClearCountingContext* context = context_owned.get(); 823 ClearCountingContext* context = context_owned.get();
818 824
819 FakeOutputSurfaceClient output_surface_client; 825 FakeOutputSurfaceClient output_surface_client;
820 scoped_ptr<OutputSurface> output_surface( 826 std::unique_ptr<OutputSurface> output_surface(
821 FakeOutputSurface::CreateOffscreen(std::move(context_owned))); 827 FakeOutputSurface::CreateOffscreen(std::move(context_owned)));
822 CHECK(output_surface->BindToClient(&output_surface_client)); 828 CHECK(output_surface->BindToClient(&output_surface_client));
823 829
824 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 830 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager(
825 new TestSharedBitmapManager()); 831 new TestSharedBitmapManager());
826 scoped_ptr<ResourceProvider> resource_provider = FakeResourceProvider::Create( 832 std::unique_ptr<ResourceProvider> resource_provider =
827 output_surface.get(), shared_bitmap_manager.get()); 833 FakeResourceProvider::Create(output_surface.get(),
834 shared_bitmap_manager.get());
828 835
829 RendererSettings settings; 836 RendererSettings settings;
830 FakeRendererClient renderer_client; 837 FakeRendererClient renderer_client;
831 FakeRendererGL renderer(&renderer_client, 838 FakeRendererGL renderer(&renderer_client,
832 &settings, 839 &settings,
833 output_surface.get(), 840 output_surface.get(),
834 resource_provider.get()); 841 resource_provider.get());
835 842
836 gfx::Rect viewport_rect(1, 1); 843 gfx::Rect viewport_rect(1, 1);
837 AddRenderPass(&render_passes_in_draw_order_, 844 AddRenderPass(&render_passes_in_draw_order_,
(...skipping 29 matching lines...) Expand all
867 active_texture_ = texture; 874 active_texture_ = texture;
868 } 875 }
869 876
870 GLenum active_texture() const { return active_texture_; } 877 GLenum active_texture() const { return active_texture_; }
871 878
872 private: 879 private:
873 GLenum active_texture_; 880 GLenum active_texture_;
874 }; 881 };
875 882
876 TEST_F(GLRendererTest, ActiveTextureState) { 883 TEST_F(GLRendererTest, ActiveTextureState) {
877 scoped_ptr<TextureStateTrackingContext> context_owned( 884 std::unique_ptr<TextureStateTrackingContext> context_owned(
878 new TextureStateTrackingContext); 885 new TextureStateTrackingContext);
879 TextureStateTrackingContext* context = context_owned.get(); 886 TextureStateTrackingContext* context = context_owned.get();
880 887
881 FakeOutputSurfaceClient output_surface_client; 888 FakeOutputSurfaceClient output_surface_client;
882 scoped_ptr<OutputSurface> output_surface( 889 std::unique_ptr<OutputSurface> output_surface(
883 FakeOutputSurface::Create3d(std::move(context_owned))); 890 FakeOutputSurface::Create3d(std::move(context_owned)));
884 CHECK(output_surface->BindToClient(&output_surface_client)); 891 CHECK(output_surface->BindToClient(&output_surface_client));
885 892
886 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 893 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager(
887 new TestSharedBitmapManager()); 894 new TestSharedBitmapManager());
888 scoped_ptr<ResourceProvider> resource_provider = FakeResourceProvider::Create( 895 std::unique_ptr<ResourceProvider> resource_provider =
889 output_surface.get(), shared_bitmap_manager.get()); 896 FakeResourceProvider::Create(output_surface.get(),
897 shared_bitmap_manager.get());
890 898
891 RendererSettings settings; 899 RendererSettings settings;
892 FakeRendererClient renderer_client; 900 FakeRendererClient renderer_client;
893 FakeRendererGL renderer(&renderer_client, 901 FakeRendererGL renderer(&renderer_client,
894 &settings, 902 &settings,
895 output_surface.get(), 903 output_surface.get(),
896 resource_provider.get()); 904 resource_provider.get());
897 905
898 // During initialization we are allowed to set any texture parameters. 906 // During initialization we are allowed to set any texture parameters.
899 EXPECT_CALL(*context, texParameteri(_, _, _)).Times(AnyNumber()); 907 EXPECT_CALL(*context, texParameteri(_, _, _)).Times(AnyNumber());
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
952 } 960 }
953 961
954 class NoClearRootRenderPassMockContext : public TestWebGraphicsContext3D { 962 class NoClearRootRenderPassMockContext : public TestWebGraphicsContext3D {
955 public: 963 public:
956 MOCK_METHOD1(clear, void(GLbitfield mask)); 964 MOCK_METHOD1(clear, void(GLbitfield mask));
957 MOCK_METHOD4(drawElements, 965 MOCK_METHOD4(drawElements,
958 void(GLenum mode, GLsizei count, GLenum type, GLintptr offset)); 966 void(GLenum mode, GLsizei count, GLenum type, GLintptr offset));
959 }; 967 };
960 968
961 TEST_F(GLRendererTest, ShouldClearRootRenderPass) { 969 TEST_F(GLRendererTest, ShouldClearRootRenderPass) {
962 scoped_ptr<NoClearRootRenderPassMockContext> mock_context_owned( 970 std::unique_ptr<NoClearRootRenderPassMockContext> mock_context_owned(
963 new NoClearRootRenderPassMockContext); 971 new NoClearRootRenderPassMockContext);
964 NoClearRootRenderPassMockContext* mock_context = mock_context_owned.get(); 972 NoClearRootRenderPassMockContext* mock_context = mock_context_owned.get();
965 973
966 FakeOutputSurfaceClient output_surface_client; 974 FakeOutputSurfaceClient output_surface_client;
967 scoped_ptr<OutputSurface> output_surface( 975 std::unique_ptr<OutputSurface> output_surface(
968 FakeOutputSurface::Create3d(std::move(mock_context_owned))); 976 FakeOutputSurface::Create3d(std::move(mock_context_owned)));
969 CHECK(output_surface->BindToClient(&output_surface_client)); 977 CHECK(output_surface->BindToClient(&output_surface_client));
970 978
971 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 979 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager(
972 new TestSharedBitmapManager()); 980 new TestSharedBitmapManager());
973 scoped_ptr<ResourceProvider> resource_provider = FakeResourceProvider::Create( 981 std::unique_ptr<ResourceProvider> resource_provider =
974 output_surface.get(), shared_bitmap_manager.get()); 982 FakeResourceProvider::Create(output_surface.get(),
983 shared_bitmap_manager.get());
975 984
976 RendererSettings settings; 985 RendererSettings settings;
977 settings.should_clear_root_render_pass = false; 986 settings.should_clear_root_render_pass = false;
978 987
979 FakeRendererClient renderer_client; 988 FakeRendererClient renderer_client;
980 FakeRendererGL renderer(&renderer_client, 989 FakeRendererGL renderer(&renderer_client,
981 &settings, 990 &settings,
982 output_surface.get(), 991 output_surface.get(),
983 resource_provider.get()); 992 resource_provider.get());
984 993
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 void disable(GLenum cap) override { 1053 void disable(GLenum cap) override {
1045 if (cap == GL_SCISSOR_TEST) 1054 if (cap == GL_SCISSOR_TEST)
1046 scissor_enabled_ = false; 1055 scissor_enabled_ = false;
1047 } 1056 }
1048 1057
1049 private: 1058 private:
1050 bool scissor_enabled_; 1059 bool scissor_enabled_;
1051 }; 1060 };
1052 1061
1053 TEST_F(GLRendererTest, ScissorTestWhenClearing) { 1062 TEST_F(GLRendererTest, ScissorTestWhenClearing) {
1054 scoped_ptr<ScissorTestOnClearCheckingContext> context_owned( 1063 std::unique_ptr<ScissorTestOnClearCheckingContext> context_owned(
1055 new ScissorTestOnClearCheckingContext); 1064 new ScissorTestOnClearCheckingContext);
1056 1065
1057 FakeOutputSurfaceClient output_surface_client; 1066 FakeOutputSurfaceClient output_surface_client;
1058 scoped_ptr<OutputSurface> output_surface( 1067 std::unique_ptr<OutputSurface> output_surface(
1059 FakeOutputSurface::Create3d(std::move(context_owned))); 1068 FakeOutputSurface::Create3d(std::move(context_owned)));
1060 CHECK(output_surface->BindToClient(&output_surface_client)); 1069 CHECK(output_surface->BindToClient(&output_surface_client));
1061 1070
1062 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 1071 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager(
1063 new TestSharedBitmapManager()); 1072 new TestSharedBitmapManager());
1064 scoped_ptr<ResourceProvider> resource_provider = FakeResourceProvider::Create( 1073 std::unique_ptr<ResourceProvider> resource_provider =
1065 output_surface.get(), shared_bitmap_manager.get()); 1074 FakeResourceProvider::Create(output_surface.get(),
1075 shared_bitmap_manager.get());
1066 1076
1067 RendererSettings settings; 1077 RendererSettings settings;
1068 FakeRendererClient renderer_client; 1078 FakeRendererClient renderer_client;
1069 FakeRendererGL renderer(&renderer_client, 1079 FakeRendererGL renderer(&renderer_client,
1070 &settings, 1080 &settings,
1071 output_surface.get(), 1081 output_surface.get(),
1072 resource_provider.get()); 1082 resource_provider.get());
1073 EXPECT_FALSE(renderer.Capabilities().using_partial_swap); 1083 EXPECT_FALSE(renderer.Capabilities().using_partial_swap);
1074 1084
1075 gfx::Rect viewport_rect(1, 1); 1085 gfx::Rect viewport_rect(1, 1);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1121 int discarded() const { return discarded_; } 1131 int discarded() const { return discarded_; }
1122 void reset() { discarded_ = 0; } 1132 void reset() { discarded_ = 0; }
1123 1133
1124 private: 1134 private:
1125 int discarded_; 1135 int discarded_;
1126 }; 1136 };
1127 1137
1128 class NonReshapableOutputSurface : public FakeOutputSurface { 1138 class NonReshapableOutputSurface : public FakeOutputSurface {
1129 public: 1139 public:
1130 explicit NonReshapableOutputSurface( 1140 explicit NonReshapableOutputSurface(
1131 scoped_ptr<TestWebGraphicsContext3D> context3d) 1141 std::unique_ptr<TestWebGraphicsContext3D> context3d)
1132 : FakeOutputSurface(TestContextProvider::Create(std::move(context3d)), 1142 : FakeOutputSurface(TestContextProvider::Create(std::move(context3d)),
1133 false) { 1143 false) {
1134 surface_size_ = gfx::Size(500, 500); 1144 surface_size_ = gfx::Size(500, 500);
1135 } 1145 }
1136 void Reshape(const gfx::Size& size, 1146 void Reshape(const gfx::Size& size,
1137 float scale_factor, 1147 float scale_factor,
1138 bool has_alpha) override {} 1148 bool has_alpha) override {}
1139 void set_fixed_size(const gfx::Size& size) { surface_size_ = size; } 1149 void set_fixed_size(const gfx::Size& size) { surface_size_ = size; }
1140 }; 1150 };
1141 1151
1142 TEST_F(GLRendererTest, NoDiscardOnPartialUpdates) { 1152 TEST_F(GLRendererTest, NoDiscardOnPartialUpdates) {
1143 scoped_ptr<DiscardCheckingContext> context_owned(new DiscardCheckingContext); 1153 std::unique_ptr<DiscardCheckingContext> context_owned(
1154 new DiscardCheckingContext);
1144 DiscardCheckingContext* context = context_owned.get(); 1155 DiscardCheckingContext* context = context_owned.get();
1145 1156
1146 FakeOutputSurfaceClient output_surface_client; 1157 FakeOutputSurfaceClient output_surface_client;
1147 scoped_ptr<NonReshapableOutputSurface> output_surface( 1158 std::unique_ptr<NonReshapableOutputSurface> output_surface(
1148 new NonReshapableOutputSurface(std::move(context_owned))); 1159 new NonReshapableOutputSurface(std::move(context_owned)));
1149 CHECK(output_surface->BindToClient(&output_surface_client)); 1160 CHECK(output_surface->BindToClient(&output_surface_client));
1150 output_surface->set_fixed_size(gfx::Size(100, 100)); 1161 output_surface->set_fixed_size(gfx::Size(100, 100));
1151 1162
1152 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 1163 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager(
1153 new TestSharedBitmapManager()); 1164 new TestSharedBitmapManager());
1154 scoped_ptr<ResourceProvider> resource_provider = FakeResourceProvider::Create( 1165 std::unique_ptr<ResourceProvider> resource_provider =
1155 output_surface.get(), shared_bitmap_manager.get()); 1166 FakeResourceProvider::Create(output_surface.get(),
1167 shared_bitmap_manager.get());
1156 1168
1157 RendererSettings settings; 1169 RendererSettings settings;
1158 settings.partial_swap_enabled = true; 1170 settings.partial_swap_enabled = true;
1159 FakeRendererClient renderer_client; 1171 FakeRendererClient renderer_client;
1160 FakeRendererGL renderer(&renderer_client, 1172 FakeRendererGL renderer(&renderer_client,
1161 &settings, 1173 &settings,
1162 output_surface.get(), 1174 output_surface.get(),
1163 resource_provider.get()); 1175 resource_provider.get());
1164 EXPECT_TRUE(renderer.Capabilities().using_partial_swap); 1176 EXPECT_TRUE(renderer.Capabilities().using_partial_swap);
1165 1177
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1287 public: 1299 public:
1288 MOCK_METHOD4(viewport, void(GLint x, GLint y, GLsizei width, GLsizei height)); 1300 MOCK_METHOD4(viewport, void(GLint x, GLint y, GLsizei width, GLsizei height));
1289 MOCK_METHOD4(scissor, void(GLint x, GLint y, GLsizei width, GLsizei height)); 1301 MOCK_METHOD4(scissor, void(GLint x, GLint y, GLsizei width, GLsizei height));
1290 }; 1302 };
1291 1303
1292 TEST_F(GLRendererTest, ScissorAndViewportWithinNonreshapableSurface) { 1304 TEST_F(GLRendererTest, ScissorAndViewportWithinNonreshapableSurface) {
1293 // In Android WebView, the OutputSurface is unable to respect reshape() calls 1305 // In Android WebView, the OutputSurface is unable to respect reshape() calls
1294 // and maintains a fixed size. This test verifies that glViewport and 1306 // and maintains a fixed size. This test verifies that glViewport and
1295 // glScissor's Y coordinate is flipped correctly in this environment, and that 1307 // glScissor's Y coordinate is flipped correctly in this environment, and that
1296 // the glViewport can be at a nonzero origin within the surface. 1308 // the glViewport can be at a nonzero origin within the surface.
1297 scoped_ptr<FlippedScissorAndViewportContext> context_owned( 1309 std::unique_ptr<FlippedScissorAndViewportContext> context_owned(
1298 new FlippedScissorAndViewportContext); 1310 new FlippedScissorAndViewportContext);
1299 1311
1300 // We expect exactly one call to viewport on this context and exactly two 1312 // We expect exactly one call to viewport on this context and exactly two
1301 // to scissor (one to scissor the clear, one to scissor the quad draw). 1313 // to scissor (one to scissor the clear, one to scissor the quad draw).
1302 EXPECT_CALL(*context_owned, viewport(10, 390, 100, 100)); 1314 EXPECT_CALL(*context_owned, viewport(10, 390, 100, 100));
1303 EXPECT_CALL(*context_owned, scissor(10, 390, 100, 100)); 1315 EXPECT_CALL(*context_owned, scissor(10, 390, 100, 100));
1304 EXPECT_CALL(*context_owned, scissor(30, 450, 20, 20)); 1316 EXPECT_CALL(*context_owned, scissor(30, 450, 20, 20));
1305 1317
1306 FakeOutputSurfaceClient output_surface_client; 1318 FakeOutputSurfaceClient output_surface_client;
1307 scoped_ptr<OutputSurface> output_surface( 1319 std::unique_ptr<OutputSurface> output_surface(
1308 new NonReshapableOutputSurface(std::move(context_owned))); 1320 new NonReshapableOutputSurface(std::move(context_owned)));
1309 CHECK(output_surface->BindToClient(&output_surface_client)); 1321 CHECK(output_surface->BindToClient(&output_surface_client));
1310 1322
1311 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 1323 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager(
1312 new TestSharedBitmapManager()); 1324 new TestSharedBitmapManager());
1313 scoped_ptr<ResourceProvider> resource_provider = FakeResourceProvider::Create( 1325 std::unique_ptr<ResourceProvider> resource_provider =
1314 output_surface.get(), shared_bitmap_manager.get()); 1326 FakeResourceProvider::Create(output_surface.get(),
1327 shared_bitmap_manager.get());
1315 1328
1316 RendererSettings settings; 1329 RendererSettings settings;
1317 FakeRendererClient renderer_client; 1330 FakeRendererClient renderer_client;
1318 FakeRendererGL renderer(&renderer_client, 1331 FakeRendererGL renderer(&renderer_client,
1319 &settings, 1332 &settings,
1320 output_surface.get(), 1333 output_surface.get(),
1321 resource_provider.get()); 1334 resource_provider.get());
1322 EXPECT_FALSE(renderer.Capabilities().using_partial_swap); 1335 EXPECT_FALSE(renderer.Capabilities().using_partial_swap);
1323 1336
1324 gfx::Rect device_viewport_rect(10, 10, 100, 100); 1337 gfx::Rect device_viewport_rect(10, 10, 100, 100);
(...skipping 14 matching lines...) Expand all
1339 false); 1352 false);
1340 } 1353 }
1341 1354
1342 TEST_F(GLRendererTest, DrawFramePreservesFramebuffer) { 1355 TEST_F(GLRendererTest, DrawFramePreservesFramebuffer) {
1343 // When using render-to-FBO to display the surface, all rendering is done 1356 // When using render-to-FBO to display the surface, all rendering is done
1344 // to a non-zero FBO. Make sure that the framebuffer is always restored to 1357 // to a non-zero FBO. Make sure that the framebuffer is always restored to
1345 // the correct framebuffer during rendering, if changed. 1358 // the correct framebuffer during rendering, if changed.
1346 // Note: there is one path that will set it to 0, but that is after the render 1359 // Note: there is one path that will set it to 0, but that is after the render
1347 // has finished. 1360 // has finished.
1348 FakeOutputSurfaceClient output_surface_client; 1361 FakeOutputSurfaceClient output_surface_client;
1349 scoped_ptr<FakeOutputSurface> output_surface( 1362 std::unique_ptr<FakeOutputSurface> output_surface(
1350 FakeOutputSurface::Create3d(TestWebGraphicsContext3D::Create())); 1363 FakeOutputSurface::Create3d(TestWebGraphicsContext3D::Create()));
1351 CHECK(output_surface->BindToClient(&output_surface_client)); 1364 CHECK(output_surface->BindToClient(&output_surface_client));
1352 1365
1353 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 1366 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager(
1354 new TestSharedBitmapManager()); 1367 new TestSharedBitmapManager());
1355 scoped_ptr<ResourceProvider> resource_provider = FakeResourceProvider::Create( 1368 std::unique_ptr<ResourceProvider> resource_provider =
1356 output_surface.get(), shared_bitmap_manager.get()); 1369 FakeResourceProvider::Create(output_surface.get(),
1370 shared_bitmap_manager.get());
1357 1371
1358 RendererSettings settings; 1372 RendererSettings settings;
1359 FakeRendererClient renderer_client; 1373 FakeRendererClient renderer_client;
1360 FakeRendererGL renderer(&renderer_client, &settings, output_surface.get(), 1374 FakeRendererGL renderer(&renderer_client, &settings, output_surface.get(),
1361 resource_provider.get()); 1375 resource_provider.get());
1362 EXPECT_FALSE(renderer.Capabilities().using_partial_swap); 1376 EXPECT_FALSE(renderer.Capabilities().using_partial_swap);
1363 1377
1364 gfx::Rect device_viewport_rect(0, 0, 100, 100); 1378 gfx::Rect device_viewport_rect(0, 0, 100, 100);
1365 gfx::Rect viewport_rect(device_viewport_rect.size()); 1379 gfx::Rect viewport_rect(device_viewport_rect.size());
1366 gfx::Rect quad_rect = gfx::Rect(20, 20, 20, 20); 1380 gfx::Rect quad_rect = gfx::Rect(20, 20, 20, 20);
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
1743 MOCK_METHOD2(bindFramebuffer, void(GLenum target, GLuint framebuffer)); 1757 MOCK_METHOD2(bindFramebuffer, void(GLenum target, GLuint framebuffer));
1744 MOCK_METHOD3(reshapeWithScaleFactor, 1758 MOCK_METHOD3(reshapeWithScaleFactor,
1745 void(int width, int height, float scale_factor)); 1759 void(int width, int height, float scale_factor));
1746 MOCK_METHOD4(drawElements, 1760 MOCK_METHOD4(drawElements,
1747 void(GLenum mode, GLsizei count, GLenum type, GLintptr offset)); 1761 void(GLenum mode, GLsizei count, GLenum type, GLintptr offset));
1748 }; 1762 };
1749 1763
1750 class MockOutputSurface : public OutputSurface { 1764 class MockOutputSurface : public OutputSurface {
1751 public: 1765 public:
1752 MockOutputSurface() 1766 MockOutputSurface()
1753 : OutputSurface( 1767 : OutputSurface(TestContextProvider::Create(
1754 TestContextProvider::Create(scoped_ptr<TestWebGraphicsContext3D>( 1768 std::unique_ptr<TestWebGraphicsContext3D>(
1755 new StrictMock<OutputSurfaceMockContext>))) { 1769 new StrictMock<OutputSurfaceMockContext>))) {
1756 surface_size_ = gfx::Size(100, 100); 1770 surface_size_ = gfx::Size(100, 100);
1757 } 1771 }
1758 virtual ~MockOutputSurface() {} 1772 virtual ~MockOutputSurface() {}
1759 1773
1760 MOCK_METHOD0(EnsureBackbuffer, void()); 1774 MOCK_METHOD0(EnsureBackbuffer, void());
1761 MOCK_METHOD0(DiscardBackbuffer, void()); 1775 MOCK_METHOD0(DiscardBackbuffer, void());
1762 MOCK_METHOD3(Reshape, 1776 MOCK_METHOD3(Reshape,
1763 void(const gfx::Size& size, float scale_factor, bool has_alpha)); 1777 void(const gfx::Size& size, float scale_factor, bool has_alpha));
1764 MOCK_METHOD0(BindFramebuffer, void()); 1778 MOCK_METHOD0(BindFramebuffer, void());
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1814 1828
1815 OutputSurfaceMockContext* Context() { 1829 OutputSurfaceMockContext* Context() {
1816 return static_cast<OutputSurfaceMockContext*>( 1830 return static_cast<OutputSurfaceMockContext*>(
1817 static_cast<TestContextProvider*>(output_surface_.context_provider()) 1831 static_cast<TestContextProvider*>(output_surface_.context_provider())
1818 ->TestContext3d()); 1832 ->TestContext3d());
1819 } 1833 }
1820 1834
1821 RendererSettings settings_; 1835 RendererSettings settings_;
1822 FakeOutputSurfaceClient output_surface_client_; 1836 FakeOutputSurfaceClient output_surface_client_;
1823 StrictMock<MockOutputSurface> output_surface_; 1837 StrictMock<MockOutputSurface> output_surface_;
1824 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; 1838 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager_;
1825 scoped_ptr<ResourceProvider> resource_provider_; 1839 std::unique_ptr<ResourceProvider> resource_provider_;
1826 FakeRendererClient renderer_client_; 1840 FakeRendererClient renderer_client_;
1827 scoped_ptr<FakeRendererGL> renderer_; 1841 std::unique_ptr<FakeRendererGL> renderer_;
1828 }; 1842 };
1829 1843
1830 TEST_F(MockOutputSurfaceTest, DrawFrameAndSwap) { 1844 TEST_F(MockOutputSurfaceTest, DrawFrameAndSwap) {
1831 gfx::Rect device_viewport_rect(1, 1); 1845 gfx::Rect device_viewport_rect(1, 1);
1832 DrawFrame(1.f, device_viewport_rect, true); 1846 DrawFrame(1.f, device_viewport_rect, true);
1833 1847
1834 EXPECT_CALL(output_surface_, SwapBuffers(_)).Times(1); 1848 EXPECT_CALL(output_surface_, SwapBuffers(_)).Times(1);
1835 renderer_->SwapBuffers(CompositorFrameMetadata()); 1849 renderer_->SwapBuffers(CompositorFrameMetadata());
1836 } 1850 }
1837 1851
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1976 // true must also have their |display_rect| converted to integer 1990 // true must also have their |display_rect| converted to integer
1977 // coordinates if necessary. 1991 // coordinates if necessary.
1978 void CheckOverlaySupport(OverlayCandidateList* surfaces) {} 1992 void CheckOverlaySupport(OverlayCandidateList* surfaces) {}
1979 }; 1993 };
1980 1994
1981 explicit TestOverlayProcessor(OutputSurface* surface) 1995 explicit TestOverlayProcessor(OutputSurface* surface)
1982 : OverlayProcessor(surface) {} 1996 : OverlayProcessor(surface) {}
1983 ~TestOverlayProcessor() override {} 1997 ~TestOverlayProcessor() override {}
1984 void Initialize() override { 1998 void Initialize() override {
1985 strategy_ = new Strategy(); 1999 strategy_ = new Strategy();
1986 strategies_.push_back(make_scoped_ptr(strategy_)); 2000 strategies_.push_back(base::WrapUnique(strategy_));
1987 } 2001 }
1988 2002
1989 Strategy* strategy_; 2003 Strategy* strategy_;
1990 }; 2004 };
1991 2005
1992 void MailboxReleased(const gpu::SyncToken& sync_token, 2006 void MailboxReleased(const gpu::SyncToken& sync_token,
1993 bool lost_resource, 2007 bool lost_resource,
1994 BlockingTaskRunner* main_thread_task_runner) {} 2008 BlockingTaskRunner* main_thread_task_runner) {}
1995 2009
1996 void IgnoreCopyResult(scoped_ptr<CopyOutputResult> result) { 2010 void IgnoreCopyResult(std::unique_ptr<CopyOutputResult> result) {}
1997 }
1998 2011
1999 TEST_F(GLRendererTest, DontOverlayWithCopyRequests) { 2012 TEST_F(GLRendererTest, DontOverlayWithCopyRequests) {
2000 scoped_ptr<DiscardCheckingContext> context_owned(new DiscardCheckingContext); 2013 std::unique_ptr<DiscardCheckingContext> context_owned(
2014 new DiscardCheckingContext);
2001 FakeOutputSurfaceClient output_surface_client; 2015 FakeOutputSurfaceClient output_surface_client;
2002 scoped_ptr<FakeOutputSurface> output_surface( 2016 std::unique_ptr<FakeOutputSurface> output_surface(
2003 FakeOutputSurface::Create3d(std::move(context_owned))); 2017 FakeOutputSurface::Create3d(std::move(context_owned)));
2004 CHECK(output_surface->BindToClient(&output_surface_client)); 2018 CHECK(output_surface->BindToClient(&output_surface_client));
2005 2019
2006 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 2020 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager(
2007 new TestSharedBitmapManager()); 2021 new TestSharedBitmapManager());
2008 scoped_ptr<ResourceProvider> resource_provider = FakeResourceProvider::Create( 2022 std::unique_ptr<ResourceProvider> resource_provider =
2009 output_surface.get(), shared_bitmap_manager.get()); 2023 FakeResourceProvider::Create(output_surface.get(),
2010 scoped_ptr<TextureMailboxDeleter> mailbox_deleter( 2024 shared_bitmap_manager.get());
2025 std::unique_ptr<TextureMailboxDeleter> mailbox_deleter(
2011 new TextureMailboxDeleter(base::ThreadTaskRunnerHandle::Get())); 2026 new TextureMailboxDeleter(base::ThreadTaskRunnerHandle::Get()));
2012 2027
2013 RendererSettings settings; 2028 RendererSettings settings;
2014 FakeRendererClient renderer_client; 2029 FakeRendererClient renderer_client;
2015 FakeRendererGL renderer(&renderer_client, &settings, output_surface.get(), 2030 FakeRendererGL renderer(&renderer_client, &settings, output_surface.get(),
2016 resource_provider.get(), mailbox_deleter.get()); 2031 resource_provider.get(), mailbox_deleter.get());
2017 2032
2018 TestOverlayProcessor* processor = 2033 TestOverlayProcessor* processor =
2019 new TestOverlayProcessor(output_surface.get()); 2034 new TestOverlayProcessor(output_surface.get());
2020 processor->Initialize(); 2035 processor->Initialize();
2021 renderer.SetOverlayProcessor(processor); 2036 renderer.SetOverlayProcessor(processor);
2022 scoped_ptr<TestOverlayProcessor::Validator> validator( 2037 std::unique_ptr<TestOverlayProcessor::Validator> validator(
2023 new TestOverlayProcessor::Validator); 2038 new TestOverlayProcessor::Validator);
2024 output_surface->SetOverlayCandidateValidator(validator.get()); 2039 output_surface->SetOverlayCandidateValidator(validator.get());
2025 2040
2026 gfx::Rect viewport_rect(1, 1); 2041 gfx::Rect viewport_rect(1, 1);
2027 RenderPass* root_pass = 2042 RenderPass* root_pass =
2028 AddRenderPass(&render_passes_in_draw_order_, RenderPassId(1, 0), 2043 AddRenderPass(&render_passes_in_draw_order_, RenderPassId(1, 0),
2029 viewport_rect, gfx::Transform()); 2044 viewport_rect, gfx::Transform());
2030 root_pass->has_transparent_background = false; 2045 root_pass->has_transparent_background = false;
2031 root_pass->copy_requests.push_back( 2046 root_pass->copy_requests.push_back(
2032 CopyOutputRequest::CreateRequest(base::Bind(&IgnoreCopyResult))); 2047 CopyOutputRequest::CreateRequest(base::Bind(&IgnoreCopyResult)));
2033 2048
2034 TextureMailbox mailbox = 2049 TextureMailbox mailbox =
2035 TextureMailbox(gpu::Mailbox::Generate(), gpu::SyncToken(), GL_TEXTURE_2D, 2050 TextureMailbox(gpu::Mailbox::Generate(), gpu::SyncToken(), GL_TEXTURE_2D,
2036 gfx::Size(256, 256), true, false); 2051 gfx::Size(256, 256), true, false);
2037 scoped_ptr<SingleReleaseCallbackImpl> release_callback = 2052 std::unique_ptr<SingleReleaseCallbackImpl> release_callback =
2038 SingleReleaseCallbackImpl::Create(base::Bind(&MailboxReleased)); 2053 SingleReleaseCallbackImpl::Create(base::Bind(&MailboxReleased));
2039 ResourceId resource_id = resource_provider->CreateResourceFromTextureMailbox( 2054 ResourceId resource_id = resource_provider->CreateResourceFromTextureMailbox(
2040 mailbox, std::move(release_callback)); 2055 mailbox, std::move(release_callback));
2041 bool premultiplied_alpha = false; 2056 bool premultiplied_alpha = false;
2042 bool flipped = false; 2057 bool flipped = false;
2043 bool nearest_neighbor = false; 2058 bool nearest_neighbor = false;
2044 float vertex_opacity[4] = {1.0f, 1.0f, 1.0f, 1.0f}; 2059 float vertex_opacity[4] = {1.0f, 1.0f, 1.0f, 1.0f};
2045 2060
2046 TextureDrawQuad* overlay_quad = 2061 TextureDrawQuad* overlay_quad =
2047 root_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); 2062 root_pass->CreateAndAppendDrawQuad<TextureDrawQuad>();
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
2100 renderer.DrawFrame(&render_passes_in_draw_order_, 1.f, viewport_rect, 2115 renderer.DrawFrame(&render_passes_in_draw_order_, 1.f, viewport_rect,
2101 viewport_rect, false); 2116 viewport_rect, false);
2102 } 2117 }
2103 2118
2104 class SingleOverlayOnTopProcessor : public OverlayProcessor { 2119 class SingleOverlayOnTopProcessor : public OverlayProcessor {
2105 public: 2120 public:
2106 class SingleOverlayValidator : public OverlayCandidateValidator { 2121 class SingleOverlayValidator : public OverlayCandidateValidator {
2107 public: 2122 public:
2108 void GetStrategies(OverlayProcessor::StrategyList* strategies) override { 2123 void GetStrategies(OverlayProcessor::StrategyList* strategies) override {
2109 strategies->push_back( 2124 strategies->push_back(
2110 make_scoped_ptr(new OverlayStrategySingleOnTop(this))); 2125 base::WrapUnique(new OverlayStrategySingleOnTop(this)));
2111 strategies->push_back(make_scoped_ptr(new OverlayStrategyUnderlay(this))); 2126 strategies->push_back(
2127 base::WrapUnique(new OverlayStrategyUnderlay(this)));
2112 } 2128 }
2113 2129
2114 bool AllowCALayerOverlays() override { return false; } 2130 bool AllowCALayerOverlays() override { return false; }
2115 2131
2116 void CheckOverlaySupport(OverlayCandidateList* surfaces) override { 2132 void CheckOverlaySupport(OverlayCandidateList* surfaces) override {
2117 ASSERT_EQ(1U, surfaces->size()); 2133 ASSERT_EQ(1U, surfaces->size());
2118 OverlayCandidate& candidate = surfaces->back(); 2134 OverlayCandidate& candidate = surfaces->back();
2119 candidate.overlay_handled = true; 2135 candidate.overlay_handled = true;
2120 } 2136 }
2121 }; 2137 };
2122 2138
2123 explicit SingleOverlayOnTopProcessor(OutputSurface* surface) 2139 explicit SingleOverlayOnTopProcessor(OutputSurface* surface)
2124 : OverlayProcessor(surface) {} 2140 : OverlayProcessor(surface) {}
2125 2141
2126 void Initialize() override { 2142 void Initialize() override {
2127 strategies_.push_back( 2143 strategies_.push_back(
2128 make_scoped_ptr(new OverlayStrategySingleOnTop(&validator_))); 2144 base::WrapUnique(new OverlayStrategySingleOnTop(&validator_)));
2129 } 2145 }
2130 2146
2131 SingleOverlayValidator validator_; 2147 SingleOverlayValidator validator_;
2132 }; 2148 };
2133 2149
2134 class WaitSyncTokenCountingContext : public TestWebGraphicsContext3D { 2150 class WaitSyncTokenCountingContext : public TestWebGraphicsContext3D {
2135 public: 2151 public:
2136 MOCK_METHOD1(waitSyncToken, void(const GLbyte* sync_token)); 2152 MOCK_METHOD1(waitSyncToken, void(const GLbyte* sync_token));
2137 }; 2153 };
2138 2154
2139 class MockOverlayScheduler { 2155 class MockOverlayScheduler {
2140 public: 2156 public:
2141 MOCK_METHOD5(Schedule, 2157 MOCK_METHOD5(Schedule,
2142 void(int plane_z_order, 2158 void(int plane_z_order,
2143 gfx::OverlayTransform plane_transform, 2159 gfx::OverlayTransform plane_transform,
2144 unsigned overlay_texture_id, 2160 unsigned overlay_texture_id,
2145 const gfx::Rect& display_bounds, 2161 const gfx::Rect& display_bounds,
2146 const gfx::RectF& uv_rect)); 2162 const gfx::RectF& uv_rect));
2147 }; 2163 };
2148 2164
2149 TEST_F(GLRendererTest, OverlaySyncTokensAreProcessed) { 2165 TEST_F(GLRendererTest, OverlaySyncTokensAreProcessed) {
2150 scoped_ptr<WaitSyncTokenCountingContext> context_owned( 2166 std::unique_ptr<WaitSyncTokenCountingContext> context_owned(
2151 new WaitSyncTokenCountingContext); 2167 new WaitSyncTokenCountingContext);
2152 WaitSyncTokenCountingContext* context = context_owned.get(); 2168 WaitSyncTokenCountingContext* context = context_owned.get();
2153 2169
2154 MockOverlayScheduler overlay_scheduler; 2170 MockOverlayScheduler overlay_scheduler;
2155 scoped_refptr<TestContextProvider> context_provider = 2171 scoped_refptr<TestContextProvider> context_provider =
2156 TestContextProvider::Create(std::move(context_owned)); 2172 TestContextProvider::Create(std::move(context_owned));
2157 context_provider->support()->SetScheduleOverlayPlaneCallback(base::Bind( 2173 context_provider->support()->SetScheduleOverlayPlaneCallback(base::Bind(
2158 &MockOverlayScheduler::Schedule, base::Unretained(&overlay_scheduler))); 2174 &MockOverlayScheduler::Schedule, base::Unretained(&overlay_scheduler)));
2159 2175
2160 FakeOutputSurfaceClient output_surface_client; 2176 FakeOutputSurfaceClient output_surface_client;
2161 scoped_ptr<OutputSurface> output_surface( 2177 std::unique_ptr<OutputSurface> output_surface(
2162 FakeOutputSurface::Create3d(context_provider)); 2178 FakeOutputSurface::Create3d(context_provider));
2163 CHECK(output_surface->BindToClient(&output_surface_client)); 2179 CHECK(output_surface->BindToClient(&output_surface_client));
2164 2180
2165 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 2181 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager(
2166 new TestSharedBitmapManager()); 2182 new TestSharedBitmapManager());
2167 scoped_ptr<ResourceProvider> resource_provider = FakeResourceProvider::Create( 2183 std::unique_ptr<ResourceProvider> resource_provider =
2168 output_surface.get(), shared_bitmap_manager.get()); 2184 FakeResourceProvider::Create(output_surface.get(),
2169 scoped_ptr<TextureMailboxDeleter> mailbox_deleter( 2185 shared_bitmap_manager.get());
2186 std::unique_ptr<TextureMailboxDeleter> mailbox_deleter(
2170 new TextureMailboxDeleter(base::ThreadTaskRunnerHandle::Get())); 2187 new TextureMailboxDeleter(base::ThreadTaskRunnerHandle::Get()));
2171 2188
2172 RendererSettings settings; 2189 RendererSettings settings;
2173 FakeRendererClient renderer_client; 2190 FakeRendererClient renderer_client;
2174 FakeRendererGL renderer(&renderer_client, &settings, output_surface.get(), 2191 FakeRendererGL renderer(&renderer_client, &settings, output_surface.get(),
2175 resource_provider.get(), mailbox_deleter.get()); 2192 resource_provider.get(), mailbox_deleter.get());
2176 2193
2177 SingleOverlayOnTopProcessor* processor = 2194 SingleOverlayOnTopProcessor* processor =
2178 new SingleOverlayOnTopProcessor(output_surface.get()); 2195 new SingleOverlayOnTopProcessor(output_surface.get());
2179 processor->Initialize(); 2196 processor->Initialize();
2180 renderer.SetOverlayProcessor(processor); 2197 renderer.SetOverlayProcessor(processor);
2181 2198
2182 gfx::Rect viewport_rect(1, 1); 2199 gfx::Rect viewport_rect(1, 1);
2183 RenderPass* root_pass = 2200 RenderPass* root_pass =
2184 AddRenderPass(&render_passes_in_draw_order_, RenderPassId(1, 0), 2201 AddRenderPass(&render_passes_in_draw_order_, RenderPassId(1, 0),
2185 viewport_rect, gfx::Transform()); 2202 viewport_rect, gfx::Transform());
2186 root_pass->has_transparent_background = false; 2203 root_pass->has_transparent_background = false;
2187 2204
2188 gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0, 2205 gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0,
2189 gpu::CommandBufferId::FromUnsafeValue(0x123), 29); 2206 gpu::CommandBufferId::FromUnsafeValue(0x123), 29);
2190 TextureMailbox mailbox = 2207 TextureMailbox mailbox =
2191 TextureMailbox(gpu::Mailbox::Generate(), sync_token, GL_TEXTURE_2D, 2208 TextureMailbox(gpu::Mailbox::Generate(), sync_token, GL_TEXTURE_2D,
2192 gfx::Size(256, 256), true, false); 2209 gfx::Size(256, 256), true, false);
2193 scoped_ptr<SingleReleaseCallbackImpl> release_callback = 2210 std::unique_ptr<SingleReleaseCallbackImpl> release_callback =
2194 SingleReleaseCallbackImpl::Create(base::Bind(&MailboxReleased)); 2211 SingleReleaseCallbackImpl::Create(base::Bind(&MailboxReleased));
2195 ResourceId resource_id = resource_provider->CreateResourceFromTextureMailbox( 2212 ResourceId resource_id = resource_provider->CreateResourceFromTextureMailbox(
2196 mailbox, std::move(release_callback)); 2213 mailbox, std::move(release_callback));
2197 bool premultiplied_alpha = false; 2214 bool premultiplied_alpha = false;
2198 bool flipped = false; 2215 bool flipped = false;
2199 bool nearest_neighbor = false; 2216 bool nearest_neighbor = false;
2200 float vertex_opacity[4] = {1.0f, 1.0f, 1.0f, 1.0f}; 2217 float vertex_opacity[4] = {1.0f, 1.0f, 1.0f, 1.0f};
2201 gfx::PointF uv_top_left(0, 0); 2218 gfx::PointF uv_top_left(0, 0);
2202 gfx::PointF uv_bottom_right(1, 1); 2219 gfx::PointF uv_bottom_right(1, 1);
2203 2220
(...skipping 13 matching lines...) Expand all
2217 EXPECT_CALL(overlay_scheduler, 2234 EXPECT_CALL(overlay_scheduler,
2218 Schedule(1, gfx::OVERLAY_TRANSFORM_NONE, _, viewport_rect, 2235 Schedule(1, gfx::OVERLAY_TRANSFORM_NONE, _, viewport_rect,
2219 BoundingRect(uv_top_left, uv_bottom_right))).Times(1); 2236 BoundingRect(uv_top_left, uv_bottom_right))).Times(1);
2220 2237
2221 renderer.DrawFrame(&render_passes_in_draw_order_, 1.f, viewport_rect, 2238 renderer.DrawFrame(&render_passes_in_draw_order_, 1.f, viewport_rect,
2222 viewport_rect, false); 2239 viewport_rect, false);
2223 } 2240 }
2224 2241
2225 } // namespace 2242 } // namespace
2226 } // namespace cc 2243 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/gl_renderer.cc ('k') | cc/output/output_surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698