OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/output/gl_renderer.h" | 5 #include "cc/output/gl_renderer.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
840 .Times(1); | 840 .Times(1); |
841 EXPECT_CALL(*context, clear(_)).Times(AnyNumber()); | 841 EXPECT_CALL(*context, clear(_)).Times(AnyNumber()); |
842 renderer.DrawFrame(&render_passes_in_draw_order_, | 842 renderer.DrawFrame(&render_passes_in_draw_order_, |
843 1.f, | 843 1.f, |
844 viewport_rect, | 844 viewport_rect, |
845 viewport_rect, | 845 viewport_rect, |
846 false); | 846 false); |
847 Mock::VerifyAndClearExpectations(context); | 847 Mock::VerifyAndClearExpectations(context); |
848 } | 848 } |
849 | 849 |
850 class VisibilityChangeIsLastCallTrackingContext | |
851 : public TestWebGraphicsContext3D { | |
852 public: | |
853 VisibilityChangeIsLastCallTrackingContext() | |
854 : last_call_was_set_visibility_(false) {} | |
855 | |
856 // TestWebGraphicsContext3D methods. | |
857 void flush() override { last_call_was_set_visibility_ = false; } | |
858 void deleteTexture(GLuint) override { last_call_was_set_visibility_ = false; } | |
859 void deleteFramebuffer(GLuint) override { | |
860 last_call_was_set_visibility_ = false; | |
861 } | |
862 void deleteQueryEXT(GLuint) override { | |
863 last_call_was_set_visibility_ = false; | |
864 } | |
865 void deleteRenderbuffer(GLuint) override { | |
866 last_call_was_set_visibility_ = false; | |
867 } | |
868 | |
869 // Methods added for test. | |
870 void set_last_call_was_visibility(bool visible) { | |
871 DCHECK(last_call_was_set_visibility_ == false); | |
872 last_call_was_set_visibility_ = true; | |
873 } | |
874 bool last_call_was_set_visibility() const { | |
875 return last_call_was_set_visibility_; | |
876 } | |
877 | |
878 private: | |
879 bool last_call_was_set_visibility_; | |
880 }; | |
881 | |
882 TEST_F(GLRendererTest, VisibilityChangeIsLastCall) { | |
883 scoped_ptr<VisibilityChangeIsLastCallTrackingContext> context_owned( | |
884 new VisibilityChangeIsLastCallTrackingContext); | |
885 VisibilityChangeIsLastCallTrackingContext* context = context_owned.get(); | |
886 | |
887 scoped_refptr<TestContextProvider> provider = | |
888 TestContextProvider::Create(context_owned.Pass()); | |
889 | |
890 provider->support()->SetSurfaceVisibleCallback(base::Bind( | |
891 &VisibilityChangeIsLastCallTrackingContext::set_last_call_was_visibility, | |
892 base::Unretained(context))); | |
893 | |
894 FakeOutputSurfaceClient output_surface_client; | |
895 scoped_ptr<OutputSurface> output_surface( | |
896 FakeOutputSurface::Create3d(provider)); | |
897 CHECK(output_surface->BindToClient(&output_surface_client)); | |
898 | |
899 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( | |
900 new TestSharedBitmapManager()); | |
901 scoped_ptr<ResourceProvider> resource_provider = FakeResourceProvider::Create( | |
902 output_surface.get(), shared_bitmap_manager.get()); | |
903 | |
904 RendererSettings settings; | |
905 FakeRendererClient renderer_client; | |
906 FakeRendererGL renderer(&renderer_client, | |
907 &settings, | |
908 output_surface.get(), | |
909 resource_provider.get()); | |
910 | |
911 gfx::Rect viewport_rect(1, 1); | |
912 AddRenderPass(&render_passes_in_draw_order_, | |
913 RenderPassId(1, 0), | |
914 viewport_rect, | |
915 gfx::Transform()); | |
916 | |
917 // Ensure that the call to SetSurfaceVisible is the last call issue to the | |
918 // GPU process, after glFlush is called, and after the RendererClient's | |
919 // SetManagedMemoryPolicy is called. Plumb this tracking between both the | |
920 // RenderClient and the Context by giving them both a pointer to a variable on | |
921 // the stack. | |
922 renderer.SetVisible(true); | |
923 renderer.DrawFrame(&render_passes_in_draw_order_, | |
924 1.f, | |
925 viewport_rect, | |
926 viewport_rect, | |
927 false); | |
928 renderer.SetVisible(false); | |
929 EXPECT_TRUE(context->last_call_was_set_visibility()); | |
930 } | |
931 | |
932 class TextureStateTrackingContext : public TestWebGraphicsContext3D { | 850 class TextureStateTrackingContext : public TestWebGraphicsContext3D { |
933 public: | 851 public: |
934 TextureStateTrackingContext() : active_texture_(GL_INVALID_ENUM) { | 852 TextureStateTrackingContext() : active_texture_(GL_INVALID_ENUM) { |
935 test_capabilities_.gpu.egl_image_external = true; | 853 test_capabilities_.gpu.egl_image_external = true; |
936 } | 854 } |
937 | 855 |
938 MOCK_METHOD1(waitSyncToken, void(const GLbyte* sync_token)); | 856 MOCK_METHOD1(waitSyncToken, void(const GLbyte* sync_token)); |
939 MOCK_METHOD3(texParameteri, void(GLenum target, GLenum pname, GLint param)); | 857 MOCK_METHOD3(texParameteri, void(GLenum target, GLenum pname, GLint param)); |
940 MOCK_METHOD4(drawElements, | 858 MOCK_METHOD4(drawElements, |
941 void(GLenum mode, GLsizei count, GLenum type, GLintptr offset)); | 859 void(GLenum mode, GLsizei count, GLenum type, GLintptr offset)); |
(...skipping 1289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2231 EXPECT_CALL(overlay_scheduler, | 2149 EXPECT_CALL(overlay_scheduler, |
2232 Schedule(1, gfx::OVERLAY_TRANSFORM_NONE, _, viewport_rect, | 2150 Schedule(1, gfx::OVERLAY_TRANSFORM_NONE, _, viewport_rect, |
2233 BoundingRect(uv_top_left, uv_bottom_right))).Times(1); | 2151 BoundingRect(uv_top_left, uv_bottom_right))).Times(1); |
2234 | 2152 |
2235 renderer.DrawFrame(&render_passes_in_draw_order_, 1.f, viewport_rect, | 2153 renderer.DrawFrame(&render_passes_in_draw_order_, 1.f, viewport_rect, |
2236 viewport_rect, false); | 2154 viewport_rect, false); |
2237 } | 2155 } |
2238 | 2156 |
2239 } // namespace | 2157 } // namespace |
2240 } // namespace cc | 2158 } // namespace cc |
OLD | NEW |